Coverage Report

Created: 2022-11-24 06:56

/src/botan/build/include/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
   {
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[], size_t key_length,
28
                          const uint8_t salt[], size_t salt_length,
29
                          const size_t workfactor, bool salt_first = false);
30
31
      void clear() override;
32
0
      std::string name() const override { return "Blowfish"; }
33
0
      std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<Blowfish>(); }
34
   private:
35
      void key_schedule(const uint8_t key[], size_t length) override;
36
37
      void key_expansion(const uint8_t key[],
38
                         size_t key_length,
39
                         const uint8_t salt[],
40
                         size_t salt_length);
41
42
      void generate_sbox(secure_vector<uint32_t>& box,
43
                         uint32_t& L, uint32_t& R,
44
                         const uint8_t salt[],
45
                         size_t salt_length,
46
                         size_t salt_off) const;
47
48
      secure_vector<uint32_t> m_S, m_P;
49
   };
50
51
}
52
53
#endif