Botan 2.19.5 Crypto and TLS for C&

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
15namespace 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_key_schedule(const uint8_t key[], size_t length);
44#endif
45
46#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
47 void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
48 void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
49#endif
50
51 secure_vector<uint32_t> m_EK, m_DK;
52 };
53
54/**
55* AES-192
56*/
57 class BOTAN_PUBLIC_API(2,0) AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
58 {
59 public:
60 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
61 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
62
63 void clear() override;
64
65 std::string provider() const override;
66 std::string name() const override { return "AES-192"; }
67 BlockCipher* clone() const override { return new AES_192; }
68 size_t parallelism() const override;
69
70 private:
71#if defined(BOTAN_HAS_AES_VPERM)
72 void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
73 void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
74 void vperm_key_schedule(const uint8_t key[], size_t length);
75#endif
76
77#if defined(BOTAN_HAS_AES_NI)
78 void aesni_key_schedule(const uint8_t key[], size_t length);
79#endif
80
81#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
82 void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
83 void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
84#endif
85
86 void key_schedule(const uint8_t key[], size_t length) override;
87
88 secure_vector<uint32_t> m_EK, m_DK;
89 };
90
91/**
92* AES-256
93*/
94 class BOTAN_PUBLIC_API(2,0) AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
95 {
96 public:
97 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
98 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
99
100 void clear() override;
101
102 std::string provider() const override;
103
104 std::string name() const override { return "AES-256"; }
105 BlockCipher* clone() const override { return new AES_256; }
106 size_t parallelism() const override;
107
108 private:
109#if defined(BOTAN_HAS_AES_VPERM)
110 void vperm_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
111 void vperm_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
112 void vperm_key_schedule(const uint8_t key[], size_t length);
113#endif
114
115#if defined(BOTAN_HAS_AES_NI)
116 void aesni_key_schedule(const uint8_t key[], size_t length);
117#endif
118
119#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
120 void hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
121 void hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
122#endif
123
124 void key_schedule(const uint8_t key[], size_t length) override;
125
126 secure_vector<uint32_t> m_EK, m_DK;
127 };
128
129}
130
131#endif
Botan::AES_128
Definition: aes.h:21
Botan::AES_128::clone
BlockCipher * clone() const override
Definition: aes.h:30
Botan::AES_128::name
std::string name() const override
Definition: aes.h:29
Botan::AES_192
Definition: aes.h:58
Botan::AES_192::clone
BlockCipher * clone() const override
Definition: aes.h:67
Botan::AES_192::name
std::string name() const override
Definition: aes.h:66
Botan::AES_256
Definition: aes.h:95
Botan::AES_256::clone
BlockCipher * clone() const override
Definition: aes.h:105
Botan::AES_256::name
std::string name() const override
Definition: aes.h:104
Botan::BlockCipher
Definition: block_cipher.h:22
Botan::BlockCipher::decrypt_n
virtual void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const =0
Botan::BlockCipher::encrypt_n
virtual void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const =0
Botan::BlockCipher::parallelism
virtual size_t parallelism() const
Definition: block_cipher.h:59
Botan::BlockCipher::provider
virtual std::string provider() const
Definition: block_cipher.h:73
Botan::Block_Cipher_Fixed_Params
Definition: block_cipher.h:222
Botan::SymmetricAlgorithm::clear
virtual void clear()=0
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65