aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--checks/cvc_tests.cpp18
-rw-r--r--checks/ec_tests.cpp14
-rw-r--r--checks/ecdsa.cpp13
-rw-r--r--checks/eckaeg.cpp7
-rw-r--r--checks/pk_bench.cpp6
-rw-r--r--checks/x509.cpp2
-rw-r--r--src/pubkey/ec_dompar/ec_dompar.cpp90
-rw-r--r--src/pubkey/ec_dompar/ec_dompar.h17
-rw-r--r--src/pubkey/gost_3410/gost_3410.cpp4
9 files changed, 81 insertions, 90 deletions
diff --git a/checks/cvc_tests.cpp b/checks/cvc_tests.cpp
index 454ed0b36..5a88a5535 100644
--- a/checks/cvc_tests.cpp
+++ b/checks/cvc_tests.cpp
@@ -91,7 +91,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(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(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_CVC cert = CVC_EAC::create_self_signed_cert(key, opts, rng);
@@ -201,7 +201,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(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(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_Req req = CVC_EAC::create_cvc_req(key, opts.chr, opts.hash_alg, rng);
@@ -226,7 +226,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(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::auto_ptr<Public_Key> p_pk = req_in.subject_public_key();
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
@@ -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,7 +256,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(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(EC_DOMPAR_ENC_IMPLICITCA);
@@ -300,7 +300,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(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(EC_DOMPAR_ENC_IMPLICITCA);
//EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts);
@@ -421,14 +421,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);
@@ -489,7 +489,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");
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp
index 0c814a136..ce3ff1195 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -186,7 +186,7 @@ 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
@@ -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 f9dcf5597..d76994937 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);
diff --git a/checks/eckaeg.cpp b/checks/eckaeg.cpp
index e5de2e425..d8a3f61d8 100644
--- a/checks/eckaeg.cpp
+++ b/checks/eckaeg.cpp
@@ -99,7 +99,9 @@ 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::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;
/*auto_ptr<Botan::X509_Encoder> x509_key_enc = public_a.x509_encoder();
@@ -135,7 +137,8 @@ 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;
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index a0ea1d1d3..124872866 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -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();
@@ -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();
diff --git a/checks/x509.cpp b/checks/x509.cpp
index 8b7ce7d47..0891d8b35 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);
diff --git a/src/pubkey/ec_dompar/ec_dompar.cpp b/src/pubkey/ec_dompar/ec_dompar.cpp
index 5ebf4932d..596edce83 100644
--- a/src/pubkey/ec_dompar/ec_dompar.cpp
+++ b/src/pubkey/ec_dompar/ec_dompar.cpp
@@ -17,13 +17,15 @@ namespace Botan {
namespace {
-std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
+std::vector<std::string> get_standard_domain_parameter(const OID& oid)
{
+ std::string oid_str = oid.as_string();
+
// using a linear search here is pretty nasty... revisit
/* SEC2 */
- if(oid == "1.3.132.0.6")
+ if(oid_str == "1.3.132.0.6")
{
/* secp112r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -37,7 +39,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.7")
+ if(oid_str == "1.3.132.0.7")
{
/* secp112r2; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -51,7 +53,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.28")
+ if(oid_str == "1.3.132.0.28")
{
/* secp128r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -65,7 +67,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.29")
+ if(oid_str == "1.3.132.0.29")
{
/* secp128r2; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -79,7 +81,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.9")
+ if(oid_str == "1.3.132.0.9")
{
/* secp160k1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -93,7 +95,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.30")
+ if(oid_str == "1.3.132.0.30")
{
/* secp160r2; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -107,7 +109,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.31")
+ if(oid_str == "1.3.132.0.31")
{
/* secp192k1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -121,7 +123,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.32")
+ if(oid_str == "1.3.132.0.32")
{
/* secp224k1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -135,7 +137,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.33")
+ if(oid_str == "1.3.132.0.33")
{
/* secp224r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -149,7 +151,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.10")
+ if(oid_str == "1.3.132.0.10")
{
/* secp256k1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -163,7 +165,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.34")
+ if(oid_str == "1.3.132.0.34")
{
/* secp384r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -177,7 +179,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.35")
+ if(oid_str == "1.3.132.0.35")
{
/* secp521r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -193,7 +195,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
/* NIS */
- if(oid == "1.3.6.1.4.1.8301.3.1.2.9.0.38")
+ if(oid_str == "1.3.6.1.4.1.8301.3.1.2.9.0.38")
{
/* NIST curve P-521; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -209,7 +211,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
/* BrainPool */
- if(oid == "1.3.36.3.3.2.8.1.1.1")
+ if(oid_str == "1.3.36.3.3.2.8.1.1.1")
{
/* brainpoolP160r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -223,7 +225,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.36.3.3.2.8.1.1.3")
+ if(oid_str == "1.3.36.3.3.2.8.1.1.3")
{
/* brainpoolP192r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -237,7 +239,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.36.3.3.2.8.1.1.5")
+ if(oid_str == "1.3.36.3.3.2.8.1.1.5")
{
/* brainpoolP224r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -251,7 +253,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.36.3.3.2.8.1.1.7")
+ if(oid_str == "1.3.36.3.3.2.8.1.1.7")
{
/* brainpoolP256r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -265,7 +267,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.36.3.3.2.8.1.1.9")
+ if(oid_str == "1.3.36.3.3.2.8.1.1.9")
{
/* brainpoolP320r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -279,7 +281,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.36.3.3.2.8.1.1.11")
+ if(oid_str == "1.3.36.3.3.2.8.1.1.11")
{
/* brainpoolP384r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -293,7 +295,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.36.3.3.2.8.1.1.13")
+ if(oid_str == "1.3.36.3.3.2.8.1.1.13")
{
/* brainpoolP512r1; source: Flexiprovider */
std::vector<std::string> dom_par;
@@ -307,7 +309,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.3.132.0.8")
+ if(oid_str == "1.3.132.0.8")
{
std::vector<std::string> dom_par;
dom_par.push_back("0xffffffffffffffffffffffffffffffff7fffffff"); //p
@@ -319,7 +321,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.2.840.10045.3.1.1") // prime192v1 Flexiprovider
+ if(oid_str == "1.2.840.10045.3.1.1") // prime192v1 Flexiprovider
{
std::vector<std::string> dom_par;
dom_par.push_back("0xfffffffffffffffffffffffffffffffeffffffffffffffff"); //p
@@ -332,7 +334,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
}
/* prime192v2; source: Flexiprovider */
- if(oid == "1.2.840.10045.3.1.2")
+ if(oid_str == "1.2.840.10045.3.1.2")
{
std::vector<std::string> dom_par;
dom_par.push_back("0xfffffffffffffffffffffffffffffffeffffffffffffffff"); //p
@@ -345,7 +347,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
}
/* prime192v3; source: Flexiprovider */
- if(oid == "1.2.840.10045.3.1.3")
+ if(oid_str == "1.2.840.10045.3.1.3")
{
std::vector<std::string> dom_par;
dom_par.push_back("0xfffffffffffffffffffffffffffffffeffffffffffffffff"); //p
@@ -358,7 +360,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
}
/* prime239v1; source: Flexiprovider */
- if(oid == "1.2.840.10045.3.1.4")
+ if(oid_str == "1.2.840.10045.3.1.4")
{
std::vector<std::string> dom_par;
dom_par.push_back("0x7fffffffffffffffffffffff7fffffffffff8000000000007fffffffffff"); //p
@@ -371,7 +373,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
}
/* prime239v2; source: Flexiprovider */
- if(oid == "1.2.840.10045.3.1.5")
+ if(oid_str == "1.2.840.10045.3.1.5")
{
std::vector<std::string> dom_par;
dom_par.push_back("0x7fffffffffffffffffffffff7fffffffffff8000000000007fffffffffff"); //p
@@ -384,7 +386,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
}
/* prime239v3; source: Flexiprovider */
- if(oid == "1.2.840.10045.3.1.6")
+ if(oid_str == "1.2.840.10045.3.1.6")
{
std::vector<std::string> dom_par;
dom_par.push_back("0x7fffffffffffffffffffffff7fffffffffff8000000000007fffffffffff"); //p
@@ -397,7 +399,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
}
/* prime256v1; source: Flexiprovider */
- if(oid == "1.2.840.10045.3.1.7")
+ if(oid_str == "1.2.840.10045.3.1.7")
{
std::vector<std::string> dom_par;
dom_par.push_back("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"); //p
@@ -409,7 +411,7 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- if(oid == "1.2.643.2.2.35.1" || oid == "1.2.643.2.2.36.0") // GostR3410-2001-CryptoPro-A-ParamSet
+ if(oid_str == "1.2.643.2.2.35.1" || oid_str == "1.2.643.2.2.36.0") // GostR3410-2001-CryptoPro-A-ParamSet
{
std::vector<std::string> dom_par;
dom_par.push_back("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97");
@@ -421,38 +423,28 @@ std::vector<std::string> get_standard_domain_parameter(const std::string& oid)
return dom_par;
}
- throw Invalid_Argument("No such ECC curve " + oid);
+ throw Invalid_Argument("No such ECC curve " + oid_str);
}
-EC_Domain_Params get_ec_dompar(const std::string& oid)
+}
+
+EC_Domain_Params::EC_Domain_Params(const OID& oid)
{
std::vector<std::string> dom_par = get_standard_domain_parameter(oid);
BigInt p(dom_par[0]); // give as 0x...
BigInt a(dom_par[1]);
BigInt b(dom_par[2]);
- BigInt order(dom_par[4]);
- BigInt cofactor(dom_par[5]);
Pipe pipe(new Hex_Decoder);
pipe.process_msg(dom_par[3]);
SecureVector<byte> sv_g = pipe.read_all();
- CurveGFp curve(p, a, b);
-
- PointGFp G = OS2ECP(sv_g, curve);
- G.check_invariants();
- EC_Domain_Params result(curve, G, order, cofactor);
- return result;
- }
-
-}
+ order = BigInt(dom_par[4]);
+ cofactor = BigInt(dom_par[5]);
-EC_Domain_Params get_EC_Dom_Pars_by_oid(std::string oid)
- {
- EC_Domain_Params result = get_ec_dompar(oid);
- result.oid = oid;
- return result;
+ curve = CurveGFp(p, a, b);
+ base_point = OS2ECP(sv_g, curve);
}
EC_Domain_Params::EC_Domain_Params(const MemoryRegion<byte>& ber_data)
@@ -466,7 +458,7 @@ EC_Domain_Params::EC_Domain_Params(const MemoryRegion<byte>& ber_data)
{
OID dom_par_oid;
BER_Decoder(ber_data).decode(dom_par_oid);
- *this = get_ec_dompar(dom_par_oid.as_string());
+ *this = EC_Domain_Params(dom_par_oid);
}
else if(obj.type_tag == SEQUENCE)
{
diff --git a/src/pubkey/ec_dompar/ec_dompar.h b/src/pubkey/ec_dompar/ec_dompar.h
index cc55aa4df..b2f1e5d7c 100644
--- a/src/pubkey/ec_dompar/ec_dompar.h
+++ b/src/pubkey/ec_dompar/ec_dompar.h
@@ -31,6 +31,7 @@ enum EC_Domain_Params_Encoding {
class BOTAN_DLL EC_Domain_Params
{
public:
+
/**
* Construct Domain paramers from specified parameters
* @param curve elliptic curve
@@ -56,6 +57,12 @@ class BOTAN_DLL EC_Domain_Params
EC_Domain_Params(const MemoryRegion<byte>& ber_encoding);
/**
+ * Create an EC domain by OID (or throw if unknown)
+ * @param oid the OID of the EC domain to create
+ */
+ EC_Domain_Params(const OID& oid);
+
+ /**
* Create the DER encoding of this domain
* @param form of encoding to use
* @returns bytes encododed as DER
@@ -115,16 +122,6 @@ inline bool operator!=(const EC_Domain_Params& lhs,
return !(lhs == rhs);
}
-/**
-* Factory function, the only way to obtain EC domain parameters with
-* an OID. The demanded OID has to be registered in the InSiTo
-* configuration. Consult the file ec_dompar.cpp for the default
-* configuration.
-* @param oid the oid of the demanded EC domain parameters
-* @result the EC domain parameters associated with the OID
-*/
-EC_Domain_Params BOTAN_DLL get_EC_Dom_Pars_by_oid(std::string oid);
-
}
#endif
diff --git a/src/pubkey/gost_3410/gost_3410.cpp b/src/pubkey/gost_3410/gost_3410.cpp
index 8f6b56324..a0225cbca 100644
--- a/src/pubkey/gost_3410/gost_3410.cpp
+++ b/src/pubkey/gost_3410/gost_3410.cpp
@@ -102,9 +102,7 @@ X509_Decoder* GOST_3410_PublicKey::x509_decoder()
BER_Decoder ber(alg_id.parameters);
ber.start_cons(SEQUENCE).decode(ecc_param_id);
- EC_Domain_Params ecc_params = get_EC_Dom_Pars_by_oid(ecc_param_id.as_string());
-
- key->mp_dom_pars.reset(new EC_Domain_Params(ecc_params));
+ key->mp_dom_pars.reset(new EC_Domain_Params(ecc_param_id));
}
void key_bits(const MemoryRegion<byte>& bits)