feat(core/prodtest): introduce logging in `pairing_key_write()`
What changed, and why it matters
This change only adds diagnostic log messages to a production-test helper function that writes pairing keys to a Tropic secure chip during factory testing. It does not alter security logic, access controls, or cryptographic operations; it merely makes failures easier to see during manufacturing tests.
No security action required. Treat as normal code-quality/diagnostics improvement. If desired, verify that `cli_trace()` output is not persisted or exposed outside the controlled production-test environment.
Security signals we found
No change to authorization or cryptographic logic
No new attack surface introduced
Added logging may leak pairing-key write/read status to production-test console, but this is expected in a factory-test context
Function remains internal to prodtest firmware
Evidence from the diff
The commit refactors pairing_key_write() in core/embed/projects/prodtest/cmd/prodtest_tropic.c to accept a cli_t* context and emit cli_trace() messages at each error/verification branch. The control flow remains identical: lt_pairing_key_write() is called, LT_L3_FAIL (already-written key) is tolerated, a read-back is performed, and the read-back value is compared with memcmp(). The only differences are added trace strings and a slight reordering of the LT_L3_FAIL check. Call sites in prodtest_tropic_pair() are updated to pass the cli pointer.
Changed components
core/embed/projects/prodtest/cmd/prodtest_tropic.cpairing_key_write()prodtest_tropic_pair()Inspect captured patch +16 / −7
diff --git a/core/embed/projects/prodtest/cmd/prodtest_tropic.c b/core/embed/projects/prodtest/cmd/prodtest_tropic.c
index d1ee78a3..b2a70322 100644
--- a/core/embed/projects/prodtest/cmd/prodtest_tropic.c
+++ b/core/embed/projects/prodtest/cmd/prodtest_tropic.c
@@ -647,22 +647,29 @@ tropic_locked_status get_tropic_locked_status(cli_t* cli) {
return TROPIC_LOCKED_TRUE;
}
-static lt_ret_t pairing_key_write(lt_handle_t* handle, lt_pkey_index_t slot,
+static lt_ret_t pairing_key_write(cli_t* cli, lt_handle_t* handle,
+ lt_pkey_index_t slot,
const ed25519_secret_key public_key) {
// If this function returns `LT_OK`, it is ensured that the pairing key
// `public_key` is written in the slot `slot`.
lt_ret_t ret = lt_pairing_key_write(handle, public_key, slot);
- if (ret != LT_OK && ret != LT_L3_FAIL) {
+ if (ret == LT_L3_FAIL) {
+ cli_trace(cli, "Pairing key has already been written.");
+ } else if (ret != LT_OK) {
+ cli_trace(cli, "`lt_pairing_key_write()` failed with error '%s'",
+ lt_ret_verbose(ret));
return ret;
}
- // If the pairing has already been written, `lt_pairing_key_write()` returns
- // `LT_L3_FAIL`.
+
curve25519_key public_key_read = {0};
ret = lt_pairing_key_read(handle, public_key_read, slot);
if (ret != LT_OK) {
+ cli_trace(cli, "`lt_pairing_key_read()` failed with error '%s'",
+ lt_ret_verbose(ret));
return ret;
}
if (memcmp(public_key, public_key_read, sizeof(ed25519_public_key)) != 0) {
+ cli_trace(cli, "Public key does not match the expected value.");
return LT_FAIL;
}
@@ -820,8 +827,9 @@ static void prodtest_tropic_pair(cli_t* cli) {
LT_OK) {
// Write the privileged pairing key to the tropic's pairing key slot if it
// has not been written yet.
- lt_ret_t ret = pairing_key_write(
- tropic_handle, TROPIC_PRIVILEGED_PAIRING_KEY_SLOT, privileged_public);
+ lt_ret_t ret = pairing_key_write(cli, tropic_handle,
+ TROPIC_PRIVILEGED_PAIRING_KEY_SLOT,
+ privileged_public);
// If the pairing key has already been written, `pairing_key_write()`
// returns `LT_OK`.
if (ret != LT_OK) {
@@ -834,7 +842,8 @@ static void prodtest_tropic_pair(cli_t* cli) {
// Write the unprivileged pairing key to the tropic's pairing key slot if it
// has not been written yet.
- ret = pairing_key_write(tropic_handle, TROPIC_UNPRIVILEGED_PAIRING_KEY_SLOT,
+ ret = pairing_key_write(cli, tropic_handle,
+ TROPIC_UNPRIVILEGED_PAIRING_KEY_SLOT,
unprivileged_public);
// If the pairing key has already been written, `pairing_key_write()`
// returns `LT_OK`.
Why this scored 20/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.