-
Notifications
You must be signed in to change notification settings - Fork 7
/
aes.h
50 lines (35 loc) · 1.29 KB
/
aes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef AES_H_
#define AES_H_
#include <stdint.h>
#define AES_256_ROUNDS 14
#define AES_192_ROUNDS 12
#define AES_128_ROUNDS 10
// Uncomment this (or compile with -DOPT_8_BIT) to optimise for an 8 bit architecture
// #define AES_OPT_8_BIT
#ifdef AES_OPT_8_BIT
typedef uint8_t counter;
#else
typedef unsigned int counter;
#endif
// AES-256
typedef struct aes_256_context_t_ {
uint8_t round_key[(AES_256_ROUNDS + 1) * 16];
} aes_256_context_t;
void aes_256_init (aes_256_context_t *context, uint8_t key[32]);
void aes_256_encrypt (aes_256_context_t *context, uint8_t block[16]);
void aes_256_decrypt (aes_256_context_t *context, uint8_t block[16]);
// AES-192
typedef struct aes_192_context_t_ {
uint8_t round_key[(AES_192_ROUNDS + 1) * 16];
} aes_192_context_t;
void aes_192_init (aes_192_context_t *context, uint8_t key[24]);
void aes_192_encrypt (aes_192_context_t *context, uint8_t block[16]);
void aes_192_decrypt (aes_192_context_t *context, uint8_t block[16]);
// AES-128
typedef struct aes_128_context_t_ {
uint8_t round_key[(AES_128_ROUNDS + 1) * 16];
} aes_128_context_t;
void aes_128_init (aes_128_context_t *context, uint8_t key[16]);
void aes_128_encrypt (aes_128_context_t *context, uint8_t block[16]);
void aes_128_decrypt (aes_128_context_t *context, uint8_t block[16]);
#endif