File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-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
@@ -56,6 +59,25 @@ int main()
56
59
printf (" Platform initialization failed with error %d\r\n " , exit_code);
57
60
return MBEDTLS_EXIT_FAILURE;
58
61
}
62
+
63
+ #if defined(MBEDTLS_USE_PSA_CRYPTO)
64
+ /*
65
+ * Initialize underlying PSA Crypto implementation.
66
+ * Even if the HTTPS client doesn't make use of
67
+ * PSA-specific API, for example for setting opaque PSKs
68
+ * or opaque private keys, Mbed TLS will use PSA
69
+ * for public and symmetric key operations as well as
70
+ * hashing.
71
+ */
72
+ psa_status_t status;
73
+ status = psa_crypto_init ();
74
+ if ( status != PSA_SUCCESS )
75
+ {
76
+ printf (" psa_crypto_init() failed with %d\r\n " , status );
77
+ return MBEDTLS_EXIT_FAILURE;
78
+ }
79
+ #endif /* MBEDTLS_USE_PSA_CRYPTO */
80
+
59
81
/*
60
82
* The default 9600 bps is too slow to print full TLS debug info and could
61
83
* cause the other party to time out.
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