diff options
Diffstat (limited to 'src/lib/pubkey/ecdh/ecdh.cpp')
-rw-r--r-- | src/lib/pubkey/ecdh/ecdh.cpp | 33 |
1 files changed, 27 insertions, 6 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); + +} |