-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaes-cpu.h
49 lines (29 loc) · 809 Bytes
/
aes-cpu.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
/*
*
* Implements AES CTR.
* To compile and run:
* gcc aes-cpu.c && ./a.out
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#define KEY_SIZE 128
#define N_ROUND 10
#define DEBUG 0
#define ROTL8(x,shift) ((uint8_t) ((x) << (shift)) | ((x) >> (8 - (shift))))
typedef struct CipherBlock
{
uint64_t lo;
uint64_t hi;
} CBlock_t; /* 16-byte fixed size block */
static uint8_t* sbox;
/* Manages CTR states */
static CBlock_t* nonce;
/* use this:
* filename - plain text input file name
* ivname - file name of iv text file that contains 16 byte hex
* keyname - file name of key text file that contains 16 byte hex
* outname - file name of output file
*/
double AESCTREncFile(const char* filename, const char* ivname, const char* keyname, const char* outname);