Botan  1.11.15
Public Member Functions
Botan::GHASH Class Reference

#include <gcm.h>

Inheritance diagram for Botan::GHASH:
Botan::SymmetricAlgorithm

List of all members.

Public Member Functions

void clear () override
secure_vector< bytefinal ()
Key_Length_Specification key_spec () const
size_t maximum_keylength () const
size_t minimum_keylength () const
std::string name () const
secure_vector< bytenonce_hash (const byte nonce[], size_t len)
void set_associated_data (const byte ad[], size_t ad_len)
void set_key (const SymmetricKey &key)
template<typename Alloc >
void set_key (const std::vector< byte, Alloc > &key)
void set_key (const byte key[], size_t length)
void start (const byte nonce[], size_t len)
void update (const byte in[], size_t len)
bool valid_keylength (size_t length) const

Detailed Description

GCM's GHASH Maybe a Transform?

Definition at line 108 of file gcm.h.


Member Function Documentation

void Botan::GHASH::clear ( ) [override, virtual]

Implements Botan::SymmetricAlgorithm.

Definition at line 145 of file gcm.cpp.

References Botan::zeroise().

   {
   zeroise(m_H);
   zeroise(m_H_ad);
   m_ghash.clear();
   m_text_len = m_ad_len = 0;
   }
secure_vector< byte > Botan::GHASH::final ( )

Definition at line 122 of file gcm.cpp.

References mac.

   {
   add_final_block(m_ghash, m_ad_len, m_text_len);

   secure_vector<byte> mac;
   mac.swap(m_ghash);

   mac ^= m_nonce;
   m_text_len = 0;
   return mac;
   }
Key_Length_Specification Botan::GHASH::key_spec ( ) const [inline, virtual]
Returns:
object describing limits on key size

Implements Botan::SymmetricAlgorithm.

Definition at line 124 of file gcm.h.

{ return Key_Length_Specification(16); }
size_t Botan::SymmetricAlgorithm::maximum_keylength ( ) const [inline, inherited]
Returns:
minimum allowed key length

Definition at line 36 of file sym_algo.h.

References Botan::Key_Length_Specification::maximum_keylength().

         {
         return key_spec().maximum_keylength();
         }
size_t Botan::SymmetricAlgorithm::minimum_keylength ( ) const [inline, inherited]
Returns:
maxmium allowed key length

Definition at line 44 of file sym_algo.h.

         {
         return key_spec().minimum_keylength();
         }
std::string Botan::GHASH::name ( ) const [inline, virtual]

Implements Botan::SymmetricAlgorithm.

Definition at line 128 of file gcm.h.

{ return "GHASH"; }
secure_vector< byte > Botan::GHASH::nonce_hash ( const byte  nonce[],
size_t  len 
)

Definition at line 134 of file gcm.cpp.

References BOTAN_ASSERT.

   {
   BOTAN_ASSERT(m_ghash.size() == 0, "nonce_hash called during wrong time");
   secure_vector<byte> y0(16);

   ghash_update(y0, nonce, nonce_len);
   add_final_block(y0, 0, nonce_len);

   return y0;
   }
void Botan::GHASH::set_associated_data ( const byte  ad[],
size_t  ad_len 
)

Definition at line 97 of file gcm.cpp.

References Botan::zeroise().

   {
   zeroise(m_H_ad);

   ghash_update(m_H_ad, input, length);
   m_ad_len = length;
   }
void Botan::SymmetricAlgorithm::set_key ( const SymmetricKey key) [inline, inherited]

Set the symmetric key of this object.

Parameters:
keythe SymmetricKey to be set.

Definition at line 63 of file sym_algo.h.

References Botan::OctetString::begin(), and Botan::OctetString::length().

Referenced by Botan::aont_package(), Botan::aont_unpackage(), botan_mac_set_key(), Botan::TLS::Session::decrypt(), Botan::TLS::Session::encrypt(), and Botan::pbkdf2().

         {
         set_key(key.begin(), key.length());
         }
template<typename Alloc >
void Botan::SymmetricAlgorithm::set_key ( const std::vector< byte, Alloc > &  key) [inline, inherited]

Definition at line 69 of file sym_algo.h.

         {
         set_key(&key[0], key.size());
         }
void Botan::SymmetricAlgorithm::set_key ( const byte  key[],
size_t  length 
) [inline, inherited]

Set the symmetric key of this object.

Parameters:
keythe to be set as a byte array.
lengthin bytes of key param

Definition at line 79 of file sym_algo.h.

         {
         if(!valid_keylength(length))
            throw Invalid_Key_Length(name(), length);
         key_schedule(key, length);
         }
void Botan::GHASH::start ( const byte  nonce[],
size_t  len 
)

Definition at line 91 of file gcm.cpp.

   {
   m_nonce.assign(nonce, nonce + len);
   m_ghash = m_H_ad;
   }
void Botan::GHASH::update ( const byte  in[],
size_t  len 
)

Definition at line 105 of file gcm.cpp.

References BOTAN_ASSERT.

   {
   BOTAN_ASSERT(m_ghash.size() == 16, "Key was set");

   m_text_len += length;

   ghash_update(m_ghash, input, length);
   }
bool Botan::SymmetricAlgorithm::valid_keylength ( size_t  length) const [inline, inherited]

Check whether a given key length is valid for this algorithm.

Parameters:
lengththe key length to be checked.
Returns:
true if the key length is valid.

Definition at line 54 of file sym_algo.h.

Referenced by Botan::aont_package(), and Botan::aont_unpackage().

         {
         return key_spec().valid_keylength(length);
         }

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