aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-04-08 18:13:41 +0000
committerlloyd <[email protected]>2011-04-08 18:13:41 +0000
commit8b543e804375a788ae71d461c0f8cf5d4193fc25 (patch)
tree6177931cd84a9be204cdab6e62729954e69e0421 /checks
parent3b66bfd4da97189ec275e5f85b9f85009d3f8370 (diff)
ECC private keys had two different constructors, one taking a group
and a random number generator, and the other taking a group and a preset private key value. The DL private keys instead have on constructor for this; if the x value is zero, then a new random key is created. For consistency, do this with ECC as well. ECDH actually didn't have one of these constructors, forcing you to either load from PKCS #8 or else use a random key. Rename EC_Domain_Params to EC_Group, with a typedef for compatability. More doc updates. Update mtn ignores for Sphinx output
Diffstat (limited to 'checks')
-rw-r--r--checks/cvc_tests.cpp18
-rw-r--r--checks/ec_tests.cpp18
-rw-r--r--checks/ecdh.cpp6
-rw-r--r--checks/ecdsa.cpp14
-rw-r--r--checks/pk.cpp13
-rw-r--r--checks/pk_bench.cpp6
-rw-r--r--checks/x509.cpp2
7 files changed, 39 insertions, 38 deletions
diff --git a/checks/cvc_tests.cpp b/checks/cvc_tests.cpp
index acc6b91cb..334fb8581 100644
--- a/checks/cvc_tests.cpp
+++ b/checks/cvc_tests.cpp
@@ -90,7 +90,7 @@ 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(OID("1.3.36.3.3.2.8.1.1.11"));
+ EC_Group dom_pars(OID("1.3.36.3.3.2.8.1.1.11"));
ECDSA_PrivateKey key(rng, dom_pars);
key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_CVC cert = CVC_EAC::create_self_signed_cert(key, opts, rng);
@@ -200,7 +200,7 @@ 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(OID("1.3.132.0.8"));
+ EC_Group dom_pars(OID("1.3.132.0.8"));
ECDSA_PrivateKey key(rng, dom_pars);
key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_Req req = CVC_EAC::create_cvc_req(key, opts.chr, opts.hash_alg, rng);
@@ -225,7 +225,7 @@ 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(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ EC_Group dom_pars(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
//req_in.set_domain_parameters(dom_pars);
std::auto_ptr<Public_Key> p_pk(req_in.subject_public_key());
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
@@ -240,7 +240,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(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ EC_Group 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);
}
@@ -255,7 +255,7 @@ 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(OID("1.3.36.3.3.2.8.1.1.11"));
+ EC_Group 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(EC_DOMPAR_ENC_IMPLICITCA);
@@ -299,7 +299,7 @@ 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(OID("1.3.36.3.3.2.8.1.1.11"));
+ EC_Group 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(EC_DOMPAR_ENC_IMPLICITCA);
//EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts);
@@ -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(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ //EC_Group 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(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ //EC_Group 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(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
+ EC_Group 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");
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp
index e299fbcc0..bad0d8912 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -172,7 +172,7 @@ void test_point_transformation ()
std::cout << "." << std::flush;
// get a vailid point
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group dom_pars(OID("1.3.132.0.8"));
PointGFp p = dom_pars.get_base_point();
// get a copy
@@ -186,7 +186,7 @@ void test_point_mult ()
{
std::cout << "." << std::flush;
- EC_Domain_Params secp160r1(OIDS::lookup("secp160r1"));
+ EC_Group secp160r1(OIDS::lookup("secp160r1"));
const CurveGFp& curve = secp160r1.get_curve();
@@ -637,9 +637,9 @@ void test_gfp_store_restore()
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(OID("1.3.132.0.8"));
+ //EC_Group dom_pars = global_config().get_ec_dompar("1.3.132.0.8");
+ //EC_Group dom_pars("1.3.132.0.8");
+ EC_Group dom_pars(OID("1.3.132.0.8"));
PointGFp p = dom_pars.get_base_point();
//store point (to std::string)
@@ -724,7 +724,7 @@ void test_mult_by_order()
std::cout << "." << std::flush;
// generate point
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group dom_pars(OID("1.3.132.0.8"));
PointGFp p = dom_pars.get_base_point();
PointGFp shouldBeZero = p * dom_pars.get_order();
@@ -735,7 +735,7 @@ void test_point_swap(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group 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()));
@@ -756,7 +756,7 @@ void test_point_swap(RandomNumberGenerator& rng)
void test_mult_sec_mass(RandomNumberGenerator& rng)
{
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group dom_pars(OID("1.3.132.0.8"));
for(int i = 0; i<50; i++)
{
std::cout << "." << std::flush;
@@ -775,7 +775,7 @@ void test_curve_cp_ctor()
{
std::cout << "." << std::flush;
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group dom_pars(OID("1.3.132.0.8"));
CurveGFp curve(dom_pars.get_curve());
}
diff --git a/checks/ecdh.cpp b/checks/ecdh.cpp
index a63742f2f..c641796d6 100644
--- a/checks/ecdh.cpp
+++ b/checks/ecdh.cpp
@@ -33,7 +33,7 @@ void test_ecdh_normal_derivation(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group dom_pars(OID("1.3.132.0.8"));
ECDH_PrivateKey private_a(rng, dom_pars);
@@ -65,7 +65,7 @@ void test_ecdh_some_dp(RandomNumberGenerator& rng)
std::cout << "." << std::flush;
OID oid(oids[i]);
- EC_Domain_Params dom_pars(oid);
+ EC_Group dom_pars(oid);
ECDH_PrivateKey private_a(rng, dom_pars);
ECDH_PrivateKey private_b(rng, dom_pars);
@@ -91,7 +91,7 @@ void test_ecdh_der_derivation(RandomNumberGenerator& rng)
for(u32bit i = 0; i< oids.size(); i++)
{
OID oid(oids[i]);
- EC_Domain_Params dom_pars(oid);
+ EC_Group dom_pars(oid);
ECDH_PrivateKey private_a(rng, dom_pars);
ECDH_PrivateKey private_b(rng, dom_pars);
diff --git a/checks/ecdsa.cpp b/checks/ecdsa.cpp
index 12f62abba..58f76c9ba 100644
--- a/checks/ecdsa.cpp
+++ b/checks/ecdsa.cpp
@@ -48,7 +48,7 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
- EC_Domain_Params dom_pars(OID("1.3.132.0.8")); // secp160r1
+ EC_Group dom_pars(OID("1.3.132.0.8")); // secp160r1
// n = 0x0100000000000000000001f4c8f927aed3ca752257 (21 bytes)
// -> shouldn't work with SHA224 which outputs 28 bytes
@@ -137,7 +137,7 @@ void test_sign_then_ver(RandomNumberGenerator& rng)
{
std::cout << '.' << std::flush;
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group dom_pars(OID("1.3.132.0.8"));
ECDSA_PrivateKey ecdsa(rng, dom_pars);
PK_Signer signer(ecdsa, "EMSA1(SHA-1)");
@@ -165,7 +165,7 @@ bool test_ec_sign(RandomNumberGenerator& rng)
try
{
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group 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);
@@ -229,7 +229,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(OID("1.3.132.0.8"));
+ EC_Group dom_pars(OID("1.3.132.0.8"));
ECDSA_PrivateKey key(rng, dom_pars);
// later used by other tests :(
@@ -246,7 +246,7 @@ void test_create_and_verify(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
- EC_Domain_Params dom_pars(OID("1.3.132.0.8"));
+ EC_Group 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);
@@ -281,7 +281,7 @@ void test_create_and_verify(RandomNumberGenerator& rng)
CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, curve );
- EC_Domain_Params dom_params(curve, p_G, bi_order_g, BigInt(1));
+ EC_Group dom_params(curve, p_G, bi_order_g, BigInt(1));
if(!p_G.on_the_curve())
throw Internal_Error("Point not on the curve");
@@ -337,7 +337,7 @@ void test_curve_registry(RandomNumberGenerator& rng)
try
{
OID oid(oids[i]);
- EC_Domain_Params dom_pars(oid);
+ EC_Group dom_pars(oid);
ECDSA_PrivateKey ecdsa(rng, dom_pars);
PK_Signer signer(ecdsa, "EMSA1(SHA-1)");
diff --git a/checks/pk.cpp b/checks/pk.cpp
index f38cf97a6..6291b1566 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -498,15 +498,16 @@ u32bit validate_dsa_sig(const std::string& algo,
}
u32bit validate_ecdsa_sig(const std::string& algo,
- const std::vector<std::string>& str)
+ const std::vector<std::string>& str,
+ RandomNumberGenerator& rng)
{
if(str.size() != 5)
throw std::runtime_error("Invalid input from pk_valid.dat");
#if defined(BOTAN_HAS_ECDSA)
- EC_Domain_Params group(OIDS::lookup(str[0]));
- ECDSA_PrivateKey ecdsa(group, to_bigint(str[1]));
+ EC_Group group(OIDS::lookup(str[0]));
+ ECDSA_PrivateKey ecdsa(rng, group, to_bigint(str[1]));
std::string emsa = algo.substr(6, std::string::npos);
@@ -529,7 +530,7 @@ u32bit validate_gost_ver(const std::string& algo,
#if defined(BOTAN_HAS_GOST_34_10_2001)
- EC_Domain_Params group(OIDS::lookup(str[0]));
+ EC_Group group(OIDS::lookup(str[0]));
PointGFp public_point = OS2ECP(hex_decode(str[1]), group.get_curve());
@@ -696,7 +697,7 @@ void do_pk_keygen_tests(RandomNumberGenerator& rng)
#define EC_KEY(TYPE, GROUP) \
{ \
- TYPE key(rng, EC_Domain_Params(OIDS::lookup(GROUP))); \
+ TYPE key(rng, EC_Group(OIDS::lookup(GROUP))); \
key.check_key(rng, true); \
validate_save_and_load(&key, rng); \
std::cout << '.' << std::flush; \
@@ -855,7 +856,7 @@ u32bit do_pk_validation_tests(const std::string& filename,
new_errors = validate_dsa_ver(algorithm, substr);
else if(algorithm.find("ECDSA/") == 0)
- new_errors = validate_ecdsa_sig(algorithm, substr);
+ new_errors = validate_ecdsa_sig(algorithm, substr, rng);
else if(algorithm.find("GOST_3410_VA/") == 0)
new_errors = validate_gost_ver(algorithm, substr);
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index 348cb7ff1..b0e689b0c 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -305,7 +305,7 @@ void benchmark_ecdsa(RandomNumberGenerator& rng,
{
for(size_t j = 0; ec_domains[j]; j++)
{
- EC_Domain_Params params(OIDS::lookup(ec_domains[j]));
+ EC_Group params(ec_domains[j]);
const size_t pbits = params.get_curve().get_p().bits();
@@ -354,7 +354,7 @@ void benchmark_gost_3410(RandomNumberGenerator& rng,
{
for(size_t j = 0; ec_domains[j]; j++)
{
- EC_Domain_Params params(OIDS::lookup(ec_domains[j]));
+ EC_Group params(ec_domains[j]);
const size_t pbits = params.get_curve().get_p().bits();
@@ -396,7 +396,7 @@ void benchmark_ecdh(RandomNumberGenerator& rng,
{
for(size_t j = 0; ec_domains[j]; j++)
{
- EC_Domain_Params params(OIDS::lookup(ec_domains[j]));
+ EC_Group params(ec_domains[j]);
size_t pbits = params.get_curve().get_p().bits();
diff --git a/checks/x509.cpp b/checks/x509.cpp
index 43d374411..8c6cd8187 100644
--- a/checks/x509.cpp
+++ b/checks/x509.cpp
@@ -159,7 +159,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(OID("1.2.840.10045.3.1.7"));
+ EC_Group ecc_domain(OID("1.2.840.10045.3.1.7"));
ECDSA_PrivateKey user2_key(rng, ecc_domain);
#else
RSA_PrivateKey user2_key(rng, 1024);