-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaes.h
58 lines (37 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
50
51
52
53
54
55
56
57
58
//
// Created by martian on 3/13/2023.
//
#ifndef AES_AES_H
#define AES_AES_H
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define AES_N_r(N_k) \
((N_k == AES_128_N_k) ? AES_128_N_r : \
(N_k == AES_192_N_k) ? AES_192_N_r : \
(N_k == AES_256_N_k) ? AES_256_N_r : \
0)
// Extracting [i][j]th element from a two dimensional array represented as a one-dimensional array
#define GET_ELEM(arr, i, j, n) (arr[n * i + j])
/*
* Functions from aes.c
*/
extern const unsigned char N_w, N_r, N_b, N_block, N_k;
extern const uint16_t PP;
uint8_t gfadd(uint8_t x, uint8_t y);
uint8_t gfmul(uint8_t x, uint8_t y);
void KeyExpansion(const uint8_t key[], uint32_t expandedKey[]);
void EqKeyExpansion(const uint8_t key[], uint32_t dexpandedKey[]);
void CipherEncrypt(uint8_t stateArray[], const uint32_t roundKeys[]);
void InverseCipher(uint8_t stateArray[], const uint32_t roundKeys[]);
void EqInverseCipher(uint8_t stateArray[], const uint32_t droundKeys[]);
/*
* Other helper functions
*/
int gentable(void);
void print_table(uint8_t arr[], uint8_t colSize, uint8_t rowSize, char *string);
void hexify(const char *hexStr, uint8_t *byteArr, size_t byteArrLen);
void xprintf(uint8_t *byteArr, size_t byteArrLen);
void transpose(uint8_t *in);
#endif //AES_AES_H