Botan 1.10.17

blowfish.h
Go to the documentation of this file.
1 /*
2 * Blowfish
3 * (C) 1999-2011 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
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_DLL Blowfish : public Block_Cipher_Fixed_Params<8, 1, 56>
19 {
20 public:
21 void encrypt_n(const byte in[], byte out[], size_t blocks) const;
22 void decrypt_n(const byte in[], byte out[], size_t blocks) const;
23
24 /**
25 * Modified EKSBlowfish key schedule, used for bcrypt password hashing
26 */
27 void eks_key_schedule(const byte key[], size_t key_length,
28 const byte salt[16], size_t workfactor);
29
30 void clear();
31 std::string name() const { return "Blowfish"; }
32 BlockCipher* clone() const { return new Blowfish; }
33
34 Blowfish() : S(1024), P(18) {}
35 private:
36 void key_schedule(const byte key[], size_t length);
37
38 void key_expansion(const byte key[],
39 size_t key_length,
40 const byte salt[16]);
41
42 void generate_sbox(MemoryRegion<u32bit>& box,
43 u32bit& L, u32bit& R,
44 const byte salt[16],
45 size_t salt_off) const;
46
47 static const u32bit P_INIT[18];
48 static const u32bit S_INIT[1024];
49
50 SecureVector<u32bit> S;
51 SecureVector<u32bit> P;
52 };
53
54 }
55
56 #endif
Botan::Blowfish::name
std::string name() const
Definition: blowfish.h:31
Botan::Blowfish::clone
BlockCipher * clone() const
Definition: blowfish.h:32
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::Blowfish::Blowfish
Blowfish()
Definition: blowfish.h:34
Botan::MemoryRegion< u32bit >
Botan
Definition: algo_base.h:14
Botan::Blowfish
Definition: blowfish.h:18
Botan::SecureVector< u32bit >
Botan::Block_Cipher_Fixed_Params
Definition: block_cipher.h:104
Botan::u32bit
unsigned int u32bit
Definition: types.h:32
Botan::BlockCipher
Definition: block_cipher.h:18