ax(ueps): rename tagLengthByte/tagLength to tagValueLength

AX Principle 1 — the `Byte` suffix encodes storage type not semantics,
and the intermediate `tagLength` variable was an immediate int cast of
`tagLengthByte` with no additional meaning. Collapsed to a single
`tagValueLength` variable that names what it is, not how it is stored.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 10:25:39 +01:00
parent f23f5adcf2
commit 092aaf4870
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -47,13 +47,12 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er
break
}
tagLengthByte, err := reader.ReadByte()
tagValueLength, err := reader.ReadByte()
if err != nil {
return nil, err
}
tagLength := int(tagLengthByte)
tagValue := make([]byte, tagLength)
tagValue := make([]byte, tagValueLength)
if _, err := io.ReadFull(reader, tagValue); err != nil {
return nil, err
}
@ -62,34 +61,34 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er
case TagVersion:
header.Version = tagValue[0]
signedData.WriteByte(tagByte)
signedData.WriteByte(byte(tagLength))
signedData.WriteByte(tagValueLength)
signedData.Write(tagValue)
case TagCurrentLayer:
header.CurrentLayer = tagValue[0]
signedData.WriteByte(tagByte)
signedData.WriteByte(byte(tagLength))
signedData.WriteByte(tagValueLength)
signedData.Write(tagValue)
case TagTargetLayer:
header.TargetLayer = tagValue[0]
signedData.WriteByte(tagByte)
signedData.WriteByte(byte(tagLength))
signedData.WriteByte(tagValueLength)
signedData.Write(tagValue)
case TagIntent:
header.IntentID = tagValue[0]
signedData.WriteByte(tagByte)
signedData.WriteByte(byte(tagLength))
signedData.WriteByte(tagValueLength)
signedData.Write(tagValue)
case TagThreatScore:
header.ThreatScore = binary.BigEndian.Uint16(tagValue)
signedData.WriteByte(tagByte)
signedData.WriteByte(byte(tagLength))
signedData.WriteByte(tagValueLength)
signedData.Write(tagValue)
case TagHMAC:
hmacSignature = tagValue
default:
// signedData.WriteByte(unknownTag); signedData.Write(tagValue) — unknown tags contribute to HMAC, blocking injection
signedData.WriteByte(tagByte)
signedData.WriteByte(byte(tagLength))
signedData.WriteByte(tagValueLength)
signedData.Write(tagValue)
}
}