Botan 2.19.3
Crypto and TLS for C&
|
#include <stream_cipher.h>
Public Member Functions | |
virtual void | cipher (const uint8_t in[], uint8_t out[], size_t len)=0 |
void | cipher1 (uint8_t buf[], size_t len) |
virtual void | clear ()=0 |
virtual StreamCipher * | clone () const =0 |
template<typename Alloc > | |
void | decrypt (std::vector< uint8_t, Alloc > &inout) |
virtual size_t | default_iv_length () const |
template<typename Alloc > | |
void | encipher (std::vector< uint8_t, Alloc > &inout) |
template<typename Alloc > | |
void | encrypt (std::vector< uint8_t, Alloc > &inout) |
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::string | provider () const |
virtual void | seek (uint64_t offset)=0 |
virtual void | set_iv (const uint8_t iv[], size_t iv_len)=0 |
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 bool | valid_iv_length (size_t iv_len) const |
bool | valid_keylength (size_t length) const |
virtual void | write_keystream (uint8_t out[], size_t len) |
virtual | ~StreamCipher ()=default |
Static Public Member Functions | |
static std::unique_ptr< StreamCipher > | create (const std::string &algo_spec, const std::string &provider="") |
static std::unique_ptr< StreamCipher > | 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 |
Base class for all stream ciphers
Definition at line 21 of file stream_cipher.h.
|
virtualdefault |
|
pure virtual |
Encrypt or decrypt a message
in | the plaintext |
out | the byte array to hold the output, i.e. the ciphertext |
len | the length of both in and out in bytes |
Implemented in Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, and Botan::SHAKE_128_Cipher.
Referenced by create(), and Botan::SIV_Decryption::finish().
|
inline |
Encrypt or decrypt a message The message is encrypted/decrypted in place.
buf | the plaintext / ciphertext |
len | the length of buf in bytes |
Definition at line 78 of file stream_cipher.h.
Referenced by Botan::SIV_Encryption::finish().
|
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::CAST_256, Botan::DES, Botan::TripleDES, Botan::DESX, Botan::GOST_28147_89, Botan::IDEA, Botan::KASUMI, Botan::Lion, Botan::MISTY1, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::Twofish, Botan::XTEA, Botan::CBC_MAC, 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_block_cipher_clear(), botan_cipher_clear(), botan_mac_clear(), Botan::TLS::TLS_CBC_HMAC_AEAD_Mode::clear(), and Botan::RC4::~RC4().
|
pure virtual |
Implemented in Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, and Botan::SHAKE_128_Cipher.
|
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 use |
Definition at line 38 of file stream_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_UNUSED, cipher(), Botan::BlockCipher::create(), and provider().
Referenced by Botan::Cipher_Mode::create(), Botan::BlockCipher::create(), and create_or_throw().
|
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 use Throws a Lookup_Error if the algo/provider combination cannot be found |
Definition at line 123 of file stream_cipher.cpp.
References create(), and provider().
Referenced by Botan::ChaCha_RNG::ChaCha_RNG(), Botan::ChaCha_RNG::ChaCha_RNG(), Botan::ChaCha_RNG::ChaCha_RNG(), Botan::ChaCha_RNG::ChaCha_RNG(), Botan::ChaCha_RNG::ChaCha_RNG(), Botan::Sodium::crypto_secretbox_detached(), Botan::Sodium::crypto_secretbox_open_detached(), Botan::Sodium::crypto_secretbox_xsalsa20poly1305(), Botan::Sodium::crypto_secretbox_xsalsa20poly1305_open(), Botan::Sodium::crypto_stream_chacha20(), Botan::Sodium::crypto_stream_chacha20_ietf(), Botan::Sodium::crypto_stream_chacha20_ietf_xor_ic(), Botan::Sodium::crypto_stream_chacha20_xor_ic(), Botan::Sodium::crypto_stream_xchacha20(), and Botan::Sodium::crypto_stream_xchacha20_xor_ic().
|
inline |
Decrypt a message in place The message is decrypted in place.
inout | the plaintext / ciphertext |
Definition at line 105 of file stream_cipher.h.
|
inlinevirtual |
Return the default (preferred) nonce length If this function returns 0, then this cipher does not support nonces
Reimplemented in Botan::ChaCha, Botan::CTR_BE, Botan::OFB, and Botan::Salsa20.
Definition at line 119 of file stream_cipher.h.
|
inline |
Encrypt a message The message is encrypted/decrypted in place.
inout | the plaintext / ciphertext |
Definition at line 87 of file stream_cipher.h.
|
inline |
Encrypt a message The message is encrypted in place.
inout | the plaintext / ciphertext |
Definition at line 96 of file stream_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, 16, 32, 8 >, Botan::Block_Cipher_Fixed_Params< 16, 24 >, Botan::Block_Cipher_Fixed_Params< 16, 32 >, Botan::Block_Cipher_Fixed_Params< 16, 4, 32, 4 >, 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, 24 >, Botan::Block_Cipher_Fixed_Params< 8, 32 >, Botan::Block_Cipher_Fixed_Params< 8, 8 >, Botan::Cascade_Cipher, Botan::Lion, Botan::CBC_MAC, 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::CAST_256, Botan::DES, Botan::TripleDES, Botan::DESX, Botan::GOST_28147_89, Botan::IDEA, Botan::KASUMI, Botan::Lion, Botan::MISTY1, Botan::Noekeon, Botan::SEED, Botan::Serpent, Botan::SHACAL2, Botan::SM4, Botan::Threefish_512, Botan::Twofish, Botan::XTEA, Botan::CBC_MAC, 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::CBC_Mode::CBC_Mode(), Botan::CBC_Mode::name(), Botan::XTS_Mode::name(), Botan::CFB_Mode::name(), Botan::AEAD_Mode::set_associated_data_n(), Botan::SymmetricAlgorithm::set_key(), Botan::MessageAuthenticationCode::start_msg(), and Botan::XTS_Mode::XTS_Mode().
|
inlinevirtual |
Reimplemented in Botan::ChaCha.
Definition at line 142 of file stream_cipher.h.
Referenced by create(), and create_or_throw().
|
static |
Definition at line 133 of file stream_cipher.cpp.
|
pure virtual |
Set the offset and the state used later to generate the keystream
offset | the offset where we begin to generate the keystream |
Implemented in Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, and Botan::SHAKE_128_Cipher.
|
pure virtual |
Resync the cipher using the IV
iv | the initialization vector |
iv_len | the length of the IV in bytes |
Implemented in Botan::ChaCha, Botan::CTR_BE, Botan::OFB, Botan::RC4, Botan::Salsa20, and Botan::SHAKE_128_Cipher.
Referenced by Botan::SIV_Mode::set_ctr_iv().
|
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::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().
|
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().
|
inlinevirtual |
iv_len | the length of the IV in bytes |
Reimplemented in Botan::ChaCha, Botan::CTR_BE, Botan::OFB, and Botan::Salsa20.
Definition at line 125 of file stream_cipher.h.
|
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::aont_package(), Botan::aont_unpackage(), and 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::CAST_256::decrypt_n(), Botan::DES::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::DESX::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::IDEA::decrypt_n(), Botan::KASUMI::decrypt_n(), Botan::Lion::decrypt_n(), Botan::MISTY1::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::XTEA::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::CAST_256::encrypt_n(), Botan::DES::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::DESX::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::IDEA::encrypt_n(), Botan::KASUMI::encrypt_n(), Botan::Lion::encrypt_n(), Botan::MISTY1::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::XTEA::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().
|
inlinevirtual |
Write keystream bytes to a buffer
out | the byte array to hold the keystream |
len | the length of out in bytes |
Reimplemented in Botan::ChaCha.
Definition at line 66 of file stream_cipher.h.
References Botan::clear_mem().
Referenced by Botan::Sodium::crypto_stream_salsa20(), and Botan::Sodium::crypto_stream_xsalsa20().