Crypto works!

This commit is contained in:
geeksville
2020-05-09 19:08:04 -07:00
parent 1cc24de787
commit 3e356e5866
8 changed files with 137 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
#include "CryptoEngine.h"
#include "configuration.h"
void CryptoEngine::setKey(size_t numBytes, const uint8_t *bytes)
void CryptoEngine::setKey(size_t numBytes, uint8_t *bytes)
{
DEBUG_MSG("WARNING: Using stub crypto - all crypto is sent in plaintext!\n");
}
@@ -19,4 +19,14 @@ void CryptoEngine::encrypt(uint32_t fromNode, uint64_t packetNum, size_t numByte
void CryptoEngine::decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes)
{
DEBUG_MSG("WARNING: noop decryption!\n");
}
/**
* 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;
}