Commit 6719363a authored by hark's avatar hark

save keys

parent 8fa05907
......@@ -6,6 +6,17 @@ to try it out:
apt-get install arduino arduino-mk
- get the required libraries from https://gitlab.net.020wireless.nl/yids/arduino-build
- in base-tx there is test.c, it is a test for the messages
possible ways to get the message to the pager:
- udp packets to open wifi ap
- multicast on lorawan
- own transmitter
- iridium paging system
- udp packets via sattelite with a not encrypted dvb-ip downlink
some things on ECC:
http://www.infosecwriters.com/Papers/Anoopms_ECC.pdf
......
......@@ -10,21 +10,15 @@ struct keypair
uint8_t compressed_point[33];
};
struct pagermessage
{
//Will be filled in with the compressed public key. Must be at least
// (curve size + 1) bytes long; for example, if the curve is secp256r1,
// compressed must be 33 bytes long.
struct pagermessage
{
uint8_t sender_compressed_point[33];
// address is SHA1 hash of publickey
//int address;
// maybe use 7bit ascii, or even smaller characters (only letters + numbers)
char msg[128];
//unsigned char key[32];
unsigned char iv[16];
unsigned char iv[16];
};
/* subjectPublicKeyInfo field
......
......@@ -97,7 +97,15 @@ struct pagermessage * send_message(struct keypair *to, struct keypair *from, c
*/
// dump_buffer(sizeof(struct pagermessage), msg);
return msg;
char to_base64[sizeof(struct keypair)];
base64_encode(&to_base64, to, sizeof(struct keypair));
printf(" \nto (keypair): len: %u base64: \n %129.129s \n", sizeof(struct keypair) ,to_base64, to);
char msg_base64[sizeof(struct pagermessage)];
base64_encode(&msg_base64, msg, sizeof(struct pagermessage));
printf(" \n encmsg: len: %u base64: \n %177.177s \n", sizeof(struct pagermessage) ,msg_base64, msg);
return msg;
}
void receive_message(struct keypair *me, struct pagermessage *msg)
{
......@@ -155,6 +163,21 @@ struct keypair * create_keypair() {
return keypair;
}
save_key(struct keypair *key, char * filename) {
FILE *f;
f = fopen(filename, "w");
fwrite(key, 1, sizeof(struct keypair), f);
fclose(f);
}
load_key(struct keypair *key, char * filename) {
FILE *f;
f = fopen(filename, "r");
fread(key, 1, sizeof(struct keypair), f);
fclose(f);
}
void pb(char buf) {
}
......@@ -185,7 +208,9 @@ int main() {
struct pagermessage * sended_msg;
/* create keypairs */
sender = create_keypair();
save_key(sender,"sender.keypair");
receiver = create_keypair();
save_key(receiver,"receiver.keypair");
sended_msg = send_message(receiver, sender, clear_message);
......
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