9#include <botan/tpm2_object.h>
11#include <botan/tpm2_session.h>
13#include <botan/internal/stl_util.h>
14#include <botan/internal/tpm2_util.h>
16#include <tss2/tss2_esys.h>
22using ObjectAttributesWrapper =
41 return ObjectAttributesWrapper::read(attributes);
45 return ObjectAttributesWrapper::render(attributes);
53 m_handles->transient = handle;
57 m_ctx(std::move(other.m_ctx)),
58 m_handles(std::move(other.m_handles)),
59 m_public_info(std::move(other.m_public_info)) {
72 m_ctx = std::move(other.m_ctx);
73 m_handles = std::move(other.m_handles);
74 m_public_info = std::move(other.m_public_info);
81void Object::flush() const noexcept {
85 Esys_TR_Close(*m_ctx, &m_handles->transient);
87 Esys_FlushContext(*m_ctx, m_handles->transient);
97 m_public_info.reset();
108 m_handles = std::make_unique<ObjectHandles>();
109 m_public_info.reset();
113 return m_handles->persistent.has_value();
117 return m_handles->transient != ESYS_TR_NONE;
122 return *m_handles->persistent;
126 return m_handles->transient;
130 const auto attrs =
_public_info(sessions).
pub->publicArea.objectAttributes;
136 m_public_info = std::make_unique<PublicInfo>();
139 Esys_ReadPublic(*m_ctx,
140 m_handles->transient,
146 out_ptr(m_public_info->qualified_name)));
154 return *m_public_info;
#define BOTAN_STATE_CHECK(expr)
#define BOTAN_ASSERT_NONNULL(ptr)
bool has_transient_handle() const
void _reset() noexcept
Flush the object's TPM handles and reset its internal state.
Object(std::shared_ptr< Context > ctx)
bool has_persistent_handle() const
PublicInfo & _public_info(const SessionBundle &sessions, std::optional< TPMI_ALG_PUBLIC > expected_type={}) const
ObjectAttributes attributes(const SessionBundle &sessions) const
ESYS_TR transient_handle() const noexcept
void _disengage() noexcept
Reset the object's internal state without flushing its TPM handles.
Object & operator=(const Object &)=delete
TPM2_HANDLE persistent_handle() const
PropMap(MaskT, FieldPointerT) -> PropMap< MaskT, FieldPointerT >
Deduction guide to simplify the creation of PropMap instances.
constexpr void check_rc(std::string_view location, TSS2_RC rc)
constexpr auto out_ptr(T &outptr) noexcept
bool no_da
If set, the object is not subject to dictionary attack protection.
bool fixed_tpm
The hierarchy of the object may or may not change (i.e. when keys are duplicated)
bool fixed_parent
The parent of the object may or may not change.
static ObjectAttributes read(TPMA_OBJECT attributes)
bool encrypted_duplication
bool admin_with_policy
ADMIN role actions may or may not require a policy session.
bool user_with_auth
USER role actions may or may not be performed without authorization (HMAC or password)
bool sensitive_data_origin
Indicates that the TPM generated all of the sensitive data other than the authValue.
static TPMA_OBJECT render(ObjectAttributes attributes)
bool st_clear
Saved contexts of this object may or may not be loaded after Startup(CLEAR)
bool decrypt
The private portion of the key might be used for data decryption.
unique_esys_ptr< TPM2B_PUBLIC > pub
uint32_t ESYS_TR
Forward declaration of TSS2 type for convenience.
uint32_t TPM2_HANDLE
Forward declaration of TSS2 type for convenience.
uint32_t TPMA_OBJECT
Forward declaration of TSS2 type for convenience.