diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bn/div.c | 4 | ||||
-rw-r--r-- | crypto/bn/gcd.c | 12 |
2 files changed, 5 insertions, 11 deletions
diff --git a/crypto/bn/div.c b/crypto/bn/div.c index 2bf86de7..8b0152e8 100644 --- a/crypto/bn/div.c +++ b/crypto/bn/div.c @@ -362,7 +362,9 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, * BN_rshift() will overwrite it. */ int neg = num->neg; - BN_rshift(rm, snum, norm_shift); + if (!BN_rshift(rm, snum, norm_shift)) { + goto err; + } if (!BN_is_zero(rm)) { rm->neg = neg; } diff --git a/crypto/bn/gcd.c b/crypto/bn/gcd.c index 789a0942..3132c29e 100644 --- a/crypto/bn/gcd.c +++ b/crypto/bn/gcd.c @@ -258,12 +258,8 @@ BIGNUM *BN_mod_inverse(BIGNUM *out, const BIGNUM *a, const BIGNUM *n, goto err; } - BN_one(X); BN_zero(Y); - if (BN_copy(B, a) == NULL) { - goto err; - } - if (BN_copy(A, n) == NULL) { + if (!BN_one(X) || BN_copy(B, a) == NULL || BN_copy(A, n) == NULL) { goto err; } A->neg = 0; @@ -570,12 +566,8 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *out, const BIGNUM *a, goto err; } - BN_one(X); BN_zero(Y); - if (BN_copy(B, a) == NULL) { - goto err; - } - if (BN_copy(A, n) == NULL) { + if (!BN_one(X) || BN_copy(B, a) == NULL || BN_copy(A, n) == NULL) { goto err; } A->neg = 0; |