9#ifndef BOTAN_P11_ECDSA_H_
10#define BOTAN_P11_ECDSA_H_
13#include <botan/pk_keys.h>
15#if defined(BOTAN_HAS_ECDSA)
17 #include <botan/ecdsa.h>
18 #include <botan/p11_ecc_key.h>
30class BOTAN_PUBLIC_API(2, 0) PKCS11_ECDSA_PublicKey final :
public PKCS11_EC_PublicKey,
31 public virtual ECDSA_PublicKey {
38 PKCS11_ECDSA_PublicKey(Session& session, ObjectHandle handle) : PKCS11_EC_PublicKey(session, handle) {}
45 PKCS11_ECDSA_PublicKey(Session& session,
const EC_PublicKeyImportProperties& props) :
46 PKCS11_EC_PublicKey(session, props) {}
48 inline std::string algo_name()
const override {
return "ECDSA"; }
51 ECDSA_PublicKey export_key()
const;
56 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& )
const final {
57 throw Not_Implemented(
"Cannot generate a new PKCS#11 ECDSA keypair from this public key");
60 std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
61 std::string_view provider)
const override;
67class BOTAN_PUBLIC_API(2, 0) PKCS11_ECDSA_PrivateKey final :
public PKCS11_EC_PrivateKey {
74 PKCS11_ECDSA_PrivateKey(Session& session, ObjectHandle handle) : PKCS11_EC_PrivateKey(session, handle) {}
81 PKCS11_ECDSA_PrivateKey(Session& session,
const EC_PrivateKeyImportProperties& props) :
82 PKCS11_EC_PrivateKey(session, props) {}
91 PKCS11_ECDSA_PrivateKey(Session& session,
92 const std::vector<uint8_t>& ec_params,
93 const EC_PrivateKeyGenerationProperties& props) :
94 PKCS11_EC_PrivateKey(session, ec_params, props) {}
96 inline std::string algo_name()
const override {
return "ECDSA"; }
101 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& )
const override {
102 throw Not_Implemented(
"Cannot generate a new PKCS#11 ECDSA keypair from this private key");
105 bool supports_operation(PublicKeyOperation op)
const override {
return (op == PublicKeyOperation::Signature); }
107 std::optional<size_t> _signature_element_size_for_DER_encoding()
const override {
108 return domain().get_order_bytes();
112 ECDSA_PrivateKey export_key()
const;
114 std::unique_ptr<Public_Key> public_key()
const override;
116 secure_vector<uint8_t> private_key_bits()
const override;
118 bool check_key(RandomNumberGenerator& rng,
bool strong)
const override;
120 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
121 std::string_view params,
122 std::string_view provider)
const override;
125using PKCS11_ECDSA_KeyPair = std::pair<PKCS11_ECDSA_PublicKey, PKCS11_ECDSA_PrivateKey>;
134PKCS11_ECDSA_KeyPair generate_ecdsa_keypair(
Session& session,
135 const EC_PublicKeyGenerationProperties& pub_props,
136 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.