aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/aesni/all.h1
-rw-r--r--include/aesni/buffer.h14
-rw-r--r--include/aesni/error.h50
3 files changed, 61 insertions, 4 deletions
diff --git a/include/aesni/all.h b/include/aesni/all.h
index 1360320..4653eca 100644
--- a/include/aesni/all.h
+++ b/include/aesni/all.h
@@ -11,4 +11,5 @@
#include "block.h"
#include "buffer.h"
#include "data.h"
+#include "error.h"
#include "raw.h"
diff --git a/include/aesni/buffer.h b/include/aesni/buffer.h
index daafc3e..13f19da 100644
--- a/include/aesni/buffer.h
+++ b/include/aesni/buffer.h
@@ -8,6 +8,8 @@
#pragma once
+#include "error.h"
+
#include <stdlib.h>
#ifdef __cplusplus
@@ -15,16 +17,20 @@ extern "C"
{
#endif
-size_t aesni_encrypt_buffer_ecb128(
+int aesni_encrypt_buffer_ecb128(
const void* src,
size_t src_size,
void* dest,
- AesNI_KeySchedule128* key_schedule);
-size_t aesni_decrypt_buffer_ecb128(
+ size_t* dest_size,
+ AesNI_KeySchedule128* key_schedule,
+ AesNI_ErrorDetails*);
+int aesni_decrypt_buffer_ecb128(
const void* src,
size_t src_size,
void* dest,
- AesNI_KeySchedule128* inverted_schedule);
+ size_t* dest_size,
+ AesNI_KeySchedule128* inverted_schedule,
+ AesNI_ErrorDetails*);
#ifdef __cplusplus
}
diff --git a/include/aesni/error.h b/include/aesni/error.h
new file mode 100644
index 0000000..54d3d34
--- /dev/null
+++ b/include/aesni/error.h
@@ -0,0 +1,50 @@
+/**
+ * \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
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef enum
+{
+ AESNI_ERROR_SUCCESS,
+
+ AESNI_ERROR_NULL_ARGUMENT,
+
+ AESNI_ERROR_INVALID_PKCS7_PADDING,
+}
+AesNI_ErrorCode;
+
+const char* aesni_strerror(AesNI_ErrorCode);
+
+typedef struct
+{
+ AesNI_ErrorCode ec;
+
+ union
+ {
+ struct
+ {
+ char arg_name[32];
+ }
+ null_arg;
+ }
+ params;
+}
+AesNI_ErrorDetails;
+
+void aesni_make_error_success(AesNI_ErrorDetails*);
+void aesni_make_error_null_argument(AesNI_ErrorDetails*, const char* arg_name);
+void aesni_make_error_invalid_pkcs7_padding(AesNI_ErrorDetails*);
+
+#ifdef __cplusplus
+}
+#endif