Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

aes.h
Go to the documentation of this file.
1 /*
2 * AES
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_AES_H__
9 #define BOTAN_AES_H__
10
11 #include <botan/block_cipher.h>
12
13 namespace Botan {
14
15 /**
16 * AES-128
17 */
18 class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
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 void clear() override;
25
26 std::string provider() const override;
27 std::string name() const override { return "AES-128"; }
28 BlockCipher* clone() const override { return new AES_128; }
29 private:
30 void key_schedule(const uint8_t key[], size_t length) override;
31
32 #if defined(BOTAN_HAS_AES_SSSE3)
33 void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
34 void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
35 void ssse3_key_schedule(const uint8_t key[], size_t length);
36 #endif
37
38 #if defined(BOTAN_HAS_AES_NI)
39 void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
40 void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
41 void aesni_key_schedule(const uint8_t key[], size_t length);
42 #endif
43
44 secure_vector<uint32_t> m_EK, m_DK;
45 secure_vector<uint8_t> m_ME, m_MD;
46 };
47
48 /**
49 * AES-192
50 */
51 class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
52 {
53 public:
54 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
55 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
56
57 void clear() override;
58
59 std::string provider() const override;
60 std::string name() const override { return "AES-192"; }
61 BlockCipher* clone() const override { return new AES_192; }
62 private:
63 #if defined(BOTAN_HAS_AES_SSSE3)
64 void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
65 void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
66 void ssse3_key_schedule(const uint8_t key[], size_t length);
67 #endif
68
69 #if defined(BOTAN_HAS_AES_NI)
70 void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
71 void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
72 void aesni_key_schedule(const uint8_t key[], size_t length);
73 #endif
74
75 void key_schedule(const uint8_t key[], size_t length) override;
76
77 secure_vector<uint32_t> m_EK, m_DK;
78 secure_vector<uint8_t> m_ME, m_MD;
79 };
80
81 /**
82 * AES-256
83 */
84 class BOTAN_DLL AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
85 {
86 public:
87 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
88 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
89
90 void clear() override;
91
92 std::string provider() const override;
93
94 std::string name() const override { return "AES-256"; }
95 BlockCipher* clone() const override { return new AES_256; }
96 private:
97 #if defined(BOTAN_HAS_AES_SSSE3)
98 void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
99 void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
100 void ssse3_key_schedule(const uint8_t key[], size_t length);
101 #endif
102
103 #if defined(BOTAN_HAS_AES_NI)
104 void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
105 void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
106 void aesni_key_schedule(const uint8_t key[], size_t length);
107 #endif
108
109 void key_schedule(const uint8_t key[], size_t length) override;
110
111 secure_vector<uint32_t> m_EK, m_DK;
112 secure_vector<uint8_t> m_ME, m_MD;
113 };
114
115 }
116
117 #endif
Botan::AES_128
Definition: aes.h:18
Botan::AES_256::name
std::string name() const override
Definition: aes.h:94
Botan::AES_256::clone
BlockCipher * clone() const override
Definition: aes.h:95
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::AES_192
Definition: aes.h:51
Botan::AES_128::name
std::string name() const override
Definition: aes.h:27
Botan::AES_128::clone
BlockCipher * clone() const override
Definition: aes.h:28
Botan
Definition: alg_id.cpp:13
Botan::AES_192::clone
BlockCipher * clone() const override
Definition: aes.h:61
Botan::AES_256
Definition: aes.h:84
Botan::Block_Cipher_Fixed_Params
Definition: block_cipher.h:183
Botan::AES_192::name
std::string name() const override
Definition: aes.h:60
Botan::BlockCipher
Definition: block_cipher.h:19