Skip to content

Commit a62084d

Browse files
Pascal van Leeuwenherbertx
authored andcommitted
crypto: aead - Do not allow authsize=0 if auth. alg has digestsize>0
Return -EINVAL on an attempt to set the authsize to 0 with an auth. algorithm with a non-zero digestsize (i.e. anything but digest_null) as authenticating the data and then throwing away the result does not make any sense at all. The digestsize zero exception is for use with digest_null for testing purposes only. Signed-off-by: Pascal van Leeuwen <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 440dc9a commit a62084d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

crypto/aead.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
7070
{
7171
int err;
7272

73-
if (authsize > crypto_aead_maxauthsize(tfm))
73+
if ((!authsize && crypto_aead_maxauthsize(tfm)) ||
74+
authsize > crypto_aead_maxauthsize(tfm))
7475
return -EINVAL;
7576

7677
if (crypto_aead_alg(tfm)->setauthsize) {

0 commit comments

Comments
 (0)