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) : PKCS11_EC_PublicKey(session, handle) {}
 
   40      PKCS11_ECDH_PublicKey(Session& session, 
const EC_PublicKeyImportProperties& props) :
 
   41            PKCS11_EC_PublicKey(session, props) {}
 
   43      inline std::string algo_name()
 const override { 
return "ECDH"; }
 
   48      std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& ) 
const final {
 
   49         throw Not_Implemented(
"Cannot generate a new PKCS#11 ECDH keypair from this public key");
 
   52      bool supports_operation(PublicKeyOperation op)
 const override { 
return (op == PublicKeyOperation::KeyAgreement); }
 
   55      ECDH_PublicKey export_key() 
const;
 
   63class BOTAN_PUBLIC_API(2, 0) PKCS11_ECDH_PrivateKey final : 
public virtual PKCS11_EC_PrivateKey,
 
   64                                                            public virtual PK_Key_Agreement_Key {
 
   71      PKCS11_ECDH_PrivateKey(Session& session, ObjectHandle handle) : PKCS11_EC_PrivateKey(session, handle) {}
 
   78      PKCS11_ECDH_PrivateKey(Session& session, 
const EC_PrivateKeyImportProperties& props) :
 
   79            PKCS11_EC_PrivateKey(session, props) {}
 
   88      PKCS11_ECDH_PrivateKey(Session& session,
 
   89                             const std::vector<uint8_t>& ec_params,
 
   90                             const EC_PrivateKeyGenerationProperties& props) :
 
   91            PKCS11_EC_PrivateKey(session, ec_params, props) {}
 
   93      inline std::string algo_name()
 const override { 
return "ECDH"; }
 
   95      std::unique_ptr<Public_Key> public_key() 
const override;
 
   97      inline std::vector<uint8_t> public_value()
 const override { 
return public_ec_point().serialize_uncompressed(); }
 
  100      ECDH_PrivateKey export_key() 
const;
 
  102      secure_vector<uint8_t> private_key_bits() 
const override;
 
  107      std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& )
 const override {
 
  108         throw Not_Implemented(
"Cannot generate a new PKCS#11 ECDH keypair from this private key");
 
  111      bool supports_operation(PublicKeyOperation op)
 const override { 
return (op == PublicKeyOperation::KeyAgreement); }
 
  113      std::unique_ptr<PK_Ops::Key_Agreement> create_key_agreement_op(RandomNumberGenerator& rng,
 
  114                                                                     std::string_view params,
 
  115                                                                     std::string_view provider) 
const override;
 
  120using PKCS11_ECDH_KeyPair = std::pair<PKCS11_ECDH_PublicKey, PKCS11_ECDH_PrivateKey>;
 
  129PKCS11_ECDH_KeyPair generate_ecdh_keypair(
Session& session,
 
  130                                          const EC_PublicKeyGenerationProperties& pub_props,
 
  131                                          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)
 
Represents a PKCS#11 session.