ff7tk 0.80.25
Work with Final Fantasy 7 game data
aes.h
Go to the documentation of this file.
1/****************************************************************************/
2// TinyAES Striped for our specific needs //
3// Origin: https://github.com/kokke/tiny-AES-c //
4// //
5// This file is part of FF7tk //
6// //
7// FF7tk is free software: you can redistribute it and/or modify //
8// it under the terms of the GNU General Public License as published by //
9// the Free Software Foundation, either version 3 of the License, or //
10// (at your option) any later version. //
11// //
12// FF7tk is distributed in the hope that it will be useful, //
13// but WITHOUT ANY WARRANTY; without even the implied warranty of //
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
15// GNU General Public License for more details. //
16/****************************************************************************/
17#ifndef _AES_H_
18#define _AES_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <stdint.h>
25
26#define AES_BLOCKLEN 16 //Block length in bytes AES is 128b block only
27#define AES_KEYLEN 16 // Key length in bytes
28#define AES_keyExpSize 176
29
30struct AES_ctx
31{
33 uint8_t Iv[AES_BLOCKLEN];
34};
35
36void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);
37void XorWithIv(uint8_t* buf, const uint8_t* Iv);
38void XorWithByte(uint8_t* buf, uint8_t byte, int length);
39
40// buffer size is exactly AES_BLOCKLEN bytes;
41// you need only AES_init_ctx as IV is not used in ECB
42// NB: ECB is considered insecure for most uses
43void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
44void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
45
46#ifdef __cplusplus
47}
48#endif
49#endif //_AES_H_
void AES_ECB_encrypt(const struct AES_ctx *ctx, uint8_t *buf)
Definition: aes.c:370
void XorWithByte(uint8_t *buf, uint8_t byte, int length)
Definition: aes.c:391
void XorWithIv(uint8_t *buf, const uint8_t *Iv)
Definition: aes.c:382
void AES_init_ctx_iv(struct AES_ctx *ctx, const uint8_t *key, const uint8_t *iv)
Definition: aes.c:160
#define AES_keyExpSize
Definition: aes.h:28
void AES_ECB_decrypt(const struct AES_ctx *ctx, uint8_t *buf)
Definition: aes.c:376
#define AES_BLOCKLEN
Definition: aes.h:26
Definition: aes.h:31
uint8_t Iv[AES_BLOCKLEN]
Definition: aes.h:33
uint8_t RoundKey[AES_keyExpSize]
Definition: aes.h:32