Skip to content

Commit a3ac5d1

Browse files
Merge branch 'release/1.4.4'
2 parents 58f836b + 72fea8c commit a3ac5d1

File tree

18 files changed

+107
-77
lines changed

18 files changed

+107
-77
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,35 @@ jobs:
88
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
99
steps:
1010
- uses: actions/checkout@v2
11-
- uses: actions/setup-java@v1
11+
with:
12+
fetch-depth: 0
13+
- uses: actions/setup-java@v2
1214
with:
1315
java-version: 11
14-
- uses: actions/cache@v2
16+
distribution: 'temurin'
17+
cache: 'maven'
18+
- name: Cache SonarCloud packages
19+
uses: actions/cache@v2
1520
with:
16-
path: ~/.m2/repository
17-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
18-
restore-keys: |
19-
${{ runner.os }}-maven-
21+
path: ~/.sonar/cache
22+
key: ${{ runner.os }}-sonar
23+
restore-keys: ${{ runner.os }}-sonar
2024
- name: Ensure to use tagged version
2125
if: startsWith(github.ref, 'refs/tags/')
2226
run: mvn versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/}
2327
- name: Build and Test
2428
id: buildAndTest
25-
run: mvn -B clean install jacoco:report -Pcoverage,dependency-check
29+
run: >
30+
mvn -B verify
31+
jacoco:report
32+
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
33+
-Pcoverage,dependency-check
34+
-Dsonar.projectKey=cryptomator_siv-mode
35+
-Dsonar.organization=cryptomator
36+
-Dsonar.host.url=https://sonarcloud.io
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
39+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2640
- name: Upload code coverage report
2741
id: codacyCoverageReporter
2842
run: bash <(curl -Ls https://coverage.codacy.com/get.sh)

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ jobs:
1818
- uses: actions/checkout@v2
1919
with:
2020
fetch-depth: 2
21-
- uses: actions/setup-java@v1
21+
- uses: actions/setup-java@v2
2222
with:
2323
java-version: 11
24-
- uses: actions/cache@v2
25-
with:
26-
path: ~/.m2/repository
27-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
28-
restore-keys: |
29-
${{ runner.os }}-maven-
24+
distribution: 'temurin'
25+
cache: 'maven'
3026
- name: Initialize CodeQL
3127
uses: github/codeql-action/init@v1
3228
with:

.github/workflows/publish-central.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ jobs:
1313
- uses: actions/checkout@v2
1414
with:
1515
ref: "refs/tags/${{ github.event.inputs.tag }}"
16-
- uses: actions/setup-java@v1
16+
- uses: actions/setup-java@v2
1717
with:
1818
java-version: 11
19+
distribution: 'temurin'
20+
cache: 'maven'
1921
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
2022
server-username: MAVEN_USERNAME # env variable for username in deploy
2123
server-password: MAVEN_PASSWORD # env variable for token in deploy
2224
gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
2325
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
24-
- uses: actions/cache@v2
25-
with:
26-
path: ~/.m2/repository
27-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
28-
restore-keys: |
29-
${{ runner.os }}-maven-
3026
- name: Enforce project version ${{ github.event.inputs.tag }}
3127
run: mvn versions:set -B -DnewVersion=${{ github.event.inputs.tag }}
3228
- name: Deploy

.github/workflows/publish-github.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@ jobs:
88
if: startsWith(github.ref, 'refs/tags/') # only allow publishing tagged versions
99
steps:
1010
- uses: actions/checkout@v2
11-
- uses: actions/setup-java@v1
11+
- uses: actions/setup-java@v2
1212
with:
1313
java-version: 11
14+
distribution: 'temurin'
15+
cache: 'maven'
1416
gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
1517
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
16-
- uses: actions/cache@v2
17-
with:
18-
path: ~/.m2/repository
19-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
20-
restore-keys: |
21-
${{ runner.os }}-maven-
2218
- name: Enforce project version ${{ github.event.release.tag_name }}
2319
run: mvn versions:set -B -DnewVersion=${{ github.event.release.tag_name }}
2420
- name: Deploy

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Java RFC 5297 SIV Authenticated Encryption
22

33
[![Build](https://github.com/cryptomator/siv-mode/workflows/Build/badge.svg)](https://github.com/cryptomator/siv-mode/actions?query=workflow%3ABuild)
4-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/8b274788dab046259a40e56688236790)](https://www.codacy.com/gh/cryptomator/siv-mode/dashboard)
5-
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/8b274788dab046259a40e56688236790)](https://www.codacy.com/gh/cryptomator/siv-mode/dashboard)
6-
[![Known Vulnerabilities](https://snyk.io/test/github/cryptomator/siv-mode/badge.svg)](https://snyk.io/test/github/cryptomator/siv-mode)
4+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cryptomator_siv-mode&metric=alert_status)](https://sonarcloud.io/dashboard?id=cryptomator_siv-mode)
5+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=cryptomator_siv-mode&metric=coverage)](https://sonarcloud.io/dashboard?id=cryptomator_siv-mode)
6+
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=cryptomator_siv-mode&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=cryptomator_siv-mode)
77
[![Maven Central](https://img.shields.io/maven-central/v/org.cryptomator/siv-mode.svg?maxAge=86400)](https://repo1.maven.org/maven2/org/cryptomator/siv-mode/)
88
[![Javadocs](http://www.javadoc.io/badge/org.cryptomator/siv-mode.svg)](http://www.javadoc.io/doc/org.cryptomator/siv-mode)
99

pom.xml

Lines changed: 14 additions & 14 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.4.3</version>
6+
<version>1.4.4</version>
77

88
<name>SIV Mode</name>
99
<description>RFC 5297 SIV mode: deterministic authenticated encryption</description>
@@ -37,14 +37,14 @@
3737
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3838

3939
<!-- dependencies -->
40-
<bouncycastle.version>1.69</bouncycastle.version>
40+
<bouncycastle.version>1.70</bouncycastle.version>
4141

4242
<!-- test dependencies -->
43-
<junit.version>5.7.2</junit.version>
44-
<mockito.version>3.11.2</mockito.version>
45-
<jmh.version>1.32</jmh.version>
43+
<junit.version>5.8.2</junit.version>
44+
<mockito.version>3.12.4</mockito.version>
45+
<jmh.version>1.34</jmh.version>
4646
<hamcrest.version>2.2</hamcrest.version>
47-
<guava.version>30.1.1-jre</guava.version>
47+
<guava.version>31.0.1-jre</guava.version>
4848
</properties>
4949

5050
<dependencies>
@@ -100,7 +100,7 @@
100100
<plugin>
101101
<groupId>org.apache.maven.plugins</groupId>
102102
<artifactId>maven-enforcer-plugin</artifactId>
103-
<version>3.0.0-M3</version>
103+
<version>3.0.0</version>
104104
<executions>
105105
<execution>
106106
<id>enforce-java</id>
@@ -120,7 +120,7 @@
120120
</plugin>
121121
<plugin>
122122
<artifactId>maven-compiler-plugin</artifactId>
123-
<version>3.8.1</version>
123+
<version>3.9.0</version>
124124
<configuration>
125125
<release>8</release>
126126
<encoding>UTF-8</encoding>
@@ -150,7 +150,7 @@
150150
</plugin>
151151
<plugin>
152152
<artifactId>maven-jar-plugin</artifactId>
153-
<version>3.2.0</version>
153+
<version>3.2.2</version>
154154
<configuration>
155155
<archive>
156156
<manifestEntries>
@@ -174,7 +174,7 @@
174174
</plugin>
175175
<plugin>
176176
<artifactId>maven-javadoc-plugin</artifactId>
177-
<version>3.3.0</version>
177+
<version>3.3.1</version>
178178
<executions>
179179
<execution>
180180
<id>attach-javadocs</id>
@@ -235,7 +235,7 @@
235235
<plugin>
236236
<groupId>org.owasp</groupId>
237237
<artifactId>dependency-check-maven</artifactId>
238-
<version>6.2.2</version>
238+
<version>6.5.3</version>
239239
<configuration>
240240
<cveValidForHours>24</cveValidForHours>
241241
<failBuildOnCVSS>0</failBuildOnCVSS>
@@ -279,7 +279,7 @@
279279
</build>
280280
</profile>
281281

282-
<profile>
282+
<profile>
283283
<id>sign</id>
284284
<build>
285285
<plugins>
@@ -312,7 +312,7 @@
312312
<repository>
313313
<id>ossrh</id>
314314
<name>Maven Central</name>
315-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
315+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
316316
</repository>
317317
</distributionManagement>
318318
<build>
@@ -324,7 +324,7 @@
324324
<extensions>true</extensions>
325325
<configuration>
326326
<serverId>ossrh</serverId>
327-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
327+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
328328
<autoReleaseAfterClose>true</autoReleaseAfterClose>
329329
</configuration>
330330
</plugin>

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,17 @@ final class JceAesCtrComputer implements SivMode.CtrComputer {
1919
private final ThreadLocal<Cipher> threadLocalCipher;
2020

2121
public JceAesCtrComputer(final Provider jceSecurityProvider) {
22-
this.threadLocalCipher = new ThreadLocal<Cipher>(){
23-
@Override
24-
protected Cipher initialValue() {
25-
try {
26-
if (jceSecurityProvider == null) {
27-
return Cipher.getInstance("AES/CTR/NoPadding");
28-
} else {
29-
return Cipher.getInstance("AES/CTR/NoPadding", jceSecurityProvider);
30-
}
31-
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
32-
throw new IllegalStateException("AES/CTR/NoPadding not available on this platform.", e);
22+
this.threadLocalCipher = ThreadLocals.withInitial(() -> {
23+
try {
24+
if (jceSecurityProvider == null) {
25+
return Cipher.getInstance("AES/CTR/NoPadding");
26+
} else {
27+
return Cipher.getInstance("AES/CTR/NoPadding", jceSecurityProvider);
3328
}
29+
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
30+
throw new IllegalStateException("AES/CTR/NoPadding not available on this platform.", e);
3431
}
35-
};
32+
});
3633
}
3734

3835
@Override

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public SivMode(final Provider jceSecurityProvider) {
6060
* @param cipherFactory A factory method creating a Blockcipher.get(). Must use a block size of 128 bits (16 bytes).
6161
*/
6262
public SivMode(final BlockCipherFactory cipherFactory) {
63-
this(ThreadLocals.withInitial(() -> cipherFactory.create()));
63+
this(ThreadLocals.withInitial(cipherFactory::create));
6464
}
6565

6666
private SivMode(final ThreadLocal<BlockCipher> threadLocalCipher) {
@@ -83,6 +83,9 @@ private SivMode(final ThreadLocal<BlockCipher> threadLocalCipher, final CtrCompu
8383
*/
8484
@FunctionalInterface
8585
public interface BlockCipherFactory {
86+
/**
87+
* @return New {@link BlockCipher} instance
88+
*/
8689
BlockCipher create();
8790
}
8891

@@ -134,7 +137,6 @@ public byte[] encrypt(byte[] ctrKey, byte[] macKey, byte[] plaintext, byte[]...
134137
throw new IllegalArgumentException("Plaintext is too long");
135138
}
136139

137-
assert plaintext.length + 15 < Integer.MAX_VALUE;
138140
final byte[] iv = s2v(macKey, plaintext, associatedData);
139141
final byte[] ciphertext = computeCtr(plaintext, ctrKey, iv);
140142

@@ -190,9 +192,6 @@ public byte[] decrypt(byte[] ctrKey, byte[] macKey, byte[] ciphertext, byte[]...
190192

191193
final byte[] iv = Arrays.copyOf(ciphertext, 16);
192194
final byte[] actualCiphertext = Arrays.copyOfRange(ciphertext, 16, ciphertext.length);
193-
194-
assert actualCiphertext.length == ciphertext.length - 16;
195-
assert actualCiphertext.length + 15 < Integer.MAX_VALUE;
196195
final byte[] plaintext = computeCtr(actualCiphertext, ctrKey, iv);
197196
final byte[] control = s2v(macKey, plaintext, associatedData);
198197

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
import java.util.function.Supplier;
44

5+
/**
6+
* Shim for Android 7.x
7+
* @see <a href="https://github.com/cryptomator/siv-mode/issues/17">Issue 17</a>
8+
*/
59
class ThreadLocals {
610

11+
private ThreadLocals() {
12+
}
13+
714
static <S> ThreadLocal<S> withInitial(Supplier<S> supplier) {
815
// ThreadLocal.withInitial is unavailable on Android 7.x
916
return new ThreadLocal<S>() {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
*/
88
public class UnauthenticCiphertextException extends BadPaddingException {
99

10+
/**
11+
* Constructs a UnauthenticCiphertextException with the specified
12+
* detail message.
13+
*
14+
* @param message the detail message.
15+
*/
1016
public UnauthenticCiphertextException(String message) {
1117
super(message);
1218
}

0 commit comments

Comments
 (0)