diff options
Diffstat (limited to 'libcmix')
| -rw-r--r-- | libcmix/cmix.c | 32 | ||||
| -rw-r--r-- | libcmix/cmix.h | 2 |
2 files changed, 18 insertions, 16 deletions
diff --git a/libcmix/cmix.c b/libcmix/cmix.c index 9c983f0..1430532 100644 --- a/libcmix/cmix.c +++ b/libcmix/cmix.c @@ -284,21 +284,23 @@ enum cmix_error key_exchange_initiator(struct CMixContext const* ctx, GroupEleme return no_error; } -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) { - GroupElement x = ctx->api.array_to_element(r_epirs, get_group_element_array_size(ctx), true); - GroupElement D = ctx->api.get_decryption_share(x, ctx->keypair.sec); - - GroupElement msg = ctx->api.array_to_element(m_epirs, get_group_element_array_size(ctx), true); - GroupElement pirs = ctx->api.multiply(D, msg, true); - element_to_buffer(ctx, m_out, pirs); - - memcpy(r_out, r_epirs, get_group_element_array_size(ctx)); - - 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); - ctx->api.free_group_element(msg); +enum cmix_error post_process(struct CMixContext* ctx, char** r_out, char** m_out, const char** r_epirs, const char** m_epirs, size_t nr_elements) { + for(size_t i = 0; i < nr_elements; ++i) { + GroupElement x = ctx->api.array_to_element(r_epirs[i], get_group_element_array_size(ctx), true); + GroupElement D = ctx->api.get_decryption_share(x, ctx->keypair.sec); + + GroupElement msg = ctx->api.array_to_element(m_epirs[i], get_group_element_array_size(ctx), true); + GroupElement pirs = ctx->api.multiply(D, msg, true); + element_to_buffer(ctx, m_out[i], pirs); + + memcpy(r_out[i], r_epirs[i], get_group_element_array_size(ctx)); + + ctx->pirs[i] = 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); + ctx->api.free_group_element(msg); + } return no_error; } diff --git a/libcmix/cmix.h b/libcmix/cmix.h index 53a3d99..390b28f 100644 --- a/libcmix/cmix.h +++ b/libcmix/cmix.h @@ -97,7 +97,7 @@ enum cmix_error key_exchange_responder(struct CMixContext const* ctx, GroupEleme 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 post_process(struct CMixContext* ctx, char** r_out, char** m_out, char const** r_epirs, char const** m_epirs, size_t nr_elements); enum cmix_error blind_message(struct CMixContext const* ctx, char* m_out, char const* message, GroupElement const* keys, size_t const nr_nodes); |
