Commit 226c96da authored by yids's avatar yids

- added string.h to arduino-tx

- init pl_pagermessage in arduino-tx
- change declaration of data
- made some defines in pagerlib
- added some doc in pagerlib
parent 68dab2c9
Pipeline #35 skipped
......@@ -5,7 +5,7 @@
#include <RHDatagram.h>
#include <SPI.h> // Not actually used but needed to compile
#include <MemoryFree.h>
#include <string.h>
#include <pagerlib.h>
#define ADDRESS 5
......@@ -25,6 +25,8 @@ const struct uECC_Curve_t * curve = CURVE;
uint8_t sharedSecret[NUM_ECC_DIGITS];
uint8_t iv[16];
pl_pagermessage myMessage;
// uECC keys 192bit
uint8_t pubkey[NUM_ECC_DIGITS*2] = {0x67, 0xCF, 0x6C, 0x6F, 0x64, 0x19, 0xCC, 0xBF, 0x44, 0x60, 0x36, 0x2C, 0x99, 0x1D, 0x8C, 0x38, 0xFB, 0x6D, 0x18, 0xF2, 0x24, 0xEC, 0x8F, 0x8, 0xAB, 0x23, 0x76, 0xC, 0x4F, 0xA4, 0x63, 0x55, 0x26, 0xF8, 0x30, 0x9A, 0xA7, 0x6C, 0x55, 0x54, 0x10, 0x31, 0x0, 0xCA, 0x55, 0xF9, 0xC1, 0xFA};
uint8_t privkey[NUM_ECC_DIGITS+1] = {0xF6, 0x8B, 0x9B, 0x7F, 0xD9, 0xF8, 0xF7, 0x8C, 0x1, 0x1F, 0x6F, 0xF1, 0x9A, 0x6D, 0xC, 0xFC, 0xD4, 0x78, 0xBE, 0x26, 0x85, 0x78, 0xFD, 0xCA, 0xF4};
......@@ -198,7 +200,7 @@ void loop()
Serial.println("start");
generateIV();
// uint8_t iv[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
char data[] = "Hallo dit is een test";
char data[32] = "Hallo dit is een test";
calcSharedSecret(remotePubkey, privkey);
sendAll(data);
// delay(2000);
......
......@@ -7,15 +7,32 @@ extern "C"
{
#endif
#define ECC_COMPRESSED_SIZE 33
#define MSG_SIZE 128
#define SHARED_SECRET_SIZE 32
//256 bits aes
#define AES_KEYSIZE 256
#define IV_SIZE 16
/* curve ecc size and shared secret size
ECC_COMPRESSED_SIZE: size of the compressed publiv key, curvesize+1, for example, if the curve is secp256r1 compressed must be 33 bytes long.
curve can be:
uECC_secp160r1();
uECC_secp192r1();
uECC_secp224r1();
uECC_secp256k1();
ECC_COMPRESSED_SIZE == SHARED_SECRET_SIZE FIXME
*/
#define CURVE uECC_secp192r1()
#define ECC_COMPRESSED_SIZE 24
#define SHARED_SECRET_SIZE 24
/* message stuff
MSG_SIZE: size of the actual message
*/
#define MSG_SIZE 32
/* AES stuff
AES_KEYSIZE: keysize of aes key
IV_SIZE: always 16? FIXME
*/
#define AES_KEYSIZE 192
#define IV_SIZE 16
// pager.h
......@@ -28,7 +45,7 @@ struct pl_keypair
{
uint8_t public_key[64];
uint8_t private_key[32];
uint8_t compressed_point[33];
uint8_t compressed_point[ECC_COMPRESSED_SIZE];
};
//Will be filled in with the compressed public key. Must be at least
......@@ -37,9 +54,9 @@ struct pl_keypair
struct pl_pagermessage
{
uint8_t sender_compressed_point[33];
char msg[MSG_SIZE];
uint8_t sender_compressed_point[ECC_COMPRESSED_SIZE];
unsigned char iv[IV_SIZE];
char msg[MSG_SIZE];
};
/* subjectPublicKeyInfo field
......
......@@ -43,7 +43,7 @@ unsigned char fakeiv[] = "123456789abcdefghijklmnop";
void pl_init() {
curve = uECC_secp256k1();
curve = CURVE;
/*
msg = malloc(sizeof(struct pl_pagermessage));
memset(msg, 7, sizeof(struct pl_pagermessage));
......
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