Commit 54d2af80 authored by yids's avatar yids
Browse files

first commit

parents
Pipeline #1 skipped
BOARD_TAG=atmega328
ARDUINO_LIBS=RadioHead SPI AESLib
include /usr/share/arduino/Arduino.mk
DEVICE_PATH = /dev/ttyUSB1
TARGET = arduino-rx
// ask_receiver.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to receive messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) receiver with an Rx-B1 module
#include <stdarg.h>
#include <ecc.h>
#include <AESLib.h>
#include <RadioHead.h>
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
RH_ASK driver;
//my pub-priv keypair
uint8_t private_0[NUM_ECC_DIGITS] = {0x4D, 0xDE, 0x17, 0xCE, 0xAC, 0x4F, 0x81, 0x25, 0xA9, 0xE5, 0xC1, 0x82, 0x79, 0x65, 0x71, 0x13, 0x47, 0xD6, 0xF4, 0x3B, 0x5E, 0x1F, 0x27, 0x53};
EccPoint public_0 = {
{0xF3, 0xCD, 0x7D, 0x81, 0x15, 0x01, 0xC0, 0x3E, 0xB5, 0x56, 0x5B, 0xF1, 0x1A, 0x99, 0xFB, 0x0B, 0x20, 0x2B, 0x18, 0x82, 0xD3, 0x71, 0x6F, 0x1E},
{0x4B, 0x84, 0xC7, 0xDD, 0x67, 0x6B, 0xED, 0x45, 0x1A, 0x4B, 0x54, 0x5A, 0x19, 0xCA, 0x1B, 0x6F, 0x3B, 0x93, 0xBA, 0xF4, 0x2A, 0x9B, 0x65, 0x69}};
// other pub key
EccPoint public_1 = {
{0x90, 0x6F, 0xFC, 0xC8, 0x07, 0xA8, 0x93, 0x9C, 0x3B, 0xDC, 0xAF, 0xF1, 0x8D, 0xA9, 0x96, 0xF8, 0xC2, 0x3B, 0x85, 0x3E, 0x5C, 0x65, 0xDE, 0x32},
{0xE1, 0xB1, 0x28, 0x7F, 0xD3, 0xB0, 0x94, 0x24, 0x69, 0x95, 0xDE, 0x76, 0x40, 0x15, 0x6E, 0xAE, 0x74, 0xE9, 0x56, 0x94, 0xA7, 0xE4, 0x63, 0xEF}};
void p(char *fmt, ... ){
char tmp[128]; // resulting string limited to 128 chars
va_list args;
va_start (args, fmt );
vsnprintf(tmp, 128, fmt, args);
va_end (args);
Serial.print(tmp);
}
void dump(char *text, uint8_t *d) {
int i;
p("%-20s", text);
for (i = 0; i < NUM_ECC_DIGITS; ++i)
p("%02x ", d[NUM_ECC_DIGITS-i-1]);
Serial.print("\n");
}
void decryptAES(uint8_t secret_0, uint8_t* data)
{
// aes128_dec_single(secret_0, data);
}
void shareSecret()
{
uint8_t secret_0[NUM_ECC_DIGITS] = { 0, };
ecdh_shared_secret(secret_0, &public_1, private_0, NULL);
dump("secret", secret_0);
}
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("hoi");
if (!driver.init())
Serial.println("init failed");
}
void loop()
{
shareSecret();
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
//char data[16];
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
driver.printBuffer("Got encrypted:", buf, buflen);
}
}
build-atmega328/arduino-rx.o: arduino-rx.ino \
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/binary.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h \
/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \
/usr/share/arduino/hardware/arduino/cores/arduino/new.h \
/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \
ecc.h /usr/share/arduino/libraries/AESLib/AESLib.h \
/usr/share/arduino/libraries/RadioHead/RadioHead.h \
/usr/share/arduino/libraries/SPI/SPI.h \
/usr/share/arduino/libraries/RadioHead/RH_ASK.h \
/usr/share/arduino/libraries/RadioHead/RHGenericDriver.h
This diff is collapsed.
build-atmega328/core/CDC.o: \
/usr/share/arduino/hardware/arduino/cores/arduino/CDC.cpp \
/usr/share/arduino/hardware/arduino/cores/arduino/Platform.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/binary.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h \
/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \
/usr/share/arduino/hardware/arduino/cores/arduino/new.h \
/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h
build-atmega328/core/HID.o: \
/usr/share/arduino/hardware/arduino/cores/arduino/HID.cpp \
/usr/share/arduino/hardware/arduino/cores/arduino/Platform.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/binary.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h \
/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \
/usr/share/arduino/hardware/arduino/cores/arduino/new.h \
/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h \
/usr/share/arduino/hardware/arduino/cores/arduino/USBDesc.h
build-atmega328/core/HardwareSerial.o: \
/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp \
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/binary.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h \
/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \
/usr/share/arduino/hardware/arduino/cores/arduino/new.h \
/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_private.h
build-atmega328/core/IPAddress.o: \
/usr/share/arduino/hardware/arduino/cores/arduino/IPAddress.cpp \
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/binary.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h \
/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \
/usr/share/arduino/hardware/arduino/cores/arduino/new.h \
/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/IPAddress.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h
build-atmega328/core/Print.o: \
/usr/share/arduino/hardware/arduino/cores/arduino/Print.cpp \
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/binary.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h \
/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \
/usr/share/arduino/hardware/arduino/cores/arduino/new.h \
/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h
build-atmega328/core/Stream.o: \
/usr/share/arduino/hardware/arduino/cores/arduino/Stream.cpp \
/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \
/usr/share/arduino/hardware/arduino/cores/arduino/binary.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h \
/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Print.h \
/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \
/usr/share/arduino/hardware/arduino/cores/arduino/new.h \
/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h
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