chovy-sign/CHOVY-KIRK/crypto.h

57 lines
1.9 KiB
C

#ifndef __RIJNDAEL_H
#define __RIJNDAEL_H
#include "kirk_engine.h"
#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
/* 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 */
} AES_ctx;
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, u8 *src, u8 *dst, int size);
void AES_cbc_decrypt(AES_ctx *ctx, u8 *src, u8 *dst, int size);
void AES_CMAC(AES_ctx *ctx, unsigned char *input, int length, unsigned char *mac);
void rijndael_encrypt(AES_ctx* ctx, const u8* src, u8* dst);
void rijndael_decrypt(AES_ctx* ctx, const u8* src, u8* dst);
int rijndael_set_key(AES_ctx* ctx, const u8* key, int bits);
typedef struct SHA1Context
{
unsigned Message_Digest[5]; /* Message Digest (output) */
unsigned Length_Low; /* Message length in bits */
unsigned Length_High; /* Message length in bits */
unsigned char Message_Block[64]; /* 512-bit message blocks */
int Message_Block_Index; /* Index into message block array */
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the message digest corruped? */
} SHA1Context;
/*
* Function Prototypes
*/
void SHA1Reset(SHA1Context *);
void SHA1Input(SHA1Context *, const unsigned char *, unsigned);
int SHA1Result(SHA1Context *);
void SHA1(unsigned char *d, size_t n, unsigned char *md);
#endif /* __RIJNDAEL_H */