crypto: bcm - Verify GCM/CCM key length in setkey
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 2 Oct 2020 07:55:22 +0000 (17:55 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 8 Oct 2020 05:38:06 +0000 (16:38 +1100)
commit10a2f0b311094ffd45463a529a410a51ca025f27
tree94d9d26368ca785407ce84b986ced8084beaf565
parent789f900b70b9125ed473e1eb4699dc7d298694e7
crypto: bcm - Verify GCM/CCM key length in setkey

The setkey function for GCM/CCM algorithms didn't verify the key
length before copying the key and subtracting the salt length.

This patch delays the copying of the key til after the verification
has been done.  It also adds checks on the key length to ensure
that it's at least as long as the salt.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Cc: <stable@vger.kernel.org>
Reported-by: kiyin(尹亮) <kiyin@tencent.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/bcm/cipher.c