summaryrefslogtreecommitdiff
path: root/crypto/ecdh.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2018-03-30 09:55:44 -0700
committerHerbert Xu <herbert@gondor.apana.org.au>2018-04-21 00:58:29 +0800
commit96ea4f4f1987807e2705f67ac2b47812b52015de (patch)
tree88e96ecf7302e051757473c1e3733f4b327e305d /crypto/ecdh.c
parentef734472771a62ae9f901367a40a89382a991917 (diff)
downloadlinux-crypto-96ea4f4f1987807e2705f67ac2b47812b52015de.tar.gz
linux-crypto-96ea4f4f1987807e2705f67ac2b47812b52015de.zip
crypto: ecc - Actually remove stack VLA usage
On the quest to remove all VLAs from the kernel[1], this avoids VLAs by just using the maximum allocation size (4 bytes) for stack arrays. All the VLAs in ecc were either 3 or 4 bytes (or a multiple), so just make it 4 bytes all the time. Initialization routines are adjusted to check that ndigits does not end up larger than the arrays. This includes a removal of the earlier attempt at this fix from commit a963834b4742 ("crypto/ecc: Remove stack VLA usage") [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/ecdh.c')
-rw-r--r--crypto/ecdh.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/ecdh.c b/crypto/ecdh.c
index d2ec33f0..bf630017 100644
--- a/crypto/ecdh.c
+++ b/crypto/ecdh.c
@@ -30,8 +30,8 @@ static inline struct ecdh_ctx *ecdh_get_ctx(struct crypto_kpp *tfm)
static unsigned int ecdh_supported_curve(unsigned int curve_id)
{
switch (curve_id) {
- case ECC_CURVE_NIST_P192: return 3;
- case ECC_CURVE_NIST_P256: return 4;
+ case ECC_CURVE_NIST_P192: return ECC_CURVE_NIST_P192_DIGITS;
+ case ECC_CURVE_NIST_P256: return ECC_CURVE_NIST_P256_DIGITS;
default: return 0;
}
}