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 {
return public_ec_point().serialize_uncompressed(); }
101 ECDH_PrivateKey export_key()
const;
103 secure_vector<uint8_t> private_key_bits()
const override;
108 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator&)
const override {
109 throw Not_Implemented(
"Cannot generate a new PKCS#11 ECDH keypair from this private key");
112 bool supports_operation(PublicKeyOperation op)
const override {
return (op == PublicKeyOperation::KeyAgreement); }
114 std::unique_ptr<PK_Ops::Key_Agreement> create_key_agreement_op(RandomNumberGenerator& rng,
115 std::string_view params,
116 std::string_view provider)
const override;
121using PKCS11_ECDH_KeyPair = std::pair<PKCS11_ECDH_PublicKey, PKCS11_ECDH_PrivateKey>;
130PKCS11_ECDH_KeyPair generate_ecdh_keypair(Session& session,
131 const EC_PublicKeyGenerationProperties& pub_props,
132 const EC_PrivateKeyGenerationProperties& priv_props);
#define BOTAN_DIAGNOSTIC_POP
#define BOTAN_DIAGNOSTIC_PUSH
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
#define BOTAN_PUBLIC_API(maj, min)
int(* final)(unsigned char *, CTX *)