Skip to content

Commit a111d0b

Browse files
authored
Merge pull request #26 from dgreen-arm/psa-crypto-api-1.0b3
Update example to use PSA Crypto 1.0b3 API
2 parents 33d8ac3 + 87bb57e commit a111d0b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

main.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <inttypes.h>
2626
#include "entropy.h"
2727
#include "entropy_poll.h"
28+
#include "mbedtls/version.h"
2829

2930
#if defined(MBEDTLS_PLATFORM_C)
3031
#include "mbedtls/platform.h"
@@ -46,11 +47,12 @@
4647
} \
4748
} while (0)
4849

49-
#if !defined(MBEDTLS_PSA_CRYPTO_C)
50+
#if !defined(MBEDTLS_PSA_CRYPTO_C) || (MBEDTLS_VERSION_NUMBER < 0x02130000)
5051
int main(void)
5152
{
52-
mbedtls_printf("Not all of the required options are defined:\n"
53-
" - MBEDTLS_PSA_CRYPTO_C\n");
53+
mbedtls_printf("Not all of the requirements are met:\n"
54+
" - MBEDTLS_PSA_CRYPTO_C\n"
55+
" - PSA Crypto API v1.0b3\n");
5456
return 0;
5557
}
5658
#else
@@ -81,7 +83,7 @@ static psa_status_t check_initial_attestation_get_token()
8183
ASSERT_STATUS(status, PSA_SUCCESS);
8284
status = psa_attestation_inject_key(NULL,
8385
0,
84-
PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1),
86+
PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_CURVE_SECP256R1),
8587
exported,
8688
sizeof(exported),
8789
&exported_length);
@@ -119,12 +121,11 @@ static void attestation_example(void)
119121

120122
int main(void)
121123
{
122-
const psa_key_id_t key_id = PSA_ATTESTATION_PRIVATE_KEY_ID;
123-
psa_key_handle_t handle = 0;
124+
psa_key_handle_t handle;
124125

125126
attestation_example();
126127

127-
psa_open_key(PSA_KEY_LIFETIME_PERSISTENT, key_id, &handle);
128+
psa_open_key(PSA_ATTESTATION_PRIVATE_KEY_ID, &handle);
128129
psa_destroy_key(handle);
129130
mbedtls_psa_crypto_free();
130131
return 0;

0 commit comments

Comments
 (0)