Botan 3.0.0-alpha0
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 |
template<typename Alloc , typename Alloc2 > | |
void | decrypt (const std::vector< uint8_t, Alloc > &in, std::vector< uint8_t, Alloc2 > &out) const |
void | decrypt (const uint8_t in[], uint8_t out[]) const |
template<typename Alloc > | |
void | decrypt (std::vector< uint8_t, Alloc > &block) const |
void | decrypt (uint8_t block[]) const |
virtual void | decrypt_n (const uint8_t in[], uint8_t out[], size_t blocks) const =0 |
virtual void | decrypt_n_xex (uint8_t data[], const uint8_t mask[], size_t blocks) const |
template<typename Alloc , typename Alloc2 > | |
void | encrypt (const std::vector< uint8_t, Alloc > &in, std::vector< uint8_t, Alloc2 > &out) const |
void | encrypt (const uint8_t in[], uint8_t out[]) const |
template<typename Alloc > | |
void | encrypt (std::vector< uint8_t, Alloc > &block) const |
void | encrypt (uint8_t block[]) const |
virtual void | encrypt_n (const uint8_t in[], uint8_t out[], size_t blocks) const =0 |
virtual void | encrypt_n_xex (uint8_t data[], const uint8_t mask[], size_t blocks) const |
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 |
template<typename Alloc > | |
void | set_key (const std::vector< uint8_t, Alloc > &key) |
void | set_key (const SymmetricKey &key) |
void | set_key (const uint8_t key[], size_t length) |
virtual void | set_tweak (const uint8_t tweak[], size_t len)=0 |
bool | valid_keylength (size_t length) const |
Static Public Member Functions | |
static std::unique_ptr< BlockCipher > | create (const std::string &algo_spec, const std::string &provider="") |
static std::unique_ptr< BlockCipher > | create_or_throw (const std::string &algo_spec, const std::string &provider="") |
static std::vector< std::string > | providers (const std::string &algo_spec) |
Protected Member Functions | |
void | verify_key_set (bool cond) const |
Tweakable block ciphers allow setting a tweak which is a non-keyed value which affects the encryption/decryption operation.
Definition at line 210 of file block_cipher.h.
|
pure virtualinherited |
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, 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< 64, 64, 0, 1, Tweakable_Block_Cipher >, Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 >, Botan::Cascade_Cipher, and Botan::Lion.
Referenced by Botan::BlockCipher::create(), Botan::nist_key_unwrap(), Botan::nist_key_unwrap_padded(), Botan::nist_key_wrap(), and Botan::nist_key_wrap_padded().
|
pure virtualinherited |
Reset the state.
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::TripleDES, Botan::GOST_28147_89, Botan::IDEA, Botan::Lion, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::Twofish, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::Poly1305, Botan::SipHash, Botan::ANSI_X919_MAC, Botan::FPE_FE1, Botan::CCM_Mode, Botan::ChaCha20Poly1305_Mode, Botan::EAX_Mode, Botan::GCM_Mode, Botan::OCB_Mode, Botan::SIV_Mode, Botan::CBC_Mode, Botan::XTS_Mode, Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, Botan::SHAKE_128_Cipher, Botan::GHASH, Botan::CFB_Mode, and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode.
Referenced by botan_cipher_clear(), botan_mac_clear(), and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::clear().
|
inlineinherited |
Definition at line 198 of file block_cipher.h.
|
staticinherited |
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 87 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(), Botan::BlockCipher::block_size(), BOTAN_UNUSED, Botan::BlockCipher::create(), Botan::HashFunction::create(), Botan::StreamCipher::create(), hash, Botan::make_commoncrypto_block_cipher(), and Botan::BlockCipher::provider().
Referenced by botan_block_cipher_init(), Botan::AEAD_Mode::create(), Botan::Cipher_Mode::create(), Botan::BlockCipher::create(), Botan::MessageAuthenticationCode::create(), Botan::StreamCipher::create(), and Botan::BlockCipher::create_or_throw().
|
staticinherited |
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 283 of file block_cipher.cpp.
References Botan::BlockCipher::create(), and Botan::BlockCipher::provider().
Referenced by Botan::TLS::Connection_Cipher_State::Connection_Cipher_State(), Botan::Encrypted_PSK_Database::Encrypted_PSK_Database(), Botan::rfc3394_keyunwrap(), and Botan::rfc3394_keywrap().
|
inlineinherited |
Decrypt one or more blocks
in | the input buffer (multiple of block_size()) |
out | the output buffer (same size as in) |
Definition at line 149 of file block_cipher.h.
|
inlineinherited |
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 92 of file block_cipher.h.
Referenced by Botan::CTS_Decryption::finish(), Botan::XTS_Decryption::finish(), and Botan::nist_key_unwrap_padded().
|
inlineinherited |
Decrypt one or more blocks
block | the input/output buffer (multiple of block_size()) |
Definition at line 126 of file block_cipher.h.
|
inlineinherited |
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 109 of file block_cipher.h.
|
pure virtualinherited |
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::TripleDES, Botan::GOST_28147_89, Botan::IDEA, Botan::Lion, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, and Botan::Twofish.
Referenced by Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BaseClass >::decrypt_n_xex(), and Botan::CBC_Decryption::process().
|
inlinevirtualinherited |
Reimplemented in Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BaseClass >, 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< 64, 64, 0, 1, Tweakable_Block_Cipher >, and Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 >.
Definition at line 183 of file block_cipher.h.
References Botan::xor_buf().
Referenced by Botan::XTS_Decryption::process().
|
inlineinherited |
Encrypt one or more blocks
in | the input buffer (multiple of block_size()) |
out | the output buffer (same size as in) |
Definition at line 137 of file block_cipher.h.
|
inlineinherited |
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.
Referenced by Botan::CCM_Encryption::finish(), Botan::CCM_Decryption::finish(), Botan::CTS_Encryption::finish(), Botan::XTS_Encryption::finish(), Botan::nist_key_wrap_padded(), Botan::CBC_Encryption::process(), and Botan::CFB_Mode::shift_register().
|
inlineinherited |
Encrypt one or more blocks
block | the input/output buffer (multiple of block_size()) |
Definition at line 116 of file block_cipher.h.
|
inlineinherited |
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 101 of file block_cipher.h.
|
pure virtualinherited |
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::TripleDES, Botan::GOST_28147_89, Botan::IDEA, Botan::Lion, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, and Botan::Twofish.
Referenced by Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BaseClass >::encrypt_n_xex().
|
inlinevirtualinherited |
Reimplemented in Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BaseClass >, 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< 64, 64, 0, 1, Tweakable_Block_Cipher >, and Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 >.
Definition at line 173 of file block_cipher.h.
References Botan::xor_buf().
Referenced by Botan::XTS_Encryption::process().
|
pure virtualinherited |
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, 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< 64, 64, 0, 1, Tweakable_Block_Cipher >, Botan::Block_Cipher_Fixed_Params< 8, 16, 24, 8 >, Botan::Cascade_Cipher, Botan::Lion, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::Poly1305, Botan::SipHash, Botan::ANSI_X919_MAC, Botan::FPE_FE1, Botan::CCM_Mode, Botan::ChaCha20Poly1305_Mode, Botan::EAX_Mode, Botan::GCM_Mode, Botan::OCB_Mode, Botan::SIV_Mode, Botan::CBC_Mode, Botan::XTS_Mode, Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, Botan::SHAKE_128_Cipher, Botan::GHASH, Botan::CFB_Mode, and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode.
Referenced by botan_cipher_get_keyspec(), botan_cipher_query_keylen(), Botan::CBC_Mode::key_spec(), Botan::XTS_Mode::key_spec(), and Botan::CFB_Mode::key_spec().
|
inlineinherited |
Definition at line 120 of file sym_algo.h.
|
inlineinherited |
Definition at line 128 of file sym_algo.h.
Referenced by botan_block_cipher_get_keyspec(), and botan_mac_get_keyspec().
|
pure virtualinherited |
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::TripleDES, Botan::GOST_28147_89, Botan::IDEA, Botan::Lion, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::Twofish, Botan::BLAKE2b, Botan::BLAKE2bMAC, Botan::CMAC, Botan::GMAC, Botan::HMAC, Botan::Poly1305, Botan::SipHash, Botan::ANSI_X919_MAC, Botan::FPE_FE1, Botan::CCM_Mode, Botan::ChaCha20Poly1305_Mode, Botan::OCB_Mode, Botan::SIV_Mode, Botan::CBC_Mode, Botan::XTS_Mode, Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, Botan::SHAKE_128_Cipher, Botan::GHASH, Botan::EAX_Mode, Botan::GCM_Mode, Botan::CFB_Mode, and Botan::TLS::TLS_CBC_HMAC_AEAD_Mode.
Referenced by Botan::CBC_Mode::name(), Botan::XTS_Mode::name(), Botan::CFB_Mode::name(), Botan::AEAD_Mode::set_associated_data_n(), Botan::SymmetricAlgorithm::set_key(), and Botan::MessageAuthenticationCode::start_msg().
|
pure virtualinherited |
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::TripleDES, Botan::GOST_28147_89, Botan::IDEA, Botan::Lion, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, and Botan::Twofish.
|
inlineinherited |
Definition at line 64 of file block_cipher.h.
References BOTAN_BLOCK_CIPHER_PAR_MULT.
Referenced by Botan::CBC_Mode::update_granularity().
|
inlinevirtualinherited |
Reimplemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::IDEA, Botan::Noekeon, Botan::Serpent, Botan::SHACAL2, Botan::SM4, and Botan::Threefish_512.
Definition at line 59 of file block_cipher.h.
|
inlinevirtualinherited |
Reimplemented in Botan::AES_128, Botan::AES_192, Botan::AES_256, Botan::IDEA, Botan::Noekeon, Botan::Serpent, Botan::SHACAL2, Botan::SM4, and Botan::Threefish_512.
Definition at line 73 of file block_cipher.h.
Referenced by Botan::BlockCipher::create(), and Botan::BlockCipher::create_or_throw().
|
staticinherited |
algo_spec | algorithm name |
Definition at line 293 of file block_cipher.cpp.
|
inlineinherited |
Definition at line 153 of file sym_algo.h.
|
inlineinherited |
Set the symmetric key of this object.
key | the SymmetricKey to be set. |
Definition at line 147 of file sym_algo.h.
References Botan::OctetString::begin(), and Botan::OctetString::length().
Referenced by 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().
|
inherited |
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 17 of file sym_algo.cpp.
References Botan::SymmetricAlgorithm::name(), and Botan::SymmetricAlgorithm::valid_keylength().
|
pure virtual |
Set the tweak value. This must be called after setting a key. The value persists until either set_tweak, set_key, or clear is called. Different algorithms support different tweak length(s). If called with an unsupported length, Invalid_Argument will be thrown.
Implemented in Botan::Threefish_512.
|
inlineinherited |
Check whether a given key length is valid for this algorithm.
length | the key length to be checked. |
Definition at line 138 of file sym_algo.h.
Referenced by Botan::SymmetricAlgorithm::set_key().
|
inlineprotectedinherited |
Definition at line 171 of file sym_algo.h.
Referenced by Botan::ChaCha::cipher(), Botan::CTR_BE::cipher(), Botan::RC4::cipher(), Botan::Salsa20::cipher(), Botan::SHAKE_128_Cipher::cipher(), 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::OCB_Encryption::finish(), Botan::OCB_Decryption::finish(), Botan::GHASH::ghash_update(), Botan::CFB_Encryption::process(), Botan::CFB_Decryption::process(), Botan::ChaCha::seek(), Botan::CTR_BE::seek(), Botan::Salsa20::seek(), Botan::OCB_Mode::set_associated_data(), Botan::ChaCha::set_iv(), Botan::Salsa20::set_iv(), Botan::GHASH::update(), Botan::GHASH::update_associated_data(), and Botan::ChaCha::write_keystream().