Rizin
unix-like reverse engineering framework and cli tools
aes.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2001, 2013 Niels Möller
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 /* aes.h
5 
6  The aes/rijndael block cipher.
7 
8  Copyright (C) 2001, 2013 Niels Möller
9 
10  This file is part of GNU Nettle.
11 
12  GNU Nettle is free software: you can redistribute it and/or
13  modify it under the terms of either:
14 
15  * the GNU Lesser General Public License as published by the Free
16  Software Foundation; either version 3 of the License, or (at your
17  option) any later version.
18 
19  or
20 
21  * the GNU General Public License as published by the Free
22  Software Foundation; either version 2 of the License, or (at your
23  option) any later version.
24 
25  or both in parallel, as here.
26 
27  GNU Nettle is distributed in the hope that it will be useful,
28  but WITHOUT ANY WARRANTY; without even the implied warranty of
29  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30  General Public License for more details.
31 
32  You should have received copies of the GNU General Public License and
33  the GNU Lesser General Public License along with this program. If
34  not, see http://www.gnu.org/licenses/.
35 */
36 
37 #ifndef NETTLE_AES_H_INCLUDED
38 #define NETTLE_AES_H_INCLUDED
39 
40 #include "nettle-types.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /* Name mangling */
47 #define aes_set_encrypt_key nettle_aes_set_encrypt_key
48 #define aes_set_decrypt_key nettle_aes_set_decrypt_key
49 #define aes_invert_key nettle_aes_invert_key
50 #define aes_encrypt nettle_aes_encrypt
51 #define aes_decrypt nettle_aes_decrypt
52 #define aes128_set_encrypt_key nettle_aes128_set_encrypt_key
53 #define aes128_set_decrypt_key nettle_aes128_set_decrypt_key
54 #define aes128_invert_key nettle_aes128_invert_key
55 #define aes128_encrypt nettle_aes128_encrypt
56 #define aes128_decrypt nettle_aes128_decrypt
57 #define aes192_set_encrypt_key nettle_aes192_set_encrypt_key
58 #define aes192_set_decrypt_key nettle_aes192_set_decrypt_key
59 #define aes192_invert_key nettle_aes192_invert_key
60 #define aes192_encrypt nettle_aes192_encrypt
61 #define aes192_decrypt nettle_aes192_decrypt
62 #define aes256_set_encrypt_key nettle_aes256_set_encrypt_key
63 #define aes256_set_decrypt_key nettle_aes256_set_decrypt_key
64 #define aes256_invert_key nettle_aes256_invert_key
65 #define aes256_encrypt nettle_aes256_encrypt
66 #define aes256_decrypt nettle_aes256_decrypt
67 
68 #define AES_BLOCK_SIZE 16
69 
70 #define AES128_KEY_SIZE 16
71 #define AES192_KEY_SIZE 24
72 #define AES256_KEY_SIZE 32
73 #define _AES128_ROUNDS 10
74 #define _AES192_ROUNDS 12
75 #define _AES256_ROUNDS 14
76 
77 struct aes128_ctx
78 {
80 };
81 
82 void
84 void
86 void
88  const struct aes128_ctx *src);
89 void
91  size_t length, uint8_t *dst,
92  const uint8_t *src);
93 void
95  size_t length, uint8_t *dst,
96  const uint8_t *src);
97 
98 struct aes192_ctx
99 {
101 };
102 
103 void
105 void
107 void
109  const struct aes192_ctx *src);
110 void
112  size_t length, uint8_t *dst,
113  const uint8_t *src);
114 void
116  size_t length, uint8_t *dst,
117  const uint8_t *src);
118 
120 {
122 };
123 
124 void
126 void
128 void
130  const struct aes256_ctx *src);
131 void
133  size_t length, uint8_t *dst,
134  const uint8_t *src);
135 void
137  size_t length, uint8_t *dst,
138  const uint8_t *src);
139 
140 /* The older nettle-2.7 AES interface is deprecated, please migrate to
141  the newer interface where each algorithm has a fixed key size. */
142 
143 /* Variable key size between 128 and 256 bits. But the only valid
144  * values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */
145 #define AES_MIN_KEY_SIZE AES128_KEY_SIZE
146 #define AES_MAX_KEY_SIZE AES256_KEY_SIZE
147 
148 #define AES_KEY_SIZE 32
149 
150 struct aes_ctx
151 {
152  unsigned key_size; /* In octets */
153  union {
154  struct aes128_ctx ctx128;
155  struct aes192_ctx ctx192;
156  struct aes256_ctx ctx256;
157  } u;
158 };
159 
160 void
162  size_t length, const uint8_t *key)
164 
165 void
167  size_t length, const uint8_t *key)
169 
170 void
171 aes_invert_key(struct aes_ctx *dst,
172  const struct aes_ctx *src)
174 
175 void
176 aes_encrypt(const struct aes_ctx *ctx,
177  size_t length, uint8_t *dst,
179 void
180 aes_decrypt(const struct aes_ctx *ctx,
181  size_t length, uint8_t *dst,
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #endif /* NETTLE_AES_H_INCLUDED */
#define _NETTLE_ATTRIBUTE_DEPRECATED
#define aes192_encrypt
Definition: aes.h:60
#define aes256_decrypt
Definition: aes.h:66
#define aes192_set_decrypt_key
Definition: aes.h:58
#define aes_encrypt
Definition: aes.h:50
#define aes_invert_key
Definition: aes.h:49
#define aes128_set_decrypt_key
Definition: aes.h:53
#define _AES192_ROUNDS
Definition: aes.h:74
#define aes_set_encrypt_key
Definition: aes.h:47
#define aes256_encrypt
Definition: aes.h:65
#define aes_decrypt
Definition: aes.h:51
#define aes128_set_encrypt_key
Definition: aes.h:52
#define aes256_set_decrypt_key
Definition: aes.h:63
#define aes128_invert_key
Definition: aes.h:54
#define aes192_set_encrypt_key
Definition: aes.h:57
#define _AES128_ROUNDS
Definition: aes.h:73
#define aes256_set_encrypt_key
Definition: aes.h:62
#define _AES256_ROUNDS
Definition: aes.h:75
#define aes128_decrypt
Definition: aes.h:56
#define aes_set_decrypt_key
Definition: aes.h:48
#define aes256_invert_key
Definition: aes.h:64
#define aes192_decrypt
Definition: aes.h:61
#define aes128_encrypt
Definition: aes.h:55
#define aes192_invert_key
Definition: aes.h:59
lzma_index * src
Definition: index.h:567
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
char * dst
Definition: lz4.h:724
unsigned int uint32_t
Definition: sftypes.h:29
unsigned char uint8_t
Definition: sftypes.h:31
Definition: aes.h:78
uint32_t keys[4 *(_AES128_ROUNDS+1)]
Definition: aes.h:79
Definition: aes.h:99
uint32_t keys[4 *(_AES192_ROUNDS+1)]
Definition: aes.h:100
uint32_t keys[4 *(_AES256_ROUNDS+1)]
Definition: aes.h:121
Definition: aes.h:151
struct aes128_ctx ctx128
Definition: aes.h:154
union aes_ctx::@422 u
struct aes256_ctx ctx256
Definition: aes.h:156
unsigned key_size
Definition: aes.h:152
struct aes192_ctx ctx192
Definition: aes.h:155