diff options
author | tb <> | 2023-03-04 21:39:34 +0000 |
---|---|---|
committer | tb <> | 2023-03-04 21:39:34 +0000 |
commit | 4530ae1a29620f025ee7ea13807490ab6b17d85b (patch) | |
tree | ef4f8a94017dbf09bb7bd43490d8bc7225634991 /src/lib/libcrypto/ecdsa | |
parent | 8a82cbb62d388a2c5f2cfe6add96806986ba1d67 (diff) | |
download | openbsd-4530ae1a29620f025ee7ea13807490ab6b17d85b.tar.gz openbsd-4530ae1a29620f025ee7ea13807490ab6b17d85b.tar.bz2 openbsd-4530ae1a29620f025ee7ea13807490ab6b17d85b.zip |
Enforce a lower bound of of EC group order so 80 bits for ECDSA
This makes sure that the elliptic curve is not completely stupid.
This is conservative enough: the smallest named groups that we support
have an order of 112 bits.
ok beck jsing
Diffstat (limited to 'src/lib/libcrypto/ecdsa')
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 6f45e173b8..f169b06bd5 100644 --- a/src/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecs_ossl.c,v 1.27 2023/03/04 21:37:37 tb Exp $ */ | 1 | /* $OpenBSD: ecs_ossl.c,v 1.28 2023/03/04 21:39:34 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
4 | */ | 4 | */ |
@@ -168,8 +168,13 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
168 | goto err; | 168 | goto err; |
169 | } | 169 | } |
170 | 170 | ||
171 | /* Reject curves with an order that is smaller than 80 bits. */ | ||
172 | if ((order_bits = BN_num_bits(order)) < 80) { | ||
173 | ECDSAerror(EC_R_INVALID_GROUP_ORDER); | ||
174 | goto err; | ||
175 | } | ||
176 | |||
171 | /* Preallocate space. */ | 177 | /* Preallocate space. */ |
172 | order_bits = BN_num_bits(order); | ||
173 | if (!BN_set_bit(k, order_bits) || | 178 | if (!BN_set_bit(k, order_bits) || |
174 | !BN_set_bit(r, order_bits) || | 179 | !BN_set_bit(r, order_bits) || |
175 | !BN_set_bit(X, order_bits)) | 180 | !BN_set_bit(X, order_bits)) |