Browse Source

Reset |out_no_inverse| before returning errors in BN_mod_inverse_odd.

This more accurately reflects the documented contract for
|BN_mod_inverse_odd|.

Change-Id: Iae98dabe3943231859eaa5e798d06ebe0231b9f1
Reviewed-on: https://boringssl-review.googlesource.com/9160
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
kris/onging/CECPQ3_patch15
Brian Smith 8 years ago
committed by CQ bot account: commit-bot@chromium.org
parent
commit
e4a432687e
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      crypto/bn/gcd.c

+ 2
- 2
crypto/bn/gcd.c View File

@@ -231,6 +231,8 @@ static int bn_mod_inverse_general(BIGNUM *out, int *out_no_inverse,

int BN_mod_inverse_odd(BIGNUM *out, int *out_no_inverse, const BIGNUM *a,
const BIGNUM *n, BN_CTX *ctx) {
*out_no_inverse = 0;

if (!BN_is_odd(n)) {
OPENSSL_PUT_ERROR(BN, BN_R_CALLED_WITH_EVEN_MODULUS);
return 0;
@@ -245,8 +247,6 @@ int BN_mod_inverse_odd(BIGNUM *out, int *out_no_inverse, const BIGNUM *a,
int ret = 0;
int sign;

*out_no_inverse = 0;

BN_CTX_start(ctx);
A = BN_CTX_get(ctx);
B = BN_CTX_get(ctx);


Loading…
Cancel
Save