9#ifndef BOTAN_P11_ECDH_H_
10#define BOTAN_P11_ECDH_H_
14#if defined(BOTAN_HAS_ECDH)
16 #include <botan/ecdh.h>
17 #include <botan/p11_ecc_key.h>
26class BOTAN_PUBLIC_API(2, 0) PKCS11_ECDH_PublicKey :
public PKCS11_EC_PublicKey {
33 PKCS11_ECDH_PublicKey(Session& session, ObjectHandle handle) :
34 EC_PublicKey(), PKCS11_EC_PublicKey(session, handle) {}
41 PKCS11_ECDH_PublicKey(Session& session,
const EC_PublicKeyImportProperties& props) :
42 EC_PublicKey(), PKCS11_EC_PublicKey(session, props) {}
44 inline std::string algo_name()
const override {
return "ECDH"; }
49 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator&)
const final {
50 throw Not_Implemented(
"Cannot generate a new PKCS#11 ECDH keypair from this public key");
53 bool supports_operation(PublicKeyOperation op)
const override {
return (op == PublicKeyOperation::KeyAgreement); }
56 ECDH_PublicKey export_key()
const;
65 public virtual PK_Key_Agreement_Key {
72 PKCS11_ECDH_PrivateKey(Session& session, ObjectHandle handle) : PKCS11_EC_PrivateKey(session, handle) {}
79 PKCS11_ECDH_PrivateKey(Session& session,
const EC_PrivateKeyImportProperties& props) :
80 PKCS11_EC_PrivateKey(session, props) {}
89 PKCS11_ECDH_PrivateKey(Session& session,
90 const std::vector<uint8_t>& ec_params,
91 const EC_PrivateKeyGenerationProperties& props) :
92 PKCS11_EC_PrivateKey(session, ec_params, props) {}
94 inline std::string algo_name()
const override {
return "ECDH"; }
96 std::unique_ptr<Public_Key> public_key()
const override;
98 inline std::vector<uint8_t> public_value()
const override {
99 return public_point().encode(EC_Point_Format::Uncompressed);
103 ECDH_PrivateKey export_key()
const;
105 secure_vector<uint8_t> private_key_bits()
const override;
110 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator&)
const override {
111 throw Not_Implemented(
"Cannot generate a new PKCS#11 ECDH keypair from this private key");
114 bool supports_operation(PublicKeyOperation op)
const override {
return (op == PublicKeyOperation::KeyAgreement); }
116 std::unique_ptr<PK_Ops::Key_Agreement> create_key_agreement_op(RandomNumberGenerator& rng,
117 std::string_view params,
118 std::string_view provider)
const override;
123using PKCS11_ECDH_KeyPair = std::pair<PKCS11_ECDH_PublicKey, PKCS11_ECDH_PrivateKey>;
132PKCS11_ECDH_KeyPair generate_ecdh_keypair(Session& session,
133 const EC_PublicKeyGenerationProperties& pub_props,
134 const EC_PrivateKeyGenerationProperties& priv_props);
int(* final)(unsigned char *, CTX *)
#define BOTAN_DIAGNOSTIC_POP
#define BOTAN_DIAGNOSTIC_PUSH
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
#define BOTAN_PUBLIC_API(maj, min)