Coverage Report

Created: 2025-07-18 06:20

/src/Botan-3.4.0/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
13
namespace Botan {
14
15
/**
16
* Blowfish
17
*/
18
class BOTAN_TEST_API Blowfish final : public Block_Cipher_Fixed_Params<8, 1, 56> {
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
0
      std::string name() const override { return "Blowfish"; }
36
37
0
      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
53
      secure_vector<uint32_t> m_S, m_P;
54
};
55
56
}  // namespace Botan
57
58
#endif