diff options
author | lloyd <[email protected]> | 2015-02-03 08:11:45 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-02-03 08:11:45 +0000 |
commit | f9a7c85b74be0f4a7273e8e0591703af83036e81 (patch) | |
tree | 075dbe119fc16863cad99b432ca6251778bd8fd1 /src/lib/pubkey/ecdh | |
parent | 69d2cd919c698a6b138b2ccba0de5d5aa2a33a03 (diff) |
Convert PK operations to using Algo_Registry instead of Engine.
Remove global PRNG.
Diffstat (limited to 'src/lib/pubkey/ecdh')
-rw-r--r-- | src/lib/pubkey/ecdh/ecdh.cpp | 33 | ||||
-rw-r--r-- | src/lib/pubkey/ecdh/ecdh.h | 16 |
2 files changed, 27 insertions, 22 deletions
diff --git a/src/lib/pubkey/ecdh/ecdh.cpp b/src/lib/pubkey/ecdh/ecdh.cpp index 418240a4c..3b0502a36 100644 --- a/src/lib/pubkey/ecdh/ecdh.cpp +++ b/src/lib/pubkey/ecdh/ecdh.cpp @@ -7,17 +7,34 @@ * Botan is released under the Simplified BSD License (see license.txt) */ +#include <botan/internal/pk_utils.h> #include <botan/ecdh.h> namespace Botan { -ECDH_KA_Operation::ECDH_KA_Operation(const ECDH_PrivateKey& key) : - curve(key.domain().get_curve()), - cofactor(key.domain().get_cofactor()) +namespace { + +/** +* ECDH operation +*/ +class ECDH_KA_Operation : public PK_Ops::Key_Agreement { - l_times_priv = inverse_mod(cofactor, key.domain().get_order()) * - key.private_value(); - } + public: + typedef ECDH_PrivateKey Key_Type; + + ECDH_KA_Operation(const ECDH_PrivateKey& key, const std::string&) : + curve(key.domain().get_curve()), + cofactor(key.domain().get_cofactor()) + { + l_times_priv = inverse_mod(cofactor, key.domain().get_order()) * key.private_value(); + } + + secure_vector<byte> agree(const byte w[], size_t w_len); + private: + const CurveGFp& curve; + const BigInt& cofactor; + BigInt l_times_priv; + }; secure_vector<byte> ECDH_KA_Operation::agree(const byte w[], size_t w_len) { @@ -33,3 +50,7 @@ secure_vector<byte> ECDH_KA_Operation::agree(const byte w[], size_t w_len) } } + +BOTAN_REGISTER_PK_KEY_AGREE_OP("ECDH", ECDH_KA_Operation); + +} diff --git a/src/lib/pubkey/ecdh/ecdh.h b/src/lib/pubkey/ecdh/ecdh.h index 6dfa4efe6..1e806f119 100644 --- a/src/lib/pubkey/ecdh/ecdh.h +++ b/src/lib/pubkey/ecdh/ecdh.h @@ -11,7 +11,6 @@ #define BOTAN_ECDH_KEY_H__ #include <botan/ecc_key.h> -#include <botan/pk_ops.h> namespace Botan { @@ -87,21 +86,6 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey, { return ECDH_PublicKey::public_value(); } }; -/** -* ECDH operation -*/ -class BOTAN_DLL ECDH_KA_Operation : public PK_Ops::Key_Agreement - { - public: - ECDH_KA_Operation(const ECDH_PrivateKey& key); - - secure_vector<byte> agree(const byte w[], size_t w_len); - private: - const CurveGFp& curve; - const BigInt& cofactor; - BigInt l_times_priv; - }; - } #endif |