Skip to content

Commit

Permalink
Bug 1561331 - Additional modular inverse test r=jcj
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D36115

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Kevin Jacobs committed May 12, 2020
1 parent 4809f51 commit 81ca42b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions gtests/freebl_gtest/mpi_unittest.cc
Expand Up @@ -273,6 +273,44 @@ TEST_F(MPITest, MpiSqrMulClamp) {
}
}

TEST_F(MPITest, MpiInvModLoop) {
mp_int a;
mp_int m;
mp_int c_actual;
mp_int c_expect;
MP_DIGITS(&a) = 0;
MP_DIGITS(&m) = 0;
MP_DIGITS(&c_actual) = 0;
MP_DIGITS(&c_expect) = 0;
ASSERT_EQ(MP_OKAY, mp_init(&a));
ASSERT_EQ(MP_OKAY, mp_init(&m));
ASSERT_EQ(MP_OKAY, mp_init(&c_actual));
ASSERT_EQ(MP_OKAY, mp_init(&c_expect));
mp_read_radix(&a,
"3e10b9f4859fb9e8150cc0d94e83ef428d655702a0b6fb1e684f4755eb6be6"
"5ac6048cdfc533f73a9bad76125801051f",
16);
mp_read_radix(&m,
"ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372d"
"df581a0db248b0a77aecec196accc52973",
16);
mp_read_radix(&c_expect,
"12302214814361c15ab6c0f2131150af186099f8c22f6c9d6e77ad496b551c"
"7c8039e61098bfe2af66474420659435c6",
16);

int rv = mp_invmod(&a, &m, &c_actual);
ASSERT_EQ(MP_OKAY, rv);

rv = mp_cmp(&c_actual, &c_expect);
EXPECT_EQ(0, rv);

mp_clear(&a);
mp_clear(&m);
mp_clear(&c_actual);
mp_clear(&c_expect);
}

// This test is slow. Disable it by default so we can run these tests on CI.
class DISABLED_MPITest : public ::testing::Test {};

Expand Down

0 comments on commit 81ca42b

Please sign in to comment.