Skip to content
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c8f79ab
remove dependency on bouncycastle
overheadhunter Oct 24, 2025
c907ae7
performance optimizations
overheadhunter Oct 25, 2025
20a705f
clean up legacy code, simplify API
overheadhunter Oct 25, 2025
3841573
more cleanup
overheadhunter Oct 25, 2025
7c54f74
create `java.security.Provider`
overheadhunter Oct 25, 2025
a571750
implement CipherSpi
overheadhunter Nov 18, 2025
2f97464
in-situ `dbl`, `xor`, `xorend`
overheadhunter Nov 18, 2025
ca27a0f
use different in/out buffers for `cipher.doFinal`
overheadhunter Nov 18, 2025
945f27d
fix assertion
overheadhunter Nov 18, 2025
eb8ce70
avoid `Arrays.copyOfRange` for `xorend`
overheadhunter Nov 18, 2025
b619e23
nil out plaintext if decryption fails
overheadhunter Nov 18, 2025
36bdb8d
avoid copying data from input
overheadhunter Nov 18, 2025
1f90d6d
Merge branch 'develop' into feature/zero-deps
overheadhunter Nov 19, 2025
68fa9a0
bump version to 2.0.0-SNAPSHOT
overheadhunter Nov 19, 2025
0612845
new build workflow
overheadhunter Nov 19, 2025
5bcdf0a
update README.md
overheadhunter Nov 19, 2025
897420e
update changelog
overheadhunter Nov 19, 2025
6edd8c5
close input stream
overheadhunter Nov 19, 2025
4da3f20
deprecate 1.x `SivMode` API
overheadhunter Nov 19, 2025
f05b4d7
cleanup
overheadhunter Nov 19, 2025
513c4ff
fix javadoc issues
overheadhunter Nov 19, 2025
6d73307
show migration path in deprecation notice
overheadhunter Nov 19, 2025
d42ca05
update changelog
overheadhunter Nov 19, 2025
afd2cd2
add tests
overheadhunter Nov 19, 2025
4546454
fixed findings from code review
overheadhunter Nov 19, 2025
a456e7b
fixed findings from code review
overheadhunter Nov 19, 2025
b629ddf
Merge branch 'develop' into feature/zero-deps
overheadhunter Nov 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 97 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@ on:
push:
pull_request_target:
types: [labeled]

env:
JAVA_VERSION: 21

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
permissions:
id-token: write # Required for the attestations step
attestations: write # Required for the attestations step
outputs:
sha256: ${{ steps.checksums.outputs.sha256 }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-java@v5
with:
java-version: 21
distribution: 'zulu'
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v4
Expand All @@ -24,10 +31,10 @@ jobs:
restore-keys: ${{ runner.os }}-sonar
- name: Ensure to use tagged version
if: startsWith(github.ref, 'refs/tags/')
run: ./mvnw -B versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/}
run: ./mvnw versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/}
- name: Build and Test
run: >
./mvnw -B verify
./mvnw -B verify --no-transfer-progress
jacoco:report
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
-Pcoverage
Expand All @@ -37,10 +44,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: actions/upload-artifact@v5
with:
name: artifacts
path: target/*.jar
- name: Calculate Checksums
id: checksums
run: |
Expand All @@ -49,12 +52,93 @@ jobs:
shasum -a256 target/*.jar
echo EOF
} >> $GITHUB_OUTPUT
- name: Create Release
- name: Attest
if: startsWith(github.ref, 'refs/tags/')
uses: actions/attest-build-provenance@v3
with:
subject-path: |
target/*.jar
target/*.pom
- uses: actions/upload-artifact@v5
with:
name: artifacts
path: target/*.jar

deploy-central:
name: Deploy to Maven Central
runs-on: ubuntu-latest
permissions: {}
needs: [build]
if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]'))
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
cache: 'maven'
server-id: central
server-username: MAVEN_CENTRAL_USERNAME
server-password: MAVEN_CENTRAL_PASSWORD
- name: Verify project version matches tag
if: startsWith(github.ref, 'refs/tags/')
run: |
PROJECT_VERSION=$(./mvnw help:evaluate "-Dexpression=project.version" -q -DforceStdout)
test "$PROJECT_VERSION" = "${GITHUB_REF##*/}"
- name: Deploy to Maven Central
run: ./mvnw deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}

deploy-github:
name: Deploy to GitHub Packages
runs-on: ubuntu-latest
permissions:
packages: write # Required for the deploy to GitHub Packages step
needs: [build]
if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]'))
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'
cache: 'maven'
- name: Verify project version matches tag
if: startsWith(github.ref, 'refs/tags/')
run: |
PROJECT_VERSION=$(./mvnw help:evaluate "-Dexpression=project.version" -q -DforceStdout)
test "$PROJECT_VERSION" = "${GITHUB_REF##*/}"
- name: Deploy to GitHub Packages
run: ./mvnw deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}

release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # Required for the release step
needs: [build, deploy-central, deploy-github]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Create Release
uses: softprops/action-gh-release@v2
with:
prerelease: true
token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
generate_release_notes: true
body: |-
### Full Changelog
See [CHANGELOG.md](https://github.com/cryptomator/siv-mode/blob/develop/CHANGELOG.md).

### Maven Coordinates
```xml
<dependency>
Expand All @@ -66,8 +150,7 @@ jobs:

### Artifact Checksums
```txt
${{ steps.checksums.outputs.sha256 }}
${{ needs.build.outputs.sha256 }}
```

See [README.md](https://github.com/cryptomator/siv-mode/#reproducible-builds) section regarding reproducing this build.
generate_release_notes: true
See [README.md](https://github.com/cryptomator/siv-mode/#reproducible-builds) section regarding reproducing this build.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-java@v5
with:
java-version: 21
distribution: 'zulu'
distribution: 'temurin'
cache: 'maven'
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/publish-central.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/publish-github.yml

This file was deleted.

35 changes: 32 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,44 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/cryptomator/siv-mode/compare/1.6.0...HEAD)
## [Unreleased](https://github.com/cryptomator/siv-mode/compare/1.6.1...HEAD)

### Added
- new low-level API:
* `new SivEngine(key).encrypt(plaintext, associatedData...)`
* `new SivEngine(key).decrypt(plaintext, associatedData...)`
- implement JCA `Cipher` SPI:
```java
Cipher siv = Cipher.getInstance("AES/SIV/NoPadding");
siv.init(Cipher.ENCRYPT_MODE, key);
siv.updateAAD(aad1);
siv.updateAAD(aad2);
byte[] ciphertext = siv.doFinal(plaintext);
```

### Changed
- remove dependencies on BouncyCastle and Jetbrains Annotations
- simplify build by removing `maven-shade-plugin`
- update test dependencies
- update build plugins

### Deprecated
- old low-level API:
* `new SivMode().encrypt(key, plaintext, associatedData...)`
* `new SivMode().encrypt(ctrKey, macKey, plaintext, associatedData...)`
* `new SivMode().decrypt(key, ciphertext, associatedData...)`
* `new SivMode().decrypt(ctrKey, macKey, ciphertext, associatedData...)`

## [1.6.1](https://github.com/cryptomator/siv-mode/compare/1.6.0...1.6.1)

### Changed
- update dependencies

## [1.6.0](https://github.com/cryptomator/siv-mode/compare/1.5.2...1.6.0)

### Added

- This CHANGELOG file
- `encrypt(SecretKey key, byte[] plaintext, byte[]... associatedData)` and `decrypt(SecretKey key, byte[] ciphertext, byte[]... associatedData)` using a single 256, 384, or 512 bit key

### Changed

- use `maven-gpg-plugin`'s bc-based signer
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
[![Javadocs](http://www.javadoc.io/badge/org.cryptomator/siv-mode.svg)](http://www.javadoc.io/doc/org.cryptomator/siv-mode)

## Features
- No dependencies (required BouncyCastle classes are repackaged)
- No dependencies
- Passes official RFC 5297 test vectors
- Constant time authentication
- Defaults on AES, but supports any block cipher with a 128-bit block size.
- Supports any key sizes that the block cipher supports (e.g. 128/192/256-bit keys for AES)
- Thread-safe
- [Fast](https://github.com/cryptomator/siv-mode/issues/15)
- Requires JDK 8+ or Android API Level 24+ (since version 1.4.0)

Expand All @@ -28,16 +25,16 @@

## Usage
```java
private static final SivMode AES_SIV = new SivMode();
SivMode AES_SIV = new SivMode(key);

public void encrypt() {
byte[] encrypted = AES_SIV.encrypt(ctrKey, macKey, "hello world".getBytes());
byte[] decrypted = AES_SIV.decrypt(ctrKey, macKey, encrypted);
byte[] encrypted = AES_SIV.encrypt("hello world".getBytes());
byte[] decrypted = AES_SIV.decrypt(encrypted);
}

public void encryptWithAssociatedData() {
byte[] encrypted = AES_SIV.encrypt(ctrKey, macKey, "hello world".getBytes(), "associated".getBytes(), "data".getBytes());
byte[] decrypted = AES_SIV.decrypt(ctrKey, macKey, encrypted, "associated".getBytes(), "data".getBytes());
byte[] encrypted = AES_SIV.encrypt("hello world".getBytes(), "associated".getBytes(), "data".getBytes());
byte[] decrypted = AES_SIV.decrypt(encrypted, "associated".getBytes(), "data".getBytes());
}
```

Expand All @@ -48,7 +45,7 @@ public void encryptWithAssociatedData() {
<dependency>
<groupId>org.cryptomator</groupId>
<artifactId>siv-mode</artifactId>
<version>1.4.0</version>
<version>2.0.0</version>
</dependency>
</dependencies>
```
Expand All @@ -61,8 +58,6 @@ From version 1.3.2 onwards this library is an explicit module with the name `org
requires org.cryptomator.siv;
```

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

## Reproducible Builds

This is a Maven project that can be built using `mvn install`. However, if you want to build this reproducibly, please make sure:
Expand Down
Loading