Skip to content

Commit f647baa

Browse files
karel-msjaeckel
authored andcommitted
OCBv3: ocb3_init taglen check
1 parent af63d0a commit f647baa

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/encauth/ocb3/ocb3_init.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,14 @@ int ocb3_init(ocb3_state *ocb, int cipher,
114114
return CRYPT_INVALID_ARG;
115115
}
116116

117-
/* Make sure taglen isn't too long */
118-
if (taglen > (unsigned long)cipher_descriptor[cipher].block_length) {
119-
taglen = cipher_descriptor[cipher].block_length;
117+
/* The blockcipher must have a 128-bit blocksize */
118+
if (cipher_descriptor[cipher].block_length != 16) {
119+
return CRYPT_INVALID_ARG;
120+
}
121+
122+
/* The TAGLEN may be any value up to 128 (bits) */
123+
if (taglen > 16) {
124+
return CRYPT_INVALID_ARG;
120125
}
121126
ocb->tag_len = taglen;
122127

src/encauth/ocb3/ocb3_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ int ocb3_test(void)
215215
}
216216

217217
for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
218-
len = sizeof(outtag);
218+
len = 16; /* must be the same as the required taglen */
219219
if ((err = ocb3_encrypt_authenticate_memory(idx,
220220
key, sizeof(key),
221221
nonce, sizeof(nonce),

0 commit comments

Comments
 (0)