diff options
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 |