aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
Diffstat (limited to 'checks')
-rw-r--r--checks/cvc_tests.cpp48
-rw-r--r--checks/ec_tests.cpp78
-rw-r--r--checks/ecdsa.cpp16
-rw-r--r--checks/eckaeg.cpp91
-rw-r--r--checks/pk_bench.cpp28
-rw-r--r--checks/x509.cpp2
6 files changed, 132 insertions, 131 deletions
diff --git a/checks/cvc_tests.cpp b/checks/cvc_tests.cpp
index 7904a2700..d041569ba 100644
--- a/checks/cvc_tests.cpp
+++ b/checks/cvc_tests.cpp
@@ -91,9 +91,9 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
opts.hash_alg = "SHA-256";
// creating a non sense selfsigned cert w/o dom pars
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.36.3.3.2.8.1.1.11"));
+ EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.11"));
ECDSA_PrivateKey key(rng, dom_pars);
- key.set_parameter_encoding(ENC_IMPLICITCA);
+ key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_CVC cert = CVC_EAC::create_self_signed_cert(key, opts, rng);
SecureVector<byte> der(cert.BER_encode());
@@ -169,11 +169,11 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
// let´s see if encoding is truely implicitca, because this is what the key should have
// been set to when decoding (see above)(because it has no domain params):
//cout << "encoding = " << p_ecdsa_pk->get_parameter_encoding() << std::endl;
- CHECK(p_ecdsa_pk->get_parameter_encoding() == ENC_IMPLICITCA);
+ CHECK(p_ecdsa_pk->domain_format() == EC_DOMPAR_ENC_IMPLICITCA);
bool exc = false;
try
{
- std::cout << "order = " << p_ecdsa_pk->domain_parameters().get_order() << std::endl;
+ std::cout << "order = " << p_ecdsa_pk->domain().get_order() << std::endl;
}
catch (Invalid_State)
{
@@ -184,8 +184,8 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
//cert_in.set_domain_parameters(dom_pars);
std::unique_ptr<Public_Key> p_pk2 = cert_in.subject_public_key();
ECDSA_PublicKey* p_ecdsa_pk2 = dynamic_cast<ECDSA_PublicKey*>(p_pk2.get());
- p_ecdsa_pk2->set_domain_parameters(dom_pars);
- CHECK(p_ecdsa_pk2->domain_parameters().get_order() == dom_pars.get_order());
+ //p_ecdsa_pk2->set_domain_parameters(dom_pars);
+ CHECK(p_ecdsa_pk2->domain().get_order() == dom_pars.get_order());
bool ver_ec = cert_in.check_signature(*p_pk2);
CHECK_MESSAGE(ver_ec, "could not positively verify correct selfsigned cvc certificate");
}
@@ -201,9 +201,9 @@ void test_enc_gen_req(RandomNumberGenerator& rng)
opts.hash_alg = "SHA-160";
// creating a non sense selfsigned cert w/o dom pars
- 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"));
ECDSA_PrivateKey key(rng, dom_pars);
- key.set_parameter_encoding(ENC_IMPLICITCA);
+ key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_Req req = CVC_EAC::create_cvc_req(key, opts.chr, opts.hash_alg, rng);
SecureVector<byte> der(req.BER_encode());
std::ofstream req_file(TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
@@ -215,8 +215,8 @@ void test_enc_gen_req(RandomNumberGenerator& rng)
//req_in.set_domain_parameters(dom_pars);
std::unique_ptr<Public_Key> p_pk = req_in.subject_public_key();
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
- p_ecdsa_pk->set_domain_parameters(dom_pars);
- CHECK(p_ecdsa_pk->domain_parameters().get_order() == dom_pars.get_order());
+ //p_ecdsa_pk->set_domain_parameters(dom_pars);
+ CHECK(p_ecdsa_pk->domain().get_order() == dom_pars.get_order());
bool ver_ec = req_in.check_signature(*p_pk);
CHECK_MESSAGE(ver_ec, "could not positively verify correct selfsigned (created by myself) cvc request");
}
@@ -226,12 +226,12 @@ void test_cvc_req_ext(RandomNumberGenerator&)
std::cout << "." << std::flush;
EAC1_1_Req req_in(TEST_DATA_DIR "/DE1_flen_chars_cvcRequest_ECDSA.der");
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
//req_in.set_domain_parameters(dom_pars);
std::unique_ptr<Public_Key> p_pk = req_in.subject_public_key();
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
- p_ecdsa_pk->set_domain_parameters(dom_pars);
- CHECK(p_ecdsa_pk->domain_parameters().get_order() == dom_pars.get_order());
+ //p_ecdsa_pk->set_domain_parameters(dom_pars);
+ CHECK(p_ecdsa_pk->domain().get_order() == dom_pars.get_order());
bool ver_ec = req_in.check_signature(*p_pk);
CHECK_MESSAGE(ver_ec, "could not positively verify correct selfsigned (external testdata) cvc request");
}
@@ -241,7 +241,7 @@ void test_cvc_ado_ext(RandomNumberGenerator&)
std::cout << "." << std::flush;
EAC1_1_ADO req_in(TEST_DATA_DIR "/ado.cvcreq");
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
//cout << "car = " << req_in.get_car().value() << std::endl;
//req_in.set_domain_parameters(dom_pars);
}
@@ -256,10 +256,10 @@ void test_cvc_ado_creation(RandomNumberGenerator& rng)
opts.hash_alg = "SHA-256";
// creating a non sense selfsigned cert w/o dom pars
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.36.3.3.2.8.1.1.11"));
+ EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.11"));
//cout << "mod = " << hex << dom_pars.get_curve().get_p() << std::endl;
ECDSA_PrivateKey req_key(rng, dom_pars);
- req_key.set_parameter_encoding(ENC_IMPLICITCA);
+ req_key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
//EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts);
EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts.chr, opts.hash_alg, rng);
SecureVector<byte> der(req.BER_encode());
@@ -300,9 +300,9 @@ void test_cvc_ado_comparison(RandomNumberGenerator& rng)
opts.hash_alg = "SHA-224";
// creating a non sense selfsigned cert w/o dom pars
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.36.3.3.2.8.1.1.11"));
+ EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.11"));
ECDSA_PrivateKey req_key(rng, dom_pars);
- req_key.set_parameter_encoding(ENC_IMPLICITCA);
+ req_key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
//EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts);
EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts.chr, opts.hash_alg, rng);
@@ -321,7 +321,7 @@ void test_cvc_ado_comparison(RandomNumberGenerator& rng)
opts2.chr = ASN1_Chr("my_opt_chr");
opts2.hash_alg = "SHA-160"; // this is the only difference
ECDSA_PrivateKey req_key2(rng, dom_pars);
- req_key.set_parameter_encoding(ENC_IMPLICITCA);
+ req_key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
//EAC1_1_Req req2 = CVC_EAC::create_cvc_req(req_key2, opts2, rng);
EAC1_1_Req req2 = CVC_EAC::create_cvc_req(req_key2, opts2.chr, opts2.hash_alg, rng);
ECDSA_PrivateKey ado_key2(rng, dom_pars);
@@ -400,7 +400,7 @@ void test_ver_cvca(RandomNumberGenerator&)
try
{
- p_ecdsa_pk2->domain_parameters().get_order();
+ p_ecdsa_pk2->domain().get_order();
}
catch (Invalid_State)
{
@@ -420,14 +420,14 @@ void test_copy_and_assignment(RandomNumberGenerator&)
CHECK(cert_in == cert_ass);
EAC1_1_ADO ado_in(TEST_DATA_DIR "/ado.cvcreq");
- //EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ //EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
EAC1_1_ADO ado_cp(ado_in);
EAC1_1_ADO ado_ass = ado_in;
CHECK(ado_in == ado_cp);
CHECK(ado_in == ado_ass);
EAC1_1_Req req_in(TEST_DATA_DIR "/DE1_flen_chars_cvcRequest_ECDSA.der");
- //EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ //EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
EAC1_1_Req req_cp(req_in);
EAC1_1_Req req_ass = req_in;
CHECK(req_in == req_cp);
@@ -488,7 +488,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
ECDSA_PrivateKey cvca_privk(rng, dom_pars);
std::string hash("SHA-224");
ASN1_Car car("DECVCA00001");
@@ -544,7 +544,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
std::unique_ptr<Public_Key> ap_pk = dvca_cert1.subject_public_key();
ECDSA_PublicKey* cert_pk = dynamic_cast<ECDSA_PublicKey*>(ap_pk.get());
- cert_pk->set_domain_parameters(dom_pars);
+ //cert_pk->set_domain_parameters(dom_pars);
//std::cout << "dvca_cert.public_point.size() = " << ec::EC2OSP(cert_pk->get_public_point(), ec::PointGFp::COMPRESSED).size() << std::endl;
EAC1_1_CVC dvca_cert1_reread(TEST_DATA_DIR "/cvc_chain_cvca.cer");
CHECK(dvca_ado2.check_signature(*cert_pk));
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());
}
diff --git a/checks/ecdsa.cpp b/checks/ecdsa.cpp
index 862677e63..6767db154 100644
--- a/checks/ecdsa.cpp
+++ b/checks/ecdsa.cpp
@@ -47,7 +47,7 @@ void test_hash_larger_than_n(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"));
// n:
// 0x0100000000000000000001f4c8f927aed3ca752257 // 21 bytes
// -> shouldn't work with SHA224 which outputs 23 bytes
@@ -124,7 +124,7 @@ void test_message_larger_than_n(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"));
ECDSA_PrivateKey priv_key(rng, dom_pars);
std::string str_message = ("12345678901234567890abcdef1212345678901234567890abcdef1212345678901234567890abcdef12");
@@ -219,7 +219,7 @@ bool test_ec_sign(RandomNumberGenerator& rng)
try
{
- 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"));
ECDSA_PrivateKey priv_key(rng, dom_pars);
std::string pem_encoded_key = PKCS8::PEM_encode(priv_key);
@@ -283,7 +283,7 @@ void test_create_pkcs8(RandomNumberGenerator& rng)
std::ofstream rsa_priv_key(TEST_DATA_DIR "/rsa_private.pkcs8.pem");
rsa_priv_key << PKCS8::PEM_encode(rsa_key);
- 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"));
ECDSA_PrivateKey key(rng, dom_pars);
// later used by other tests :(
@@ -300,7 +300,7 @@ void test_create_and_verify(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"));
ECDSA_PrivateKey key(rng, dom_pars);
std::ofstream priv_key(TEST_DATA_DIR "/dompar_private.pkcs8.pem");
priv_key << PKCS8::PEM_encode(key);
@@ -389,7 +389,8 @@ void test_curve_registry(RandomNumberGenerator& rng)
try
{
- EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid(oids[i]));
+ OID oid(oids[i]);
+ EC_Domain_Params dom_pars(oid);
dom_pars.get_base_point().check_invariants();
ECDSA_PrivateKey key(rng, dom_pars);
@@ -490,8 +491,7 @@ void test_non_init_ecdsa_keys(RandomNumberGenerator& rng)
std::cout << "." << std::flush;
std::unique_ptr<PKCS8_PrivateKey> loaded_key(PKCS8::load_key(TEST_DATA_DIR "/wo_dompar_private.pkcs8.pem", rng));
- //ECDSA_PrivateKey* loaded_ec_key = dynamic_cast<ECDSA_PrivateKey*>(loaded_key.get());
- //CHECK_MESSAGE(loaded_ec_key, "the loaded key could not be converted into an ECDSA_PrivateKey");
+
std::string str_message = ("12345678901234567890abcdef12");
ECDSA_PrivateKey empty_priv;
ECDSA_PublicKey empty_pub;
diff --git a/checks/eckaeg.cpp b/checks/eckaeg.cpp
index 3f5443607..bc7945a7b 100644
--- a/checks/eckaeg.cpp
+++ b/checks/eckaeg.cpp
@@ -1,30 +1,28 @@
-/******************************************************
-* ECKAEG tests *
-* *
-* (C) 2007 Manuel Hartl *
-* 2008 Jack Lloyd *
-******************************************************/
+/*
+* ECDH tests
+*
+* (C) 2007 Manuel Hartl ([email protected])
+* 2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/build.h>
#include "validate.h"
#include "common.h"
-#if defined(BOTAN_HAS_ECKAEG)
+#if defined(BOTAN_HAS_ECDH)
#include <iostream>
#include <fstream>
#include <botan/symkey.h>
#include <botan/dh.h>
-#include <botan/eckaeg.h>
+#include <botan/ecdh.h>
#include <botan/x509self.h>
#include <botan/der_enc.h>
-#include <botan/point_gfp.h>
-#include <botan/curve_gfp.h>
-
using namespace Botan;
#define CHECK_MESSAGE(expr, print) try { if(!(expr)) std::cout << print << "\n"; } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; }
@@ -64,17 +62,17 @@ void test_eckaeg_normal_derivation(RandomNumberGenerator& rng)
Botan::EC_Domain_Params dom_pars = Botan::EC_Domain_Params(curve, p_G, order, cofactor);
/**
- * begin ECKAEG
+ * begin ECDH
*/
// alices key (a key constructed by domain parameters IS an ephimeral key!)
- Botan::ECKAEG_PrivateKey private_a(rng, dom_pars);
- Botan::ECKAEG_PublicKey public_a = private_a; // Bob gets this
+ Botan::ECDH_PrivateKey private_a(rng, dom_pars);
+ Botan::ECDH_PublicKey public_a = private_a; // Bob gets this
// Bob creates a key with a matching group
- Botan::ECKAEG_PrivateKey private_b(rng, dom_pars); //public_a.getCurve()
+ Botan::ECDH_PrivateKey private_b(rng, dom_pars); //public_a.getCurve()
// Bob sends the key back to Alice
- Botan::ECKAEG_PublicKey public_b = private_b; // Alice gets this
+ Botan::ECDH_PublicKey public_b = private_b; // Alice gets this
// Both of them create a key using their private key and the other's
// public key
@@ -99,9 +97,11 @@ void test_eckaeg_some_dp(RandomNumberGenerator& rng)
for(Botan::u32bit i = 0; i< oids.size(); i++)
{
std::cout << "." << std::flush;
- Botan::EC_Domain_Params dom_pars(Botan::get_EC_Dom_Pars_by_oid(oids[i]));
- Botan::ECKAEG_PrivateKey private_a(rng, dom_pars);
- Botan::ECKAEG_PublicKey public_a = private_a;
+
+ Botan::OID oid(oids[i]);
+ Botan::EC_Domain_Params dom_pars(oid);
+ Botan::ECDH_PrivateKey private_a(rng, dom_pars);
+ Botan::ECDH_PublicKey public_a = private_a;
/*unique_ptr<Botan::X509_Encoder> x509_key_enc = public_a.x509_encoder();
Botan::MemoryVector<Botan::byte> enc_key_a = Botan::DER_Encoder()
.start_cons(Botan::SEQUENCE)
@@ -110,8 +110,8 @@ void test_eckaeg_some_dp(RandomNumberGenerator& rng)
.end_cons()
.get_contents();*/
- Botan::ECKAEG_PrivateKey private_b(rng, dom_pars);
- Botan::ECKAEG_PublicKey public_b = private_b;
+ Botan::ECDH_PrivateKey private_b(rng, dom_pars);
+ Botan::ECDH_PublicKey public_b = private_b;
// to test the equivalence, we
// use the direct derivation method here
@@ -135,13 +135,14 @@ void test_eckaeg_der_derivation(RandomNumberGenerator& rng)
for(Botan::u32bit i = 0; i< oids.size(); i++)
{
- Botan::EC_Domain_Params dom_pars(Botan::get_EC_Dom_Pars_by_oid(oids[i]));
+ Botan::OID oid(oids[i]);
+ Botan::EC_Domain_Params dom_pars(oid);
- Botan::ECKAEG_PrivateKey private_a(rng, dom_pars);
- Botan::ECKAEG_PublicKey public_a = private_a;
+ Botan::ECDH_PrivateKey private_a(rng, dom_pars);
+ Botan::ECDH_PublicKey public_a = private_a;
- Botan::ECKAEG_PrivateKey private_b(rng, dom_pars);
- Botan::ECKAEG_PublicKey public_b = private_b;
+ Botan::ECDH_PrivateKey private_b(rng, dom_pars);
+ Botan::ECDH_PublicKey public_b = private_b;
Botan::MemoryVector<Botan::byte> key_der_a = private_a.public_value();
Botan::MemoryVector<Botan::byte> key_der_b = private_b.public_value();
@@ -171,26 +172,26 @@ void test_eckaeg_cp_ctor_as_op(RandomNumberGenerator& rng)
Botan::EC_Domain_Params dom_pars = Botan::EC_Domain_Params(curve, p_G, order, cofactor);
/**
- * begin ECKAEG
+ * begin ECDH
*/
// alices key (a key constructed by domain parameters IS an ephimeral key!)
- Botan::ECKAEG_PrivateKey private_a(rng, dom_pars);
- Botan::ECKAEG_PrivateKey private_a2(private_a);
- Botan::ECKAEG_PrivateKey private_a3;
+ Botan::ECDH_PrivateKey private_a(rng, dom_pars);
+ Botan::ECDH_PrivateKey private_a2(private_a);
+ Botan::ECDH_PrivateKey private_a3;
private_a3 = private_a2;
Botan::DH_PrivateKey dh_pr_empty;
Botan::DH_PublicKey dh_pub_empty;
- Botan::ECKAEG_PublicKey public_a = private_a; // Bob gets this
- Botan::ECKAEG_PublicKey public_a2(public_a);
- Botan::ECKAEG_PublicKey public_a3;
+ Botan::ECDH_PublicKey public_a = private_a; // Bob gets this
+ Botan::ECDH_PublicKey public_a2(public_a);
+ Botan::ECDH_PublicKey public_a3;
public_a3 = public_a;
// Bob creates a key with a matching group
- Botan::ECKAEG_PrivateKey private_b(rng, dom_pars); //public_a.getCurve()
+ Botan::ECDH_PrivateKey private_b(rng, dom_pars); //public_a.getCurve()
// Bob sends the key back to Alice
- Botan::ECKAEG_PublicKey public_b = private_b; // Alice gets this
+ Botan::ECDH_PublicKey public_b = private_b; // Alice gets this
// Both of them create a key using their private key and the other's
// public key
@@ -210,7 +211,7 @@ void test_eckaeg_cp_ctor_as_op(RandomNumberGenerator& rng)
}
/**
-* The following test tests whether ECKAEG keys exhibit correct behaviour when it is
+* The following test tests whether ECDH keys exhibit correct behaviour when it is
* attempted to use them in an uninitialized state
*/
void test_non_init_eckaeg_keys(RandomNumberGenerator& rng)
@@ -230,13 +231,13 @@ void test_non_init_eckaeg_keys(RandomNumberGenerator& rng)
Botan::EC_Domain_Params dom_pars = Botan::EC_Domain_Params(curve, p_G, order, cofactor);
// alices key (a key constructed by domain parameters IS an emphemeral key!)
- Botan::ECKAEG_PrivateKey private_a(rng, dom_pars);
- Botan::ECKAEG_PrivateKey private_b(rng, dom_pars);
+ Botan::ECDH_PrivateKey private_a(rng, dom_pars);
+ Botan::ECDH_PrivateKey private_b(rng, dom_pars);
- Botan::ECKAEG_PublicKey public_b;
+ Botan::ECDH_PublicKey public_b;
- Botan::ECKAEG_PrivateKey private_empty;
- Botan::ECKAEG_PublicKey public_empty;
+ Botan::ECDH_PrivateKey private_empty;
+ Botan::ECDH_PublicKey public_empty;
bool exc1 = false;
try
@@ -248,7 +249,7 @@ void test_non_init_eckaeg_keys(RandomNumberGenerator& rng)
exc1 = true;
}
- CHECK_MESSAGE(exc1, "there was no exception thrown when attempting to use an uninitialized ECKAEG key");
+ CHECK_MESSAGE(exc1, "there was no exception thrown when attempting to use an uninitialized ECDH key");
bool exc2 = false;
try
@@ -260,14 +261,14 @@ void test_non_init_eckaeg_keys(RandomNumberGenerator& rng)
exc2 = true;
}
- CHECK_MESSAGE(exc2, "there was no exception thrown when attempting to use an uninitialized ECKAEG key");
+ CHECK_MESSAGE(exc2, "there was no exception thrown when attempting to use an uninitialized ECDH key");
}
}
u32bit do_eckaeg_tests(Botan::RandomNumberGenerator& rng)
{
- std::cout << "Testing ECKAEG (InSiTo unit tests): ";
+ std::cout << "Testing ECDH (InSiTo unit tests): ";
test_eckaeg_normal_derivation(rng);
test_eckaeg_some_dp(rng);
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index 4a70a5899..84eba79e2 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -45,8 +45,8 @@
#include <botan/ecdsa.h>
#endif
-#if defined(BOTAN_HAS_ECKAEG)
- #include <botan/eckaeg.h>
+#if defined(BOTAN_HAS_ECDH)
+ #include <botan/ecdh.h>
#endif
using namespace Botan;
@@ -296,7 +296,8 @@ void benchmark_ecdsa(RandomNumberGenerator& rng,
for(size_t j = 0; domains[j]; j++)
{
- EC_Domain_Params params = get_EC_Dom_Pars_by_oid(domains[j]);
+ OID oid(domains[j]);
+ EC_Domain_Params params(oid);
u32bit pbits = params.get_curve().get_p().bits();
@@ -337,7 +338,7 @@ void benchmark_ecdsa(RandomNumberGenerator& rng,
#endif
-#if defined(BOTAN_HAS_ECKAEG)
+#if defined(BOTAN_HAS_ECDH)
void benchmark_eckaeg(RandomNumberGenerator& rng,
double seconds,
@@ -353,7 +354,8 @@ void benchmark_eckaeg(RandomNumberGenerator& rng,
for(size_t j = 0; domains[j]; j++)
{
- EC_Domain_Params params = get_EC_Dom_Pars_by_oid(domains[j]);
+ OID oid(domains[j]);
+ EC_Domain_Params params(oid);
u32bit pbits = params.get_curve().get_p().bits();
@@ -363,15 +365,15 @@ void benchmark_eckaeg(RandomNumberGenerator& rng,
while(kex_timer.seconds() < seconds)
{
keygen_timer.start();
- ECKAEG_PrivateKey eckaeg1(rng, params);
+ ECDH_PrivateKey eckaeg1(rng, params);
keygen_timer.stop();
keygen_timer.start();
- ECKAEG_PrivateKey eckaeg2(rng, params);
+ ECDH_PrivateKey eckaeg2(rng, params);
keygen_timer.stop();
- ECKAEG_PublicKey pub1(eckaeg1);
- ECKAEG_PublicKey pub2(eckaeg2);
+ ECDH_PublicKey pub1(eckaeg1);
+ ECDH_PublicKey pub2(eckaeg2);
SecureVector<byte> secret1, secret2;
@@ -389,11 +391,11 @@ void benchmark_eckaeg(RandomNumberGenerator& rng,
kex_timer.stop();
if(secret1 != secret2)
- std::cerr << "ECKAEG secrets did not match, bug in the library!?!\n";
+ std::cerr << "ECDH secrets did not match, bug in the library!?!\n";
}
}
- const std::string nm = "ECKAEG-" + std::to_string(pbits);
+ const std::string nm = "ECDH-" + std::to_string(pbits);
report.report(nm, keygen_timer);
report.report(nm, kex_timer);
}
@@ -670,8 +672,8 @@ void bench_pk(RandomNumberGenerator& rng,
benchmark_ecdsa(rng, seconds, report);
#endif
-#if defined(BOTAN_HAS_ECKAEG)
- if(algo == "All" || algo == "ECKAEG")
+#if defined(BOTAN_HAS_ECDH)
+ if(algo == "All" || algo == "ECDH")
benchmark_eckaeg(rng, seconds, report);
#endif
diff --git a/checks/x509.cpp b/checks/x509.cpp
index 3a48f57f9..a86df7691 100644
--- a/checks/x509.cpp
+++ b/checks/x509.cpp
@@ -161,7 +161,7 @@ void do_x509_tests(RandomNumberGenerator& rng)
/* Create user #2's key and cert request */
std::cout << '.' << std::flush;
#if defined(BOTAN_HAS_ECDSA)
- EC_Domain_Params ecc_domain = get_EC_Dom_Pars_by_oid("1.2.840.10045.3.1.7");
+ EC_Domain_Params ecc_domain(OID("1.2.840.10045.3.1.7"));
ECDSA_PrivateKey user2_key(rng, ecc_domain);
#else
RSA_PrivateKey user2_key(rng, 1024);