1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-04 21:48:17 +00:00
trezor-firmware/docs/storage/addon-block.md
2020-05-13 17:30:42 +02:00

1.5 KiB

Add-on Block

Fixed storage which stores an immutable binary-search tree of items. Each item consists of a pair of pointers to binary data of arbitrary length. These two pointers are interpreted as a key and a value. Since items contain only pointers, multiple instances of data are stored just once.

Block contains 3 logical parts: a) header (256 bytes) b) binary-search tree (variable size) c) item data (variable size)

Header

offset length name description
0x0000 4 magic magic TRAB
0x0004 64 sig signature of the whole blob (except magic and sig)
0x0044 4 tree_count number of elements in the tree
0x0048 4 items_size length of the item section
0x004A 182 reserved -

Binary-Search Tree

Each node of the tree has the following structure:

offset length name description
... 2 key_offset key offset (divided by 4)
... 2 value_offset value offset (divided by 4)

Item Data

Each item has the following structure:

offset length name description
... 2 item_len item (key or value) length
... 2 item_flags item (key or value) flags
... item_len item_data item (key or value) data (padded to multiple of 4)