Botan  1.10.9
Public Member Functions | List of all members
Botan::Skein_512 Class Reference

#include <skein_512.h>

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

Public Member Functions

void clear ()
 
HashFunctionclone () const
 
void final (byte out[])
 
SecureVector< bytefinal ()
 
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)
 
 Skein_512 (size_t output_bits=512, const std::string &personalization="")
 
void update (const byte in[], size_t length)
 
void update (const MemoryRegion< byte > &in)
 
void update (const std::string &str)
 
void update (byte in)
 
template<typename T >
void update_be (const T in)
 

Detailed Description

Skein-512, a SHA-3 candidate

Definition at line 20 of file skein_512.h.

Constructor & Destructor Documentation

Botan::Skein_512::Skein_512 ( size_t  output_bits = 512,
const std::string &  personalization = "" 
)
Parameters
output_bitsthe output size of Skein in bits
personalizationis a string that will paramaterize the hash output

Definition at line 173 of file skein_512.cpp.

Referenced by clone().

174  :
175  personalization(arg_personalization),
176  output_bits(arg_output_bits),
177  H(9), T(3), buffer(64), buf_pos(0)
178  {
179  if(output_bits == 0 || output_bits % 8 != 0 || output_bits > 64*1024)
180  throw Invalid_Argument("Bad output bits size for Skein-512");
181 
182  initial_block(H, T, output_bits, personalization);
183  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20

Member Function Documentation

void Botan::Skein_512::clear ( )
virtual

Zeroize internal state

Implements Botan::Algorithm.

Definition at line 197 of file skein_512.cpp.

References Botan::zeroise().

198  {
199  zeroise(H);
200  zeroise(T);
201  zeroise(buffer);
202  buf_pos = 0;
203  }
void zeroise(MemoryRegion< T > &vec)
Definition: secmem.h:415
HashFunction * Botan::Skein_512::clone ( ) const
virtual

Get a new object representing the same algorithm as *this

Implements Botan::HashFunction.

Definition at line 192 of file skein_512.cpp.

References Skein_512().

193  {
194  return new Skein_512(output_bits, personalization);
195  }
Skein_512(size_t output_bits=512, const std::string &personalization="")
Definition: skein_512.cpp:173
void Botan::Buffered_Computation::final ( byte  out[])
inlineinherited
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
size_t Botan::Skein_512::hash_block_size ( ) const
inlinevirtual

The hash block size as defined for this algorithm

Reimplemented from Botan::HashFunction.

Definition at line 31 of file skein_512.h.

31 { return 64; }
std::string Botan::Skein_512::name ( ) const
virtual
Returns
name of this algorithm

Implements Botan::Algorithm.

Definition at line 185 of file skein_512.cpp.

References Botan::to_string().

186  {
187  if(personalization != "")
188  return "Skein-512(" + to_string(output_bits) + "," + personalization + ")";
189  return "Skein-512(" + to_string(output_bits) + ")";
190  }
std::string to_string(u64bit n, size_t min_len)
Definition: parsing.cpp:42
size_t Botan::Skein_512::output_length ( ) const
inlinevirtual
Returns
length of the output of this function in bytes

Implements Botan::Buffered_Computation.

Definition at line 32 of file skein_512.h.

32 { return output_bits / 8; }
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.

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

102  {
103  add_data(in, length);
104  return final();
105  }
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.

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

114  {
115  add_data(&in[0], in.size());
116  return final();
117  }
size_t size() const
Definition: secmem.h:29
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
void Botan::Buffered_Computation::update ( const byte  in[],
size_t  length 
)
inlineinherited
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.

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

40  {
41  add_data(&in[0], in.size());
42  }
size_t size() const
Definition: secmem.h:29
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  }
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); }
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.

References Botan::get_byte().

Referenced by Botan::KDF2::derive(), Botan::PKCS5_PBKDF2::derive_key(), Botan::Record_Reader::get_record(), and Botan::MGF1::mask().

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
unsigned char byte
Definition: types.h:22

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