Skip to content

Commit 440ebc1

Browse files
Merge branch 'release/1.3.2'
2 parents ed1b43b + da14237 commit 440ebc1

14 files changed

+9136
-285473
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
dist: bionic
12
language: java
23
sudo: false
34
jdk:
4-
- oraclejdk9
5+
- openjdk13
56
env:
67
global:
78
- secure: "dYjMF9qjmv85TdhSauKTfU+5Lt7q1ZpOLfpYuRz1yQF3Y+Ru/5/2Ucb4efgzLNRE4u9KGM7MJr1YRH3qV5OyxBqfKZ9ORq5noQbukfKyDDjS7oRn1HiHWG5ZWs2Ja35z0a5BK8+h5OF8kA1C5dmQ/tePKP5JAZZlhwnBolkwUXTJXAvppSBpl2/m/0KBJoHMJYxiY4DJ8grf3OWWhsWO9YMeJAov+N4GFJy9J85tbKvb4XgJITBPrSmK981JS67sddjelaodaolF5vewoW7KfxG87SMRr6xOno0Qy1td2aiUXMt10w2eI2FTluC9Fp0UJ7z3rMEGcHGFjaPXk+bLOAwGwoJq3xt3mA91Y7N1aQuOnWL01K94c7rw9yUU+HUfrUz1iPVEFD36FkwZNFYXHPL8JMuSL6bIafaiu5Nd95QZP7vET3It07zBc/KcV2izdk9aXOOPumKmw/VpzunWfYF2we53uuN1tvzBJ5yxuHjsoteTkbdoYpIinAHI3QfREwwRX19Q4jjJU9GTT12n/7GQopXzuytK6M6xlltVVD/KffmdyiqqWA1u391t2HcgmX6TyvHS4jNy9hbJ+/zfqwZG+NQFSPz99LAiGpLYmctY3A5oofM16x07Tofk/HvbCMCjuMsk0zLgd1m915TFJ5ZUQ510ohrM5IBSdUJ6NUc=" # CODACY_PROJECT_TOKEN
8-
- secure: "PQ/K3HeqG52aDOel6ROp8vJo1ybfnwjdYKewKssWQwsb38BIPe68RKgJ06mOeyacrf+i1BkJgKspTcwLeMqfRNP+mxAg3WBccG6dwZy3LdeaRBrcGQhiBLgK8RthIFxOPoY4pm2iiUQdcakWXHIqz62as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lub7LXBsArgTLT1Aw0EzyX+wnWcVM/QYNSMj+TUlnWg+mPdZemjyBkvoyw9UhNpvtdK/AdGUpu1oS146Q53PwXb4ROd3n57116ZJbUwhYfThFseQctj3gunCjDJId0uSwkyeowrolDRsCgPfZ1YQYGLQi1PEpesfTvm4PVYUfx9Jc=" # BINTRAY_API_KEY
910
install:
1011
- curl -o $HOME/.m2/settings.xml https://gist.githubusercontent.com/cryptobot/cf5fbd909c4782aaeeeb7c7f4a1a43da/raw/e60ee486e34ee0c79f89f947abe2c83b4290c6bb/settings.xml
1112
- mvn dependency:go-offline -Pdependency-check,coverage,release
@@ -14,7 +15,7 @@ before_script:
1415
script:
1516
- mvn clean test jacoco:report verify -Pcoverage
1617
after_success:
17-
- curl -o ~/codacy-coverage-reporter.jar https://oss.sonatype.org/service/local/repositories/releases/content/com/codacy/codacy-coverage-reporter/4.0.2/codacy-coverage-reporter-4.0.2-assembly.jar
18+
- curl -o ~/codacy-coverage-reporter.jar https://oss.sonatype.org/service/local/repositories/releases/content/com/codacy/codacy-coverage-reporter/7.0.0/codacy-coverage-reporter-7.0.0-assembly.jar
1819
- $JAVA_HOME/bin/java -jar ~/codacy-coverage-reporter.jar report -l Java -r target/site/jacoco/jacoco.xml
1920
cache:
2021
directories:
@@ -27,4 +28,4 @@ deploy:
2728
repo: cryptomator/siv-mode
2829
tags: true
2930
after_deploy:
30-
- "echo '{\"close\": \"1\"}' | curl -v -X POST -u cryptobot:${BINTRAY_API_KEY} https://api.bintray.com/maven_central_sync/cryptomator/maven/siv-mode/versions/${TRAVIS_TAG}"
31+
- "echo '{\"close\": \"1\"}' | curl --max-time 10 -X POST -u cryptobot:${BINTRAY_API_KEY} https://api.bintray.com/maven_central_sync/cryptomator/maven/siv-mode/versions/${TRAVIS_TAG}"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ requires org.cryptomator.siv;
6262

6363
Because BouncyCastle classes are shaded, this library only depends on `java.base`.
6464

65+
## Building
66+
67+
This is a Maven project. To build it, run `mvn clean install`.
68+
69+
Requires JDK 9+ at build time due to JPMS support.
70+
6571
## License
6672
Distributed under the MIT X Consortium license. See the LICENSE file for more info.
6773

pom.xml

Lines changed: 93 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.cryptomator</groupId>
55
<artifactId>siv-mode</artifactId>
6-
<version>1.3.1</version>
6+
<version>1.3.2</version>
77

88
<name>SIV Mode</name>
99
<description>RFC 5297 SIV mode: deterministic authenticated encryption</description>
@@ -41,71 +41,119 @@
4141
<dependency>
4242
<groupId>org.bouncycastle</groupId>
4343
<artifactId>bcprov-jdk15on</artifactId>
44-
<version>1.60</version>
44+
<version>1.64</version>
4545
<!-- see maven-shade-plugin; we don't want this as a transitive dependency in other projects -->
4646
<optional>true</optional>
4747
</dependency>
4848

4949
<!-- Tests -->
5050
<dependency>
51-
<groupId>junit</groupId>
52-
<artifactId>junit</artifactId>
53-
<version>4.12</version>
51+
<groupId>org.junit.jupiter</groupId>
52+
<artifactId>junit-jupiter</artifactId>
53+
<version>5.6.0</version>
5454
<scope>test</scope>
5555
</dependency>
5656
<dependency>
5757
<groupId>org.mockito</groupId>
5858
<artifactId>mockito-core</artifactId>
59-
<version>2.16.0</version>
59+
<version>3.2.4</version>
60+
<scope>test</scope>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.hamcrest</groupId>
64+
<artifactId>hamcrest</artifactId>
65+
<version>2.2</version>
6066
<scope>test</scope>
6167
</dependency>
6268
<dependency>
6369
<groupId>com.google.guava</groupId>
6470
<artifactId>guava</artifactId>
65-
<version>24.0-jre</version>
71+
<version>28.2-jre</version>
6672
<scope>test</scope>
6773
</dependency>
6874
<dependency>
6975
<groupId>org.openjdk.jmh</groupId>
7076
<artifactId>jmh-core</artifactId>
71-
<version>1.20</version>
77+
<version>1.23</version>
7278
<scope>test</scope>
7379
</dependency>
7480
<dependency>
7581
<groupId>org.openjdk.jmh</groupId>
7682
<artifactId>jmh-generator-annprocess</artifactId>
77-
<version>1.20</version>
83+
<version>1.23</version>
7884
<scope>test</scope>
7985
</dependency>
8086
</dependencies>
8187

8288
<build>
8389
<plugins>
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-enforcer-plugin</artifactId>
93+
<version>3.0.0-M3</version>
94+
<executions>
95+
<execution>
96+
<id>enforce-java</id>
97+
<goals>
98+
<goal>enforce</goal>
99+
</goals>
100+
<configuration>
101+
<rules>
102+
<requireJavaVersion>
103+
<message>You need at least JDK 11.0.3 to build this project.</message>
104+
<version>[11.0.3,)</version>
105+
</requireJavaVersion>
106+
</rules>
107+
</configuration>
108+
</execution>
109+
</executions>
110+
</plugin>
84111
<plugin>
85112
<artifactId>maven-compiler-plugin</artifactId>
86-
<version>3.7.0</version>
113+
<version>3.8.1</version>
87114
<configuration>
88-
<source>1.7</source>
89-
<target>1.7</target>
90115
<release>7</release>
116+
<testRelease>8</testRelease>
91117
<encoding>UTF-8</encoding>
92118
<showWarnings>true</showWarnings>
93119
</configuration>
120+
<executions>
121+
<execution>
122+
<id>java9</id>
123+
<phase>compile</phase>
124+
<goals>
125+
<goal>compile</goal>
126+
</goals>
127+
<configuration>
128+
<release>9</release>
129+
<compileSourceRoots>
130+
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
131+
</compileSourceRoots>
132+
<multiReleaseOutput>true</multiReleaseOutput>
133+
</configuration>
134+
</execution>
135+
</executions>
136+
</plugin>
137+
<plugin>
138+
<groupId>org.apache.maven.plugins</groupId>
139+
<artifactId>maven-surefire-plugin</artifactId>
140+
<version>3.0.0-M4</version>
94141
</plugin>
95142
<plugin>
96143
<artifactId>maven-jar-plugin</artifactId>
97-
<version>3.0.2</version>
144+
<version>3.2.0</version>
98145
<configuration>
99146
<archive>
100147
<manifestEntries>
148+
<Multi-Release>true</Multi-Release>
101149
<Sealed>true</Sealed>
102150
</manifestEntries>
103151
</archive>
104152
</configuration>
105153
</plugin>
106154
<plugin>
107155
<artifactId>maven-shade-plugin</artifactId>
108-
<version>3.1.0</version>
156+
<version>3.2.2</version>
109157
<executions>
110158
<execution>
111159
<phase>package</phase>
@@ -132,51 +180,55 @@
132180
<filter>
133181
<artifact>*:*</artifact>
134182
<excludes>
183+
<exclude>META-INF/MANIFEST.MF</exclude>
135184
<exclude>META-INF/*.SF</exclude>
136185
<exclude>META-INF/*.DSA</exclude>
137186
<exclude>META-INF/*.RSA</exclude>
187+
<exclude>META-INF/services/**</exclude>
138188
</excludes>
139189
</filter>
140190
</filters>
141191
</configuration>
142192
</execution>
143193
</executions>
144194
</plugin>
145-
<plugin>
146-
<groupId>org.moditect</groupId>
147-
<artifactId>moditect-maven-plugin</artifactId>
148-
<version>1.0.0.Beta1</version>
149-
<executions>
150-
<execution>
151-
<id>add-module-infos</id>
152-
<phase>package</phase>
153-
<goals>
154-
<goal>add-module-info</goal>
155-
</goals>
156-
<configuration>
157-
<module>
158-
<moduleInfoSource>
159-
module org.cryptomator.siv {
160-
exports org.cryptomator.siv;
161-
}
162-
</moduleInfoSource>
163-
</module>
164-
</configuration>
165-
</execution>
166-
</executions>
167-
</plugin>
168195
</plugins>
169196
</build>
170197

171198
<profiles>
199+
<profile>
200+
<id>intellij</id>
201+
<!-- workaround for intellij bug: https://youtrack.jetbrains.com/issue/IDEA-85478 -->
202+
<activation>
203+
<activeByDefault>false</activeByDefault>
204+
<property>
205+
<name>idea.maven.embedder.version</name>
206+
</property>
207+
</activation>
208+
<build>
209+
<plugins>
210+
<plugin>
211+
<groupId>org.apache.maven.plugins</groupId>
212+
<artifactId>maven-compiler-plugin</artifactId>
213+
<version>3.8.1</version>
214+
<configuration>
215+
<release>8</release>
216+
<source>1.8</source>
217+
<target>1.8</target>
218+
</configuration>
219+
</plugin>
220+
</plugins>
221+
</build>
222+
</profile>
223+
172224
<profile>
173225
<id>dependency-check</id>
174226
<build>
175227
<plugins>
176228
<plugin>
177229
<groupId>org.owasp</groupId>
178230
<artifactId>dependency-check-maven</artifactId>
179-
<version>3.1.1</version>
231+
<version>5.3.0</version>
180232
<configuration>
181233
<cveValidForHours>24</cveValidForHours>
182234
<failBuildOnCVSS>0</failBuildOnCVSS>
@@ -200,7 +252,7 @@
200252
<plugin>
201253
<groupId>org.jacoco</groupId>
202254
<artifactId>jacoco-maven-plugin</artifactId>
203-
<version>0.8.0</version>
255+
<version>0.8.5</version>
204256
<executions>
205257
<execution>
206258
<id>prepare-agent</id>
@@ -226,7 +278,7 @@
226278
<plugins>
227279
<plugin>
228280
<artifactId>maven-source-plugin</artifactId>
229-
<version>3.0.1</version>
281+
<version>3.2.1</version>
230282
<executions>
231283
<execution>
232284
<id>attach-sources</id>
@@ -238,7 +290,7 @@
238290
</plugin>
239291
<plugin>
240292
<artifactId>maven-javadoc-plugin</artifactId>
241-
<version>3.0.0</version>
293+
<version>3.1.1</version>
242294
<executions>
243295
<execution>
244296
<id>attach-javadocs</id>

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
* Copyright (c) 2016 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

1111
import java.security.InvalidKeyException;
1212
import java.security.Key;
1313
import java.security.NoSuchAlgorithmException;
14+
import java.security.Provider;
1415

1516
import javax.crypto.Cipher;
1617
import javax.crypto.NoSuchPaddingException;
@@ -24,12 +25,12 @@
2425

2526
/**
2627
* Adapter class between BouncyCastle's {@link BlockCipher} and JCE's {@link Cipher} API.
27-
*
28+
*
2829
* <p>
2930
* As per contract of {@link BlockCipher#processBlock(byte[], int, byte[], int)}, this class is designed to encrypt or decrypt just <b>one single block</b> at a time.
3031
* JCE doesn't allow us to retrieve the plain cipher without a mode, so we explicitly request {@value #SINGLE_BLOCK_PLAIN_AES_JCE_CIPHER_NAME}.
3132
* This is by design, because we want the plain cipher for a single 128 bit block without any mode. We're not actually using ECB mode.
32-
*
33+
*
3334
* <p>
3435
* This is a package-private class only used to encrypt the 128 bit counter during SIV mode.
3536
*/
@@ -43,9 +44,17 @@ final class JceAesBlockCipher implements BlockCipher {
4344
private Key key;
4445
private int opmode;
4546

46-
public JceAesBlockCipher() {
47+
JceAesBlockCipher() {
48+
this(null);
49+
}
50+
51+
JceAesBlockCipher(Provider provider) {
4752
try {
48-
this.cipher = Cipher.getInstance(SINGLE_BLOCK_PLAIN_AES_JCE_CIPHER_NAME); // defaults to SunJCE but allows to configure different providers
53+
if(provider != null) {
54+
this.cipher = Cipher.getInstance(SINGLE_BLOCK_PLAIN_AES_JCE_CIPHER_NAME, provider);
55+
} else {
56+
this.cipher = Cipher.getInstance(SINGLE_BLOCK_PLAIN_AES_JCE_CIPHER_NAME); // defaults to SunJCE
57+
}
4958
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
5059
throw new IllegalStateException("Every implementation of the Java platform is required to support AES/ECB/NoPadding.");
5160
}

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
******************************************************************************/
1010

1111
import java.nio.ByteBuffer;
12+
import java.security.Provider;
1213
import java.util.Arrays;
1314

1415
import javax.crypto.IllegalBlockSizeException;
@@ -40,11 +41,24 @@ public final class SivMode {
4041
* @see #SivMode(BlockCipherFactory)
4142
*/
4243
public SivMode() {
44+
this((Provider) null);
45+
}
46+
47+
/**
48+
* 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.
51+
*
52+
* @param jceSecurityProvider to use to create the internal {@link javax.crypto.Cipher} instance
53+
*
54+
* @see #SivMode(BlockCipherFactory)
55+
*/
56+
public SivMode(final Provider jceSecurityProvider) {
4357
this(new BlockCipherFactory() {
4458

4559
@Override
4660
public BlockCipher create() {
47-
return new JceAesBlockCipher();
61+
return new JceAesBlockCipher(jceSecurityProvider);
4862
}
4963

5064
});
@@ -75,7 +89,7 @@ protected BlockCipher initialValue() {
7589
/**
7690
* Creates {@link BlockCipher}s.
7791
*/
78-
public static interface BlockCipherFactory {
92+
public interface BlockCipherFactory {
7993
BlockCipher create();
8094
}
8195

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Java implementation of RFC 5297 SIV Authenticated Encryption.
3+
* <p>
4+
* Use an instance of the {@link org.cryptomator.siv.SivMode} class to
5+
* {@link org.cryptomator.siv.SivMode#encrypt(javax.crypto.SecretKey, javax.crypto.SecretKey, byte[], byte[]...) encrypt} or
6+
* {@link org.cryptomator.siv.SivMode#decrypt(javax.crypto.SecretKey, javax.crypto.SecretKey, byte[], byte[]...) decrypt} data.
7+
*/
8+
package org.cryptomator.siv;

0 commit comments

Comments
 (0)