Commit 8e2ce7ed authored by yids's avatar yids
Browse files

fixed tx-test, rx-test and keygen

added test keypairs
parent bcda4da1
CC=colorgcc
CFLAGS="-I ../libs"
CFLAGS="-I ../libs"
all: test rx-test tx-test keygen
......
......@@ -14,5 +14,16 @@ char decompressed_point[64];
int main()
{
struct pl_keypair *receiver, *sender;
struct pl_ctx * context;
context = pl_init(context);
pl_create_keypair(context, sender);
pl_save_key(sender,"sender.keypair");
pl_create_keypair(context, receiver);
pl_save_key(receiver,"receiver.keypair");
return 0;
}
O˪)_UUZ6V*CujD$jG>`><=Ʀ|B.Um&=$
\ No newline at end of file
......@@ -15,22 +15,23 @@ char decompressed_point[64];
int main ()
{
struct pl_keypair *receiver;
char crypt_message[sizeof(struct pl_pagermessage)];
char decrypted_message[128];
struct pl_pagermessage * received_message;
read(STDIN_FILENO, crypt_message, sizeof(struct pl_pagermessage));
char encrypted_message[sizeof(struct pl_pagermessage)];
// initialise the pager
struct pl_ctx * context;
context = pl_init(context);
pl_init();
received_message=(struct pl_pagermessage *) malloc(sizeof(struct pl_pagermessage));
memset(received_message, 7, sizeof(struct pl_pagermessage));
receiver = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
memset(receiver, 2, sizeof(struct pl_keypair));
pl_load_key(receiver, "receiver.keypair");
memcpy(&context->receiver_compressed_point, &receiver->compressed_point, sizeof(context->receiver_compressed_point));
context->kp = receiver;
memcpy(received_message->msg, crypt_message, MSG_SIZE);
read(STDIN_FILENO, context->msg , sizeof(struct pl_pagermessage));
pl_receive_message(receiver, received_message, &decrypted_message, &shared_secret, &decompressed_point);
pl_receive_message(context);
printf("the decrypted message: %s \n", context->msg->msg);
return 0;
}
......@@ -28,8 +28,8 @@ char decompressed_point[64];
int main() {
struct pl_keypair *receiver, *sender;
char clear_message[] = "Blaat blaat, dit is een test berichtje :) ";
char crypt_message[128];
char decrypted_message[128];
// char crypt_message[128]; DIT IS NERGENS VOOR NODIG TOCH?
// char decrypted_message[128]; DIT IS NERGENS VOOR NODIG TOCH?
// struct pl_pagermessage * sended_msg;
// initialise the pager
struct pl_ctx * context;
......@@ -51,12 +51,12 @@ int main() {
/* create keypairs */
/*
pl_create_keypair(context, sender);
pl_save_key(sender,"sender.keypair");
pl_create_keypair(context, receiver);
pl_save_key(receiver,"receiver.keypair");
*/
//switch to sender key
// context->kp = sender;
pl_load_key(sender, "sender.keypair");
......@@ -68,8 +68,6 @@ int main() {
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);
memcpy(context->msg->msg, clear_message, MSG_SIZE);
DBM("receiver->compressed",sizeof(receiver->compressed_point) , &receiver->compressed_point);
......
......@@ -2,6 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "../libs/pagerlib/pagerlib.h"
#ifndef uECC_TEST_NUMBER_OF_ITERATIONS
......@@ -14,23 +15,29 @@ char decompressed_point[64];
int main()
{
struct pl_keypair *transmitter;
char plain_message[] = "test bericht lala";
char crypt_message[sizeof(struct pl_pagermessage)];
char encrypted_message[128];
struct pl_pagermessage * sent_message;
struct pl_keypair *sender, *receiver;
char clear_message[] = "dit is een test berichtje :) ";
pl_init();
// initialise the pager
struct pl_ctx * context;
context = pl_init(context);
sent_message=(struct pl_pagermessage *) malloc(sizeof(struct pl_pagermessage));
memset(sent_message, 7, sizeof(struct pl_pagermessage));
sender = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
receiver = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
pl_load_key(transmitter, "receiver.keypair");
pl_load_key(sender, "sender.keypair"); // load tx keypair
pl_load_key(receiver, "receiver.keypair"); // load tx keypair
memcpy(sent_message->msg, crypt_message, MSG_SIZE);
context->kp = sender;
pl_send_message(transmitter, sent_message, &plain_message, &shared_secret, &decompressed_point);
memcpy(context->msg->msg, clear_message, MSG_SIZE);
memcpy(&context->receiver_compressed_point, &receiver->compressed_point, sizeof(context->receiver_compressed_point));
DBM("context->recv_comp_point", sizeof(context->kp->private_key), &context->receiver_compressed_point);
pl_send_message(context);
write(STDOUT_FILENO,context->msg, sizeof(struct pl_pagermessage));
return 0;
}
......@@ -61,7 +61,7 @@ struct pl_ctx
struct pl_keypair *kp;
// struct pl_keypair *to, *from;
struct pl_pagermessage *msg;
uint8_t receiver_compressed_point[ECC_COMPRESSED_SIZE];
#ifdef ARDUINO
......
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