aboutsummaryrefslogtreecommitdiffstats
path: root/checks/ec_tests.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-02 05:08:15 +0000
committerlloyd <[email protected]>2010-03-02 05:08:15 +0000
commit3c15bd259f0921f1fa08ec91ee3cf2621c64a02d (patch)
tree54351d5e865a872896c6a95175693cc0ffa9e246 /checks/ec_tests.cpp
parent5fec937bd0c72858d6cf2f09b58b219294c7d5cc (diff)
parent54a3c5ae67f8b987d05ffd18e2d49a2da1d5988e (diff)
propagate from branch 'net.randombit.botan' (head fc86fc4842254088bf820ea6ebf05877aa63fb22)
to branch 'net.randombit.botan.c++0x' (head 77565ff7252df7f8faad86d65075498b0adb93d8)
Diffstat (limited to 'checks/ec_tests.cpp')
-rw-r--r--checks/ec_tests.cpp78
1 files changed, 38 insertions, 40 deletions
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp
index 637e3d988..2d23a3033 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -156,12 +156,12 @@ void test_coordinates()
PointGFp point_exp(secp160r1, exp_affine_x, exp_affine_y);
point_exp.check_invariants();
- if(p1.get_jac_proj_x() != exp_x)
- std::cout << p1.get_jac_proj_x() << " != " << exp_x << "\n";
- if(p1.get_jac_proj_y() != exp_y)
- std::cout << p1.get_jac_proj_y() << " != " << exp_y << "\n";
- if(p1.get_jac_proj_z() != exp_z)
- std::cout << p1.get_jac_proj_z() << " != " << exp_z << "\n";
+ if(p1.get_x() != exp_x)
+ std::cout << p1.get_x() << " != " << exp_x << "\n";
+ if(p1.get_y() != exp_y)
+ std::cout << p1.get_y() << " != " << exp_y << "\n";
+ if(p1.get_z() != exp_z)
+ std::cout << p1.get_z() << " != " << exp_z << "\n";
CHECK_MESSAGE( p1.get_affine_x() == exp_affine_x, " p1_x = " << p1.get_affine_x() << "\n" << "exp_x = " << exp_affine_x << "\n");
CHECK_MESSAGE( p1.get_affine_y() == exp_affine_y, " p1_y = " << p1.get_affine_y() << "\n" << "exp_y = " << exp_affine_y << "\n");
@@ -186,16 +186,16 @@ void test_point_transformation ()
// get a vailid point
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.132.0.8"));
+ EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
PointGFp p = dom_pars.get_base_point();
// get a copy
PointGFp q = p;
//turn on montg.
- CHECK_MESSAGE( p.get_jac_proj_x() == q.get_jac_proj_x(), "projective_x changed while turning on montg.!");
- CHECK_MESSAGE( p.get_jac_proj_y() == q.get_jac_proj_y(), "projective_y changed while turning on montg.!");
- CHECK_MESSAGE( p.get_jac_proj_z() == q.get_jac_proj_z(), "projective_z changed while turning on montg.!");
+ CHECK_MESSAGE( p.get_x() == q.get_x(), "projective_x changed while turning on montg.!");
+ CHECK_MESSAGE( p.get_y() == q.get_y(), "projective_y changed while turning on montg.!");
+ CHECK_MESSAGE( p.get_z() == q.get_z(), "projective_z changed while turning on montg.!");
CHECK_MESSAGE( p.get_affine_x() == q.get_affine_x(), "affine_x changed while turning on montg.!");
CHECK_MESSAGE( p.get_affine_y() == q.get_affine_y(), "affine_y changed while turning on montg.!");
}
@@ -231,9 +231,9 @@ void test_point_mult ()
SecureVector<byte> sv_d_U = decode_hex(str_d_U);
BigInt d_U = BigInt::decode(sv_d_U.begin(), sv_d_U.size());
PointGFp Q_U = d_U * p_G;
- CHECK( Q_U.get_jac_proj_x() == exp_Qx);
- CHECK( Q_U.get_jac_proj_y() == exp_Qy);
- CHECK( Q_U.get_jac_proj_z() == exp_Qz);
+ CHECK( Q_U.get_x() == exp_Qx);
+ CHECK( Q_U.get_y() == exp_Qy);
+ CHECK( Q_U.get_z() == exp_Qz);
}
void test_point_negative()
@@ -263,15 +263,15 @@ void test_point_negative()
PointGFp p1 = p_G *= 2;
- CHECK( p1.get_jac_proj_x() == exp_p1_x);
- CHECK( p1.get_jac_proj_y() == exp_p1_y);
- //cout << "p1.y_proj = " << p1.get_jac_proj_y() << "\n";
+ CHECK( p1.get_x() == exp_p1_x);
+ CHECK( p1.get_y() == exp_p1_y);
+ //cout << "p1.y_proj = " << p1.get_y() << "\n";
PointGFp p1_neg = p1.negate();
- //cout << "p1_neg.y_proj = " << p1_neg.get_jac_proj_y() << "\n";
+ //cout << "p1_neg.y_proj = " << p1_neg.get_y() << "\n";
//p1.negate();
- BigInt calc_y_value = p1_neg.get_jac_proj_y();
- BigInt calc_z_value = p1_neg.get_jac_proj_z();
- CHECK( p1_neg.get_jac_proj_x() == exp_p1_neg_x);
+ BigInt calc_y_value = p1_neg.get_y();
+ BigInt calc_z_value = p1_neg.get_z();
+ CHECK( p1_neg.get_x() == exp_p1_neg_x);
CHECK_MESSAGE( calc_y_value == exp_p1_neg_y, "calc_y_value = " << calc_y_value << "\nexp_p1_neg_v = " << exp_p1_neg_y);
//CHECK_MESSAGE( calc_z_value == exp_p1_neg_y, "calc_y_value = " << calc_y_value << "\nexp_p1_neg_v = " << exp_p1_neg_y);
}
@@ -453,7 +453,7 @@ void test_mult_point()
PointGFp p0 = p_G;
PointGFp p1 = p_G *= 2;
- p1 *= p0.get_jac_proj_x();
+ p1 *= p0.get_x();
PointGFp expected(secp160r1, exp_mult_x, exp_mult_y);
@@ -506,9 +506,9 @@ void test_basic_operations()
PointGFp p1 = p_G *= 2;
// check that all points have correct values
- CHECK( p1.get_jac_proj_x() == exp_p1_x);
- CHECK( p1.get_jac_proj_y() == exp_p1_y);
- CHECK( p1.get_jac_proj_z() == exp_p1_z);
+ CHECK( p1.get_x() == exp_p1_x);
+ CHECK( p1.get_y() == exp_p1_y);
+ CHECK( p1.get_z() == exp_p1_z);
PointGFp expected(secp160r1, exp_p0_x, exp_p0_y, exp_p0_z);
CHECK(p0 == expected);
@@ -522,18 +522,18 @@ void test_basic_operations()
CHECK(simpleMinus == exp_simpleMinus);
PointGFp simpleMult= p1 * 123456789;
- CHECK( simpleMult.get_jac_proj_x() == exp_mult_x);
- CHECK( simpleMult.get_jac_proj_y() == exp_mult_y);
- CHECK( simpleMult.get_jac_proj_z() == exp_mult_z);
+ CHECK( simpleMult.get_x() == exp_mult_x);
+ CHECK( simpleMult.get_y() == exp_mult_y);
+ CHECK( simpleMult.get_z() == exp_mult_z);
// check that all initial points hasn't changed
- CHECK( p1.get_jac_proj_x() == exp_p1_x);
- CHECK( p1.get_jac_proj_y() == exp_p1_y);
- CHECK( p1.get_jac_proj_z() == exp_p1_z);
+ CHECK( p1.get_x() == exp_p1_x);
+ CHECK( p1.get_y() == exp_p1_y);
+ CHECK( p1.get_z() == exp_p1_z);
- CHECK( p0.get_jac_proj_x() == exp_p0_x);
- CHECK( p0.get_jac_proj_y() == exp_p0_y);
- CHECK( p0.get_jac_proj_z() == exp_p0_z);
+ CHECK( p0.get_x() == exp_p0_x);
+ CHECK( p0.get_y() == exp_p0_y);
+ CHECK( p0.get_z() == exp_p0_z);
}
void test_enc_dec_compressed_160()
@@ -706,7 +706,7 @@ void test_gfp_store_restore()
// generate point
//EC_Domain_Params dom_pars = global_config().get_ec_dompar("1.3.132.0.8");
//EC_Domain_Params dom_pars("1.3.132.0.8");
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.132.0.8"));
+ EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
PointGFp p = dom_pars.get_base_point();
//store point (to std::string)
@@ -792,9 +792,7 @@ void test_mult_by_order()
std::cout << "." << std::flush;
// generate point
- //EC_Domain_Params dom_pars = global_config().get_ec_dompar("1.3.132.0.8");
- //EC_Domain_Params dom_pars("1.3.132.0.8");
- EC_Domain_Params dom_pars = get_EC_Dom_Pars_by_oid("1.3.132.0.8");
+ EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
PointGFp p = dom_pars.get_base_point();
PointGFp shouldBeZero = p * dom_pars.get_order();
@@ -805,7 +803,7 @@ void test_point_swap(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.132.0.8"));
+ EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
PointGFp a(create_random_point(rng, dom_pars.get_curve()));
PointGFp b(create_random_point(rng, dom_pars.get_curve()));
@@ -826,7 +824,7 @@ void test_point_swap(RandomNumberGenerator& rng)
void test_mult_sec_mass(RandomNumberGenerator& rng)
{
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.132.0.8"));
+ EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
for(int i = 0; i<50; i++)
{
std::cout << "." << std::flush;
@@ -845,7 +843,7 @@ void test_curve_cp_ctor()
{
std::cout << "." << std::flush;
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.132.0.8"));
+ EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
CurveGFp curve(dom_pars.get_curve());
}