From 327aaf46f8a0775d5a7ca4d7aae6ba1297a65430 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 4 Apr 2018 12:39:40 +0200 Subject: [PATCH] created centralized function salt_reset() --- src/globals.h | 2 +- src/macsniff.h | 1 + src/main.cpp | 7 ++++--- src/rcommand.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/globals.h b/src/globals.h index 56d6b669..396f7fa9 100644 --- a/src/globals.h +++ b/src/globals.h @@ -44,7 +44,7 @@ extern configData_t cfg; extern uint8_t mydata[]; extern uint64_t uptimecounter; extern osjob_t sendjob; -extern int countermode, screensaver, adrmode, lorasf, txpower, rlim, salt; +extern int countermode, screensaver, adrmode, lorasf, txpower, rlim; extern bool joinstate; extern std::set wifis; extern std::set macs; diff --git a/src/macsniff.h b/src/macsniff.h index 423c62b8..fb00cd6d 100644 --- a/src/macsniff.h +++ b/src/macsniff.h @@ -19,6 +19,7 @@ typedef struct { uint8_t payload[0]; /* network data ended with 4 bytes csum (CRC32) */ } wifi_ieee80211_packet_t; +uint16_t salt_reset(void); void BLECount(); void wifi_sniffer_init(void); void wifi_sniffer_set_channel(uint8_t channel); diff --git a/src/main.cpp b/src/main.cpp index 63eb4f2a..0a4c2084 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,7 @@ Refer to LICENSE.txt file in repository for more details. // OLED driver #include +#include // Does nothing and avoid any compilation error with I2C // LMIC-Arduino LoRaWAN Stack #include "loraconf.h" @@ -45,7 +46,7 @@ configData_t cfg; // struct holds current device configuration osjob_t sendjob, initjob; // LMIC // Initialize global variables -int macnum = 0, salt; +int macnum = 0; uint64_t uptimecounter = 0; bool joinstate = false; @@ -291,7 +292,7 @@ void wifi_sniffer_loop(void * pvParameters) { #ifdef BLECOUNTER bles.clear(); // clear BLE macs counter #endif - salt = random(65536); // get new 16bit random for salting hashes + salt_reset(); // get new salt for salting hashes u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter } @@ -489,7 +490,7 @@ wifi_sniffer_init(); // setup wifi in monitor mode and start MAC counting // initialize salt value using esp_random() called by random() in arduino-esp32 core // note: do this *after* wifi has started, since gets it's seed from RF noise -salt = random(65536); // get new 16bit random for salting hashes +salt_reset(); // get new 16bit for salting hashes // Start FreeRTOS tasks #if CONFIG_FREERTOS_UNICORE // run all tasks on core 0 and switch off core 1 diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 09d813fc..2e9ea33c 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -70,7 +70,7 @@ void set_reset(int val) { macs.clear(); // clear all macs container wifis.clear(); // clear Wifi macs container bles.clear(); // clear BLE macs container - salt = random(65536); // get new 16bit random for salting hashes + salt_reset(); // get new 16bit salt u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter u8x8.clearLine(5); u8x8.setCursor(0, 5);