ff7tk  1.2.0.13
Work with Final Fantasy 7 game data
aes.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: TinyAES Striped to support only AES for ff7tk by Chris Rizzitello <sithlord48@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 /****************************************************************************/
4 // TinyAES Striped for our specific needs //
5 // Origin: https://github.com/kokke/tiny-AES-c //
6 /****************************************************************************/
7 
8 #ifndef _AES_H_
9 #define _AES_H_
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 
17 #define AES_BLOCKLEN 16 //Block length in bytes AES is 128b block only
18 #define AES_KEYLEN 16 // Key length in bytes
19 #define AES_keyExpSize 176
20 
21 struct AES_ctx
22 {
24  uint8_t Iv[AES_BLOCKLEN];
25 };
26 
27 void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);
28 void XorWithIv(uint8_t* buf, const uint8_t* Iv);
29 void XorWithByte(uint8_t* buf, uint8_t byte, int length);
30 
31 // buffer size is exactly AES_BLOCKLEN bytes;
32 // you need only AES_init_ctx as IV is not used in ECB
33 // NB: ECB is considered insecure for most uses
34 void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
35 void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
36 
37 #ifdef __cplusplus
38 }
39 #endif
40 #endif //_AES_H_
AES_keyExpSize
#define AES_keyExpSize
Definition: aes.h:19
AES_ECB_encrypt
void AES_ECB_encrypt(const struct AES_ctx *ctx, uint8_t *buf)
Definition: aes.c:304
AES_ECB_decrypt
void AES_ECB_decrypt(const struct AES_ctx *ctx, uint8_t *buf)
Definition: aes.c:310
AES_ctx::Iv
uint8_t Iv[AES_BLOCKLEN]
Definition: aes.h:24
AES_ctx::RoundKey
uint8_t RoundKey[AES_keyExpSize]
Definition: aes.h:23
AES_init_ctx_iv
void AES_init_ctx_iv(struct AES_ctx *ctx, const uint8_t *key, const uint8_t *iv)
Definition: aes.c:133
AES_BLOCKLEN
#define AES_BLOCKLEN
Definition: aes.h:17
XorWithByte
void XorWithByte(uint8_t *buf, uint8_t byte, int length)
Definition: aes.c:323
AES_ctx
Definition: aes.h:21
XorWithIv
void XorWithIv(uint8_t *buf, const uint8_t *Iv)
Definition: aes.c:316