|
Botan
1.11.15
|
#include <comb4p.h>
Public Types | |
| typedef SCAN_Name | Spec |
Public Member Functions | |
| void | clear () |
| HashFunction * | clone () const |
| Comb4P (HashFunction *h1, HashFunction *h2) | |
| void | final (byte out[]) |
| secure_vector< byte > | final () |
| template<typename Alloc > | |
| void | final (std::vector< byte, Alloc > &out) |
| size_t | hash_block_size () const |
| std::string | name () const |
| size_t | output_length () const |
| secure_vector< byte > | process (const byte in[], size_t length) |
| secure_vector< byte > | process (const secure_vector< byte > &in) |
| secure_vector< byte > | process (const std::vector< byte > &in) |
| secure_vector< byte > | process (const std::string &in) |
| void | update (const byte in[], size_t length) |
| void | update (const secure_vector< byte > &in) |
| void | update (const std::vector< byte > &in) |
| void | update (const std::string &str) |
| void | update (byte in) |
| template<typename T > | |
| void | update_be (const T in) |
Static Public Member Functions | |
| static Comb4P * | make (const Spec &spec) |
Combines two hash functions using a Feistel scheme. Described in "On the Security of Hash Function Combiners", Anja Lehmann
typedef SCAN_Name Botan::HashFunction::Spec [inherited] |
| Botan::Comb4P::Comb4P | ( | HashFunction * | h1, |
| HashFunction * | h2 | ||
| ) |
| h1 | the first hash |
| h2 | the second hash |
Definition at line 54 of file comb4p.cpp.
References clear().
Referenced by make().
:
m_hash1(h1), m_hash2(h2)
{
if(m_hash1->name() == m_hash2->name())
throw std::invalid_argument("Comb4P: Must use two distinct hashes");
if(m_hash1->output_length() != m_hash2->output_length())
throw std::invalid_argument("Comb4P: Incompatible hashes " +
m_hash1->name() + " and " +
m_hash2->name());
clear();
}
| void Botan::Comb4P::clear | ( | ) | [virtual] |
Implements Botan::HashFunction.
Definition at line 80 of file comb4p.cpp.
Referenced by Comb4P().
{
m_hash1->clear();
m_hash2->clear();
// Prep for processing next message, if any
m_hash1->update(0);
m_hash2->update(0);
}
| HashFunction* Botan::Comb4P::clone | ( | ) | const [inline, virtual] |
Implements Botan::HashFunction.
Definition at line 37 of file comb4p.h.
{
return new Comb4P(m_hash1->clone(), m_hash2->clone());
}
| void Botan::Buffered_Computation::final | ( | byte | out[] | ) | [inline, inherited] |
Complete the computation and retrieve the final result.
| out | The byte array to be filled with the result. Must be of length output_length() |
Definition at line 90 of file buf_comp.h.
Referenced by botan_hash_final(), botan_mac_final(), Botan::McEliece_KEM_Decryptor::decrypt(), Botan::TLS::Session::decrypt(), Botan::McEliece_KEM_Encryptor::encrypt(), Botan::TLS::Session::encrypt(), Botan::mgf1_mask(), Botan::pbkdf2(), and Botan::TLS::write_record().
{ final_result(out); }
| secure_vector<byte> Botan::Buffered_Computation::final | ( | ) | [inline, inherited] |
Complete the computation and retrieve the final result.
Definition at line 97 of file buf_comp.h.
{
secure_vector<byte> output(output_length());
final_result(&output[0]);
return output;
}
| void Botan::Buffered_Computation::final | ( | std::vector< byte, Alloc > & | out | ) | [inline, inherited] |
Definition at line 105 of file buf_comp.h.
{
out.resize(output_length());
final_result(&out[0]);
}
| size_t Botan::Comb4P::hash_block_size | ( | ) | const [virtual] |
Reimplemented from Botan::HashFunction.
Definition at line 68 of file comb4p.cpp.
{
if(m_hash1->hash_block_size() == m_hash2->hash_block_size())
return m_hash1->hash_block_size();
/*
* Return LCM of the block sizes? This would probably be OK for
* HMAC, which is the main thing relying on knowing the block size.
*/
return 0;
}
| Comb4P * Botan::Comb4P::make | ( | const Spec & | spec | ) | [static] |
Definition at line 40 of file comb4p.cpp.
References Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), and Comb4P().
{
if(spec.arg_count() == 2)
{
auto& hashes = Algo_Registry<HashFunction>::global_registry();
std::unique_ptr<HashFunction> h1(hashes.make(spec.arg(0)));
std::unique_ptr<HashFunction> h2(hashes.make(spec.arg(1)));
if(h1 && h2)
return new Comb4P(h1.release(), h2.release());
}
return nullptr;
}
| std::string Botan::Comb4P::name | ( | ) | const [inline, virtual] |
Implements Botan::HashFunction.
Definition at line 42 of file comb4p.h.
References name().
Referenced by name().
{
return "Comb4P(" + m_hash1->name() + "," + m_hash2->name() + ")";
}
| size_t Botan::Comb4P::output_length | ( | ) | const [inline, virtual] |
Implements Botan::Buffered_Computation.
Definition at line 30 of file comb4p.h.
{
return m_hash1->output_length() + m_hash2->output_length();
}
| secure_vector<byte> Botan::Buffered_Computation::process | ( | const byte | in[], |
| size_t | length | ||
| ) | [inline, inherited] |
Update and finalize computation. Does the same as calling update() and final() consecutively.
| in | the input to process as a byte array |
| length | the length of the byte array |
Definition at line 118 of file buf_comp.h.
Referenced by Botan::HMAC_RNG::HMAC_RNG(), Botan::RTSS_Share::split(), and Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID().
{
add_data(in, length);
return final();
}
| secure_vector<byte> Botan::Buffered_Computation::process | ( | const secure_vector< byte > & | in | ) | [inline, inherited] |
Update and finalize computation. Does the same as calling update() and final() consecutively.
| in | the input to process |
Definition at line 130 of file buf_comp.h.
{
add_data(&in[0], in.size());
return final();
}
| secure_vector<byte> Botan::Buffered_Computation::process | ( | const std::vector< byte > & | in | ) | [inline, inherited] |
Update and finalize computation. Does the same as calling update() and final() consecutively.
| in | the input to process |
Definition at line 142 of file buf_comp.h.
{
add_data(&in[0], in.size());
return final();
}
| secure_vector<byte> Botan::Buffered_Computation::process | ( | const std::string & | in | ) | [inline, inherited] |
| void Botan::Buffered_Computation::update | ( | const byte | in[], |
| size_t | length | ||
| ) | [inline, inherited] |
Add new input to process.
| 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::McEliece_KEM_Decryptor::decrypt(), Botan::TLS::Session::decrypt(), Botan::McEliece_KEM_Encryptor::encrypt(), Botan::TLS::Session::encrypt(), Botan::mgf1_mask(), Botan::pbkdf2(), and Botan::TLS::write_record().
{ add_data(in, length); }
| void Botan::Buffered_Computation::update | ( | const secure_vector< byte > & | in | ) | [inline, inherited] |
Add new input to process.
| in | the input to process as a secure_vector |
Definition at line 40 of file buf_comp.h.
{
add_data(&in[0], in.size());
}
| void Botan::Buffered_Computation::update | ( | const std::vector< byte > & | in | ) | [inline, inherited] |
Add new input to process.
| in | the input to process as a std::vector |
Definition at line 49 of file buf_comp.h.
{
add_data(&in[0], in.size());
}
| void Botan::Buffered_Computation::update | ( | const std::string & | str | ) | [inline, inherited] |
Add new input to process.
| str | the input to process as a std::string. Will be interpreted as a byte array based on the strings encoding. |
Definition at line 73 of file buf_comp.h.
{
add_data(reinterpret_cast<const byte*>(str.data()), str.size());
}
| void Botan::Buffered_Computation::update | ( | byte | in | ) | [inline, inherited] |
Process a single byte.
| in | the byte to process |
Definition at line 82 of file buf_comp.h.
{ add_data(&in, 1); }
| void Botan::Buffered_Computation::update_be | ( | const T | in | ) | [inline, inherited] |
Add an integer in big-endian order
| in | the value |
Definition at line 58 of file buf_comp.h.
References Botan::get_byte().
Referenced by Botan::mgf1_mask(), and Botan::pbkdf2().
1.7.6.1