forked from pa-pa/AskSinPP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aes.h
50 lines (39 loc) · 1.69 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
50
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// adoption of Daniel Otte's cool AVR-Crypto-Lib, Copyright (C) 2008, GPLv3 or later
// cleaned and tidied to fit the purpose for AskSin++ by trilu
//- -----------------------------------------------------------------------------------------------------------------------
#ifndef AES_H_
#define AES_H_
#include <stdint.h>
typedef struct {
uint8_t ks[16];
} aes_roundkey_t;
typedef struct {
aes_roundkey_t key[10 + 1];
} aes128_ctx_t;
typedef struct {
aes_roundkey_t key[1]; /* just to avoid the warning */
} aes_genctx_t;
typedef struct {
uint8_t s[16];
} aes_cipher_state_t;
void aes128_init(const void* key, aes128_ctx_t* ctx);
void aes128_enc(void* buffer, aes128_ctx_t* ctx);
void aes128_dec(void* buffer, aes128_ctx_t* ctx);
//-init
void aes_rotword(void* a);
void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx);
//-encrypt
void aes_shiftcol(void* data, uint8_t shift);
void aes_enc_round(aes_cipher_state_t* state, const aes_roundkey_t* k);
void aes_enc_lastround(aes_cipher_state_t* state, const aes_roundkey_t* k);
void aes_encrypt_core(aes_cipher_state_t* state, const aes_genctx_t* ks, uint8_t rounds);
//-decrypt
void aes_invshiftrow(void* data, uint8_t shift);
void aes_invshiftcol(void* data, uint8_t shift);
void aes_dec_round(aes_cipher_state_t* state, const aes_roundkey_t* k);
void aes_dec_firstround(aes_cipher_state_t* state, const aes_roundkey_t* k);
void aes_decrypt_core(aes_cipher_state_t* state, const aes_genctx_t* ks, uint8_t rounds);
#endif