Botan 3.8.1
Crypto and TLS for C&
|
#include <block_cipher.h>
Public Member Functions | |
virtual size_t | block_size () const =0 |
virtual void | clear ()=0 |
BlockCipher * | clone () const |
void | decrypt (const uint8_t in[], uint8_t out[]) const |
void | decrypt (std::span< const uint8_t > in, std::span< uint8_t > out) const |
void | decrypt (std::span< uint8_t > block) const |
void | decrypt (uint8_t block[]) const |
virtual void | decrypt_n (const uint8_t in[], uint8_t out[], size_t blocks) const =0 |
void | decrypt_n_xex (uint8_t data[], const uint8_t mask[], size_t blocks) const |
void | encrypt (const uint8_t in[], uint8_t out[]) const |
void | encrypt (std::span< const uint8_t > in, std::span< uint8_t > out) const |
void | encrypt (std::span< uint8_t > block) const |
void | encrypt (uint8_t block[]) const |
virtual void | encrypt_n (const uint8_t in[], uint8_t out[], size_t blocks) const =0 |
void | encrypt_n_xex (uint8_t data[], const uint8_t mask[], size_t blocks) const |
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 |
virtual std::unique_ptr< BlockCipher > | new_object () const =0 |
size_t | parallel_bytes () const |
virtual size_t | parallelism () const |
virtual std::string | provider () const |
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) |
bool | valid_keylength (size_t length) const |
~BlockCipher () override=default | |
Static Public Member Functions | |
static std::unique_ptr< BlockCipher > | create (std::string_view algo_spec, std::string_view provider="") |
static std::unique_ptr< BlockCipher > | create_or_throw (std::string_view algo_spec, std::string_view provider="") |
static std::vector< std::string > | providers (std::string_view algo_spec) |
Static Public Attributes | |
static constexpr size_t | ParallelismMult = 4 |
Protected Member Functions | |
void | assert_key_material_set () const |
void | assert_key_material_set (bool predicate) const |
This class represents a block cipher object.
Definition at line 22 of file block_cipher.h.
|
overridedefault |
|
inlineprotectedinherited |
Definition at line 141 of file sym_algo.h.
References assert_key_material_set(), and has_keying_material().
Referenced by assert_key_material_set(), Botan::Salsa20::cipher_bytes(), Botan::Lion::decrypt_n(), Botan::Lion::encrypt_n(), Botan::GHASH::final(), Botan::GHASH::nonce_hash(), Botan::ChaCha::seek(), Botan::CTR_BE::seek(), Botan::Salsa20::seek(), Botan::GHASH::set_associated_data(), Botan::OCB_Mode::set_associated_data_n(), Botan::Salsa20::set_iv_bytes(), Botan::GHASH::update(), and Botan::GHASH::update_associated_data().
|
inlineprotectedinherited |
Definition at line 143 of file sym_algo.h.
|
pure virtual |
Implemented in 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, 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, 32 >, Botan::Block_Cipher_Fixed_Params< 8, 8 >, Botan::Cascade_Cipher, and Botan::Lion.
Referenced by create(), decrypt(), decrypt(), decrypt_n_xex(), encrypt(), encrypt(), encrypt_n_xex(), Botan::nist_key_unwrap(), Botan::nist_key_unwrap_padded(), Botan::nist_key_wrap(), Botan::nist_key_wrap_padded(), parallel_bytes(), and Botan::CBC_Mode::update_granularity().
|
pure virtualinherited |
Reset the internal state. This includes not just the key, but any partial message that may have been in process.
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ANSI_X919_MAC, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::CBC_Mode, Botan::CCM_Mode, Botan::CFB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::ChaCha, Botan::CMAC, Botan::CTR_BE, Botan::DES, Botan::EAX_Mode, Botan::FPE_FE1, Botan::GCM_Mode, Botan::GHASH, Botan::GMAC, Botan::GOST_28147_89, Botan::HMAC, Botan::IDEA, Botan::KMAC, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::RC4, Botan::Salsa20, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SHAKE_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::SM4, Botan::Threefish_512, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::TripleDES, Botan::Twofish, and Botan::XTS_Mode.
Referenced by Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::clear().
|
inline |
Definition at line 188 of file block_cipher.h.
References new_object().
|
static |
Create an instance based on a name If provider is empty then best available is chosen.
algo_spec | algorithm name |
provider | provider implementation to choose |
Definition at line 92 of file block_cipher.cpp.
References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), Botan::SCAN_Name::arg_count_between(), block_size(), BOTAN_UNUSED, create(), Botan::HashFunction::create(), Botan::StreamCipher::create(), Botan::make_commoncrypto_block_cipher(), and provider().
Referenced by botan_block_cipher_init(), Botan::AEAD_Mode::create(), create(), Botan::Cipher_Mode::create(), Botan::MessageAuthenticationCode::create(), Botan::StreamCipher::create(), and create_or_throw().
|
static |
Create an instance based on a name, or throw if the algo/provider combination cannot be found. If provider is empty then best available is chosen.
Definition at line 267 of file block_cipher.cpp.
References create(), and provider().
Referenced by botan_nist_kw_dec(), botan_nist_kw_enc(), Botan::TLS::Connection_Cipher_State::Connection_Cipher_State(), Botan::Encrypted_PSK_Database::Encrypted_PSK_Database(), Botan::rfc3394_keyunwrap(), and Botan::rfc3394_keywrap().
|
inline |
Decrypt a block.
in | The ciphertext block to be decypted as a byte array. Must be of length block_size(). |
out | The byte array designated to hold the decrypted block. Must be of length block_size(). |
Definition at line 91 of file block_cipher.h.
References decrypt_n().
Referenced by Botan::nist_key_unwrap(), and Botan::nist_key_unwrap_padded().
|
inline |
Decrypt one or more blocks
in | the input buffer (multiple of block_size()) |
out | the output buffer (same size as in) |
Definition at line 139 of file block_cipher.h.
References block_size(), and decrypt_n().
|
inline |
Decrypt one or more blocks
block | the input/output buffer (multiple of block_size()) |
Definition at line 121 of file block_cipher.h.
References block_size(), and decrypt_n().
|
inline |
Decrypt a block.
block | the ciphertext block to be decrypted Must be of length block_size(). Will hold the result when the function has finished. |
Definition at line 107 of file block_cipher.h.
References decrypt_n().
|
pure virtual |
Decrypt one or more blocks
in | the input buffer (multiple of block_size()) |
out | the output buffer (same size as in) |
blocks | the number of blocks to process |
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::DES, Botan::GOST_28147_89, Botan::IDEA, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::TripleDES, and Botan::Twofish.
Referenced by decrypt(), decrypt(), decrypt(), decrypt(), and decrypt_n_xex().
|
inline |
Definition at line 172 of file block_cipher.h.
References block_size(), decrypt_n(), and decrypt_n_xex().
Referenced by decrypt_n_xex().
|
inline |
Encrypt a block.
in | The plaintext block to be encrypted as a byte array. Must be of length block_size(). |
out | The byte array designated to hold the encrypted block. Must be of length block_size(). |
Definition at line 82 of file block_cipher.h.
References encrypt_n().
Referenced by Botan::nist_key_wrap(), Botan::nist_key_wrap_padded(), and Botan::CFB_Mode::shift_register().
|
inline |
Encrypt one or more blocks
in | the input buffer (multiple of block_size()) |
out | the output buffer (same size as in) |
Definition at line 130 of file block_cipher.h.
References block_size(), and encrypt_n().
|
inline |
Encrypt one or more blocks
block | the input/output buffer (multiple of block_size()) |
Definition at line 113 of file block_cipher.h.
References block_size(), and encrypt_n().
|
inline |
Encrypt a block.
block | the plaintext block to be encrypted Must be of length block_size(). Will hold the result when the function has finished. |
Definition at line 99 of file block_cipher.h.
References encrypt_n().
|
pure virtual |
Encrypt one or more blocks
in | the input buffer (multiple of block_size()) |
out | the output buffer (same size as in) |
blocks | the number of blocks to process |
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::DES, Botan::GOST_28147_89, Botan::IDEA, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::TripleDES, and Botan::Twofish.
Referenced by encrypt(), encrypt(), encrypt(), encrypt(), and encrypt_n_xex().
|
inline |
Definition at line 160 of file block_cipher.h.
References block_size(), encrypt_n(), and encrypt_n_xex().
Referenced by encrypt_n_xex().
|
pure virtualinherited |
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ANSI_X919_MAC, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::CBC_Mode, Botan::CCM_Mode, Botan::CFB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::ChaCha, Botan::CMAC, Botan::CTR_BE, Botan::DES, Botan::EAX_Mode, Botan::FPE_FE1, Botan::GCM_Mode, Botan::GHASH, Botan::GMAC, Botan::GOST_28147_89, Botan::HMAC, Botan::IDEA, Botan::KMAC, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::RC4, Botan::Salsa20, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SHAKE_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::SM4, Botan::Threefish_512, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::TripleDES, Botan::Twofish, and Botan::XTS_Mode.
Referenced by assert_key_material_set(), and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::has_keying_material().
|
pure virtualinherited |
Implemented in Botan::ANSI_X919_MAC, 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, 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, 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::GHASH, Botan::GMAC, Botan::HMAC, Botan::KMAC, Botan::Lion, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::RC4, Botan::Salsa20, Botan::SHAKE_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::TLS::TLS_CBC_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().
|
inlineinherited |
Definition at line 97 of file sym_algo.h.
References key_spec().
|
inlineinherited |
Definition at line 102 of file sym_algo.h.
References key_spec().
|
pure virtualinherited |
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ANSI_X919_MAC, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::CBC_Mode, Botan::CCM_Mode, Botan::CFB_Mode, Botan::ChaCha20Poly1305_Mode, Botan::ChaCha, Botan::CMAC, Botan::CTR_BE, Botan::DES, Botan::EAX_Mode, Botan::FPE_FE1, Botan::GCM_Mode, Botan::GHASH, Botan::GMAC, Botan::GOST_28147_89, Botan::HMAC, Botan::IDEA, Botan::KMAC128, Botan::KMAC256, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::OCB_Mode, Botan::OFB, Botan::Poly1305, Botan::RC4, Botan::Salsa20, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SHAKE_128_Cipher, Botan::SHAKE_256_Cipher, Botan::SipHash, Botan::SIV_Mode, Botan::SM4, Botan::Threefish_512, Botan::TLS::TLS_CBC_HMAC_AEAD_Mode, Botan::TripleDES, Botan::Twofish, and Botan::XTS_Mode.
Referenced by Botan::XTS_Mode::name(), set_key(), and Botan::MessageAuthenticationCode::start_msg().
|
pure virtual |
Implemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::ARIA_128, Botan::ARIA_192, Botan::ARIA_256, Botan::Blowfish, Botan::Camellia_128, Botan::Camellia_192, Botan::Camellia_256, Botan::Cascade_Cipher, Botan::CAST_128, Botan::DES, Botan::GOST_28147_89, Botan::IDEA, Botan::Kuznyechik, Botan::Lion, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::TripleDES, and Botan::Twofish.
Referenced by clone().
|
inline |
Definition at line 67 of file block_cipher.h.
References block_size(), parallelism(), and ParallelismMult.
Referenced by Botan::CBC_Mode::ideal_granularity().
|
inlinevirtual |
Reimplemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::IDEA, Botan::Noekeon, Botan::Serpent, Botan::SHACAL2, and Botan::SM4.
Definition at line 62 of file block_cipher.h.
Referenced by parallel_bytes().
|
inlinevirtual |
Reimplemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::IDEA, Botan::Noekeon, Botan::Serpent, Botan::SHACAL2, and Botan::SM4.
Definition at line 73 of file block_cipher.h.
Referenced by create(), and create_or_throw().
|
static |
algo_spec | algorithm name |
Definition at line 274 of file block_cipher.cpp.
References Botan::probe_providers_of().
|
inherited |
Set the symmetric key of this object.
key | the SymmetricKey to be set. |
Definition at line 14 of file sym_algo.cpp.
References Botan::OctetString::begin(), Botan::OctetString::length(), and set_key().
Referenced by Botan::create_aes_row_generator(), 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(), Botan::Sphincs_Hash_Functions_Sha2::PRF_msg(), Botan::Sodium::randombytes_buf_deterministic(), and set_key().
|
inlineinherited |
Set the symmetric key of this object.
key | the to be set as a byte array. |
length | in bytes of key param |
Definition at line 128 of file sym_algo.h.
References set_key().
Referenced by set_key().
|
inherited |
Set the symmetric key of this object.
key | the contiguous byte range to be set. |
Definition at line 22 of file sym_algo.cpp.
References name(), and valid_keylength().
|
inlineinherited |
Check whether a given key length is valid for this algorithm.
length | the key length to be checked. |
Definition at line 109 of file sym_algo.h.
References key_spec().
Referenced by set_key().
|
staticconstexpr |
Multiplier on a block cipher's native parallelism
Usually notable performance gains come from further loop blocking, at least for 2 or 4x
Definition at line 52 of file block_cipher.h.
Referenced by Botan::GCM_Mode::ideal_granularity(), and parallel_bytes().