Skip to content

Commit ea914be

Browse files
dalessangregkh
authored andcommitted
crypto: ecdh_helper - Ensure 'len >= secret.len' in decode_key()
[ Upstream commit a53ab94 ] The length ('len' parameter) passed to crypto_ecdh_decode_key() is never checked against the length encoded in the passed buffer ('buf' parameter). This could lead to an out-of-bounds access when the passed length is less than the encoded length. Add a check to prevent that. Fixes: 3c4b239 ("crypto: ecdh - Add ECDH software support") Signed-off-by: Daniele Alessandrelli <daniele.alessandrelli@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bebfe70 commit ea914be

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

crypto/ecdh_helper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ int crypto_ecdh_decode_key(const char *buf, unsigned int len,
6767
if (secret.type != CRYPTO_KPP_SECRET_TYPE_ECDH)
6868
return -EINVAL;
6969

70+
if (unlikely(len < secret.len))
71+
return -EINVAL;
72+
7073
ptr = ecdh_unpack_data(&params->curve_id, ptr, sizeof(params->curve_id));
7174
ptr = ecdh_unpack_data(&params->key_size, ptr, sizeof(params->key_size));
7275
if (secret.len != crypto_ecdh_key_len(params))

0 commit comments

Comments
 (0)