meshtastic-firmware/src/mesh/CryptoEngine.cpp

35 wiersze
840 B
C++
Czysty Zwykły widok Historia

#include "CryptoEngine.h"
2023-01-21 13:34:29 +00:00
#include "configuration.h"
2020-05-09 23:15:01 +00:00
2021-02-23 02:10:35 +00:00
void CryptoEngine::setKey(const CryptoKey &k)
2020-05-09 23:15:01 +00:00
{
2022-12-30 02:41:37 +00:00
LOG_DEBUG("Using AES%d key!\n", k.length * 8);
2021-02-23 02:10:35 +00:00
key = k;
2020-05-09 23:15:01 +00:00
}
/**
* Encrypt a packet
*
* @param bytes is updated in place
*/
2022-03-20 00:40:13 +00:00
void CryptoEngine::encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes)
{
2022-12-30 02:41:37 +00:00
LOG_WARN("noop encryption!\n");
}
2020-05-09 23:15:01 +00:00
2022-03-20 00:40:13 +00:00
void CryptoEngine::decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes)
{
2022-12-30 02:41:37 +00:00
LOG_WARN("noop decryption!\n");
2020-05-10 02:08:04 +00:00
}
/**
* Init our 128 bit nonce for a new packet
*/
2022-03-20 00:40:13 +00:00
void CryptoEngine::initNonce(uint32_t fromNode, uint64_t packetId)
2020-05-10 02:08:04 +00:00
{
memset(nonce, 0, sizeof(nonce));
2021-08-02 17:50:28 +00:00
// use memcpy to avoid breaking strict-aliasing
2022-03-20 00:40:13 +00:00
memcpy(nonce, &packetId, sizeof(uint64_t));
2021-08-02 17:50:28 +00:00
memcpy(nonce + sizeof(uint64_t), &fromNode, sizeof(uint32_t));
}