![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork to force BLE id to have prefix that is assumed by the app
Dependencies: BLE_API Crypto RNG mbed nRF51822
Fork of Garagem by
Diff: SecurityService.h
- Revision:
- 13:bc1be947b497
- Parent:
- 12:eaee29bfa1c7
diff -r eaee29bfa1c7 -r bc1be947b497 SecurityService.h --- 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)); }