From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "magic" |
|---|
| subject | "Format:Zlib stream" |
|---|
| claim | "A zlib stream starts with CMF (low nibble 8 = deflate, high nibble log2(window) - 8) and FLG such that (CMF * 256 + FLG) % 31 == 0. zlib writes 78 01 for levels 0-1 (and the Huffman-only/RLE strategies), 78 5E for 2-5, 78 9C for 6 (default), 78 DA for 7-9; bit 5 of FLG means a 4-byte preset-dictionary id follows." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:Zlib stream" |
|---|
| observed_in | | "Python 3.11 zlib 1.3.2 output" |
|
|---|
|
|---|
| data | | bytes | "78 9C" |
|---|
| offset | "0x0" |
|---|
| meaning | "zlib stream, 32 KiB window, default level (other levels: 78 01, 78 5E, 78 DA)" |
|---|
| mask | "0F 00" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8; level_flags 0 (level < 2 or strategy >= Z_HUFFMAN_ONLY), 1 (< 6), 2 (== 6), 3; header |= PRESET_DICT if a dictionary was set; header += 31 - (header % 31)" |
|---|
| repo | "https://github.com/madler/zlib" |
|---|
| commit | "767c4c947852e143f582c85f14cf573411df1b35" |
|---|
| path | "deflate.c" |
|---|
| lines | "1030-1047" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "zlib.compress(data, level) for levels 0-9 gives 78 01, 78 01, 78 5E x4, 78 9C, 78 DA x3; zlib.compress(b'') = 78 9C 03 00 00 00 00 01; with zdict=b'hello' the stream starts 78 BB 06 2C 02 15 (Adler-32 of 'hello')." |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "zlib header" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T05:49:44.792Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T12:36:24.987Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read deflate.c 1028-1047 at 767c4c9: level_flags 0 (strategy>=HUFFMAN_ONLY or level<2), 1 (<6), 2 (==6), else 3; PRESET_DICT; header += 31 - header%31. Mask 0F 00 compares only the method nibble, so it also accepts other window sizes and levels, as intended." |
|---|
|
|
|---|