本文整理汇总了C++中AES::set_IV方法的典型用法代码示例。如果您正苦于以下问题:C++ AES::set_IV方法的具体用法?C++ AES::set_IV怎么用?C++ AES::set_IV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AES
的用法示例。
在下文中一共展示了AES::set_IV方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transportReceive
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;
}
示例2: transportReceive
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;
}
示例3: transportSend
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;
}
示例4: transportInit
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();
}
示例5: transportSend
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
}
示例6: transportSend
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;
}
示例7: transportReceive
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;
}