diff options
author | jsing <> | 2022-11-24 01:30:01 +0000 |
---|---|---|
committer | jsing <> | 2022-11-24 01:30:01 +0000 |
commit | 8a7c8abfd4f8805f2a5101e89356e9411d908a0c (patch) | |
tree | faea38f1c86dae9f6d4b143b2aa9f7752ecd0a34 /src/lib/libcrypto/bn/bn_mont.c | |
parent | 095ccaedd0631462c52a1a2d9aa19b35c3e45b12 (diff) | |
download | openbsd-8a7c8abfd4f8805f2a5101e89356e9411d908a0c.tar.gz openbsd-8a7c8abfd4f8805f2a5101e89356e9411d908a0c.tar.bz2 openbsd-8a7c8abfd4f8805f2a5101e89356e9411d908a0c.zip |
Change bn_expand()/bn_wexpand() to indicate failure/success via 0/1.
Currently bn_expand()/bn_wexpand() return a BIGNUM *, however none of the
callers use this (and many already treat it as a true/false value).
Change these functions to return 0 on failure and 1 on success, revising
callers that test against NULL in the process.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/bn/bn_mont.c')
-rw-r--r-- | src/lib/libcrypto/bn/bn_mont.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c index 4555f6146b..251c67b89d 100644 --- a/src/lib/libcrypto/bn/bn_mont.c +++ b/src/lib/libcrypto/bn/bn_mont.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_mont.c,v 1.29 2022/11/23 03:10:10 jsing Exp $ */ | 1 | /* $OpenBSD: bn_mont.c,v 1.30 2022/11/24 01:30:01 jsing 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 | * |
@@ -137,7 +137,7 @@ BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | |||
137 | int num = mont->N.top; | 137 | int num = mont->N.top; |
138 | 138 | ||
139 | if (num > 1 && a->top == num && b->top == num) { | 139 | if (num > 1 && a->top == num && b->top == num) { |
140 | if (bn_wexpand(r, num) == NULL) | 140 | if (!bn_wexpand(r, num)) |
141 | return (0); | 141 | return (0); |
142 | if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) { | 142 | if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) { |
143 | r->neg = a->neg^b->neg; | 143 | r->neg = a->neg^b->neg; |
@@ -197,7 +197,7 @@ BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont) | |||
197 | } | 197 | } |
198 | 198 | ||
199 | max = (2 * nl); /* carry is stored separately */ | 199 | max = (2 * nl); /* carry is stored separately */ |
200 | if (bn_wexpand(r, max) == NULL) | 200 | if (!bn_wexpand(r, max)) |
201 | return (0); | 201 | return (0); |
202 | 202 | ||
203 | r->neg ^= n->neg; | 203 | r->neg ^= n->neg; |
@@ -226,7 +226,7 @@ BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont) | |||
226 | rp[nl] = v; | 226 | rp[nl] = v; |
227 | } | 227 | } |
228 | 228 | ||
229 | if (bn_wexpand(ret, nl) == NULL) | 229 | if (!bn_wexpand(ret, nl)) |
230 | return (0); | 230 | return (0); |
231 | ret->top = nl; | 231 | ret->top = nl; |
232 | ret->neg = r->neg; | 232 | ret->neg = r->neg; |
@@ -419,7 +419,7 @@ BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) | |||
419 | } | 419 | } |
420 | else /* if N mod word size == 1 */ | 420 | else /* if N mod word size == 1 */ |
421 | { | 421 | { |
422 | if (bn_wexpand(Ri, 2) == NULL) | 422 | if (!bn_wexpand(Ri, 2)) |
423 | goto err; | 423 | goto err; |
424 | /* Ri-- (mod double word size) */ | 424 | /* Ri-- (mod double word size) */ |
425 | Ri->neg = 0; | 425 | Ri->neg = 0; |