summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorPascal van Leeuwen <pascalvanl@gmail.com>2019-08-09 17:51:07 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2019-08-15 21:52:14 +1000
commit9e9b33a2d019edc4ba465ae5721256dd610f0991 (patch)
tree9f1299d389cb6af464d9ab244387f0e728f310f7 /crypto
parent7e28a4ed64ca3a3f2ff2264a1afe776c6722b7f9 (diff)
downloadlinux-crypto-9e9b33a2d019edc4ba465ae5721256dd610f0991.tar.gz
linux-crypto-9e9b33a2d019edc4ba465ae5721256dd610f0991.zip
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 <pvanleeuwen@verimatrix.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/aead.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/aead.c b/crypto/aead.c
index fbf0ec93..ce035589 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) {