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:
parent
f23f5adcf2
commit
092aaf4870
1 changed files with 8 additions and 9 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue