• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 13215274653

08 Feb 2025 11:38AM UTC coverage: 91.655% (-0.009%) from 91.664%
13215274653

Pull #4650

github

web-flow
Merge 107f31833 into bc555cd3c
Pull Request #4650: Reorganize code and reduce header dependencies

94836 of 103471 relevant lines covered (91.65%)

11230958.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.78
/src/lib/block/aes/aes.h
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
#include <botan/secmem.h>
13

14
namespace Botan {
15

16
/**
17
* AES-128
18
*/
19
class AES_128 final : public Block_Cipher_Fixed_Params<16, 16> {
524✔
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

28
      std::string name() const override { return "AES-128"; }
19,481✔
29

30
      std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<AES_128>(); }
5,072✔
31

32
      size_t parallelism() const override;
33

34
      bool has_keying_material() const override;
35

36
   private:
37
      void key_schedule(std::span<const uint8_t> key) override;
38

39
#if defined(BOTAN_HAS_AES_VPERM)
40
      void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
41
      void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
42
      void vperm_key_schedule(const uint8_t key[], size_t length);
43
#endif
44

45
#if defined(BOTAN_HAS_AES_NI)
46
      void aesni_key_schedule(const uint8_t key[], size_t length);
47
#endif
48

49
#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
50
      void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
51
      void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
52
#endif
53

54
#if defined(BOTAN_HAS_AES_VAES)
55
      void x86_vaes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
56
      void x86_vaes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
57
#endif
58

59
      secure_vector<uint32_t> m_EK, m_DK;
60
};
61

62
/**
63
* AES-192
64
*/
65
class AES_192 final : public Block_Cipher_Fixed_Params<16, 24> {
×
66
   public:
67
      void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
68
      void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
69

70
      void clear() override;
71

72
      std::string provider() const override;
73

74
      std::string name() const override { return "AES-192"; }
13,807✔
75

76
      std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<AES_192>(); }
2,045✔
77

78
      size_t parallelism() const override;
79
      bool has_keying_material() const override;
80

81
   private:
82
#if defined(BOTAN_HAS_AES_VPERM)
83
      void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
84
      void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
85
      void vperm_key_schedule(const uint8_t key[], size_t length);
86
#endif
87

88
#if defined(BOTAN_HAS_AES_NI)
89
      void aesni_key_schedule(const uint8_t key[], size_t length);
90
#endif
91

92
#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
93
      void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
94
      void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
95
#endif
96

97
#if defined(BOTAN_HAS_AES_VAES)
98
      void x86_vaes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
99
      void x86_vaes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
100
#endif
101

102
      void key_schedule(std::span<const uint8_t> key) override;
103

104
      secure_vector<uint32_t> m_EK, m_DK;
105
};
106

107
/**
108
* AES-256
109
*/
110
class AES_256 final : public Block_Cipher_Fixed_Params<16, 32> {
×
111
   public:
112
      void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
113
      void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
114

115
      void clear() override;
116

117
      std::string provider() const override;
118

119
      std::string name() const override { return "AES-256"; }
18,053✔
120

121
      std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<AES_256>(); }
2,624✔
122

123
      size_t parallelism() const override;
124
      bool has_keying_material() const override;
125

126
   private:
127
#if defined(BOTAN_HAS_AES_VPERM)
128
      void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
129
      void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
130
      void vperm_key_schedule(const uint8_t key[], size_t length);
131
#endif
132

133
#if defined(BOTAN_HAS_AES_NI)
134
      void aesni_key_schedule(const uint8_t key[], size_t length);
135
#endif
136

137
#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
138
      void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
139
      void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
140
#endif
141

142
#if defined(BOTAN_HAS_AES_VAES)
143
      void x86_vaes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
144
      void x86_vaes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
145
#endif
146

147
      void key_schedule(std::span<const uint8_t> key) override;
148

149
      secure_vector<uint32_t> m_EK, m_DK;
150
};
151

152
}  // namespace Botan
153

154
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc