aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-07-03 09:36:25 -0400
committerJack Lloyd <[email protected]>2017-07-03 09:36:25 -0400
commit8041a14888c5d947fd0658712293c6593b5ae45e (patch)
treefc56e70eb01838c2af1bd813e0be83383979d4f6 /src/lib/pubkey
parent17cdc021e771666f7271973c76d8cff9e863cefb (diff)
parent3e953ddfac173bc54010eea92bbce917f9a32432 (diff)
Merge GH #1093 In EC keys, use OID encoding if possible
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r--src/lib/pubkey/ecc_key/ecc_key.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp
index 0c59c75fd..ad62f6ae3 100644
--- a/src/lib/pubkey/ecc_key/ecc_key.cpp
+++ b/src/lib/pubkey/ecc_key/ecc_key.cpp
@@ -30,9 +30,12 @@ size_t EC_PublicKey::estimated_strength() const
EC_PublicKey::EC_PublicKey(const EC_Group& dom_par,
const PointGFp& pub_point) :
- m_domain_params(dom_par), m_public_key(pub_point),
- m_domain_encoding(EC_DOMPAR_ENC_EXPLICIT)
+ m_domain_params(dom_par), m_public_key(pub_point)
{
+ if (!dom_par.get_oid().empty())
+ m_domain_encoding = EC_DOMPAR_ENC_OID;
+ else
+ m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT;
if(domain().get_curve() != public_point().get_curve())
throw Invalid_Argument("EC_PublicKey: curve mismatch in constructor");
}
@@ -40,9 +43,13 @@ EC_PublicKey::EC_PublicKey(const EC_Group& dom_par,
EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id,
const std::vector<uint8_t>& key_bits) :
m_domain_params{EC_Group(alg_id.parameters)},
- m_public_key{OS2ECP(key_bits, domain().get_curve())},
- m_domain_encoding{EC_DOMPAR_ENC_EXPLICIT}
- {}
+ m_public_key{OS2ECP(key_bits, domain().get_curve())}
+ {
+ if (!domain().get_oid().empty())
+ m_domain_encoding = EC_DOMPAR_ENC_OID;
+ else
+ m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT;
+ }
bool EC_PublicKey::check_key(RandomNumberGenerator& rng,
bool) const
@@ -120,7 +127,10 @@ EC_PrivateKey::EC_PrivateKey(RandomNumberGenerator& rng,
bool with_modular_inverse)
{
m_domain_params = ec_group;
- m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT;
+ if (!ec_group.get_oid().empty())
+ m_domain_encoding = EC_DOMPAR_ENC_OID;
+ else
+ m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT;
if(x == 0)
{