Skip to content

OneKey Pro bootloader 2.8.4

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

Verified with cverif 0.1.4; this repository now uses cverif 0.1.5, which may prove more and report fewer false alarms. This result is due to be re-run.

700 / 982
functions proved equal to the source
67.5%
of code bytes proved (170,322 of 252,386)
58.0%
of source statements and branches proved
36
mismatches reported: 36 cverif false alarm
700 proved145 bounded7 timing leak77 mismatch, cverif false alarm14 reveals by design1 mark too broad9 inconclusive29 unsupported

Constant time

18 functions are marked constant time by the specs trezor-crypto, onekey-core; 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). 41 spec entries are not in this image.

21 proved6 bounded7 timing leak41 mismatch, cverif false alarm14 reveals by design1 mark too broad5 inconclusive1 unsupported
FunctionClaimDetail
__assert_func
given secrets by bn_cmov, bn_cnegate, bn_mult_k, bn_sqrt, bn_subi, point_jacobian_add, point_jacobian_double, point_multiply
violationnot constant time
__fatal_error
given secrets by __assert_func, gt911_read, gt911_write, se_random_encrypted_ex, se_transmit_mac_ex, thd89_transmit_ex
violationthe call to lcd_cover_background_hide may read secrets from memory (stored there by this function, or by a call it gave secrets to), and lcd_cover_background_hide is not checked as constant time for that (embed/trezorhal/common.c:68)
any input
aes_cbc_decrypt
marked
violationthe condition of the branch `beq 0x8026a08` depends on secrets (vendor/trezor-crypto/aes/aes_modes.c:363)
false with secret len = 0x8; true with secret len = 0x0
aes_cbc_encrypt
marked
violationthe condition of the branch `bne 0x802689a` depends on secrets (vendor/trezor-crypto/aes/aes_modes.c:330)
true with secret ret0:aes_encrypt = 0x2; false with secret ret0:aes_encrypt = 0x0
aes_ecb_decrypt
given secrets by se_random_encrypted_ex
violationthe condition of the branch `beq 0x802686c` depends on secrets (vendor/trezor-crypto/aes/aes_modes.c:203)
false with secret len = 0x8; true with secret len = 0x0
aes_encrypt_key128
marked
violationthe address of a 4-byte load depends on secrets (vendor/trezor-crypto/aes/aeskey.c:91)
0x20003bd4 with secret key[3] = 0x69, key[2] = 0xbf, key[1] = 0xfe, key[0] = 0xc0, key[7] = 0x65, key[6] = 0x98; 0x20003ce4 with secret key[3] = 0x1, key[2] = 0x0, key[1] = 0x0, key[0] = 0x0, key[7] = 0x0, key[6] = 0x0 (public: key = 0x20001808, cx = 0x20001894)
bn_addmod
given secrets by ecdsa_validate_pubkey, point_add
violationnot constant time
bn_cmov
given secrets by bn_mod, point_jacobian_add
violationthe condition of the branch `beq 0x80246c4` depends on secrets (vendor/trezor-crypto/bignum.c:275)
false with secret cond = 0x0; true with secret cond = 0x1
bn_cnegate
given secrets by point_multiply
violationthe condition of the branch `beq 0x8024be2` depends on secrets (vendor/trezor-crypto/bignum.c:295)
true with secret cond = 0x1; false with secret cond = 0x0
bn_fast_mod
given secrets by bn_addmod, bn_mult_k, point_add, point_double, point_jacobian_add, point_jacobian_double
violation`umull r5, r8, r7, r5` gets an operand that depends on secrets; on the Cortex-M4 or M7 (the binary records only ARMv7E-M; --cpu says which) it takes a number of cycles that nothing documents as fixed (vendor/trezor-crypto/bignum.c:759)
0x22 with secret *(u8 *)0xc00086f = 0x22; 0x0 with secret *(u8 *)0xc00086f = 0x0 (public: x = 0xc00084c)
bn_mod
given secrets by bn_cnegate, bn_sqrt, ecdsa_validate_pubkey, jacobian_to_curve, point_add, point_double
violationnot constant time
bn_mult_k
given secrets by point_double, point_jacobian_add, point_jacobian_double
violationthe condition of the branch `bls 0x8024930` depends on secrets (vendor/trezor-crypto/bignum.c:497)
true with secret k = 0x4; false with secret k = 0xc7
bn_multiply
given secrets by bn_power_mod, curve_to_jacobian, ecdsa_validate_pubkey, jacobian_to_curve, point_add, point_double, point_jacobian_add, point_jacobian_double, uncompress_coords
violationnot constant time
bn_multiply_long
given secrets by bn_multiply
violationthe address of a 4-byte load depends on secrets (vendor/trezor-crypto/bignum.c:538)
0x71b3bc20 with secret k = 0x71b3bc20; 0x7fdfffff with secret k = 0x7fdfffff
bn_multiply_reduce
given secrets by bn_multiply
violationnot constant time
bn_multiply_reduce_step
given secrets by bn_multiply_reduce
violation`umull r3, r10, r4, r3` gets an operand that depends on secrets; on the Cortex-M4 or M7 (the binary records only ARMv7E-M; --cpu says which) it takes a number of cycles that nothing documents as fixed (vendor/trezor-crypto/bignum.c:617)
0x16800081 with secret *(u8 *)0xb0000017 = 0x81, *(u32 *)0xb0000018 = 0xb40000; 0x0 with secret *(u8 *)0xb0000017 = 0x0, *(u32 *)0xb0000018 = 0x0 (public: res = 0x2c, d = 0x2bfffff2)
bn_power_mod
given secrets by bn_sqrt
violationthe condition of the branch `bpl 0x8024998` depends on secrets (vendor/trezor-crypto/bignum.c:826)
true with secret *(u32 *)0x80000004 = 0x0; false with secret *(u32 *)0x80000004 = 0x1 (public: e = 0x80000004)
bn_sqrt
given secrets by uncompress_coords
violationthe condition of the branch `beq 0x8024c68` depends on secrets (vendor/trezor-crypto/bignum.c:861)
true with secret *(u32 *)0x48 = 0x80000003; false with secret *(u32 *)0x48 = 0x0 (public: prime = 0x28)
bn_subi
given secrets by ecdsa_validate_pubkey, point_double, uncompress_coords
violationthe condition of the branch `bhi 0x8024af6` depends on secrets (vendor/trezor-crypto/bignum.c:1464)
true with secret y = 0x0, *(u32 *)0x4 = 0x7fffffff; false with secret y = 0x80642000, *(u32 *)0x4 = 0x400000 (public: prime = 0x4)
cal_mac
marked
violationthe condition of the branch `beq 0x8043784` depends on secrets (embed/trezorhal/se_thd89.c:139)
false with secret len = 0x8; true with secret len = 0x0
curve_to_jacobian
given secrets by point_multiply
violationnot constant time
display_bar
given secrets by __fatal_error
violationthe call to fb_fill_rect may read secrets from memory (stored there by this function, or by a call it gave secrets to), and fb_fill_rect is not checked as constant time for that (embed/extmod/modtrezorui/display.c:175)
any input
display_clear
given secrets by __fatal_error
violationthe call to fb_fill_rect may read secrets from memory (stored there by this function, or by a call it gave secrets to), and fb_fill_rect is not checked as constant time for that (embed/extmod/modtrezorui/display.c:171)
any input
display_image
given secrets by __fatal_error
violationargument 1 of the call to display_set_window depends on secrets (embed/extmod/modtrezorui/display.c:354)
0x0 with secret *(u32 *)0x20005afc = 0x80000162, *(u16 *)0x20005afc = 0x162; 0x2201 with secret *(u32 *)0x20005afc = 0xf4201c27, *(u16 *)0x20005afc = 0x1c27 (public: x = 0x400005da)
display_text
given secrets by __fatal_error, display_text_printf
violationnot constant time
display_text_printf
given secrets by __fatal_error
violationthe call to strchr may read secrets from memory (stored there by this function, or by a call it gave secrets to), and strchr is not checked as constant time for that (embed/extmod/modtrezorui/display.c:978)
any input
display_text_render
given secrets by display_text
violationthe condition of the branch `bge 0x802988e` depends on secrets (embed/extmod/modtrezorui/display.c:853)
false with secret textlen = 0x88e20043; true with secret textlen = 0x0
dwt_delay_ms
given secrets by i2c_master_recive, se_transmit_mac_ex
violation`udiv r4, r1, r7` gets an operand that depends on secrets; on the Cortex-M4 or M7 (the binary records only ARMv7E-M; --cpu says which) it takes a number of cycles that nothing documents as fixed (embed/trezorhal/systick.c:117)
0xfa104030 with secret *(u32 *)0x20000034 = 0xfa104030; 0x2987c000 with secret *(u32 *)0x20000034 = 0x2987c000
ecdh_multiply
marked
violationthe condition of the branch `beq 0x8025c0c` depends on secrets (vendor/trezor-crypto/ecdsa.c:638)
true with secret ret0:ecdsa_read_pubkey = 0x0; false with secret ret0:ecdsa_read_pubkey = 0x2
ecdsa_get_public_key65
marked
violationthe condition of the branch `cbz r0, 0x80259ba` depends on secrets (vendor/trezor-crypto/ecdsa.c:816)
false with secret ret1:bn_is_zero = 0x80000000; true with secret ret1:bn_is_zero = 0x0
ecdsa_read_pubkey
given secrets by ecdh_multiply
violationnot constant time
ecdsa_validate_pubkey
given secrets by ecdsa_read_pubkey
violationthe condition of the branch `cbz r0, 0x8025a98` depends on secrets (vendor/trezor-crypto/ecdsa.c:974)
false with secret ret0:point_is_infinity = 0x80000000; true with secret ret0:point_is_infinity = 0x0
generate_k_random
given secrets by curve_to_jacobian
violationthe condition of the branch `bne 0x8024ec0` depends on secrets (vendor/trezor-crypto/ecdsa.c:181)
false with secret ret9:bn_is_zero = 0x0; true with secret ret9:bn_is_zero = 0x1
get_glyph
given secrets by display_text_render
violationthe condition of the branch `bhi 0x802979c` depends on secrets (embed/extmod/modtrezorui/display.c:752)
false with secret c = 0x0; true with secret c = 0x80
gt911_read
given secrets by gt911_read_location
violationthe condition of the branch `cbz r0, 0x80448f4` depends on secrets (embed/trezorhal/gt911.c:59)
false with secret ret0:HAL_I2C_Mem_Read = 0x80; true with secret ret0:HAL_I2C_Mem_Read = 0x0
gt911_read_location
given secrets by touch_read
violationthe condition of the branch `cbnz r3, 0x8044996` depends on secrets (embed/trezorhal/gt911.c:82)
false with secret esc0:&gt911_read_location.point_data#0@1+0 = 0x0; true with secret esc0:&gt911_read_location.point_data#0@1+0 = 0x1
gt911_write
given secrets by gt911_read_location
violationthe condition of the branch `cbz r0, 0x804493c` depends on secrets (embed/trezorhal/gt911.c:66)
false with secret ret0:HAL_I2C_Mem_Write = 0x80; true with secret ret0:HAL_I2C_Mem_Write = 0x0
HAL_I2C_Mem_Read
given secrets by gt911_read
violationthe address of a 1-byte load depends on secrets (vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c:2422)
0x10420155 with secret hi2c = 0x10420114; 0x180040 with secret hi2c = 0x17ffff
HAL_I2C_Mem_Write
given secrets by gt911_write
violationthe address of a 1-byte load depends on secrets (vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c:2287)
0x10420155 with secret hi2c = 0x10420114; 0x180040 with secret hi2c = 0x17ffff
i2c_master_recive
given secrets by thd89_transmit_ex
violationthe address of a 1-byte load depends on secrets (embed/trezorhal/thd89.c:420)
0x10069 with secret hi2c = 0x10028; 0x8b8 with secret hi2c = 0x877
i2c_master_send
given secrets by se_transmit_mac_ex, thd89_transmit_ex
violationthe address of a 1-byte load depends on secrets (embed/trezorhal/thd89.c:288)
0x45 with secret hi2c = 0x4; 0x7a610002 with secret hi2c = 0x7a60ffc1
I2C_RequestMemoryRead
given secrets by HAL_I2C_Mem_Read
violationthe address of a 4-byte load depends on secrets (vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c:6341)
0x8 with secret hi2c = 0x8; 0x13ffff with secret hi2c = 0x13ffff
I2C_RequestMemoryWrite
given secrets by HAL_I2C_Mem_Write
violationthe address of a 4-byte load depends on secrets (vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c:6341)
0x8 with secret hi2c = 0x8; 0x13ffff with secret hi2c = 0x13ffff
jacobian_to_curve
given secrets by point_multiply
violationnot constant time
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
point_add
given secrets by point_multiply
violationthe condition of the branch `cbnz r0, 0x802516e` depends on secrets (vendor/trezor-crypto/ecdsa.c:48)
true with secret ret0:point_is_infinity = 0x80000000; false with secret ret0:point_is_infinity = 0x0
point_double
given secrets by point_add, point_multiply
violationthe condition of the branch `cbnz r0, 0x8024f74` depends on secrets (vendor/trezor-crypto/ecdsa.c:94)
true with secret ret0:point_is_infinity = 0x80000000; false with secret ret0:point_is_infinity = 0x0
point_is_equal
given secrets by point_add
violationthe condition of the branch `cbz r0, 0x80250da` depends on secrets (vendor/trezor-crypto/ecdsa.c:149)
false with secret ret0:bn_is_equal = 0x80000000; true with secret ret0:bn_is_equal = 0x0
point_is_infinity
given secrets by ecdsa_validate_pubkey, point_add, point_double
violationthe condition of the branch `cbz r0, 0x8024f30` depends on secrets (vendor/trezor-crypto/ecdsa.c:144)
false with secret ret0:bn_is_zero = 0x80000000; true with secret ret0:bn_is_zero = 0x0
point_is_negative_of
given secrets by point_add
violationthe condition of the branch `cbnz r0, 0x80250ec` depends on secrets (vendor/trezor-crypto/ecdsa.c:156)
false with secret ret0:bn_is_equal = 0x0; true with secret ret0:bn_is_equal = 0x1
point_jacobian_add
given secrets by point_multiply
violationthe condition of the branch `bls 0x80253c2` depends on secrets (vendor/trezor-crypto/ecdsa.c:227)
false with secret *(u32 *)0x57908 = 0xfffffffc; true with secret *(u32 *)0x57908 = 0x0 (public: curve = 0x57854)
point_jacobian_double
given secrets by point_multiply
violationthe condition of the branch `bls 0x802560c` depends on secrets (vendor/trezor-crypto/ecdsa.c:341)
false with secret *(u32 *)0x188 = 0xeff7f7f9; true with secret *(u32 *)0x188 = 0x0 (public: curve = 0xd4)
point_multiply
marked
violationthe condition of the branch `beq 0x802582c` depends on secrets (vendor/trezor-crypto/ecdsa.c:413)
true with secret ret0:bn_is_less = 0x0; false with secret ret0:bn_is_less = 0x1
random32
given secrets by generate_k_random
violationnot constant time
rng_get
given secrets by random32
violationthe condition of the branch `bne 0x803c698` depends on secrets (embed/trezorhal/rng.c:51)
false with secret *(u32 *)0x200060f0 = 0x80000000, *(u32 *)0x200060ec = 0x80000000; true with secret *(u32 *)0x200060f0 = 0xf, *(u32 *)0x200060ec = 0x0
rng_read
given secrets by rng_get
violationthe condition of the branch `beq 0x803c66a` depends on secrets (embed/trezorhal/rng.c:41)
false with secret previous = 0x80000001; true with secret previous = 0x1
scalar_multiply
marked
violationnot constant time
se_random_encrypted_ex
marked
violationthe condition of the branch `beq 0x8043a9a` depends on secrets (embed/trezorhal/se_thd89.c:317)
true with secret ret0:thd89_transmit_ex = 0xaaaaaaaa; false with secret ret0:thd89_transmit_ex = 0x0
se_transmit_mac_ex
marked
violationthe condition of the branch `cbnz r0, 0x8043b3c` depends on secrets (embed/trezorhal/se_thd89.c:168)
true with secret ret0:se_random_encrypted_ex = 0x1; false with secret ret0:se_random_encrypted_ex = 0x0
thd89_transmit_ex
given secrets by se_random_encrypted_ex
violationthe condition of the branch `cbz r0, 0x8043216` depends on secrets (embed/trezorhal/thd89.c:549)
false with secret ret5:i2c_master_send = 0x80; true with secret ret5:i2c_master_send = 0x0
touch_click
given secrets by __fatal_error
violationthe condition of the branch `cbz r0, 0x8044e8c` depends on secrets (embed/trezorhal/touch.c:45)
true with secret ret0:touch_read = 0x0; false with secret ret0:touch_read = 0x1
touch_read
given secrets by touch_click
violationthe condition of the branch `cbz r0, 0x8044e30` depends on secrets (embed/trezorhal/touch.c:61)
true with secret ret0:gt911_read_location = 0x0; false with secret ret0:gt911_read_location = 0x800000
uncompress_coords
given secrets by ecdsa_read_pubkey
violationthe condition of the branch `bpl 0x8025a6a` depends on secrets (vendor/trezor-crypto/ecdsa.c:941)
false with secret odd = 0x1, *(u32 *)0x4 = 0x0; true with secret odd = 0x0, *(u32 *)0x4 = 0x0 (public: y = 0x4)
aes_decrypt
marked
inconclusiveconstant time not established, checked for the secrets of caller aes_ecb_decrypt too
aes_decrypt_key128
given secrets by se_random_encrypted_ex
boundedconstant time on the explored paths only, checked for caller se_random_encrypted_ex
aes_encrypt
marked
inconclusiveconstant time not established, checked for the secrets of caller aes_cbc_encrypt, cal_mac too
bn_add
given secrets by point_jacobian_add, uncompress_coords
provedconstant time, checked for caller point_jacobian_add, uncompress_coords
bn_addi
given secrets by bn_sqrt
provedconstant time, checked for caller bn_sqrt
bn_inverse
given secrets by jacobian_to_curve, point_add, point_double
boundedconstant time on the explored paths only, checked for caller jacobian_to_curve, point_add, point_double
bn_is_equal
given secrets by ecdsa_validate_pubkey, point_is_equal, point_is_negative_of, point_jacobian_add
provedconstant time, checked for caller ecdsa_validate_pubkey, point_is_equal, point_is_negative_of, point_jacobian_add
bn_is_less
given secrets by bn_mod, ecdh_multiply, ecdsa_get_public_key65, ecdsa_validate_pubkey, generate_k_random, point_multiply
provedconstant time, checked for caller bn_mod, ecdh_multiply, ecdsa_get_public_key65, ecdsa_validate_pubkey, generate_k_random, point_multiply
bn_is_zero
given secrets by ecdh_multiply, ecdsa_get_public_key65, generate_k_random, point_double, point_is_infinity, point_is_negative_of
provedconstant time, checked for caller ecdh_multiply, ecdsa_get_public_key65, generate_k_random, point_double, point_is_infinity, point_is_negative_of
bn_lshift
given secrets by point_double, point_jacobian_double
provedconstant time, checked for caller point_double, point_jacobian_double
bn_mult_half
given secrets by point_jacobian_add, point_jacobian_double
provedconstant time, checked for caller point_jacobian_add, point_jacobian_double
bn_one
given secrets by bn_power_mod
provedconstant time, checked for caller bn_power_mod
bn_read_be
given secrets by ecdh_multiply, ecdsa_get_public_key65, ecdsa_read_pubkey
provedconstant time, checked for caller ecdh_multiply, ecdsa_get_public_key65, ecdsa_read_pubkey
bn_rshift
given secrets by bn_sqrt
provedconstant time, checked for caller bn_sqrt
bn_subtract
given secrets by bn_mod, uncompress_coords
provedconstant time, checked for caller bn_mod, uncompress_coords
bn_subtractmod
given secrets by point_add, point_double, point_jacobian_add, point_jacobian_double
provedconstant time, checked for caller point_add, point_double, point_jacobian_add, point_jacobian_double
bn_write_be
given secrets by ecdh_multiply, ecdsa_get_public_key65
provedconstant time, checked for caller ecdh_multiply, ecdsa_get_public_key65
bn_zero
given secrets by point_set_infinity
provedconstant time, checked for caller point_set_infinity
display_print_clear
given secrets by __fatal_error
provedconstant time, checked for caller __fatal_error
display_print_color
given secrets by __fatal_error
provedconstant time, checked for caller __fatal_error
ECRYPT_keysetup
marked
provedconstant time
HAL_GetTick
given secrets by HAL_I2C_Mem_Read, HAL_I2C_Mem_Write
provedconstant time, checked for caller HAL_I2C_Mem_Read, HAL_I2C_Mem_Write
HAL_NVIC_SystemReset
given secrets by svc_reset_system
boundedconstant time on the explored paths only, checked for caller svc_reset_system
i2c_find_channel_by_device
given secrets by se_transmit_mac_ex, thd89_transmit_ex
provedconstant time, checked for caller se_transmit_mac_ex, thd89_transmit_ex
interpolate_color
given secrets by set_color_table
inconclusiveconstant time not checked: the binary differs from the source, checked for caller set_color_table
mini_snprintf
given secrets by se_transmit_mac_ex, thd89_transmit_ex
inconclusiveconstant time, checked for caller se_transmit_mac_ex, thd89_transmit_ex
mini_vsnprintf
given secrets by display_text_printf, mini_snprintf
unsupportedconstant time not established, checked for caller display_text_printf, mini_snprintf
point_copy
given secrets by point_add
provedconstant time, checked for caller point_add
point_set_infinity
given secrets by point_add, point_double, point_multiply
provedconstant time, checked for caller point_add, point_double, point_multiply
set_color_table
given secrets by display_text_render
inconclusiveconstant time, checked for caller display_text_render
sha256_Transform
marked
boundedconstant time on the explored paths only
sha512_Transform
marked
boundedconstant time on the explored paths only
svc_reset_system
given secrets by __fatal_error
boundedconstant time, checked for caller __fatal_error

Chain of evidence

  1. Published image
    pro.bootloader.2.8.4-Stable-0420-3542e8c.signed.bin, sha256 25b8dbd2657ca46228e72ce8c25bb3097d184a08ecae1bad78cb508fc475e559
  2. Header
    the signed header's code hashes match the code
  3. Source
    OneKeyHQ/firmware-pro, tag bootloader-v2.8.4, commit 3542e8c46029…, the commit the vendor names for this release
  4. Reproducible build
    the vendor's own build reproduces the published image byte for byte, signatures aside
  5. Source bundle
    135 C/assembly units linked into the image; 47 linked inputs have no C source (Rust, toolchain libraries); toolchain: arm-none-eabi-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205; GNU assembler (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 2.39.0.20221210
  6. Extraction
    code at 0x8020400, 261,120 bytes; every published byte is accounted for except 8 bytes of erased flash
  7. Verification
    cverif 0.1.4 on the published bytes: 700 of 982 functions proved, 1 flag group(s)

Findings

lowtiming leakbn_cmov/bn_cnegate: the assert on the secret condition is compiled into branches
bn_cmov and bn_cnegate (bignum.c:275, :295) start with assert((int)(cond == 1) | (int)(cond == 0));, written with | "to ensure constant time". The bootloader is built without NDEBUG (-Os), and GCC compiles it as cmp cond, #1; beq ok; cbz cond, ok (0x80246b0, 0x8024bce): cond = 1 takes the first branch, cond = 0 executes one more instruction and takes the second. point_multiply calls bn_cnegate((sign ^ nsign) & 1, ...) once per 4-bit window with sign from the secret scalar's digits (ecdsa.c), and bn_mod calls bn_cmov on whether the value is below the prime (jacobian_to_curve on the secret-derived result). In this bootloader point_multiply runs with a secret scalar in ecdh_multiply for the MCU–SE session key (se_sync_session_key_ex: a fresh random prikey_tmp per session). The difference is about a cycle per call on a Cortex-M7 with branch prediction, on an ephemeral key: hard to exploit, but the code is not constant time as its comment intends. Trezor changed the assert upstream to assert(cond <= 1) (trezor-firmware 7829d7c7, 2026-11-16, "hardening against potential side-channel leakage"), which takes the same path for 0 and 1; OneKey's tree has the earlier form. OneKey was pointed to Trezor's fix on 2026-12-06.
ct-triage · confidence high · ct-assert-branch
lowtiming leakAES key expansion looks up the S-box with key bytes
aes_encrypt_key128 (aeskey.c:91, the ke4 round of Gladman's key schedule) loads from the table t_fl at an address computed from the key's bytes. In this bootloader AES is used with the SE session key (the AES-CBC-MAC and encryption of SE commands, se_thd89.c). The tables are built at boot into RAM at 0x2000xxxx (STATIC_TABLES=0), which on the STM32H747's Cortex-M7 is DTCM: uncached, fixed latency, so the dependency should not show in timing on this chip, short of bus contention. It is a timing leak in cverif's model (any secret-dependent address) and would be one on a core with a data cache in front of the table.
ct-triage · confidence medium · ct-aes-sbox
infoThe bootloader build reproduces the published image
Building tag bootloader-v2.8.4 (commit 3542e8c) with OneKey's CI recipe (build-pro.yml: ci/shell.nix, make -C core build_boardloader build_bootloader) in a pinned Nix container gives the published image byte for byte once the fields written by CI's last steps are zeroed on both sides: the signature and sigmask, the code hashes and hash_block (headertool.py -h), and hdrlen. The build writes hdrlen 0x3f8 (the length of header.S's bytes); headertool.py rewrites it to 0x400, which is what the boardloader requires. All 16 BLAKE2s chunk hashes in the header match the code.
reproducibility · confidence high · reproducible
infoThe OneKey app installs exactly this file
The app's update channel (data.onekey.so/config.json, pro.firmware-v8[].bootloaderResource) serves pro.bootloader.2.8.4-Stable-0420-3542e8c.signed.bin from web.onekey-asset.com, byte-identical to the GitHub release asset (sha256 25b8dbd2...). The channel lists it as bootloaderVersion 2.8.3 and displayBootloaderVersion 2.8.4; the image header says 2.8.4.
integrity · confidence high · app-channel
info9 of 135 units skipped by cverif
cverif 0.1.4 skips 9 units (verify/group0.err). Six define the strong version of an STM32 HAL __weak callback and are rejected as redefinition of HAL_...: trezorhal/qspi_flash.c, usbd_conf.c, spi_legacy.c, usart.c, camera.c, stm32_it_handler.c (issue 24), so neither those callbacks nor the rest of these units are verified. Two use initializers GCC folds as constants: mipi_lcd.c:81 (.end_x = lcd_params.hres - 1, a member of a const struct) and usbd_msc_storage.c:83 (TO_CHAR(x), (TO_STR(x))[0], a subscripted string literal). stm32h7xx_ll_fmc.c fails with #endif without #if at its last line; its conditionals are balanced and a reduced copy of the opening #if parses, so the cause is not known yet.
coverage · confidence high · skipped-units
infotiming leakpoint_multiply's table pmult indexed by the secret scalar's digits
point_multiply reads pmult[bits >> 1] (curve_to_jacobian, point_jacobian_add), bits being a digit of the secret scalar; the field arithmetic then loads through that pointer (bn_multiply_long, bignum.c:538). Secret-dependent addresses are a timing leak in cverif's model. pmult is on the stack, and the stack (.stack at 0x2000ca50) is in the STM32H747's DTCM (0x20000000–0x2001ffff): not behind the Cortex-M7's data cache, fixed latency, so the dependency should not show in timing on this chip, as for ct-aes-sbox.
ct-triage · confidence medium · ct-table-index
infocverif false alarmUMULL on the Cortex-M7
cverif flags umull with secret operands because the image records only ARMv7E-M (--cpu not given: Cortex-M4 or M7) and nothing documents its timing as fixed. The STM32H747 is a Cortex-M7, whose multiplier is a pipelined fixed-latency unit with no early termination (unlike the Cortex-M3's); ARM publishes no cycle table for the M7, so this rests on that common understanding, not on a document.
ct-triage · confidence medium · ct-umull-m7
inforeveals by designRejection sampling of random values
generate_k_random (ecdsa.c:181: while (bn_is_zero(k) || !bn_is_less(k, prime)), the random z of curve_to_jacobian's blinding) and the hardware RNG's health check (rng.c:41, :51: a new output equal to the previous one is discarded and read again; random32, rng_get, rng_read) branch on random values only to reject them. The timing reveals that a rejected candidate was drawn, nothing about the value kept.
ct-triage · confidence high · ct-rejection-sampling
inforeveals by designPrivate-key range checks branch on the key (k = 0 or k >= n)
point_multiply (ecdsa.c:413, if (!bn_is_less(k, &curve->order)) return 1;) and ecdsa_get_public_key65 (ecdsa.c:816, bn_is_zero) reject a scalar that is zero or not below the group order before using it; scalar_multiply inherits point_multiply's check. The branch reveals only whether the key is valid, which the result reveals anyway; a valid key never takes it.
ct-triage · confidence high · ct-key-range-check
infocverif false alarmPublic data taken as secret in callees
A function cverif checks "for the secrets its callers give it" takes as secret every byte its pointers reach that is not shown public, including constants in flash and plain globals. Here that is: the SE's public key and its validation in ecdh_multiply (ecdsa.c:638, ecdsa_read_pubkey), ecdsa_validate_pubkey, uncompress_coords (the key's parity byte), bn_sqrt, bn_power_mod, bn_subi, point_is_infinity; the secp256k1 constants (prime->val, curve->a in point_jacobian_add/_double's assert(-3 <= a && a <= 0), the exponent (p+1)/4) and bn_mult_k's constant multiplier; the precomputation on the public point in point_multiply (point_double, point_add, point_is_equal, point_is_negative_of on pmult, multiples of the SE's public key); and the error path every marked function can reach (ensure → __fatal_error → lcd_cover_background_hide, display, touch, I2C): __assert_func, __fatal_error, display_*, get_glyph, touch_*, gt911_*, HAL_I2C_Mem_*, I2C_RequestMemory*, i2c_master_send/_recive (the I2C handle pointer), dwt_delay_ms (SystemCoreClock). None of these values is secret.
ct-triage · confidence high · ct-public-memory
inforeveals by designSE protocol: branches on lengths and transfer status
se_transmit_mac_ex (se_thd89.c:168), se_random_encrypted_ex (:317) and thd89_transmit_ex (thd89.c:549) branch on whether an I2C exchange with the SE succeeded; cal_mac (:139), aes_ecb_decrypt and aes_cbc_decrypt (aes_modes.c:203, :363, len & 15) on a message length. Both are visible on the I2C bus (the frames and their lengths), as the spec's comment says of lengths; the session key only enters the bytes, which are encrypted and MACed.
ct-triage · confidence medium · ct-se-wire
infomark too broadAES: the branch is on the key schedule's length field, not on key material
aes_encrypt/aes_decrypt start with if (cx->inf.b[0] != 10*16 && ...) return EXIT_FAILURE; (aescrypt.c:104, :239): cx[240] is the key length in the schedule, public. The spec marks the whole cx secret, so the check is flagged; aes_cbc_encrypt then branches on aes_encrypt's return value, which depends only on that field. The spec should mark only the round keys. As above, the table-driven rounds after the check were not analysed; Gladman AES uses lookup tables indexed by the state, so they are not constant time by construction.
ct-triage · confidence high · ct-aes-key-length
infocverif false alarmmemzero calls explicit_bzero on secret memory
memzero is explicit_bzero(pnt, len); newlib's explicit_bzero falls into bzero, then memset, whose branches depend on the pointer's alignment and the length only. cverif has no constant-time knowledge of the library function.
ct-triage · confidence high · ct-memzero
infocverif false alarmCounterexample points an argument at __stack_chk_guard
In each counterexample a pointer argument points at __stack_chk_guard (0x20005d60): hdr == &__stack_chk_guard (load_image_header), fp == &__stack_chk_guard (f_open), stream, out, .... The source's store through it overwrites the canary, the binary's epilogue check fails and __stack_chk_fail runs (error_shutdown, then __fatal_error, whose first call is lcd_cover_background_hide). No caller can pass the address of the guard, an object the compiler introduces (issue 23); every path's binary condition compares __stack_chk_guard.
mismatch-triage · confidence high · covers 7 mismatches · cverif issue 23 · canary-alias
infocverif false alarmHAL callbacks compared with the HAL's empty __weak definitions
The STM32H7 HAL defines these callbacks __weak and empty; the bootloader's trezorhal units define them for real. The link map keeps those (.text.HAL_QSPI_CmdCpltCallback 0x803c478 ... qspi_flash.o, usbd_conf.o, spi_legacy.o, usart.o, camera.o, stm32_it_handler.o) and discards the HAL's (size 2 at address 0). cverif skips the units with the strong definitions (redefinition of ...) and compares the binary with the weak ones (issue 24), hence calls (USBD_LL_StallEP, usart_rx_dma_process, spi_cs_irq_handler, lcd_cover_background_hide through __fatal_error) and stores the empty functions lack. SPI_DMAError is the HAL's own static function: it calls HAL_SPI_ErrorCallback, the strong one (0x80368c6 bl 0x803e31c, which calls __fatal_error), where the weak source returns.
mismatch-triage · confidence high · covers 25 mismatches · cverif issue 24 · weak-callbacks
infocverif false alarm__atomic built-ins expanded inline
drbg_random8 (random_delays.c) guards the DRBG with __atomic_test_and_set; GCC expands it to dmb and exclusive loads/stores, which cverif compares with a call (issue 22).
mismatch-triage · confidence high · covers 1 mismatch · cverif issue 22 · atomics
infocverif false alarminterpolate_color specialised for its callers' step range
static inline uint16_t interpolate_color(color0, color1, uint8_t step) computes (... * step + ... * (15 - step)) / 15 in int; every caller passes 0 to 15 (set_color_table's i, and d - 16 or d in display.c:433/:435 with d split at 16), so the sums are never negative and GCC divides with udiv (0x8029756). The counterexample has step = 254, where the source's signed division gives another result (issue 12: a static function compiled for the arguments its callers pass).
mismatch-triage · confidence high · covers 1 mismatch · cverif issue 12 · interpolate-color
infocverif false alarmsend_msg_features_simple: `= Features_init_default` done by memcpy
MSG_SEND_INIT(Features) declares Features msg_send = Features_init_default; GCC copies the template from flash with memcpy (0x802e2f6), then the binary calls memzero, strncpy, ... _send_msg in the source's order. cverif expects no call for the initializer and reports the memcpy where the source calls explicit_bzero (as issue 29, with memcpy from a constant template instead of memset).
mismatch-triage · confidence high · covers 1 mismatch · cverif issue 29 · init-template
infocverif false alarmHAL_DMA_Start_IT: counterexample puts the DMA handle in peripheral space
The counterexample has hdma = 0x40000000, inside the default peripheral range (--mmio 40000000-5fffffff), with hdma->Instance (read from there) equal to DMA1_Stream0 (0x40020010). The binary reads Instance once and takes a path specialised for that stream (0x8031b28: ldr r1, =0x40020000; ldr r2, [r1, #16]); the source reads hdma->Instance again for each access, and a read of an address in the peripheral range gives a fresh value each time, so cverif does not see the same register access. Every DMA_HandleTypeDef in the bootloader is a RAM static; no caller passes a handle in peripheral space.
mismatch-triage · confidence medium · covers 1 mismatch · dma-handle-in-mmio

What the image is made of

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

OriginBytesShare
C252,58896.4%
toolchain libraries (newlib, libgcc)4,3311.7%
linker fill3,1601.2%
assembly2,0560.8%

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_DMA_Start_IT
0x8031780
mismatch1004binary reads 4 byte(s) of the peripheral register at 0x40020010 (instruction at 0x8031b2a) where the source makes no such access
f_open
0x8041e3c
mismatch516binary calls lcd_cover_background_hide, which the source does not call at this point
expand256_modm
0x80241d4
mismatch488binary calls lcd_cover_background_hide, which the source does not call at this point
HAL_PCD_MspInit
0x803d314
mismatch456binary reads 4 byte(s) of the peripheral register at 0x580244e0 (instruction at 0x803d32c) where the source makes no such access
load_image_header
0x803a940
mismatch400binary calls lcd_cover_background_hide, which the source does not call at this point
drbg_random8
0x803c4c4
mismatch244binary executes `dmb` where the source is calling __atomic_test_and_set
emmc_fs_path_info
0x80471c4
mismatch216binary calls lcd_cover_background_hide, which the source does not call at this point
send_msg_features_simple
0x802e2d8
mismatch176binary calls memcpy where the source is calling explicit_bzero
pb_read
0x802f008
mismatch152binary calls lcd_cover_background_hide, which the source does not call at this point
HAL_SPI_RxCpltCallback
0x803e298
mismatch96binary writes 4 byte(s) of the peripheral register at 0x58022818 (instruction at 0x8032fb6) where the source makes no such access
emmc_fs_path_type
0x8047150
mismatch72binary calls lcd_cover_background_hide, which the source does not call at this point
interpolate_color
0x8029728
mismatch
CT inconclusive
70return value: source gives 0xf6ed, binary gives 0xf8ed for mem[0x20000028]=0x2e mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_PCD_MspDeInit
0x803d4dc
mismatch68binary reads 4 byte(s) of the peripheral register at 0x580244d8 (instruction at 0x803d4e6) where the source makes no such access
pb_decode_fixed64
0x802f274
mismatch60binary calls lcd_cover_background_hide, which the source does not call at this point
SPI_DMAError
0x80368a2
mismatch42binary calls lcd_cover_background_hide, which the source does not call at this point
HAL_PCD_DataInStageCallback
0x803d550
mismatch36memory at return: 1-byte value stored at 0x2000676a: source gives 0x0, binary gives 0x1 for r0=0x81d mem[0x14]=0x00 mem[0x15]=0x00 mem[0x16]=0x00 mem[0x17]=0x00 mem[0x7b9]=0x00 mem[0x7ba]=0x00 mem[0x7bb]=0x00 mem[0x7bc]=0x00
HAL_SPI_TxCpltCallback
0x803e2f8
mismatch36memory at return: 4-byte value stored at 0x2000ac18: source gives 0x80000000, binary gives 0x0 for r0=0x80000006 mem[0x20000028]=0x50 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_SPI_ErrorCallback
0x803e31c
mismatch36binary calls lcd_cover_background_hide, which the source does not call at this point
HAL_PCD_ResetCallback
0x803d57c
mismatch32binary calls USBD_LL_OpenEP, which the source does not call at this point
HAL_PCD_SetupStageCallback
0x803d520
mismatch28binary calls USBD_LL_StallEP, which the source does not call at this point
HAL_PCD_SuspendCallback
0x803d59c
mismatch24memory at return: 1-byte value stored at (mem0.32[(r0 + 1028)] + 629): source gives 0x40, binary gives 0x0 for r0=0x1404402 mem[0x14042b5]=0x00 mem[0x14042b6]=0x40 mem[0x1404806]=0x41 mem[0x1404807]=0x40 mem[0x1404808]=0x40 mem[0x1404809]=0x01 mem[0x20000028]=0x2c mem[0x20000029]=0x01
HAL_PCD_ConnectCallback
0x803d5cc
mismatch24memory at return: 1-byte value stored at 0x2000676b: source gives 0x0, binary gives 0x1 for r0=0x80000006 mem[0x20000028]=0x54 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_PCD_DisconnectCallback
0x803d5e4
mismatch24binary calls <indirect call>, which the source does not call at this point
HAL_PCD_DataOutStageCallback
0x803d53c
mismatch18binary calls <indirect call>, which the source does not call at this point
HAL_QSPI_CmdCpltCallback
0x803c478
mismatch16memory at return: 1-byte value stored at 0x2000600f: source gives 0x0, binary gives 0x1 for r0=0x80000006 mem[0x20000028]=0x41 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_QSPI_RxCpltCallback
0x803c488
mismatch16memory at return: 1-byte value stored at 0x2000600e: source gives 0x0, binary gives 0x1 for r0=0x80000006 mem[0x20000028]=0x41 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_QSPI_TxCpltCallback
0x803c498
mismatch16memory at return: 1-byte value stored at 0x2000600d: source gives 0x0, binary gives 0x1 for r0=0x80000006 mem[0x20000028]=0x41 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_QSPI_StatusMatchCallback
0x803c4a8
mismatch16memory at return: 1-byte value stored at 0x2000600c: source gives 0x0, binary gives 0x1 for r0=0x80000006 mem[0x20000028]=0x41 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_SPI_AbortCpltCallback
0x803e340
mismatch12memory at return: 4-byte value stored at 0x2000ac14: source gives 0x1, binary gives 0x0 for r0=0x80000006 mem[0x20000028]=0x50 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_UART_TxCpltCallback
0x803ed14
mismatch12memory at return: 1-byte value stored at 0x2000af9c: source gives 0x0, binary gives 0x1 for r0=0x80000006 mem[0x20000028]=0x54 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_DCMI_FrameEventCallback
0x8044724
mismatch12memory at return: 1-byte value stored at 0x2000c030: source gives 0x0, binary gives 0x1 for r0=0x80000006 mem[0x20000028]=0x54 mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_GPIO_EXTI_Callback
0x8044db8
mismatch12binary calls spi_cs_irq_handler, which the source does not call at this point
HAL_PCD_SOFCallback
0x803d574
mismatch8binary calls <indirect call>, which the source does not call at this point
HAL_PCD_ResumeCallback
0x803d5b4
mismatch8memory at return: 1-byte value stored at (mem0.32[(r0 + 1028)] + 628): source gives 0x7f, binary gives 0x80 for r0=0x80808465 mem[0x20000028]=0x2c mem[0x20000029]=0x01 mem[0x2000002a]=0x00 mem[0x2000002b]=0x00 mem[0x20000290]=0x00 mem[0x20000291]=0x00 mem[0x20000292]=0x00 mem[0x20000293]=0x00
HAL_UART_RxCpltCallback
0x803ed0c
mismatch4binary calls usart_rx_dma_process, which the source does not call at this point
HAL_UART_RxHalfCpltCallback
0x803ed10
mismatch4binary calls usart_rx_dma_process, which the source does not call at this point
ui_bootloader_view_details
0x802bef4
proved764
mount_volume
0x8040dbc
proved628
curve25519_contract
0x8022d84
proved624
device_verify_ble
0x803f50c
proved588
ui_bootloader_page_switch
0x802c4bc
proved568
usb_class_setup
0x803c8f4
proved568
sdram_reinit
0x8044b84
proved536
DMA_SetConfig
0x8031054
proved512
USB_EPStartXfer
0x8039c64
proved508
ui_statusbar_update
0x802b038
proved500
HAL_GPIO_Init
0x8032ca8
proved456
encode_basic_field
0x802ff04
proved452
HAL_RCCEx_GetPeriphCLKFreq
0x8035d7c
proved444
ui_bootloader_first
0x802bc38
proved436
ge25519_unpack_negative_vartime
0x80237cc
proved420
HAL_MMC_InitCard
0x8033f2c
proved412
HAL_MMC_WriteBlocks
0x80339c4
proved392
HAL_MMC_GetCardCSD
0x8033db8
proved372
QSPI_Config
0x8037898
proved372
usb_init
0x803cdf0
proved368
HAL_RCCEx_GetPLL2ClockFreq
0x8035980
proved340
HAL_RCCEx_GetPLL3ClockFreq
0x8035ad4
proved340
HAL_RCCEx_GetPLL1ClockFreq
0x8035c28
proved340
process_msg_EmmcPathInfo
0x804671c
proved340
ecdsa_verify_digest
0x8025c10
proved330
error_shutdown
0x803a668
proved328
ADC_ConfigureBoostMode
0x8030ac8
proved324
HAL_RCC_GetSysClockFreq
0x8034c90
proved324
SystemCoreClockUpdate
0x803a084
proved324
emmc_init
0x803bc10
proved324
HAL_DMA_Abort_IT
0x8031fac
proved320
HAL_GPIO_DeInit
0x8032e70
proved312
get_boardloader_version
0x8040624
proved312
check_bootloader_update
0x80462c0
proved312
f_mkdir
0x8042880
proved308
ge25519_pnielsadd
0x8023608
proved304
adc_init_device_hw_ver
0x803a1c8
proved292
reduce256_modm
0x8023b54
proved288
ui_bootloader_factory_reset_confirm
0x802c2e8
proved284
usb_init_all
0x802c6f4
proved284
HAL_EXTI_SetConfigLine
0x8032794
proved284
HAL_MMC_ConfigWideBusOperation
0x8033b6c
proved268
LTDC_SetConfig
0x8037284
proved268
ui_bootloader_main_menu
0x802bdec
proved264
_send_msg
0x802d488
proved256
HAL_TIM_PWM_ConfigChannel
0x80370b4
proved254
HAL_ADC_Start
0x8030964
proved252
HAL_DMA2D_PollForTransfer
0x80376e0
proved250
ui_bootloader_restart_confirm
0x802c1f0
proved248
USB_EP0StartXfer
0x8039b48
proved244
HAL_MMC_ConfigSpeedBusOperation
0x8034100
proved242
RCCEx_PLL2_Config
0x8034e48
proved240
RCCEx_PLL3_Config
0x8034f38
proved240
get_firmware_hash
0x80407fc
proved240
emmc_fs_file_read
0x8047460
proved240
flash_erase_sectors
0x803b434
proved236
usb_webusb_add
0x803cfb8
proved236
process_msg_EmmcFixPermission
0x8046630
proved236
ui_screen_install_confirm_newvendor_or_downgrade_wipe
0x802b2b4
proved232
MMC_HighSpeed
0x8033734
proved232
curve25519_sub_after_basic
0x8022148
proved230
usb_class_data_out
0x803c810
proved228
ge25519_pnielsadd_p1p1
0x8023500
proved224
USB_SetTurnaroundTime
0x8039764
proved224

Showing 100 of 982.

Raw results

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