feat(prodtest): add tropic-benchmark command
What changed, and why it matters
This commit adds a new factory/production-test command called tropic-benchmark. It only measures how long certain Tropic secure-chip operations take and prints average timings. There is no user-facing change, no wallet behavior change, and no fix or vulnerability indicated.
No security action required. Treat as a normal feature addition to production-test tooling.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change introduces prodtest_tropic_benchmark(), registered as the CLI command tropic-benchmark in the prodtest (production testing) firmware project. The function runs 25 iterations of Tropic secure-element operations (session start, MAC-and-destroy, R-MEM read/write/erase, monotonic counter init/get/update, and random value generation), sums elapsed milliseconds using systick_ms(), and prints averages. It reuses existing helper functions and follows the same error-handling patterns as neighboring prodtest commands. No cryptographic constants, access controls, or production firmware logic are modified.
Changed components
core/embed/projects/prodtest/cmd/prodtest_tropic.ccore/embed/projects/prodtest/README.mdInspect captured patch +219 / −0
diff --git a/core/embed/projects/prodtest/README.md b/core/embed/projects/prodtest/README.md
index e95a87a4..acd6db07 100644
--- a/core/embed/projects/prodtest/README.md
+++ b/core/embed/projects/prodtest/README.md
@@ -1466,6 +1466,25 @@ OK
Runs a Tropic stress test that repeatedly calls `lt_init()`, `lt_session_start()`, `lt_mac_and_destroy()`, `lt_ecc_key_generate()` and `lt_random_value_get()` to test that Tropic doesn't enter alarm mode.
+### tropic-benchmark
+
+Measures the actual average duration of individual Tropic operations over 25 iterations and prints the results.
+
+Example:
+```
+tropic-benchmark
+# session_start() 204 ms
+# mac_and_destroy() 28 ms
+# r_mem_data_write() 37 ms
+# r_mem_data_read() 33 ms
+# r_mem_data_erase() 4 ms
+# mcounter_init() 9 ms
+# mcounter_get() 4 ms
+# mcounter_update() 4 ms
+# random_value_get() 10 ms
+OK
+```
+
### wpc-info
Retrieves detailed information from the wireless power receiver, including chip identification, firmware version, configuration settings, and error status.
diff --git a/core/embed/projects/prodtest/cmd/prodtest_tropic.c b/core/embed/projects/prodtest/cmd/prodtest_tropic.c
index 9f24fbfb..c9a349f7 100644
--- a/core/embed/projects/prodtest/cmd/prodtest_tropic.c
+++ b/core/embed/projects/prodtest/cmd/prodtest_tropic.c
@@ -1807,6 +1807,199 @@ static void prodtest_tropic_stress_test(cli_t* cli) {
cli_ok(cli, "");
}
+static void prodtest_tropic_benchmark(cli_t* cli) {
+ if (cli_arg_count(cli) != 0) {
+ cli_error_arg_count(cli);
+ return;
+ }
+
+ g_tropic_handshake_state = TROPIC_HANDSHAKE_STATE_0;
+
+ lt_ret_t res = LT_FAIL;
+ lt_pkey_index_t pairing_key_index = -1;
+
+ if (!find_pairing_key(cli, &pairing_key_index)) {
+ cli_error(cli, CLI_ERROR, "No pairing key is available");
+ return;
+ }
+
+ lt_handle_t* h = tropic_get_handle();
+ uint32_t start_ms = 0;
+
+ const int iterations = 25;
+ const uint16_t timing_data_slot = TR01_R_MEM_DATA_SLOT_MAX;
+ const lt_mcounter_index_t timing_mcounter_slot = TR01_MCOUNTER_INDEX_15;
+
+ // Ensure data slot is empty before the first iteration
+ res = lt_r_mem_data_erase(h, timing_data_slot);
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR, "`lt_r_mem_data_erase()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+
+ uint32_t total_session_start_ms = 0;
+ uint32_t total_mac_and_destroy_ms = 0;
+ uint32_t total_r_mem_data_write_ms = 0;
+ uint32_t total_r_mem_data_read_ms = 0;
+ uint32_t total_r_mem_data_erase_ms = 0;
+ uint32_t total_mcounter_init_ms = 0;
+ uint32_t total_mcounter_get_ms = 0;
+ uint32_t total_mcounter_update_ms = 0;
+ uint32_t total_random_value_get_ms = 0;
+
+ for (int i = 0; i < iterations; i++) {
+ // Measure `tropic_custom_session_start()`
+ {
+ res = tropic_session_invalidate();
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR,
+ "`tropic_session_invalidate()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ start_ms = systick_ms();
+ res = tropic_custom_session_start(cli, pairing_key_index);
+ total_session_start_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR,
+ "`tropic_custom_session_start()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+
+ // Measure `lt_mac_and_destroy()`
+ {
+ uint8_t buffer[TROPIC_MAC_AND_DESTROY_SIZE] = {0};
+ rng_fill_buffer(buffer, sizeof(buffer));
+ start_ms = systick_ms();
+ res = lt_mac_and_destroy(
+ h, TROPIC_FIRST_MAC_AND_DESTROY_SLOT_UNPRIVILEGED, buffer, buffer);
+ total_mac_and_destroy_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR,
+ "`lt_mac_and_destroy()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+
+ uint8_t data[320] = {0};
+
+ // Measure `lt_r_mem_data_write()` (320 bytes)
+ {
+ rng_fill_buffer(data, sizeof(data));
+ start_ms = systick_ms();
+ res = lt_r_mem_data_write(h, timing_data_slot, data, sizeof(data));
+ total_r_mem_data_write_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR,
+ "`lt_r_mem_data_write()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+
+ // Measure `lt_r_mem_data_read()` (320 bytes)
+ {
+ uint16_t read_size = 0;
+ start_ms = systick_ms();
+ res = lt_r_mem_data_read(h, timing_data_slot, data, sizeof(data),
+ &read_size);
+ total_r_mem_data_read_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR,
+ "`lt_r_mem_data_read()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+
+ // Measure `lt_r_mem_data_erase()`
+ {
+ start_ms = systick_ms();
+ res = lt_r_mem_data_erase(h, timing_data_slot);
+ total_r_mem_data_erase_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR,
+ "`lt_r_mem_data_erase()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+
+ // Measure `lt_mcounter_init()`
+ {
+ start_ms = systick_ms();
+ res = lt_mcounter_init(h, timing_mcounter_slot, 1);
+ total_mcounter_init_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR, "`lt_mcounter_init()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+
+ // Measure `lt_mcounter_get()`
+ {
+ uint32_t counter_value = 0;
+ start_ms = systick_ms();
+ res = lt_mcounter_get(h, timing_mcounter_slot, &counter_value);
+ total_mcounter_get_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR, "`lt_mcounter_get()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+
+ // Measure `lt_mcounter_update()`
+ {
+ start_ms = systick_ms();
+ res = lt_mcounter_update(h, timing_mcounter_slot);
+ total_mcounter_update_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR,
+ "`lt_mcounter_update()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+
+ // Measure `lt_random_value_get()` (32 bytes)
+ {
+ uint8_t buffer[32] = {0};
+ start_ms = systick_ms();
+ res = lt_random_value_get(h, buffer, sizeof(buffer));
+ total_random_value_get_ms += systick_ms() - start_ms;
+ if (res != LT_OK) {
+ cli_error(cli, CLI_ERROR,
+ "`lt_random_value_get()` failed with error '%s'",
+ lt_ret_verbose(res));
+ return;
+ }
+ }
+ }
+
+#define CLI_TRACE_AVERAGE(name, total) \
+ cli_trace(cli, name " %lu ms", (((total) + iterations / 2) / iterations))
+
+ CLI_TRACE_AVERAGE("session_start() ", total_session_start_ms);
+ CLI_TRACE_AVERAGE("mac_and_destroy() ", total_mac_and_destroy_ms);
+ CLI_TRACE_AVERAGE("r_mem_data_write()", total_r_mem_data_write_ms);
+ CLI_TRACE_AVERAGE("r_mem_data_read() ", total_r_mem_data_read_ms);
+ CLI_TRACE_AVERAGE("r_mem_data_erase()", total_r_mem_data_erase_ms);
+ CLI_TRACE_AVERAGE("mcounter_init() ", total_mcounter_init_ms);
+ CLI_TRACE_AVERAGE("mcounter_get() ", total_mcounter_get_ms);
+ CLI_TRACE_AVERAGE("mcounter_update() ", total_mcounter_update_ms);
+ CLI_TRACE_AVERAGE("random_value_get()", total_random_value_get_ms);
+
+#undef CLI_TRACE_AVERAGE
+
+ cli_ok(cli, "");
+}
+
static bool privileged_session_start(cli_t* cli) {
g_tropic_handshake_state = TROPIC_HANDSHAKE_STATE_0;
@@ -2167,6 +2360,13 @@ PRODTEST_CLI_CMD(
.args = "[<init-iterations> <start-session-iterations> <mac-and-destroy-slot-count> <mac-and-destroy-per-slot-iterations> <signing-iterations> <rng-iterations>]"
);
+PRODTEST_CLI_CMD(
+ .name = "tropic-benchmark",
+ .func = prodtest_tropic_benchmark,
+ .info = "Measure actual duration of Tropic operations",
+ .args = ""
+);
+
PRODTEST_CLI_CMD(
.name = "tropic-set-sensors",
.func = prodtest_tropic_set_sensors,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.