Commit 2d4b1bf2 authored by yids's avatar yids
Browse files

added some more test programs

parent 2669b4ef
......@@ -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
$(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;
}
/* Copyright 2014, Kenneth MacKay. Licensed under the BSD 2-clause license. */
#include "../libs/micro-ecc/uECC.h"
//#include "../include/oaes_lib.h"
//#include "mbedtls_config.h"
......@@ -51,13 +49,13 @@ int main() {
pl_send_message(receiver, sender, sended_msg, &shared_secret, &decompressed_point);
dump_buffer(sizeof(struct pl_pagermessage), sended_msg);
// dump_buffer(sizeof(struct pl_pagermessage), sended_msg);
printf("\n The message that decrypted: \n");
//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");
//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;
}
......@@ -25,7 +25,7 @@ extern "C"
/* message stuff
MSG_SIZE: size of the actual message
*/
#define MSG_SIZE 32
#define MSG_SIZE 64
/* AES stuff
AES_KEYSIZE: keysize of aes key
......
......@@ -58,7 +58,7 @@ void pl_init() {
pl_send_message(struct pl_keypair *to, struct pl_keypair *from, struct pl_pagermessage *msg, char * shared_secret, char * sender_decompressed_point) {
printf("thiniieeie\n");
/* create a random iv */
// TODO (this is stupid)
memcpy(msg->iv, fakeiv, sizeof(msg->iv));
......@@ -66,7 +66,7 @@ pl_send_message(struct pl_keypair *to, struct pl_keypair *from, struct pl_pager
// copy compressed point into pager message
memcpy(msg->sender_compressed_point, from->compressed_point, sizeof(msg->sender_compressed_point));
#ifndef NOCRYPT
//#ifndef NOCRYPT
/*calculate shared secret on sender*/
if (!uECC_shared_secret(to->public_key, from->private_key, shared_secret, curve)) {
DBG("shared_secret() failed (1)\n");
......@@ -74,7 +74,7 @@ pl_send_message(struct pl_keypair *to, struct pl_keypair *from, struct pl_pager
}
// dump_buffer(32, shared_secret);
// dump_buffer(16, msg->iv);
#ifdef ARDUINO
/*#ifdef ARDUINO
aes_ctx = aes192_cbc_enc_start(&shared_secret, msg->iv);
aes192_cbc_enc_continue(aes_ctx, msg->msg, MSG_SIZE);
......@@ -82,6 +82,7 @@ pl_send_message(struct pl_keypair *to, struct pl_keypair *from, struct pl_pager
#else
*/
mbedtls_aes_init( &aes_ctx );
/* encrypt message with aes using shared secret as the key */
......@@ -93,9 +94,10 @@ pl_send_message(struct pl_keypair *to, struct pl_keypair *from, struct pl_pager
mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_ENCRYPT, MSG_SIZE, msg->iv, cmsg, msg->msg );
mbedtls_aes_free (&aes_ctx);
DBG("message to send: %s \n ", msg);
#endif
#endif
//#endif
//#endif
/*
char to_base64[sizeof(struct pl_keypair)];
base64_encode(&to_base64, to, sizeof(struct pl_keypair));
......@@ -117,8 +119,8 @@ void pl_receive_message(struct pl_keypair *me, struct pl_pagermessage *msg, char
if (!uECC_shared_secret(sender_decompressed_point, me->private_key, shared_secret, curve)) {
DBG("shared_secret() failed (receive)\n");
}
DB(SHARED_SECRET_SIZE, shared_secret);
DB(IV_SIZE, msg->iv);
//DB(SHARED_SECRET_SIZE, shared_secret);
//DB(IV_SIZE, msg->iv);
#ifndef NOCRYPT
#ifdef ARDUINO
......@@ -141,7 +143,7 @@ void pl_receive_message(struct pl_keypair *me, struct pl_pagermessage *msg, char
#endif
DBG("decrypted_message: %s \n ", msg->msg);
DB(sizeof(decrypted_message), decrypted_message);
//DB(sizeof(decrypted_message), decrypted_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