diff options
author | lloyd <[email protected]> | 2014-11-15 14:35:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-11-15 14:35:19 +0000 |
commit | 1518c30f1c90c2d0e5e06731e3dffe21353b34db (patch) | |
tree | c2f819f2a2011a7af6052ede3b32638412b546d0 /src/tests | |
parent | 17349a1fc49d604f8160f2077538fdf397b702c6 (diff) |
Add specialized reduction for P-521 along with 9x9 Comba routines.
Roughly 35-50% faster on my laptop (depending on if mlock is enabled,
the overhead in that allocator is becoming much more of a hotspot).
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/unit_ecc.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp index 9153ba1b9..6834a7f59 100644 --- a/src/tests/unit_ecc.cpp +++ b/src/tests/unit_ecc.cpp @@ -532,9 +532,9 @@ size_t test_enc_dec_compressed_256() BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); - CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); + CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp); - PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 ); + PointGFp p_G = OS2ECP ( sv_G_secp_comp, curve ); std::vector<byte> sv_result = unlock(EC2OSP(p_G, PointGFp::COMPRESSED)); CHECK( sv_result == sv_G_secp_comp); @@ -563,9 +563,9 @@ size_t test_enc_dec_uncompressed_112() BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); - CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); + CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp); - PointGFp p_G = OS2ECP ( sv_G_secp_uncomp, secp160r1 ); + PointGFp p_G = OS2ECP ( sv_G_secp_uncomp, curve ); std::vector<byte> sv_result = unlock(EC2OSP(p_G, PointGFp::UNCOMPRESSED)); CHECK( sv_result == sv_G_secp_uncomp); @@ -592,9 +592,9 @@ size_t test_enc_dec_uncompressed_521() BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() ); BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() ); - CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp); + CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp); - PointGFp p_G = OS2ECP ( sv_G_secp_uncomp, secp160r1 ); + PointGFp p_G = OS2ECP ( sv_G_secp_uncomp, curve ); std::vector<byte> sv_result = unlock(EC2OSP(p_G, PointGFp::UNCOMPRESSED)); std::string result = hex_encode(&sv_result[0], sv_result.size()); @@ -813,17 +813,22 @@ size_t randomized_test(RandomNumberGenerator& rng, const EC_Group& group) const BigInt b = BigInt::random_integer(rng, 2, group.get_order()); const BigInt c = a + b; - PointGFp P = group.get_base_point() * a; - PointGFp Q = group.get_base_point() * b; - PointGFp R = group.get_base_point() * c; + const PointGFp P = group.get_base_point() * a; + const PointGFp Q = group.get_base_point() * b; + const PointGFp R = group.get_base_point() * c; - PointGFp A1 = P + Q; - PointGFp A2 = Q + P; + const PointGFp A1 = P + Q; + const PointGFp A2 = Q + P; size_t fails = 0; CHECK(A1 == R); CHECK(A2 == R); + CHECK(P.on_the_curve()); + CHECK(Q.on_the_curve()); + CHECK(R.on_the_curve()); + CHECK(A1.on_the_curve()); + CHECK(A2.on_the_curve()); return fails; } @@ -842,7 +847,6 @@ size_t randomized_test() "brainpool384r1", "brainpool512r1", "gost_256A", - "gost_256A", "secp112r1", "secp112r2", "secp128r1", |