Skip to content

Commit b7b04ff

Browse files
authored
Merge pull request #778 from libtom/pr/eax-taglen
EAX properly handle taglen boundaries
2 parents 84aec00 + 39f5e1f commit b7b04ff

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

doc/crypt.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,10 @@ \chapter{Authenticated Encryption}
18671867
The only difference is eax\_decrypt\_verify\_memory() does not emit a tag. Instead you pass it a tag as input and it compares it against
18681868
the tag it computed while decrypting the message. If the tags match then it stores a $1$ in \textit{res}, otherwise it stores a $0$.
18691869

1870+
The length of the tag is a security parameter of EAX mode: tags may be truncated and a zerolength tag is legal -- it simply
1871+
provides no authenticity, which is the caller's choice. A \textit{taglen} larger than the block size of the used cipher is rejected
1872+
by eax\_decrypt\_verify\_memory() with \textbf{CRYPT\_INVALID\_ARG} (encrypt side can never emit such a tag).
1873+
18701874
\mysection{OCB Mode}
18711875
\subsection{Preface}
18721876

src/encauth/eax/eax_decrypt_verify_memory.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ int eax_decrypt_verify_memory(int cipher,
4949
/* default to zero */
5050
*stat = 0;
5151

52-
/* limit taglen */
53-
taglen = MIN(taglen, MAXBLOCKSIZE);
52+
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
53+
return err;
54+
}
55+
/* NOTE: zero-length tag is legal (it just provides no authenticity) */
56+
if (taglen > (unsigned long)cipher_descriptor[cipher].block_length) {
57+
return CRYPT_INVALID_ARG;
58+
}
5459

5560
/* allocate ram */
5661
buf = XMALLOC(taglen);

0 commit comments

Comments
 (0)