uint8_t transportReceive(void* data) { uint8_t len = _rf24.getDynamicPayloadSize(); _rf24.read(data, len); #if defined(MY_RF24_ENABLE_ENCRYPTION) _aes.set_IV(0);//not sure if necessary _aes.cbc_decrypt((byte*)(data), (byte*)(data), len>16?2:1); // decrypt #endif return len; }
uint8_t transportReceive(void* data) { uint8_t len = RF24_readMessage(data); #if defined(MY_RF24_ENABLE_ENCRYPTION) // has to be adjusted, WIP! _aes.set_IV(0); // decrypt data _aes.cbc_decrypt((byte*)(data), (byte*)(data), len>16?2:1); #endif return len; }
bool transportSend(uint8_t recipient, const void* data, uint8_t len) { #if defined(MY_RF24_ENABLE_ENCRYPTION) // copy input data because it is read-only memcpy(_dataenc,data,len); len = len > 16 ? 32 : 16; #if defined(MY_GATEWAY_FEATURE) SdReadNodeData(RF24_getNodeID(), nd); _aes.set_key(nd.AES_256,32); _aes.set_IV(nd.IV); #else #endif //encrypt data _aes.set_IV(IVCl); _aes.cbc_encrypt(_dataenc, _dataenc, len/16); bool status = RF24_sendMessage( recipient, _dataenc, len ); #else bool status = RF24_sendMessage( recipient, data, len ); #endif return status; }
bool transportInit() { #if defined(MY_RF24_ENABLE_ENCRYPTION) hwReadConfigBlock((void*)_psk, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 32); //set up AES-key _aes.set_key(_psk, 32); // Make sure it is purged from memory when set memset(_psk, 0, 32); //set up AES IV hwReadConfigBlock((void*)IVCl,(void*)EEPROM_RF_ENCRYPTION_AES_IV_ADDRESS,8); _aes.set_IV(IVCl); #endif return RF24_initialize(); }
bool transportSend(const uint8_t to, const void *data, const uint8_t len, const bool noACK) { #if defined(MY_RF24_ENABLE_ENCRYPTION) // copy input data because it is read-only (void)memcpy(RF24_dataenc,data,len); // has to be adjusted, WIP! RF24_aes.set_IV(0); const uint8_t finalLength = len > 16 ? 32 : 16; //encrypt data RF24_aes.cbc_encrypt(RF24_dataenc, RF24_dataenc, finalLength / 16); return RF24_sendMessage(to, RF24_dataenc, finalLength, noACK); #else return RF24_sendMessage(to, data, len, noACK); #endif }
bool transportSend(uint8_t to, const void* data, uint8_t len) { #if defined(MY_RF24_ENABLE_ENCRYPTION) memcpy(_dataenc,data,len); // copy input data because it is read-only _aes.set_IV(0);//not sure if necessary len = len > 16 ? 32 : 16; _aes.cbc_encrypt(_dataenc, _dataenc, len/16); //encrypt #endif // Make sure radio has powered up _rf24.powerUp(); _rf24.stopListening(); _rf24.openWritingPipe(TO_ADDR(to)); #if defined(MY_RF24_ENABLE_ENCRYPTION) bool ok = _rf24.write(_dataenc, len, to == BROADCAST_ADDRESS); #else bool ok = _rf24.write(data, len, to == BROADCAST_ADDRESS); #endif _rf24.startListening(); return ok; }
uint8_t transportReceive(void *data) { uint8_t len = 0; #if defined(MY_RX_MESSAGE_BUFFER_FEATURE) transportQueuedMessage* msg = transportRxQueue.getBack(); if (msg) { len = msg->m_len; (void)memcpy(data, msg->m_data, len); (void)transportRxQueue.popBack(); } #else len = RF24_readMessage(data); #endif #if defined(MY_RF24_ENABLE_ENCRYPTION) // has to be adjusted, WIP! RF24_aes.set_IV(0); // decrypt data if (RF24_aes.cbc_decrypt((uint8_t *)data, (uint8_t *)data, len > 16 ? 2 : 1) != AES_SUCCESS) { len = 0; } #endif return len; }