Botan 3.10.0
Crypto and TLS for C&
Botan::BLAKE2b Class Referencefinal

#include <blake2b.h>

Inheritance diagram for Botan::BLAKE2b:
Botan::HashFunction Botan::SymmetricAlgorithm Botan::Buffered_Computation

Public Member Functions

 BLAKE2b (size_t output_bits=512)
void clear () override
HashFunctionclone () const
std::unique_ptr< 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 ()
bool has_keying_material () const override
size_t hash_block_size () const override
size_t key_size () const
Key_Length_Specification key_spec () const override
size_t maximum_keylength () const
size_t minimum_keylength () const
std::string name () const override
std::unique_ptr< 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
void set_key (const OctetString &key)
void set_key (const uint8_t key[], size_t length)
void set_key (std::span< const uint8_t > key)
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)
bool valid_keylength (size_t length) const

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)

Protected Member Functions

void add_data (std::span< const uint8_t > input) override
void assert_key_material_set () const
void assert_key_material_set (bool predicate) const
void final_result (std::span< uint8_t > out) override
void key_schedule (std::span< const uint8_t > key) override

Friends

class BLAKE2bMAC

Detailed Description

BLAKE2B

Definition at line 26 of file blake2b.h.

Constructor & Destructor Documentation

◆ BLAKE2b()

Botan::BLAKE2b::BLAKE2b ( size_t output_bits = 512)
explicit
Parameters
output_bitsthe output size of BLAKE2b in bits

Definition at line 34 of file blake2b.cpp.

34 : m_output_bits(output_bits), m_H(blake2b_IV.size()), m_T(), m_F(), m_key_size(0) {
35 if(output_bits == 0 || output_bits > 512 || output_bits % 8 != 0) {
36 throw Invalid_Argument("Bad output bits size for BLAKE2b");
37 }
38
39 state_init();
40}

Member Function Documentation

◆ add_data()

void Botan::BLAKE2b::add_data ( std::span< const uint8_t > input)
overrideprotectedvirtual

Add more data to the computation

Parameters
inputis an input buffer

Implements Botan::Buffered_Computation.

Definition at line 139 of file blake2b.cpp.

139 {
140 BufferSlicer in(input);
141
142 while(!in.empty()) {
143 if(const auto one_block = m_buffer.handle_unaligned_data(in)) {
144 compress(one_block->data(), 1, BLAKE2B_BLOCKBYTES);
145 }
146
147 if(m_buffer.in_alignment()) {
148 const auto [aligned_data, full_blocks] = m_buffer.aligned_data_to_process(in);
149 if(full_blocks > 0) {
150 compress(aligned_data.data(), full_blocks, BLAKE2B_BLOCKBYTES);
151 }
152 }
153 }
154}
constexpr size_t BLAKE2B_BLOCKBYTES
Definition blake2b.h:21

References Botan::BLAKE2B_BLOCKBYTES, and Botan::BufferSlicer::empty().

◆ assert_key_material_set() [1/2]

◆ assert_key_material_set() [2/2]

void Botan::SymmetricAlgorithm::assert_key_material_set ( bool predicate) const
inlineprotectedinherited

Definition at line 148 of file sym_algo.h.

148 {
149 if(!predicate) {
150 throw_key_not_set_error();
151 }
152 }

◆ clear()

void Botan::BLAKE2b::clear ( )
overridevirtual

Reset the state.

Implements Botan::HashFunction.

Definition at line 201 of file blake2b.cpp.

201 {
202 zeroise(m_H);
203 m_buffer.clear();
204 zeroise(m_padded_key_buffer);
205 m_key_size = 0;
206 state_init();
207}
void zeroise(std::vector< T, Alloc > &vec)
Definition secmem.h:125

References Botan::zeroise().

◆ clone()

HashFunction * Botan::HashFunction::clone ( ) const
inlineinherited
Returns
new object representing the same algorithm as *this

Definition at line 85 of file hash.h.

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

References new_object().

◆ copy_state()

std::unique_ptr< HashFunction > Botan::BLAKE2b::copy_state ( ) const
overridevirtual

Return a new hash object with the same state as *this. This allows computing the hash of several messages with a common prefix more efficiently than would otherwise be possible.

This function should be called clone but that was already used for the case of returning an uninitialized object.

Returns
new hash object

Implements Botan::HashFunction.

Definition at line 178 of file blake2b.cpp.

178 {
179 return std::make_unique<BLAKE2b>(*this);
180}

◆ 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:49
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(), and create_or_throw().

◆ 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::create_hex_fingerprint(), Botan::Sodium::crypto_hash_sha256(), Botan::Sodium::crypto_hash_sha512(), Botan::Bcrypt_PBKDF::derive_key(), Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::expand_message_xmd(), Botan::TLS::Handshake_Hash::final(), Botan::Certificate_Store_In_Memory::find_cert_by_pubkey_sha1(), Botan::Certificate_Store_In_Memory::find_cert_by_raw_subject_dn_sha256(), Botan::generate_dsa_primes(), Botan::LMOTS_Params::hash(), Botan::LMS_Params::hash(), Botan::Classic_McEliece_Parameters::hash_func(), Botan::OCSP::CertID::is_id_for(), 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(), 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 of your choice.

Returns
a contiguous container holding the result

Definition at line 77 of file buf_comp.h.

77 {
78 T output(output_length());
79 final_result(output);
80 return output;
81 }
virtual size_t output_length() const =0

References output_length().

◆ final() [2/4]

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

Definition at line 54 of file buf_comp.cpp.

54 {
55 BOTAN_ARG_CHECK(out.size() >= output_length(), "provided output buffer has insufficient capacity");
56 final_result(out);
57}
#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

Definition at line 88 of file buf_comp.h.

88 {
89 out.resize(output_length());
90 final_result(out);
91 }

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. Must be of length output_length()

Definition at line 69 of file buf_comp.h.

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

References output_length().

Referenced by 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_result()

void Botan::BLAKE2b::final_result ( std::span< uint8_t > out)
overrideprotectedvirtual

Write the final output to out

Parameters
outis an output buffer of output_length()

Implements Botan::Buffered_Computation.

Definition at line 156 of file blake2b.cpp.

156 {
157 const auto pos = m_buffer.elements_in_buffer();
158 m_buffer.fill_up_with_zeros();
159
160 m_F = 0xFFFFFFFFFFFFFFFF;
161 compress(m_buffer.consume().data(), 1, pos);
162 copy_out_le(output.first(output_length()), m_H);
163 state_init();
164}
size_t output_length() const override
Definition blake2b.h:36
void copy_out_le(std::span< uint8_t > out, const InR &in)
Definition loadstor.h:789

References Botan::copy_out_le(), and output_length().

◆ final_stdvec()

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

Definition at line 83 of file buf_comp.h.

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

References final().

◆ has_keying_material()

bool Botan::BLAKE2b::has_keying_material ( ) const
overridevirtual
Returns
true if a key has been set on this object

Implements Botan::SymmetricAlgorithm.

Definition at line 182 of file blake2b.cpp.

182 {
183 return m_key_size > 0;
184}

◆ hash_block_size()

size_t Botan::BLAKE2b::hash_block_size ( ) const
inlineoverridevirtual
Returns
hash block size as defined for this algorithm

Reimplemented from Botan::HashFunction.

Definition at line 34 of file blake2b.h.

34{ return 128; }

◆ key_schedule()

void Botan::BLAKE2b::key_schedule ( std::span< const uint8_t > key)
overrideprotectedvirtual

Run the key schedule

Parameters
keythe key

Implements Botan::SymmetricAlgorithm.

Definition at line 186 of file blake2b.cpp.

186 {
187 BOTAN_ASSERT_NOMSG(key.size() <= m_buffer.size());
188
189 m_key_size = key.size();
190 m_padded_key_buffer.resize(m_buffer.size());
191
192 if(m_padded_key_buffer.size() > m_key_size) {
193 size_t padding = m_padded_key_buffer.size() - m_key_size;
194 clear_mem(m_padded_key_buffer.data() + m_key_size, padding);
195 }
196
197 copy_mem(m_padded_key_buffer.data(), key.data(), key.size());
198 state_init();
199}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:145
constexpr void clear_mem(T *ptr, size_t n)
Definition mem_ops.h:119

References BOTAN_ASSERT_NOMSG, Botan::clear_mem(), and Botan::copy_mem().

◆ key_size()

size_t Botan::BLAKE2b::key_size ( ) const
inline

Definition at line 38 of file blake2b.h.

38{ return m_key_size; }

◆ key_spec()

Key_Length_Specification Botan::BLAKE2b::key_spec ( ) const
overridevirtual
Returns
object describing limits on key size

Implements Botan::SymmetricAlgorithm.

Definition at line 166 of file blake2b.cpp.

166 {
167 return Key_Length_Specification(1, 64);
168}

◆ maximum_keylength()

size_t Botan::SymmetricAlgorithm::maximum_keylength ( ) const
inlineinherited
Returns
maximum allowed key length

Definition at line 102 of file sym_algo.h.

102{ return key_spec().maximum_keylength(); }
size_t maximum_keylength() const
Definition sym_algo.h:56
virtual Key_Length_Specification key_spec() const =0

References key_spec().

◆ minimum_keylength()

size_t Botan::SymmetricAlgorithm::minimum_keylength ( ) const
inlineinherited
Returns
minimum allowed key length

Definition at line 107 of file sym_algo.h.

107{ return key_spec().minimum_keylength(); }
size_t minimum_keylength() const
Definition sym_algo.h:51

References key_spec().

◆ name()

std::string Botan::BLAKE2b::name ( ) const
overridevirtual
Returns
the hash function name

Implements Botan::HashFunction.

Definition at line 170 of file blake2b.cpp.

170 {
171 return fmt("BLAKE2b({})", m_output_bits);
172}
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::fmt().

◆ new_object()

std::unique_ptr< HashFunction > Botan::BLAKE2b::new_object ( ) const
overridevirtual
Returns
new object representing the same algorithm as *this

Implements Botan::HashFunction.

Definition at line 174 of file blake2b.cpp.

174 {
175 return std::make_unique<BLAKE2b>(m_output_bits);
176}

◆ output_length()

size_t Botan::BLAKE2b::output_length ( ) const
inlineoverridevirtual
Returns
length of the output of this function in bytes

Implements Botan::Buffered_Computation.

Definition at line 36 of file blake2b.h.

36{ return m_output_bits / 8; }

Referenced by final_result().

◆ 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 101 of file buf_comp.h.

101 {
102 update(in, length);
103 return final<T>();
104 }
void update(const uint8_t in[], size_t length)
Definition buf_comp.h:34

References final(), and update().

Referenced by Botan::Kyber_Symmetric_Primitives::H(), Botan::Kyber_Symmetric_Primitives::H(), and Botan::Kyber_Symmetric_Primitives::H().

◆ 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 125 of file buf_comp.h.

125 {
126 update(in);
127 return final<T>();
128 }

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 113 of file buf_comp.h.

113 {
114 update(in);
115 return final<T>();
116 }

References final(), and update().

◆ provider()

virtual std::string Botan::HashFunction::provider ( ) const
inlinevirtualinherited
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, and Botan::SHAKE_256.

Definition at line 49 of file hash.h.

49{ return "base"; }

Referenced by create(), and create_or_throw().

◆ providers()

std::vector< std::string > Botan::HashFunction::providers ( std::string_view algo_spec)
staticinherited
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:105

References Botan::probe_providers_of().

◆ set_key() [1/3]

◆ set_key() [2/3]

void Botan::SymmetricAlgorithm::set_key ( const uint8_t key[],
size_t length )
inlineinherited

Set the symmetric key of this object.

Parameters
keythe to be set as a byte array.
lengthin bytes of key param

Definition at line 133 of file sym_algo.h.

133{ set_key(std::span{key, length}); }

References set_key().

Referenced by set_key().

◆ set_key() [3/3]

void Botan::SymmetricAlgorithm::set_key ( std::span< const uint8_t > key)
inherited

Set the symmetric key of this object.

Parameters
keythe contiguous byte range to be set.

Definition at line 22 of file sym_algo.cpp.

22 {
23 if(!valid_keylength(key.size())) {
24 throw Invalid_Key_Length(name(), key.size());
25 }
26 key_schedule(key);
27}
bool valid_keylength(size_t length) const
Definition sym_algo.h:114
virtual std::string name() const =0

References name(), and valid_keylength().

◆ 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 34 of file buf_comp.h.

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

Referenced by 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(), Botan::TLS::TLS_NULL_HMAC_AEAD_Mode::set_associated_data_n(), 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 40 of file buf_comp.h.

40{ 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:28

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 61 of file buf_comp.h.

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

◆ update_be() [1/3]

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

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::mgf1_mask(), and Botan::pbkdf2().

◆ update_be() [2/3]

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

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

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

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

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

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().

◆ valid_keylength()

bool Botan::SymmetricAlgorithm::valid_keylength ( size_t length) const
inlineinherited

Check whether a given key length is valid for this algorithm.

Parameters
lengththe key length to be checked.
Returns
true if the key length is valid.

Definition at line 114 of file sym_algo.h.

114{ return key_spec().valid_keylength(length); }
bool valid_keylength(size_t length) const
Definition sym_algo.h:44

References key_spec().

Referenced by set_key().

◆ BLAKE2bMAC

friend class BLAKE2bMAC
friend

Definition at line 50 of file blake2b.h.

References BLAKE2bMAC.

Referenced by BLAKE2bMAC.


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