diff options
-rw-r--r-- | src/lib/pubkey/ecc_key/ecc_key.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp index cb0af42eb..fd1e9dd83 100644 --- a/src/lib/pubkey/ecc_key/ecc_key.cpp +++ b/src/lib/pubkey/ecc_key/ecc_key.cpp @@ -47,9 +47,32 @@ EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id, bool EC_PublicKey::check_key(RandomNumberGenerator&, bool) const { - return public_point().on_the_curve(); + //check that public point is not at infinity + if(public_point().is_zero()) + { + return false; + } + //check that public point is on the curve + if(!public_point().on_the_curve()) + { + return false; + } + if(m_domain_params.get_cofactor() > 1) + { + if((public_point() * m_domain_params.get_cofactor()).is_zero()) + { + return false; + } + //check that public point has order q + if(!(public_point() * m_domain_params.get_order()).is_zero()) + { + return false; + } + } + return true; } + AlgorithmIdentifier EC_PublicKey::algorithm_identifier() const { return AlgorithmIdentifier(get_oid(), DER_domain()); |