diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index 9783f6255..bce9bb02f 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -32,6 +32,10 @@ void CryptoEngine::decrypt(uint32_t fromNode, uint64_t packetNum, size_t numByte void CryptoEngine::initNonce(uint32_t fromNode, uint64_t packetNum) { memset(nonce, 0, sizeof(nonce)); - *((uint64_t *)&nonce[0]) = packetNum; - *((uint32_t *)&nonce[8]) = fromNode; + + // use memcpy to avoid breaking strict-aliasing + memcpy(nonce, &packetNum, sizeof(uint64_t)); + memcpy(nonce + sizeof(uint64_t), &fromNode, sizeof(uint32_t)); + //*((uint64_t *)&nonce[0]) = packetNum; + //*((uint32_t *)&nonce[8]) = fromNode; } \ No newline at end of file