aboutsummaryrefslogtreecommitdiff
path: root/libcmix
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-11-07 16:45:34 +0100
committerDennis Brentjes <d.brentjes@gmail.com>2016-11-07 16:45:34 +0100
commit8ff9babe2da4a2efc8529e800a6093fbd0327286 (patch)
tree83f2d15f8dae8c7a5e216f9ec0a8001bd40673a3 /libcmix
parent46f22621759d388f7cef4bf0d2ac03667a5d611e (diff)
downloadcmix-8ff9babe2da4a2efc8529e800a6093fbd0327286.tar.gz
cmix-8ff9babe2da4a2efc8529e800a6093fbd0327286.tar.bz2
cmix-8ff9babe2da4a2efc8529e800a6093fbd0327286.zip
The client sends his first message.
Changed some of the boilerplate so it's more conveniant to add types.
Diffstat (limited to 'libcmix')
-rw-r--r--libcmix/cmix.c25
-rw-r--r--libcmix/cmix.h4
2 files changed, 26 insertions, 3 deletions
diff --git a/libcmix/cmix.c b/libcmix/cmix.c
index 582fe70..a47a9fa 100644
--- a/libcmix/cmix.c
+++ b/libcmix/cmix.c
@@ -216,6 +216,8 @@ enum cmix_error key_exchange_init(struct CMixContext const* ctx, char* pubkey_bu
get_public_key(ctx, pubkey_buffer);
element_to_buffer(ctx, value_buffer, value);
+
+ ctx->api.free_group_element(value);
return no_error;
}
@@ -235,10 +237,13 @@ enum cmix_error key_exchange_responder(struct CMixContext const* ctx, GroupEleme
return no_error;
}
-enum cmix_error key_exchange_initiator(struct CMixContext const* ctx, GroupElement* shared_key, char const* pubkey, char const* value, GroupElement priv_el) {
+enum cmix_error key_exchange_initiator(struct CMixContext const* ctx, GroupElement* shared_key, char const* pubkey, char const* value, GroupElement* priv_el) {
size_t el_len = get_group_element_array_size(ctx);
*shared_key = ctx->api.derive_shared_key(ctx->keypair, (unsigned char*)pubkey, el_len, (unsigned char*)value, el_len, priv_el, false);
+ ctx->api.free_group_element(*priv_el);
+ *priv_el = NULL;
+
return no_error;
}
@@ -251,7 +256,7 @@ enum cmix_error post_process(struct CMixContext* ctx, char* r_out, char* m_out,
GroupElement pirs = ctx->api.multiply(D, msg, true);
element_to_buffer(ctx, m_out, pirs);
- ctx->pirs = pirs; // this is not always usable as only the last node will be able to use this effectively, but we store it anyways.
+ ctx->pirs[index] = pirs; // this is not always usable as only the last node will be able to use this effectively, but we store it anyways.
ctx->api.free_group_element(x);
ctx->api.free_group_element(D);
@@ -259,3 +264,19 @@ enum cmix_error post_process(struct CMixContext* ctx, char* r_out, char* m_out,
return no_error;
}
+
+enum cmix_error blind_message(struct CMixContext const* ctx, char* m_out, char const* message, GroupElement const* keys, size_t const nr_nodes) {
+ size_t len = get_group_element_array_size(ctx);
+
+ GroupElement mes = ctx->api.array_to_element(message, len, true);
+
+ for(size_t i = 0; i < nr_nodes; ++i) {
+ ctx->api.multiply(mes, mes, keys[i]);
+ }
+
+ element_to_buffer(ctx, m_out, mes);
+
+ ctx->api.free_group_element(mes);
+
+ return no_error;
+}
diff --git a/libcmix/cmix.h b/libcmix/cmix.h
index 7442369..33b99d2 100644
--- a/libcmix/cmix.h
+++ b/libcmix/cmix.h
@@ -113,10 +113,12 @@ enum cmix_error key_exchange_init(struct CMixContext const* ctx, char* pubkey_bu
enum cmix_error key_exchange_responder(struct CMixContext const* ctx, GroupElement* shared_key, char* public_key_buffer, char* exhange_value_buffer, char const* pubkey, char const* value);
-enum cmix_error key_exchange_initiator(struct CMixContext const* ctx, GroupElement* shared_key, char const* pubkey, char const* value, GroupElement priv_el);
+enum cmix_error key_exchange_initiator(struct CMixContext const* ctx, GroupElement* shared_key, char const* pubkey, char const* value, GroupElement* priv_el);
enum cmix_error post_process(struct CMixContext* ctx, char* r_out, char* m_out, char const* r_epirs, char const* m_epirs, size_t index);
+enum cmix_error blind_message(struct CMixContext const* ctx, char* m_out, char const* message, GroupElement const* keys, size_t const nr_nodes);
+
#ifdef __cplusplus
} // extern "C"
#endif