Botan  1.11.15
Public Types | Public Member Functions
Botan::Keccak_1600 Class Reference

#include <keccak.h>

Inheritance diagram for Botan::Keccak_1600:
Botan::HashFunction Botan::Buffered_Computation

List of all members.

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)
size_t hash_block_size () const
 Keccak_1600 (size_t output_bits=512)
std::string name () const
size_t output_length () const
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)

Detailed Description

Keccak[1600], a SHA-3 candidate

Definition at line 20 of file keccak.h.


Member Typedef Documentation

typedef SCAN_Name Botan::HashFunction::Spec [inherited]

Definition at line 37 of file hash.h.


Constructor & Destructor Documentation

Botan::Keccak_1600::Keccak_1600 ( size_t  output_bits = 512)
Parameters:
output_bitsthe size of the hash output; must be one of 224, 256, 384, or 512

Definition at line 105 of file keccak.cpp.

References Botan::ASN1::to_string().

Referenced by clone().

                                           :
   output_bits(output_bits),
   bitrate(1600 - 2*output_bits),
   S(25),
   S_pos(0)
   {
   // We only support the parameters for the SHA-3 proposal

   if(output_bits != 224 && output_bits != 256 &&
      output_bits != 384 && output_bits != 512)
      throw Invalid_Argument("Keccak_1600: Invalid output length " +
                             std::to_string(output_bits));
   }

Member Function Documentation

void Botan::Keccak_1600::clear ( ) [virtual]

Implements Botan::HashFunction.

Definition at line 129 of file keccak.cpp.

References Botan::zeroise().

   {
   zeroise(S);
   S_pos = 0;
   }
HashFunction * Botan::Keccak_1600::clone ( ) const [virtual]
Returns:
new object representing the same algorithm as *this

Implements Botan::HashFunction.

Definition at line 124 of file keccak.cpp.

References Keccak_1600().

   {
   return new Keccak_1600(output_bits);
   }
void Botan::Buffered_Computation::final ( byte  out[]) [inline, inherited]

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().

{ final_result(out); }
secure_vector<byte> Botan::Buffered_Computation::final ( ) [inline, inherited]

Complete the computation and retrieve the final result.

Returns:
secure_vector holding the result

Definition at line 97 of file buf_comp.h.

         {
         secure_vector<byte> output(output_length());
         final_result(&output[0]);
         return output;
         }
template<typename Alloc >
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::Keccak_1600::hash_block_size ( ) const [inline, virtual]
Returns:
hash block size as defined for this algorithm

Reimplemented from Botan::HashFunction.

Definition at line 30 of file keccak.h.

{ return bitrate / 8; }
std::string Botan::Keccak_1600::name ( ) const [virtual]

Implements Botan::HashFunction.

Definition at line 119 of file keccak.cpp.

References Botan::ASN1::to_string().

   {
   return "Keccak-1600(" + std::to_string(output_bits) + ")";
   }
size_t Botan::Keccak_1600::output_length ( ) const [inline, virtual]
Returns:
length of the output of this function in bytes

Implements Botan::Buffered_Computation.

Definition at line 31 of file keccak.h.

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

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::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.

Parameters:
inthe input to process
Returns:
the result of the call to final()

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.

Parameters:
inthe input to process
Returns:
the result of the call to final()

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]

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.

         {
         update(in);
         return final();
         }
void Botan::Buffered_Computation::update ( const byte  in[],
size_t  length 
) [inline, inherited]

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().

{ add_data(in, length); }
void Botan::Buffered_Computation::update ( const secure_vector< byte > &  in) [inline, inherited]

Add new input to process.

Parameters:
inthe 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.

Parameters:
inthe 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.

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.

         {
         add_data(reinterpret_cast<const byte*>(str.data()), str.size());
         }
void Botan::Buffered_Computation::update ( byte  in) [inline, inherited]

Process a single byte.

Parameters:
inthe byte to process

Definition at line 82 of file buf_comp.h.

{ 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:
inthe value

Definition at line 58 of file buf_comp.h.

References Botan::get_byte().

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

         {
         for(size_t i = 0; i != sizeof(T); ++i)
            {
            byte b = get_byte(i, in);
            add_data(&b, 1);
            }
         }

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