Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
Botan::SymmetricAlgorithm Class Referenceabstract

`#include <sym_algo.h>`

Inheritance diagram for Botan::SymmetricAlgorithm:

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

## Constructor & Destructor Documentation

virtual Botan::SymmetricAlgorithm::~SymmetricAlgorithm | ( |  | ) |
| virtual default

## Member Function Documentation

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

Reset the state.

Implemented in Botan::AES_256, Botan::ARIA_256, Botan::AES_192, Botan::GOST_28147_89, Botan::Camellia_256, Botan::GHASH, Botan::ARIA_192, Botan::SIV_Mode, Botan::ChaCha, Botan::OCB_Mode, Botan::FPE_FE1, Botan::ChaCha20Poly1305_Mode, Botan::Camellia_192, Botan::TripleDES, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::SHAKE_128_Cipher, Botan::CCM_Mode, Botan::GCM_Mode, Botan::Blowfish, Botan::Lion, Botan::EAX_Mode, Botan::CFB_Mode, Botan::CTR_BE, Botan::OFB, Botan::XTS_Mode, Botan::CBC_Mode, Botan::ARIA_128, Botan::Cascade_Cipher, Botan::Salsa20, Botan::GMAC, Botan::Threefish_512, Botan::Poly1305, Botan::CMAC, Botan::RC4, Botan::Noekeon, Botan::Serpent, Botan::SHACAL2, Botan::CBC_MAC, Botan::AES_128, Botan::Camellia_128, Botan::CAST_128, Botan::CAST_256, Botan::DES, Botan::DESX, Botan::IDEA, Botan::KASUMI, Botan::MISTY1, Botan::SEED, Botan::SM4, Botan::Twofish, Botan::XTEA, Botan::HMAC, Botan::ANSI_X919_MAC, and Botan::SipHash.

Referenced by botan_block_cipher_clear(), botan_cipher_clear(), botan_mac_clear(), Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::clear(), and Botan::RC4::~RC4().

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

Returns
  object describing limits on key size

Implemented in Botan::Block_Cipher_Fixed_Params< 16, 32 >, Botan::Block_Cipher_Fixed_Params< 8, 1, 56 >, Botan::Block_Cipher_Fixed_Params< 8, 32 >, Botan::Block_Cipher_Fixed_Params< 16, 16 >, Botan::Block_Cipher_Fixed_Params< 8, 11, 16 >, Botan::Block_Cipher_Fixed_Params< 32, 16, 64, 4 >, Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 >, Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 >, Botan::Block_Cipher_Fixed_Params< 16, 4, 32, 4 >, Botan::Block_Cipher_Fixed_Params< 16, 24 >, Botan::Block_Cipher_Fixed_Params< 8, 16 >, Botan::Block_Cipher_Fixed_Params< 8, 8 >, Botan::Block_Cipher_Fixed_Params< 64, 64, 0, 1, Tweakable_Block_Cipher >, Botan::Block_Cipher_Fixed_Params< 8, 24 >, Botan::GHASH, Botan::ChaCha, Botan::SIV_Mode, Botan::FPE_FE1, Botan::OCB_Mode, Botan::SHAKE_128_Cipher, Botan::ChaCha20Poly1305_Mode, Botan::CCM_Mode, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::Lion, Botan::GMAC, Botan::GCM_Mode, Botan::Poly1305, Botan::EAX_Mode, Botan::RC4, Botan::CTR_BE, Botan::OFB, Botan::CFB_Mode, Botan::XTS_Mode, Botan::Salsa20, Botan::CMAC, Botan::HMAC, Botan::ANSI_X919_MAC, Botan::CBC_Mode, Botan::CBC_MAC, Botan::SipHash, and Botan::Cascade_Cipher.

Referenced by botan_cipher_get_keyspec(), botan_cipher_query_keylen(), Botan::CBC_Mode::key_spec(), Botan::CFB_Mode::key_spec(), and Botan::XTS_Mode::key_spec().

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

Returns
  minimum allowed key length

Definition at line 38 of file sym_algo.h.

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

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

Returns
  maximum allowed key length

Definition at line 46 of file sym_algo.h.

Referenced by botan_block_cipher_get_keyspec(), and botan_mac_get_keyspec().

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

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

Returns
  the algorithm name

Implemented in Botan::AES_256, Botan::AES_192, Botan::ARIA_256, Botan::GOST_28147_89, Botan::GHASH, Botan::Camellia_256, Botan::ARIA_192, Botan::ChaCha, Botan::Camellia_192, Botan::TripleDES, Botan::FPE_FE1, Botan::SHAKE_128_Cipher, Botan::SIV_Mode, Botan::Blowfish, Botan::Lion, Botan::OCB_Mode, Botan::ARIA_128, Botan::Cascade_Cipher, Botan::ChaCha20Poly1305_Mode, Botan::CTR_BE, Botan::OFB, Botan::Salsa20, Botan::CCM_Mode, Botan::Threefish_512, Botan::GMAC, Botan::GCM_Mode, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::AES_128, Botan::IDEA, Botan::Serpent, Botan::EAX_Mode, Botan::RC4, Botan::Noekeon, Botan::SHACAL2, Botan::Camellia_128, Botan::CAST_128, Botan::CAST_256, Botan::DES, Botan::DESX, Botan::KASUMI, Botan::MISTY1, Botan::SEED, Botan::SM4, Botan::Twofish, Botan::XTEA, Botan::CBC_Mode, Botan::HMAC, Botan::Poly1305, Botan::ANSI_X919_MAC, Botan::CFB_Mode, Botan::XTS_Mode, Botan::CBC_MAC, Botan::CMAC, and Botan::SipHash.

Referenced by Botan::CBC_Mode::CBC_Mode(), Botan::CFB_Mode::name(), Botan::XTS_Mode::name(), Botan::CBC_Mode::name(), set_key(), Botan::MessageAuthenticationCode::start_msg(), and Botan::XTS_Mode::XTS_Mode().

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

Set the symmetric key of this object.

Parameters

  key | the SymmetricKey to be set.

Definition at line 65 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_cipher_set_key(), botan_mac_set_key(), Botan::Sodium::crypto_stream_salsa20(), Botan::Sodium::crypto_stream_salsa20_xor_ic(), Botan::Sodium::crypto_stream_xsalsa20(), Botan::Sodium::crypto_stream_xsalsa20_xor_ic(), Botan::FPE::fe1_decrypt(), Botan::FPE::fe1_encrypt(), and Botan::Sodium::randombytes_buf_deterministic().

66 {
67 set_key(key.begin(), key.length());
68 }
Botan::SymmetricAlgorithm::set_key
void set_key(const SymmetricKey &key)
Definition: sym_algo.h:65
template<typename Alloc >

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

Definition at line 71 of file sym_algo.h.

72 {
73 set_key(key.data(), key.size());
74 }
Botan::SymmetricAlgorithm::set_key
void set_key(const SymmetricKey &key)
Definition: sym_algo.h:65

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

Set the symmetric key of this object.

Parameters

  key | the to be set as a byte array.
  length | in bytes of key param

Definition at line 17 of file sym_algo.cpp.

References name(), and valid_keylength().

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

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

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

Parameters

  length | the key length to be checked.

Returns
  true if the key length is valid.

Definition at line 56 of file sym_algo.h.

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

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

void Botan::SymmetricAlgorithm::verify_key_set | ( | bool | cond | ) | const
| inline protected

Definition at line 89 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::MISTY1::decrypt_n(), Botan::XTEA::decrypt_n(), Botan::Twofish::decrypt_n(), Botan::KASUMI::decrypt_n(), Botan::AES_128::decrypt_n(), Botan::DESX::decrypt_n(), Botan::SHACAL2::decrypt_n(), Botan::SM4::decrypt_n(), Botan::CAST_128::decrypt_n(), Botan::SEED::decrypt_n(), Botan::CAST_256::decrypt_n(), Botan::Camellia_128::decrypt_n(), Botan::IDEA::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::Noekeon::decrypt_n(), Botan::DES::decrypt_n(), Botan::Serpent::decrypt_n(), Botan::Threefish_512::decrypt_n(), Botan::Lion::decrypt_n(), Botan::ARIA_128::decrypt_n(), Botan::Camellia_192::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::ARIA_192::decrypt_n(), Botan::Camellia_256::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::AES_192::decrypt_n(), Botan::ARIA_256::decrypt_n(), Botan::AES_256::decrypt_n(), Botan::SM4::encrypt_n(), Botan::IDEA::encrypt_n(), Botan::KASUMI::encrypt_n(), Botan::AES_128::encrypt_n(), Botan::MISTY1::encrypt_n(), Botan::Noekeon::encrypt_n(), Botan::CAST_128::encrypt_n(), Botan::SEED::encrypt_n(), Botan::CAST_256::encrypt_n(), Botan::SHACAL2::encrypt_n(), Botan::DES::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::Twofish::encrypt_n(), Botan::Camellia_128::encrypt_n(), Botan::XTEA::encrypt_n(), Botan::DESX::encrypt_n(), Botan::Serpent::encrypt_n(), Botan::Threefish_512::encrypt_n(), Botan::Lion::encrypt_n(), Botan::ARIA_128::encrypt_n(), Botan::Camellia_192::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::ARIA_192::encrypt_n(), Botan::Camellia_256::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::AES_192::encrypt_n(), Botan::ARIA_256::encrypt_n(), Botan::AES_256::encrypt_n(), Botan::OCB_Encryption::finish(), Botan::OCB_Decryption::finish(), Botan::GHASH::ghash_update(), Botan::CFB_Encryption::process(), Botan::CFB_Decryption::process(), Botan::Salsa20::seek(), Botan::CTR_BE::seek(), Botan::ChaCha::seek(), Botan::OCB_Mode::set_associated_data(), Botan::Salsa20::set_iv(), Botan::ChaCha::set_iv(), Botan::GHASH::update(), Botan::GHASH::update_associated_data(), and Botan::ChaCha::write_keystream().

90 {
91 if(cond == false)
92 throw_key_not_set_error();
93 }

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

- src/lib/base/sym_algo.h
- src/lib/base/sym_algo.cpp