]> xenbits.xensource.com Git - arm/linux.git/commitdiff
crypto: aead - Do not allow authsize=0 if auth. alg has digestsize>0
authorPascal van Leeuwen <pascalvanl@gmail.com>
Fri, 9 Aug 2019 15:51:07 +0000 (17:51 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 15 Aug 2019 11:52:14 +0000 (21:52 +1000)
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 <pvanleeuwen@verimatrix.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/aead.c

index fbf0ec93bc8e1ea343ea19ab276a2f112df9c336..ce035589cf577b962423de8181d3520daf260818 100644 (file)
@@ -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) {