diff options
Diffstat (limited to 'src/pubkey/ecdh/ecdh.h')
-rw-r--r-- | src/pubkey/ecdh/ecdh.h | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/src/pubkey/ecdh/ecdh.h b/src/pubkey/ecdh/ecdh.h index 630237edf..d670361f6 100644 --- a/src/pubkey/ecdh/ecdh.h +++ b/src/pubkey/ecdh/ecdh.h @@ -11,6 +11,7 @@ #define BOTAN_ECDH_KEY_H__ #include <botan/ecc_key.h> +#include <botan/pk_ops.h> namespace Botan { @@ -21,11 +22,10 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey { public: - /** - * Default constructor. Use this one if you want to later fill - * this object with data from an encoded key. - */ - ECDH_PublicKey() {} + + ECDH_PublicKey(const AlgorithmIdentifier& alg_id, + const MemoryRegion<byte>& key_bits) : + EC_PublicKey(alg_id, key_bits) {} /** * Construct a public key from a given public point. @@ -49,6 +49,8 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey * @result the maximum number of input bits */ u32bit max_input_bits() const { return domain().get_order().bits(); } + protected: + ECDH_PublicKey() {} }; /** @@ -60,11 +62,9 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey, { public: - /** - * Default constructor. Use this one if you want to later fill - * this object with data from an encoded key. - */ - ECDH_PrivateKey() {} + ECDH_PrivateKey(const AlgorithmIdentifier& alg_id, + const MemoryRegion<byte>& key_bits) : + EC_PrivateKey(alg_id, key_bits) {} /** * Generate a new private key @@ -76,25 +76,21 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey, MemoryVector<byte> public_value() const { return EC2OSP(public_point(), PointGFp::UNCOMPRESSED); } + }; - /** - * Derive a shared key with the other parties public key. - * @param key the other partys public key - * @param key_len the other partys public key - */ - SecureVector<byte> derive_key(const byte key[], u32bit key_len) const; - - /** - * Derive a shared key with the other parties public key. - * @param other the other partys public key - */ - SecureVector<byte> derive_key(const ECDH_PublicKey& other) const; +/** +* ECDH operation +*/ +class BOTAN_DLL ECDH_KA_Operation : public PK_Ops::Key_Agreement + { + public: + ECDH_KA_Operation(const ECDH_PrivateKey& key); - /** - * Derive a shared key with the other parties public key. - * @param point the public point of the other parties key - */ - SecureVector<byte> derive_key(const PointGFp& point) const; + SecureVector<byte> agree(const byte w[], u32bit w_len); + private: + const CurveGFp& curve; + const BigInt& cofactor; + BigInt l_times_priv; }; } |