Merge pull request #778 from libtom/pr/eax-taglen

EAX properly handle taglen boundaries
This commit is contained in:
Steffen Jaeckel 2026-07-21 10:59:19 +02:00 committed by GitHub
commit b7b04ffd37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -1867,6 +1867,10 @@ have the same meaning as with those respective functions.
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
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$.
The length of the tag is a security parameter of EAX mode: tags may be truncated and a zerolength tag is legal -- it simply
provides no authenticity, which is the caller's choice. A \textit{taglen} larger than the block size of the used cipher is rejected
by eax\_decrypt\_verify\_memory() with \textbf{CRYPT\_INVALID\_ARG} (encrypt side can never emit such a tag).
\mysection{OCB Mode}
\subsection{Preface}

View file

@ -49,8 +49,13 @@ int eax_decrypt_verify_memory(int cipher,
/* default to zero */
*stat = 0;
/* limit taglen */
taglen = MIN(taglen, MAXBLOCKSIZE);
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
return err;
}
/* NOTE: zero-length tag is legal (it just provides no authenticity) */
if (taglen > (unsigned long)cipher_descriptor[cipher].block_length) {
return CRYPT_INVALID_ARG;
}
/* allocate ram */
buf = XMALLOC(taglen);