Botan  2.4.0
Crypto and TLS for C++11
Public Member Functions | Protected Member Functions | List of all members
Botan::SymmetricAlgorithm Class Referenceabstract

#include <sym_algo.h>

Inheritance diagram for Botan::SymmetricAlgorithm:
Botan::BlockCipher Botan::GHASH Botan::MessageAuthenticationCode Botan::StreamCipher Botan::Block_Cipher_Fixed_Params< 16, 16 > Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 > Botan::Block_Cipher_Fixed_Params< 16, 24 > Botan::Block_Cipher_Fixed_Params< 16, 32 > Botan::Block_Cipher_Fixed_Params< 16, 4, 32, 4 > Botan::Block_Cipher_Fixed_Params< 32, 16, 64, 4 > Botan::Block_Cipher_Fixed_Params< 64, 64 > Botan::Block_Cipher_Fixed_Params< 8, 1, 56 > Botan::Block_Cipher_Fixed_Params< 8, 11, 16 > Botan::Block_Cipher_Fixed_Params< 8, 16 > Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 > Botan::Block_Cipher_Fixed_Params< 8, 24 > Botan::Block_Cipher_Fixed_Params< 8, 32 > Botan::Block_Cipher_Fixed_Params< 8, 8 > Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD > Botan::Cascade_Cipher Botan::Lion Botan::ANSI_X919_MAC Botan::CBC_MAC Botan::CMAC Botan::GMAC Botan::HMAC Botan::Poly1305 Botan::SipHash Botan::ChaCha Botan::CTR_BE Botan::OFB Botan::RC4 Botan::Salsa20 Botan::SHAKE_128_Cipher

Public Member Functions

virtual void clear ()=0
 
virtual Key_Length_Specification key_spec () const =0
 
size_t maximum_keylength () const
 
size_t minimum_keylength () const
 
virtual std::string name () const =0
 
void set_key (const SymmetricKey &key)
 
template<typename Alloc >
void set_key (const std::vector< uint8_t, Alloc > &key)
 
void set_key (const uint8_t key[], size_t length)
 
bool valid_keylength (size_t length) const
 
virtual ~SymmetricAlgorithm ()=default
 

Protected Member Functions

void verify_key_set (bool cond) const
 

Detailed Description

This class represents a symmetric algorithm object.

Definition at line 21 of file sym_algo.h.

Constructor & Destructor Documentation

◆ ~SymmetricAlgorithm()

virtual Botan::SymmetricAlgorithm::~SymmetricAlgorithm ( )
virtualdefault

Member Function Documentation

◆ clear()

virtual void Botan::SymmetricAlgorithm::clear ( )
pure virtual

◆ key_spec()

virtual Key_Length_Specification Botan::SymmetricAlgorithm::key_spec ( ) const
pure virtual

◆ maximum_keylength()

size_t Botan::SymmetricAlgorithm::maximum_keylength ( ) const
inline
Returns
minimum allowed key length

Definition at line 39 of file sym_algo.h.

40  {
41  return key_spec().maximum_keylength();
42  }
size_t maximum_keylength() const
Definition: key_spec.h:69
virtual Key_Length_Specification key_spec() const =0

◆ minimum_keylength()

size_t Botan::SymmetricAlgorithm::minimum_keylength ( ) const
inline
Returns
maximum allowed key length

Definition at line 47 of file sym_algo.h.

48  {
49  return key_spec().minimum_keylength();
50  }
virtual Key_Length_Specification key_spec() const =0
size_t minimum_keylength() const
Definition: key_spec.h:61

◆ name()

virtual std::string Botan::SymmetricAlgorithm::name ( ) const
pure virtual

◆ set_key() [1/3]

void Botan::SymmetricAlgorithm::set_key ( const SymmetricKey key)
inline

Set the symmetric key of this object.

Parameters
keythe SymmetricKey to be set.

Definition at line 66 of file sym_algo.h.

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

Referenced by Botan::aont_package(), Botan::aont_unpackage(), botan_block_cipher_set_key(), botan_mac_set_key(), Botan::GOST_34_11::copy_state(), Botan::DESX::decrypt_n(), Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::key_spec(), Botan::pbkdf2(), and Botan::TLS_PRF::TLS_PRF().

67  {
68  set_key(key.begin(), key.length());
69  }
void set_key(const SymmetricKey &key)
Definition: sym_algo.h:66

◆ set_key() [2/3]

template<typename Alloc >
void Botan::SymmetricAlgorithm::set_key ( const std::vector< uint8_t, Alloc > &  key)
inline

Definition at line 72 of file sym_algo.h.

73  {
74  set_key(key.data(), key.size());
75  }
void set_key(const SymmetricKey &key)
Definition: sym_algo.h:66

◆ set_key() [3/3]

void Botan::SymmetricAlgorithm::set_key ( const uint8_t  key[],
size_t  length 
)
inline

Set the symmetric key of this object.

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

Definition at line 82 of file sym_algo.h.

83  {
84  if(!valid_keylength(length))
85  throw Invalid_Key_Length(name(), length);
86  key_schedule(key, length);
87  }
bool valid_keylength(size_t length) const
Definition: sym_algo.h:57
virtual std::string name() const =0

◆ valid_keylength()

bool Botan::SymmetricAlgorithm::valid_keylength ( size_t  length) const
inline

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 57 of file sym_algo.h.

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

58  {
59  return key_spec().valid_keylength(length);
60  }
bool valid_keylength(size_t length) const
Definition: key_spec.h:51
virtual Key_Length_Specification key_spec() const =0

◆ verify_key_set()

void Botan::SymmetricAlgorithm::verify_key_set ( bool  cond) const
inlineprotected

Definition at line 95 of file sym_algo.h.

Referenced by Botan::Salsa20::cipher(), Botan::CTR_BE::cipher(), Botan::RC4::cipher(), Botan::SHAKE_128_Cipher::cipher(), Botan::ChaCha::cipher(), Botan::Poly1305::clear(), Botan::Noekeon::decrypt_n(), Botan::CAST_128::decrypt_n(), Botan::Threefish_512::decrypt_n(), Botan::KASUMI::decrypt_n(), Botan::MISTY1::decrypt_n(), Botan::CAST_256::decrypt_n(), Botan::DESX::decrypt_n(), Botan::SEED::decrypt_n(), Botan::SHACAL2::decrypt_n(), Botan::IDEA::decrypt_n(), Botan::SM4::decrypt_n(), Botan::DES::decrypt_n(), Botan::Twofish::decrypt_n(), Botan::XTEA::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::Serpent::decrypt_n(), Botan::Lion::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::CAST_128::encrypt_n(), Botan::Noekeon::encrypt_n(), Botan::XTEA::encrypt_n(), Botan::MISTY1::encrypt_n(), Botan::Twofish::encrypt_n(), Botan::SHACAL2::encrypt_n(), Botan::SEED::encrypt_n(), Botan::SM4::encrypt_n(), Botan::DES::encrypt_n(), Botan::CAST_256::encrypt_n(), Botan::DESX::encrypt_n(), Botan::IDEA::encrypt_n(), Botan::Threefish_512::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::KASUMI::encrypt_n(), Botan::Serpent::encrypt_n(), Botan::Lion::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::Salsa20::seek(), Botan::CTR_BE::seek(), Botan::ChaCha::seek(), and Botan::GHASH::update_associated_data().

96  {
97  if(cond == false)
98  throw Key_Not_Set(name());
99  }
virtual std::string name() const =0

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