Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] crypto: aead - Do not allow authsize=0 if auth. alg has digestsize>0
@ 2019-08-09 15:51 Pascal van Leeuwen
  2019-08-15 12:07 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Pascal van Leeuwen @ 2019-08-09 15:51 UTC (permalink / raw)
  To: linux-crypto; +Cc: herbert, davem, Pascal van Leeuwen

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>
---
 crypto/aead.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/crypto/aead.c b/crypto/aead.c
index 4908b5e..e423107 100644
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -75,7 +75,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) {
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: aead - Do not allow authsize=0 if auth. alg has digestsize>0
  2019-08-09 15:51 [PATCH] crypto: aead - Do not allow authsize=0 if auth. alg has digestsize>0 Pascal van Leeuwen
@ 2019-08-15 12:07 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2019-08-15 12:07 UTC (permalink / raw)
  To: Pascal van Leeuwen; +Cc: linux-crypto, davem, Pascal van Leeuwen

On Fri, Aug 09, 2019 at 05:51:07PM +0200, Pascal van Leeuwen wrote:
> 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>
> ---
>  crypto/aead.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 15:51 [PATCH] crypto: aead - Do not allow authsize=0 if auth. alg has digestsize>0 Pascal van Leeuwen
2019-08-15 12:07 ` Herbert Xu

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lore.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org linux-crypto@archiver.kernel.org
	public-inbox-index linux-crypto


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/ public-inbox