Botan 3.13.0
Crypto and TLS for C&
Botan::TPM2::HashFunction Class Referencefinal

#include <tpm2_hash.h>

Inheritance diagram for Botan::TPM2::HashFunction:
Botan::HashFunction Botan::Buffered_Computation

Public Member Functions

void clear () override
HashFunctionclone () const
std::unique_ptr< Botan::HashFunctioncopy_state () const override
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
final ()
void final (std::span< uint8_t > out)
template<concepts::resizable_byte_buffer T>
void final (T &out)
void final (uint8_t out[])
std::vector< uint8_t > final_stdvec ()
std::pair< unique_esys_ptr< TPM2B_DIGEST >, unique_esys_ptr< TPMT_TK_HASHCHECK > > final_with_ticket ()
virtual size_t hash_block_size () const
 HashFunction (std::shared_ptr< Context > ctx, std::string_view algorithm, TPMI_RH_HIERARCHY hierarchy=ESYS_TR_RH_NULL, SessionBundle sessions={})
std::string name () const override
std::unique_ptr< Botan::HashFunctionnew_object () const override
size_t output_length () const override
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
process (const uint8_t in[], size_t length)
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
process (std::span< const uint8_t > in)
template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
process (std::string_view in)
virtual std::string provider () const
size_t security_level () const override
TPMI_ALG_HASH type () const
void update (const uint8_t in[], size_t length)
void update (std::span< const uint8_t > in)
void update (std::string_view str)
void update (uint8_t in)
void update_be (uint16_t val)
void update_be (uint32_t val)
void update_be (uint64_t val)
void update_le (uint16_t val)
void update_le (uint32_t val)
void update_le (uint64_t val)

Static Public Member Functions

static std::unique_ptr< HashFunctioncreate (std::string_view algo_spec, std::string_view provider="")
static std::unique_ptr< HashFunctioncreate_or_throw (std::string_view algo_spec, std::string_view provider="")
static std::vector< std::string > providers (std::string_view algo_spec)

Detailed Description

Exposes the hashing capability of a TPM 2.0 device as a Botan::HashFunction. Typically this is used to obtain a TPMT_TK_HASHCHECK ticket after the hash operation has been completed. Otherwise, the HashFunction behaves like any other Botan::HashFunction.

Definition at line 29 of file tpm2_hash.h.

Constructor & Destructor Documentation

◆ HashFunction()

Botan::TPM2::HashFunction::HashFunction ( std::shared_ptr< Context > ctx,
std::string_view algorithm,
TPMI_RH_HIERARCHY hierarchy = ESYS_TR_RH_NULL,
SessionBundle sessions = {} )

Definition at line 20 of file tpm2_hash.cpp.

23 :
24 m_hash_type(get_tpm2_hash_type(algorithm)),
25 m_hierarchy(hierarchy),
26 m_handle(std::move(ctx)),
27 m_sessions(std::move(sessions)) {
28 // When creating a new hash object we assume that the call will use it to
29 // hash data and therefore setup the hash object immediately.
30 lazy_setup();
31}
TPMI_ALG_HASH get_tpm2_hash_type(std::string_view hash_name)

References Botan::TPM2::get_tpm2_hash_type().

Member Function Documentation

◆ clear()

void Botan::TPM2::HashFunction::clear ( )
overridevirtual

Reset the state.

Implements Botan::HashFunction.

Definition at line 66 of file tpm2_hash.cpp.

66 {
67 m_handle._reset();
68}

◆ clone()

HashFunction * Botan::HashFunction::clone ( ) const
inlineinherited

Create a new uninitialized object of the same type

Returns
new object representing the same algorithm as *this

Definition at line 100 of file hash.h.

100{ return this->new_object().release(); }
virtual std::unique_ptr< HashFunction > new_object() const =0

References new_object().

◆ copy_state()

std::unique_ptr< Botan::HashFunction > Botan::TPM2::HashFunction::copy_state ( ) const
overridevirtual
Exceptions
Not_Implementedas copying state is not supported within the TPM

Implements Botan::HashFunction.

Definition at line 70 of file tpm2_hash.cpp.

70 {
71 throw Not_Implemented("TPM 2.0 hash functions do not support copy_state");
72}

◆ create()

std::unique_ptr< HashFunction > Botan::HashFunction::create ( std::string_view algo_spec,
std::string_view provider = "" )
staticinherited

Create an instance based on a name, or return null if the algo/provider combination cannot be found. If provider is empty then best available is chosen.

Definition at line 111 of file hash.cpp.

111 {
112#if defined(BOTAN_HAS_COMMONCRYPTO)
113 if(provider.empty() || provider == "commoncrypto") {
114 if(auto hash = make_commoncrypto_hash(algo_spec))
115 return hash;
116
117 if(!provider.empty())
118 return nullptr;
119 }
120#endif
121
122 if(provider.empty() == false && provider != "base") {
123 return nullptr; // unknown provider
124 }
125
126#if defined(BOTAN_HAS_SHA1)
127 if(algo_spec == "SHA-1") {
128 return std::make_unique<SHA_1>();
129 }
130#endif
131
132#if defined(BOTAN_HAS_SHA2_32)
133 if(algo_spec == "SHA-224") {
134 return std::make_unique<SHA_224>();
135 }
136
137 if(algo_spec == "SHA-256") {
138 return std::make_unique<SHA_256>();
139 }
140#endif
141
142#if defined(BOTAN_HAS_SHA2_64)
143 if(algo_spec == "SHA-384") {
144 return std::make_unique<SHA_384>();
145 }
146
147 if(algo_spec == "SHA-512") {
148 return std::make_unique<SHA_512>();
149 }
150
151 if(algo_spec == "SHA-512-256") {
152 return std::make_unique<SHA_512_256>();
153 }
154#endif
155
156#if defined(BOTAN_HAS_RIPEMD_160)
157 if(algo_spec == "RIPEMD-160") {
158 return std::make_unique<RIPEMD_160>();
159 }
160#endif
161
162#if defined(BOTAN_HAS_WHIRLPOOL)
163 if(algo_spec == "Whirlpool") {
164 return std::make_unique<Whirlpool>();
165 }
166#endif
167
168#if defined(BOTAN_HAS_MD5)
169 if(algo_spec == "MD5") {
170 return std::make_unique<MD5>();
171 }
172#endif
173
174#if defined(BOTAN_HAS_MD4)
175 if(algo_spec == "MD4") {
176 return std::make_unique<MD4>();
177 }
178#endif
179
180#if defined(BOTAN_HAS_GOST_34_11)
181 if(algo_spec == "GOST-R-34.11-94" || algo_spec == "GOST-34.11") {
182 return std::make_unique<GOST_34_11>();
183 }
184#endif
185
186#if defined(BOTAN_HAS_ADLER32)
187 if(algo_spec == "Adler32") {
188 return std::make_unique<Adler32>();
189 }
190#endif
191
192#if defined(BOTAN_HAS_ASCON_HASH256)
193 if(algo_spec == "Ascon-Hash256") {
194 return std::make_unique<Ascon_Hash256>();
195 }
196#endif
197
198#if defined(BOTAN_HAS_CRC24)
199 if(algo_spec == "CRC24") {
200 return std::make_unique<CRC24>();
201 }
202#endif
203
204#if defined(BOTAN_HAS_CRC32)
205 if(algo_spec == "CRC32") {
206 return std::make_unique<CRC32>();
207 }
208#endif
209
210#if defined(BOTAN_HAS_STREEBOG)
211 if(algo_spec == "Streebog-256") {
212 return std::make_unique<Streebog>(256);
213 }
214 if(algo_spec == "Streebog-512") {
215 return std::make_unique<Streebog>(512);
216 }
217#endif
218
219#if defined(BOTAN_HAS_SM3)
220 if(algo_spec == "SM3") {
221 return std::make_unique<SM3>();
222 }
223#endif
224
225 const SCAN_Name req(algo_spec);
226
227#if defined(BOTAN_HAS_SKEIN_512)
228 if(req.algo_name() == "Skein-512") {
229 return std::make_unique<Skein_512>(req.arg_as_integer(0, 512), req.arg(1, ""));
230 }
231#endif
232
233#if defined(BOTAN_HAS_BLAKE2B)
234 if(req.algo_name() == "Blake2b" || req.algo_name() == "BLAKE2b") {
235 return std::make_unique<BLAKE2b>(req.arg_as_integer(0, 512));
236 }
237#endif
238
239#if defined(BOTAN_HAS_BLAKE2S)
240 if(req.algo_name() == "Blake2s" || req.algo_name() == "BLAKE2s") {
241 return std::make_unique<BLAKE2s>(req.arg_as_integer(0, 256));
242 }
243#endif
244
245#if defined(BOTAN_HAS_KECCAK)
246 if(req.algo_name() == "Keccak-1600") {
247 return std::make_unique<Keccak_1600>(req.arg_as_integer(0, 512));
248 }
249#endif
250
251#if defined(BOTAN_HAS_SHA3)
252 if(req.algo_name() == "SHA-3") {
253 return std::make_unique<SHA_3>(req.arg_as_integer(0, 512));
254 }
255#endif
256
257#if defined(BOTAN_HAS_SHAKE)
258 if(req.algo_name() == "SHAKE-128" && req.arg_count() == 1) {
259 return std::make_unique<SHAKE_128>(req.arg_as_integer(0));
260 }
261 if(req.algo_name() == "SHAKE-256" && req.arg_count() == 1) {
262 return std::make_unique<SHAKE_256>(req.arg_as_integer(0));
263 }
264#endif
265
266#if defined(BOTAN_HAS_PARALLEL_HASH)
267 if(req.algo_name() == "Parallel") {
268 std::vector<std::unique_ptr<HashFunction>> hashes;
269
270 for(size_t i = 0; i != req.arg_count(); ++i) {
271 auto h = HashFunction::create(req.arg(i));
272 if(!h) {
273 return nullptr;
274 }
275 hashes.push_back(std::move(h));
276 }
277
278 return std::make_unique<Parallel>(hashes);
279 }
280#endif
281
282#if defined(BOTAN_HAS_TRUNCATED_HASH)
283 if(req.algo_name() == "Truncated" && req.arg_count() == 2) {
284 auto hash = HashFunction::create(req.arg(0));
285 if(!hash) {
286 return nullptr;
287 }
288
289 return std::make_unique<Truncated_Hash>(std::move(hash), req.arg_as_integer(1));
290 }
291#endif
292
293#if defined(BOTAN_HAS_COMB4P)
294 if(req.algo_name() == "Comb4P" && req.arg_count() == 2) {
295 auto h1 = HashFunction::create(req.arg(0));
296 auto h2 = HashFunction::create(req.arg(1));
297
298 if(h1 && h2) {
299 return std::make_unique<Comb4P>(std::move(h1), std::move(h2));
300 }
301 }
302#endif
303
304 return nullptr;
305}
virtual std::string provider() const
Definition hash.h:51
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:111
std::unique_ptr< HashFunction > make_commoncrypto_hash(std::string_view name)

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), create(), Botan::make_commoncrypto_hash(), and provider().

Referenced by botan_hash_init(), Botan::BlockCipher::create(), Botan::EncryptionPaddingScheme::create(), create(), Botan::KDF::create(), Botan::MessageAuthenticationCode::create(), Botan::PasswordHashFamily::create(), Botan::PBKDF::create(), Botan::SignaturePaddingScheme::create(), create_or_throw(), and Botan::EC_Group_Data::hash_to_curve_supported().

◆ create_or_throw()

std::unique_ptr< HashFunction > Botan::HashFunction::create_or_throw ( std::string_view algo_spec,
std::string_view provider = "" )
staticinherited

Create an instance based on a name If provider is empty then best available is chosen.

Parameters
algo_specalgorithm name
providerprovider implementation to use Throws Lookup_Error if not found.

Definition at line 308 of file hash.cpp.

308 {
309 if(auto hash = HashFunction::create(algo, provider)) {
310 return hash;
311 }
312 throw Lookup_Error("Hash", algo, provider);
313}

References create(), and provider().

Referenced by botan_pubkey_fingerprint(), botan_pubkey_sm2_compute_za(), Botan::OCSP::CertID::CertID(), Botan::TLS::Client_Hello_Internal::Client_Hello_Internal(), Botan::SPAKE2p::SystemParameters::confirmation_size(), Botan::Kyber_90s_Symmetric_Primitives::create_G(), Botan::Kyber_Modern_Symmetric_Primitives::create_G(), Botan::ML_KEM_Symmetric_Primitives::create_G(), Botan::Kyber_90s_Symmetric_Primitives::create_H(), Botan::Kyber_Modern_Symmetric_Primitives::create_H(), Botan::ML_KEM_Symmetric_Primitives::create_H(), Botan::create_hex_fingerprint(), Botan::ML_KEM_Symmetric_Primitives::create_J(), Botan::Kyber_90s_Symmetric_Primitives::create_KDF(), Botan::Kyber_Modern_Symmetric_Primitives::create_KDF(), Botan::Sodium::crypto_hash_sha256(), Botan::Sodium::crypto_hash_sha512(), Botan::TLS::PSKImporter::derive_imported_psk(), Botan::Bcrypt_PBKDF::derive_key(), Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::PKCS12::export_to(), Botan::TLS::Handshake_Hash::final(), Botan::X509_Certificate_Cache::find_or_insert(), Botan::generate_dsa_primes(), Botan::h2c_expand_message(), Botan::LMOTS_Params::hash(), Botan::LMS_Params::hash(), Botan::Classic_McEliece_Parameters::hash_func(), Botan::Stateful_Key_Index_Registry::KeyId::KeyId(), Botan::TLS::make_hello_random(), Botan::Roughtime::nonce_from_blind(), Botan::PKCS1v15_Raw_SignaturePaddingScheme::PKCS1v15_Raw_SignaturePaddingScheme(), Botan::TLS::Transcript_Hash_State::set_algorithm(), Botan::RTSS_Share::split(), Botan::srp6_client_agree(), Botan::srp6_generate_verifier(), Botan::SRP6_Server_Session::step1(), Botan::SRP6_Server_Session::step2(), Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID(), Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID(), and Botan::PK_Ops::Verification_with_Hash::Verification_with_Hash().

◆ final() [1/4]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::Buffered_Computation::final ( )
inlineinherited

Complete the computation and retrieve the final result as a container.

Returns
a contiguous container holding the result

Definition at line 104 of file buf_comp.h.

104 {
105 T output(output_length());
106 final_result(output);
107 return output;
108 }
virtual size_t output_length() const =0

References output_length().

◆ final() [2/4]

void Botan::Buffered_Computation::final ( std::span< uint8_t > out)
inherited

Complete the computation and retrieve the final result

Parameters
outthe buffer to write the result to, must be output_length() bytes

Definition at line 54 of file buf_comp.cpp.

54 {
55 BOTAN_ARG_CHECK(out.size() >= output_length(), "Output buffer has insufficient capacity");
56 // Pass exactly output_length() bytes so that an oversized buffer has the
57 // result written to its leading bytes with the remainder left untouched.
58 final_result(out.first(output_length()));
59}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33

References BOTAN_ARG_CHECK, and output_length().

◆ final() [3/4]

template<concepts::resizable_byte_buffer T>
void Botan::Buffered_Computation::final ( T & out)
inlineinherited

Complete the computation and retrieve the final result

Parameters
outa container which is resized to hold the result

Definition at line 127 of file buf_comp.h.

127 {
128 out.resize(output_length());
129 final_result(out);
130 }

References output_length().

◆ final() [4/4]

void Botan::Buffered_Computation::final ( uint8_t out[])
inlineinherited

Complete the computation and retrieve the final result.

Parameters
outThe byte array to be filled with the result, which must be of length output_length()

Definition at line 97 of file buf_comp.h.

97{ final_result({out, output_length()}); }

References output_length().

Referenced by Botan::expand_message_xmd(), final_stdvec(), Botan::PseudorandomKeyGeneration::gen(), Botan::TPM2::Verification_Operation::is_valid_signature(), Botan::mgf1_mask(), Botan::KMAC::operator=(), Botan::pbkdf2(), Botan::Sphincs_Hash_Functions_Sha2::PRF_msg(), process(), process(), process(), Botan::TPM2::Signature_Operation::sign(), and Botan::sm2_compute_za().

◆ final_stdvec()

std::vector< uint8_t > Botan::Buffered_Computation::final_stdvec ( )
inlineinherited

Complete the computation and retrieve the final result

Returns
a std::vector holding the result

Definition at line 114 of file buf_comp.h.

114{ return final<std::vector<uint8_t>>(); }
void final(uint8_t out[])
Definition buf_comp.h:97

References final().

◆ final_with_ticket()

std::pair< unique_esys_ptr< TPM2B_DIGEST >, unique_esys_ptr< TPMT_TK_HASHCHECK > > Botan::TPM2::HashFunction::final_with_ticket ( )

Finalize the hash operation and return the digest and the ticket as TSS2 structures.

Returns
A pair of TPM2B_DIGEST and TPMT_TK_HASHCHECK

Definition at line 116 of file tpm2_hash.cpp.

116 {
117 BOTAN_STATE_CHECK(m_handle.has_transient_handle());
118
119 std::pair<unique_esys_ptr<TPM2B_DIGEST>, unique_esys_ptr<TPMT_TK_HASHCHECK>> result;
120
121 const auto nodata = init_empty<TPM2B_MAX_BUFFER>();
122 check_rc("Esys_SequenceComplete",
123 Esys_SequenceComplete(m_handle.context()->esys_context(),
124 m_handle.transient_handle(),
125 m_sessions[0],
126 m_sessions[1],
127 m_sessions[2],
128 &nodata,
129 m_hierarchy,
130 out_ptr(result.first),
131 out_ptr(result.second)));
132 BOTAN_ASSERT_NONNULL(result.first);
133
134 // Esys_SequenceComplete() destroys the underlying transient object
135 // so we need to disengage it's RAII wrapper.
136 m_handle._disengage();
137
138 return result;
139}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:114
constexpr T init_empty()
Create an empty TPM2 buffer of the given type.
Definition tpm2_util.h:153
constexpr void check_rc(std::string_view location, TSS2_RC rc)
Definition tpm2_util.h:55
std::unique_ptr< T, esys_liberator > unique_esys_ptr
A unique pointer type for ESYS handles that automatically frees the handle.
Definition tpm2_util.h:163
constexpr auto out_ptr(T &outptr) noexcept
Definition stl_util.h:148

References BOTAN_ASSERT_NONNULL, BOTAN_STATE_CHECK, Botan::TPM2::check_rc(), Botan::TPM2::init_empty(), and Botan::out_ptr().

◆ hash_block_size()

virtual size_t Botan::HashFunction::hash_block_size ( ) const
inlinevirtualinherited

Return the internal block size of this hash function

Returns
hash block size as defined for this algorithm

Reimplemented in Botan::BLAKE2b, Botan::BLAKE2s, Botan::Comb4P, Botan::GOST_34_11, Botan::Keccak_1600, Botan::MD4, Botan::MD5, Botan::RIPEMD_160, Botan::SHA_1, Botan::SHA_224, Botan::SHA_256, Botan::SHA_384, Botan::SHA_3, Botan::SHA_512, Botan::SHA_512_256, Botan::SHAKE_128, Botan::SHAKE_256, Botan::Skein_512, Botan::SM3, Botan::Streebog, and Botan::Whirlpool.

Definition at line 68 of file hash.h.

68{ return 0; }

Referenced by Botan::expand_message_xmd().

◆ name()

std::string Botan::TPM2::HashFunction::name ( ) const
overridevirtual

Return the name of this hash function

Returns
the hash function name

Implements Botan::HashFunction.

Definition at line 33 of file tpm2_hash.cpp.

33 {
34 return get_botan_hash_name(m_hash_type);
35}
std::string get_botan_hash_name(TPM2_ALG_ID hash_id)

References Botan::TPM2::get_botan_hash_name().

Referenced by new_object().

◆ new_object()

std::unique_ptr< Botan::HashFunction > Botan::TPM2::HashFunction::new_object ( ) const
overridevirtual

Create a new uninitialized object of the same type

Returns
new object representing the same algorithm as *this

Implements Botan::HashFunction.

Definition at line 74 of file tpm2_hash.cpp.

74 {
75 return std::make_unique<HashFunction>(m_handle.context(), name(), m_hierarchy, m_sessions);
76}
std::string name() const override
Definition tpm2_hash.cpp:33

References name().

◆ output_length()

size_t Botan::TPM2::HashFunction::output_length ( ) const
overridevirtual

Return the output length of this function

Returns
length of the output of this function in bytes

Implements Botan::Buffered_Computation.

Definition at line 37 of file tpm2_hash.cpp.

37 {
38 switch(m_hash_type) {
39 case TPM2_ALG_SHA1:
40 return 20;
41 case TPM2_ALG_SHA256:
42 case TPM2_ALG_SHA3_256:
43 case TPM2_ALG_SM3_256:
44 return 32;
45 case TPM2_ALG_SHA384:
46 case TPM2_ALG_SHA3_384:
47 return 48;
48 case TPM2_ALG_SHA512:
49 case TPM2_ALG_SHA3_512:
50 return 64;
51 default:
52 throw Invalid_State("TPM 2.0 hash object with unexpected hash type");
53 }
54}

◆ process() [1/3]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::Buffered_Computation::process ( const uint8_t in[],
size_t length )
inlineinherited

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process as a byte array
lengththe length of the byte array
Returns
the result of the call to final()

Definition at line 140 of file buf_comp.h.

140 {
141 update(in, length);
142 return final<T>();
143 }
void update(const uint8_t in[], size_t length)
Definition buf_comp.h:35

References final(), and update().

◆ process() [2/3]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::Buffered_Computation::process ( std::span< const uint8_t > in)
inlineinherited

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process as a contiguous container
Returns
the result of the call to final()

Definition at line 164 of file buf_comp.h.

164 {
165 update(in);
166 return final<T>();
167 }

References final(), and update().

◆ process() [3/3]

template<concepts::resizable_byte_buffer T = secure_vector<uint8_t>>
T Botan::Buffered_Computation::process ( std::string_view in)
inlineinherited

Update and finalize computation. Does the same as calling update() and final() consecutively.

Parameters
inthe input to process as a string
Returns
the result of the call to final()

Definition at line 152 of file buf_comp.h.

152 {
153 update(in);
154 return final<T>();
155 }

References final(), and update().

◆ provider()

virtual std::string Botan::HashFunction::provider ( ) const
inlinevirtualinherited

Return the name of the provider implementing this object

Returns
provider information about this implementation. Default is "base", might also return "sse2", "avx2", "openssl", or some other arbitrary string.

Reimplemented in Botan::Ascon_Hash256, Botan::Keccak_1600, Botan::SHA_1, Botan::SHA_224, Botan::SHA_256, Botan::SHA_384, Botan::SHA_3, Botan::SHA_512, Botan::SHA_512_256, Botan::SHAKE_128, Botan::SHAKE_256, Botan::SM3, Botan::Streebog, and Botan::Whirlpool.

Definition at line 51 of file hash.h.

51{ return "base"; }

Referenced by create(), and create_or_throw().

◆ providers()

std::vector< std::string > Botan::HashFunction::providers ( std::string_view algo_spec)
staticinherited

List the providers available for a given hash

Returns
list of available providers for this algorithm, empty if not available
Parameters
algo_specalgorithm name

Definition at line 315 of file hash.cpp.

315 {
316 return probe_providers_of<HashFunction>(algo_spec, {"base", "commoncrypto"});
317}
std::vector< std::string > probe_providers_of(std::string_view algo_spec, const std::vector< std::string > &possible={"base"})
Definition scan_name.h:99

References Botan::probe_providers_of().

◆ security_level()

size_t Botan::TPM2::HashFunction::security_level ( ) const
overridevirtual

Return an estimate, in bits, of the security level of this hash function, with respect to collision resistance. For most hashes this is simply half the output length, matching the generic birthday attack. It is lower for hash functions with a known collision attack, and zero for checksums and any hash where finding collisions is trivial.

Reimplemented from Botan::HashFunction.

Definition at line 56 of file tpm2_hash.cpp.

56 {
57 if(m_hash_type == TPM2_ALG_SHA1) {
58 // Collision attacks with cost ~2^61 are known (Leurent and Peyrin, 2020)
59 return 61;
60 } else {
61 // Otherwise just call the base class impl
63 }
64}
size_t security_level() const override
Definition tpm2_hash.cpp:56

References security_level().

Referenced by security_level().

◆ type()

TPMI_ALG_HASH Botan::TPM2::HashFunction::type ( ) const
inline
Returns
The hash algorithm identifier as TSS2's TPMI_ALG_HASH

Definition at line 46 of file tpm2_hash.h.

46{ return m_hash_type; }

◆ update() [1/4]

void Botan::Buffered_Computation::update ( const uint8_t in[],
size_t length )
inlineinherited

Add new input to process.

Parameters
inthe input to process as a byte array
lengthof param in in bytes

Definition at line 35 of file buf_comp.h.

35{ add_data({in, length}); }

Referenced by Botan::expand_message_xmd(), Botan::PseudorandomKeyGeneration::gen(), Botan::LMOTS_Public_Key::LMOTS_Public_Key(), Botan::mgf1_mask(), Botan::pbkdf2(), Botan::Sphincs_Hash_Functions_Sha2::PRF_msg(), process(), process(), process(), and Botan::sm2_compute_za().

◆ update() [2/4]

void Botan::Buffered_Computation::update ( std::span< const uint8_t > in)
inlineinherited

Add new input to process.

Parameters
inthe input to process as a contiguous data range

Definition at line 41 of file buf_comp.h.

41{ add_data(in); }

◆ update() [3/4]

void Botan::Buffered_Computation::update ( std::string_view str)
inherited

Add new input to process.

Parameters
strthe input to process as a std::string_view. Will be interpreted as a byte array based on the strings encoding.

Definition at line 14 of file buf_comp.cpp.

14 {
15 add_data(as_span_of_bytes(str));
16}
std::span< const uint8_t > as_span_of_bytes(const char *s, size_t len)
Definition mem_utils.h:59

References Botan::as_span_of_bytes().

◆ update() [4/4]

void Botan::Buffered_Computation::update ( uint8_t in)
inlineinherited

Process a single byte.

Parameters
inthe byte to process

Definition at line 90 of file buf_comp.h.

90{ add_data({&in, 1}); }

◆ update_be() [1/3]

void Botan::Buffered_Computation::update_be ( uint16_t val)
inherited

Add new input to process, encoded as a big-endian integer

Parameters
valthe value to process

Definition at line 18 of file buf_comp.cpp.

18 {
19 uint8_t inb[sizeof(val)];
20 store_be(val, inb);
21 add_data({inb, sizeof(inb)});
22}
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:745

References Botan::store_be().

Referenced by Botan::expand_message_xmd(), Botan::mgf1_mask(), and Botan::pbkdf2().

◆ update_be() [2/3]

void Botan::Buffered_Computation::update_be ( uint32_t val)
inherited

Add new input to process, encoded as a big-endian integer

Parameters
valthe value to process

Definition at line 24 of file buf_comp.cpp.

24 {
25 uint8_t inb[sizeof(val)];
26 store_be(val, inb);
27 add_data({inb, sizeof(inb)});
28}

References Botan::store_be().

◆ update_be() [3/3]

void Botan::Buffered_Computation::update_be ( uint64_t val)
inherited

Add new input to process, encoded as a big-endian integer

Parameters
valthe value to process

Definition at line 30 of file buf_comp.cpp.

30 {
31 uint8_t inb[sizeof(val)];
32 store_be(val, inb);
33 add_data({inb, sizeof(inb)});
34}

References Botan::store_be().

◆ update_le() [1/3]

void Botan::Buffered_Computation::update_le ( uint16_t val)
inherited

Add new input to process, encoded as a little-endian integer

Parameters
valthe value to process

Definition at line 36 of file buf_comp.cpp.

36 {
37 uint8_t inb[sizeof(val)];
38 store_le(val, inb);
39 add_data({inb, sizeof(inb)});
40}
constexpr auto store_le(ParamTs &&... params)
Definition loadstor.h:736

References Botan::store_le().

◆ update_le() [2/3]

void Botan::Buffered_Computation::update_le ( uint32_t val)
inherited

Add new input to process, encoded as a little-endian integer

Parameters
valthe value to process

Definition at line 42 of file buf_comp.cpp.

42 {
43 uint8_t inb[sizeof(val)];
44 store_le(val, inb);
45 add_data({inb, sizeof(inb)});
46}

References Botan::store_le().

◆ update_le() [3/3]

void Botan::Buffered_Computation::update_le ( uint64_t val)
inherited

Add new input to process, encoded as a little-endian integer

Parameters
valthe value to process

Definition at line 48 of file buf_comp.cpp.

48 {
49 uint8_t inb[sizeof(val)];
50 store_le(val, inb);
51 add_data({inb, sizeof(inb)});
52}

References Botan::store_le().


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