Botan 3.6.0
Crypto and TLS for C&
Botan::TPM2::Verification_Operation Class Referenceabstract

#include <tpm2_pkops.h>

Inheritance diagram for Botan::TPM2::Verification_Operation:
Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification > Botan::PK_Ops::Verification

Public Member Functions

std::string hash_function () const override
 
bool is_valid_signature (std::span< const uint8_t > sig_data) override
 
void update (std::span< const uint8_t > msg) override
 
 Verification_Operation (const Object &object, const SessionBundle &sessions, const SignatureAlgorithmSelection &algorithms)
 

Protected Member Functions

Botan::HashFunctionhash ()
 
const Objectkey_handle () const
 
std::optional< std::string > padding () const
 
const TPMT_SIG_SCHEME & scheme () const
 
const SessionBundlesessions () const
 
virtual TPMT_SIGNATURE unmarshal_signature (std::span< const uint8_t > sig_data) const =0
 

Detailed Description

Signature verification on the TPM. This does not require a validation ticket, therefore the hash is always calculated in software.

Definition at line 90 of file tpm2_pkops.h.

Constructor & Destructor Documentation

◆ Verification_Operation()

Botan::TPM2::Verification_Operation::Verification_Operation ( const Object & object,
const SessionBundle & sessions,
const SignatureAlgorithmSelection & algorithms )

Definition at line 97 of file tpm2_pkops.cpp.

99 :
100 Signature_Operation_Base<PK_Ops::Verification>(
101 object, sessions, algorithms, Botan::HashFunction::create_or_throw(algorithms.hash_name)) {}
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:298

Member Function Documentation

◆ hash()

Definition at line 46 of file tpm2_pkops.h.

46{ return m_hash.get(); }

Referenced by is_valid_signature().

◆ hash_function()

std::string Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::hash_function ( ) const
inlineoverridevirtualinherited

Implements Botan::PK_Ops::Verification.

Definition at line 43 of file tpm2_pkops.h.

43{ return m_hash->name(); }

◆ is_valid_signature()

bool Botan::TPM2::Verification_Operation::is_valid_signature ( std::span< const uint8_t > sig)
overridevirtual

Perform a verification operation

Parameters
sigthe signature to be checked with respect to the input

Implements Botan::PK_Ops::Verification.

Definition at line 103 of file tpm2_pkops.cpp.

103 {
104 TPM2B_DIGEST digest;
105 hash()->final(as_span(digest, hash()->output_length()));
106
107 const auto signature = unmarshal_signature(sig_data);
108
109 // If the signature is not valid, this returns TPM2_RC_SIGNATURE.
110 const auto rc = check_rc_expecting<TPM2_RC_SIGNATURE>("Esys_VerifySignature",
111 Esys_VerifySignature(*key_handle().context(),
112 key_handle().transient_handle(),
113 sessions()[0],
114 sessions()[1],
115 sessions()[2],
116 &digest,
117 &signature,
118 nullptr /* validation */));
119
120 return rc == TPM2_RC_SUCCESS;
121}
void final(uint8_t out[])
Definition buf_comp.h:70
virtual TPMT_SIGNATURE unmarshal_signature(std::span< const uint8_t > sig_data) const =0
constexpr auto as_span(tpm2_buffer auto &data)
Construct a std::span as a view into a TPM2 buffer.
Definition tpm2_util.h:102
constexpr TSS2_RC check_rc_expecting(std::string_view location, TSS2_RC rc)
Definition tpm2_util.h:72

References Botan::TPM2::as_span(), Botan::TPM2::check_rc_expecting(), Botan::Buffered_Computation::final(), Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::hash(), Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::key_handle(), Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::sessions(), and unmarshal_signature().

◆ key_handle()

const Object & Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::key_handle ( ) const
inlineprotectedinherited

Definition at line 48 of file tpm2_pkops.h.

48{ return m_key_handle; }

Referenced by is_valid_signature().

◆ padding()

std::optional< std::string > Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::padding ( ) const
inlineprotectedinherited

Definition at line 54 of file tpm2_pkops.h.

54{ return m_padding; }

◆ scheme()

const TPMT_SIG_SCHEME & Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::scheme ( ) const
inlineprotectedinherited

Definition at line 52 of file tpm2_pkops.h.

52{ return m_scheme; }

◆ sessions()

const SessionBundle & Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::sessions ( ) const
inlineprotectedinherited

Definition at line 50 of file tpm2_pkops.h.

50{ return m_sessions; }

Referenced by is_valid_signature().

◆ unmarshal_signature()

virtual TPMT_SIGNATURE Botan::TPM2::Verification_Operation::unmarshal_signature ( std::span< const uint8_t > sig_data) const
protectedpure virtual

Referenced by is_valid_signature().

◆ update()

void Botan::TPM2::Signature_Operation_Base< PK_Ops::Verification >::update ( std::span< const uint8_t > input)
inlineoverridevirtualinherited

Implements Botan::PK_Ops::Verification.

Definition at line 41 of file tpm2_pkops.h.

41{ m_hash->update(msg); }

The documentation for this class was generated from the following files: