Skip to content

Commit

Permalink
update master-with-bazel from master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
BoringSSL Robot committed Jan 15, 2020
2 parents 9473bbd + 0416e8c commit b9f169e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
47 changes: 40 additions & 7 deletions src/crypto/fipsmodule/ec/ec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -879,11 +879,45 @@ TEST(ECTest, ScalarBaseMultVectors) {
ASSERT_TRUE(
EC_POINT_mul(group.get(), p.get(), nullptr, g, n.get(), ctx.get()));
check_point(p.get());
});
}

// These tests take a very long time, but are worth running when we make
// non-trivial changes to the EC code.
TEST(ECTest, DISABLED_ScalarBaseMultVectorsTwoPoint) {
bssl::UniquePtr<BN_CTX> ctx(BN_CTX_new());
ASSERT_TRUE(ctx);

FileTestGTest("crypto/fipsmodule/ec/ec_scalar_base_mult_tests.txt",
[&](FileTest *t) {
bssl::UniquePtr<EC_GROUP> group = GetCurve(t, "Curve");
ASSERT_TRUE(group);
bssl::UniquePtr<BIGNUM> n = GetBIGNUM(t, "N");
ASSERT_TRUE(n);
bssl::UniquePtr<BIGNUM> x = GetBIGNUM(t, "X");
ASSERT_TRUE(x);
bssl::UniquePtr<BIGNUM> y = GetBIGNUM(t, "Y");
ASSERT_TRUE(y);
bool is_infinity = BN_is_zero(x.get()) && BN_is_zero(y.get());

bssl::UniquePtr<BIGNUM> px(BN_new());
ASSERT_TRUE(px);
bssl::UniquePtr<BIGNUM> py(BN_new());
ASSERT_TRUE(py);
auto check_point = [&](const EC_POINT *p) {
if (is_infinity) {
EXPECT_TRUE(EC_POINT_is_at_infinity(group.get(), p));
} else {
ASSERT_TRUE(EC_POINT_get_affine_coordinates_GFp(
group.get(), p, px.get(), py.get(), ctx.get()));
EXPECT_EQ(0, BN_cmp(x.get(), px.get()));
EXPECT_EQ(0, BN_cmp(y.get(), py.get()));
}
};

// These tests take a very long time, but are worth running when we make
// non-trivial changes to the EC code.
#if 0
// Test two-point multiplication.
const EC_POINT *g = EC_GROUP_get0_generator(group.get());
bssl::UniquePtr<EC_POINT> p(EC_POINT_new(group.get()));
ASSERT_TRUE(p);
bssl::UniquePtr<BIGNUM> a(BN_new()), b(BN_new());
for (int i = -64; i < 64; i++) {
SCOPED_TRACE(i);
Expand All @@ -905,11 +939,10 @@ TEST(ECTest, ScalarBaseMultVectors) {
EC_SCALAR a_scalar, b_scalar;
ASSERT_TRUE(ec_bignum_to_scalar(group.get(), &a_scalar, a.get()));
ASSERT_TRUE(ec_bignum_to_scalar(group.get(), &b_scalar, b.get()));
ASSERT_TRUE(ec_point_mul_scalar_public(group.get(), &p->raw, &a_scalar, &g->raw,
&b_scalar));
ASSERT_TRUE(ec_point_mul_scalar_public(group.get(), &p->raw, &a_scalar,
&g->raw, &b_scalar));
check_point(p.get());
}
#endif
});
}

Expand Down
9 changes: 6 additions & 3 deletions src/crypto/rsa_extra/rsa_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1118,9 +1118,13 @@ TEST(RSATest, Threads) {
}
}

#if defined(OPENSSL_X86_64)
// This test might be excessively slow on slower CPUs.
TEST(RSATest, BlindingCacheConcurrency) {
#if defined(OPENSSL_X86_64)
#define MAYBE_BlindingCacheConcurrency BlindingCacheConcurrency
#else
#define MAYBE_BlindingCacheConcurrency DISABLED_BlindingCacheConcurrency
#endif
TEST(RSATest, MAYBE_BlindingCacheConcurrency) {
bssl::UniquePtr<RSA> rsa(
RSA_private_key_from_bytes(kKey1, sizeof(kKey1) - 1));
ASSERT_TRUE(rsa);
Expand Down Expand Up @@ -1154,6 +1158,5 @@ TEST(RSATest, BlindingCacheConcurrency) {
thread.join();
}
}
#endif // X86_64

#endif // THREADS

0 comments on commit b9f169e

Please sign in to comment.