2020-05-09 23:15:01 +00:00
|
|
|
#include "CryptoEngine.h"
|
|
|
|
#include "configuration.h"
|
|
|
|
|
2021-02-23 02:10:35 +00:00
|
|
|
void CryptoEngine::setKey(const CryptoKey &k)
|
2020-05-09 23:15:01 +00:00
|
|
|
{
|
2021-02-23 02:10:35 +00:00
|
|
|
DEBUG_MSG("Installing AES%d key!\n", k.length * 8);
|
|
|
|
key = k;
|
2020-05-09 23:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Encrypt a packet
|
|
|
|
*
|
|
|
|
* @param bytes is updated in place
|
|
|
|
*/
|
2020-05-10 00:51:20 +00:00
|
|
|
void CryptoEngine::encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes)
|
|
|
|
{
|
|
|
|
DEBUG_MSG("WARNING: noop encryption!\n");
|
|
|
|
}
|
2020-05-09 23:15:01 +00:00
|
|
|
|
2020-05-10 00:51:20 +00:00
|
|
|
void CryptoEngine::decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes)
|
|
|
|
{
|
|
|
|
DEBUG_MSG("WARNING: noop decryption!\n");
|
2020-05-10 02:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init our 128 bit nonce for a new packet
|
|
|
|
*/
|
|
|
|
void CryptoEngine::initNonce(uint32_t fromNode, uint64_t packetNum)
|
|
|
|
{
|
|
|
|
memset(nonce, 0, sizeof(nonce));
|
|
|
|
*((uint64_t *)&nonce[0]) = packetNum;
|
|
|
|
*((uint32_t *)&nonce[8]) = fromNode;
|
2020-05-10 00:51:20 +00:00
|
|
|
}
|