diff options
author | lloyd <[email protected]> | 2010-04-28 22:31:20 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-04-28 22:31:20 +0000 |
commit | 0f47cb60e703ca2de56286f07b4c9d91c7bba071 (patch) | |
tree | 5304fd84516c79f55e213755b2b2b99e6e65c9e0 /src/pubkey | |
parent | 6eec50d372143afcb3188f21d0991ace3e0d5e9e (diff) | |
parent | 50fc7b15553d888d95bee72972e53eae27a82c1f (diff) |
propagate from branch 'net.randombit.botan' (head a5f25a3b954f24c5d07fa0dab6c4d76f63767165)
to branch 'net.randombit.botan.c++0x' (head a365694b70b4b84ca713272d56d496acca351cb5)
Diffstat (limited to 'src/pubkey')
-rw-r--r-- | src/pubkey/ec_dompar/ec_dompar.cpp | 15 | ||||
-rw-r--r-- | src/pubkey/ec_dompar/ec_dompar.h | 7 | ||||
-rw-r--r-- | src/pubkey/ecdh/ecdh.h | 13 |
3 files changed, 26 insertions, 9 deletions
diff --git a/src/pubkey/ec_dompar/ec_dompar.cpp b/src/pubkey/ec_dompar/ec_dompar.cpp index b0aa7a87a..512d8d769 100644 --- a/src/pubkey/ec_dompar/ec_dompar.cpp +++ b/src/pubkey/ec_dompar/ec_dompar.cpp @@ -30,12 +30,21 @@ EC_Domain_Params::EC_Domain_Params(const OID& domain_oid) EC_Domain_Params::EC_Domain_Params(const std::string& pem) { - if(pem != "") + if(pem == "") + return; // no initialization / uninitialized + + try { DataSource_Memory input(pem); - *this = EC_Domain_Params( - PEM_Code::decode_check_label(input, "EC PARAMETERS")); + SecureVector<byte> ber = + PEM_Code::decode_check_label(input, "EC PARAMETERS"); + + *this = EC_Domain_Params(ber); + } + catch(Decoding_Error) // hmm, not PEM? + { + *this = EC_Domain_Params(OID(pem)); } } diff --git a/src/pubkey/ec_dompar/ec_dompar.h b/src/pubkey/ec_dompar/ec_dompar.h index 7da2120cc..15143373a 100644 --- a/src/pubkey/ec_dompar/ec_dompar.h +++ b/src/pubkey/ec_dompar/ec_dompar.h @@ -60,10 +60,11 @@ class BOTAN_DLL EC_Domain_Params EC_Domain_Params(const OID& oid); /** - * Create an EC domain from PEM encoding (as from PEM_encode) - * @param pem data + * Create an EC domain from PEM encoding (as from PEM_encode), + * or from an OID name (eg "secp16r1", or "1.3.132.0.8") + * @param pem_or_oid PEM-encoded data, or an OID */ - EC_Domain_Params(const std::string& pem = ""); + EC_Domain_Params(const std::string& pem_or_oid = ""); /** * Create the DER encoding of this domain diff --git a/src/pubkey/ecdh/ecdh.h b/src/pubkey/ecdh/ecdh.h index d670361f6..19621f2ca 100644 --- a/src/pubkey/ecdh/ecdh.h +++ b/src/pubkey/ecdh/ecdh.h @@ -38,7 +38,7 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey /** * Get this keys algorithm name. - * @result this keys algorithm name + * @return this keys algorithm name */ std::string algo_name() const { return "ECDH"; } @@ -46,9 +46,16 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey * Get the maximum number of bits allowed to be fed to this key. * This is the bitlength of the order of the base point. - * @result the maximum number of input bits + * @return the maximum number of input bits */ u32bit max_input_bits() const { return domain().get_order().bits(); } + + /** + * @return the public point value + */ + MemoryVector<byte> public_value() const + { return EC2OSP(public_point(), PointGFp::UNCOMPRESSED); } + protected: ECDH_PublicKey() {} }; @@ -75,7 +82,7 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey, EC_PrivateKey(rng, domain) {} MemoryVector<byte> public_value() const - { return EC2OSP(public_point(), PointGFp::UNCOMPRESSED); } + { return ECDH_PublicKey::public_value(); } }; /** |