Commit cce908bd authored by yids's avatar yids

fixed rx-test and tx-test, but it still doesnt work

parent acb5cd32
......@@ -2,7 +2,7 @@
CC=colorgcc
CFLAGS="-I ../libs -DDEBUG"
all: test
all: test keygen tx-test rx-test
base-tx: base-tx.c
$(CC) -o base-tx base-tx.c $(LIBS) $(CFLAGS)
......@@ -15,13 +15,13 @@ putstest: putstest.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c ../li
rx-test: rx-test.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c
$(CC) -std=c99 -g -o rx-test rx-test.c ../libs/micro-ecc/uECC.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c -lmbedtls -lmbedx509 -lmbedcrypto $(LIBS) $(CFLAGS)
$(CC) -std=c99 -g -o rx-test rx-test.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c -lmbedtls -lmbedx509 -lmbedcrypto -lsodium $(LIBS) $(CFLAGS)
tx-test: tx-test.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c
$(CC) -std=c99 -g -o tx-test tx-test.c ../libs/micro-ecc/uECC.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c -lmbedtls -lmbedx509 -lmbedcrypto $(LIBS) $(CFLAGS)
$(CC) -std=c99 -g -o tx-test tx-test.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c -lmbedtls -lmbedx509 -lmbedcrypto -lsodium $(LIBS) $(CFLAGS)
#keygen: keygen.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c
# $(CC) -std=c99 -g -o keygen keygen.c ../libs/micro-ecc/uECC.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c -lmbedtls -lmbedx509 -lmbedcrypto $(LIBS) $(CFLAGS)
keygen: keygen.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c
$(CC) -std=c99 -g -o keygen keygen.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c -lmbedtls -lmbedx509 -lmbedcrypto -lsodium $(LIBS) $(CFLAGS)
test2: test2.c
$(CC) -std=c99 -o test2 test2.c ../libs/micro-ecc/uECC.c -lmbedtls -lmbedx509 -lmbedcrypto $(LIBS) $(CFLAGS)
......
......@@ -9,29 +9,52 @@
#define uECC_TEST_NUMBER_OF_ITERATIONS 1
#endif
char shared_secret[SHARED_SECRET_SIZE];
char decompressed_point[64];
int main ()
{
struct pl_keypair *receiver;
struct pl_keypair *rx_kp;
char encrypted_message[sizeof(struct pl_pagermessage)];
// initialise the pager
struct pl_ctx * context;
context = pl_init(context);
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;
read(STDIN_FILENO, context->msg , sizeof(struct pl_pagermessage));
pl_receive_message(context);
printf("the decrypted message: %s \n", context->msg->msg);
struct pl_ctx * rx_ctx ;
rx_ctx = pl_init();
rx_kp = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
pl_load_key(rx_kp, "meinsleusel");
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;
read(STDIN_FILENO, rx_ctx->msg , sizeof(struct pl_pagermessage));
switch(pl_receive_message(rx_ctx)) {
case 0:
printf("RCV: OK! \n");
break;
case -1:
printf("RCV: -1 (box open error)\n");
break;
case -2:
printf("RCV: -2 \n");
break;
case -3:
printf("RCV: -3 (zerobytes not zero)\n");
break;
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;
}
......@@ -9,35 +9,34 @@
#define uECC_TEST_NUMBER_OF_ITERATIONS 1
#endif
char shared_secret[SHARED_SECRET_SIZE];
char decompressed_point[64];
int main()
{
struct pl_keypair *sender, *receiver;
struct pl_keypair *tx_kp;
char *rx_pubkey;
char clear_message[] = "dit is een test berichtje :) ";
// initialise the pager
struct pl_ctx * context;
context = pl_init(context);
struct pl_ctx * tx_ctx;
tx_ctx = pl_init();
tx_kp = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
pl_load_key(tx_kp, "sender.keypair"); // load tx keypair
sender = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
receiver = (struct pl_keypair *) malloc(sizeof(struct pl_keypair));
rx_pubkey = malloc(crypto_box_PUBLICKEYBYTES);
pl_load_public_key(rx_pubkey, "receiver.pub"); // load tx keypair
pl_load_key(sender, "sender.keypair"); // load tx keypair
pl_load_key(receiver, "receiver.keypair"); // load tx keypair
tx_ctx->kp = tx_kp;
context->kp = sender;
memcpy(tx_ctx->msg->msg, clear_message, MSG_SIZE);
memcpy(&tx_ctx->receiver_public_key, rx_pubkey , crypto_box_PUBLICKEYBYTES);
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);
// DBM("context->recv_comp_point", sizeof(tx_ctx->kp->private_key), &context->receiver_compressed_point);
pl_send_message(context);
pl_send_message(tx_ctx);
write(STDOUT_FILENO,context->msg, sizeof(struct pl_pagermessage));
write(STDOUT_FILENO,tx_ctx->msg, sizeof(struct pl_pagermessage));
return 0;
}
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