Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BahlDecrypModified CyaSSL mbed nRF51822
Fork of Decryptulator by
LookupTable.cpp
00001 #include "LookupTable.h" 00002 #include "sfh_mbed.h" 00003 00004 #include <iostream> 00005 #define LOOKUP_TABLE_SIZE 30000 00006 00007 LookupTable::LookupTable(void){ 00008 //uint32_t * lookupTable = new int[INITIAL_LOOKUP_TABLE_SIZE]; 00009 LookupTableStruct = new (nothrow) pair<BLEProtocol::AddressBytes_t, unsigned char *> * [LOOKUP_TABLE_SIZE]; 00010 00011 if(this->LookupTableStruct == NULL){ 00012 printf("Exception ignored, uncomment 'nothrow' for more efficient code\n\n"); 00013 } 00014 00015 } 00016 00017 void LookupTable::clearLookupTable(void){ 00018 for(uint32_t i = 0; i < LOOKUP_TABLE_SIZE; i++){ 00019 delete LookupTableStruct[i]; 00020 } 00021 delete [] LookupTableStruct; 00022 } 00023 00024 LookupTable::~LookupTable(void){ 00025 clearLookupTable(); 00026 } 00027 00028 00029 int LookupTable::insertValue(BLEProtocol::AddressBytes_t scanned_ble_address, unsigned char * encryptedCounter){ 00030 00031 if(scanned_ble_address == NULL || encryptedCounter == NULL) 00032 return -1; //Error 00033 00034 // map<const char * data, 00035 uint32_t hasehdBLEAddress = hash((const char *) scanned_ble_address, 6); 00036 //uint32_t hashedCounter = hash(encryptedCounter,sizeof(encryptedCounter)); 00037 00038 //map<BLEProtocol::AddressBytes_t, unsigned char *> indirectMap; 00039 uint32_t index = hasehdBLEAddress % LOOKUP_TABLE_SIZE; 00040 pair<BLEProtocol::AddressBytes_t, unsigned char *> tableValue;// = make_pair (scanned_ble_address,encryptedCounter); // (scanned_ble_address, encryptedCounter); 00041 //tableValue = make_pair(scanned_ble_address,encryptedCounter); 00042 tableValue = pair<BLEProtocol::AddressBytes_t, unsigned char *>(scanned_ble_address,encryptedCounter); 00043 LookupTableStruct[index] = &tableValue; 00044 00045 return 0; //Success 00046 }
Generated on Fri Jul 15 2022 14:11:05 by
1.7.2
