Skip to content

Commit

Permalink
attestation consistency: sensitive-stack to protect the key during setup
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieDriver committed Nov 14, 2024
1 parent 5a6bff1 commit 4e59c37
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main/attestation/attestation.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,13 @@ bool attestation_initialise(const char* privkey_pem, const size_t privkey_pem_le

mbedtls_pk_context pk;
mbedtls_pk_init(&pk);
SENSITIVE_PUSH(&pk, sizeof(pk));

const bool is_private_key = true;

// Import RSA private key - expected 4096-bit key
if (!import_rsa_key(&pk, privkey_pem, privkey_pem_len, is_private_key)
|| mbedtls_pk_get_bitlen(&pk) != (JADE_ATTEST_RSA_KEY_LEN * 8)) {
|| mbedtls_pk_get_len(&pk) != JADE_ATTEST_RSA_KEY_LEN) {
JADE_LOGE("Failed to import valid RSA private key of expected length");
goto cleanup;
}
Expand Down Expand Up @@ -620,6 +622,8 @@ bool attestation_initialise(const char* privkey_pem, const size_t privkey_pem_le
cleanup:
SENSITIVE_POP(hmac_key);
mbedtls_pk_free(&pk);
SENSITIVE_POP(&pk);

return retval;
}

Expand Down

0 comments on commit 4e59c37

Please sign in to comment.