From 1463fd0559e0a664cd6a1bf6462a68dd79e58814 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 22 May 2015 01:03:07 +0300 Subject: initial commit --- include/aesni/all.h | 12 ++++++++++++ include/aesni/data.h | 41 +++++++++++++++++++++++++++++++++++++++++ include/aesni/raw.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 include/aesni/all.h create mode 100644 include/aesni/data.h create mode 100644 include/aesni/raw.h (limited to 'include') diff --git a/include/aesni/all.h b/include/aesni/all.h new file mode 100644 index 0000000..f16d2a6 --- /dev/null +++ b/include/aesni/all.h @@ -0,0 +1,12 @@ +/** + * \file + * \author Egor Tensin + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#pragma once + +#include "data.h" +#include "raw.h" diff --git a/include/aesni/data.h b/include/aesni/data.h new file mode 100644 index 0000000..029d8c8 --- /dev/null +++ b/include/aesni/data.h @@ -0,0 +1,41 @@ +/** + * \file + * \author Egor Tensin + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#pragma once + +#include + +typedef __m128i AesBlock; + +AesBlock make_aes_block(int highest, int high, int low, int lowest); + +typedef AesBlock Aes128Key; + +typedef struct +{ + AesBlock hi; + AesBlock lo; +} +Aes192Key; + +typedef struct +{ + AesBlock hi; + AesBlock lo; +} +Aes256Key; + +typedef struct +{ + unsigned char bytes[4][4]; +} +AesState; + +AesState aes_block_to_state(AesBlock); + +void print_aes_block(AesBlock); diff --git a/include/aesni/raw.h b/include/aesni/raw.h new file mode 100644 index 0000000..03ce217 --- /dev/null +++ b/include/aesni/raw.h @@ -0,0 +1,47 @@ +/** + * \file + * \author Egor Tensin + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#pragma once + +#include "data.h" + +AesBlock __fastcall aes128ecb_encrypt( + AesBlock plain, + AesBlock key); +AesBlock __fastcall aes128ecb_decrypt( + AesBlock cypher, + AesBlock key); + +AesBlock __fastcall aes192ecb_encrypt( + AesBlock plain, + AesBlock key_lo, + AesBlock key_hi); +AesBlock __fastcall aes192ecb_decrypt( + AesBlock cypher, + AesBlock key_lo, + AesBlock key_hi); + +AesBlock __fastcall aes256ecb_encrypt( + AesBlock plain, + AesBlock key_lo, + AesBlock key_hi); +AesBlock __fastcall aes256ecb_decrypt( + AesBlock cypher, + AesBlock key_lo, + AesBlock key_hi); + +AesBlock __fastcall aes256cbc_encrypt( + AesBlock plain, + AesBlock key_lo, + AesBlock key_hi, + AesBlock *iv); +AesBlock __fastcall aes256cbc_decrypt( + AesBlock cypher, + AesBlock key_lo, + AesBlock key_hi, + AesBlock *iv); -- cgit v1.2.3