The footer
Worked example: footer revision 4 file
The footer is the last 96 bytes of the file, at offsets 0x1FA0 to 0x2000. It is a sealed region: 64 bytes of ciphertext followed by the 32-byte seal trailer. The AAD is "stc" ‖ 0x03 ‖ file_id u64 ‖ 0u32, 16 bytes in all.
The trailer
Section titled “The trailer”The last 32 bytes:
tag : 16 bytes ending ... 2e 78 8c 7c 07 4anonce : 01 00 00 00 | 05 00 00 00 00 00 00 00 epoch 1, counter 5key id: 01 00 00 00 data key 1The first 64 bytes of the footer are ciphertext, beginning 95 ed 26 e5 ac 33 aa 0d .... A reader looks up data key 1 in the keyring, decrypts, and checks the tag.
The decrypted footer
Section titled “The decrypted footer”- magic4 B"STC1"
- version2 B4
- layer1 B1 hot/row
- flags1 B0x07
- file_id8 B1
- bloom_off8 B3872
- bloom_len4 B684
- index_off8 B4611
- index_len4 B89
- entries8 B1000
- min_ts8 B7
- max_ts8 B7
53 54 43 31 04 00 01 07 "STC1", version 4, layer 1, flags 0x07 (STATS|SKIP|RANGES)01 00 00 00 00 00 00 00 file_id 120 0f 00 00 00 00 00 00 bloom_off 3872ac 02 00 00 bloom_len 68403 12 00 00 00 00 00 00 index_off 461159 00 00 00 index_len 89e8 03 00 00 00 00 00 00 entries 100007 00 00 00 00 00 00 00 min_ts 707 00 00 00 00 00 00 00 max_ts 7Footer revision 4 with SKIP and RANGES set and COUNTS clear is legal: this file predates footer revision 5. See Footer revision 4 and Footer flags.
The checks a reader makes
Section titled “The checks a reader makes”| Check | Arithmetic |
|---|---|
file_id equals the id in the name |
1 and 0000000000000001.stc |
| Bloom inside the file | 3872 + 684 = 4556, at most 8192 - 96 = 8096 |
| Index inside the file | 4611 + 89 = 4700, at most 8096 |
| Index after bloom | 4611 >= 3872 |
Stats frame, when STATS is set |
[3872 + 684, 4611) = [4556, 4611), 55 bytes |
Zero padding from 4700 to 8096 (3396 bytes) makes the file 8192 bytes, a multiple of 4096.