From 40128a49363fc7c7e21333023bbbe07810f440ab Mon Sep 17 00:00:00 2001 From: sukun Date: Fri, 5 Apr 2024 13:13:02 +0530 Subject: [PATCH] Improve comment for CRC32 --- packet.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packet.go b/packet.go index 6d3cb3ca..72660f3e 100644 --- a/packet.go +++ b/packet.go @@ -172,8 +172,12 @@ func (p *packet) marshal(doChecksum bool) ([]byte, error) { } if doChecksum { - // Checksum is already in BigEndian - // Using LittleEndian.PutUint32 stops it from being flipped + // golang CRC32C uses reflected input and reflected output, the + // net result of this is to have the bytes flipped compared to + // the non reflected variant that the spec expects. + // + // Use LittleEndian.PutUint32 to avoid flipping the bytes in to + // the spec compliant checksum order binary.LittleEndian.PutUint32(raw[8:], generatePacketChecksum(raw)) }