Coverage Report

Created: 2021-02-21 07:20

/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
   {
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
395
      std::string name() const override { return "AES-128"; }
28
0
      BlockCipher* clone() const override { return new AES_128; }
29
      size_t parallelism() const override;
30
31
   private:
32
      void key_schedule(const uint8_t key[], size_t length) override;
33
34
#if defined(BOTAN_HAS_AES_VPERM)
35
      void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
36
      void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
37
      void vperm_key_schedule(const uint8_t key[], size_t length);
38
#endif
39
40
#if defined(BOTAN_HAS_AES_NI)
41
      void aesni_key_schedule(const uint8_t key[], size_t length);
42
#endif
43
44
#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
45
      void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
46
      void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
47
#endif
48
49
      secure_vector<uint32_t> m_EK, m_DK;
50
   };
51
52
/**
53
* AES-192
54
*/
55
class AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
56
   {
57
   public:
58
      void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
59
      void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
60
61
      void clear() override;
62
63
      std::string provider() const override;
64
0
      std::string name() const override { return "AES-192"; }
65
0
      BlockCipher* clone() const override { return new AES_192; }
66
      size_t parallelism() const override;
67
68
   private:
69
#if defined(BOTAN_HAS_AES_VPERM)
70
      void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
71
      void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
72
      void vperm_key_schedule(const uint8_t key[], size_t length);
73
#endif
74
75
#if defined(BOTAN_HAS_AES_NI)
76
      void aesni_key_schedule(const uint8_t key[], size_t length);
77
#endif
78
79
#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
80
      void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
81
      void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
82
#endif
83
84
      void key_schedule(const uint8_t key[], size_t length) override;
85
86
      secure_vector<uint32_t> m_EK, m_DK;
87
   };
88
89
/**
90
* AES-256
91
*/
92
class AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
93
   {
94
   public:
95
      void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
96
      void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
97
98
      void clear() override;
99
100
      std::string provider() const override;
101
102
717
      std::string name() const override { return "AES-256"; }
103
0
      BlockCipher* clone() const override { return new AES_256; }
104
      size_t parallelism() const override;
105
106
   private:
107
#if defined(BOTAN_HAS_AES_VPERM)
108
      void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
109
      void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
110
      void vperm_key_schedule(const uint8_t key[], size_t length);
111
#endif
112
113
#if defined(BOTAN_HAS_AES_NI)
114
      void aesni_key_schedule(const uint8_t key[], size_t length);
115
#endif
116
117
#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
118
      void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
119
      void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
120
#endif
121
122
      void key_schedule(const uint8_t key[], size_t length) override;
123
124
      secure_vector<uint32_t> m_EK, m_DK;
125
   };
126
127
}
128
129
#endif