From 73d14c711ba2d5174210d243d385c8236be1300a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 17 Jun 2015 05:32:36 +0300 Subject: add "boxes" as a uniform encryption interface CTR is not yet supported. --- include/aesni/algorithm.h | 17 ++++++++++ include/aesni/all.h | 3 ++ include/aesni/box.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++ include/aesni/mode.h | 19 +++++++++++ 4 files changed, 122 insertions(+) create mode 100644 include/aesni/algorithm.h create mode 100644 include/aesni/box.h create mode 100644 include/aesni/mode.h (limited to 'include') diff --git a/include/aesni/algorithm.h b/include/aesni/algorithm.h new file mode 100644 index 0000000..8aacfdc --- /dev/null +++ b/include/aesni/algorithm.h @@ -0,0 +1,17 @@ +/** + * \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 + +typedef enum +{ + AESNI_AES128, + AESNI_AES192, + AESNI_AES256, +} +AesNI_Algorithm; diff --git a/include/aesni/all.h b/include/aesni/all.h index 350e4dd..70f5e7e 100644 --- a/include/aesni/all.h +++ b/include/aesni/all.h @@ -15,8 +15,11 @@ * \defgroup aesni AesNI */ +#include "algorithm.h" #include "block.h" +#include "box.h" #include "buffer.h" #include "data.h" #include "error.h" +#include "mode.h" #include "raw.h" diff --git a/include/aesni/box.h b/include/aesni/box.h new file mode 100644 index 0000000..2ae6533 --- /dev/null +++ b/include/aesni/box.h @@ -0,0 +1,83 @@ +/** + * \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 "algorithm.h" +#include "data.h" +#include "error.h" +#include "mode.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef union +{ + AesNI_KeySchedule128 aes128_key_schedule; + AesNI_KeySchedule192 aes192_key_schedule; + AesNI_KeySchedule256 aes256_key_schedule; +} +AesNI_EncryptionParams; + +typedef union +{ + AesNI_KeySchedule128 aes128_key_schedule; + AesNI_KeySchedule192 aes192_key_schedule; + AesNI_KeySchedule256 aes256_key_schedule; +} +AesNI_DecryptionParams; + +typedef union +{ + AesNI_Block128 aes_block; +} +AesNI_State; + +typedef union +{ + AesNI_Block128 aes128_key; + AesNI_Block192 aes192_key; + AesNI_Block256 aes256_key; +} +AesNI_AlgorithmParams; + +typedef struct +{ + AesNI_Algorithm algorithm; + AesNI_EncryptionParams encrypt_params; + AesNI_DecryptionParams decrypt_params; + AesNI_Mode mode; + AesNI_State iv; +} +AesNI_Box; + +AesNI_StatusCode aesni_box_init( + AesNI_Box*, + AesNI_Algorithm, + const AesNI_AlgorithmParams*, + AesNI_Mode, + const AesNI_State* iv, + AesNI_ErrorDetails*); + +AesNI_StatusCode aesni_box_encrypt( + AesNI_Box*, + const AesNI_State*, + AesNI_State*, + AesNI_ErrorDetails*); + +AesNI_StatusCode aesni_box_decrypt( + AesNI_Box*, + const AesNI_State*, + AesNI_State*, + AesNI_ErrorDetails*); + +#ifdef __cplusplus +} +#endif diff --git a/include/aesni/mode.h b/include/aesni/mode.h new file mode 100644 index 0000000..fc00e9c --- /dev/null +++ b/include/aesni/mode.h @@ -0,0 +1,19 @@ +/** + * \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 + +typedef enum +{ + AESNI_ECB, + AESNI_CBC, + AESNI_CFB, + AESNI_OFB, + AESNI_CTR, +} +AesNI_Mode; -- cgit v1.2.3