Skip to content

Commit 513c4ff

Browse files
fix javadoc issues
[deploy]
1 parent f05b4d7 commit 513c4ff

File tree

7 files changed

+61
-8
lines changed

7 files changed

+61
-8
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ private static void encryptBlock(Cipher cipher, byte[] block, byte[] output) {
157157

158158
/**
159159
* Create a new CMAC instance for incremental message processing
160+
* @param key The AES key (16, 24, or 32 bytes)
161+
* @return The CMAC instance
162+
* @throws IllegalArgumentException if the key length is invalid
160163
*/
161164
public static CMac create(byte[] key) {
162165
if (key.length != 16 && key.length != 24 && key.length != 32) {
@@ -175,6 +178,10 @@ public static CMac create(byte[] key) {
175178

176179
/**
177180
* One-shot CMAC computation
181+
* @param key The AES key (16, 24, or 32 bytes)
182+
* @param message The message to authenticate
183+
* @return The CMAC tag (always {@value BLOCK_SIZE} bytes)
184+
* @throws IllegalArgumentException if the key length is invalid
178185
*/
179186
public static byte[] tag(byte[] key, byte[] message) {
180187
CMac cmac = create(key);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
import java.util.Arrays;
1919
import java.util.List;
2020

21+
/**
22+
* JCE Cipher implementation for AES-SIV mode.
23+
* <p>
24+
* This cipher implements the Synthetic Initialization Vector (SIV) mode as specified in RFC 5297.
25+
*/
2126
public class SivCipher extends CipherSpi {
2227

2328
private static final byte[] EMPTY = new byte[0];

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121

2222
/**
2323
* Implements the RFC 5297 SIV mode.
24+
* <p>
25+
* Note: Instances of this class are not thread-safe.
26+
*
27+
* @see <a href="https://tools.ietf.org/html/rfc5297">RFC 5297</a>
28+
* @since 2.0
2429
*/
2530
public final class SivEngine {
2631

@@ -86,6 +91,17 @@ public byte[] encrypt(byte[] plaintext, byte[]... associatedData) {
8691
return ciphertext;
8792
}
8893

94+
/**
95+
* Encrypts plaintext using SIV mode and writes the result to the provided output buffer.
96+
*
97+
* @param plaintext Your plaintext, which shall be encrypted.
98+
* @param output The output buffer to write IV + ciphertext to.
99+
* @param outputOffset The offset in the output buffer to start writing at.
100+
* @param associatedData Optional associated data, which gets authenticated but not encrypted.
101+
* @return The number of bytes written to the output buffer (should always be {@value IV_LENGTH} + plaintext length).
102+
* @throws ShortBufferException If the output buffer is too small.
103+
* @throws IllegalArgumentException if either param exceeds the limits for safe use.
104+
*/
89105
public int encrypt(byte[] plaintext, byte[] output, int outputOffset, byte[]... associatedData) throws ShortBufferException {
90106
// Check if plaintext length will cause overflows
91107
if (plaintext.length > (Integer.MAX_VALUE - IV_LENGTH)) {
@@ -104,11 +120,12 @@ public int encrypt(byte[] plaintext, byte[] output, int outputOffset, byte[]...
104120
/**
105121
* Decrypts ciphertext using SIV mode. A block cipher defined by the constructor is being used.<br>
106122
*
107-
* @param ciphertext Your ciphertext, which shall be encrypted.
123+
* @param ciphertext Your ciphertext, which shall be decrypted.
108124
* @param associatedData Optional associated data, which needs to be authenticated during decryption.
109125
* @return Plaintext byte array.
110-
* @throws AEADBadTagException If the authentication failed, e.g. because ciphertext and/or associatedData are corrupted.
111-
* @throws IllegalBlockSizeException If the provided ciphertext is of invalid length.
126+
* @throws AEADBadTagException If the authentication failed, e.g. because ciphertext and/or associatedData are corrupted.
127+
* @throws IllegalBlockSizeException If the provided ciphertext is shorter than 16 bytes.
128+
* @throws IllegalArgumentException If number of associatedData fields exceed the limits for safe use.
112129
*/
113130
public byte[] decrypt(byte[] ciphertext, byte[]... associatedData) throws AEADBadTagException, IllegalBlockSizeException {
114131
if (ciphertext.length < IV_LENGTH) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public byte[] encrypt(SecretKey ctrKey, SecretKey macKey, byte[] plaintext, byte
6868
* @param plaintext Your plaintext, which shall be encrypted.
6969
* @param associatedData Optional associated data, which gets authenticated but not encrypted.
7070
* @return IV + Ciphertext as a concatenated byte array.
71-
* @throws IllegalArgumentException if the either of the two keys is of invalid length for the used {@link BlockCipher}.
71+
* @throws IllegalArgumentException if the either of the two keys is of invalid length.
7272
*/
7373
public byte[] encrypt(byte[] ctrKey, byte[] macKey, byte[] plaintext, byte[]... associatedData) {
7474
byte[] combinedKey = new byte[ctrKey.length + macKey.length];

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,27 @@
33
import java.security.Provider;
44
import java.util.HashMap;
55

6+
/**
7+
* JCE Security Provider for AES-SIV mode.
8+
* <p>
9+
* Provides implementations for:
10+
* <ul>
11+
* <li>CMAC (Cipher-based Message Authentication Code)</li>
12+
* <li>AES/SIV/NoPadding cipher</li>
13+
* </ul>
14+
*/
615
public class SivProvider extends Provider {
716

17+
/**
18+
* Singleton instance of the SIV provider.
19+
*/
820
public static final SivProvider INSTANCE = new SivProvider();
921

22+
/**
23+
* Constructs a new SIV provider and registers the available algorithms.
24+
*/
1025
public SivProvider() {
11-
super("SIV", 2.0, "");
26+
super("SIV", 2.0, "AES-SIV mode provider for authenticated encryption");
1227
putService(new Service(this, "Mac", "CMAC", CMac.class.getName(), null, new HashMap<>()));
1328
putService(new Service(this, "Cipher", "AES/SIV/NoPadding", SivCipher.class.getName(), null, new HashMap<>()));
1429
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import java.util.Arrays;
44

5+
/**
6+
* Utility methods for cryptographic operations.
7+
* <p>
8+
* Provides bit manipulation and padding operations used in AES-SIV mode.
9+
*/
510
public class Utils {
611

712
private static final byte DOUBLING_CONST = (byte) 0x87;
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
/**
22
* Java implementation of RFC 5297 SIV Authenticated Encryption.
33
* <p>
4-
* Use an instance of the {@link org.cryptomator.siv.SivEngine} class to
5-
* {@link org.cryptomator.siv.SivEngine#encrypt(byte[], byte[]...) encrypt} or
6-
* {@link org.cryptomator.siv.SivEngine#decrypt(byte[], byte[]...) decrypt} data.
4+
* Two usage patterns are supported:
5+
* <ul>
6+
* <li>Direct API: Use {@link org.cryptomator.siv.SivEngine} for encrypt/decrypt operations</li>
7+
* <li>JCE Provider: Register {@link org.cryptomator.siv.SivProvider} and use standard JCE APIs</li>
8+
* </ul>
9+
*
10+
* @see <a href="https://tools.ietf.org/html/rfc5297">RFC 5297</a>
711
*/
812
package org.cryptomator.siv;

0 commit comments

Comments
 (0)