-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaes.h
33 lines (24 loc) · 790 Bytes
/
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
#ifndef _H_AES
#define _H_AES
#include <stdint.h>
#define AES_NB 4
#define MAX_NK 8
#define MAX_NR 14
#define _AES_BLOCK_SIZE (AES_NB << 2)
typedef struct {
uint8_t rd_key[(MAX_NR + 1) * AES_NB * 4];
uint8_t inv_rd_key[(MAX_NR + 1) * AES_NB * 4];
int rounds;
} _AES_KEY;
typedef struct aes_st {
_AES_KEY key;
uint8_t ivec[_AES_BLOCK_SIZE];
void (*encrypt)(void *in, void *out, struct aes_st *ctx);
void (*decrypt)(void *in, void *out, struct aes_st *ctx);
} _AES_CTX;
void expand_key(_AES_KEY *key, void *_init_key, int bits);
void _AES_ecb_encrypt(void *in, void *out, _AES_CTX *ctx);
void _AES_ecb_decrypt(void *in, void *out, _AES_CTX *ctx);
void _AES_cbc_encrypt(void *in, void *out, _AES_CTX *ctx);
void _AES_cbc_decrypt(void *in, void *out, _AES_CTX *ctx);
#endif