diff options
author | bcook <> | 2016-07-05 02:54:35 +0000 |
---|---|---|
committer | bcook <> | 2016-07-05 02:54:35 +0000 |
commit | 893dbf4e24a37a4ac3cf521b4c386df31e6edf21 (patch) | |
tree | 90c31bd2681496537a3d217c0819f837c5e8d8b4 /src/lib/libcrypto/dh/dh_check.c | |
parent | 25f89b1a60c16a8a6f6b2258cfebc4c8db737315 (diff) | |
download | openbsd-893dbf4e24a37a4ac3cf521b4c386df31e6edf21.tar.gz openbsd-893dbf4e24a37a4ac3cf521b4c386df31e6edf21.tar.bz2 openbsd-893dbf4e24a37a4ac3cf521b4c386df31e6edf21.zip |
On systems where we do not have BN_ULLONG defined (most 64-bit systems),
BN_mod_word() can return incorrect results if the supplied modulus is
too big, so we need to fall back to BN_div_word.
Now that BN_mod_word may fail, handle errors properly update the man page.
Thanks to Brian Smith for pointing out these fixes from BoringSSL:
https://boringssl.googlesource.com/boringssl/+/67cb49d045f04973ddba0f92fe8a8ad483c7da89
https://boringssl.googlesource.com/boringssl/+/44bedc348d9491e63c7ed1438db100a4b8a830be
ok beck@
Diffstat (limited to 'src/lib/libcrypto/dh/dh_check.c')
-rw-r--r-- | src/lib/libcrypto/dh/dh_check.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c index 93e1003bd6..a6010f0a6d 100644 --- a/src/lib/libcrypto/dh/dh_check.c +++ b/src/lib/libcrypto/dh/dh_check.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dh_check.c,v 1.15 2015/02/07 13:19:15 doug Exp $ */ | 1 | /* $OpenBSD: dh_check.c,v 1.16 2016/07/05 02:54:35 bcook 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 | * |
@@ -89,10 +89,14 @@ DH_check(const DH *dh, int *ret) | |||
89 | 89 | ||
90 | if (BN_is_word(dh->g, DH_GENERATOR_2)) { | 90 | if (BN_is_word(dh->g, DH_GENERATOR_2)) { |
91 | l = BN_mod_word(dh->p, 24); | 91 | l = BN_mod_word(dh->p, 24); |
92 | if (l == (BN_ULONG)-1) | ||
93 | goto err; | ||
92 | if (l != 11) | 94 | if (l != 11) |
93 | *ret |= DH_NOT_SUITABLE_GENERATOR; | 95 | *ret |= DH_NOT_SUITABLE_GENERATOR; |
94 | } else if (BN_is_word(dh->g, DH_GENERATOR_5)) { | 96 | } else if (BN_is_word(dh->g, DH_GENERATOR_5)) { |
95 | l = BN_mod_word(dh->p, 10); | 97 | l = BN_mod_word(dh->p, 10); |
98 | if (l == (BN_ULONG)-1) | ||
99 | goto err; | ||
96 | if (l != 3 && l != 7) | 100 | if (l != 3 && l != 7) |
97 | *ret |= DH_NOT_SUITABLE_GENERATOR; | 101 | *ret |= DH_NOT_SUITABLE_GENERATOR; |
98 | } else | 102 | } else |