mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-01 23:50:38 +00:00
Remove nRF Crypt Debug
This commit is contained in:
@@ -16,7 +16,6 @@ class NRF52CryptoEngine : public CryptoEngine
|
||||
*/
|
||||
virtual void encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
hexDump("before", bytes, numBytes, 16);
|
||||
if (key.length > 16) {
|
||||
DEBUG_MSG("Software encrypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
AES_ctx ctx;
|
||||
@@ -28,7 +27,6 @@ class NRF52CryptoEngine : public CryptoEngine
|
||||
nRFCrypto.begin();
|
||||
nRFCrypto_AES ctx;
|
||||
uint8_t myLen = ctx.blockLen(numBytes);
|
||||
DEBUG_MSG("nRF52 encBuf myLen=%d!\n", myLen);
|
||||
char encBuf[myLen] = {0};
|
||||
initNonce(fromNode, packetId);
|
||||
ctx.begin();
|
||||
@@ -37,33 +35,12 @@ class NRF52CryptoEngine : public CryptoEngine
|
||||
nRFCrypto.end();
|
||||
memcpy(bytes, encBuf, numBytes);
|
||||
}
|
||||
hexDump("after", bytes, numBytes, 16);
|
||||
}
|
||||
|
||||
virtual void decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
hexDump("before", bytes, numBytes, 16);
|
||||
if (key.length > 16) {
|
||||
DEBUG_MSG("Software decrypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
AES_ctx ctx;
|
||||
initNonce(fromNode, packetId);
|
||||
AES_init_ctx_iv(&ctx, key.bytes, nonce);
|
||||
AES_CTR_xcrypt_buffer(&ctx, bytes, numBytes);
|
||||
} else if (key.length > 0) {
|
||||
DEBUG_MSG("nRF52 decrypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
nRFCrypto.begin();
|
||||
nRFCrypto_AES ctx;
|
||||
uint8_t myLen = ctx.blockLen(numBytes);
|
||||
DEBUG_MSG("nRF52 decBuf myLen=%d!\n", myLen);
|
||||
char decBuf[myLen] = {0};
|
||||
initNonce(fromNode, packetId);
|
||||
ctx.begin();
|
||||
ctx.Process((char*)bytes, numBytes, nonce, key.bytes, key.length, decBuf, ctx.decryptFlag, ctx.ctrMode);
|
||||
ctx.end();
|
||||
nRFCrypto.end();
|
||||
memcpy(bytes, decBuf, numBytes);
|
||||
}
|
||||
hexDump("after", bytes, numBytes, 16);
|
||||
// For CTR, the implementation is the same
|
||||
encrypt(fromNode, packetId, numBytes, bytes);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user