]> git.baikalelectronics.ru Git - kernel.git/commitdiff
crypto: chcr - Fix key length for RFC4106
authorHarsh Jain <harsh@chelsio.com>
Fri, 27 Jan 2017 10:39:06 +0000 (16:09 +0530)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 3 Feb 2017 10:09:31 +0000 (18:09 +0800)
Check keylen before copying salt to avoid wrap around of Integer.

Signed-off-by: Harsh Jain <harsh@chelsio.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/chelsio/chcr_algo.c

index d29c2b45d3ab078a17ea7db369f270cd9051c1b9..b4b78b37f8a684698d79bc053be0b2f9db7e654f 100644 (file)
@@ -2192,8 +2192,8 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
        unsigned int ck_size;
        int ret = 0, key_ctx_size = 0;
 
-       if (get_aead_subtype(aead) ==
-           CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106) {
+       if (get_aead_subtype(aead) == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106 &&
+           keylen > 3) {
                keylen -= 4;  /* nonce/salt is present in the last 4 bytes */
                memcpy(aeadctx->salt, key + keylen, 4);
        }