spec: reconcile NHP header size and packet framing with CSA standard
Author: justin-layervCreated Jun 12, 2026Updated Jun 12, 2026
LabelsbugcompatibilityP1
Summary
The CSA NHP standard describes a fixed NHP header size of 160 bytes for the standard/international profile and 224 bytes for the extended/domestic profile, with the ciphertext body immediately following the header. It also describes message length as the encrypted body length, supporting UDP and TCP short-connection framing.
Current OpenNHP main appears to use a different wire layout:
nhp/core/scheme/curve/header.go:HeaderSize = HeaderCommonSize + PublicKeySize + MaximumIdentitySize + GCMTagSize + PublicKeySize + GCMTagSize + TimestampSize + GCMTagSize + HashSize, which is 240 bytes for the Curve profile.nhp/core/scheme/gmsm/header.go: uses the same formula, also producing 240 bytes.nhp/core/constants.go:PacketBufferSize = 4096, creating a much smaller practical packet/body limit than the standard's UDP-size framing language.nhp/core/initiator.go: rejects bodies larger thanPacketBufferSize - mad.header.Size().
Why This Matters
A strict standard implementation expecting 160/224-byte headers or larger standard-framed payloads will not interoperate cleanly with the current OpenNHP wire layout. If the current layout is intentional, it should be documented as an OpenNHP profile/extension rather than left ambiguous.
Suggested Acceptance Criteria
- Document a byte-level matrix for CSA standard header layout vs current OpenNHP Curve/GMSM layout.
- Decide whether OpenNHP should be strict wire-compatible with the CSA standard or advertise a distinct profile.
- If strict compatibility is required, add parser/assembler support and migration handling.
- Add golden tests for header size, type/length offsets, and packet/body size behavior.
Source: OpenNHP/opennhp