Botan  1.11.16
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Botan::Parallel Class Reference

#include <par_hash.h>

Inheritance diagram for Botan::Parallel:
Botan::HashFunction Botan::Buffered_Computation

Public Types

typedef SCAN_Name Spec
 

Public Member Functions

void clear ()
 
HashFunctionclone () const
 
void final (byte out[])
 
secure_vector< bytefinal ()
 
template<typename Alloc >
void final (std::vector< byte, Alloc > &out)
 
virtual size_t hash_block_size () const
 
std::string name () const
 
Paralleloperator= (const Parallel &)=delete
 
size_t output_length () const
 
 Parallel (const std::vector< HashFunction * > &hashes)
 
 Parallel (const Parallel &)=delete
 
secure_vector< byteprocess (const byte in[], size_t length)
 
secure_vector< byteprocess (const secure_vector< byte > &in)
 
secure_vector< byteprocess (const std::vector< byte > &in)
 
secure_vector< byteprocess (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 Parallelmake (const Spec &spec)
 

Detailed Description

Parallel Hashes

Definition at line 19 of file par_hash.h.

Member Typedef Documentation

Definition at line 37 of file hash.h.

Constructor & Destructor Documentation

Botan::Parallel::Parallel ( const std::vector< HashFunction * > &  hashes)
Parameters
hashesa set of hashes to compute in parallel

Definition at line 85 of file par_hash.cpp.

References clone().

86  {
87  for(size_t i = 0; i != in.size(); ++i)
88  {
89  std::unique_ptr<HashFunction> h(in[i]->clone());
90  hashes.push_back(std::move(h));
91  }
92  }
HashFunction * clone() const
Definition: par_hash.cpp:69
Botan::Parallel::Parallel ( const Parallel )
delete

Member Function Documentation

void Botan::Parallel::clear ( )
virtual

Implements Botan::HashFunction.

Definition at line 79 of file par_hash.cpp.

80  {
81  for(auto&& hash : hashes)
82  hash->clear();
83  }
HashFunction * Botan::Parallel::clone ( ) const
virtual
Returns
new object representing the same algorithm as *this

Implements Botan::HashFunction.

Definition at line 69 of file par_hash.cpp.

Referenced by Parallel().

70  {
71  std::vector<HashFunction*> hash_copies;
72 
73  for(auto&& hash : hashes)
74  hash_copies.push_back(hash->clone());
75 
76  return new Parallel(hash_copies);
77  }
Parallel(const std::vector< HashFunction * > &hashes)
Definition: par_hash.cpp:85
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 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().

90 { final_result(out); }
secure_vector<byte> Botan::Buffered_Computation::final ( )
inlineinherited

Complete the computation and retrieve the final result.

Returns
secure_vector holding the result

Definition at line 97 of file buf_comp.h.

98  {
99  secure_vector<byte> output(output_length());
100  final_result(&output[0]);
101  return output;
102  }
virtual size_t output_length() const =0
template<typename Alloc >
void Botan::Buffered_Computation::final ( std::vector< byte, Alloc > &  out)
inlineinherited

Definition at line 105 of file buf_comp.h.

106  {
107  out.resize(output_length());
108  final_result(&out[0]);
109  }
virtual size_t output_length() const =0
virtual size_t Botan::HashFunction::hash_block_size ( ) const
inlinevirtualinherited
Returns
hash block size as defined for this algorithm

Reimplemented in Botan::MDx_HashFunction, Botan::Skein_512, Botan::Keccak_1600, Botan::Comb4P, Botan::GOST_34_11, and Botan::MD2.

Definition at line 35 of file hash.h.

35 { return 0; }
Parallel * Botan::Parallel::make ( const Spec spec)
static

Definition at line 16 of file par_hash.cpp.

References Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), and Botan::get_hash_function().

17  {
18  std::vector<std::unique_ptr<HashFunction>> hashes;
19 
20  for(size_t i = 0; i != spec.arg_count(); ++i)
21  {
22  std::unique_ptr<HashFunction> h(get_hash_function(spec.arg(i)));
23  if(!h)
24  return nullptr;
25  hashes.push_back(std::move(h));
26  }
27 
28  Parallel* p = new Parallel;
29  std::swap(p->hashes, hashes);
30  return p;
31  }
Parallel(const std::vector< HashFunction * > &hashes)
Definition: par_hash.cpp:85
HashFunction * get_hash_function(const std::string &algo_spec, const std::string &provider)
Definition: lookup.cpp:37
std::string Botan::Parallel::name ( ) const
virtual

Implements Botan::HashFunction.

Definition at line 59 of file par_hash.cpp.

References Botan::string_join().

60  {
61  std::vector<std::string> names;
62 
63  for(auto&& hash : hashes)
64  names.push_back(hash->name());
65 
66  return "Parallel(" + string_join(names, ',') + ")";
67  }
std::string string_join(const std::vector< std::string > &strs, char delim)
Definition: parsing.cpp:150
Parallel& Botan::Parallel::operator= ( const Parallel )
delete
size_t Botan::Parallel::output_length ( ) const
virtual
Returns
length of the output of this function in bytes

Implements Botan::Buffered_Computation.

Definition at line 50 of file par_hash.cpp.

51  {
52  size_t sum = 0;
53 
54  for(auto&& hash : hashes)
55  sum += hash->output_length();
56  return sum;
57  }
secure_vector<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 118 of file buf_comp.h.

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

119  {
120  add_data(in, length);
121  return final();
122  }
secure_vector<byte> Botan::Buffered_Computation::process ( const secure_vector< 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 130 of file buf_comp.h.

131  {
132  add_data(&in[0], in.size());
133  return final();
134  }
secure_vector<byte> Botan::Buffered_Computation::process ( const std::vector< 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 142 of file buf_comp.h.

143  {
144  add_data(&in[0], in.size());
145  return final();
146  }
secure_vector<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 154 of file buf_comp.h.

155  {
156  update(in);
157  return final();
158  }
void update(const byte in[], size_t length)
Definition: buf_comp.h:34
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 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().

34 { add_data(in, length); }
void Botan::Buffered_Computation::update ( const secure_vector< byte > &  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[0], in.size());
43  }
void Botan::Buffered_Computation::update ( const std::vector< byte > &  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[0], in.size());
52  }
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 73 of file buf_comp.h.

74  {
75  add_data(reinterpret_cast<const byte*>(str.data()), str.size());
76  }
void Botan::Buffered_Computation::update ( byte  in)
inlineinherited

Process a single byte.

Parameters
inthe byte to process

Definition at line 82 of file buf_comp.h.

82 { add_data(&in, 1); }
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().

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

59  {
60  for(size_t i = 0; i != sizeof(T); ++i)
61  {
62  byte b = get_byte(i, in);
63  add_data(&b, 1);
64  }
65  }
byte get_byte(size_t byte_num, T input)
Definition: get_byte.h:21
uint8_t byte
Definition: types.h:31

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