CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/ext/libkirk/AES.h
Views: 1401
1
#ifndef __RIJNDAEL_H
2
#define __RIJNDAEL_H
3
4
#include "kirk_engine.h"
5
6
#define AES_KEY_LEN_128 (128)
7
#define AES_KEY_LEN_192 (192)
8
#define AES_KEY_LEN_256 (256)
9
10
#define AES_BUFFER_SIZE (16)
11
12
#define AES_MAXKEYBITS (256)
13
#define AES_MAXKEYBYTES (AES_MAXKEYBITS/8)
14
/* for 256-bit keys, fewer for less */
15
#define AES_MAXROUNDS 14
16
#define pwuAESContextBuffer rijndael_ctx
17
18
/* The structure for key information */
19
typedef struct
20
{
21
int enc_only; /* context contains only encrypt schedule */
22
int Nr; /* key-length-dependent number of rounds */
23
u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */
24
u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */
25
} rijndael_ctx;
26
27
typedef struct
28
{
29
int enc_only; /* context contains only encrypt schedule */
30
int Nr; /* key-length-dependent number of rounds */
31
u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */
32
u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */
33
} AES_ctx;
34
35
int rijndael_set_key(rijndael_ctx *, const u8 *, int);
36
int rijndael_set_key_enc_only(rijndael_ctx *, const u8 *, int);
37
void rijndael_decrypt(rijndael_ctx *, const u8 *, u8 *);
38
void rijndael_encrypt(rijndael_ctx *, const u8 *, u8 *);
39
40
int AES_set_key(AES_ctx *ctx, const u8 *key, int bits);
41
void AES_encrypt(AES_ctx *ctx, const u8 *src, u8 *dst);
42
void AES_decrypt(AES_ctx *ctx, const u8 *src, u8 *dst);
43
void AES_cbc_encrypt(AES_ctx *ctx, const u8 *src, u8 *dst, int size);
44
void AES_cbc_decrypt(AES_ctx *ctx, const u8 *src, u8 *dst, int size);
45
void AES_CMAC(AES_ctx *ctx, unsigned char *input, int length, unsigned char *mac);
46
47
int rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int);
48
int rijndaelKeySetupDec(unsigned int [], const unsigned char [], int);
49
void rijndaelEncrypt(const unsigned int [], int, const unsigned char [],
50
unsigned char []);
51
52
#endif /* __RIJNDAEL_H */
53
54