From 31c69b6ca1b91e7fd9fd8e14082fd2584c5f538c Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sun, 24 May 2020 16:48:22 +0200 Subject: first public release Signed-off-by: Toni Uhlig --- include/aes.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/aes.h (limited to 'include/aes.h') diff --git a/include/aes.h b/include/aes.h new file mode 100644 index 0000000..c828c96 --- /dev/null +++ b/include/aes.h @@ -0,0 +1,36 @@ +#ifndef AES_H_INCLUDED +#define AES_H_INCLUDED + +#include +#include + +#define KEY_128 (128/8) +#define KEY_192 (192/8) +#define KEY_256 (256/8) + + +typedef struct { + unsigned char state[4][4]; + int kcol; + uint32_t rounds; + uint32_t keysched[0]; +} aes_ctx_t; + + +void aes_randomkey(unsigned char* keyout, uint32_t keyLen); + +void aes_init(); + +void aes_cleanup(); + +aes_ctx_t* aes_alloc_ctx(unsigned char* key, uint32_t keyLen); + +char* aes_crypt_s(aes_ctx_t* ctx, const char* input, uint32_t siz, uint32_t* newsiz, bool doEncrypt); + +void aes_encrypt(aes_ctx_t* ctx, const unsigned char input[16], unsigned char output[16]); + +void aes_decrypt(aes_ctx_t* ctx, const unsigned char input[16], unsigned char output[16]); + +void aes_free_ctx(aes_ctx_t* ctx); + +#endif // AES_H_INCLUDED -- cgit v1.2.3