Botan 3.0.0
Crypto and TLS for C&
Public Member Functions | Protected Member Functions | List of all members
Botan::SymmetricAlgorithm Class Referenceabstract

#include <sym_algo.h>

Inheritance diagram for Botan::SymmetricAlgorithm:
Botan::BLAKE2b Botan::BlockCipher Botan::Cipher_Mode Botan::FPE_FE1 Botan::GHASH Botan::MessageAuthenticationCode Botan::StreamCipher Botan::Block_Cipher_Fixed_Params< 16, 16 > Botan::Block_Cipher_Fixed_Params< 16, 24 > Botan::Block_Cipher_Fixed_Params< 16, 32 > Botan::Block_Cipher_Fixed_Params< 8, 1, 56 > Botan::Block_Cipher_Fixed_Params< 8, 11, 16 > Botan::Block_Cipher_Fixed_Params< 8, 8 > Botan::Block_Cipher_Fixed_Params< 8, 32 > Botan::Block_Cipher_Fixed_Params< 8, 16 > Botan::Block_Cipher_Fixed_Params< 32, 16, 64, 4 > Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 > Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 > Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BaseClass > Botan::Cascade_Cipher Botan::Lion Botan::Tweakable_Block_Cipher Botan::AEAD_Mode Botan::CBC_Mode Botan::CFB_Mode Botan::XTS_Mode Botan::ANSI_X919_MAC Botan::BLAKE2bMAC Botan::CMAC Botan::GMAC Botan::HMAC Botan::Poly1305 Botan::SipHash Botan::CTR_BE Botan::ChaCha Botan::OFB Botan::RC4 Botan::SHAKE_Cipher Botan::Salsa20

Public Member Functions

virtual void clear ()=0
 
virtual bool has_keying_material () const =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)
 
void set_key (const uint8_t key[], size_t length)
 
void set_key (std::span< const uint8_t > key)
 
bool valid_keylength (size_t length) const
 
virtual ~SymmetricAlgorithm ()=default
 

Protected Member Functions

void assert_key_material_set () const
 
void assert_key_material_set (bool predicate) const
 

Detailed Description

This class represents a symmetric algorithm object.

Definition at line 104 of file sym_algo.h.

Constructor & Destructor Documentation

◆ ~SymmetricAlgorithm()

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

Member Function Documentation

◆ assert_key_material_set() [1/2]

void Botan::SymmetricAlgorithm::assert_key_material_set ( ) const
inlineprotected

Definition at line 182 of file sym_algo.h.

183 {
185 }
virtual bool has_keying_material() const =0
void assert_key_material_set() const
Definition: sym_algo.h:182

Referenced by Botan::Salsa20::cipher_bytes(), Botan::AES_128::decrypt_n(), Botan::AES_192::decrypt_n(), Botan::AES_256::decrypt_n(), Botan::ARIA_128::decrypt_n(), Botan::ARIA_192::decrypt_n(), Botan::ARIA_256::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::Camellia_128::decrypt_n(), Botan::Camellia_192::decrypt_n(), Botan::Camellia_256::decrypt_n(), Botan::CAST_128::decrypt_n(), Botan::DES::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::IDEA::decrypt_n(), Botan::Lion::decrypt_n(), Botan::Noekeon::decrypt_n(), Botan::SEED::decrypt_n(), Botan::Serpent::decrypt_n(), Botan::SHACAL2::decrypt_n(), Botan::SM4::decrypt_n(), Botan::Threefish_512::decrypt_n(), Botan::Twofish::decrypt_n(), Botan::AES_128::encrypt_n(), Botan::AES_192::encrypt_n(), Botan::AES_256::encrypt_n(), Botan::ARIA_128::encrypt_n(), Botan::ARIA_192::encrypt_n(), Botan::ARIA_256::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::Camellia_128::encrypt_n(), Botan::Camellia_192::encrypt_n(), Botan::Camellia_256::encrypt_n(), Botan::CAST_128::encrypt_n(), Botan::DES::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::IDEA::encrypt_n(), Botan::Lion::encrypt_n(), Botan::Noekeon::encrypt_n(), Botan::SEED::encrypt_n(), Botan::Serpent::encrypt_n(), Botan::SHACAL2::encrypt_n(), Botan::SM4::encrypt_n(), Botan::Threefish_512::encrypt_n(), Botan::Twofish::encrypt_n(), Botan::GHASH::final(), Botan::GHASH::ghash_update(), Botan::ChaCha::seek(), Botan::CTR_BE::seek(), Botan::Salsa20::seek(), Botan::OCB_Mode::set_associated_data_n(), Botan::Salsa20::set_iv_bytes(), Botan::GHASH::update(), and Botan::GHASH::update_associated_data().

◆ assert_key_material_set() [2/2]

void Botan::SymmetricAlgorithm::assert_key_material_set ( bool  predicate) const
inlineprotected

Definition at line 187 of file sym_algo.h.

188 {
189 if(!predicate)
190 throw_key_not_set_error();
191 }

◆ clear()

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

◆ has_keying_material()

virtual bool Botan::SymmetricAlgorithm::has_keying_material ( ) const
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
maximum allowed key length

Definition at line 123 of file sym_algo.h.

124 {
125 return key_spec().maximum_keylength();
126 }
size_t maximum_keylength() const
Definition: sym_algo.h:72
virtual Key_Length_Specification key_spec() const =0

◆ minimum_keylength()

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

Definition at line 131 of file sym_algo.h.

132 {
133 return key_spec().minimum_keylength();
134 }
size_t minimum_keylength() const
Definition: sym_algo.h:64

◆ name()

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

◆ set_key() [1/3]

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

◆ set_key() [2/3]

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

Set the symmetric key of this object.

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

Definition at line 17 of file sym_algo.cpp.

18 {
19 if(!valid_keylength(length))
20 throw Invalid_Key_Length(name(), length);
21 key_schedule(key, length);
22 }
bool valid_keylength(size_t length) const
Definition: sym_algo.h:141
virtual std::string name() const =0

References name(), and valid_keylength().

◆ set_key() [3/3]

void Botan::SymmetricAlgorithm::set_key ( std::span< const uint8_t >  key)
inline

Set the symmetric key of this object.

Parameters
keythe contiguous byte range to be set.

Definition at line 159 of file sym_algo.h.

160 {
161 set_key(key.data(), key.size());
162 }

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

142 {
143 return key_spec().valid_keylength(length);
144 }
bool valid_keylength(size_t length) const
Definition: sym_algo.h:54

Referenced by set_key().


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