Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setters and tests for WireGuard protocol message fields #1601

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

nadongjun
Copy link
Contributor

Reference

Summary:

This PR introduces setter methods and corresponding tests for WireGuard message fields. These changes allow for easier modification of message attributes such as the reserved field, sender index, and encrypted data.

What's Changed:

Added setter methods for various fields in WireGuard message structures, including Handshake Initiation, Handshake Response, Cookie Reply, and Transport Data.

WireGuardLayer

void setReserved(const std::array<uint8_t, 3>& reserved);

WireGuardHandshakeInitiationLayer

void setSenderIndex(uint32_t senderIndex);
void setInitiatorEphemeral(const std::array<uint8_t, 32>& initiatorEphemeral);
void setEncryptedInitiatorStatic(const std::array<uint8_t, 48>& encryptedInitiatorStatic);
void setEncryptedTimestamp(const std::array<uint8_t, 28>& encryptedTimestamp);
void setMac1(const std::array<uint8_t, 16>& mac1);
void setMac2(const std::array<uint8_t, 16>& mac2);

WireGuardHandshakeResponseLayer

void setSenderIndex(uint32_t senderIndex);
void setReceiverIndex(uint32_t receiverIndex);
void setResponderEphemeral(const std::array<uint8_t, 32>& responderEphemeral);
void setEncryptedEmpty(const std::array<uint8_t, 16>& encryptedEmpty);
void setMac1(const std::array<uint8_t, 16>& mac1);
void setMac2(const std::array<uint8_t, 16>& mac2);

WireGuardCookieReplyLayer

void setReceiverIndex(uint32_t receiverIndex);
void setNonce(const std::array<uint8_t, 24>& nonce);
void setEncryptedCookie(const std::array<uint8_t, 32>& encryptedCookie);

WireGuardTransportDataLayer

void setReceiverIndex(uint32_t receiverIndex);
void setCounter(uint64_t counter);
void setEncryptedData(const uint8_t* encryptedData, size_t encryptedDataLen);

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.11%. Comparing base (742bc3f) to head (9ec80f1).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1601      +/-   ##
==========================================
+ Coverage   83.04%   83.11%   +0.06%     
==========================================
  Files         276      276              
  Lines       46716    46907     +191     
  Branches     9329     9340      +11     
==========================================
+ Hits        38797    38988     +191     
- Misses       7060     7062       +2     
+ Partials      859      857       -2     
Flag Coverage Δ
fedora40 74.67% <100.00%> (+0.11%) ⬆️
macos-12 81.10% <100.00%> (+0.07%) ⬆️
macos-13 80.53% <100.00%> (+0.07%) ⬆️
macos-14 80.45% <100.00%> (+0.07%) ⬆️
mingw32 70.61% <100.00%> (+0.12%) ⬆️
mingw64 70.57% <100.00%> (+0.14%) ⬆️
npcap 84.93% <100.00%> (-0.03%) ⬇️
rhel94 74.56% <100.00%> (+0.10%) ⬆️
ubuntu2004 57.96% <100.00%> (+0.03%) ⬆️
ubuntu2004-zstd 58.05% <100.00%> (+0.01%) ⬆️
ubuntu2204 74.49% <100.00%> (+0.11%) ⬆️
ubuntu2204-icpx 58.70% <100.00%> (+0.12%) ⬆️
ubuntu2404 74.74% <100.00%> (+0.11%) ⬆️
unittest 83.11% <100.00%> (+0.06%) ⬆️
windows-2019 85.04% <100.00%> (+0.04%) ⬆️
windows-2022 85.05% <100.00%> (+0.04%) ⬆️
winpcap 85.03% <100.00%> (+0.05%) ⬆️
xdp 49.65% <100.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seladb seladb merged commit 44972d0 into seladb:dev Oct 3, 2024
40 checks passed
fxlb pushed a commit to fxlb/PcapPlusPlus that referenced this pull request Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants