Botan 2.1.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 | Protected Member Functions | List of all members
Botan::MDx_HashFunction Class Referenceabstract

`#include <mdx_hash.h>`

Inheritance diagram for Botan::MDx_HashFunction:

## Public Member Functions
virtual HashFunction * | clone () const =0
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
| MDx_HashFunction (size_t block_length, bool big_byte_endian, bool big_bit_endian, size_t counter_size=8)
virtual std::string | name () const =0
virtual size_t | output_length () const =0
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
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 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 std::vector< std::string > | providers (const std::string &algo_spec)

## Protected Member Functions
void | add_data (const uint8_t input[], size_t length) override
void | clear () override
virtual void | compress_n (const uint8_t blocks[], size_t block_n)=0
virtual void | copy_out (uint8_t buffer[])=0
void | final_result (uint8_t output[]) override
virtual void | write_count (uint8_t out[])

## Detailed Description

MDx Hash Function Base Class

Definition at line 18 of file mdx_hash.h.

## Constructor & Destructor Documentation

Botan::MDx_HashFunction::MDx_HashFunction | ( | size_t | block_length,
|  | bool | big_byte_endian,
|  | bool | big_bit_endian,
|  | size_t | counter_size = `8`
| ) |  |

Parameters

  block_length | is the number of bytes per block
  big_byte_endian | specifies if the hash uses big-endian bytes
  big_bit_endian | specifies if the hash uses big-endian bits
  counter_size | specifies the size of the counter var in bytes

Definition at line 17 of file mdx_hash.cpp.

20 :
21 m_buffer(block_len),
22 BIG_BYTE_ENDIAN(byte_end),
23 BIG_BIT_ENDIAN(bit_end),
24 COUNT_SIZE(cnt_size)
25 {
26 m_count = m_position = 0;
27 }

## Member Function Documentation

void Botan::MDx_HashFunction::add_data | ( | const uint8_t | input[],
|  | size_t | length
| ) |  |
| override protected virtual

Add more data to the computation

Parameters

  input | is an input buffer
  length | is the length of input in bytes

Implements Botan::Buffered_Computation.

Definition at line 41 of file mdx_hash.cpp.

References Botan::buffer_insert(), and compress_n().

42 {
43 m_count += length;
44
45 if(m_position)
46 {
47 buffer_insert(m_buffer, m_position, input, length);
48
49 if(m_position + length >= m_buffer.size())
50 {
51 compress_n(m_buffer.data(), 1);
52 input += (m_buffer.size() - m_position);
53 length -= (m_buffer.size() - m_position);
54 m_position = 0;
55 }
56 }
57
58 const size_t full_blocks = length / m_buffer.size();
59 const size_t remaining = length % m_buffer.size();
60
61 if(full_blocks)
62 compress_n(input, full_blocks);
63
64 buffer_insert(m_buffer, m_position, input + full_blocks * m_buffer.size(), remaining);
65 m_position += remaining;
66 }
Botan::MDx_HashFunction::compress_n
virtual void compress_n(const uint8_t blocks[], size_t block_n)=0
Botan::buffer_insert
size_t buffer_insert(std::vector< T, Alloc > &buf, size_t buf_offset, const T input[], size_t input_length)
Definition: secmem.h:133

void Botan::MDx_HashFunction::clear | ( |  | ) |
| override protected virtual

Reset the state.

Implements Botan::HashFunction.

Reimplemented in Botan::SHA_512_256, Botan::SHA_256, Botan::SHA_512, Botan::Tiger, Botan::SHA_224, Botan::RIPEMD_160, Botan::SHA_160, Botan::SHA_384, and Botan::Whirlpool.

Definition at line 32 of file mdx_hash.cpp.

References Botan::zeroise().

Referenced by Botan::MD4::clear(), Botan::MD5::clear(), Botan::RIPEMD_160::clear(), Botan::SHA_384::clear(), Botan::SHA_160::clear(), Botan::Whirlpool::clear(), Botan::SHA_224::clear(), Botan::Tiger::clear(), Botan::SHA_512::clear(), Botan::SHA_256::clear(), Botan::SHA_512_256::clear(), and final_result().

33 {
34 zeroise(m_buffer);
35 m_count = m_position = 0;
36 }
Botan::zeroise
void zeroise(std::vector< T, Alloc > &vec)
Definition: secmem.h:211

virtual HashFunction* Botan::HashFunction::clone | ( |  | ) | const
| pure virtual inherited

Returns
  new object representing the same algorithm as *this

Implemented in Botan::SHA_512_256, Botan::SHAKE_256, Botan::SHA_256, Botan::SHA_512, Botan::Blake2b, Botan::Comb4P, Botan::Skein_512, Botan::Keccak_1600, Botan::SHA_3, Botan::SHAKE_128, Botan::GOST_34_11, Botan::Parallel, Botan::SHA_224, Botan::Tiger, Botan::Adler32, Botan::CRC24, Botan::CRC32, Botan::MD4, Botan::MD5, Botan::RIPEMD_160, Botan::SHA_160, Botan::SHA_384, and Botan::Whirlpool.

virtual void Botan::MDx_HashFunction::compress_n | ( | const uint8_t | blocks[],
|  | size_t | block_n
| ) |  |
| protected pure virtual

Run the hash's compression function over a set of blocks

Parameters

  blocks | the input
  block_n | the number of blocks

Implemented in Botan::MD4, and Botan::MD5.

Referenced by add_data(), and final_result().

virtual void Botan::MDx_HashFunction::copy_out | ( | uint8_t | buffer[] | ) |
| protected pure virtual

Copy the output to the buffer

Parameters

  buffer | to put the output into

Implemented in Botan::MD4, and Botan::MD5.

Referenced by final_result().

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 93 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, and Botan::make_openssl_hash().

Referenced by botan_hash_init(), botan_pubkey_fingerprint(), Botan::OCSP::CertID::CertID(), Botan::BlockCipher::create(), Botan::MessageAuthenticationCode::create(), Botan::PBKDF::create(), Botan::KDF::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::Private_Key::fingerprint(), Botan::X509_Certificate::fingerprint(), Botan::get_eme(), Botan::get_emsa(), Botan::get_hash(), Botan::get_hash_function(), Botan::OCSP::CertID::is_id_for(), Botan::X942_PRF::kdf(), Botan::newhope_shareda(), Botan::newhope_sharedb(), Botan::X509_Certificate::raw_issuer_dn_sha256(), Botan::X509_Certificate::raw_subject_dn_sha256(), and Botan::X509_Certificate::subject_public_key_bitstring_sha1().

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

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 not found.

Definition at line 303 of file hash.cpp.

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

Referenced by Botan::choose_sig_format(), Botan::TLS::Handshake_Hash::final(), Botan::generate_dsa_primes(), and Botan::make_hash_function().

305 {
306 if(auto hash = HashFunction::create(algo, provider))
307 {
308 return hash;
309 }
310 throw Lookup_Error("Hash", algo, provider);
311 }
Botan::HashFunction::provider
virtual std::string provider() const
Definition: hash.h:57
Botan::HashFunction::create
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:93
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

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

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

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

97 {
98 secure_vector<uint8_t> output(output_length());
99 final_result(output.data());
100 return output;
101 }
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 111 of file buf_comp.h.

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

void Botan::MDx_HashFunction::final_result | ( | uint8_t | out[] | ) |
| override protected virtual

Write the final output to out

Parameters

  out | is an output buffer of output_length()

Implements Botan::Buffered_Computation.

Definition at line 71 of file mdx_hash.cpp.

References clear(), compress_n(), copy_out(), write_count(), and Botan::zeroise().

72 {
73 m_buffer[m_position] = (BIG_BIT_ENDIAN ? 0x80 : 0x01);
74 for(size_t i = m_position+1; i != m_buffer.size(); ++i)
75 m_buffer[i] = 0;
76
77 if(m_position >= m_buffer.size() - COUNT_SIZE)
78 {
79 compress_n(m_buffer.data(), 1);
80 zeroise(m_buffer);
81 }
82
83 write_count(&m_buffer[m_buffer.size() - COUNT_SIZE]);
84
85 compress_n(m_buffer.data(), 1);
86 copy_out(output);
87 clear();
88 }
Botan::MDx_HashFunction::clear
void clear() override
Definition: mdx_hash.cpp:32
Botan::MDx_HashFunction::compress_n
virtual void compress_n(const uint8_t blocks[], size_t block_n)=0
Botan::MDx_HashFunction::copy_out
virtual void copy_out(uint8_t buffer[])=0
Botan::MDx_HashFunction::write_count
virtual void write_count(uint8_t out[])
Definition: mdx_hash.cpp:93
Botan::zeroise
void zeroise(std::vector< T, Alloc > &vec)
Definition: secmem.h:211

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

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 }
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0

size_t Botan::MDx_HashFunction::hash_block_size | ( |  | ) | const
| inline override virtual

Returns
  hash block size as defined for this algorithm

Reimplemented from Botan::HashFunction.

Definition at line 32 of file mdx_hash.h.

Referenced by Botan::MD4::compress_n(), Botan::MD5::compress_n(), and write_count().

32 { return m_buffer.size(); }

virtual std::string Botan::HashFunction::name | ( |  | ) | const
| pure virtual inherited

Returns
  the hash function name

Implemented in Botan::SHAKE_256, Botan::SHA_512_256, Botan::SHA_256, Botan::SHA_512, Botan::Comb4P, Botan::Blake2b, Botan::Skein_512, Botan::Keccak_1600, Botan::SHA_3, Botan::SHAKE_128, Botan::Parallel, Botan::GOST_34_11, Botan::SHA_224, Botan::Adler32, Botan::CRC24, Botan::CRC32, Botan::MD4, Botan::MD5, Botan::RIPEMD_160, Botan::SHA_160, Botan::SHA_384, Botan::Tiger, and Botan::Whirlpool.

Referenced by Botan::EMSA_X931::EMSA_X931().

virtual size_t Botan::Buffered_Computation::output_length | ( |  | ) | const
| pure virtual inherited

Returns
  length of the output of this function in bytes

Implemented in Botan::SHA_512_256, Botan::SHAKE_256, Botan::SHA_256, Botan::SHA_512, Botan::Blake2b, Botan::Skein_512, Botan::Keccak_1600, Botan::SHA_3, Botan::SHAKE_128, Botan::Comb4P, Botan::Poly1305, Botan::GMAC, Botan::Parallel, Botan::HMAC, Botan::SipHash, Botan::CBC_MAC, Botan::ANSI_X919_MAC, Botan::GOST_34_11, Botan::SHA_224, Botan::CMAC, Botan::Adler32, Botan::CRC24, Botan::CRC32, Botan::MD4, Botan::MD5, Botan::RIPEMD_160, Botan::SHA_160, Botan::SHA_384, Botan::Tiger, and Botan::Whirlpool.

Referenced by botan_hash_output_length(), botan_mac_output_length(), Botan::pbkdf2(), and write_count().

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

Referenced by Botan::RTSS_Share::split().

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

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

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

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

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

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

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

virtual std::string Botan::HashFunction::provider | ( |  | ) | const
| inline virtual inherited

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

Definition at line 57 of file hash.h.

57 { return "base"; }

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

Referenced by Botan::get_hash_function_providers().

314 {
315 return probe_providers_of<HashFunction>(algo_spec, {"base", "openssl"});
316 }

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

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

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

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

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

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

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

73 {
74 add_data(reinterpret_cast<const uint8_t*>(str.data()), str.size());
75 }

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

Process a single byte.

Parameters

  in | the byte to process

Definition at line 81 of file buf_comp.h.

81 { add_data(&in, 1); }
template<typename T >

void Botan::Buffered_Computation::update_be | ( | const T | in | ) |
| inline inherited

Add an integer in big-endian order

Parameters

  in | the value

Definition at line 58 of file buf_comp.h.

References Botan::get_byte().

Referenced by Botan::mgf1_mask(), and 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 }
Botan::get_byte
uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:47

void Botan::MDx_HashFunction::write_count | ( | uint8_t | out[] | ) |
| protected virtual

Write the count, if used, to this spot

Parameters

  out | where to write the counter to

Definition at line 93 of file mdx_hash.cpp.

References hash_block_size(), Botan::Buffered_Computation::output_length(), Botan::store_be(), and Botan::store_le().

Referenced by final_result().

94 {
95 if(COUNT_SIZE < 8)
96 throw Invalid_State("MDx_HashFunction::write_count: COUNT_SIZE < 8");
97 if(COUNT_SIZE >= output_length() || COUNT_SIZE >= hash_block_size())
98 throw Invalid_Argument("MDx_HashFunction: COUNT_SIZE is too big");
99
100 const uint64_t bit_count = m_count * 8;
101
102 if(BIG_BYTE_ENDIAN)
103 store_be(bit_count, out + COUNT_SIZE - 8);
104 else
105 store_le(bit_count, out + COUNT_SIZE - 8);
106 }
Botan::store_be
void store_be(uint16_t in, uint8_t out[2])
Definition: loadstor.h:441
Botan::MDx_HashFunction::hash_block_size
size_t hash_block_size() const override
Definition: mdx_hash.h:32
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0
Botan::store_le
void store_le(uint16_t in, uint8_t out[2])
Definition: loadstor.h:457

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

- src/lib/hash/mdx_hash/mdx_hash.h
- src/lib/hash/mdx_hash/mdx_hash.cpp