MCPcopy Index your code
hub / github.com/cryptomator/siv-mode

github.com/cryptomator/siv-mode @1.6.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.6.1 ↗ · + Follow
121 symbols 298 edges 23 files 27 documented · 22% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Java RFC 5297 SIV Authenticated Encryption

Build Quality Gate Status Coverage Vulnerabilities Maven Central Javadocs

Features

  • No dependencies (required BouncyCastle classes are repackaged)
  • 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
  • Requires JDK 8+ or Android API Level 24+ (since version 1.4.0)

Audits

Finding Comment
1u1-22-001 The GPG key is used exclusively for the Maven repositories, is designed for signing only and is protected by a 30-character generated password (alphabet size: 96 chars). It is iterated and salted (SHA1 with 20971520 iterations). An offline attack is also very unattractive. Apart from that, this finding has no influence on the Tresor apps1. This was not known to Cure53 at the time of reporting.
1u1-22-002 As per contract of BlockCipher#processBlock(byte[], int, byte[], int), JceAesBlockCipher is designed to encrypt or decrypt just one single block at a time. JCE doesn't allow us to retrieve the plain cipher without a mode, so we explicitly request AES/ECB/NoPadding. 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.

Usage

private static final SivMode AES_SIV = new SivMode();

public void encrypt() {
  byte[] encrypted = AES_SIV.encrypt(ctrKey, macKey, "hello world".getBytes());
  byte[] decrypted = AES_SIV.decrypt(ctrKey, macKey, 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());
}

Maven integration

<dependencies>
  <dependency>
    <groupId>org.cryptomator</groupId>
    <artifactId>siv-mode</artifactId>
    <version>1.4.0</version>
  </dependency>
</dependencies>

Java Module

From version 1.3.2 onwards this library is an explicit module with the name org.cryptomator.siv. You can use it by adding the following line to your module-info.java.

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:

  1. Use the same build environment
    • The same JDK as our CI builds
    • Ideally the same same arch and OS (x86_64 Linux)
    • Same locale (en_US) and linebreaks (POSIX)
  2. Use ./mvnw install instead (or ./mvnw verify or ./mvnw package -DskipTests, depending on your intentions)

License

Distributed under the MIT X Consortium license. See the LICENSE file for more info.


1 The Cure53 pentesting was performed during the development of the apps for 1&1 Mail & Media GmbH.

Extension points exported contracts — how you extend this code

BlockCipherFactory (Interface)
Creates BlockCiphers. [1 implementers]
src/main/java/org/cryptomator/siv/SivMode.java

Core symbols most depended-on inside this repo

decrypt
called by 19
src/main/java/org/cryptomator/siv/SivMode.java
init
called by 16
src/main/java/org/cryptomator/siv/JceAesBlockCipher.java
encrypt
called by 12
src/main/java/org/cryptomator/siv/SivMode.java
computeCtr
called by 9
src/main/java/org/cryptomator/siv/SivMode.java
xor
called by 7
src/main/java/org/cryptomator/siv/SivMode.java
xorend
called by 7
src/main/java/org/cryptomator/siv/SivMode.java
dbl
called by 6
src/main/java/org/cryptomator/siv/SivMode.java
processBlock
called by 5
src/main/java/org/cryptomator/siv/JceAesBlockCipher.java

Shape

Method 95
Class 14
Interface 9
Function 3

Languages

Java98%
Go2%

Modules by API surface

src/test/java/org/cryptomator/siv/SivModeTest.java28 symbols
src/main/java/org/cryptomator/siv/SivMode.java20 symbols
src/test/java/org/cryptomator/siv/JceAesBlockCipherTest.java18 symbols
src/test/java/org/cryptomator/siv/EncryptionTestCase.java9 symbols
src/main/java/org/cryptomator/siv/JceAesBlockCipher.java7 symbols
src/test/java/org/cryptomator/siv/SivModeBenchmark.java6 symbols
src/test/java/org/cryptomator/siv/CustomCtrComputerTest.java4 symbols
src/main/java/org/cryptomator/siv/ThreadLocals.java4 symbols
src/test/java/org/cryptomator/siv/JceAesCtrComputerTest.java3 symbols
src/test/go/siv-test-vectors.go3 symbols
src/main/java9/org.cryptomator.siv/ThreadLocals.java3 symbols
src/main/java/org/cryptomator/siv/JceAesCtrComputer.java3 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add siv-mode \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact