diff options
author | tb <> | 2023-03-11 15:29:03 +0000 |
---|---|---|
committer | tb <> | 2023-03-11 15:29:03 +0000 |
commit | 41f7f65096b8335fece23db719c013b6f69b9f15 (patch) | |
tree | b33c50310114b7cefaab3359699921ac74dd8db9 /src/lib | |
parent | 35110baf921b6dce1cf276a12a23a1e226a410dd (diff) | |
download | openbsd-41f7f65096b8335fece23db719c013b6f69b9f15.tar.gz openbsd-41f7f65096b8335fece23db719c013b6f69b9f15.tar.bz2 openbsd-41f7f65096b8335fece23db719c013b6f69b9f15.zip |
Fix an off-by-one in dsa_check_key()
The private key is a random number in [1, q-1], so 1 must be allowed.
Since q is at least an 160-bit prime and 2^159 + 1 is not prime (159
is not a power of 2), the probability that this is hit is < 2^-159,
but a tiny little bit wrong is still wrong.
Found while investigating a report by bluhm
ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index 1a6ca54da1..6986f9ad6b 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_lib.c,v 1.41 2023/03/07 09:27:10 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_lib.c,v 1.42 2023/03/11 15:29:03 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -487,7 +487,7 @@ dsa_check_key(const DSA *dsa) | |||
487 | 487 | ||
488 | /* The private key must be nonzero and in GF(q). */ | 488 | /* The private key must be nonzero and in GF(q). */ |
489 | if (dsa->priv_key != NULL) { | 489 | if (dsa->priv_key != NULL) { |
490 | if (BN_cmp(dsa->priv_key, BN_value_one()) <= 0 || | 490 | if (BN_cmp(dsa->priv_key, BN_value_one()) < 0 || |
491 | BN_cmp(dsa->priv_key, dsa->q) >= 0) { | 491 | BN_cmp(dsa->priv_key, dsa->q) >= 0) { |
492 | DSAerror(DSA_R_INVALID_PARAMETERS); | 492 | DSAerror(DSA_R_INVALID_PARAMETERS); |
493 | return 0; | 493 | return 0; |