From: Pascal van Leeuwen Date: Fri, 9 Aug 2019 15:51:07 +0000 (+0200) Subject: crypto: aead - Do not allow authsize=0 if auth. alg has digestsize>0 X-Git-Tag: v5.4.17~2708^2~153 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a62084d299d950f2ad0649caf9a9b9a431346996;p=arm%2Flinux.git 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 Signed-off-by: Herbert Xu --- diff --git a/crypto/aead.c b/crypto/aead.c index fbf0ec93bc8e..ce035589cf57 100644 --- a/crypto/aead.c +++ b/crypto/aead.c @@ -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) {