ax(ueps): expand ReadAndVerify comment to show error sentinel branches

AX Principle 2 — comments as usage examples: the ReadAndVerify doc
comment only showed the success path; both errMissingHMAC and
errIntegrityViolation sentinel branches are now illustrated so callers
can copy-paste correct dispatch logic.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 13:28:59 +01:00
parent 5aa17421f6
commit 41761823d3
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -24,6 +24,8 @@ type ParsedPacket struct {
}
// packet, err := ueps.ReadAndVerify(bufio.NewReader(conn), []byte("my-shared-secret"))
// if err == errMissingHMAC { return } // unauthenticated: no HMAC tag in stream
// if err == errIntegrityViolation { return } // tampered: HMAC mismatch; reject and raise threat score
// if err == nil { dispatch(packet.Header.IntentID, packet.Header.ThreatScore, packet.Payload) }
func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, error) {
var hmacInputBuffer bytes.Buffer