Botan  2.7.0
Crypto and TLS for C++11
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:
Botan::SHA_3 Botan::HashFunction Botan::Buffered_Computation

Public Member Functions

void clear () override
 
HashFunctionclone () const override
 
std::unique_ptr< HashFunctioncopy_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)
 
virtual std::string provider () const
 
 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)
 
template<typename T >
void update_be (const T in)
 

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< HashFunctioncreate (const std::string &algo_spec, const std::string &provider="")
 
static std::unique_ptr< HashFunctioncreate_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 94 of file sha3.h.

Constructor & Destructor Documentation

◆ SHA_3_224()

Botan::SHA_3_224::SHA_3_224 ( )
inline

Definition at line 97 of file sha3.h.

97 : SHA_3(224) {}
SHA_3(size_t output_bits)
Definition: sha3.cpp:181

Member Function Documentation

◆ absorb()

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 
)
staticinherited

Absorb data into the provided state

Parameters
bitratethe bitrate to absorb into the sponge
Sthe sponge state
S_poswhere to begin absorbing into S
inputthe input data
lengthsize of input in bytes

Definition at line 98 of file sha3.cpp.

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

101  {
102  while(length > 0)
103  {
104  size_t to_take = std::min(length, bitrate / 8 - S_pos);
105 
106  length -= to_take;
107 
108  while(to_take && S_pos % 8)
109  {
110  S[S_pos / 8] ^= static_cast<uint64_t>(input[0]) << (8 * (S_pos % 8));
111 
112  ++S_pos;
113  ++input;
114  --to_take;
115  }
116 
117  while(to_take && to_take % 8 == 0)
118  {
119  S[S_pos / 8] ^= load_le<uint64_t>(input, 0);
120  S_pos += 8;
121  input += 8;
122  to_take -= 8;
123  }
124 
125  while(to_take)
126  {
127  S[S_pos / 8] ^= static_cast<uint64_t>(input[0]) << (8 * (S_pos % 8));
128 
129  ++S_pos;
130  ++input;
131  --to_take;
132  }
133 
134  if(S_pos == bitrate / 8)
135  {
136  SHA_3::permute(S.data());
137  S_pos = 0;
138  }
139  }
140 
141  return S_pos;
142  }
uint64_t load_le< uint64_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:235
static void permute(uint64_t A[25])
Definition: sha3.cpp:14

◆ clear()

void Botan::SHA_3::clear ( )
overridevirtualinherited

Reset the state.

Implements Botan::HashFunction.

Definition at line 210 of file sha3.cpp.

References Botan::zeroise().

211  {
212  zeroise(m_S);
213  m_S_pos = 0;
214  }
void zeroise(std::vector< T, Alloc > &vec)
Definition: secmem.h:183

◆ clone()

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

Implements Botan::HashFunction.

Definition at line 205 of file sha3.cpp.

References Botan::SHA_3::SHA_3().

206  {
207  return new SHA_3(m_output_bits);
208  }
SHA_3(size_t output_bits)
Definition: sha3.cpp:181

◆ copy_state()

std::unique_ptr< HashFunction > Botan::SHA_3::copy_state ( ) const
overridevirtualinherited

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

References Botan::SHA_3::SHA_3().

201  {
202  return std::unique_ptr<HashFunction>(new SHA_3(*this));
203  }
SHA_3(size_t output_bits)
Definition: sha3.cpp:181

◆ create()

std::unique_ptr< HashFunction > Botan::HashFunction::create ( const std::string &  algo_spec,
const std::string &  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 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_bearssl_hash(), Botan::make_openssl_hash(), and Botan::HashFunction::provider().

Referenced by botan_hash_init(), botan_pubkey_fingerprint(), Botan::PBKDF::create(), Botan::BlockCipher::create(), Botan::KDF::create(), Botan::MessageAuthenticationCode::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::OCSP::CertID::is_id_for(), Botan::X942_PRF::kdf(), and Botan::X509_Certificate::raw_subject_dn_sha256().

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

◆ create_or_throw()

std::unique_ptr< HashFunction > Botan::HashFunction::create_or_throw ( const std::string &  algo_spec,
const std::string &  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 345 of file hash.cpp.

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

Referenced by botan_pubkey_sm2_compute_za(), Botan::OCSP::CertID::CertID(), Botan::create_hex_fingerprint(), Botan::EMSA_PKCS1v15_Raw::EMSA_PKCS1v15_Raw(), Botan::TLS::Handshake_Hash::final(), Botan::generate_dsa_primes(), Botan::TLS::make_hello_random(), Botan::newhope_shareda(), Botan::newhope_sharedb(), Botan::X509_Certificate::raw_issuer_dn_sha256(), Botan::RTSS_Share::split(), and Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID().

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

◆ expand()

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

Expand from provided state

Parameters
bitratesponge parameter
Sthe state
outputthe output buffer
output_lengththe size of output in bytes

Definition at line 157 of file sha3.cpp.

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

160  {
161  BOTAN_ARG_CHECK(bitrate % 64 == 0, "SHA-3 bitrate must be multiple of 64");
162 
163  const size_t byterate = bitrate / 8;
164 
165  while(output_length > 0)
166  {
167  const size_t copying = std::min(byterate, output_length);
168 
169  copy_out_vec_le(output, copying, S);
170 
171  output += copying;
172  output_length -= copying;
173 
174  if(output_length > 0)
175  {
176  SHA_3::permute(S.data());
177  }
178  }
179  }
size_t output_length() const override
Definition: sha3.h:31
#define BOTAN_ARG_CHECK(expr, msg)
Definition: assert.h:37
static void permute(uint64_t A[25])
Definition: sha3.cpp:14
void copy_out_vec_le(uint8_t out[], size_t out_bytes, const std::vector< T, Alloc > &in)
Definition: loadstor.h:690

◆ final() [1/3]

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

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

89 { final_result(out); }

◆ final() [2/3]

secure_vector<uint8_t> Botan::Buffered_Computation::final ( )
inlineinherited

Complete the computation and retrieve the final result.

Returns
secure_vector holding the result

Definition at line 96 of file buf_comp.h.

97  {
98  secure_vector<uint8_t> output(output_length());
99  final_result(output.data());
100  return output;
101  }
virtual size_t output_length() const =0

◆ final() [3/3]

template<typename Alloc >
void Botan::Buffered_Computation::final ( std::vector< uint8_t, Alloc > &  out)
inlineinherited

Definition at line 111 of file buf_comp.h.

112  {
113  out.resize(output_length());
114  final_result(out.data());
115  }
virtual size_t output_length() const =0

◆ final_stdvec()

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

Definition at line 103 of file buf_comp.h.

104  {
105  std::vector<uint8_t> output(output_length());
106  final_result(output.data());
107  return output;
108  }
virtual size_t output_length() const =0

◆ finish()

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 
)
staticinherited

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

Parameters
bitratethe bitrate to absorb into the sponge
Sthe sponge state
S_poswhere to begin absorbing into S
init_padthe leading pad bits
fini_padthe final pad bits

Definition at line 145 of file sha3.cpp.

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

148  {
149  BOTAN_ARG_CHECK(bitrate % 64 == 0, "SHA-3 bitrate must be multiple of 64");
150 
151  S[S_pos / 8] ^= static_cast<uint64_t>(init_pad) << (8 * (S_pos % 8));
152  S[(bitrate / 64) - 1] ^= static_cast<uint64_t>(fini_pad) << 56;
153  SHA_3::permute(S.data());
154  }
#define BOTAN_ARG_CHECK(expr, msg)
Definition: assert.h:37
static void permute(uint64_t A[25])
Definition: sha3.cpp:14

◆ hash_block_size()

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

Reimplemented from Botan::HashFunction.

Definition at line 30 of file sha3.h.

30 { return m_bitrate / 8; }

◆ name()

std::string Botan::SHA_3::name ( ) const
overridevirtualinherited
Returns
the hash function name

Implements Botan::HashFunction.

Definition at line 195 of file sha3.cpp.

References Botan::ASN1::to_string().

196  {
197  return "SHA-3(" + std::to_string(m_output_bits) + ")";
198  }
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:210

◆ output_length()

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

Implements Botan::Buffered_Computation.

Definition at line 31 of file sha3.h.

Referenced by Botan::SHA_3::expand().

31 { return m_output_bits / 8; }

◆ permute()

void Botan::SHA_3::permute ( uint64_t  A[25])
staticinherited

The bare Keccak-1600 permutation

Definition at line 14 of file sha3.cpp.

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

15  {
16  static const uint64_t RC[24] = {
17  0x0000000000000001, 0x0000000000008082, 0x800000000000808A,
18  0x8000000080008000, 0x000000000000808B, 0x0000000080000001,
19  0x8000000080008081, 0x8000000000008009, 0x000000000000008A,
20  0x0000000000000088, 0x0000000080008009, 0x000000008000000A,
21  0x000000008000808B, 0x800000000000008B, 0x8000000000008089,
22  0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
23  0x000000000000800A, 0x800000008000000A, 0x8000000080008081,
24  0x8000000000008080, 0x0000000080000001, 0x8000000080008008
25  };
26 
27  for(size_t i = 0; i != 24; ++i)
28  {
29  const uint64_t C0 = A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20];
30  const uint64_t C1 = A[1] ^ A[6] ^ A[11] ^ A[16] ^ A[21];
31  const uint64_t C2 = A[2] ^ A[7] ^ A[12] ^ A[17] ^ A[22];
32  const uint64_t C3 = A[3] ^ A[8] ^ A[13] ^ A[18] ^ A[23];
33  const uint64_t C4 = A[4] ^ A[9] ^ A[14] ^ A[19] ^ A[24];
34 
35  const uint64_t D0 = rotl<1>(C0) ^ C3;
36  const uint64_t D1 = rotl<1>(C1) ^ C4;
37  const uint64_t D2 = rotl<1>(C2) ^ C0;
38  const uint64_t D3 = rotl<1>(C3) ^ C1;
39  const uint64_t D4 = rotl<1>(C4) ^ C2;
40 
41  const uint64_t B00 = A[ 0] ^ D1;
42  const uint64_t B10 = rotl< 1>(A[ 1] ^ D2);
43  const uint64_t B20 = rotl<62>(A[ 2] ^ D3);
44  const uint64_t B05 = rotl<28>(A[ 3] ^ D4);
45  const uint64_t B15 = rotl<27>(A[ 4] ^ D0);
46  const uint64_t B16 = rotl<36>(A[ 5] ^ D1);
47  const uint64_t B01 = rotl<44>(A[ 6] ^ D2);
48  const uint64_t B11 = rotl< 6>(A[ 7] ^ D3);
49  const uint64_t B21 = rotl<55>(A[ 8] ^ D4);
50  const uint64_t B06 = rotl<20>(A[ 9] ^ D0);
51  const uint64_t B07 = rotl< 3>(A[10] ^ D1);
52  const uint64_t B17 = rotl<10>(A[11] ^ D2);
53  const uint64_t B02 = rotl<43>(A[12] ^ D3);
54  const uint64_t B12 = rotl<25>(A[13] ^ D4);
55  const uint64_t B22 = rotl<39>(A[14] ^ D0);
56  const uint64_t B23 = rotl<41>(A[15] ^ D1);
57  const uint64_t B08 = rotl<45>(A[16] ^ D2);
58  const uint64_t B18 = rotl<15>(A[17] ^ D3);
59  const uint64_t B03 = rotl<21>(A[18] ^ D4);
60  const uint64_t B13 = rotl< 8>(A[19] ^ D0);
61  const uint64_t B14 = rotl<18>(A[20] ^ D1);
62  const uint64_t B24 = rotl< 2>(A[21] ^ D2);
63  const uint64_t B09 = rotl<61>(A[22] ^ D3);
64  const uint64_t B19 = rotl<56>(A[23] ^ D4);
65  const uint64_t B04 = rotl<14>(A[24] ^ D0);
66 
67  A[ 0] = B00 ^ (~B01 & B02);
68  A[ 1] = B01 ^ (~B02 & B03);
69  A[ 2] = B02 ^ (~B03 & B04);
70  A[ 3] = B03 ^ (~B04 & B00);
71  A[ 4] = B04 ^ (~B00 & B01);
72  A[ 5] = B05 ^ (~B06 & B07);
73  A[ 6] = B06 ^ (~B07 & B08);
74  A[ 7] = B07 ^ (~B08 & B09);
75  A[ 8] = B08 ^ (~B09 & B05);
76  A[ 9] = B09 ^ (~B05 & B06);
77  A[10] = B10 ^ (~B11 & B12);
78  A[11] = B11 ^ (~B12 & B13);
79  A[12] = B12 ^ (~B13 & B14);
80  A[13] = B13 ^ (~B14 & B10);
81  A[14] = B14 ^ (~B10 & B11);
82  A[15] = B15 ^ (~B16 & B17);
83  A[16] = B16 ^ (~B17 & B18);
84  A[17] = B17 ^ (~B18 & B19);
85  A[18] = B18 ^ (~B19 & B15);
86  A[19] = B19 ^ (~B15 & B16);
87  A[20] = B20 ^ (~B21 & B22);
88  A[21] = B21 ^ (~B22 & B23);
89  A[22] = B22 ^ (~B23 & B24);
90  A[23] = B23 ^ (~B24 & B20);
91  A[24] = B24 ^ (~B20 & B21);
92 
93  A[0] ^= RC[i];
94  }
95  }

◆ process() [1/4]

secure_vector<uint8_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 124 of file buf_comp.h.

125  {
126  add_data(in, length);
127  return final();
128  }

◆ process() [2/4]

secure_vector<uint8_t> Botan::Buffered_Computation::process ( const secure_vector< uint8_t > &  in)
inlineinherited

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

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

Definition at line 136 of file buf_comp.h.

137  {
138  add_data(in.data(), in.size());
139  return final();
140  }

◆ process() [3/4]

secure_vector<uint8_t> Botan::Buffered_Computation::process ( const std::vector< uint8_t > &  in)
inlineinherited

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

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

Definition at line 148 of file buf_comp.h.

149  {
150  add_data(in.data(), in.size());
151  return final();
152  }

◆ process() [4/4]

secure_vector<uint8_t> Botan::Buffered_Computation::process ( const std::string &  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 160 of file buf_comp.h.

161  {
162  update(in);
163  return final();
164  }
void update(const uint8_t in[], size_t length)
Definition: buf_comp.h:34

◆ 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.

Definition at line 58 of file hash.h.

Referenced by Botan::HashFunction::create(), and Botan::HashFunction::create_or_throw().

58 { return "base"; }

◆ providers()

std::vector< std::string > Botan::HashFunction::providers ( const std::string &  algo_spec)
staticinherited
Returns
list of available providers for this algorithm, empty if not available
Parameters
algo_specalgorithm name

Definition at line 355 of file hash.cpp.

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

◆ update() [1/5]

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.

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

34 { add_data(in, length); }

◆ update() [2/5]

void Botan::Buffered_Computation::update ( const secure_vector< uint8_t > &  in)
inlineinherited

Add new input to process.

Parameters
inthe input to process as a secure_vector

Definition at line 40 of file buf_comp.h.

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

◆ update() [3/5]

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

Add new input to process.

Parameters
inthe input to process as a std::vector

Definition at line 49 of file buf_comp.h.

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

◆ update() [4/5]

void Botan::Buffered_Computation::update ( const std::string &  str)
inlineinherited

Add new input to process.

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

Definition at line 72 of file buf_comp.h.

References Botan::cast_char_ptr_to_uint8().

73  {
74  add_data(cast_char_ptr_to_uint8(str.data()), str.size());
75  }
const uint8_t * cast_char_ptr_to_uint8(const char *s)
Definition: mem_ops.h:131

◆ update() [5/5]

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

Process a single byte.

Parameters
inthe byte to process

Definition at line 81 of file buf_comp.h.

81 { add_data(&in, 1); }

◆ update_be()

template<typename T >
void Botan::Buffered_Computation::update_be ( const T  in)
inlineinherited

Add an integer in big-endian order

Parameters
inthe value

Definition at line 58 of file buf_comp.h.

References Botan::get_byte(), and T.

Referenced by Botan::pbkdf2().

59  {
60  for(size_t i = 0; i != sizeof(T); ++i)
61  {
62  uint8_t b = get_byte(i, in);
63  add_data(&b, 1);
64  }
65  }
fe T
Definition: ge.cpp:37
uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:39

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