diff options
author | lloyd <[email protected]> | 2010-03-02 04:01:18 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-02 04:01:18 +0000 |
commit | b822cc605b324bf449fb3e0a2185b83cd4a157e3 (patch) | |
tree | f59b57f65e30a0c025c0c4265e591a9f507ac0ff /src/pubkey/ecdsa | |
parent | 510128ffd3789301305c7f1fe52a11b238a6a60b (diff) |
Add some simple constructors to the EC_ base key types to simplify
the various implementations
Diffstat (limited to 'src/pubkey/ecdsa')
-rw-r--r-- | src/pubkey/ecdsa/ecdsa.cpp | 33 | ||||
-rw-r--r-- | src/pubkey/ecdsa/ecdsa.h | 10 |
2 files changed, 7 insertions, 36 deletions
diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp index f5ded5aa6..d245543f7 100644 --- a/src/pubkey/ecdsa/ecdsa.cpp +++ b/src/pubkey/ecdsa/ecdsa.cpp @@ -11,39 +11,6 @@ namespace Botan { -ECDSA_PublicKey::ECDSA_PublicKey(const EC_Domain_Params& dom_par, - const PointGFp& pub_point) - { - domain_encoding = EC_DOMPAR_ENC_EXPLICIT; - domain_params = dom_par; - public_key = pub_point; - } - -ECDSA_PrivateKey::ECDSA_PrivateKey(RandomNumberGenerator& rng, - const EC_Domain_Params& dom_pars) - { - domain_params = dom_pars; - generate_private_key(rng); - } - -ECDSA_PrivateKey::ECDSA_PrivateKey(const EC_Domain_Params& dom_pars, - const BigInt& x) - { - domain_params = dom_pars; - - private_key = x; - public_key = domain().get_base_point() * x; - - try - { - public_key.check_invariants(); - } - catch(Illegal_Point& e) - { - throw Invalid_State("ECDSA key generation failed"); - } - } - bool ECDSA_PublicKey::verify(const byte msg[], u32bit msg_len, const byte sig[], u32bit sig_len) const { diff --git a/src/pubkey/ecdsa/ecdsa.h b/src/pubkey/ecdsa/ecdsa.h index 447bc3758..e7f29b600 100644 --- a/src/pubkey/ecdsa/ecdsa.h +++ b/src/pubkey/ecdsa/ecdsa.h @@ -62,7 +62,9 @@ class BOTAN_DLL ECDSA_PublicKey : public virtual EC_PublicKey, * @param public_point the public point defining this key */ ECDSA_PublicKey(const EC_Domain_Params& dom_par, - const PointGFp& public_point); // sets core + const PointGFp& public_point) : + EC_PublicKey(dom_par, public_point) {} + }; /** @@ -84,14 +86,16 @@ class BOTAN_DLL ECDSA_PrivateKey : public ECDSA_PublicKey, * @param the domain parameters to used for this key */ ECDSA_PrivateKey(RandomNumberGenerator& rng, - const EC_Domain_Params& domain); + const EC_Domain_Params& domain) : + EC_PrivateKey(rng, domain) {} /** * Load a private key * @param domain parameters * @param x the private key */ - ECDSA_PrivateKey(const EC_Domain_Params& domain, const BigInt& x); + ECDSA_PrivateKey(const EC_Domain_Params& domain, const BigInt& x) : + EC_PrivateKey(domain, x) {} /** * Sign a message with this key. |