CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/ext/libkirk/AES.h
Views: 1401
#ifndef __RIJNDAEL_H1#define __RIJNDAEL_H23#include "kirk_engine.h"45#define AES_KEY_LEN_128 (128)6#define AES_KEY_LEN_192 (192)7#define AES_KEY_LEN_256 (256)89#define AES_BUFFER_SIZE (16)1011#define AES_MAXKEYBITS (256)12#define AES_MAXKEYBYTES (AES_MAXKEYBITS/8)13/* for 256-bit keys, fewer for less */14#define AES_MAXROUNDS 1415#define pwuAESContextBuffer rijndael_ctx1617/* The structure for key information */18typedef struct19{20int enc_only; /* context contains only encrypt schedule */21int Nr; /* key-length-dependent number of rounds */22u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */23u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */24} rijndael_ctx;2526typedef struct27{28int enc_only; /* context contains only encrypt schedule */29int Nr; /* key-length-dependent number of rounds */30u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */31u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */32} AES_ctx;3334int rijndael_set_key(rijndael_ctx *, const u8 *, int);35int rijndael_set_key_enc_only(rijndael_ctx *, const u8 *, int);36void rijndael_decrypt(rijndael_ctx *, const u8 *, u8 *);37void rijndael_encrypt(rijndael_ctx *, const u8 *, u8 *);3839int AES_set_key(AES_ctx *ctx, const u8 *key, int bits);40void AES_encrypt(AES_ctx *ctx, const u8 *src, u8 *dst);41void AES_decrypt(AES_ctx *ctx, const u8 *src, u8 *dst);42void AES_cbc_encrypt(AES_ctx *ctx, const u8 *src, u8 *dst, int size);43void AES_cbc_decrypt(AES_ctx *ctx, const u8 *src, u8 *dst, int size);44void AES_CMAC(AES_ctx *ctx, unsigned char *input, int length, unsigned char *mac);4546int rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int);47int rijndaelKeySetupDec(unsigned int [], const unsigned char [], int);48void rijndaelEncrypt(const unsigned int [], int, const unsigned char [],49unsigned char []);5051#endif /* __RIJNDAEL_H */525354