Coverage Report

Created: 2020-02-14 15:38

/src/botan/build/include/botan/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
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
251
      std::string name() const override { return "AES-128"; }
30
0
      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
0
      std::string name() const override { return "AES-192"; }
75
0
      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
550
      std::string name() const override { return "AES-256"; }
121
0
      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