Commit 993963d2 authored by hark's avatar hark
Browse files

bla

parent 153fb075
<<<<<<< HEAD
зzUm 0خCA+$G;v G ;t$[nV? R
=======
O˪)_UUZ6V*CujD$jG>`><=Ʀ|B.Um&=$
>>>>>>> 8e2ce7edbca8605c6b11a0456b1b93762e4c0935
:; y;p~bdN6 휉cP~4I( {}Mo<44eH
\ No newline at end of file
g#YY^Wmkĉ@vF@A~z{MQ
2am-y
\ No newline at end of file
='srWPື Ob=h^JJAIr\j&a5ɪ
\ No newline at end of file
......@@ -20,11 +20,6 @@
#define uECC_TEST_NUMBER_OF_ITERATIONS 1
#endif
char shared_secret[SHARED_SECRET_SIZE];
char decompressed_point[64];
int main() {
struct pl_keypair *receiver, *sender;
char clear_message[] = "Blaat blaat, dit is een test berichtje :), en nog meer en meer en meer 123456744555 blablablablablablabal jajajajaj hee blaat ";
......@@ -38,9 +33,7 @@ int main() {
}
*/
context = pl_init(context);
// sended_msg = (struct pl_pagermessage *) malloc(sizeof(struct pl_pagermessage));
// memset(sended_msg, 7, sizeof(struct pl_pagermessage));
sender = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
memset(sender, 9, sizeof(struct pl_keypair));
......@@ -55,15 +48,18 @@ int main() {
pl_save_key(receiver,"receiver.keypair");
//switch to sender key
// context->kp = sender;
pl_load_key(sender, "sender.keypair");
pl_load_key(receiver, "receiver.keypair");
pl_load_key_in_list(context, sender);
pl_load_key_in_list(context, receiver);
// print list of keypairs
pl_print_keylist(context);
// ------------------------------------------------- //
// set key to use for sending the message
context->kp = sender;
/*
......@@ -72,14 +68,15 @@ int main() {
DBM("receiver", sizeof(struct pl_keypair), receiver);
DBM("context->kp (sender)", sizeof(struct pl_keypair), context->kp);
DBM("context->kp->private_key (sender)", sizeof(context->kp->private_key), &context->kp->private_key);
DBM("receiver->compressed",sizeof(receiver->compressed_point) , &receiver->compressed_point);
DBM("context->receiver_compressed_point",sizeof(context->receiver_compressed_point) , &context->receiver_compressed_point);
*/
// load the message to send
memcpy(context->msg->msg, clear_message, MSG_SIZE);
// DBM("receiver->compressed",sizeof(receiver->compressed_point) , &receiver->compressed_point);
//
memcpy(&context->receiver_compressed_point, &receiver->compressed_point, sizeof(context->receiver_compressed_point));
// DBM("context->receiver_compressed_point",sizeof(context->receiver_compressed_point) , &context->receiver_compressed_point);
pl_send_message(context);
......
......@@ -86,7 +86,7 @@ inline int pl_set_receiver(struct pl_ctx *ctx, struct pl_keypair *keypair)
/*
* This sends a message (encrypts it)
* Before calling this make sure u set sender ( ctx->kp , ctx->msg->sender_compressed_point) and receiver ctx->receiver_compressed_point, and the message you want to send
* Before calling this make sure u set sender ( ctx->kp , ctx->msg->sender_compressed_point) and receiver ctx->receiver_compressed_point, and the message you want to send in ctx->msg->msg
*/
inline int pl_send_message(struct pl_ctx *ctx) {
......@@ -94,14 +94,12 @@ inline int pl_send_message(struct pl_ctx *ctx) {
memset(ctx->shared_secret, 7, sizeof(ctx->shared_secret));
/* create a random iv */
// TODO (this is stupid)
// memcpy(&ctx->msg->iv, &fakeiv, sizeof(ctx->msg->iv));
rng(&ctx->msg->iv, sizeof(ctx->msg->iv));
// copy compressed point into pager message
memcpy(&ctx->msg->sender_compressed_point, &ctx->kp->compressed_point, sizeof(ctx->msg->sender_compressed_point));
DBG("Sending message \n");
//DBG("Sending message \n");
#ifndef NOCRYPT
/* decompress key */
uECC_decompress(&ctx->receiver_compressed_point, &ctx->decompressed_point, ctx->curve);
......@@ -110,8 +108,8 @@ inline int pl_send_message(struct pl_ctx *ctx) {
// DBM("#decompr point ",sizeof(ctx->decompressed_point) , &ctx->decompressed_point);
ctx->msg->address = compressed_point_to_addr(ctx->receiver_compressed_point);
DBM("address: ", sizeof(ctx->msg->address), &ctx->msg->address);
printf(">>>>>>>>>>>>>>>>>>>address: %u \n \n", ctx->msg->address );
// DBM("address: ", sizeof(ctx->msg->address), &ctx->msg->address);
//printf(">>>>>>>>>>>>>>>>>>>address: %u \n \n", ctx->msg->address );
/*calculate shared secret on sender*/
if (!uECC_shared_secret(&ctx->decompressed_point, &ctx->kp->private_key, &ctx->shared_secret, ctx->curve)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment