BLE Application to open a Garage door
Dependencies: BLE_API Crypto RNG mbed nRF51822
Fork of BLE_LED by
Revision 13:bc1be947b497, committed 2015-08-30
- Comitter:
- dgomes
- Date:
- Sun Aug 30 01:06:17 2015 +0000
- Parent:
- 12:eaee29bfa1c7
- Child:
- 14:1c187c90992c
- Commit message:
- Works :)
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RNG.lib Sun Aug 30 01:06:17 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/feb11/code/RNG/#75b4f86fb3aa
--- a/SecurityService.h Wed Aug 26 00:59:07 2015 +0000 +++ b/SecurityService.h Sun Aug 30 01:06:17 2015 +0000 @@ -2,7 +2,7 @@ #define __BLE_SECURITY_SERVICE_H__ #include "Crypto.h" - +#include "Random.h" class SecurityService { public: @@ -22,8 +22,10 @@ } void init(char *shared_key) { //Initialize AES + uint8_t new_iv[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + memcpy(iv, new_iv,16); + ble.gattServer().write(SecurityIV.getValueHandle(), (uint8_t *)iv, 16*sizeof(uint8_t)); setKey(shared_key); - genIV(); } void decode(uint8_t *out, uint8_t *in, uint32_t len) { @@ -38,9 +40,9 @@ } void genIV() { - //TODO RANDOM THIS: - uint8_t new_iv[16] = { 0xA2, 0x68, 0x56, 0x36, 0x52, 0x18, 0x71, 0xD0, 0x23, 0x06, 0xE2, 0xEB, 0x8F, 0x70, 0x27, 0xB3 }; - memcpy(iv, new_iv,16); + Random rnd; + rnd.init(); + rnd.getBytes(iv, 16); ble.gattServer().write(SecurityIV.getValueHandle(), (uint8_t *)iv, 16*sizeof(uint8_t)); }
--- a/main.cpp Wed Aug 26 00:59:07 2015 +0000 +++ b/main.cpp Sun Aug 30 01:06:17 2015 +0000 @@ -1,4 +1,4 @@ -#define DEBUG +//#define DEBUG #ifndef DEBUG #define DEVICE_SERIAL 0 //disable SERIAL so me can use P0_8 (shared with serial)