From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:LZ4" |
|---|
| claim | "The HC byte of an LZ4 frame header is (XXH32(descriptor, seed 0) >> 8) & 0xFF, where the descriptor is every byte from FLG up to and including the last optional field (content size, dictionary ID), without the magic. A wrong HC makes liblz4 fail with ERROR_headerChecksum_invalid." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:LZ4" |
|---|
| observed_in | |
|---|
|
|---|
| data | | trigger | "reading or writing a frame header" |
|---|
| effect | "one-byte header checksum = second byte of XXH32 of FLG..optional fields" |
|---|
| test_vectors | |
|
|
|
|
|
|
| input | "61 40 C7 D1 00 00" |
|---|
| expected | "69" |
|---|
|
|
|---|
|
|---|
| evidence | | type | "documentation" |
|---|
| detail | "The value is the second byte of xxh32() : (xxh32()>>8) & 0xFF using zero as a seed, and the full Frame Descriptor as an input (including optional fields)" |
|---|
| repo | "https://github.com/lz4/lz4" |
|---|
| commit | "aa787570e681c695fc087b4a44cd2d5b38c2289a" |
|---|
| path | "doc/lz4_Frame_format.md" |
|---|
| lines | "243-249" |
|---|
|
| type | "source" |
|---|
| detail | "LZ4F_headerChecksum: XXH32(header, length, 0) >> 8; decoder: HC = LZ4F_headerChecksum(srcPtr+4, frameHeaderSize-5)" |
|---|
| repo | "https://github.com/lz4/lz4" |
|---|
| commit | "aa787570e681c695fc087b4a44cd2d5b38c2289a" |
|---|
| path | "lib/lz4frame.c" |
|---|
| lines | "351-355, 1495" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "Vectors computed with the XXH32 of Code:LZ4/LZ4 codec and frame scanner (Python); 64 40 A7, 64 50 08, 64 60 85, 64 70 B9, 44 40 5E and 61 40 C7 D1 00 00 69 also occur in frames written by the C lz4 tool (pierrec/lz4 testdata, lz4 tests/goldenSamples/dictID.bin)." |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Header checksum" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T17:53:41.765Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T09:22:46.417Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read doc/lz4_Frame_format.md Header Checksum paragraph (lines ~240-250) and lib/lz4frame.c at aa78757: LZ4F_headerChecksum = (BYTE)(XXH32(header,len,0)>>8) (line 351-355); decoder line 1495-1496 computes HC over srcPtr+4 (after magic), length frameHeaderSize-5, and RETURN_ERROR_IF(HC != srcPtr[frameHeaderSize-1], headerChecksum_invalid). Read those lines, not the whole decoder." |
|---|
|
|
|---|