mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-17 00:02:55 +00:00
trunk roundhouse kick
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
|
||||
|
||||
class ESP32CryptoEngine : public CryptoEngine
|
||||
{
|
||||
|
||||
@@ -42,7 +40,7 @@ class ESP32CryptoEngine : public CryptoEngine
|
||||
virtual void encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
if (key.length > 0) {
|
||||
LOG_DEBUG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
LOG_DEBUG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t)packetId, numBytes);
|
||||
initNonce(fromNode, packetId);
|
||||
if (numBytes <= MAX_BLOCKSIZE) {
|
||||
static uint8_t scratch[MAX_BLOCKSIZE];
|
||||
@@ -50,7 +48,7 @@ class ESP32CryptoEngine : public CryptoEngine
|
||||
size_t nc_off = 0;
|
||||
memcpy(scratch, bytes, numBytes);
|
||||
memset(scratch + numBytes, 0,
|
||||
sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it)
|
||||
sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it)
|
||||
|
||||
auto res = mbedtls_aes_crypt_ctr(&aes, numBytes, &nc_off, nonce, stream_block, scratch, bytes);
|
||||
assert(!res);
|
||||
|
||||
Reference in New Issue
Block a user