aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/ecdh/ecdh.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-02-03 08:11:45 +0000
committerlloyd <[email protected]>2015-02-03 08:11:45 +0000
commitf9a7c85b74be0f4a7273e8e0591703af83036e81 (patch)
tree075dbe119fc16863cad99b432ca6251778bd8fd1 /src/lib/pubkey/ecdh/ecdh.cpp
parent69d2cd919c698a6b138b2ccba0de5d5aa2a33a03 (diff)
Convert PK operations to using Algo_Registry instead of Engine.
Remove global PRNG.
Diffstat (limited to 'src/lib/pubkey/ecdh/ecdh.cpp')
-rw-r--r--src/lib/pubkey/ecdh/ecdh.cpp33
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);
+
+}