Skip to content

Commit 4e59c37

Browse files
author
Jamie C. Driver
committed
attestation consistency: sensitive-stack to protect the key during setup
1 parent 5a6bff1 commit 4e59c37

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

main/attestation/attestation.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,13 @@ bool attestation_initialise(const char* privkey_pem, const size_t privkey_pem_le
526526

527527
mbedtls_pk_context pk;
528528
mbedtls_pk_init(&pk);
529+
SENSITIVE_PUSH(&pk, sizeof(pk));
530+
529531
const bool is_private_key = true;
530532

531533
// Import RSA private key - expected 4096-bit key
532534
if (!import_rsa_key(&pk, privkey_pem, privkey_pem_len, is_private_key)
533-
|| mbedtls_pk_get_bitlen(&pk) != (JADE_ATTEST_RSA_KEY_LEN * 8)) {
535+
|| mbedtls_pk_get_len(&pk) != JADE_ATTEST_RSA_KEY_LEN) {
534536
JADE_LOGE("Failed to import valid RSA private key of expected length");
535537
goto cleanup;
536538
}
@@ -620,6 +622,8 @@ bool attestation_initialise(const char* privkey_pem, const size_t privkey_pem_le
620622
cleanup:
621623
SENSITIVE_POP(hmac_key);
622624
mbedtls_pk_free(&pk);
625+
SENSITIVE_POP(&pk);
626+
623627
return retval;
624628
}
625629

0 commit comments

Comments
 (0)