diff options
Diffstat (limited to 'src/pubkey')
-rw-r--r-- | src/pubkey/ecc_key/ecc_key.cpp | 24 | ||||
-rw-r--r-- | src/pubkey/ecc_key/ecc_key.h | 4 | ||||
-rw-r--r-- | src/pubkey/gost_3410/gost_3410.cpp | 9 |
3 files changed, 16 insertions, 21 deletions
diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp index 081649de3..f1ece3ebd 100644 --- a/src/pubkey/ecc_key/ecc_key.cpp +++ b/src/pubkey/ecc_key/ecc_key.cpp @@ -45,18 +45,6 @@ MemoryVector<byte> EC_PublicKey::x509_subject_public_key() const return EC2OSP(public_point(), PointGFp::COMPRESSED); } -void EC_PublicKey::X509_load_hook() - { - try - { - public_point().check_invariants(); - } - catch(Illegal_Point) - { - throw Decoding_Error("Invalid public point; not on curve"); - } - } - EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id, const MemoryRegion<byte>& key_bits) { @@ -160,11 +148,15 @@ EC_PrivateKey::EC_PrivateKey(const AlgorithmIdentifier& alg_id, private_key = BigInt::decode(octstr_secret, octstr_secret.size()); public_key = domain().get_base_point() * private_key; - } -void EC_PrivateKey::PKCS8_load_hook(bool) - { - public_key = domain().get_base_point() * private_key; + try + { + public_key.check_invariants(); + } + catch(Illegal_Point) + { + throw Internal_Error("Loaded ECC private key failed self test"); + } } } diff --git a/src/pubkey/ecc_key/ecc_key.h b/src/pubkey/ecc_key/ecc_key.h index e9cd7f68b..295de2797 100644 --- a/src/pubkey/ecc_key/ecc_key.h +++ b/src/pubkey/ecc_key/ecc_key.h @@ -82,8 +82,6 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key protected: EC_PublicKey() : domain_encoding(EC_DOMPAR_ENC_EXPLICIT) {} - virtual void X509_load_hook(); - EC_Domain_Params domain_params; PointGFp public_key; EC_Domain_Params_Encoding domain_encoding; @@ -117,8 +115,6 @@ class BOTAN_DLL EC_PrivateKey : public virtual EC_PublicKey, protected: EC_PrivateKey() {} - virtual void PKCS8_load_hook(bool = false); - BigInt private_key; }; diff --git a/src/pubkey/gost_3410/gost_3410.cpp b/src/pubkey/gost_3410/gost_3410.cpp index f2fb15a2e..47438653d 100644 --- a/src/pubkey/gost_3410/gost_3410.cpp +++ b/src/pubkey/gost_3410/gost_3410.cpp @@ -50,7 +50,14 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id, public_key = PointGFp(domain().get_curve(), x, y); - X509_load_hook(); + try + { + public_key.check_invariants(); + } + catch(Illegal_Point) + { + throw Internal_Error("Loaded ECC private key failed self test"); + } } bool GOST_3410_PublicKey::verify(const byte msg[], u32bit msg_len, |