Skip to content

Commit a03704f

Browse files
author
jsing
committed
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@
1 parent b715a23 commit a03704f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib/libcrypto/bn/bn_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: bn_lib.c,v 1.59 2022/11/23 03:04:52 jsing Exp $ */
1+
/* $OpenBSD: bn_lib.c,v 1.60 2022/11/23 03:10:10 jsing Exp $ */
22
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
33
* All rights reserved.
44
*
@@ -518,7 +518,7 @@ int
518518
BN_set_word(BIGNUM *a, BN_ULONG w)
519519
{
520520
bn_check_top(a);
521-
if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
521+
if (bn_wexpand(a, 1) == NULL)
522522
return (0);
523523
a->neg = 0;
524524
a->d[0] = w;

src/lib/libcrypto/bn/bn_mont.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: bn_mont.c,v 1.28 2022/02/07 19:44:23 tb Exp $ */
1+
/* $OpenBSD: bn_mont.c,v 1.29 2022/11/23 03:10:10 jsing Exp $ */
22
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
33
* All rights reserved.
44
*
@@ -419,7 +419,7 @@ BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
419419
}
420420
else /* if N mod word size == 1 */
421421
{
422-
if (bn_expand(Ri, (int)sizeof(BN_ULONG) * 2) == NULL)
422+
if (bn_wexpand(Ri, 2) == NULL)
423423
goto err;
424424
/* Ri-- (mod double word size) */
425425
Ri->neg = 0;

0 commit comments

Comments
 (0)