diff options
Diffstat (limited to 'libcmix')
| -rw-r--r-- | libcmix/cmix.c | 25 | ||||
| -rw-r--r-- | libcmix/cmix.h | 4 |
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 |
