8#ifndef BOTAN_TPM2_ASYM_KEYS_H_
9#define BOTAN_TPM2_ASYM_KEYS_H_
11#include <botan/pk_keys.h>
12#include <botan/tpm2_context.h>
13#include <botan/tpm2_object.h>
14#include <botan/tpm2_session.h>
15#if defined(BOTAN_HAS_RSA)
16 #include <botan/rsa.h>
18#if defined(BOTAN_HAS_ECC_GROUP)
19 #include <botan/ec_apoint.h>
20 #include <botan/ec_group.h>
23struct TPM2B_SENSITIVE_CREATE;
29#if defined(BOTAN_HAS_RSA)
40#if defined(BOTAN_HAS_ECC_GROUP)
50std::pair<EC_Group, EC_AffinePoint> ecc_pubkey_from_tss2_public(const TPM2B_PUBLIC* public_blob);
70 static std::unique_ptr<PublicKey>
load_persistent(
const std::shared_ptr<Context>& ctx,
85 static std::unique_ptr<PublicKey>
load_transient(
const std::shared_ptr<Context>& ctx,
86 std::span<const uint8_t> public_blob,
91 throw Not_Implemented(
"Cannot generate a new TPM-based keypair from this asymmetric key");
97 std::vector<uint8_t> raw_public_key_bits()
const override;
149 static std::unique_ptr<PrivateKey>
load_persistent(
const std::shared_ptr<Context>& ctx,
151 std::span<const uint8_t> auth_value,
169 static std::unique_ptr<PrivateKey>
load_transient(
const std::shared_ptr<Context>& ctx,
170 std::span<const uint8_t> auth_value,
172 std::span<const uint8_t> public_blob,
173 std::span<const uint8_t> private_blob,
200 const TPMT_PUBLIC& key_template,
201 const TPM2B_SENSITIVE_CREATE& sensitive_data);
206 throw Not_Implemented(
"cannot export private key bits from a TPM2 key, maybe use raw_private_key_bits()?");
218 std::vector<uint8_t> raw_public_key_bits()
const override;
226 bool is_parent()
const;
230 m_handle(std::move(handle)),
231 m_sessions(std::move(sessions)),
232 m_private_blob(private_blob.begin(), private_blob.end()) {}
234 static std::unique_ptr<PrivateKey> create(Object handles,
235 const SessionBundle& sessions,
236 const TPM2B_PUBLIC* public_info,
237 std::span<const uint8_t> private_blob);
241 SessionBundle m_sessions;
245 std::vector<uint8_t> m_private_blob;
#define BOTAN_DIAGNOSTIC_POP
#define BOTAN_DIAGNOSTIC_PUSH
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
#define BOTAN_PUBLIC_API(maj, min)
static std::unique_ptr< PrivateKey > create_transient_from_template(const std::shared_ptr< Context > &ctx, const SessionBundle &sessions, ESYS_TR parent, const TPMT_PUBLIC &key_template, const TPM2B_SENSITIVE_CREATE &sensitive_data)
static std::unique_ptr< PrivateKey > load_persistent(const std::shared_ptr< Context > &ctx, TPM2_HANDLE persistent_object_handle, std::span< const uint8_t > auth_value, const SessionBundle &sessions)
PrivateKey(Object handle, SessionBundle sessions, std::span< const uint8_t > private_blob={})
static std::unique_ptr< PrivateKey > load_transient(const std::shared_ptr< Context > &ctx, std::span< const uint8_t > auth_value, const TPM2::PrivateKey &parent, std::span< const uint8_t > public_blob, std::span< const uint8_t > private_blob, const SessionBundle &sessions)
const SessionBundle & sessions() const
const Object & handles() const
secure_vector< uint8_t > private_key_bits() const override
static std::unique_ptr< PublicKey > load_persistent(const std::shared_ptr< Context > &ctx, TPM2_HANDLE persistent_object_handle, const SessionBundle &sessions={})
const Object & handles() const
PublicKey(Object object, SessionBundle sessions)
const SessionBundle & sessions() const
static std::unique_ptr< PublicKey > load_transient(const std::shared_ptr< Context > &ctx, std::span< const uint8_t > public_blob, const SessionBundle &sessions)
std::unique_ptr< Private_Key > generate_another(Botan::RandomNumberGenerator &) const override
std::vector< T, secure_allocator< T > > secure_vector
uint32_t ESYS_TR
Forward declaration of TSS2 type for convenience.
uint32_t TPM2_HANDLE
Forward declaration of TSS2 type for convenience.