Botan 1.10.17
Botan::Comb4P Class Reference

#include <comb4p.h>

Inheritance diagram for Botan::Comb4P:
Botan::HashFunction Botan::Buffered_Computation Botan::Algorithm

Public Member Functions

void clear ()
HashFunctionclone () const
 Comb4P (HashFunction *h1, HashFunction *h2)
SecureVector< bytefinal ()
void final (byte out[])
size_t hash_block_size () const
std::string name () const
size_t output_length () const
SecureVector< byteprocess (const byte in[], size_t length)
SecureVector< byteprocess (const MemoryRegion< byte > &in)
SecureVector< byteprocess (const std::string &in)
void update (byte in)
void update (const byte in[], size_t length)
void update (const MemoryRegion< byte > &in)
void update (const std::string &str)
template<typename T>
void update_be (const T in)
 ~Comb4P ()

Detailed Description

Combines two hash functions using a Feistel scheme. Described in "On the Security of Hash Function Combiners", Anja Lehmann

Definition at line 19 of file comb4p.h.

Constructor & Destructor Documentation

◆ Comb4P()

Botan::Comb4P::Comb4P ( HashFunction * h1,
HashFunction * h2 )
Parameters
h1the first hash
h2the second hash

Definition at line 37 of file comb4p.cpp.

37 :
38 hash1(h1), hash2(h2)
39 {
40 if(hash1->name() == hash2->name())
41 throw std::invalid_argument("Comb4P: Must use two distinct hashes");
42
43 if(hash1->output_length() != hash2->output_length())
44 throw std::invalid_argument("Comb4P: Incompatible hashes " +
45 hash1->name() + " and " +
46 hash2->name());
47
48 clear();
49 }
void clear()
Definition comb4p.cpp:63

References clear().

Referenced by clone(), and Botan::Core_Engine::find_hash().

◆ ~Comb4P()

Botan::Comb4P::~Comb4P ( )
inline

Definition at line 28 of file comb4p.h.

28{ delete hash1; delete hash2; }

Member Function Documentation

◆ clear()

void Botan::Comb4P::clear ( )
virtual

Zeroize internal state

Implements Botan::Algorithm.

Definition at line 63 of file comb4p.cpp.

64 {
65 hash1->clear();
66 hash2->clear();
67
68 // Prep for processing next message, if any
69 hash1->update(0);
70 hash2->update(0);
71 }

Referenced by Comb4P().

◆ clone()

HashFunction * Botan::Comb4P::clone ( ) const
inlinevirtual

Get a new object representing the same algorithm as *this

Implements Botan::HashFunction.

Definition at line 37 of file comb4p.h.

38 {
39 return new Comb4P(hash1->clone(), hash2->clone());
40 }
Comb4P(HashFunction *h1, HashFunction *h2)
Definition comb4p.cpp:37

References Comb4P().

◆ final() [1/2]

SecureVector< byte > Botan::Buffered_Computation::final ( )
inlineinherited

Complete the computation and retrieve the final result.

Returns
SecureVector holding the result

Definition at line 87 of file buf_comp.h.

88 {
89 SecureVector<byte> output(output_length());
90 final_result(&output[0]);
91 return output;
92 }
virtual size_t output_length() const =0

References output_length().

◆ final() [2/2]

void Botan::Buffered_Computation::final ( byte 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 80 of file buf_comp.h.

80{ final_result(out); }

Referenced by Botan::X942_PRF::derive(), Botan::HandshakeHash::final(), and Botan::HandshakeHash::final_ssl3().

◆ hash_block_size()

size_t Botan::Comb4P::hash_block_size ( ) const
virtual

The hash block size as defined for this algorithm

Reimplemented from Botan::HashFunction.

Definition at line 51 of file comb4p.cpp.

52 {
53 if(hash1->hash_block_size() == hash2->hash_block_size())
54 return hash1->hash_block_size();
55
56 /*
57 * Return LCM of the block sizes? This would probably be OK for
58 * HMAC, which is the main thing relying on knowing the block size.
59 */
60 return 0;
61 }

◆ name()

std::string Botan::Comb4P::name ( ) const
inlinevirtual
Returns
name of this algorithm

Implements Botan::Algorithm.

Definition at line 42 of file comb4p.h.

43 {
44 return "Comb4P(" + hash1->name() + "," + hash2->name() + ")";
45 }

◆ output_length()

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

Implements Botan::Buffered_Computation.

Definition at line 32 of file comb4p.h.

33 {
34 return hash1->output_length() + hash2->output_length();
35 }

◆ process() [1/3]

SecureVector< byte > Botan::Buffered_Computation::process ( const byte 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.

102 {
103 add_data(in, length);
104 return final();
105 }

Referenced by Botan::EME1::EME1(), Botan::RTSS_Share::split(), and Botan::Cert_Extension::Subject_Key_ID::Subject_Key_ID().

◆ process() [2/3]

SecureVector< byte > Botan::Buffered_Computation::process ( const MemoryRegion< byte > & 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 113 of file buf_comp.h.

114 {
115 add_data(&in[0], in.size());
116 return final();
117 }

References Botan::MemoryRegion< T >::size().

◆ process() [3/3]

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

126 {
127 update(in);
128 return final();
129 }
void update(const byte in[], size_t length)
Definition buf_comp.h:33

References update().

◆ update() [1/4]

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

Process a single byte.

Parameters
inthe byte to process

Definition at line 72 of file buf_comp.h.

72{ add_data(&in, 1); }

◆ update() [2/4]

void Botan::Buffered_Computation::update ( const byte 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 33 of file buf_comp.h.

33{ add_data(in, length); }

Referenced by Botan::X942_PRF::derive(), Botan::HandshakeHash::final(), Botan::HandshakeHash::final_ssl3(), process(), and Botan::EAX_Base::start_msg().

◆ update() [3/4]

void Botan::Buffered_Computation::update ( const MemoryRegion< byte > & in)
inlineinherited

Add new input to process.

Parameters
inthe input to process as a MemoryRegion

Definition at line 39 of file buf_comp.h.

40 {
41 add_data(&in[0], in.size());
42 }

References Botan::MemoryRegion< T >::size().

◆ update() [4/4]

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

64 {
65 add_data(reinterpret_cast<const byte*>(str.data()), str.size());
66 }

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

49 {
50 for(size_t i = 0; i != sizeof(T); ++i)
51 {
52 byte b = get_byte(i, in);
53 add_data(&b, 1);
54 }
55 }
byte get_byte(size_t byte_num, T input)
Definition get_byte.h:21

References Botan::get_byte().


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