9#include <botan/internal/tpm2_pkops.h>
11#include <botan/internal/stl_util.h>
12#include <botan/internal/tpm2_algo_mappings.h>
13#include <botan/internal/tpm2_hash.h>
30std::unique_ptr<Botan::HashFunction> create_hash_function(
const Object& key_handle,
31 const SessionBundle& sessions,
32 std::string_view hash_name) {
33 if(key_handle.attributes(sessions).restricted) {
36 const TPMI_RH_HIERARCHY hierarchy = ESYS_TR_RH_OWNER;
37 return std::make_unique<HashFunction>(key_handle.context(), hash_name, hierarchy, sessions);
49 object, sessions, algorithms, create_hash_function(object, sessions, algorithms.hash_name)) {}
54 auto do_sign = [
this](
const TPM2B_DIGEST& digest,
const TPMT_TK_HASHCHECK& validation) {
72 auto signature = [&] {
76 auto [digest, validation] = h->final_with_ticket();
79 return do_sign(*digest, *validation);
85 return do_sign(digest,
87 .tag = TPM2_ST_HASHCHECK,
88 .hierarchy = TPM2_RH_NULL,
101 object, sessions, algorithms,
Botan::
HashFunction::create_or_throw(algorithms.hash_name)) {}
120 return rc == TPM2_RC_SUCCESS;
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_ASSERT_NONNULL(ptr)
void final(uint8_t out[])
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
const Object & key_handle() const
Botan::HashFunction * hash()
const SessionBundle & sessions() const
const TPMT_SIG_SCHEME & scheme() const
Signature_Operation(const Object &object, const SessionBundle &sessions, const SignatureAlgorithmSelection &algorithms)
virtual std::vector< uint8_t > marshal_signature(const TPMT_SIGNATURE &signature) const =0
std::vector< uint8_t > sign(Botan::RandomNumberGenerator &rng) override
virtual TPMT_SIGNATURE unmarshal_signature(std::span< const uint8_t > sig_data) const =0
Verification_Operation(const Object &object, const SessionBundle &sessions, const SignatureAlgorithmSelection &algorithms)
bool is_valid_signature(std::span< const uint8_t > sig_data) override
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.
constexpr auto as_span(tpm2_buffer auto &data)
Construct a std::span as a view into a TPM2 buffer.
constexpr TSS2_RC check_rc_expecting(std::string_view location, TSS2_RC rc)
constexpr auto out_ptr(T &outptr) noexcept