Commit 6357130a authored by hark's avatar hark

bla

parent 92f42620
......@@ -21,117 +21,103 @@
#endif
int main() {
struct pl_keypair *kp;
kp = NULL;
char clear_message[] = "Blaat blaat, dit is een test berichtje :), en nog meer en meer en meer 123456744555 blablablablablablabal jajajajaj hee blaat ";
// initialise the pager
struct pl_ctx * context;
context = pl_init(context);
context = pl_init();
sender = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
memset(sender, 9, sizeof(struct pl_keypair));
receiver = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
memset(receiver, 2, sizeof(struct pl_keypair));
struct pl_keypair *kp;
kp = NULL;
char clear_message[] = "Blaat blaat, dit is een test berichtje :), en nog meer en meer en meer 123456744555 blablablablablablabal jajajajaj hee blaat ";
// initialise the pager
struct pl_ctx * context;
context = pl_init();
int f = 0;
while ( 1 ) {
while ( f < 10 ) {
f++;
if (f == 10) break;
/* create keypairs */
/* create keypairs */
kp = pl_create_keypair(context);
pl_load_key_in_list(context, kp);
}
/* create keypairs */
/*
pl_create_keypair(context, sender);
pl_save_key(sender,"sender_test.keypair");
pl_create_keypair(context, receiver);
pl_save_key(receiver,"receiver_test.keypair");
pl_load_key(sender, "sender_test.keypair");
pl_load_key(receiver, "receiver_test.keypair");
pl_load_key_in_list(context, sender);
pl_load_key_in_list(context, receiver);
*/
// print list of keypairs
// ------------------------------------------------- //
// set key to use for sending the message (FIXME)
context->kp = kp;
/*
DBG("\n sender.keypair");
DBM("sender", sizeof(struct pl_keypair), sender);
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);
*/
int i = 0;
while ( 1 ) {
i++;
if (i == 10) break;
// load the message to send
memcpy(context->msg->msg, clear_message, MSG_SIZE);
//
//to who to send the message to (get from kp)
memcpy(&context->receiver_compressed_point, &kp->compressed_point, sizeof(context->receiver_compressed_point));
pl_send_message(context);
context->kp = kp;
// DBM("context->kp (receiver)", sizeof(struct pl_keypair), context->kp);
// DBM("context->kp->private_key (receiver)", sizeof(context->kp->private_key), &context->kp->private_key);
/* receive the msg */
if ( pl_receive_message(context) == 1) {
printf("failed to receive this message ! (exit 1) \n");
} else {
printf("recv success! \n");
// printf(" Message! \n to: %u from: %u \n the decrypted message: %s \n", context->msg->address, compressed_point_to_addr(context->msg->sender_compressed_point), context->msg->msg);
}
}
/*
DBG("\n sender.keypair");
DBM("sender", sizeof(struct pl_keypair), sender);
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);
DBM("context->kp (receiver)", sizeof(struct pl_keypair), context->kp);
DBM("context->kp->private_key (receiver)", sizeof(context->kp->private_key), &context->kp->private_key);
*/
int i = 0;
while ( i < 10 ) {
i++;
context->kp = kp;
if ( pl_receive_message(context) == 1) {
printf("failed to receive this message ! (exit 1)");
} else {
// printf(" Message! \n to: %u from: %u \n the decrypted message: %s \n", context->msg->address, compressed_point_to_addr(context->msg->sender_compressed_point), context->msg->msg);
// printf(" Message! \n to: %u from: %u \n the decrypted message: %s \n", context->msg->address, compressed_point_to_addr(context->msg->sender_compressed_point), context->msg->msg);
}
}
}
pl_print_keylist(context);
//pl_inbox_display_all(context);
//pl_inbox_display_all(context);
i = 0;
while ( i < 20)
{
i = 0;
while ( i < 20)
{
if (pl_inbox_next(context)) {
if (pl_inbox_next(context)) {
pl_inbox_display(context);
/*
pl_inbox_delete(context);
pl_send_message(context);
pl_inbox_display(context);
pl_inbox_delete(context);
pl_send_message(context);
pl_inbox_display(context);
pl_inbox_delete(context);
pl_inbox_display(context);
pl_inbox_delete(context);
pl_inbox_display(context);
pl_inbox_display(context);
pl_inbox_delete(context);
pl_inbox_display(context);
pl_inbox_delete(context);
pl_inbox_display(context);
*/
}
else
{
break;
}
}
pl_print_keylist(context);
}
else
{
break;
}
}
return 0;
return 0;
}
......@@ -432,6 +432,7 @@ pl_load_key_in_list(struct pl_ctx *ctx, struct pl_keypair *key){
}
pl_print_keylist(struct pl_ctx *ctx) {
struct list_kp * list;
printf("the list of loaded keys: \n ");
......
......@@ -85,15 +85,16 @@ struct pl_ctx
char decompressed_point[64];
// contains the message that will be send or is received
char clear_message[MSG_SIZE];
// my (currently used) keypair
// my (currently used ) keypair
struct pl_keypair *kp;
// keypair list (all available keypairs)
struct list_kp *keypairs;
// place to store messages to be sent or received
struct pl_pagermessage *msg;
struct list_inbox *inbox;
struct list_inbox *inbox_curr;
uint8_t receiver_compressed_point[ECC_COMPRESSED_SIZE];
// uint8_t receiver_compressed_point[ECC_COMPRESSED_SIZE];
#ifdef ARDUINO
aes_context aes_ctx;
......
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