2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-24 05:04:00 +08:00

crypto: chcr - Fix key length for RFC4106

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>
This commit is contained in:
Harsh Jain 2017-01-27 16:09:06 +05:30 committed by Herbert Xu
parent 0b529f143e
commit 7c2cf1c461

View File

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