Botan 2.13.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 BOTAN_FUTURE_INTERNAL_HEADER(aes.h)
14
15 namespace Botan {
16
17 /**
18 * AES-128
19 */
20 class BOTAN_PUBLIC_API(2,0) AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
21 {
22 public:
23 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
24 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
25
26 void clear() override;
27
28 std::string provider() const override;
29 std::string name() const override { return "AES-128"; }
30 BlockCipher* clone() const override { return new AES_128; }
31 size_t parallelism() const override;
32
33 private:
34 void key_schedule(const uint8_t key[], size_t length) override;
35
36 #if defined(BOTAN_HAS_AES_VPERM)
37 void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
38 void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
39 void vperm_key_schedule(const uint8_t key[], size_t length);
40 #endif
41
42 #if defined(BOTAN_HAS_AES_NI)
43 void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
44 void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
45 void aesni_key_schedule(const uint8_t key[], size_t length);
46 #endif
47
48 #if defined(BOTAN_HAS_AES_ARMV8)
49 void armv8_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
50 void armv8_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
51 #endif
52
53 #if defined(BOTAN_HAS_AES_POWER8)
54 void power8_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
55 void power8_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
56 #endif
57
58 secure_vector<uint32_t> m_EK, m_DK;
59 secure_vector<uint8_t> m_ME, m_MD;
60 };
61
62 /**
63 * AES-192
64 */
65 class BOTAN_PUBLIC_API(2,0) AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
66 {
67 public:
68 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
69 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
70
71 void clear() override;
72
73 std::string provider() const override;
74 std::string name() const override { return "AES-192"; }
75 BlockCipher* clone() const override { return new AES_192; }
76 size_t parallelism() const override;
77
78 private:
79 #if defined(BOTAN_HAS_AES_VPERM)
80 void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
81 void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
82 void vperm_key_schedule(const uint8_t key[], size_t length);
83 #endif
84
85 #if defined(BOTAN_HAS_AES_NI)
86 void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
87 void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
88 void aesni_key_schedule(const uint8_t key[], size_t length);
89 #endif
90
91 #if defined(BOTAN_HAS_AES_ARMV8)
92 void armv8_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
93 void armv8_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
94 #endif
95
96 #if defined(BOTAN_HAS_AES_POWER8)
97 void power8_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
98 void power8_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
99 #endif
100
101 void key_schedule(const uint8_t key[], size_t length) override;
102
103 secure_vector<uint32_t> m_EK, m_DK;
104 secure_vector<uint8_t> m_ME, m_MD;
105 };
106
107 /**
108 * AES-256
109 */
110 class BOTAN_PUBLIC_API(2,0) AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
111 {
112 public:
113 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
114 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
115
116 void clear() override;
117
118 std::string provider() const override;
119
120 std::string name() const override { return "AES-256"; }
121 BlockCipher* clone() const override { return new AES_256; }
122 size_t parallelism() const override;
123
124 private:
125 #if defined(BOTAN_HAS_AES_VPERM)
126 void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
127 void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
128 void vperm_key_schedule(const uint8_t key[], size_t length);
129 #endif
130
131 #if defined(BOTAN_HAS_AES_NI)
132 void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
133 void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
134 void aesni_key_schedule(const uint8_t key[], size_t length);
135 #endif
136
137 #if defined(BOTAN_HAS_AES_ARMV8)
138 void armv8_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
139 void armv8_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
140 #endif
141
142 #if defined(BOTAN_HAS_AES_POWER8)
143 void power8_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
144 void power8_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
145 #endif
146
147 void key_schedule(const uint8_t key[], size_t length) override;
148
149 secure_vector<uint32_t> m_EK, m_DK;
150 secure_vector<uint8_t> m_ME, m_MD;
151 };
152
153 }
154
155 #endif
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
Botan::AES_128
Definition: aes.h:20
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan::AES_256::name
std::string name() const override
Definition: aes.h:120
Botan::AES_256::clone
BlockCipher * clone() const override
Definition: aes.h:121
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:65
Botan::AES_192
Definition: aes.h:65
Botan::AES_128::name
std::string name() const override
Definition: aes.h:29
Botan::AES_128::clone
BlockCipher * clone() const override
Definition: aes.h:30
Botan
Definition: alg_id.cpp:13
Botan::AES_192::clone
BlockCipher * clone() const override
Definition: aes.h:75
Botan::AES_256
Definition: aes.h:110
Botan::Block_Cipher_Fixed_Params
Definition: block_cipher.h:221
Botan::AES_192::name
std::string name() const override
Definition: aes.h:74
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139
Botan::BlockCipher
Definition: block_cipher.h:21