Botan 2.19.3
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Botan::CTR_BE Class Referencefinal

#include <ctr.h>

Inheritance diagram for Botan::CTR_BE:
Botan::StreamCipher Botan::SymmetricAlgorithm

Public Member Functions

void cipher (const uint8_t in[], uint8_t out[], size_t length) override
 
void cipher1 (uint8_t buf[], size_t len)
 
void clear () override
 
CTR_BEclone () const override
 
 CTR_BE (BlockCipher *cipher)
 
 CTR_BE (BlockCipher *cipher, size_t ctr_size)
 
template<typename Alloc >
void decrypt (std::vector< uint8_t, Alloc > &inout)
 
size_t default_iv_length () const override
 
template<typename Alloc >
void encipher (std::vector< uint8_t, Alloc > &inout)
 
template<typename Alloc >
void encrypt (std::vector< uint8_t, Alloc > &inout)
 
Key_Length_Specification key_spec () const override
 
size_t maximum_keylength () const
 
size_t minimum_keylength () const
 
std::string name () const override
 
virtual std::string provider () const
 
void seek (uint64_t offset) override
 
void set_iv (const uint8_t iv[], size_t iv_len) override
 
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)
 
bool valid_iv_length (size_t iv_len) const override
 
bool valid_keylength (size_t length) const
 
virtual void write_keystream (uint8_t out[], size_t len)
 

Static Public Member Functions

static std::unique_ptr< StreamCiphercreate (const std::string &algo_spec, const std::string &provider="")
 
static std::unique_ptr< StreamCiphercreate_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
 

Detailed Description

CTR-BE (Counter mode, big-endian)

Definition at line 21 of file ctr.h.

Constructor & Destructor Documentation

◆ CTR_BE() [1/2]

Botan::CTR_BE::CTR_BE ( BlockCipher cipher)
explicit
Parameters
cipherthe block cipher to use

Definition at line 15 of file ctr.cpp.

15 :
16 m_cipher(ciph),
17 m_block_size(m_cipher->block_size()),
18 m_ctr_size(m_block_size),
19 m_ctr_blocks(m_cipher->parallel_bytes() / m_block_size),
20 m_counter(m_cipher->parallel_bytes()),
21 m_pad(m_counter.size()),
22 m_pad_pos(0)
23 {
24 }

◆ CTR_BE() [2/2]

Botan::CTR_BE::CTR_BE ( BlockCipher cipher,
size_t  ctr_size 
)

Definition at line 26 of file ctr.cpp.

26 :
27 m_cipher(cipher),
28 m_block_size(m_cipher->block_size()),
29 m_ctr_size(ctr_size),
30 m_ctr_blocks(m_cipher->parallel_bytes() / m_block_size),
31 m_counter(m_cipher->parallel_bytes()),
32 m_pad(m_counter.size()),
33 m_pad_pos(0)
34 {
35 BOTAN_ARG_CHECK(m_ctr_size >= 4 && m_ctr_size <= m_block_size,
36 "Invalid CTR-BE counter size");
37 }
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:37
void cipher(const uint8_t in[], uint8_t out[], size_t length) override
Definition ctr.cpp:85

References BOTAN_ARG_CHECK.

Member Function Documentation

◆ cipher()

void Botan::CTR_BE::cipher ( const uint8_t  in[],
uint8_t  out[],
size_t  len 
)
overridevirtual

Encrypt or decrypt a message

Parameters
inthe plaintext
outthe byte array to hold the output, i.e. the ciphertext
lenthe length of both in and out in bytes

Implements Botan::StreamCipher.

Definition at line 85 of file ctr.cpp.

86 {
87 verify_key_set(m_iv.empty() == false);
88
89 const uint8_t* pad_bits = &m_pad[0];
90 const size_t pad_size = m_pad.size();
91
92 if(m_pad_pos > 0)
93 {
94 const size_t avail = pad_size - m_pad_pos;
95 const size_t take = std::min(length, avail);
96 xor_buf(out, in, pad_bits + m_pad_pos, take);
97 length -= take;
98 in += take;
99 out += take;
100 m_pad_pos += take;
101
102 if(take == avail)
103 {
104 add_counter(m_ctr_blocks);
105 m_cipher->encrypt_n(m_counter.data(), m_pad.data(), m_ctr_blocks);
106 m_pad_pos = 0;
107 }
108 }
109
110 while(length >= pad_size)
111 {
112 xor_buf(out, in, pad_bits, pad_size);
113 length -= pad_size;
114 in += pad_size;
115 out += pad_size;
116
117 add_counter(m_ctr_blocks);
118 m_cipher->encrypt_n(m_counter.data(), m_pad.data(), m_ctr_blocks);
119 }
120
121 xor_buf(out, in, pad_bits, length);
122 m_pad_pos += length;
123 }
void verify_key_set(bool cond) const
Definition sym_algo.h:171
void xor_buf(uint8_t out[], const uint8_t in[], size_t length)
Definition mem_ops.h:262

References Botan::SymmetricAlgorithm::verify_key_set(), and Botan::xor_buf().

◆ cipher1()

void Botan::StreamCipher::cipher1 ( uint8_t  buf[],
size_t  len 
)
inlineinherited

Encrypt or decrypt a message The message is encrypted/decrypted in place.

Parameters
bufthe plaintext / ciphertext
lenthe length of buf in bytes

Definition at line 78 of file stream_cipher.h.

79 { cipher(buf, buf, len); }
virtual void cipher(const uint8_t in[], uint8_t out[], size_t len)=0

Referenced by Botan::SIV_Encryption::finish().

◆ clear()

void Botan::CTR_BE::clear ( )
overridevirtual

Reset the state.

Implements Botan::SymmetricAlgorithm.

Definition at line 39 of file ctr.cpp.

40 {
41 m_cipher->clear();
42 zeroise(m_pad);
43 zeroise(m_counter);
44 zap(m_iv);
45 m_pad_pos = 0;
46 }
void zeroise(std::vector< T, Alloc > &vec)
Definition secmem.h:114
void zap(std::vector< T, Alloc > &vec)
Definition secmem.h:124

References Botan::zap(), and Botan::zeroise().

◆ clone()

CTR_BE * Botan::CTR_BE::clone ( ) const
overridevirtual
Returns
a new object representing the same algorithm as *this

Implements Botan::StreamCipher.

Definition at line 63 of file ctr.cpp.

64 {
65 return new CTR_BE(m_cipher->clone(), m_ctr_size);
66 }
CTR_BE(BlockCipher *cipher)
Definition ctr.cpp:15

◆ create()

std::unique_ptr< StreamCipher > Botan::StreamCipher::create ( const std::string &  algo_spec,
const std::string &  provider = "" 
)
staticinherited

Create an instance based on a name If provider is empty then best available is chosen.

Parameters
algo_specalgorithm name
providerprovider implementation to use
Returns
a null pointer if the algo/provider combination cannot be found

Definition at line 38 of file stream_cipher.cpp.

40 {
41 const SCAN_Name req(algo_spec);
42
43#if defined(BOTAN_HAS_CTR_BE)
44 if((req.algo_name() == "CTR-BE" || req.algo_name() == "CTR") && req.arg_count_between(1,2))
45 {
46 if(provider.empty() || provider == "base")
47 {
48 auto cipher = BlockCipher::create(req.arg(0));
49 if(cipher)
50 {
51 size_t ctr_size = req.arg_as_integer(1, cipher->block_size());
52 return std::unique_ptr<StreamCipher>(new CTR_BE(cipher.release(), ctr_size));
53 }
54 }
55 }
56#endif
57
58#if defined(BOTAN_HAS_CHACHA)
59 if(req.algo_name() == "ChaCha")
60 {
61 if(provider.empty() || provider == "base")
62 return std::unique_ptr<StreamCipher>(new ChaCha(req.arg_as_integer(0, 20)));
63 }
64
65 if(req.algo_name() == "ChaCha20")
66 {
67 if(provider.empty() || provider == "base")
68 return std::unique_ptr<StreamCipher>(new ChaCha(20));
69 }
70#endif
71
72#if defined(BOTAN_HAS_SALSA20)
73 if(req.algo_name() == "Salsa20")
74 {
75 if(provider.empty() || provider == "base")
76 return std::unique_ptr<StreamCipher>(new Salsa20);
77 }
78#endif
79
80#if defined(BOTAN_HAS_SHAKE_CIPHER)
81 if(req.algo_name() == "SHAKE-128" || req.algo_name() == "SHAKE-128-XOF")
82 {
83 if(provider.empty() || provider == "base")
84 return std::unique_ptr<StreamCipher>(new SHAKE_128_Cipher);
85 }
86#endif
87
88#if defined(BOTAN_HAS_OFB)
89 if(req.algo_name() == "OFB" && req.arg_count() == 1)
90 {
91 if(provider.empty() || provider == "base")
92 {
93 if(auto c = BlockCipher::create(req.arg(0)))
94 return std::unique_ptr<StreamCipher>(new OFB(c.release()));
95 }
96 }
97#endif
98
99#if defined(BOTAN_HAS_RC4)
100
101 if(req.algo_name() == "RC4" ||
102 req.algo_name() == "ARC4" ||
103 req.algo_name() == "MARK-4")
104 {
105 const size_t skip = (req.algo_name() == "MARK-4") ? 256 : req.arg_as_integer(0, 0);
106
107 if(provider.empty() || provider == "base")
108 {
109 return std::unique_ptr<StreamCipher>(new RC4(skip));
110 }
111 }
112
113#endif
114
115 BOTAN_UNUSED(req);
117
118 return nullptr;
119 }
#define BOTAN_UNUSED(...)
Definition assert.h:142
static std::unique_ptr< BlockCipher > create(const std::string &algo_spec, const std::string &provider="")
virtual std::string provider() const

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, Botan::StreamCipher::cipher(), Botan::BlockCipher::create(), and Botan::StreamCipher::provider().

Referenced by Botan::Cipher_Mode::create(), Botan::BlockCipher::create(), and Botan::StreamCipher::create_or_throw().

◆ create_or_throw()

std::unique_ptr< StreamCipher > Botan::StreamCipher::create_or_throw ( const std::string &  algo_spec,
const std::string &  provider = "" 
)
staticinherited

Create an instance based on a name If provider is empty then best available is chosen.

Parameters
algo_specalgorithm name
providerprovider implementation to use Throws a Lookup_Error if the algo/provider combination cannot be found

Definition at line 123 of file stream_cipher.cpp.

125 {
126 if(auto sc = StreamCipher::create(algo, provider))
127 {
128 return sc;
129 }
130 throw Lookup_Error("Stream cipher", algo, provider);
131 }
static std::unique_ptr< StreamCipher > create(const std::string &algo_spec, const std::string &provider="")

References Botan::StreamCipher::create(), and Botan::StreamCipher::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().

◆ decrypt()

template<typename Alloc >
void Botan::StreamCipher::decrypt ( std::vector< uint8_t, Alloc > &  inout)
inlineinherited

Decrypt a message in place The message is decrypted in place.

Parameters
inoutthe plaintext / ciphertext

Definition at line 105 of file stream_cipher.h.

106 { cipher(inout.data(), inout.data(), inout.size()); }

◆ default_iv_length()

size_t Botan::CTR_BE::default_iv_length ( ) const
overridevirtual

Return the default (preferred) nonce length If this function returns 0, then this cipher does not support nonces

Reimplemented from Botan::StreamCipher.

Definition at line 48 of file ctr.cpp.

49 {
50 return m_block_size;
51 }

◆ encipher()

template<typename Alloc >
void Botan::StreamCipher::encipher ( std::vector< uint8_t, Alloc > &  inout)
inlineinherited

Encrypt a message The message is encrypted/decrypted in place.

Parameters
inoutthe plaintext / ciphertext

Definition at line 87 of file stream_cipher.h.

88 { cipher(inout.data(), inout.data(), inout.size()); }

◆ encrypt()

template<typename Alloc >
void Botan::StreamCipher::encrypt ( std::vector< uint8_t, Alloc > &  inout)
inlineinherited

Encrypt a message The message is encrypted in place.

Parameters
inoutthe plaintext / ciphertext

Definition at line 96 of file stream_cipher.h.

97 { cipher(inout.data(), inout.data(), inout.size()); }

◆ key_spec()

Key_Length_Specification Botan::CTR_BE::key_spec ( ) const
overridevirtual
Returns
object describing limits on key size

Implements Botan::SymmetricAlgorithm.

Definition at line 58 of file ctr.cpp.

59 {
60 return m_cipher->key_spec();
61 }

◆ maximum_keylength()

size_t Botan::SymmetricAlgorithm::maximum_keylength ( ) const
inlineinherited
Returns
maximum allowed key length

Definition at line 120 of file sym_algo.h.

121 {
122 return key_spec().maximum_keylength();
123 }
size_t maximum_keylength() const
Definition sym_algo.h:70
virtual Key_Length_Specification key_spec() const =0

◆ minimum_keylength()

size_t Botan::SymmetricAlgorithm::minimum_keylength ( ) const
inlineinherited
Returns
minimum allowed key length

Definition at line 128 of file sym_algo.h.

129 {
130 return key_spec().minimum_keylength();
131 }
size_t minimum_keylength() const
Definition sym_algo.h:62

Referenced by botan_block_cipher_get_keyspec(), and botan_mac_get_keyspec().

◆ name()

std::string Botan::CTR_BE::name ( ) const
overridevirtual
Returns
the algorithm name

Implements Botan::SymmetricAlgorithm.

Definition at line 76 of file ctr.cpp.

77 {
78 if(m_ctr_size == m_block_size)
79 return ("CTR-BE(" + m_cipher->name() + ")");
80 else
81 return ("CTR-BE(" + m_cipher->name() + "," + std::to_string(m_ctr_size) + ")");
82
83 }

Referenced by set_iv().

◆ provider()

virtual std::string Botan::StreamCipher::provider ( ) const
inlinevirtualinherited
Returns
provider information about this implementation. Default is "base", might also return "sse2", "avx2", "openssl", or some other arbitrary string.

Reimplemented in Botan::ChaCha.

Definition at line 142 of file stream_cipher.h.

142{ return "base"; }

Referenced by Botan::StreamCipher::create(), and Botan::StreamCipher::create_or_throw().

◆ providers()

std::vector< std::string > Botan::StreamCipher::providers ( const std::string &  algo_spec)
staticinherited
Returns
list of available providers for this algorithm, empty if not available

Definition at line 133 of file stream_cipher.cpp.

134 {
135 return probe_providers_of<StreamCipher>(algo_spec, {"base"});
136 }

◆ seek()

void Botan::CTR_BE::seek ( uint64_t  offset)
overridevirtual

Set the offset and the state used later to generate the keystream

Parameters
offsetthe offset where we begin to generate the keystream

Implements Botan::StreamCipher.

Definition at line 197 of file ctr.cpp.

198 {
199 verify_key_set(m_iv.empty() == false);
200
201 const uint64_t base_counter = m_ctr_blocks * (offset / m_counter.size());
202
203 zeroise(m_counter);
204 buffer_insert(m_counter, 0, m_iv);
205
206 const size_t BS = m_block_size;
207
208 // Set m_counter blocks to IV, IV + 1, ... IV + n
209
210 if(m_ctr_size == 4 && BS >= 8)
211 {
212 const uint32_t low32 = load_be<uint32_t>(&m_counter[BS-4], 0);
213
214 if(m_ctr_blocks >= 4 && is_power_of_2(m_ctr_blocks))
215 {
216 size_t written = 1;
217 while(written < m_ctr_blocks)
218 {
219 copy_mem(&m_counter[written*BS], &m_counter[0], BS*written);
220 written *= 2;
221 }
222 }
223 else
224 {
225 for(size_t i = 1; i != m_ctr_blocks; ++i)
226 {
227 copy_mem(&m_counter[i*BS], &m_counter[0], BS - 4);
228 }
229 }
230
231 for(size_t i = 1; i != m_ctr_blocks; ++i)
232 {
233 const uint32_t c = static_cast<uint32_t>(low32 + i);
234 store_be(c, &m_counter[(BS-4)+i*BS]);
235 }
236 }
237 else
238 {
239 // do everything sequentially:
240 for(size_t i = 1; i != m_ctr_blocks; ++i)
241 {
242 buffer_insert(m_counter, i*BS, &m_counter[(i-1)*BS], BS);
243
244 for(size_t j = 0; j != m_ctr_size; ++j)
245 if(++m_counter[i*BS + (BS - 1 - j)])
246 break;
247 }
248 }
249
250 if(base_counter > 0)
251 add_counter(base_counter);
252
253 m_cipher->encrypt_n(m_counter.data(), m_pad.data(), m_ctr_blocks);
254 m_pad_pos = offset % m_counter.size();
255 }
size_t buffer_insert(std::vector< T, Alloc > &buf, size_t buf_offset, const T input[], size_t input_length)
Definition mem_ops.h:228
void store_be(uint16_t in, uint8_t out[2])
Definition loadstor.h:438
void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:133
uint32_t load_be< uint32_t >(const uint8_t in[], size_t off)
Definition loadstor.h:179
constexpr bool is_power_of_2(T arg)
Definition bit_ops.h:43

References Botan::buffer_insert(), Botan::copy_mem(), Botan::is_power_of_2(), Botan::load_be< uint32_t >(), Botan::store_be(), Botan::SymmetricAlgorithm::verify_key_set(), and Botan::zeroise().

Referenced by set_iv().

◆ set_iv()

void Botan::CTR_BE::set_iv ( const uint8_t  iv[],
size_t  iv_len 
)
overridevirtual

Resync the cipher using the IV

Parameters
ivthe initialization vector
iv_lenthe length of the IV in bytes

Implements Botan::StreamCipher.

Definition at line 125 of file ctr.cpp.

126 {
127 if(!valid_iv_length(iv_len))
128 throw Invalid_IV_Length(name(), iv_len);
129
130 m_iv.resize(m_block_size);
131 zeroise(m_iv);
132 buffer_insert(m_iv, 0, iv, iv_len);
133
134 seek(0);
135 }
bool valid_iv_length(size_t iv_len) const override
Definition ctr.cpp:53
void seek(uint64_t offset) override
Definition ctr.cpp:197
std::string name() const override
Definition ctr.cpp:76

References Botan::buffer_insert(), name(), seek(), valid_iv_length(), and Botan::zeroise().

◆ set_key() [1/3]

template<typename Alloc >
void Botan::SymmetricAlgorithm::set_key ( const std::vector< uint8_t, Alloc > &  key)
inlineinherited

Definition at line 153 of file sym_algo.h.

154 {
155 set_key(key.data(), key.size());
156 }
void set_key(const SymmetricKey &key)
Definition sym_algo.h:147

◆ set_key() [2/3]

void Botan::SymmetricAlgorithm::set_key ( const SymmetricKey key)
inlineinherited

◆ set_key() [3/3]

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

Set the symmetric key of this object.

Parameters
keythe to be set as a byte array.
lengthin bytes of key param

Definition at line 17 of file sym_algo.cpp.

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

References Botan::SymmetricAlgorithm::name(), and Botan::SymmetricAlgorithm::valid_keylength().

◆ valid_iv_length()

bool Botan::CTR_BE::valid_iv_length ( size_t  iv_len) const
overridevirtual
Parameters
iv_lenthe length of the IV in bytes
Returns
if the length is valid for this algorithm

Reimplemented from Botan::StreamCipher.

Definition at line 53 of file ctr.cpp.

54 {
55 return (iv_len <= m_block_size);
56 }

Referenced by set_iv().

◆ valid_keylength()

bool Botan::SymmetricAlgorithm::valid_keylength ( size_t  length) const
inlineinherited

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

139 {
140 return key_spec().valid_keylength(length);
141 }
bool valid_keylength(size_t length) const
Definition sym_algo.h:52

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

◆ verify_key_set()

void Botan::SymmetricAlgorithm::verify_key_set ( bool  cond) const
inlineprotectedinherited

Definition at line 171 of file sym_algo.h.

172 {
173 if(cond == false)
174 throw_key_not_set_error();
175 }

Referenced by Botan::ChaCha::cipher(), 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(), 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().

◆ write_keystream()

virtual void Botan::StreamCipher::write_keystream ( uint8_t  out[],
size_t  len 
)
inlinevirtualinherited

Write keystream bytes to a buffer

Parameters
outthe byte array to hold the keystream
lenthe length of out in bytes

Reimplemented in Botan::ChaCha.

Definition at line 66 of file stream_cipher.h.

67 {
68 clear_mem(out, len);
69 cipher1(out, len);
70 }
void cipher1(uint8_t buf[], size_t len)
void clear_mem(T *ptr, size_t n)
Definition mem_ops.h:115

References Botan::clear_mem().

Referenced by Botan::Sodium::crypto_stream_salsa20(), and Botan::Sodium::crypto_stream_xsalsa20().


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