Skip to content

Trezor Safe 5 bootloader 2.1.16

The published firmware image, checked against its published source. reproducible

517 / 638
functions proved equal to the source
41.7%
of code bytes proved (52,103 of 124,991)
68.5%
of source statements and branches proved
19
mismatches reported: 18 cverif false alarm, 1 unspecified in C
517 proved74 bounded1 differs where C leaves it open19 mismatch, cverif false alarm4 inconclusive23 unsupported

Constant time

4 functions are marked constant time by the specs trezor-crypto, secp256k1-zkp, trezor-storage; cverif checks that the published machine code's timing doesn't depend on their secrets, nor that of the helpers they pass secrets to (how). 61 spec entries are not in this image.

2 proved1 bounded1 mismatch, cverif false alarm
FunctionClaimDetail
memzero
marked
violationargument 1 of the call to explicit_bzero points to secret memory, and explicit_bzero is not known to be constant time (vendor/trezor-crypto/memzero.c:55)
any input
ECRYPT_keysetup
marked
provedconstant time
sha256_Transform
marked
provedconstant time
sha512_Transform
marked
boundedconstant time on the explored paths only

Chain of evidence

  1. Published image
    bootloader-t3t1-2.1.16.bin, sha256 9e276650572519ce1524858527270e95eafa9fbf75773604e5977b8d776c3fb8
  2. Header
    the signed header's code hashes match the code
  3. Source
    trezor/trezor-firmware, tag core/bl2.1.16, commit 764df17ae782…
  4. Reproducible build
    the vendor's own build reproduces the published image byte for byte, signatures aside
  5. Source bundle
    166 C/assembly units linked into the image; 15 linked inputs have no C source (Rust, toolchain libraries); toolchain: arm-none-eabi-gcc (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 13.3.1 20240614
  6. Extraction
    code at 0xc010400, 129,024 bytes; every published byte is accounted for
  7. Verification
    cverif 0.1.5 on the published bytes: 517 of 638 functions proved, 1 flag group(s)

Findings

infoThe bootloader build reproduces the published image
build-docker.sh --models T3T1 --targets bootloader core/bl2.1.16 gives the published image once the signature fields and the code hashes (left to the signing tool) are zeroed; the fingerprint build-docker.sh prints equals the published header's.
reproducibility · confidence high · findings.md · reproducible
infoThe published bootloader is the one in the source tree and in firmware 2.13.1
The image at data.trezor.io is byte-identical to core/embed/models/T3T1/bootloaders/bootloader_T3T1.bin at core/v2.13.1 and to the bootloader embedded (raw deflate) in the published T3T1 firmware 2.13.1, which installs it. Its header's code hash matches. No vendor metadata names the bootloader's source commit; the tag core/bl2.1.16 is used.
integrity · confidence high · same-as-embedded
infoAbout 35% of the bootloader is Rust
The bootloader UI is Rust (28 KB of code, 17.5 KB of data), out of cverif's scope, and so are memcpy, memset, strlen and the __aeabi_mem* helpers: 12-byte weak C-ABI wrappers that tail-jump to Rust's compiler_builtins, in place of newlib's.
scope · confidence high · rust-share
infoRead as secure code (-mcmse)
Every unit is built with -mcmse, for which GCC predefines __ARM_FEATURE_CMSE as 3; the STM32U5 headers select the secure peripheral aliases (FLASH at 0x50022000) and the secure-only code on it. verify.py passes -D__ARM_FEATURE_CMSE=3 (from 2026-12-05); before that, 47 functions showed false mismatches on peripheral accesses.
coverage · confidence high · cmse
infoVendor note: one boot command makes the enum 64-bit
BOOT_COMMAND_POWER_OFF = 0x24EEE8828 has nine hex digits, while every other command is a 32-bit constant; it looks like a typo, and it is in every Trezor core tree here (bootloaders 2.1.16 and 2.1.18, firmware 2.13.1). All producers and consumers of the command are C compiled with the same header, and the linker scripts align .boot_args to 8 after .boot_command, so the RAM layout is the same as with a 32-bit enumeration; code built with a 32-bit boot_command_t would leave the upper word unwritten, and a command compared as 64-bit would then not match. No effect was found in the code verified here.
security · confidence medium · boot-command-enum-width
infocverif false alarmmemzero calls explicit_bzero on secret memory
memzero is explicit_bzero(pnt, len). newlib's explicit_bzero falls through into bzero, which tail-calls memset (the compiler_builtins one): its branches depend on the pointer's alignment and the length, never on the bytes it overwrites. cverif has no constant-time knowledge of the library function.
ct-triage · confidence high · ct-memzero
infoNo constant-time violation in the bootloader
The bootloader holds no signing key or PIN. ECRYPT_keysetup (key setup of the ChaCha-based random generator) is proved constant time; sha256_Transform and sha512_Transform are constant time on every path explored before the time limit; the one violation reported (memzero) is the library call above.
coverage · confidence high · constant-time
infocverif false alarmUSB callbacks compared with the HAL's __weak defaults
stm32u5xx_hal_pcd.c defines these callbacks __weak and empty; embed/io/usb/stm32/usbd_conf.c defines them for real. The link map keeps usbd_conf.o's and discards the HAL's (.text.HAL_PCD_SetupStageCallback 0x0 0x2 ...hal_pcd.o). cverif compares the binary with the weak definition (issue 24), hence calls (USBD_LL_StallEP, USBD_LL_OpenEP, the class callbacks) and stores the empty function lacks.
mismatch-triage · confidence high · covers 10 mismatches · cverif issue 24 · weak-callbacks
infocverif false alarmboot_command_t is a 64-bit enumeration
BOOT_COMMAND_POWER_OFF = 0x24EEE8828 (sys/startup/inc/sys/bootargs.h) does not fit 32 bits, so GCC makes boot_command_t 64-bit: g_boot_command is 8 bytes, bootargs_init copies it with ldrd/strd, bootargs_set takes the command in r0:r1. cverif reads the type as 32-bit (issue 25), so the upper word differs.
mismatch-triage · confidence high · covers 2 mismatches · cverif issue 25 · boot-command-64bit
infounspecified in Cfb_queue_take: counterexample has rix == FRAME_BUFFER_COUNT
The counterexample's queue has rix == 2 with FRAME_BUFFER_COUNT == 2, so queue->entries[queue->rix] is past the array and lands on rix itself (r0 + 4): undefined behaviour. rix is only ever set by (rix + 1) % FRAME_BUFFER_COUNT or reset to 0.
mismatch-triage · confidence high · covers 1 mismatch · fb-queue-index
infocverif false alarmmemcpy/memset/__aeabi_mem*: counterexample overlaps the callee's own frame
These are Rust compiler_builtins thunks with no C source, compared with cverif's library model. The counterexample puts the destination at 0xffffffff so that the thunk's push {r7, lr} writes the same byte: an object overlapping the callee's new stack frame, which no C caller can produce.
mismatch-triage · confidence medium · covers 6 mismatches · aeabi-mem

Full analysis (findings.md)

What the image is made of

Bytes by origin, from the link map. cverif verifies C and assembly; the rest counts as unverified.

OriginBytesShare
C82,05463.1%
Rust45,70135.1%
assembly1,6481.3%
linker fill3940.3%
toolchain libraries (newlib, libgcc)2500.2%

Functions

Every function of the image cverif compared with its source. Bounded: no difference within the explored paths, not a proof. Unsupported/inconclusive: a construct cverif doesn't model yet.

FunctionStatusBytesDetail
HAL_PCD_MspInit
0xc01f140
mismatch256binary reads 4 byte(s) of the peripheral register at 0x56020c8c (instruction at 0xc01f15c) where the source makes no such access
bootargs_set
0xc01d174
mismatch84memory at return: 4-byte value stored at 0x3002ff04: source gives 0x0, binary gives 0x80000006 for r1=0x80000006 mem[0x30030028]=0x9c mem[0x30030029]=0x7f mem[0x3003002a]=0xf5 mem[0x3003002b]=0x59 mem[0x30030740]=0xf7 mem[0x30030741]=0xff mem[0x30030742]=0xff mem[0x30030743]=0x7f
fb_queue_take
0xc020d70
mismatch48memory at `msr primask` (event #3): 2-byte value stored at (r0 + 2*zext32(mem2.8[(r0 + 4)])): source gives 0xff00, binary gives 0xff01 for r0=0x61fa mem[0x61fe]=0x02 mem[0x61ff]=0x7e mem[0x30030028]=0x9f mem[0x30030029]=0x7f mem[0x3003002a]=0x1f mem[0x3003002b]=0x84 mem[0x30030740]=0x00 mem[0x30030741]=0x00
HAL_PCD_MspDeInit
0xc01f240
mismatch44binary reads 4 byte(s) of the peripheral register at 0x56020c8c (instruction at 0xc01f24a) where the source makes no such access
bootargs_init
0xc01d210
mismatch32memory at return: 4-byte value stored at 0x300307cc: source gives 0x7fffffff, binary gives 0x80000000 for mem[0x3002ff04]=0x00 mem[0x3002ff05]=0x00 mem[0x3002ff06]=0x00 mem[0x3002ff07]=0x80 mem[0x30030028]=0xff mem[0x30030029]=0x7f mem[0x3003002a]=0xaa mem[0x3003002b]=0xaa
HAL_PCD_ResetCallback
0xc01f2a2
mismatch32binary calls USBD_LL_OpenEP, which the source does not call at this point
HAL_PCD_DataOutStageCallback
0xc01f278
mismatch18binary calls <indirect call>, which the source does not call at this point
HAL_PCD_DataInStageCallback
0xc01f28a
mismatch16binary calls <indirect call>, which the source does not call at this point
HAL_PCD_SetupStageCallback
0xc01f26c
mismatch12binary calls USBD_LL_StallEP, which the source does not call at this point
memcpy
0xc029a56
mismatch12memory at return: 1-byte value stored at r0: source gives 0xc, binary gives 0x82 for r0=0xffffffff r1=0xc2081008 r2=0x1 mem[0xc2081008]=0x0c mem[0xffffffff]=0x82
memset
0xc029abc
mismatch12memory at return: 1-byte value stored at r0: source gives 0x84, binary gives 0x0 for r0=0xffffffff r1=0x84 r2=0x1 mem[0xffffffff]=0x00
__aeabi_memcpy
0xc029b0e
mismatch12memory at return: 1-byte value stored at r0: source gives 0x1, binary gives 0x0 for r0=0xffffffff r1=0x46281088 r2=0x1 mem[0x46281088]=0x01 mem[0xffffffff]=0x00
__aeabi_memcpy4
0xc029b32
mismatch12memory at return: 1-byte value stored at r0: source gives 0x1, binary gives 0x0 for r0=0xffffffff r1=0x46281088 r2=0x1 mem[0x46281088]=0x01 mem[0xffffffff]=0x00
__aeabi_memclr
0xc029b70
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x10 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x10
__aeabi_memclr4
0xc029b8a
mismatch12memory at return: 1-byte value stored at r0: source gives 0x0, binary gives 0x10 for r0=0xffffffff r1=0x1 mem[0xffffffff]=0x10
HAL_PCD_SOFCallback
0xc01f29a
mismatch8binary calls <indirect call>, which the source does not call at this point
HAL_PCD_SuspendCallback
0xc01f2c2
mismatch8memory at return: 1-byte value stored at (mem0.32[(r0 + 1288)] + 509): source gives 0x7f, binary gives 0x80 for r0=0x80207f26 mem[0x30030028]=0x80 mem[0x30030029]=0x80 mem[0x3003002a]=0xa0 mem[0x3003002b]=0x80 mem[0x30030740]=0x80 mem[0x30030741]=0x80 mem[0x30030742]=0x80 mem[0x30030743]=0x80
HAL_PCD_ResumeCallback
0xc01f2ca
mismatch8memory at return: 1-byte value stored at (mem0.32[(r0 + 1288)] + 508): source gives 0x7f, binary gives 0x80 for r0=0x80808a7e mem[0x30030028]=0x80 mem[0x30030029]=0x80 mem[0x3003002a]=0x80 mem[0x3003002b]=0x80 mem[0x30030740]=0x80 mem[0x30030741]=0x80 mem[0x30030742]=0x80 mem[0x30030743]=0x80
HAL_PCD_DisconnectCallback
0xc01f2ea
mismatch8binary calls <indirect call>, which the source does not call at this point
curve25519_contract
0xc012d40
proved668
HAL_GPIO_Init
0xc019b0c
proved532
sha256_Transform
0xc0147c0
proved
constant time
488
SystemInit
0xc01d4bc
proved488
expand256_modm
0xc0143c4
proved484
encode_basic_field
0xc01885c
proved456
USB_EPStartXfer
0xc02017c
proved452
ge25519_unpack_negative_vartime
0xc0139c8
proved416
workflow_firmware_update
0xc015f08
proved404
HAL_GTZC_TZSC_ConfigPeriphAttributes
0xc019e3c
proved400
mpu_reconfig
0xc01ccfc
proved364
ge25519_pnielsadd
0xc0137ec
proved332
backlight_init
0xc020f30
proved324
tamper_init
0xc01c474
proved320
unit_properties_init
0xc01c708
proved308
ge25519_pnielsadd_p1p1
0xc013684
proved288
reduce256_modm
0xc013d48
proved288
HAL_GTZC_TZSC_MPCWM_ConfigMemAttributes
0xc019fcc
proved272
display_io_init_gpio
0xc020808
proved268
fw_check
0xc017078
proved260
HAL_GPIO_DeInit
0xc019d20
proved260
flash_area_write_data_padded
0xc022ba0
proved256
usb_class_setup
0xc01ec84
proved244
mpu_init
0xc01cbfc
proved240
touch_get_state
0xc021ec0
proved240
chacha_drbg_reseed
0xc011864
proved236
dma2d_rgb565_fill
0xc022460
proved232
curve25519_sub_after_basic
0xc012108
proved230
tamper_build_pminfo
0xc01c5b4
proved228
USB_SetTurnaroundTime
0xc01fc4c
proved224
codec_send_msg
0xc01676c
proved216
secret_bhk_regenerate
0xc01c194
proved216
HAL_GTZC_MPCBB_ConfigMem
0xc01a0dc
proved212
USBD_StdEPReq
0xc01f984
proved210
bg_copy_start_const_out_8
0xc021164
proved208
ed25519_cosi_combine_publickeys
0xc013430
proved200
dma2d_wait
0xc022398
proved200
HAL_DMAEx_List_Start_IT
0xc019628
proved196
HASH_GetDigest
0xc01a2a8
proved196
FMC_NORSRAM_Init
0xc01b634
proved196
bootloader_process_comm
0xc016528
proved192
pb_encode_submessage
0xc01879c
proved192
touch_fsm_get_event
0xc022038
proved192
dma2d_rgb565_blend_mono8
0xc0228e4
proved188
curve25519_swap_conditional
0xc012fdc
proved186
pb_validate_utf8
0xc017562
proved186
ge25519_double_p1p1
0xc0135cc
proved184
expand_raw256_modm
0xc0145a8
proved184
HAL_EXTI_SetConfigLine
0xc0196ec
proved184
hash_processor_init
0xc01b8fc
proved184
curve25519_sub
0xc012058
proved176
workflow_menu
0xc016218
proved176
backlight_set
0xc020e80
proved176
workflow_wipe_device
0xc01609c
proved172
HAL_FLASHEx_Erase
0xc019a60
proved172
USB_DeactivateEndpoint
0xc020024
proved172
curve25519_add_after_basic
0xc011faa
proved170
curve25519_neg
0xc0121f4
proved168
HASH_WriteData
0xc01a3e0
proved168
lx154a2482_init_seq
0xc020c84
proved168
check_vendor_header_sig
0xc010efc
proved164
pb_encode_varint
0xc0185f4
proved164
sha256_Final
0xc014a96
proved160
HAL_DMA2D_ConfigLayer
0xc018e14
proved160
system_fault_message
0xc01dd6c
proved160
USBD_LL_DataInStage
0xc01f5b8
proved158
usb_iface_init
0xc016920
proved156
pb_read
0xc017738
proved152
HASH_Accumulate
0xc01a734
proved152
memregion_del_range
0xc01cb00
proved152
syshandle_write_blocking
0xc01e544
proved152
display_io_init_fmc
0xc020914
proved152
usb_start
0xc01ef78
proved148
ge25519_pack
0xc013938
proved144
hash_processor_sha256_update
0xc01ba60
proved144
dma2d_rgb565_copy_rgb565
0xc0226b4
proved144
USBD_LL_SetupStage
0xc01f4ca
proved142
pb_decode_varint
0xc0177d8
proved140
HAL_PWR_ConfigPVD
0xc01b50c
proved140
random_delays_init
0xc01bdd8
proved140
secret_write
0xc01bfb0
proved140

Showing 100 of 638.

Raw results

Results are produced by scripts anyone can re-run. MIT licensed.