Commit 29486290 authored by yids's avatar yids

c file

parent ba716f9f
......@@ -97,6 +97,26 @@ inline int pl_set_receiver(struct pl_ctx *ctx, char *public_key)
return 0;
}
/* int pl_set_receiver_by_address(struct pl_ctx *ctx, uint32_t addr);
* loops over the list of public keys and sets the key with address addr as the receiver in the context
* returns 0 if key is found
* returns 1 if key is not found
*/
int pl_set_receiver_by_address(struct pl_ctx *ctx, uint32_t addr)
{
struct list_public_key * list;
int found = 0;
for(list = ctx->public_keys; list != NULL; list = list->next) {
if (addr == list->id){
// set keypair to use
memcpy(ctx->receiver_public_key, list->public_key, crypto_box_PUBLICKEYBYTES);
found = 1;
return 0;
}
}
return 1;
}
/*
* 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 in ctx->msg->msg
......@@ -135,6 +155,20 @@ inline int pl_send_message(struct pl_ctx *ctx) {
return 0;
}
/* pl_send_message_fifo(struct pl_ctx * ctx, char *fifo)
* sends the pagermessage to a fifo
*/
int pl_send_message_fifo(struct pl_ctx *ctx, char *fifo)
{
int fd;
mkfifo(fifo, 0666);
fd = open(fifo, O_WRONLY);
write(fd, ctx->msg, sizeof(struct pl_pagermessage));
close(fd);
//unlink(fifo);
return 0;
}
int pl_receive_message(struct pl_ctx * ctx)
{
// memset(&ctx->clear_message, 7, sizeof(ctx->clear_message));
......@@ -243,7 +277,7 @@ int pl_save_key(struct pl_keypair *key, char *filename)
#endif
}
int pl_load_key(struct pl_ctx *ctx, char *filename)
int pl_load_keypair(struct pl_ctx *ctx, char *filename)
{
struct pl_keypair *keypair;
#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