8#ifndef BOTAN_TPM2_SESSION_H_
9#define BOTAN_TPM2_SESSION_H_
11#include <botan/secmem.h>
12#include <botan/tpm2_context.h>
13#include <botan/tpm2_object.h>
74 [[nodiscard]]
operator ESYS_TR() &&
noexcept;
82 std::optional<std::reference_wrapper<Session>> m_session;
105 std::string_view sym_algo =
"CFB(AES-256)",
106 std::string_view hash_algo =
"SHA-256");
125 std::string_view sym_algo =
"CFB(AES-256)",
126 std::string_view hash_algo =
"SHA-256");
141 Session(std::shared_ptr<Context> ctx,
ESYS_TR session_handle) : m_session(std::move(ctx), session_handle) {}
155 ESYS_TR transient_handle() const noexcept {
return m_session.transient_handle(); }
170 std::shared_ptr<Session> s2 =
nullptr,
171 std::shared_ptr<Session> s3 =
nullptr) :
172 m_sessions({std::move(s1), std::move(s2), std::move(s3)}) {}
175 if(m_sessions[i] ==
nullptr) {
178 return m_sessions[i]->handle();
183 std::array<std::shared_ptr<Session>, 3> m_sessions;
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_UNSTABLE_API
SessionBundle(std::shared_ptr< Session > s1=nullptr, std::shared_ptr< Session > s2=nullptr, std::shared_ptr< Session > s3=nullptr)
detail::SessionHandle operator[](size_t i) 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)
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")
SessionAttributes attributes() const
detail::SessionHandle handle()
SessionHandle & operator=(SessionHandle &&)=delete
SessionHandle(SessionHandle &&)=delete
SessionHandle & operator=(const SessionHandle &)=delete
SessionHandle(const SessionHandle &)=delete
friend class Botan::TPM2::Session
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.