Fix NTP Authenticator parsing for non-MD5 digest types#4918
Draft
Fix NTP Authenticator parsing for non-MD5 digest types#4918
Conversation
- Add XStrField import - Add _ntp_auth_tail_size() helper for dynamic MAC size detection - Update _NTPAuthenticatorPaddingField to use dynamic tail size - Change NTPAuthenticator.dgst from XStrFixedLenField to XStrField - Update NTPExtPacketListField.getfield() for dynamic tail detection - Add SHA384 (48-byte) to NTPHeader.guess_payload_class() Co-authored-by: guedou <11683796+guedou@users.noreply.github.com>
- Add SHA1 (24-byte) authenticator parsing test with round-trip verification - Add SHA256 (36-byte) authenticator parsing test with round-trip verification - Update existing MD5 authenticator test to reflect correct SHA1 parsing for 24-byte payloads - Update NTPControl test to expect SHA1 parsing for 24-byte authenticator data Co-authored-by: guedou <11683796+guedou@users.noreply.github.com>
…ents - Define named constants for MAC sizes (_NTP_AUTH_MD5_SIZE, _NTP_AUTH_SHA1_SIZE, etc.) - Update _ntp_auth_tail_size() to use constants instead of hardcoded values - Clarify test comments to explain SHA1 vs MD5 parsing interpretation Co-authored-by: guedou <11683796+guedou@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix NTP Authenticator parsing for dynamic digest sizes
Fix NTP Authenticator parsing for non-MD5 digest types
Feb 14, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4918 +/- ##
==========================================
+ Coverage 80.10% 80.63% +0.53%
==========================================
Files 370 370
Lines 91727 91739 +12
==========================================
+ Hits 73477 73973 +496
+ Misses 18250 17766 -484
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NTP Authenticator fields were hardcoded to MD5's 16-byte digest size, causing misaligned parsing for SHA1/SHA256/SHA384/SHA512. The
_NTPAuthenticatorPaddingFieldassumed a fixed 20-byte tail (4-byte key_id + 16-byte MD5), incorrectly consuming digest bytes as padding for larger hash types.Changes
Core Implementation:
_ntp_auth_tail_size()helper to compute tail size dynamically against valid MAC sizes (20/24/36/52/68 bytes)NTPAuthenticator.dgstfromXStrFixedLenField(length=16)toXStrFieldto consume all remaining bytes after key_id_NTPAuthenticatorPaddingField.getfield()andNTPExtPacketListField.getfield()to use dynamic tail detectionNTPHeader.guess_payload_class()_NTP_AUTH_SHA1_SIZE,_NTP_AUTH_SHA256_SIZE, etc.)Tests:
Example
Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.