Skip to content

Commit bbad3ab

Browse files
updated JPMS and MR-JAR setup
make sure to include a MANIFEST.MF again fixed warnings logged when shading
1 parent de2c6c0 commit bbad3ab

File tree

3 files changed

+42
-43
lines changed

3 files changed

+42
-43
lines changed

pom.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164
<minimizeJar>true</minimizeJar>
165165
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
166166
<createDependencyReducedPom>false</createDependencyReducedPom>
167-
<createSourcesJar>false</createSourcesJar>
167+
<createSourcesJar>true</createSourcesJar>
168+
<shadeSourcesContent>true</shadeSourcesContent>
168169
<artifactSet>
169170
<includes>
170171
<include>org.bouncycastle:bcprov-jdk15on</include>
@@ -178,13 +179,9 @@
178179
</relocations>
179180
<filters>
180181
<filter>
181-
<artifact>*:*</artifact>
182+
<artifact>org.bouncycastle:bcprov-jdk15on</artifact>
182183
<excludes>
183-
<exclude>META-INF/MANIFEST.MF</exclude>
184-
<exclude>META-INF/*.SF</exclude>
185-
<exclude>META-INF/*.DSA</exclude>
186-
<exclude>META-INF/*.RSA</exclude>
187-
<exclude>META-INF/services/**</exclude>
184+
<exclude>META-INF/**</exclude>
188185
</excludes>
189186
</filter>
190187
</filters>
@@ -282,6 +279,7 @@
282279
<executions>
283280
<execution>
284281
<id>attach-sources</id>
282+
<phase>prepare-package</phase>
285283
<goals>
286284
<goal>jar-no-fork</goal>
287285
</goals>
@@ -299,6 +297,9 @@
299297
</goals>
300298
</execution>
301299
</executions>
300+
<configuration>
301+
<release>7</release>
302+
</configuration>
302303
</plugin>
303304
</plugins>
304305
</build>

src/main/java/org/cryptomator/siv/SivMode.java

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,24 @@
33
* Copyright (c) 2015 Sebastian Stenzel
44
* This file is licensed under the terms of the MIT license.
55
* See the LICENSE.txt file for more info.
6-
*
6+
*
77
* Contributors:
88
* Sebastian Stenzel - initial API and implementation
99
******************************************************************************/
1010

11-
import java.nio.ByteBuffer;
12-
import java.security.Provider;
13-
import java.util.Arrays;
14-
15-
import javax.crypto.IllegalBlockSizeException;
16-
import javax.crypto.SecretKey;
17-
1811
import org.bouncycastle.crypto.BlockCipher;
1912
import org.bouncycastle.crypto.CipherParameters;
2013
import org.bouncycastle.crypto.Mac;
21-
import org.bouncycastle.crypto.engines.AESLightEngine;
2214
import org.bouncycastle.crypto.macs.CMac;
2315
import org.bouncycastle.crypto.paddings.ISO7816d4Padding;
2416
import org.bouncycastle.crypto.params.KeyParameter;
2517

18+
import javax.crypto.IllegalBlockSizeException;
19+
import javax.crypto.SecretKey;
20+
import java.nio.ByteBuffer;
21+
import java.security.Provider;
22+
import java.util.Arrays;
23+
2624
/**
2725
* Implements the RFC 5297 SIV mode.
2826
*/
@@ -35,9 +33,9 @@ public final class SivMode {
3533

3634
/**
3735
* Creates an AES-SIV instance using JCE's cipher implementation, which should normally be the best choice.<br>
38-
*
39-
* For embedded systems, you might want to consider using {@link #SivMode(BlockCipherFactory)} with {@link AESLightEngine} instead.
40-
*
36+
* <p>
37+
* For embedded systems, you might want to consider using {@link #SivMode(BlockCipherFactory)} with BouncyCastle's {@code AESLightEngine} instead.
38+
*
4139
* @see #SivMode(BlockCipherFactory)
4240
*/
4341
public SivMode() {
@@ -46,11 +44,10 @@ public SivMode() {
4644

4745
/**
4846
* Creates an AES-SIV instance using a custom JCE's security provider<br>
49-
*
50-
* For embedded systems, you might want to consider using {@link #SivMode(BlockCipherFactory)} with {@link AESLightEngine} instead.
47+
* <p>
48+
* For embedded systems, you might want to consider using {@link #SivMode(BlockCipherFactory)} with BouncyCastle's {@code AESLightEngine} instead.
5149
*
5250
* @param jceSecurityProvider to use to create the internal {@link javax.crypto.Cipher} instance
53-
*
5451
* @see #SivMode(BlockCipherFactory)
5552
*/
5653
public SivMode(final Provider jceSecurityProvider) {
@@ -66,7 +63,7 @@ public BlockCipher create() {
6663

6764
/**
6865
* Creates an instance using a specific Blockcipher.get(). If you want to use AES, just use the default constructor.
69-
*
66+
*
7067
* @param cipherFactory A factory method creating a Blockcipher.get(). Must use a block size of 128 bits (16 bytes).
7168
*/
7269
public SivMode(final BlockCipherFactory cipherFactory) {
@@ -95,10 +92,10 @@ public interface BlockCipherFactory {
9592

9693
/**
9794
* Convenience method, if you are using the javax.crypto API. This is just a wrapper for {@link #encrypt(byte[], byte[], byte[], byte[]...)}.
98-
*
99-
* @param ctrKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
100-
* @param macKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
101-
* @param plaintext Your plaintext, which shall be encrypted.
95+
*
96+
* @param ctrKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
97+
* @param macKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
98+
* @param plaintext Your plaintext, which shall be encrypted.
10299
* @param associatedData Optional associated data, which gets authenticated but not encrypted.
103100
* @return IV + Ciphertext as a concatenated byte array.
104101
* @throws IllegalArgumentException if keys are invalid or {@link SecretKey#getEncoded()} is not supported.
@@ -119,10 +116,10 @@ public byte[] encrypt(SecretKey ctrKey, SecretKey macKey, byte[] plaintext, byte
119116

120117
/**
121118
* Encrypts plaintext using SIV mode. A block cipher defined by the constructor is being used.<br>
122-
*
123-
* @param ctrKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
124-
* @param macKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
125-
* @param plaintext Your plaintext, which shall be encrypted.
119+
*
120+
* @param ctrKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
121+
* @param macKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
122+
* @param plaintext Your plaintext, which shall be encrypted.
126123
* @param associatedData Optional associated data, which gets authenticated but not encrypted.
127124
* @return IV + Ciphertext as a concatenated byte array.
128125
* @throws IllegalArgumentException if the either of the two keys is of invalid length for the used {@link BlockCipher}.
@@ -148,15 +145,15 @@ public byte[] encrypt(byte[] ctrKey, byte[] macKey, byte[] plaintext, byte[]...
148145

149146
/**
150147
* Convenience method, if you are using the javax.crypto API. This is just a wrapper for {@link #decrypt(byte[], byte[], byte[], byte[]...)}.
151-
*
152-
* @param ctrKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
153-
* @param macKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
154-
* @param ciphertext Your cipehrtext, which shall be decrypted.
148+
*
149+
* @param ctrKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
150+
* @param macKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
151+
* @param ciphertext Your cipehrtext, which shall be decrypted.
155152
* @param associatedData Optional associated data, which needs to be authenticated during decryption.
156153
* @return Plaintext byte array.
157-
* @throws IllegalArgumentException If keys are invalid or {@link SecretKey#getEncoded()} is not supported.
154+
* @throws IllegalArgumentException If keys are invalid or {@link SecretKey#getEncoded()} is not supported.
158155
* @throws UnauthenticCiphertextException If the authentication failed, e.g. because ciphertext and/or associatedData are corrupted.
159-
* @throws IllegalBlockSizeException If the provided ciphertext is of invalid length.
156+
* @throws IllegalBlockSizeException If the provided ciphertext is of invalid length.
160157
*/
161158
public byte[] decrypt(SecretKey ctrKey, SecretKey macKey, byte[] ciphertext, byte[]... associatedData) throws UnauthenticCiphertextException, IllegalBlockSizeException {
162159
final byte[] ctrKeyBytes = ctrKey.getEncoded();
@@ -174,15 +171,15 @@ public byte[] decrypt(SecretKey ctrKey, SecretKey macKey, byte[] ciphertext, byt
174171

175172
/**
176173
* Decrypts ciphertext using SIV mode. A block cipher defined by the constructor is being used.<br>
177-
*
178-
* @param ctrKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
179-
* @param macKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
180-
* @param ciphertext Your ciphertext, which shall be encrypted.
174+
*
175+
* @param ctrKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
176+
* @param macKey SIV mode requires two separate keys. You can use one long key, which is splitted in half. See https://tools.ietf.org/html/rfc5297#section-2.2
177+
* @param ciphertext Your ciphertext, which shall be encrypted.
181178
* @param associatedData Optional associated data, which needs to be authenticated during decryption.
182179
* @return Plaintext byte array.
183-
* @throws IllegalArgumentException If the either of the two keys is of invalid length for the used {@link BlockCipher}.
180+
* @throws IllegalArgumentException If the either of the two keys is of invalid length for the used {@link BlockCipher}.
184181
* @throws UnauthenticCiphertextException If the authentication failed, e.g. because ciphertext and/or associatedData are corrupted.
185-
* @throws IllegalBlockSizeException If the provided ciphertext is of invalid length.
182+
* @throws IllegalBlockSizeException If the provided ciphertext is of invalid length.
186183
*/
187184
public byte[] decrypt(byte[] ctrKey, byte[] macKey, byte[] ciphertext, byte[]... associatedData) throws UnauthenticCiphertextException, IllegalBlockSizeException {
188185
if (ciphertext.length < 16) {

src/main/java9/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module org.cryptomator.siv {
22
exports org.cryptomator.siv;
3+
requires static org.bouncycastle.provider;
34
}

0 commit comments

Comments
 (0)