aboutsummaryrefslogtreecommitdiff
path: root/libcmix-crypto/message.h
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix-crypto/message.h')
-rw-r--r--libcmix-crypto/message.h36
1 files changed, 32 insertions, 4 deletions
diff --git a/libcmix-crypto/message.h b/libcmix-crypto/message.h
index 7222d00..b1c3b87 100644
--- a/libcmix-crypto/message.h
+++ b/libcmix-crypto/message.h
@@ -1,5 +1,9 @@
#pragma once
+/**
+ * \file
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -7,16 +11,33 @@ extern "C" {
#include <stddef.h>
#include <stdlib.h>
+/*!
+ * Defines how a cMix Buffer allocater should look like.
+ */
typedef char*(*CmixBufferAllocator)(size_t);
+/*!
+ * Defines how a cMix Buffer deallocater should look like.
+ */
typedef void(*CmixBufferDeallocator)(void*);
+/*!
+ * Defines how the function looks like that returns the length of one message in this buffer implementation.
+ */
typedef size_t(*CmixBufferMessageLength)();
+/*!
+ * \brief The CmixBufferImpl struct
+ */
struct CmixBufferImpl {
- CmixBufferAllocator allocate_cmix_buffer;
- CmixBufferDeallocator deallocate_cmix_buffer;
- CmixBufferMessageLength message_length;
+ CmixBufferAllocator allocate_cmix_buffer; ///< pointer to function to implementation specific allocater.
+ CmixBufferDeallocator deallocate_cmix_buffer; ///< pointer to function to implementation specific deallocater.
+ CmixBufferMessageLength message_length; ///< pointer to function to implementation specific function returning message length.
};
+/*!
+ * \def DEFINE_CIPHER(NAME, MESSAGE_SIZE)
+ * Generates some cipher specific boilerplate for manipulating the message buffer.
+ */
+
#define DEFINE_CIPHER(NAME, MESSAGE_SIZE)\
typedef char NAME ## Message[MESSAGE_SIZE];\
\
@@ -40,8 +61,15 @@ struct CmixBufferImpl get_cmix_ ## NAME ## _buffer_implementation() {\
};\
}
+/*!
+ * #DEFINE_CIPHER(Null, 0)
+ */
DEFINE_CIPHER(Null, 0)
-DEFINE_CIPHER(Curve25519, 20);
+
+/*!
+ * #DEFINE_CIPHER(Curve25519, 31)
+ */
+DEFINE_CIPHER(Curve25519, 31)
#undef DEFINE_CIPHER