Skip to content

CryptoEngine: fix missleading packet id uint64 type#10076

Open
Jorropo wants to merge 1 commit intomeshtastic:developfrom
Jorropo:lies
Open

CryptoEngine: fix missleading packet id uint64 type#10076
Jorropo wants to merge 1 commit intomeshtastic:developfrom
Jorropo:lies

Conversation

@Jorropo
Copy link
Copy Markdown
Member

@Jorropo Jorropo commented Apr 4, 2026

The packet id is always a uint32.

The wire header format hardcodes a uint32 value.
All the callers zext uint32s to uint64s when calling the CryptoEngine. Inside initNonce we even overwrite the upper half of the packet id when extraNonce is present.


I didn't tested this code.

@Jorropo Jorropo requested a review from Copilot April 4, 2026 10:55
@github-actions github-actions bot added needs-review Needs human review bugfix Pull request that fixes bugs labels Apr 4, 2026
@Jorropo Jorropo added the cleanup Code cleanup or refactor label Apr 4, 2026
@Jorropo Jorropo removed the bugfix Pull request that fixes bugs label Apr 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects the CryptoEngine API to treat packet identifiers as 32-bit values (matching the on-wire header format) and updates nonce initialization accordingly.

Changes:

  • Change CryptoEngine method signatures to use uint32_t for packetNum / packetId (Curve25519 and packet encryption/decryption APIs).
  • Update initNonce() to build the nonce from a 32-bit packet id plus optional 32-bit extraNonce, then fromNode.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/mesh/CryptoEngine.h Updates public API types from uint64_t to uint32_t and adjusts initNonce() signature.
src/mesh/CryptoEngine.cpp Updates implementations to match new 32-bit packet id types and modifies nonce packing logic.

Comment thread src/mesh/CryptoEngine.h Outdated
Comment thread src/mesh/CryptoEngine.cpp
Comment thread src/mesh/CryptoEngine.cpp
The packet id is always a uint32.

The wire header format hardcodes a uint32 value.
All the callers zext uint32s to uint64s when calling the CryptoEngine.
Inside initNonce we even overwrite the upper half of the packet id when extraNonce is present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Code cleanup or refactor needs-review Needs human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants