Botan 2.19.2
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
14
15namespace Botan {
16
17/**
18* AES-128
19*/
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*/
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*/
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
BlockCipher * clone() const override
Definition: aes.h:30
std::string name() const override
Definition: aes.h:29
BlockCipher * clone() const override
Definition: aes.h:67
std::string name() const override
Definition: aes.h:66
BlockCipher * clone() const override
Definition: aes.h:105
std::string name() const override
Definition: aes.h:104
virtual void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const =0
virtual void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const =0
virtual size_t parallelism() const
Definition: block_cipher.h:59
virtual std::string provider() const
Definition: block_cipher.h:73
virtual void clear()=0
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65