aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/ecc_key
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey/ecc_key')
-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)
{