From 341829195e0c845cf26339768f275f021b69fedc Mon Sep 17 00:00:00 2001 From: tb <> Date: Mon, 15 Dec 2025 12:09:46 +0000 Subject: BN_get_word(): return (BN_ULONG)-1 on error rather than BN_MASK2 While the latter is more general in that it also works on 1-complement achitectures, we don't care about that. Adjust documentation and the only error check for it in libcrypto. ok deraadt --- src/lib/libcrypto/bn/bn_lib.c | 4 ++-- src/lib/libcrypto/ec/ec_curve.c | 4 ++-- src/lib/libcrypto/man/BN_zero.3 | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/lib/libcrypto') diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 3e451a6191..0326e72c4d 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.94 2025/05/10 05:54:38 tb Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.95 2025/12/15 12:09:46 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -349,7 +349,7 @@ BN_ULONG BN_get_word(const BIGNUM *a) { if (a->top > 1) - return BN_MASK2; + return (BN_ULONG)-1; else if (a->top == 1) return a->d[0]; /* a->top == 0 */ diff --git a/src/lib/libcrypto/ec/ec_curve.c b/src/lib/libcrypto/ec/ec_curve.c index 2838965c1e..fda2681704 100644 --- a/src/lib/libcrypto/ec/ec_curve.c +++ b/src/lib/libcrypto/ec/ec_curve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_curve.c,v 1.59 2025/11/02 13:06:30 tb Exp $ */ +/* $OpenBSD: ec_curve.c,v 1.60 2025/12/15 12:09:46 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2010 The OpenSSL Project. All rights reserved. * @@ -1392,7 +1392,7 @@ ec_curve_from_group(const EC_GROUP *group) if ((cofactor = EC_GROUP_get0_cofactor(group)) != NULL) { BN_ULONG cofactor_word; - if ((cofactor_word = BN_get_word(cofactor)) == BN_MASK2) + if ((cofactor_word = BN_get_word(cofactor)) == (BN_ULONG)-1) goto err; if (cofactor_word > INT_MAX) goto err; diff --git a/src/lib/libcrypto/man/BN_zero.3 b/src/lib/libcrypto/man/BN_zero.3 index 18a31a1080..d94a2a10da 100644 --- a/src/lib/libcrypto/man/BN_zero.3 +++ b/src/lib/libcrypto/man/BN_zero.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_zero.3,v 1.15 2025/06/14 06:48:47 tb Exp $ +.\" $OpenBSD: BN_zero.3,v 1.16 2025/12/15 12:09:46 tb Exp $ .\" full merge up to: OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 .\" selective merge up to: OpenSSL b713c4ff Jan 22 14:41:09 2018 -0500 .\" @@ -67,7 +67,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 14 2025 $ +.Dd $Mdocdate: December 15 2025 $ .Dt BN_ZERO 3 .Os .Sh NAME @@ -132,7 +132,7 @@ This constant is useful for comparisons and assignments. .Fn BN_get_word returns the value .Fa a , -or a number with all bits set if +or (BN_ULONG)\-1 if .Fa a cannot be represented as a .Vt BN_ULONG . -- cgit v1.2.3-55-g6feb