/src/botan/build/include/internal/botan/internal/blowfish.h
Line | Count | Source (jump to first uncovered line) |
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 | | #include <botan/secmem.h> |
13 | | |
14 | | namespace Botan { |
15 | | |
16 | | /** |
17 | | * Blowfish |
18 | | */ |
19 | | class BOTAN_TEST_API Blowfish final : public Block_Cipher_Fixed_Params<8, 1, 56> { |
20 | | public: |
21 | | void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
22 | | void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
23 | | |
24 | | /** |
25 | | * Modified EKSBlowfish key schedule, used for bcrypt password hashing |
26 | | */ |
27 | | void salted_set_key(const uint8_t key[], |
28 | | size_t key_length, |
29 | | const uint8_t salt[], |
30 | | size_t salt_length, |
31 | | size_t workfactor, |
32 | | bool salt_first = false); |
33 | | |
34 | | void clear() override; |
35 | | |
36 | 0 | std::string name() const override { return "Blowfish"; } |
37 | | |
38 | 0 | std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<Blowfish>(); } |
39 | | |
40 | | bool has_keying_material() const override; |
41 | | |
42 | | private: |
43 | | void key_schedule(std::span<const uint8_t> key) override; |
44 | | |
45 | | void key_expansion(const uint8_t key[], size_t key_length, const uint8_t salt[], size_t salt_length); |
46 | | |
47 | | void generate_sbox(secure_vector<uint32_t>& box, |
48 | | uint32_t& L, |
49 | | uint32_t& R, |
50 | | const uint8_t salt[], |
51 | | size_t salt_length, |
52 | | size_t salt_off) const; |
53 | | |
54 | | secure_vector<uint32_t> m_S, m_P; |
55 | | }; |
56 | | |
57 | | } // namespace Botan |
58 | | |
59 | | #endif |