ax(ueps): rename tag to tagByte in ReadAndVerify loop (AX-1 predictable names)
`tag` is not in the accepted single-letter exception list (i, _, t, c). `tagByte` is self-describing: the byte value of the TLV tag field. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
eafd673d13
commit
c7c2bd7df9
1 changed files with 9 additions and 9 deletions
|
|
@ -35,13 +35,13 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er
|
|||
// Loop through TLVs until we hit Payload (0xFF) or EOF
|
||||
for {
|
||||
// 1. Read Tag
|
||||
tag, err := reader.ReadByte()
|
||||
tagByte, err := reader.ReadByte()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 2. Handle Payload Tag (0xFF) - The Exit Condition
|
||||
if tag == TagPayload {
|
||||
if tagByte == TagPayload {
|
||||
// Payload is length-prefixless; caller frames the stream.
|
||||
// HMAC covers signedData (header TLVs) + raw payload bytes, not the 0xFF tag.
|
||||
remaining, err := io.ReadAll(reader)
|
||||
|
|
@ -65,31 +65,31 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er
|
|||
return nil, err
|
||||
}
|
||||
|
||||
switch tag {
|
||||
switch tagByte {
|
||||
case TagVersion:
|
||||
header.Version = tagValue[0]
|
||||
// Reconstruct signed data: Tag + Len + Val
|
||||
signedData.WriteByte(tag)
|
||||
signedData.WriteByte(tagByte)
|
||||
signedData.WriteByte(byte(tagLength))
|
||||
signedData.Write(tagValue)
|
||||
case TagCurrentLayer:
|
||||
header.CurrentLayer = tagValue[0]
|
||||
signedData.WriteByte(tag)
|
||||
signedData.WriteByte(tagByte)
|
||||
signedData.WriteByte(byte(tagLength))
|
||||
signedData.Write(tagValue)
|
||||
case TagTargetLayer:
|
||||
header.TargetLayer = tagValue[0]
|
||||
signedData.WriteByte(tag)
|
||||
signedData.WriteByte(tagByte)
|
||||
signedData.WriteByte(byte(tagLength))
|
||||
signedData.Write(tagValue)
|
||||
case TagIntent:
|
||||
header.IntentID = tagValue[0]
|
||||
signedData.WriteByte(tag)
|
||||
signedData.WriteByte(tagByte)
|
||||
signedData.WriteByte(byte(tagLength))
|
||||
signedData.Write(tagValue)
|
||||
case TagThreatScore:
|
||||
header.ThreatScore = binary.BigEndian.Uint16(tagValue)
|
||||
signedData.WriteByte(tag)
|
||||
signedData.WriteByte(tagByte)
|
||||
signedData.WriteByte(byte(tagLength))
|
||||
signedData.Write(tagValue)
|
||||
case TagHMAC:
|
||||
|
|
@ -97,7 +97,7 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er
|
|||
// We do NOT add the HMAC itself to signedData
|
||||
default:
|
||||
// Unknown tag (future proofing), verify it but ignore semantics
|
||||
signedData.WriteByte(tag)
|
||||
signedData.WriteByte(tagByte)
|
||||
signedData.WriteByte(byte(tagLength))
|
||||
signedData.Write(tagValue)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue