update main-with-bazel from master branch

This commit is contained in:
BoringSSL Robot
2023-06-02 20:15:57 +00:00
2 changed files with 13 additions and 6 deletions
+8
View File
@@ -909,6 +909,14 @@ static void TestModInv(BIGNUMFileTest *t, BN_CTX *ctx) {
bn_mod_inverse_consttime(ret.get(), &no_inverse, a.get(), m.get(), ctx));
EXPECT_BIGNUMS_EQUAL("inv(A) (mod M) (constant-time)", mod_inv.get(),
ret.get());
ASSERT_TRUE(BN_copy(ret.get(), m.get()));
ASSERT_TRUE(BN_mod_inverse(ret.get(), a.get(), ret.get(), ctx));
EXPECT_BIGNUMS_EQUAL("inv(A) (mod M) (ret == m)", mod_inv.get(), ret.get());
ASSERT_TRUE(BN_copy(ret.get(), a.get()));
ASSERT_TRUE(BN_mod_inverse(ret.get(), ret.get(), m.get(), ctx));
EXPECT_BIGNUMS_EQUAL("inv(A) (mod M) (ret == a)", mod_inv.get(), ret.get());
}
static void TestGCD(BIGNUMFileTest *t, BN_CTX *ctx) {
+5 -6
View File
@@ -263,15 +263,14 @@ int BN_mod_inverse_odd(BIGNUM *out, int *out_no_inverse, const BIGNUM *a,
// Now Y*a == A (mod |n|).
// Y*a == 1 (mod |n|)
if (!Y->neg && BN_ucmp(Y, n) < 0) {
if (!BN_copy(R, Y)) {
goto err;
}
} else {
if (!BN_nnmod(R, Y, n, ctx)) {
if (Y->neg || BN_ucmp(Y, n) >= 0) {
if (!BN_nnmod(Y, Y, n, ctx)) {
goto err;
}
}
if (!BN_copy(R, Y)) {
goto err;
}
ret = 1;