Skip to content

Commit

Permalink
crypto: aead - Do not allow authsize=0 if auth. alg has digestsize>0
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Pascal van Leeuwen authored and herbertx committed Aug 15, 2019
1 parent 440dc9a commit a62084d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
{
int err;

if (authsize > crypto_aead_maxauthsize(tfm))
if ((!authsize && crypto_aead_maxauthsize(tfm)) ||
authsize > crypto_aead_maxauthsize(tfm))
return -EINVAL;

if (crypto_aead_alg(tfm)->setauthsize) {
Expand Down

0 comments on commit a62084d

Please sign in to comment.