diff options
author | lloyd <[email protected]> | 2010-03-04 03:22:35 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-04 03:22:35 +0000 |
commit | 76f39cc9fe4b2a3354db22f8beaf0c3788578b79 (patch) | |
tree | c25ddaf29f22dc29786487d606d68c2344c46f22 /src/pubkey/ecc_key | |
parent | da09382f398dcf27a3ffdb82dd9f916ba96567ac (diff) |
Add a new constructor to each public key algorithm (only the public
keys so far, private keys not changed) that takes an
AlgorithmIdentifier and a MemoryRegion<byte>&. This performs the X.509
decoding. It is not possible anymore to create uninitialized PK
objects.
Diffstat (limited to 'src/pubkey/ecc_key')
-rw-r--r-- | src/pubkey/ecc_key/ecc_key.cpp | 17 | ||||
-rw-r--r-- | src/pubkey/ecc_key/ecc_key.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp index 2f98eb691..8e1f40665 100644 --- a/src/pubkey/ecc_key/ecc_key.cpp +++ b/src/pubkey/ecc_key/ecc_key.cpp @@ -57,6 +57,23 @@ void EC_PublicKey::X509_load_hook() } } +EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id, + const MemoryRegion<byte>& key_bits) + { + domain_params = EC_Domain_Params(alg_id.parameters); + + public_key = PointGFp(OS2ECP(key_bits, domain().get_curve())); + + try + { + public_point().check_invariants(); + } + catch(Illegal_Point) + { + throw Decoding_Error("Invalid public point; not on curve"); + } + } + X509_Decoder* EC_PublicKey::x509_decoder() { class EC_Key_Decoder : public X509_Decoder diff --git a/src/pubkey/ecc_key/ecc_key.h b/src/pubkey/ecc_key/ecc_key.h index 6f3ab6a01..52aad4f03 100644 --- a/src/pubkey/ecc_key/ecc_key.h +++ b/src/pubkey/ecc_key/ecc_key.h @@ -84,6 +84,9 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key EC_PublicKey(const EC_Domain_Params& dom_par, const PointGFp& pub_point); + EC_PublicKey(const AlgorithmIdentifier& alg_id, + const MemoryRegion<byte>& key_bits); + virtual ~EC_PublicKey() {} protected: virtual void X509_load_hook(); |