Skip to content

Commit 99f641b

Browse files
Clarified missing branch
if n = 0 then return V = AES-CMAC(K, <one>) fi Fixes #14
1 parent bbad3ab commit 99f641b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ byte[] s2v(byte[] macKey, byte[] plaintext, byte[]... associatedData) {
242242
final CipherParameters params = new KeyParameter(macKey);
243243
final CMac mac = new CMac(threadLocalCipher.get());
244244
mac.init(params);
245+
246+
// RFC 5297 defines a n == 0 case here. Where n is the length of the input vector:
247+
// S1 = associatedData1, S2 = associatedData2, ... Sn = plaintext
248+
// Since this method is invoked only by encrypt/decrypt, we always have a plaintext.
249+
// Thus n > 0
245250

246251
byte[] d = mac(mac, BYTES_ZERO);
247252

0 commit comments

Comments
 (0)