Commit 35d5a2db authored by yids's avatar yids
Browse files

Merge branch 'master' of 185.52.224.4:yids/avr-pager

Conflicts:
	base-tx/test.c
parents d5c80abb 6ffef450
......@@ -14,7 +14,12 @@ possible ways to get the message to the pager:
- own transmitter
- iridium paging system
- udp packets via sattelite with a not encrypted dvb-ip downlink
- encoded in color changin lights (this thing with the twitter lights)
- on fm broadcast station (as fsk)
- soundsystem
how we do it now:
- with an arduino + radiohead library and OOK via a pin
some things on ECC:
......@@ -33,3 +38,4 @@ TODO:
- fix the serial input of the arduino-tx so you can send messages to it
- make a program to generate keypairs and upload them to the pager
- displaying the received messages in a proper way
- message counters (to know how many you missed)
=Jڵ1]6bVUsF$5q>ܾS1?htJ6
\ No newline at end of file
<<<<<<< HEAD
:; y;p~bdN6 휉cP~4I( {}Mo<44eH
=======
=Jڵ1]6bVUsF$5q>ܾS1?htJ6
>>>>>>> d272dd12fd328253d3387159caf4731d11acb7c0
uR'_S\zNuxiW=RCZ%澜%'5.\v
\ No newline at end of file
<<<<<<< HEAD
='srWPື Ob=h^JJAIr\j&a5ɪ
=======
uR'_S\zNuxiW=RCZ%澜%'5.\v
>>>>>>> d272dd12fd328253d3387159caf4731d11acb7c0
......@@ -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 ";
......@@ -37,10 +32,9 @@ int main() {
DBG("pagerlib initialized \n");
}
*/
context = pl_init();
// 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));
......@@ -50,20 +44,23 @@ int main() {
/* create keypairs */
pl_create_keypair(context, sender);
pl_save_key(sender,"sender.keypair");
pl_save_key(sender,"sender_test.keypair");
pl_create_keypair(context, receiver);
pl_save_key(receiver,"receiver.keypair");
pl_save_key(receiver,"receiver_test.keypair");
//switch to sender key
// context->kp = sender;
pl_load_key(sender, "sender.keypair");
pl_load_key(receiver, "receiver.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
pl_print_keylist(context);
// ------------------------------------------------- //
// set key to use for sending the message
context->kp = sender;
/*
......@@ -72,14 +69,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);
......
......@@ -92,7 +92,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) {
......@@ -100,14 +100,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);
......@@ -116,8 +114,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)) {
......@@ -315,21 +313,7 @@ pl_print_keylist(struct pl_ctx *ctx) {
printf("the list of loaded keys: \n ");
for(list = ctx->keypairs; list != NULL; list = list->next) {
printf("address in list: %u \n", list->id );
/*
if (ctx->msg->address == list->id)
{
DBG("Found address in list!");
// set keypair to use
ctx->kp = list->kp;
}
else
{
DBG("address not found in list, message probably not for us");
return 1;
}
}
*/
}
}
}
......@@ -43,13 +43,33 @@ extern "C"
#include "packets.h"
/*
* List of all the available keypairs
* Should we use same list for only pubkeys?
*/
typedef struct list_kp {
uint32_t id;
struct pl_keypair *kp;
struct list_kp *next;
// things maybe:
// - nickname
// - message counter
} list_kp;
/*
* the inbox
*/
typedef struct list_inbox {
int status; // 1 unread 2 read
struct pl_pagermessage *msg;
struct list_inbox *prev;
struct list_inbox *next;
} list_inbox;
/*
* pagerlib context for sending or receiving messages
......@@ -68,7 +88,7 @@ struct pl_ctx
struct pl_keypair *kp;
// keypair list (all available keypairs)
struct list_kp *keypairs;
// struct pl_keypair *to, *from;
// place to store messages to be sent or received
struct pl_pagermessage *msg;
uint8_t receiver_compressed_point[ECC_COMPRESSED_SIZE];
......
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