-
-
Notifications
You must be signed in to change notification settings - Fork 710
Implement tropic provisioning #5525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
model | device_test | click_test | persistence_test |
---|---|---|---|
T2T1 | |||
T3B1 | |||
T3T1 | |||
T3W1 |
Latest CI run: 17072904578
ad989b9
to
e29ef7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review. Still need to look at prodtest_tropic.c
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prodtest_tropic.c
checked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review.
lt_handle_t* tropic_handle = tropic_get_handle(); | ||
lt_ret_t ret = LT_FAIL; | ||
|
||
systick_delay_ms(80); | ||
curve25519_key tropic_public = {0}; | ||
if (secret_key_tropic_public(tropic_public) != sectrue) { | ||
cli_error(cli, CLI_ERROR, "`secret_key_tropic_public()` failed."); | ||
goto cleanup; | ||
} | ||
|
||
curve25519_key privileged_private = {0}; | ||
if (secret_key_tropic_pairing_privileged(privileged_private) != sectrue) { | ||
cli_error(cli, CLI_ERROR, | ||
"`secret_key_tropic_pairing_privileged()` failed."); | ||
goto cleanup; | ||
} | ||
curve25519_key privileged_public = {0}; | ||
curve25519_scalarmult_basepoint(privileged_public, privileged_private); | ||
|
||
ret = | ||
lt_session_start(tropic_handle, tropic_public, PRIVILEGED_PAIRING_KEYSLOT, | ||
privileged_private, privileged_public); | ||
if (ret != LT_OK) { | ||
cli_error(cli, CLI_ERROR, | ||
"`lt_session_start()` for privileged key failed with error %d", | ||
ret); | ||
goto cleanup; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is duplicated across cert_write()
, read_cert()
and twice in is_paired()
. We can define a function like this:
static bool tropic_handshake(int key_slot) {
tropic_handshake_state = TROPIC_HANDSHAKE_STATE_0;
lt_handle_t* tropic_handle = tropic_get_handle();
curve25519_key tropic_public = {0};
if (secret_key_tropic_public(tropic_public) != sectrue) {
cli_error(cli, CLI_ERROR, "`secret_key_tropic_public()` failed.");
goto cleanup;
}
curve25519_key private = {0};
if (key_slot == PRIVILEGED_PAIRING_KEY_SLOT) {
if (secret_key_tropic_pairing_privileged(private) != sectrue) {
cli_error(cli, CLI_ERROR,
"`secret_key_tropic_pairing_privileged()` failed.");
goto cleanup;
}
} else if (key_slot == UNPRIVILEGED_PAIRING_KEY_SLOT) {
if (secret_key_tropic_pairing_unprivileged(private) != sectrue) {
cli_error(cli, CLI_ERROR,
"`secret_key_tropic_pairing_unprivileged()` failed.");
goto cleanup;
}
} else {
cli_error(cli, CLI_ERROR,
"Unknown key_slot.");
goto cleanup;
}
curve25519_key public = {0};
curve25519_scalarmult_basepoint(public, private);
lt_ret_t ret =
lt_session_start(tropic_handle, tropic_public, key_slot,
private, public);
if (ret != LT_OK) {
cli_error(cli, CLI_ERROR,
"`lt_session_start()` for privileged key failed with error %d",
ret);
goto cleanup;
}
cleanup:
memzero(private, sizeof(private));
return ret == LT_OK; // TODO set ret correctly above
}
- Maybe we can reuse/replace
tropic_init()
from embed/sec/tropic/tropic.c? I didn't look closely enough. The error handling would probably complicate things. - Probably makes sense to add
FACTORY_PAIRING_KEY_SLOT
to the if-else, so that it can be used inprodtest_tropic_pair()
, again I didn't look close enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I don't know how long the handshake takes, but we could optimize this, so that if the handshake is already active we don't repeat it. For example replace TROPIC_HANDSHAKE_STATE_1
with different states for each key:
TROPIC_HANDSHAKE_STATE_FACTORY
TROPIC_HANDSHAKE_STATE_PRIVILEGED
TROPIC_HANDSHAKE_STATE_UNPRIVILEGED
TROPIC_HANDSHAKE_STATE_HSM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you, and I wanted to refactor it exactly as you suggested, but I considered it a low priority.
0723387
to
695cd1a
Compare
I squashed all the fix-up commits, reordered the commits, and changed the commit messages. The diff between the old branch and the new branch is empty. |
15934d0
to
6099c3a
Compare
@andrewkozlik Could you please review 01675e0? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
[no changelog]
[no changelog]
[no changelog]
04488d9
to
f1bff16
Compare
f1bff16
to
3d04afe
Compare
No description provided.