File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 35
35
#include " mbed.h"
36
36
37
37
#include " mbedtls/platform.h"
38
+ #if defined(MBEDTLS_USE_PSA_CRYPTO)
39
+ #include " psa/crypto.h"
40
+ #endif /* MBEDTLS_USE_PSA_CRYPTO */
38
41
39
42
#include " HelloHttpsClient.h"
40
43
@@ -52,6 +55,24 @@ int main()
52
55
{
53
56
int exit_code = MBEDTLS_EXIT_FAILURE;
54
57
58
+ #if defined(MBEDTLS_USE_PSA_CRYPTO)
59
+ /*
60
+ * Initialize underlying PSA Crypto implementation.
61
+ * Even if the HTTPS client doesn't make use of
62
+ * PSA-specific API, for example for setting opaque PSKs
63
+ * or opaque private keys, Mbed TLS will use PSA
64
+ * for public and symmetric key operations as well as
65
+ * hashing.
66
+ */
67
+ psa_status_t status;
68
+ status = psa_crypto_init ();
69
+ if ( status != PSA_SUCCESS )
70
+ {
71
+ printf (" psa_crypto_init() failed with %d\r\n " , status );
72
+ return MBEDTLS_EXIT_FAILURE;
73
+ }
74
+ #endif /* MBEDTLS_USE_PSA_CRYPTO */
75
+
55
76
if ((exit_code = mbedtls_platform_setup (NULL )) != 0 ) {
56
77
printf (" Platform initialization failed with error %d\r\n " , exit_code);
57
78
return MBEDTLS_EXIT_FAILURE;
Original file line number Diff line number Diff line change 36
36
#undef MBEDTLS_MPI_MAX_SIZE
37
37
#define MBEDTLS_MPI_MAX_SIZE 256
38
38
39
+ /* This macro determines whether Mbed TLS uses its own legacy crypto library
40
+ * or an implementation of the PSA Crypto API such as Mbed Crypto.
41
+ *
42
+ * To confirm the use of PSA Crypto, you may enable debugging by setting
43
+ * HELLO_HTTPS_CLIENT_DEBUG_LEVEL in HelloHttpsClient.h and look for
44
+ * PSA-related debugging output on the serial line.
45
+ *
46
+ * Uncomment this to use the PSA Crypto API. */
47
+ //#define MBEDTLS_USE_PSA_CRYPTO
48
+
39
49
#define MBEDTLS_MPI_WINDOW_SIZE 1
You can’t perform that action at this time.
0 commit comments