/src/botan/build/include/botan/internal/aes.h
Line | Count | Source (jump to first uncovered line) |
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 AES_128 final : public Block_Cipher_Fixed_Params<16, 16> { |
19 | | public: |
20 | | void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
21 | | void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
22 | | |
23 | | void clear() override; |
24 | | |
25 | | std::string provider() const override; |
26 | | |
27 | 0 | std::string name() const override { return "AES-128"; } |
28 | | |
29 | 0 | std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<AES_128>(); } |
30 | | |
31 | | size_t parallelism() const override; |
32 | | |
33 | | bool has_keying_material() const override; |
34 | | |
35 | | private: |
36 | | void key_schedule(const uint8_t key[], size_t length) override; |
37 | | |
38 | | #if defined(BOTAN_HAS_AES_VPERM) |
39 | | void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
40 | | void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
41 | | void vperm_key_schedule(const uint8_t key[], size_t length); |
42 | | #endif |
43 | | |
44 | | #if defined(BOTAN_HAS_AES_NI) |
45 | | void aesni_key_schedule(const uint8_t key[], size_t length); |
46 | | #endif |
47 | | |
48 | | #if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI) |
49 | | void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
50 | | void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
51 | | #endif |
52 | | |
53 | | secure_vector<uint32_t> m_EK, m_DK; |
54 | | }; |
55 | | |
56 | | /** |
57 | | * AES-192 |
58 | | */ |
59 | | class AES_192 final : public Block_Cipher_Fixed_Params<16, 24> { |
60 | | public: |
61 | | void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
62 | | void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
63 | | |
64 | | void clear() override; |
65 | | |
66 | | std::string provider() const override; |
67 | | |
68 | 0 | std::string name() const override { return "AES-192"; } |
69 | | |
70 | 0 | std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<AES_192>(); } |
71 | | |
72 | | size_t parallelism() const override; |
73 | | bool has_keying_material() const override; |
74 | | |
75 | | private: |
76 | | #if defined(BOTAN_HAS_AES_VPERM) |
77 | | void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
78 | | void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
79 | | void vperm_key_schedule(const uint8_t key[], size_t length); |
80 | | #endif |
81 | | |
82 | | #if defined(BOTAN_HAS_AES_NI) |
83 | | void aesni_key_schedule(const uint8_t key[], size_t length); |
84 | | #endif |
85 | | |
86 | | #if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI) |
87 | | void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
88 | | void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
89 | | #endif |
90 | | |
91 | | void key_schedule(const uint8_t key[], size_t length) override; |
92 | | |
93 | | secure_vector<uint32_t> m_EK, m_DK; |
94 | | }; |
95 | | |
96 | | /** |
97 | | * AES-256 |
98 | | */ |
99 | | class AES_256 final : public Block_Cipher_Fixed_Params<16, 32> { |
100 | | public: |
101 | | void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
102 | | void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override; |
103 | | |
104 | | void clear() override; |
105 | | |
106 | | std::string provider() const override; |
107 | | |
108 | 0 | std::string name() const override { return "AES-256"; } |
109 | | |
110 | 0 | std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<AES_256>(); } |
111 | | |
112 | | size_t parallelism() const override; |
113 | | bool has_keying_material() const override; |
114 | | |
115 | | private: |
116 | | #if defined(BOTAN_HAS_AES_VPERM) |
117 | | void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
118 | | void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
119 | | void vperm_key_schedule(const uint8_t key[], size_t length); |
120 | | #endif |
121 | | |
122 | | #if defined(BOTAN_HAS_AES_NI) |
123 | | void aesni_key_schedule(const uint8_t key[], size_t length); |
124 | | #endif |
125 | | |
126 | | #if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI) |
127 | | void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
128 | | void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const; |
129 | | #endif |
130 | | |
131 | | void key_schedule(const uint8_t key[], size_t length) override; |
132 | | |
133 | | secure_vector<uint32_t> m_EK, m_DK; |
134 | | }; |
135 | | |
136 | | } // namespace Botan |
137 | | |
138 | | #endif |