Botan 3.6.1
Crypto and TLS for C&
blowfish.h
Go to the documentation of this file.
1/*
2* Blowfish
3* (C) 1999-2011 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_BLOWFISH_H_
9#define BOTAN_BLOWFISH_H_
10
11#include <botan/block_cipher.h>
12
13namespace Botan {
14
15/**
16* Blowfish
17*/
19 public:
20 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
21 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
22
23 /**
24 * Modified EKSBlowfish key schedule, used for bcrypt password hashing
25 */
26 void salted_set_key(const uint8_t key[],
27 size_t key_length,
28 const uint8_t salt[],
29 size_t salt_length,
30 size_t workfactor,
31 bool salt_first = false);
32
33 void clear() override;
34
35 std::string name() const override { return "Blowfish"; }
36
37 std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<Blowfish>(); }
38
39 bool has_keying_material() const override;
40
41 private:
42 void key_schedule(std::span<const uint8_t> key) override;
43
44 void key_expansion(const uint8_t key[], size_t key_length, const uint8_t salt[], size_t salt_length);
45
46 void generate_sbox(secure_vector<uint32_t>& box,
47 uint32_t& L,
48 uint32_t& R,
49 const uint8_t salt[],
50 size_t salt_length,
51 size_t salt_off) const;
52
54};
55
56} // namespace Botan
57
58#endif
std::unique_ptr< BlockCipher > new_object() const override
Definition blowfish.h:37
std::string name() const override
Definition blowfish.h:35
int(* final)(unsigned char *, CTX *)
#define BOTAN_TEST_API
Definition compiler.h:51
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61