From 664e00a6d51cf7d6f3fefbbb3500a113d21288ab Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 4 Mar 2010 22:09:07 +0000 Subject: This checkin represents a pretty major change in how PK operations are performed. Up until now, each key object (eg DSA_PublicKey or ECDH_PrivateKey) had two jobs: contain the key material, and know how to perform any operations on that key. However because of a desire to support alternative implementations (GNU MP, hardware, whatever), there was a notion of operations, with the key objects containing an op that they got via engine rather than actually implementing the underlying algorithms directly. Now, represent the operation as an abstract interface (typically mapping a byte string to a byte string), and pass a plain Public_Key& or Private_Key& to the engine. The engine does any checks it wants (eg based on name, typeid, key sizes, etc), and either returns nothing (I'll pass) or a pointer to a new operation that represents signatures or encryption or what-have-you using that key. This means that plain key objects no longer contain operations. This is a major break with the traditional interface. On the other hand, using these 'bare' operations without padding, KDFs, etc is 99% of the time a bad idea anyway (and if you really need them, there are options so you get the bare op but via the pubkey.h interfaces). Currently this change is only implemented for DH and ECDH (ie, key agreement algorithms). Additionally the optional engines (gnump and openssl) have not been updated. I'll probably wait to touch those until after I can change them all in one go for all algos. --- src/pubkey/ecdh/ecdh.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/pubkey/ecdh/ecdh.h') diff --git a/src/pubkey/ecdh/ecdh.h b/src/pubkey/ecdh/ecdh.h index 8185e25f2..ad7efdc13 100644 --- a/src/pubkey/ecdh/ecdh.h +++ b/src/pubkey/ecdh/ecdh.h @@ -11,6 +11,7 @@ #define BOTAN_ECDH_KEY_H__ #include +#include namespace Botan { @@ -75,7 +76,7 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey, MemoryVector public_value() const { return EC2OSP(public_point(), PointGFp::UNCOMPRESSED); } - + private: /** * Derive a shared key with the other parties public key. * @param key the other partys public key @@ -96,6 +97,20 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey, SecureVector derive_key(const PointGFp& point) const; }; +/** +* ECDH operation +*/ +class BOTAN_DLL ECDH_KA_Operation : public PK_Ops::KA_Operation + { + public: + ECDH_KA_Operation(const ECDH_PrivateKey& key); + + SecureVector agree(const byte w[], u32bit w_len) const; + private: + CurveGFp curve; + BigInt l_times_priv, cofactor; + }; + } #endif -- cgit v1.2.3