diff options
author | 2016-03-04 16:23:30 +0000 | |
---|---|---|
committer | 2016-03-04 16:23:30 +0000 | |
commit | db404e3e47b81c28b9d0c712935961d815dccab1 (patch) | |
tree | c4456b32fa4cd8b2207e838cda6ade1c6f87c720 /lib/libssl/src | |
parent | Revert bn_expand until there's consensus on a fix. (diff) | |
download | wireguard-openbsd-db404e3e47b81c28b9d0c712935961d815dccab1.tar.xz wireguard-openbsd-db404e3e47b81c28b9d0c712935961d815dccab1.zip |
graduate bn_expand() to a real function. the openssl version of this
uses a macro with multiple-evaluations of arguments (different amount
than the previous version..), but doug/bcook's inline version makes
BIGNUM not opaque [problem spotted by naddy]
ok doug
Diffstat (limited to 'lib/libssl/src')
-rw-r--r-- | lib/libssl/src/crypto/bn/bn.h | 6 | ||||
-rw-r--r-- | lib/libssl/src/crypto/bn/bn_lib.c | 14 |
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/libssl/src/crypto/bn/bn.h b/lib/libssl/src/crypto/bn/bn.h index 7d11a049d0f..4ae6a8195da 100644 --- a/lib/libssl/src/crypto/bn/bn.h +++ b/lib/libssl/src/crypto/bn/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.30 2016/03/04 16:06:38 doug Exp $ */ +/* $OpenBSD: bn.h,v 1.31 2016/03/04 16:23:30 deraadt Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -619,10 +619,10 @@ const BIGNUM *BN_get0_nist_prime_521(void); /* library internal functions */ -#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\ - (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2)) #define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) BIGNUM *bn_expand2(BIGNUM *a, int words); +BIGNUM *bn_expand(BIGNUM *a, int bits); + #ifndef OPENSSL_NO_DEPRECATED BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ #endif diff --git a/lib/libssl/src/crypto/bn/bn_lib.c b/lib/libssl/src/crypto/bn/bn_lib.c index 7cc76c1e854..311ec2044d4 100644 --- a/lib/libssl/src/crypto/bn/bn_lib.c +++ b/lib/libssl/src/crypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.34 2015/09/10 15:56:25 jsing Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.35 2016/03/04 16:23:30 deraadt Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -550,6 +550,18 @@ BN_get_word(const BIGNUM *a) return 0; } +BIGNUM * +bn_expand(BIGNUM *a, int bits) +{ + if (bits > (INT_MAX - BN_BITS2 + 1)) + return (NULL); + + if (((bits + BN_BITS2 - 1) / BN_BITS2) <= a->dmax) + return (a); + + return bn_expand2(a, (bits + BN_BITS2 - 1) / BN_BITS2); +} + int BN_set_word(BIGNUM *a, BN_ULONG w) { |