Fixed bugs in new AEs encryption layer.

This commit is contained in:
Starbeamrainbowlabs 2019-07-15 14:31:39 +01:00
parent 723941bdf8
commit d806a2e4c9
3 changed files with 12 additions and 4 deletions

View file

@ -55,8 +55,13 @@ void setup() {
// Activate the RFM95
peripheral_switch(PIN_SPI_CS_SD, PIN_SPI_CS_RFM95);
const uint8_t message_size = sizeof(uint32_t) + sizeof(float)*2;
// Initialise an array to store the message in,but make sure it's at least 16 bytes long (because of AES restrictions at the other end)
uint8_t message_size = sizeof(uint32_t) + sizeof(float)*2;
if(message_size < 16) message_size = 16;
uint8_t message[message_size];
// Initialise the message to a known state (i.e. null bytes)
for(uint8_t i = 0; i < message_size; i++)
message[i] = 0;
const uint8_t* bytes_id = reinterpret_cast<uint8_t const *>(&id);
const uint8_t* bytes_lat = reinterpret_cast<uint8_t const *>(&(gps_data.lat));

View file

@ -10,9 +10,12 @@ function decode_payload(payload_base64, key_hex) {
let payload_buffer_enc = Buffer.from(payload_base64, "base64");
let key_buffer = Buffer.from(key_hex, "hex");
let aes_ecb = new aes.ModeOfOperation.ecb(key_buffer);
let payload_buffer = aes_ecb.decrypt(payload_buffer_enc);
console.log(payload_buffer_enc);
let aes_ecb = new aes.ModeOfOperation.ecb(key_buffer);
let payload_buffer = Buffer.from(aes_ecb.decrypt(payload_buffer_enc).buffer);
console.debug(payload_buffer);
// console.debug(`Offsets: ${offset_id}, ${offset_lat}, ${offset_lng}`);
// console.debug(`Message hex: ${payload_buffer.toString("hex")}`)

View file

@ -5,7 +5,7 @@ import { get_id_number } from '../Helpers/IdGenerator.mjs';
class MessageHandler {
get debug() {
return this.settings.logging.debug;
return this.settings.logging.verbose;
}
constructor({ settings, ReadingRepo, GatewayRepo }) {
this.settings = settings;