From ece07459cdd51c2753bb4f4fe3e7ee03cf3c3e2e Mon Sep 17 00:00:00 2001 From: jsing Date: Wed, 23 Nov 2022 03:10:10 +0000 Subject: [PATCH] Use bn_wexpand() rather than bn_expand() with sizeof(BN_ULONG). This also fixes a bug in BN_MONT_CTX_set(), where the sizeof(BN_ULONG) in the call to bn_expand() was not multiplied by eight (to get bits). ok tb@ --- lib/libcrypto/bn/bn_lib.c | 4 ++-- lib/libcrypto/bn/bn_mont.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libcrypto/bn/bn_lib.c b/lib/libcrypto/bn/bn_lib.c index 15bbdf12730..1c079b004a2 100644 --- a/lib/libcrypto/bn/bn_lib.c +++ b/lib/libcrypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.59 2022/11/23 03:04:52 jsing Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.60 2022/11/23 03:10:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -518,7 +518,7 @@ int BN_set_word(BIGNUM *a, BN_ULONG w) { bn_check_top(a); - if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL) + if (bn_wexpand(a, 1) == NULL) return (0); a->neg = 0; a->d[0] = w; diff --git a/lib/libcrypto/bn/bn_mont.c b/lib/libcrypto/bn/bn_mont.c index e01af702e77..4555f6146bb 100644 --- a/lib/libcrypto/bn/bn_mont.c +++ b/lib/libcrypto/bn/bn_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mont.c,v 1.28 2022/02/07 19:44:23 tb Exp $ */ +/* $OpenBSD: bn_mont.c,v 1.29 2022/11/23 03:10:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -419,7 +419,7 @@ BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) } else /* if N mod word size == 1 */ { - if (bn_expand(Ri, (int)sizeof(BN_ULONG) * 2) == NULL) + if (bn_wexpand(Ri, 2) == NULL) goto err; /* Ri-- (mod double word size) */ Ri->neg = 0; -- 2.20.1