Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
Botan::SHA_3_224 Class Referencefinal

`#include <sha3.h>`

Inheritance diagram for Botan::SHA_3_224:

## Public Member Functions
void | clear () override
HashFunction * | clone () const override
std::unique_ptr< HashFunction > | copy_state () const override
void | final (uint8_t out[])
secure_vector< uint8_t > | final ()
template<typename Alloc >
void | final (std::vector< uint8_t, Alloc > &out)
std::vector< uint8_t > | final_stdvec ()
size_t | hash_block_size () const override
std::string | name () const override
size_t | output_length () const override
secure_vector< uint8_t > | process (const uint8_t in[], size_t length)
secure_vector< uint8_t > | process (const secure_vector< uint8_t > &in)
secure_vector< uint8_t > | process (const std::vector< uint8_t > &in)
secure_vector< uint8_t > | process (const std::string &in)
std::string | provider () const override
| SHA_3_224 ()
void | update (const uint8_t in[], size_t length)
void | update (const secure_vector< uint8_t > &in)
void | update (const std::vector< uint8_t > &in)
void | update (const std::string &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 size_t | absorb (size_t bitrate, secure_vector< uint64_t > &S, size_t S_pos, const uint8_t input[], size_t length)
static std::unique_ptr< HashFunction > | create (const std::string &algo_spec, const std::string &provider="")
static std::unique_ptr< HashFunction > | create_or_throw (const std::string &algo_spec, const std::string &provider="")
static void | expand (size_t bitrate, secure_vector< uint64_t > &S, uint8_t output[], size_t output_length)
static void | finish (size_t bitrate, secure_vector< uint64_t > &S, size_t S_pos, uint8_t init_pad, uint8_t fini_pad)
static void | permute (uint64_t A[25])
static std::vector< std::string > | providers (const std::string &algo_spec)

## Detailed Description

SHA-3-224

Definition at line 101 of file sha3.h.

## Constructor & Destructor Documentation

Botan::SHA_3_224::SHA_3_224 | ( |  | ) |
| inline

Definition at line 104 of file sha3.h.

104 : SHA_3(224) {}
Botan::SHA_3::SHA_3
SHA_3(size_t output_bits)
Definition: sha3.cpp:204

## Member Function Documentation

size_t Botan::SHA_3::absorb | ( | size_t | bitrate,
|  | secure_vector< uint64_t > & | S,
|  | size_t | S_pos,
|  | const uint8_t | input[],
|  | size_t | length
| ) |  |
| static inherited

Absorb data into the provided state

Parameters

  bitrate | the bitrate to absorb into the sponge
  S | the sponge state
  S_pos | where to begin absorbing into S
  input | the input data
  length | size of input in bytes

Definition at line 121 of file sha3.cpp.

References Botan::load_le< uint64_t >(), and Botan::SHA_3::permute().

124 {
125 while(length > 0)
126 {
127 size_t to_take = std::min(length, bitrate / 8 - S_pos);
128
129 length -= to_take;
130
131 while(to_take && S_pos % 8)
132 {
133 S[S_pos / 8] ^= static_cast<uint64_t>(input[0]) << (8 * (S_pos % 8));
134
135 ++S_pos;
136 ++input;
137 --to_take;
138 }
139
140 while(to_take && to_take % 8 == 0)
141 {
142 S[S_pos / 8] ^= load_le<uint64_t>(input, 0);
143 S_pos += 8;
144 input += 8;
145 to_take -= 8;
146 }
147
148 while(to_take)
149 {
150 S[S_pos / 8] ^= static_cast<uint64_t>(input[0]) << (8 * (S_pos % 8));
151
152 ++S_pos;
153 ++input;
154 --to_take;
155 }
156
157 if(S_pos == bitrate / 8)
158 {
159 SHA_3::permute(S.data());
160 S_pos = 0;
161 }
162 }
163
164 return S_pos;
165 }
Botan::load_le< uint64_t >
uint64_t load_le< uint64_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:237
Botan::SHA_3::permute
static void permute(uint64_t A[25])
Definition: sha3.cpp:91

void Botan::SHA_3::clear | ( |  | ) |
| override virtual inherited

Reset the state.

Implements Botan::HashFunction.

Definition at line 245 of file sha3.cpp.

References Botan::zeroise().

246 {
247 zeroise(m_S);
248 m_S_pos = 0;
249 }
Botan::zeroise
void zeroise(std::vector< T, Alloc > &vec)
Definition: secmem.h:160

HashFunction * Botan::SHA_3::clone | ( |  | ) | const
| override virtual inherited

Returns
  new object representing the same algorithm as *this

Implements Botan::HashFunction.

Definition at line 240 of file sha3.cpp.

References Botan::SHA_3::SHA_3().

241 {
242 return new SHA_3(m_output_bits);
243 }
Botan::SHA_3::SHA_3
SHA_3(size_t output_bits)
Definition: sha3.cpp:204

std::unique_ptr< HashFunction > Botan::SHA_3::copy_state | ( |  | ) | const
| override virtual inherited

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 235 of file sha3.cpp.

References Botan::SHA_3::SHA_3().

236 {
237 return std::unique_ptr<HashFunction>(new SHA_3(*this));
238 }
Botan::SHA_3::SHA_3
SHA_3(size_t output_bits)
Definition: sha3.cpp:204

std::unique_ptr< HashFunction > Botan::HashFunction::create | ( | const std::string & | algo_spec,
|  | const std::string & | provider = `""`
| ) |  |
| static inherited

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 106 of file hash.cpp.

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), hash, Botan::make_commoncrypto_hash(), and Botan::make_openssl_hash().

Referenced by botan_hash_init(), botan_pubkey_fingerprint(), Botan::BlockCipher::create(), Botan::KDF::create(), Botan::MessageAuthenticationCode::create(), Botan::PBKDF::create(), Botan::PasswordHashFamily::create(), Botan::HashFunction::create_or_throw(), Botan::Certificate_Store_In_Memory::find_cert_by_pubkey_sha1(), Botan::Certificate_Store_In_Memory::find_cert_by_raw_subject_dn_sha256(), Botan::get_eme(), Botan::get_emsa(), Botan::X942_PRF::kdf(), and Botan::X509_Certificate::raw_subject_dn_sha256().

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

std::unique_ptr< HashFunction > Botan::HashFunction::create_or_throw | ( | const std::string & | algo_spec,
|  | const std::string & | provider = `""`
| ) |  |
| static inherited

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

Parameters

  algo_spec | algorithm name
  provider | provider implementation to use Throws Lookup_Error if not found.

Definition at line 344 of file hash.cpp.

References Botan::HashFunction::create(), and hash.

Referenced by Botan::argon2(), Botan::bcrypt_pbkdf(), botan_pubkey_sm2_compute_za(), Botan::OCSP::CertID::CertID(), Botan::create_hex_fingerprint(), Botan::Sodium::crypto_hash_sha256(), Botan::Sodium::crypto_hash_sha512(), Botan::EMSA_PKCS1v15_Raw::EMSA_PKCS1v15_Raw(), Botan::TLS::Handshake_Hash::final(), Botan::generate_dsa_primes(), Botan::OCSP::CertID::is_id_for(), Botan::TLS::make_hello_random(), Botan::newhope_shareda(), Botan::newhope_sharedb(), Botan::Roughtime::nonce_from_blind(), Botan::X509_Certificate::raw_issuer_dn_sha256(), Botan::RTSS_Share::split(), and Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID().

346 {
347 if(auto hash = HashFunction::create(algo, provider))
348 {
349 return hash;
350 }
351 throw Lookup_Error("Hash", algo, provider);
352 }
Botan::HashFunction::provider
virtual std::string provider() const
Definition: hash.h:58
Botan::HashFunction::create
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:106
hash
MechanismType hash
Definition: p11_mechanism.cpp:64

void Botan::SHA_3::expand | ( | size_t | bitrate,
|  | secure_vector< uint64_t > & | S,
|  | uint8_t | output[],
|  | size_t | output_length
| ) |  |
| static inherited

Expand from provided state

Parameters

  bitrate | sponge parameter
  S | the state
  output | the output buffer
  output_length | the size of output in bytes

Definition at line 180 of file sha3.cpp.

References BOTAN_ARG_CHECK, Botan::copy_out_vec_le(), and Botan::SHA_3::permute().

183 {
184 BOTAN_ARG_CHECK(bitrate % 64 == 0, "SHA-3 bitrate must be multiple of 64");
185
186 const size_t byterate = bitrate / 8;
187
188 while(output_length > 0)
189 {
190 const size_t copying = std::min(byterate, output_length);
191
192 copy_out_vec_le(output, copying, S);
193
194 output += copying;
195 output_length -= copying;
196
197 if(output_length > 0)
198 {
199 SHA_3::permute(S.data());
200 }
201 }
202 }
Botan::SHA_3::output_length
size_t output_length() const override
Definition: sha3.h:33
BOTAN_ARG_CHECK
#define BOTAN_ARG_CHECK(expr, msg)
Definition: assert.h:37
Botan::SHA_3::permute
static void permute(uint64_t A[25])
Definition: sha3.cpp:91
Botan::copy_out_vec_le
void copy_out_vec_le(uint8_t out[], size_t out_bytes, const std::vector< T, Alloc > &in)
Definition: loadstor.h:694

void Botan::Buffered_Computation::final | ( | uint8_t | out[] | ) |
| inline inherited

Complete the computation and retrieve the final result.

Parameters

  out | The byte array to be filled with the result. Must be of length output_length()

Definition at line 83 of file buf_comp.h.

Referenced by botan_hash_final(), botan_mac_final(), Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::TLS::TLS_CBC_HMAC_AEAD_Encryption::finish(), Botan::TLS::TLS_CBC_HMAC_AEAD_Decryption::finish(), Botan::mgf1_mask(), Botan::pbkdf2(), and Botan::sm2_compute_za().

83 { final_result(out); }

secure_vector<uint8_t> Botan::Buffered_Computation::final | ( |  | ) |
| inline inherited

Complete the computation and retrieve the final result.

Returns
  secure_vector holding the result

Definition at line 90 of file buf_comp.h.

91 {
92 secure_vector<uint8_t> output(output_length());
93 final_result(output.data());
94 return output;
95 }
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0
template<typename Alloc >

void Botan::Buffered_Computation::final | ( | std::vector< uint8_t, Alloc > & | out | ) |
| inline inherited

Definition at line 105 of file buf_comp.h.

106 {
107 out.resize(output_length());
108 final_result(out.data());
109 }
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0

std::vector<uint8_t> Botan::Buffered_Computation::final_stdvec | ( |  | ) |
| inline inherited

Definition at line 97 of file buf_comp.h.

98 {
99 std::vector<uint8_t> output(output_length());
100 final_result(output.data());
101 return output;
102 }
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0

void Botan::SHA_3::finish | ( | size_t | bitrate,
|  | secure_vector< uint64_t > & | S,
|  | size_t | S_pos,
|  | uint8_t | init_pad,
|  | uint8_t | fini_pad
| ) |  |
| static inherited

Add final padding and permute. The padding is assumed to be init_pad || 00... || fini_pad

Parameters

  bitrate | the bitrate to absorb into the sponge
  S | the sponge state
  S_pos | where to begin absorbing into S
  init_pad | the leading pad bits
  fini_pad | the final pad bits

Definition at line 168 of file sha3.cpp.

References BOTAN_ARG_CHECK, and Botan::SHA_3::permute().

171 {
172 BOTAN_ARG_CHECK(bitrate % 64 == 0, "SHA-3 bitrate must be multiple of 64");
173
174 S[S_pos / 8] ^= static_cast<uint64_t>(init_pad) << (8 * (S_pos % 8));
175 S[(bitrate / 64) - 1] ^= static_cast<uint64_t>(fini_pad) << 56;
176 SHA_3::permute(S.data());
177 }
BOTAN_ARG_CHECK
#define BOTAN_ARG_CHECK(expr, msg)
Definition: assert.h:37
Botan::SHA_3::permute
static void permute(uint64_t A[25])
Definition: sha3.cpp:91

size_t Botan::SHA_3::hash_block_size | ( |  | ) | const
| inline override virtual inherited

Returns
  hash block size as defined for this algorithm

Reimplemented from Botan::HashFunction.

Definition at line 32 of file sha3.h.

32 { return m_bitrate / 8; }

std::string Botan::SHA_3::name | ( |  | ) | const
| override virtual inherited

Returns
  the hash function name

Implements Botan::HashFunction.

Definition at line 218 of file sha3.cpp.

References Botan::ASN1::to_string().

219 {
220 return "SHA-3(" + std::to_string(m_output_bits) + ")";
221 }
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213

size_t Botan::SHA_3::output_length | ( |  | ) | const
| inline override virtual inherited

Returns
  length of the output of this function in bytes

Implements Botan::Buffered_Computation.

Definition at line 33 of file sha3.h.

33 { return m_output_bits / 8; }

void Botan::SHA_3::permute | ( | uint64_t | A[25] | ) |
| static inherited

The bare Keccak-1600 permutation

Definition at line 91 of file sha3.cpp.

References T.

Referenced by Botan::SHA_3::absorb(), Botan::SHAKE_128_Cipher::cipher(), Botan::SHA_3::expand(), and Botan::SHA_3::finish().

92 {
93 #if defined(BOTAN_HAS_SHA3_BMI2)
94 if(CPUID::has_bmi2())
95 {
96 return permute_bmi2(A);
97 }
98 #endif
99
100 static const uint64_t RC[24] = {
101 0x0000000000000001, 0x0000000000008082, 0x800000000000808A,
102 0x8000000080008000, 0x000000000000808B, 0x0000000080000001,
103 0x8000000080008081, 0x8000000000008009, 0x000000000000008A,
104 0x0000000000000088, 0x0000000080008009, 0x000000008000000A,
105 0x000000008000808B, 0x800000000000008B, 0x8000000000008089,
106 0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
107 0x000000000000800A, 0x800000008000000A, 0x8000000080008081,
108 0x8000000000008080, 0x0000000080000001, 0x8000000080008008
109 };
110
111 uint64_t T[25];
112
113 for(size_t i = 0; i != 24; i += 2)
114 {
115 SHA3_round(T, A, RC[i+0]);
116 SHA3_round(A, T, RC[i+1]);
117 }
118 }
T
fe T
Definition: ge.cpp:37

secure_vector<uint8_t> Botan::Buffered_Computation::process | ( | const uint8_t | in[],
|  | size_t | length
| ) |  |
| inline inherited

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

Parameters

  in | the input to process as a byte array
  length | the length of the byte array

Returns
  the result of the call to final()

Definition at line 118 of file buf_comp.h.

119 {
120 add_data(in, length);
121 return final();
122 }

secure_vector<uint8_t> Botan::Buffered_Computation::process | ( | const secure_vector< uint8_t > & | in | ) |
| inline inherited

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

Parameters

  in | the input to process

Returns
  the result of the call to final()

Definition at line 130 of file buf_comp.h.

131 {
132 add_data(in.data(), in.size());
133 return final();
134 }

secure_vector<uint8_t> Botan::Buffered_Computation::process | ( | const std::vector< uint8_t > & | in | ) |
| inline inherited

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

Parameters

  in | the input to process

Returns
  the result of the call to final()

Definition at line 142 of file buf_comp.h.

143 {
144 add_data(in.data(), in.size());
145 return final();
146 }

secure_vector<uint8_t> Botan::Buffered_Computation::process | ( | const std::string & | in | ) |
| inline inherited

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

Parameters

  in | the input to process as a string

Returns
  the result of the call to final()

Definition at line 154 of file buf_comp.h.

References update.

155 {
156 update(in);
157 return final();
158 }
Botan::Buffered_Computation::update
void update(const uint8_t in[], size_t length)
Definition: buf_comp.h:33

std::string Botan::SHA_3::provider | ( |  | ) | const
| override virtual inherited

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

Reimplemented from Botan::HashFunction.

Definition at line 223 of file sha3.cpp.

224 {
225 #if defined(BOTAN_HAS_SHA3_BMI2)
226 if(CPUID::has_bmi2())
227 {
228 return "bmi2";
229 }
230 #endif
231
232 return "base";
233 }

std::vector< std::string > Botan::HashFunction::providers | ( | const std::string & | algo_spec | ) |
| static inherited

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

Parameters

  algo_spec | algorithm name

Definition at line 354 of file hash.cpp.

355 {
356 return probe_providers_of<HashFunction>(algo_spec, {"base", "openssl", "commoncrypto"});
357 }

void Botan::Buffered_Computation::update | ( | const uint8_t | in[],
|  | size_t | length
| ) |  |
| inline inherited

Add new input to process.

Parameters

  in | the input to process as a byte array
  length | of param in in bytes

Definition at line 33 of file buf_comp.h.

Referenced by botan_hash_update(), botan_mac_update(), Botan::ed25519_gen_keypair(), Botan::ed25519_sign(), Botan::ed25519_verify(), Botan::TLS::TLS_CBC_HMAC_AEAD_Encryption::finish(), Botan::TLS::TLS_CBC_HMAC_AEAD_Decryption::finish(), Botan::mgf1_mask(), Botan::pbkdf2(), and Botan::sm2_compute_za().

33 { add_data(in, length); }

void Botan::Buffered_Computation::update | ( | const secure_vector< uint8_t > & | in | ) |
| inline inherited

Add new input to process.

Parameters

  in | the input to process as a secure_vector

Definition at line 39 of file buf_comp.h.

40 {
41 add_data(in.data(), in.size());
42 }

void Botan::Buffered_Computation::update | ( | const std::vector< uint8_t > & | in | ) |
| inline inherited

Add new input to process.

Parameters

  in | the input to process as a std::vector

Definition at line 48 of file buf_comp.h.

49 {
50 add_data(in.data(), in.size());
51 }

void Botan::Buffered_Computation::update | ( | const std::string & | str | ) |
| inline inherited

Add new input to process.

Parameters

  str | the input to process as a std::string. Will be interpreted as a byte array based on the strings encoding.

Definition at line 66 of file buf_comp.h.

References Botan::cast_char_ptr_to_uint8().

67 {
68 add_data(cast_char_ptr_to_uint8(str.data()), str.size());
69 }
Botan::cast_char_ptr_to_uint8
const uint8_t * cast_char_ptr_to_uint8(const char *s)
Definition: mem_ops.h:189

void Botan::Buffered_Computation::update | ( | uint8_t | in | ) |
| inline inherited

Process a single byte.

Parameters

  in | the byte to process

Definition at line 75 of file buf_comp.h.

75 { add_data(&in, 1); }

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

Definition at line 12 of file buf_comp.cpp.

References Botan::store_be().

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

13 {
14 uint8_t inb[sizeof(val)];
15 store_be(val, inb);
16 add_data(inb, sizeof(inb));
17 }
Botan::store_be
void store_be(uint16_t in, uint8_t out[2])
Definition: loadstor.h:438

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

Definition at line 19 of file buf_comp.cpp.

References Botan::store_be().

20 {
21 uint8_t inb[sizeof(val)];
22 store_be(val, inb);
23 add_data(inb, sizeof(inb));
24 }
Botan::store_be
void store_be(uint16_t in, uint8_t out[2])
Definition: loadstor.h:438

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

Definition at line 26 of file buf_comp.cpp.

References Botan::store_be().

27 {
28 uint8_t inb[sizeof(val)];
29 store_be(val, inb);
30 add_data(inb, sizeof(inb));
31 }
Botan::store_be
void store_be(uint16_t in, uint8_t out[2])
Definition: loadstor.h:438

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

Definition at line 33 of file buf_comp.cpp.

References Botan::store_le().

34 {
35 uint8_t inb[sizeof(val)];
36 store_le(val, inb);
37 add_data(inb, sizeof(inb));
38 }
Botan::store_le
void store_le(uint16_t in, uint8_t out[2])
Definition: loadstor.h:454

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

Definition at line 40 of file buf_comp.cpp.

References Botan::store_le().

41 {
42 uint8_t inb[sizeof(val)];
43 store_le(val, inb);
44 add_data(inb, sizeof(inb));
45 }
Botan::store_le
void store_le(uint16_t in, uint8_t out[2])
Definition: loadstor.h:454

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

Definition at line 47 of file buf_comp.cpp.

References Botan::store_le().

48 {
49 uint8_t inb[sizeof(val)];
50 store_le(val, inb);
51 add_data(inb, sizeof(inb));
52 }
Botan::store_le
void store_le(uint16_t in, uint8_t out[2])
Definition: loadstor.h:454

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

- src/lib/hash/sha3/sha3.h