Commit b8bf6465 authored by hark's avatar hark
Browse files

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

Conflicts:
	base-tx/test.c
	libs/pagerlib/packets.h
	libs/pagerlib/pagerlib.c
parents 637f78f3 2d4b1bf2
......@@ -3,7 +3,7 @@
url = https://github.com/kmackay/micro-ecc.git
[submodule "arduino-build"]
path = arduino-build
url = ssh://git@gitlab.net.020wireless.nl:2222/yids/arduino-build.git
url = git@185.52.224.4:yids/arduino-build.git
[submodule "libs/AESLib"]
path = libs/AESLib
url = https://github.com/y1ds/AESLib.git
......
CC=colorgcc
CFLAGS="-I ../libs"
all: test
all: test rx-test tx-test keygen
base-tx: base-tx.c
$(CC) -o base-tx base-tx.c $(LIBS) $(CFLAGS)
test: test.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c ../libs/pagerlib/pagerlib.h ../libs/pagerlib/packets.h
$(CC) -std=c99 -g -o test test.c ../libs/micro-ecc/uECC.c ../libs/pagerlib/pagerlib.c ../libs/pagerlib/things.c -lmbedtls -lmbedx509 -lmbedcrypto $(LIBS) $(CFLAGS)
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)
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)
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)
test2: test2.c
$(CC) -std=c99 -o test2 test2.c ../libs/micro-ecc/uECC.c -lmbedtls -lmbedx509 -lmbedcrypto $(LIBS) $(CFLAGS)
clean :
rm -r test tx-test rx-test keygen
#include "../libs/micro-ecc/uECC.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../libs/pagerlib/pagerlib.h"
#ifndef uECC_TEST_NUMBER_OF_ITERATIONS
#define uECC_TEST_NUMBER_OF_ITERATIONS 1
#endif
char shared_secret[SHARED_SECRET_SIZE];
char decompressed_point[64];
int main()
{
return 0;
}
#include "../libs/micro-ecc/uECC.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "../libs/pagerlib/pagerlib.h"
#ifndef uECC_TEST_NUMBER_OF_ITERATIONS
#define uECC_TEST_NUMBER_OF_ITERATIONS 1
#endif
char shared_secret[SHARED_SECRET_SIZE];
char decompressed_point[64];
int main ()
{
struct pl_keypair *receiver;
char crypt_message[sizeof(struct pl_pagermessage)];
char decrypted_message[128];
struct pl_pagermessage * received_message;
read(STDIN_FILENO, crypt_message, sizeof(struct pl_pagermessage));
pl_init();
received_message=(struct pl_pagermessage *) malloc(sizeof(struct pl_pagermessage));
memset(received_message, 7, sizeof(struct pl_pagermessage));
pl_load_key(receiver, "receiver.keypair");
memcpy(received_message->msg, crypt_message, MSG_SIZE);
pl_receive_message(receiver, received_message, &decrypted_message, &shared_secret, &decompressed_point);
return 0;
}
......@@ -87,7 +87,16 @@ int main() {
pl_receive_message(context);
printf("the decrypted message: %s \n", context->msg->msg);
// printf("\n ----------------------------\n");
// printf("\n ----------------------------\n");
// dump_buffer(sizeof(struct pl_pagermessage), sended_msg);
//printf("\n The message that decrypted: \n");
// pl_receive_message(receiver, sended_msg, &decrypted_message, &shared_secret, &decompressed_point);
//printf("the message: %s", &decrypted_message);
//printf("\n ----------------------------\n");
return 0;
}
#include "../libs/micro-ecc/uECC.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../libs/pagerlib/pagerlib.h"
#ifndef uECC_TEST_NUMBER_OF_ITERATIONS
#define uECC_TEST_NUMBER_OF_ITERATIONS 1
#endif
char shared_secret[SHARED_SECRET_SIZE];
char decompressed_point[64];
int main()
{
struct pl_keypair *transmitter;
char plain_message[] = "test bericht lala";
char crypt_message[sizeof(struct pl_pagermessage)];
char encrypted_message[128];
struct pl_pagermessage * sent_message;
pl_init();
sent_message=(struct pl_pagermessage *) malloc(sizeof(struct pl_pagermessage));
memset(sent_message, 7, sizeof(struct pl_pagermessage));
pl_load_key(transmitter, "receiver.keypair");
memcpy(sent_message->msg, crypt_message, MSG_SIZE);
pl_send_message(transmitter, sent_message, &plain_message, &shared_secret, &decompressed_point);
return 0;
}
......@@ -26,7 +26,6 @@ extern "C"
#define CURVE uECC_secp256r1()
#define ECC_COMPRESSED_SIZE 33
#define SHARED_SECRET_SIZE 39
/* AES stuff
AES_KEYSIZE: keysize of aes key
IV_SIZE: always 16? FIXME
......
......@@ -82,7 +82,7 @@ inline int pl_send_message(struct pl_ctx *ctx) {
// 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);
......@@ -110,7 +110,7 @@ inline int pl_send_message(struct pl_ctx *ctx) {
#else
mbedtls_aes_init( &ctx->aes_ctx );
/* encrypt message with aes using shared secret as the key */
/* encrypt message with aes using shared secret as the key */
mbedtls_aes_setkey_enc( &ctx->aes_ctx, &ctx->shared_secret, AES_KEYSIZE );
char cmsg[MSG_SIZE];
......@@ -123,9 +123,10 @@ inline int pl_send_message(struct pl_ctx *ctx) {
mbedtls_aes_crypt_cbc( &ctx->aes_ctx, MBEDTLS_AES_ENCRYPT, MSG_SIZE, civ, &cmsg, &ctx->msg->msg );
mbedtls_aes_free (&ctx->aes_ctx);
// DBG("message to send: %s \n ", ctx->msg);
DBG("message to send: %s \n ", ctx->msg);
#endif
#endif
/*
char to_base64[sizeof(struct pl_keypair)];
base64_encode(&to_base64, to, sizeof(struct pl_keypair));
......@@ -138,8 +139,6 @@ inline int pl_send_message(struct pl_ctx *ctx) {
DBM("msg->msg in pl_send_message after crypt", sizeof(ctx->msg->msg), &ctx->msg->msg);
DBM("iv in pl_send_message after crypt", sizeof(ctx->msg->iv), &ctx->msg->iv);
return 0;
}
inline int pl_receive_message(struct pl_ctx * ctx)
......
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