Botan  2.11.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 */
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  BOTAN_DEPRECATED("Use Blowfish::salted_set_key taking salt length")
32  void eks_key_schedule(const uint8_t key[], size_t key_length,
33  const uint8_t salt[16], size_t workfactor)
34  {
35  salted_set_key(key, key_length, salt, 16, workfactor);
36  }
37 
38  void clear() override;
39  std::string name() const override { return "Blowfish"; }
40  BlockCipher* clone() const override { return new Blowfish; }
41  private:
42  void key_schedule(const uint8_t key[], size_t length) override;
43 
44  void key_expansion(const uint8_t key[],
45  size_t key_length,
46  const uint8_t salt[],
47  size_t salt_length);
48 
49  void generate_sbox(secure_vector<uint32_t>& box,
50  uint32_t& L, uint32_t& R,
51  const uint8_t salt[],
52  size_t salt_length,
53  size_t salt_off) const;
54 
55  secure_vector<uint32_t> m_S, m_P;
56  };
57 
58 }
59 
60 #endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
std::string name() const override
Definition: blowfish.h:39
Definition: alg_id.cpp:13
BlockCipher * clone() const override
Definition: blowfish.h:40
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65