Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c2cf1c4 authored by Harsh Jain's avatar Harsh Jain Committed by Herbert Xu
Browse files

crypto: chcr - Fix key length for RFC4106



Check keylen before copying salt to avoid wrap around of Integer.

Signed-off-by: default avatarHarsh Jain <harsh@chelsio.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0b529f14
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
	}