Botan 3.14.1
Crypto and TLS for C&
Botan::Twofish Class Referencefinal

#include <twofish.h>

Inheritance diagram for Botan::Twofish:
Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 > Botan::BlockCipher Botan::SymmetricAlgorithm

Public Types

enum  

Public Member Functions

size_t block_size () const final
void clear () override
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
void decrypt_n (const uint8_t in[], uint8_t out[], size_t blocks) const override
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
void encrypt_n (const uint8_t in[], uint8_t out[], size_t blocks) const override
void encrypt_n_xex (uint8_t data[], const uint8_t mask[], size_t blocks) const
bool has_keying_material () const override
Key_Length_Specification key_spec () const final
size_t maximum_keylength () const
size_t minimum_keylength () const
std::string name () const override
std::unique_ptr< BlockCipher > new_object () const override
size_t parallel_bytes () const
size_t parallelism () const override
std::string provider () const override
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

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

Protected Member Functions

void assert_key_material_set () const
void assert_key_material_set (bool predicate) const

Detailed Description

Twofish, an AES finalist

Definition at line 19 of file twofish.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

Definition at line 234 of file block_cipher.h.

234{ BLOCK_SIZE = BS }; /* NOLINT(*-enum-size,*-use-enum-class) */

Member Function Documentation

◆ assert_key_material_set() [1/2]

◆ assert_key_material_set() [2/2]

void Botan::SymmetricAlgorithm::assert_key_material_set ( bool predicate) const
inlineprotectedinherited

Throw Key_Not_Set unless the predicate holds

Parameters
predicateif false, a Key_Not_Set exception is thrown

Definition at line 186 of file sym_algo.h.

186 {
187 if(!predicate) {
189 }
190 }

◆ block_size()

size_t Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BlockCipher >::block_size ( ) const
inlinefinalvirtualinherited

Return the block size of this cipher

Returns
the fixed block size BS

Implements Botan::BlockCipher.

Definition at line 240 of file block_cipher.h.

240{ return BS; }

◆ clear()

void Botan::Twofish::clear ( )
overridevirtual

Reset the internal state. This includes not just the key, but any partial message that may have been in process.

Implements Botan::SymmetricAlgorithm.

Definition at line 490 of file twofish.cpp.

490 {
491 zap(m_SB);
492 zap(m_RK);
493 zap(m_QS);
494}
void zap(std::vector< T, Alloc > &vec)
Definition secmem.h:261

References Botan::zap().

◆ clone()

BlockCipher * Botan::BlockCipher::clone ( ) const
inlineinherited

Create a new uninitialized object of the same type

Returns
new object representing the same algorithm as *this

Definition at line 210 of file block_cipher.h.

210{ return this->new_object().release(); }
virtual std::unique_ptr< BlockCipher > new_object() const=0

◆ create()

std::unique_ptr< BlockCipher > Botan::BlockCipher::create ( std::string_view algo_spec,
std::string_view 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 choose
Returns
a null pointer if the algo/provider combination cannot be found

Definition at line 31 of file block_cipher.cpp.

97 {
98#if defined(BOTAN_HAS_COMMONCRYPTO)
99 if(provider.empty() || provider == "commoncrypto") {
101 return bc;
102
103 if(!provider.empty())
104 return nullptr;
105 }
106#endif
107
108 // TODO: CryptoAPI
109 // TODO: /dev/crypto
110
111 // Only base providers from here on out
112 if(provider.empty() == false && provider != "base") {
113 return nullptr;
114 }
115
116#if defined(BOTAN_HAS_AES)
117 if(algo == "AES-128") {
119 }
120
121 if(algo == "AES-192") {
123 }
124
125 if(algo == "AES-256") {
127 }
128#endif
129
130#if defined(BOTAN_HAS_ARIA)
131 if(algo == "ARIA-128") {
133 }
134
135 if(algo == "ARIA-192") {
137 }
138
139 if(algo == "ARIA-256") {
141 }
142#endif
143
144#if defined(BOTAN_HAS_SERPENT)
145 if(algo == "Serpent") {
147 }
148#endif
149
150#if defined(BOTAN_HAS_SHACAL2)
151 if(algo == "SHACAL2") {
153 }
154#endif
155
156#if defined(BOTAN_HAS_TWOFISH)
157 if(algo == "Twofish") {
159 }
160#endif
161
162#if defined(BOTAN_HAS_THREEFISH_512)
163 if(algo == "Threefish-512") {
165 }
166#endif
167
168#if defined(BOTAN_HAS_BLOWFISH)
169 if(algo == "Blowfish") {
171 }
172#endif
173
174#if defined(BOTAN_HAS_CAMELLIA)
175 if(algo == "Camellia-128") {
177 }
178
179 if(algo == "Camellia-192") {
181 }
182
183 if(algo == "Camellia-256") {
185 }
186#endif
187
188#if defined(BOTAN_HAS_DES)
189 if(algo == "DES") {
190 return std::make_unique<DES>();
191 }
192
193 if(algo == "TripleDES" || algo == "3DES" || algo == "DES-EDE") {
195 }
196#endif
197
198#if defined(BOTAN_HAS_NOEKEON)
199 if(algo == "Noekeon") {
201 }
202#endif
203
204#if defined(BOTAN_HAS_CAST_128)
205 if(algo == "CAST-128" || algo == "CAST5") {
207 }
208#endif
209
210#if defined(BOTAN_HAS_IDEA)
211 if(algo == "IDEA") {
212 return std::make_unique<IDEA>();
213 }
214#endif
215
216#if defined(BOTAN_HAS_KUZNYECHIK)
217 if(algo == "Kuznyechik") {
219 }
220#endif
221
222#if defined(BOTAN_HAS_SEED)
223 if(algo == "SEED") {
224 return std::make_unique<SEED>();
225 }
226#endif
227
228#if defined(BOTAN_HAS_SM4)
229 if(algo == "SM4") {
230 return std::make_unique<SM4>();
231 }
232#endif
233
234 const AlgorithmSpec req(algo);
235
236#if defined(BOTAN_HAS_GOST_28147_89)
237 if(auto m = req.match("GOST-28147-89({params:str=R3411_94_TestParam})")) {
238 return std::make_unique<GOST_28147_89>(m->str("params"));
239 }
240#endif
241
242#if defined(BOTAN_HAS_CASCADE)
243 if(auto m = req.match("Cascade({cipher1},{cipher2})")) {
244 auto c1 = BlockCipher::create(m->str("cipher1"));
245 auto c2 = BlockCipher::create(m->str("cipher2"));
246
247 if(c1 && c2) {
249 }
250 }
251#endif
252
253#if defined(BOTAN_HAS_LION)
254 if(auto m = req.match("Lion({hash},{stream},{block_size:int=1024})")) {
255 auto hash = HashFunction::create(m->str("hash"));
256 auto stream = StreamCipher::create(m->str("stream"));
257
258 if(hash && stream) {
259 return std::make_unique<Lion>(std::move(hash), std::move(stream), m->integer("block_size"));
260 }
261 }
262#endif
263
266
267 return nullptr;
268}
#define BOTAN_UNUSED
Definition assert.h:151
static std::unique_ptr< BlockCipher > create(std::string_view algo_spec, std::string_view provider="")
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:112
static std::unique_ptr< StreamCipher > create(std::string_view algo_spec, std::string_view provider="")
std::unique_ptr< BlockCipher > make_commoncrypto_block_cipher(std::string_view name)

◆ create_or_throw()

std::unique_ptr< BlockCipher > Botan::BlockCipher::create_or_throw ( std::string_view algo_spec,
std::string_view provider = "" )
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 38 of file block_cipher.cpp.

271 {
272 if(auto bc = BlockCipher::create(algo, provider)) {
273 return bc;
274 }
275 throw Lookup_Error("Block cipher", algo, provider);
276}

◆ decrypt() [1/4]

void Botan::BlockCipher::decrypt ( const uint8_t in[],
uint8_t out[] ) const
inlineinherited

Decrypt a block.

Parameters
inThe ciphertext block to be decrypted as a byte array. Must be of length block_size().
outThe byte array designated to hold the decrypted block. Must be of length block_size().

Definition at line 96 of file block_cipher.h.

96{ decrypt_n(in, out, 1); }
virtual void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const=0

◆ decrypt() [2/4]

void Botan::BlockCipher::decrypt ( std::span< const uint8_t > in,
std::span< uint8_t > out ) const
inlineinherited

Decrypt one or more blocks

Parameters
inthe input buffer (multiple of block_size())
outthe output buffer (same size as in)

Definition at line 144 of file block_cipher.h.

144 {
145 return decrypt_n(in.data(), out.data(), in.size() / block_size());
146 }

◆ decrypt() [3/4]

void Botan::BlockCipher::decrypt ( std::span< uint8_t > block) const
inlineinherited

Decrypt one or more blocks

Parameters
Block Ciphersthe input/output buffer (multiple of block_size())

Definition at line 126 of file block_cipher.h.

126 {
127 return decrypt_n(block.data(), block.data(), block.size() / block_size());
128 }

◆ decrypt() [4/4]

void Botan::BlockCipher::decrypt ( uint8_t block[]) const
inlineinherited

Decrypt a block.

Parameters
Block Ciphersthe ciphertext block to be decrypted Must be of length block_size(). Will hold the result when the function has finished.

Definition at line 112 of file block_cipher.h.

112{ decrypt_n(block, block, 1); }

◆ decrypt_n()

void Botan::Twofish::decrypt_n ( const uint8_t in[],
uint8_t out[],
size_t blocks ) const
overridevirtual

Decrypt one or more blocks

Parameters
inthe input buffer (multiple of block_size())
outthe output buffer (same size as in)
blocksthe number of blocks to process

Implements Botan::BlockCipher.

Definition at line 257 of file twofish.cpp.

257 {
259
260#if defined(BOTAN_HAS_TWOFISH_AVX512)
261 if(!m_QS.empty()) {
262 return avx512_decrypt(in, out, blocks);
263 }
264#endif
265
266 BOTAN_ASSERT_NOMSG(!m_SB.empty());
267
268 while(blocks >= 2) {
269 uint32_t A0 = 0;
270 uint32_t B0 = 0;
271 uint32_t C0 = 0;
272 uint32_t D0 = 0;
273 uint32_t A1 = 0;
274 uint32_t B1 = 0;
275 uint32_t C1 = 0;
276 uint32_t D1 = 0;
277 load_le(in, A0, B0, C0, D0, A1, B1, C1, D1);
278
279 A0 ^= m_RK[4];
280 A1 ^= m_RK[4];
281 B0 ^= m_RK[5];
282 B1 ^= m_RK[5];
283 C0 ^= m_RK[6];
284 C1 ^= m_RK[6];
285 D0 ^= m_RK[7];
286 D1 ^= m_RK[7];
287
288 for(size_t k = 40; k != 8; k -= 4) {
289 TF_D(A0, B0, C0, D0, m_RK[k - 2], m_RK[k - 1], m_SB);
290 TF_D(A1, B1, C1, D1, m_RK[k - 2], m_RK[k - 1], m_SB);
291
292 TF_D(C0, D0, A0, B0, m_RK[k - 4], m_RK[k - 3], m_SB);
293 TF_D(C1, D1, A1, B1, m_RK[k - 4], m_RK[k - 3], m_SB);
294 }
295
296 C0 ^= m_RK[0];
297 C1 ^= m_RK[0];
298 D0 ^= m_RK[1];
299 D1 ^= m_RK[1];
300 A0 ^= m_RK[2];
301 A1 ^= m_RK[2];
302 B0 ^= m_RK[3];
303 B1 ^= m_RK[3];
304
305 store_le(out, C0, D0, A0, B0, C1, D1, A1, B1);
306
307 blocks -= 2;
308 out += 2 * BLOCK_SIZE;
309 in += 2 * BLOCK_SIZE;
310 }
311
312 if(blocks > 0) {
313 uint32_t A = 0;
314 uint32_t B = 0;
315 uint32_t C = 0;
316 uint32_t D = 0;
317 load_le(in, A, B, C, D);
318
319 A ^= m_RK[4];
320 B ^= m_RK[5];
321 C ^= m_RK[6];
322 D ^= m_RK[7];
323
324 for(size_t k = 40; k != 8; k -= 4) {
325 TF_D(A, B, C, D, m_RK[k - 2], m_RK[k - 1], m_SB);
326 TF_D(C, D, A, B, m_RK[k - 4], m_RK[k - 3], m_SB);
327 }
328
329 C ^= m_RK[0];
330 D ^= m_RK[1];
331 A ^= m_RK[2];
332 B ^= m_RK[3];
333
334 store_le(out, C, D, A, B);
335 }
336}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
constexpr auto store_le(ParamTs &&... params)
Definition loadstor.h:736
constexpr auto load_le(ParamTs &&... params)
Definition loadstor.h:495

References Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 >::assert_key_material_set(), Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 >::BLOCK_SIZE, BOTAN_ASSERT_NOMSG, Botan::load_le(), and Botan::store_le().

◆ decrypt_n_xex()

void Botan::BlockCipher::decrypt_n_xex ( uint8_t data[],
const uint8_t mask[],
size_t blocks ) const
inlineinherited

Decrypt blocks in XEX mode: XOR with the mask, decrypt, then XOR again

Parameters
datathe input/output buffer of blocks*block_size() bytes
maskthe mask to XOR with, same size as data
blocksthe number of blocks to process

Definition at line 189 of file block_cipher.h.

189 {
190 const size_t BS = block_size();
191 for(size_t i = 0; i != blocks * BS; ++i) {
192 data[i] ^= mask[i];
193 }
195 for(size_t i = 0; i != blocks * BS; ++i) {
196 data[i] ^= mask[i];
197 }
198 }

◆ encrypt() [1/4]

void Botan::BlockCipher::encrypt ( const uint8_t in[],
uint8_t out[] ) const
inlineinherited

Encrypt a block.

Parameters
inThe plaintext block to be encrypted as a byte array. Must be of length block_size().
outThe byte array designated to hold the encrypted block. Must be of length block_size().

Definition at line 87 of file block_cipher.h.

87{ encrypt_n(in, out, 1); }
virtual void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const=0

◆ encrypt() [2/4]

void Botan::BlockCipher::encrypt ( std::span< const uint8_t > in,
std::span< uint8_t > out ) const
inlineinherited

Encrypt one or more blocks

Parameters
inthe input buffer (multiple of block_size())
outthe output buffer (same size as in)

Definition at line 135 of file block_cipher.h.

135 {
136 return encrypt_n(in.data(), out.data(), in.size() / block_size());
137 }

◆ encrypt() [3/4]

void Botan::BlockCipher::encrypt ( std::span< uint8_t > block) const
inlineinherited

Encrypt one or more blocks

Parameters
Block Ciphersthe input/output buffer (multiple of block_size())

Definition at line 118 of file block_cipher.h.

118 {
119 return encrypt_n(block.data(), block.data(), block.size() / block_size());
120 }

◆ encrypt() [4/4]

void Botan::BlockCipher::encrypt ( uint8_t block[]) const
inlineinherited

Encrypt a block.

Parameters
Block Ciphersthe plaintext block to be encrypted Must be of length block_size(). Will hold the result when the function has finished.

Definition at line 104 of file block_cipher.h.

104{ encrypt_n(block, block, 1); }

◆ encrypt_n()

void Botan::Twofish::encrypt_n ( const uint8_t in[],
uint8_t out[],
size_t blocks ) const
overridevirtual

Encrypt one or more blocks

Parameters
inthe input buffer (multiple of block_size())
outthe output buffer (same size as in)
blocksthe number of blocks to process

Implements Botan::BlockCipher.

Definition at line 173 of file twofish.cpp.

173 {
175
176#if defined(BOTAN_HAS_TWOFISH_AVX512)
177 if(!m_QS.empty()) {
178 return avx512_encrypt(in, out, blocks);
179 }
180#endif
181
182 BOTAN_ASSERT_NOMSG(!m_SB.empty());
183
184 while(blocks >= 2) {
185 uint32_t A0 = 0;
186 uint32_t B0 = 0;
187 uint32_t C0 = 0;
188 uint32_t D0 = 0;
189 uint32_t A1 = 0;
190 uint32_t B1 = 0;
191 uint32_t C1 = 0;
192 uint32_t D1 = 0;
193 load_le(in, A0, B0, C0, D0, A1, B1, C1, D1);
194
195 A0 ^= m_RK[0];
196 A1 ^= m_RK[0];
197 B0 ^= m_RK[1];
198 B1 ^= m_RK[1];
199 C0 ^= m_RK[2];
200 C1 ^= m_RK[2];
201 D0 ^= m_RK[3];
202 D1 ^= m_RK[3];
203
204 for(size_t k = 8; k != 40; k += 4) {
205 TF_E(A0, B0, C0, D0, m_RK[k + 0], m_RK[k + 1], m_SB);
206 TF_E(A1, B1, C1, D1, m_RK[k + 0], m_RK[k + 1], m_SB);
207
208 TF_E(C0, D0, A0, B0, m_RK[k + 2], m_RK[k + 3], m_SB);
209 TF_E(C1, D1, A1, B1, m_RK[k + 2], m_RK[k + 3], m_SB);
210 }
211
212 C0 ^= m_RK[4];
213 C1 ^= m_RK[4];
214 D0 ^= m_RK[5];
215 D1 ^= m_RK[5];
216 A0 ^= m_RK[6];
217 A1 ^= m_RK[6];
218 B0 ^= m_RK[7];
219 B1 ^= m_RK[7];
220
221 store_le(out, C0, D0, A0, B0, C1, D1, A1, B1);
222
223 blocks -= 2;
224 out += 2 * BLOCK_SIZE;
225 in += 2 * BLOCK_SIZE;
226 }
227
228 if(blocks > 0) {
229 uint32_t A = 0;
230 uint32_t B = 0;
231 uint32_t C = 0;
232 uint32_t D = 0;
233 load_le(in, A, B, C, D);
234
235 A ^= m_RK[0];
236 B ^= m_RK[1];
237 C ^= m_RK[2];
238 D ^= m_RK[3];
239
240 for(size_t k = 8; k != 40; k += 4) {
241 TF_E(A, B, C, D, m_RK[k], m_RK[k + 1], m_SB);
242 TF_E(C, D, A, B, m_RK[k + 2], m_RK[k + 3], m_SB);
243 }
244
245 C ^= m_RK[4];
246 D ^= m_RK[5];
247 A ^= m_RK[6];
248 B ^= m_RK[7];
249
250 store_le(out, C, D, A, B);
251 }
252}

References Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 >::assert_key_material_set(), Botan::Block_Cipher_Fixed_Params< 16, 16, 32, 8 >::BLOCK_SIZE, BOTAN_ASSERT_NOMSG, Botan::load_le(), and Botan::store_le().

◆ encrypt_n_xex()

void Botan::BlockCipher::encrypt_n_xex ( uint8_t data[],
const uint8_t mask[],
size_t blocks ) const
inlineinherited

Encrypt blocks in XEX mode: XOR with the mask, encrypt, then XOR again

Parameters
datathe input/output buffer of blocks*block_size() bytes
maskthe mask to XOR with, same size as data
blocksthe number of blocks to process

Definition at line 171 of file block_cipher.h.

171 {
172 const size_t BS = block_size();
173 for(size_t i = 0; i != blocks * BS; ++i) {
174 data[i] ^= mask[i];
175 }
177 for(size_t i = 0; i != blocks * BS; ++i) {
178 data[i] ^= mask[i];
179 }
180 }

◆ has_keying_material()

bool Botan::Twofish::has_keying_material ( ) const
overridevirtual

Test whether a key has been set on this object

Returns
true if a key has been set on this object

Implements Botan::SymmetricAlgorithm.

Definition at line 338 of file twofish.cpp.

338 {
339 return !m_RK.empty();
340}

◆ key_spec()

Key_Length_Specification Botan::Block_Cipher_Fixed_Params< BS, KMIN, KMAX, KMOD, BlockCipher >::key_spec ( ) const
inlinefinalvirtualinherited

Return the key lengths supported by this cipher

Returns
the fixed key length specification

Implements Botan::SymmetricAlgorithm.

Definition at line 246 of file block_cipher.h.

◆ maximum_keylength()

size_t Botan::SymmetricAlgorithm::maximum_keylength ( ) const
inlineinherited

Return the largest acceptable key length

Returns
maximum allowed key length

Definition at line 130 of file sym_algo.h.

130{ return key_spec().maximum_keylength(); }
Key_Length_Specification key_spec() const final
size_t maximum_keylength() const
Definition sym_algo.h:58

◆ minimum_keylength()

size_t Botan::SymmetricAlgorithm::minimum_keylength ( ) const
inlineinherited

Return the smallest acceptable key length

Returns
minimum allowed key length

Definition at line 136 of file sym_algo.h.

136{ return key_spec().minimum_keylength(); }
size_t minimum_keylength() const
Definition sym_algo.h:52

◆ name()

std::string Botan::Twofish::name ( ) const
inlineoverridevirtual

Return the name of this algorithm

Returns
the algorithm name

Implements Botan::SymmetricAlgorithm.

Definition at line 27 of file twofish.h.

27{ return "Twofish"; }

◆ new_object()

std::unique_ptr< BlockCipher > Botan::Twofish::new_object ( ) const
inlineoverridevirtual

Create a new uninitialized object of the same type

Returns
new object representing the same algorithm as *this

Implements Botan::BlockCipher.

Definition at line 29 of file twofish.h.

29{ return std::make_unique<Twofish>(); }

◆ parallel_bytes()

size_t Botan::BlockCipher::parallel_bytes ( ) const
inlineinherited

Return the preferred input size for bulk processing

Returns
preferred parallelism of this cipher in bytes

Definition at line 71 of file block_cipher.h.

◆ parallelism()

size_t Botan::Twofish::parallelism ( ) const
overridevirtual

Return how many blocks this cipher processes in parallel

Returns
native parallelism of this cipher in blocks

Reimplemented from Botan::BlockCipher.

Definition at line 351 of file twofish.cpp.

351 {
352#if defined(BOTAN_HAS_TWOFISH_AVX512)
354 return 16;
355 }
356#endif
357 return 1;
358}
static bool has(CPUID::Feature feat)
Definition cpuid.h:93

References Botan::CPUFeature::AVX512, Botan::CPUFeature::GFNI, and Botan::CPUID::has().

◆ provider()

std::string Botan::Twofish::provider ( ) const
overridevirtual

Return the name of the provider implementing this object

Returns
provider information about this implementation. Default is "base", might also return "sse2", "avx2", "openssl", or some other arbitrary string.

Reimplemented from Botan::BlockCipher.

Definition at line 342 of file twofish.cpp.

342 {
343#if defined(BOTAN_HAS_TWOFISH_AVX512)
345 return "avx512";
346 }
347#endif
348 return "base";
349}

References Botan::CPUFeature::AVX512, Botan::CPUFeature::GFNI, and Botan::CPUID::has().

◆ providers()

std::vector< std::string > Botan::BlockCipher::providers ( std::string_view algo_spec)
staticinherited

List the providers available for a given block cipher

Returns
list of available providers for this algorithm, empty if not available
Parameters
algo_specalgorithm name

Definition at line 45 of file block_cipher.cpp.

278 {
279 return probe_providers_of<BlockCipher>(algo, {"base", "commoncrypto"});
280}
std::vector< std::string > probe_providers_of(std::string_view algo_spec, const std::vector< std::string > &possible={"base"})

◆ set_key() [1/3]

void Botan::SymmetricAlgorithm::set_key ( const OctetString & key)
inherited

Set the symmetric key of this object.

Parameters
keythe SymmetricKey to be set.

Definition at line 149 of file sym_algo.cpp.

14 {
15 set_key(std::span{key.begin(), key.length()});
16}

◆ set_key() [2/3]

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

Set the symmetric key of this object.

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

Definition at line 162 of file sym_algo.h.

◆ set_key() [3/3]

void Botan::SymmetricAlgorithm::set_key ( std::span< const uint8_t > key)
inherited

Set the symmetric key of this object.

Parameters
keythe contiguous byte range to be set.

Definition at line 155 of file sym_algo.cpp.

22 {
23 if(!valid_keylength(key.size())) {
24 throw Invalid_Key_Length(name(), key.size());
25 }
27}

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

143{ return key_spec().valid_keylength(length); }
bool valid_keylength(size_t length) const
Definition sym_algo.h:44

Member Data Documentation

◆ ParallelismMult

size_t Botan::BlockCipher::ParallelismMult
staticconstexprinherited

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 53 of file block_cipher.h.


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