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:
parent
5aa17421f6
commit
41761823d3
1 changed files with 2 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue