9#include <botan/internal/tpm2_hash.h> 
   11#include <botan/internal/fmt.h> 
   12#include <botan/internal/stl_util.h> 
   13#include <botan/internal/tpm2_algo_mappings.h> 
   15#include <tss2/tss2_esys.h> 
   20                           std::string_view algorithm,
 
   21                           TPMI_RH_HIERARCHY hierarchy,
 
   24      m_hierarchy(hierarchy),
 
   25      m_handle(std::move(ctx)),
 
   26      m_sessions(std::move(sessions)) {
 
 
   41      case TPM2_ALG_SHA3_256:
 
   42      case TPM2_ALG_SM3_256:
 
   45      case TPM2_ALG_SHA3_384:
 
   48      case TPM2_ALG_SHA3_512:
 
   51         throw Invalid_State(
"TPM 2.0 hash object with unexpected hash type");
 
 
   60   throw Not_Implemented(
"TPM 2.0 hash functions do not support copy_state");
 
 
   64   return std::make_unique<HashFunction>(m_handle.context(), 
name(), m_hierarchy, m_sessions);
 
 
   67void HashFunction::lazy_setup() {
 
   74                                                    Esys_HashSequenceStart(*m_handle.
context(),
 
   82   if(rc == TPM2_RC_HASH) {
 
   87void HashFunction::add_data(std::span<const uint8_t> input) {
 
   90   BufferSlicer slicer(input);
 
   91   while(slicer.remaining() > 0) {
 
   92      const size_t chunk = std::min(slicer.remaining(), 
size_t(TPM2_MAX_DIGEST_BUFFER));
 
   95         "Esys_SequenceUpdate",
 
   97            *m_handle.context(), m_handle.transient_handle(), m_sessions[0], m_sessions[1], m_sessions[2], &data));
 
  109            Esys_SequenceComplete(*m_handle.context(),
 
  110                                  m_handle.transient_handle(),
 
  122   m_handle._disengage();
 
 
  127void HashFunction::final_result(std::span<uint8_t> output) {
 
  133   copy_mem(output.first(output.size()), 
as_span(*digest_and_ticket.first));
 
#define BOTAN_ASSERT_NOMSG(expr)
 
#define BOTAN_DEBUG_ASSERT(expr)
 
#define BOTAN_STATE_CHECK(expr)
 
#define BOTAN_ASSERT_NONNULL(ptr)
 
size_t output_length() const override
 
std::string name() const override
 
HashFunction(std::shared_ptr< Context > ctx, std::string_view algorithm, TPMI_RH_HIERARCHY hierarchy=ESYS_TR_RH_NULL, SessionBundle sessions={})
 
std::unique_ptr< Botan::HashFunction > new_object() const override
 
std::unique_ptr< Botan::HashFunction > copy_state() const override
 
std::pair< unique_esys_ptr< TPM2B_DIGEST >, unique_esys_ptr< TPMT_TK_HASHCHECK > > final_with_ticket()
 
bool has_transient_handle() const
 
const std::shared_ptr< Context > & context() const
 
constexpr T init_empty()
Create an empty TPM2 buffer of the given type.
 
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)
 
constexpr void copy_into(T &dest, std::span< const uint8_t > data)
 
constexpr auto as_span(tpm2_buffer auto &data)
Construct a std::span as a view into a TPM2 buffer.
 
std::string get_botan_hash_name(TPM2_ALG_ID hash_id)
 
constexpr TSS2_RC check_rc_expecting(std::string_view location, TSS2_RC rc)
 
constexpr void copy_mem(T *out, const T *in, size_t n)
 
constexpr auto out_ptr(T &outptr) noexcept
 
std::string fmt(std::string_view format, const T &... args)