summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/chelsio
diff options
context:
space:
mode:
authorHarsh Jain <harsh@chelsio.com>2017-01-27 11:39:06 +0100
committerHerbert Xu <herbert@gondor.apana.org.au>2017-02-03 11:09:31 +0100
commit7c2cf1c4615cc2f576d0604406cdf0065f00b83b (patch)
tree08407f9ebbdac1343473259b8d5099d6089527af /drivers/crypto/chelsio
parentcrypto: algif_aead - Fix kernel panic on list_del (diff)
downloadlinux-7c2cf1c4615cc2f576d0604406cdf0065f00b83b.tar.xz
linux-7c2cf1c4615cc2f576d0604406cdf0065f00b83b.zip
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>
Diffstat (limited to 'drivers/crypto/chelsio')
-rw-r--r--drivers/crypto/chelsio/chcr_algo.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index d29c2b45d3ab..b4b78b37f8a6 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -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);
}