Commit 0d46deb8 authored by yids's avatar yids

tx-test and rx-test work now

parent 374054d7
......@@ -11,28 +11,26 @@
int main ()
{
struct pl_ctx *rx_ctx;
struct pl_keypair *rx_kp;
char encrypted_message[sizeof(struct pl_pagermessage)];
// initialise the pager
struct pl_ctx * rx_ctx ;
rx_ctx = pl_init();
rx_kp = NULL;
rx_kp = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
pl_load_key(rx_kp, "meinsleusel");
/* init */
rx_ctx = pl_init();
/*load keypair */
rx_kp = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
pl_load_key(rx_kp, "rx");
pl_load_key_in_list(rx_ctx, rx_kp);
pl_print_keylist(rx_ctx);
// memcpy(&context->receiver_compressed_point, &receiver->compressed_point, sizeof(context->receiver_compressed_point));
rx_ctx->kp = rx_kp;
/* get message from stdin */
struct pl_pagermessage * message = NULL;
message = (struct pl_pagermessage *) malloc(sizeof(struct pl_pagermessage));
read(STDIN_FILENO, message , sizeof(struct pl_pagermessage));
rx_ctx->msg = message;
message = NULL;
switch(pl_receive_message(rx_ctx)) {
case 0:
......@@ -50,19 +48,10 @@ int main ()
case -4:
printf("RCV: -4 (key not found) \n");
break;
default:
printf("RCV: unknown error \n");
break;
}
// while (pl_inbox_next(rx_ctx))
// {
pl_inbox_display(rx_ctx);
// }
// printf("the decrypted message: %s \n", rx_ctx->msg->msg);
return 0;
pl_inbox_display(rx_ctx);
}
......@@ -13,30 +13,44 @@
int main()
{
struct pl_keypair *tx_kp;
char *rx_pubkey;
char clear_message[] = "dit is een test berichtje :) ";
struct pl_ctx *tx_ctx;
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 * tx_ctx;
/* init */
tx_kp = NULL;
tx_ctx = pl_init();
tx_kp = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
pl_load_key(tx_kp, "sender.keypair"); // load tx keypair
rx_pubkey = malloc(crypto_box_PUBLICKEYBYTES);
pl_load_public_key(rx_pubkey, "receiver.pub"); // load tx keypair
/* load keypair */
tx_kp = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
pl_load_key(tx_kp, "tx");
tx_ctx->kp = tx_kp;
memcpy(tx_ctx->msg->msg, clear_message, MSG_SIZE);
memcpy(&tx_ctx->receiver_public_key, rx_pubkey , crypto_box_PUBLICKEYBYTES);
// DBM("context->recv_comp_point", sizeof(tx_ctx->kp->private_key), &context->receiver_compressed_point);
pl_send_message(tx_ctx);
write(STDOUT_FILENO,tx_ctx->msg, sizeof(struct pl_pagermessage));
return 0;
/*load public key of receiver*/
char *rx_pubkey;
rx_pubkey = malloc(crypto_box_PUBLICKEYBYTES);
pl_load_public_key(rx_pubkey, "rx.pub");
memcpy(tx_ctx->msg->msg, clear_message, MSG_SIZE); // copy clear msg into context
memcpy(&tx_ctx->receiver_public_key, rx_pubkey, sizeof(tx_ctx->receiver_public_key)); // copy rx pubkey into context
switch(pl_send_message(tx_ctx)) { // send msg
case 0:
printf("SEND: OK! \n");
break;
case -1:
printf("SEND: -1 \n");
break;
case -2:
printf("SEND: -2 \n");
break;
case -3:
printf("SEND: -3 \n");
break;
default:
printf("SEND: unknown error \n");
break;
}
write(STDOUT_FILENO,tx_ctx->msg, sizeof(struct pl_pagermessage)); // dump to stdout
////// RRRRXXXX /////////
}
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