Botan  2.6.0
Crypto and TLS for C++11
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 
13 namespace Botan {
14 
15 /**
16 * Blowfish
17 */
18 class BOTAN_PUBLIC_API(2,0) 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 eks_key_schedule(const uint8_t key[], size_t key_length,
28  const uint8_t salt[16], size_t workfactor);
29 
30  void clear() override;
31  std::string name() const override { return "Blowfish"; }
32  BlockCipher* clone() const override { return new Blowfish; }
33  private:
34  void key_schedule(const uint8_t key[], size_t length) override;
35 
36  void key_expansion(const uint8_t key[],
37  size_t key_length,
38  const uint8_t salt[16]);
39 
40  void generate_sbox(secure_vector<uint32_t>& box,
41  uint32_t& L, uint32_t& R,
42  const uint8_t salt[16],
43  size_t salt_off) const;
44 
45  secure_vector<uint32_t> m_S, m_P;
46  };
47 
48 }
49 
50 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
std::string name() const override
Definition: blowfish.h:31
Definition: alg_id.cpp:13
BlockCipher * clone() const override
Definition: blowfish.h:32
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88