Botan 3.13.0
Crypto and TLS for C&
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::Polyval Botan::StreamCipher

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
SymmetricAlgorithmoperator= (const SymmetricAlgorithm &other)=default
SymmetricAlgorithmoperator= (SymmetricAlgorithm &&other)=default
void set_key (const OctetString &key)
void set_key (const uint8_t key[], size_t length)
void set_key (std::span< const uint8_t > key)
 SymmetricAlgorithm ()=default
 SymmetricAlgorithm (const SymmetricAlgorithm &other)=default
 SymmetricAlgorithm (SymmetricAlgorithm &&other)=default
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 83 of file sym_algo.h.

Constructor & Destructor Documentation

◆ SymmetricAlgorithm() [1/3]

Botan::SymmetricAlgorithm::SymmetricAlgorithm ( )
default

Default constructor

Referenced by operator=(), operator=(), SymmetricAlgorithm(), and SymmetricAlgorithm().

◆ ~SymmetricAlgorithm()

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

◆ SymmetricAlgorithm() [2/3]

Botan::SymmetricAlgorithm::SymmetricAlgorithm ( const SymmetricAlgorithm & other)
default

Copy constructor

References SymmetricAlgorithm().

◆ SymmetricAlgorithm() [3/3]

Botan::SymmetricAlgorithm::SymmetricAlgorithm ( SymmetricAlgorithm && other)
default

Move constructor

References SymmetricAlgorithm().

Member Function Documentation

◆ assert_key_material_set() [1/2]

◆ assert_key_material_set() [2/2]

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

Throw Key_Not_Set unless the predicate holds

Parameters
predicateif false, a Key_Not_Set exception is thrown

Definition at line 186 of file sym_algo.h.

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

◆ clear()

◆ has_keying_material()

◆ key_spec()

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

Return the key lengths supported by this algorithm

Returns
object describing limits on key size

Implemented in Botan::ANSI_X919_MAC, Botan::Ascon_AEAD128_Mode, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BaseClass >, 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< 32, 16, 64, 4 >, Botan::Block_Cipher_Fixed_Params< 64, 64, 0, 1, Tweakable_Block_Cipher >, Botan::Block_Cipher_Fixed_Params< 8, 1, 72 >, 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, 32 >, Botan::Block_Cipher_Fixed_Params< 8, 8 >, Botan::Cascade_Cipher, Botan::CBC_Mode, Botan::CCM_Mode, Botan::CFB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::ChaCha, Botan::CMAC, Botan::CTR_BE, Botan::EAX_Mode, Botan::FPE_FE1, Botan::GCM_Mode, Botan::GCM_SIV_Mode, Botan::GHASH, Botan::GMAC, Botan::HMAC, Botan::KMAC, Botan::Lion, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::Polyval, Botan::RC4, Botan::Salsa20, Botan::SHAKE_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::TLS::TLS_NULL_HMAC_AEAD_Mode, and Botan::XTS_Mode.

Referenced by Botan::CBC_Mode::key_spec(), Botan::CFB_Mode::key_spec(), Botan::XTS_Mode::key_spec(), maximum_keylength(), minimum_keylength(), and valid_keylength().

◆ maximum_keylength()

size_t Botan::SymmetricAlgorithm::maximum_keylength ( ) const
inline

Return the largest acceptable key length

Returns
maximum allowed key length

Definition at line 130 of file sym_algo.h.

130{ return key_spec().maximum_keylength(); }
size_t maximum_keylength() const
Definition sym_algo.h:58
virtual Key_Length_Specification key_spec() const =0

References key_spec().

◆ minimum_keylength()

size_t Botan::SymmetricAlgorithm::minimum_keylength ( ) const
inline

Return the smallest acceptable key length

Returns
minimum allowed key length

Definition at line 136 of file sym_algo.h.

136{ return key_spec().minimum_keylength(); }
size_t minimum_keylength() const
Definition sym_algo.h:52

References key_spec().

◆ name()

◆ operator=() [1/2]

SymmetricAlgorithm & Botan::SymmetricAlgorithm::operator= ( const SymmetricAlgorithm & other)
default

Copy assignment

Returns
reference to this

References SymmetricAlgorithm().

◆ operator=() [2/2]

SymmetricAlgorithm & Botan::SymmetricAlgorithm::operator= ( SymmetricAlgorithm && other)
default

Move assignment

Returns
reference to this

References SymmetricAlgorithm().

◆ set_key() [1/3]

◆ set_key() [2/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 162 of file sym_algo.h.

162{ set_key(std::span{key, length}); }

References set_key().

Referenced by set_key().

◆ set_key() [3/3]

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

Set the symmetric key of this object.

Parameters
keythe contiguous byte range to be set.

Definition at line 22 of file sym_algo.cpp.

22 {
23 if(!valid_keylength(key.size())) {
24 throw Invalid_Key_Length(name(), key.size());
25 }
26 key_schedule(key);
27}
bool valid_keylength(size_t length) const
Definition sym_algo.h:143
virtual std::string name() const =0

References name(), and valid_keylength().

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

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

References key_spec().

Referenced by set_key().


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