aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/aesni/box_data.h
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-17 20:07:32 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-17 20:07:32 +0300
commit522a5b906d7620bcebddb5a8f476b022c140ab27 (patch)
tree8b02e4f5b5948da91e4117c6892d850eeeac8445 /include/aesni/box_data.h
parentrefactoring (diff)
downloadaes-tools-522a5b906d7620bcebddb5a8f476b022c140ab27.tar.gz
aes-tools-522a5b906d7620bcebddb5a8f476b022c140ab27.zip
factoring out AES-specific stuff
Diffstat (limited to 'include/aesni/box_data.h')
-rw-r--r--include/aesni/box_data.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/include/aesni/box_data.h b/include/aesni/box_data.h
new file mode 100644
index 0000000..160cf34
--- /dev/null
+++ b/include/aesni/box_data.h
@@ -0,0 +1,110 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#pragma once
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef union
+{
+ AesNI_Block128 aes128_key;
+ AesNI_Block192 aes192_key;
+ AesNI_Block256 aes256_key;
+}
+AesNI_BoxAlgorithmParams;
+
+typedef enum
+{
+ AESNI_AES128,
+ AESNI_AES192,
+ AESNI_AES256,
+}
+AesNI_BoxAlgorithm;
+
+typedef enum
+{
+ AESNI_ECB,
+ AESNI_CBC,
+ AESNI_CFB,
+ AESNI_OFB,
+ AESNI_CTR,
+}
+AesNI_BoxMode;
+
+typedef union
+{
+ AesNI_Aes128_RoundKeys aes128_encryption_keys;
+ AesNI_Aes192_RoundKeys aes192_encryption_keys;
+ AesNI_Aes256_RoundKeys aes256_encryption_keys;
+}
+AesNI_BoxEncryptionParams;
+
+typedef union
+{
+ AesNI_Aes128_RoundKeys aes128_decryption_keys;
+ AesNI_Aes192_RoundKeys aes192_decryption_keys;
+ AesNI_Aes256_RoundKeys aes256_decryption_keys;
+}
+AesNI_BoxDecryptionParams;
+
+typedef union
+{
+ AesNI_Block128 aes_block;
+}
+AesNI_BoxBlock;
+
+typedef AesNI_StatusCode (*AesNI_BoxDeriveParams)(
+ const AesNI_BoxAlgorithmParams* params,
+ AesNI_BoxEncryptionParams*,
+ AesNI_BoxDecryptionParams*,
+ AesNI_ErrorDetails* err_details);
+
+typedef AesNI_StatusCode (*AesNI_BoxEncrypt)(
+ const AesNI_BoxBlock* plaintext,
+ const AesNI_BoxEncryptionParams* params,
+ AesNI_BoxBlock* ciphertext,
+ AesNI_ErrorDetails* err_details);
+
+typedef AesNI_StatusCode (*AesNI_BoxDecrypt)(
+ const AesNI_BoxBlock* ciphertext,
+ const AesNI_BoxDecryptionParams* params,
+ AesNI_BoxBlock* plaintext,
+ AesNI_ErrorDetails* err_details);
+
+typedef AesNI_StatusCode (*AesNI_BoxXorBlock)(
+ AesNI_BoxBlock*,
+ const AesNI_BoxBlock*,
+ AesNI_ErrorDetails*);
+
+typedef struct
+{
+ AesNI_BoxDeriveParams derive_params;
+ AesNI_BoxEncrypt encrypt;
+ AesNI_BoxDecrypt decrypt;
+ AesNI_BoxXorBlock xor_block;
+}
+AesNI_BoxAlgorithmInterface;
+
+typedef struct
+{
+ const AesNI_BoxAlgorithmInterface* algorithm_iface;
+ AesNI_BoxEncryptionParams encrypt_params;
+ AesNI_BoxDecryptionParams decrypt_params;
+ AesNI_BoxMode mode;
+ AesNI_BoxBlock iv;
+}
+AesNI_Box;
+
+#ifdef __cplusplus
+}
+#endif