mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-26 06:16:24 +02:00
kirk_engine.h and amctrl.h guard their declarations, but AES.h and SHA1.h never did, and kirk_engine.h includes them from outside its own guard. So the AES_* and SHA1* functions got C++ linkage in any C++ file that reached them through there, and only linked for callers that happened to wrap the whole header in an extern "C" of their own. Nothing had called AES_* from C++ before, so it stayed hidden until something did. Guarding the two headers instead lets every caller include them plainly, and the wrappers scattered around the tree come out. Both are pure declarations over kirk_common.h's typedefs with no system headers behind them, so there's nothing in there that shouldn't be wrapped. kirk_engine.h also uses size_t without including anything that defines it, which only held together because its includers happened to have it already. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
60 lines
1.8 KiB
C
60 lines
1.8 KiB
C
#ifndef __RIJNDAEL_H
|
|
#define __RIJNDAEL_H
|
|
|
|
#include "kirk_common.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define AES_KEY_LEN_128 (128)
|
|
#define AES_KEY_LEN_192 (192)
|
|
#define AES_KEY_LEN_256 (256)
|
|
|
|
#define AES_BUFFER_SIZE (16)
|
|
|
|
#define AES_MAXKEYBITS (256)
|
|
#define AES_MAXKEYBYTES (AES_MAXKEYBITS/8)
|
|
/* for 256-bit keys, fewer for less */
|
|
#define AES_MAXROUNDS 14
|
|
#define pwuAESContextBuffer rijndael_ctx
|
|
|
|
/* The structure for key information */
|
|
typedef struct
|
|
{
|
|
int enc_only; /* context contains only encrypt schedule */
|
|
int Nr; /* key-length-dependent number of rounds */
|
|
u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */
|
|
u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */
|
|
} rijndael_ctx;
|
|
|
|
typedef struct
|
|
{
|
|
int enc_only; /* context contains only encrypt schedule */
|
|
int Nr; /* key-length-dependent number of rounds */
|
|
u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */
|
|
u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */
|
|
} AES_ctx;
|
|
|
|
int rijndael_set_key(rijndael_ctx *, const u8 *, int);
|
|
int rijndael_set_key_enc_only(rijndael_ctx *, const u8 *, int);
|
|
void rijndael_decrypt(rijndael_ctx *, const u8 *, u8 *);
|
|
void rijndael_encrypt(rijndael_ctx *, const u8 *, u8 *);
|
|
|
|
int AES_set_key(AES_ctx *ctx, const u8 *key, int bits);
|
|
void AES_encrypt(AES_ctx *ctx, const u8 *src, u8 *dst);
|
|
void AES_decrypt(AES_ctx *ctx, const u8 *src, u8 *dst);
|
|
void AES_cbc_encrypt(AES_ctx *ctx, const u8 *src, u8 *dst, int size);
|
|
void AES_cbc_decrypt(AES_ctx *ctx, const u8 *src, u8 *dst, int size);
|
|
void AES_CMAC(AES_ctx *ctx, const unsigned char *input, int length, unsigned char *mac);
|
|
|
|
int rijndaelKeySetupEnc(u32 [], const u8 [], int);
|
|
int rijndaelKeySetupDec(u32 [], const u8 [], int);
|
|
void rijndaelEncrypt(const u32 [], int, const u8 pt[16], u8 ct[16]);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __RIJNDAEL_H */
|