9#include <botan/tpm2_session.h>
11#include <botan/tpm2_key.h>
13#include <botan/internal/stl_util.h>
14#include <botan/internal/tpm2_algo_mappings.h>
15#include <botan/internal/tpm2_util.h>
21using SessionAttributesWrapper =
34 return SessionAttributesWrapper::read(attributes);
38 return SessionAttributesWrapper::render(attributes);
43 std::string_view sym_algo,
44 std::string_view hash_algo) {
52 Esys_StartAuthSession(*ctx,
64 return std::shared_ptr<Session>(
new Session(std::move(session),
66 .continue_session =
true,
74 std::string_view sym_algo,
75 std::string_view hash_algo) {
83 Esys_StartAuthSession(*ctx,
95 return std::shared_ptr<Session>(
new Session(std::move(session),
97 .continue_session =
true,
109 check_rc(
"Esys_TRSess_GetAttributes",
115 check_rc(
"Esys_TRSess_SetAttributes",
116 Esys_TRSess_SetAttributes(
127[[nodiscard]] detail::SessionHandle::operator
ESYS_TR() &&
noexcept {
129 return m_session->get().transient_handle();
#define BOTAN_ASSERT_NONNULL(ptr)
const std::shared_ptr< Context > & context() const
ESYS_TR transient_handle() const noexcept
static std::shared_ptr< Session > unauthenticated_session(const std::shared_ptr< Context > &ctx, std::string_view sym_algo="CFB(AES-256)", std::string_view hash_algo="SHA-256")
Session(std::shared_ptr< Context > ctx, ESYS_TR session_handle)
void set_attributes(SessionAttributes attributes)
static std::shared_ptr< Session > authenticated_session(const std::shared_ptr< Context > &ctx, const TPM2::PrivateKey &tpm_key, std::string_view sym_algo="CFB(AES-256)", std::string_view hash_algo="SHA-256")
secure_vector< uint8_t > tpm_nonce() const
SessionAttributes attributes() 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)
std::unique_ptr< T, esys_liberator > unique_esys_ptr
A unique pointer type for ESYS handles that automatically frees the handle.
TPMI_ALG_HASH get_tpm2_hash_type(std::string_view hash_name)
constexpr auto out_transient_handle(Object &object)
TPMT_SYM_DEF get_tpm2_sym_cipher_spec(std::string_view algo_name)
constexpr void copy_into(T &dest, std::span< const uint8_t > data)
constexpr auto out_ptr(T &outptr) noexcept
std::vector< T, secure_allocator< T > > secure_vector
static SessionAttributes read(TPMA_SESSION attributes)
bool audit_exclusive
Indicates that a command should only be executed if the session is exclusive.
bool decrypt
Indicates that the first parameter of the command is to be decrypted by the TPM.
bool continue_session
The session may or may not remain active after the successful completion of any command.
bool encrypt
Indicates that the first parameter of a command's response is to be encrypted by the TPM.
bool audit_reset
Indicates that the audit digest should be initialized and exclusive status of the session SET.
static TPMA_SESSION render(SessionAttributes attributes)
bool audit
Indicates that the session is fused for audit and that audit_exclusive and audit_reset have meaning.
uint32_t ESYS_TR
Forward declaration of TSS2 type for convenience.