blob: 41b7752bea08bc3eed2f2a0535f43ddf32cf026e [file] [log] [blame]
Gilles Peskine952f4092019-05-23 20:25:48 +02001/*
Gilles Peskine3cff7682019-06-20 12:54:43 +02002 * Helper functions for tests that use the PSA Crypto API.
Gilles Peskine952f4092019-05-23 20:25:48 +02003 */
Bence Szépkúti86974652020-06-15 11:59:37 +02004/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02005 * Copyright The Mbed TLS Contributors
Dave Rodgman16799db2023-11-02 19:47:20 +00006 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Gilles Peskine952f4092019-05-23 20:25:48 +02007 */
8
Gilles Peskine1838e822019-06-20 12:40:56 +02009#ifndef PSA_CRYPTO_HELPERS_H
10#define PSA_CRYPTO_HELPERS_H
11
Ronald Cron28a45ed2021-02-09 20:35:42 +010012#include "test/helpers.h"
Gilles Peskine9de97e22021-02-02 21:00:11 +010013
14#if defined(MBEDTLS_PSA_CRYPTO_C)
Ronald Cron02c78b72020-05-27 09:22:32 +020015#include "test/psa_helpers.h"
Gilles Peskine3cff7682019-06-20 12:54:43 +020016#include <psa/crypto.h>
Manuel Pégourié-Gonnard9f132b72023-03-14 10:26:46 +010017#endif
Gilles Peskine952f4092019-05-23 20:25:48 +020018
David Horstmann2de5abf2023-12-20 11:26:40 +000019#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C) \
20 && defined(MBEDTLS_PSA_COPY_CALLER_BUFFERS)
David Horstmann7de09282023-12-14 14:27:50 +000021#include "test/psa_memory_poisoning_wrappers.h"
22#endif
Manuel Pégourié-Gonnardffcda562023-03-14 23:37:18 +010023
Manuel Pégourié-Gonnard9f132b72023-03-14 10:26:46 +010024#if defined(MBEDTLS_PSA_CRYPTO_C)
25/** Initialize the PSA Crypto subsystem. */
26#define PSA_INIT() PSA_ASSERT(psa_crypto_init())
27
28/** Shut down the PSA Crypto subsystem and destroy persistent keys.
29 * Expect a clean shutdown, with no slots in use.
30 *
31 * If some key slots are still in use, record the test case as failed,
32 * but continue executing. This macro is suitable (and primarily intended)
33 * for use in the cleanup section of test functions.
34 *
35 * \note Persistent keys must be recorded with #TEST_USES_KEY_ID before
36 * creating them.
37 */
38#define PSA_DONE() \
39 do \
40 { \
41 mbedtls_test_fail_if_psa_leaking(__LINE__, __FILE__); \
42 mbedtls_test_psa_purge_key_storage(); \
43 mbedtls_psa_crypto_free(); \
44 } \
45 while (0)
46#else /*MBEDTLS_PSA_CRYPTO_C */
47#define PSA_INIT() ((void) 0)
48#define PSA_DONE() ((void) 0)
49#endif /* MBEDTLS_PSA_CRYPTO_C */
50
51#if defined(MBEDTLS_PSA_CRYPTO_C)
52
Gilles Peskine313ffb82021-02-14 12:51:14 +010053#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
Gilles Peskinee09ef872021-02-14 13:10:38 +010054
55/* Internal function for #TEST_USES_KEY_ID. Return 1 on success, 0 on failure. */
Gilles Peskine449bd832023-01-11 14:50:10 +010056int mbedtls_test_uses_key_id(mbedtls_svc_key_id_t key_id);
Gilles Peskinee09ef872021-02-14 13:10:38 +010057
58/** Destroy persistent keys recorded with #TEST_USES_KEY_ID.
59 */
Gilles Peskine449bd832023-01-11 14:50:10 +010060void mbedtls_test_psa_purge_key_storage(void);
Gilles Peskinee09ef872021-02-14 13:10:38 +010061
Gilles Peskineaae718c2021-02-14 13:46:39 +010062/** Purge the in-memory cache of persistent keys recorded with
63 * #TEST_USES_KEY_ID.
Gilles Peskine65048ad2021-02-14 14:08:22 +010064 *
65 * Call this function before calling PSA_DONE() if it's ok for
66 * persistent keys to still exist at this point.
Gilles Peskineaae718c2021-02-14 13:46:39 +010067 */
Gilles Peskine449bd832023-01-11 14:50:10 +010068void mbedtls_test_psa_purge_key_cache(void);
Gilles Peskineaae718c2021-02-14 13:46:39 +010069
Gilles Peskinee09ef872021-02-14 13:10:38 +010070/** \def TEST_USES_KEY_ID
71 *
72 * Call this macro in a test function before potentially creating a
73 * persistent key. Test functions that use this mechanism must call
74 * mbedtls_test_psa_purge_key_storage() in their cleanup code.
75 *
76 * This macro records a persistent key identifier as potentially used in the
77 * current test case. Recorded key identifiers will be cleaned up at the end
78 * of the test case, even on failure.
79 *
80 * This macro has no effect on volatile keys. Therefore, it is safe to call
81 * this macro in a test function that creates either volatile or persistent
82 * keys depending on the test data.
83 *
84 * This macro currently has no effect on special identifiers
85 * used to store implementation-specific files.
86 *
87 * Calling this macro multiple times on the same key identifier in the same
88 * test case has no effect.
89 *
90 * This macro can fail the test case if there isn't enough memory to
91 * record the key id.
92 *
93 * \param key_id The PSA key identifier to record.
94 */
Gilles Peskine449bd832023-01-11 14:50:10 +010095#define TEST_USES_KEY_ID(key_id) \
96 TEST_ASSERT(mbedtls_test_uses_key_id(key_id))
Gilles Peskinee09ef872021-02-14 13:10:38 +010097
Gilles Peskine313ffb82021-02-14 12:51:14 +010098#else /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
Gilles Peskinee09ef872021-02-14 13:10:38 +010099
Gilles Peskine449bd832023-01-11 14:50:10 +0100100#define TEST_USES_KEY_ID(key_id) ((void) (key_id))
101#define mbedtls_test_psa_purge_key_storage() ((void) 0)
102#define mbedtls_test_psa_purge_key_cache() ((void) 0)
Gilles Peskinee09ef872021-02-14 13:10:38 +0100103
Gilles Peskine313ffb82021-02-14 12:51:14 +0100104#endif /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
105
Gilles Peskine1e005652020-11-24 17:41:07 +0100106/** Check for things that have not been cleaned up properly in the
107 * PSA subsystem.
108 *
109 * \return NULL if nothing has leaked.
110 * \return A string literal explaining what has not been cleaned up
111 * if applicable.
112 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100113const char *mbedtls_test_helper_is_psa_leaking(void);
Gilles Peskinedd413d32019-05-28 15:06:43 +0200114
Gilles Peskine3cff7682019-06-20 12:54:43 +0200115/** Check that no PSA Crypto key slots are in use.
Gilles Peskinec85c2012021-01-06 20:47:16 +0100116 *
117 * If any slots are in use, mark the current test as failed and jump to
118 * the exit label. This is equivalent to
119 * `TEST_ASSERT( ! mbedtls_test_helper_is_psa_leaking( ) )`
120 * but with a more informative message.
Gilles Peskinedd413d32019-05-28 15:06:43 +0200121 */
Yanray Wange64b4052022-10-28 18:12:01 +0800122#define ASSERT_PSA_PRISTINE() \
Gilles Peskinec85c2012021-01-06 20:47:16 +0100123 do \
124 { \
Yanray Wange64b4052022-10-28 18:12:01 +0800125 if (mbedtls_test_fail_if_psa_leaking(__LINE__, __FILE__)) \
126 goto exit; \
Gilles Peskinec85c2012021-01-06 20:47:16 +0100127 } \
Gilles Peskine449bd832023-01-11 14:50:10 +0100128 while (0)
Gilles Peskinea6d252a2019-05-23 20:34:30 +0200129
Gilles Peskine65048ad2021-02-14 14:08:22 +0100130/** Shut down the PSA Crypto subsystem, allowing persistent keys to survive.
131 * Expect a clean shutdown, with no slots in use.
132 *
133 * If some key slots are still in use, record the test case as failed and
134 * jump to the `exit` label.
135 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100136#define PSA_SESSION_DONE() \
Gilles Peskine65048ad2021-02-14 14:08:22 +0100137 do \
138 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100139 mbedtls_test_psa_purge_key_cache(); \
140 ASSERT_PSA_PRISTINE(); \
141 mbedtls_psa_crypto_free(); \
Gilles Peskinec85c2012021-01-06 20:47:16 +0100142 } \
Gilles Peskine449bd832023-01-11 14:50:10 +0100143 while (0)
Gilles Peskinea6d252a2019-05-23 20:34:30 +0200144
Gilles Peskine51681552019-05-20 19:35:37 +0200145
146
147#if defined(RECORD_PSA_STATUS_COVERAGE_LOG)
Gilles Peskine449bd832023-01-11 14:50:10 +0100148psa_status_t mbedtls_test_record_status(psa_status_t status,
149 const char *func,
150 const char *file, int line,
151 const char *expr);
Gilles Peskine51681552019-05-20 19:35:37 +0200152
153/** Return value logging wrapper macro.
154 *
155 * Evaluate \p expr. Write a line recording its value to the log file
156 * #STATUS_LOG_FILE_NAME and return the value. The line is a colon-separated
157 * list of fields:
158 * ```
159 * value of expr:string:__FILE__:__LINE__:expr
160 * ```
161 *
162 * The test code does not call this macro explicitly because that would
163 * be very invasive. Instead, we instrument the source code by defining
164 * a bunch of wrapper macros like
165 * ```
166 * #define psa_crypto_init() RECORD_STATUS("psa_crypto_init", psa_crypto_init())
167 * ```
168 * These macro definitions must be present in `instrument_record_status.h`
169 * when building the test suites.
170 *
171 * \param string A string, normally a function name.
172 * \param expr An expression to evaluate, normally a call of the function
173 * whose name is in \p string. This expression must return
174 * a value of type #psa_status_t.
175 * \return The value of \p expr.
176 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100177#define RECORD_STATUS(string, expr) \
178 mbedtls_test_record_status((expr), string, __FILE__, __LINE__, #expr)
Gilles Peskine51681552019-05-20 19:35:37 +0200179
180#include "instrument_record_status.h"
181
182#endif /* defined(RECORD_PSA_STATUS_COVERAGE_LOG) */
183
gabor-mezei-arm4ff73032021-05-13 12:05:01 +0200184/** Return extended key usage policies.
185 *
186 * Do a key policy permission extension on key usage policies always involves
187 * permissions of other usage policies
Tom Cosgrove1797b052022-12-04 17:19:59 +0000188 * (like PSA_KEY_USAGE_SIGN_HASH involves PSA_KEY_USAGE_SIGN_MESSAGE).
gabor-mezei-arm4ff73032021-05-13 12:05:01 +0200189 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100190psa_key_usage_t mbedtls_test_update_key_usage_flags(psa_key_usage_t usage_flags);
gabor-mezei-arm4ff73032021-05-13 12:05:01 +0200191
Yanray Wange64b4052022-10-28 18:12:01 +0800192/** Check that no PSA Crypto key slots are in use.
193 *
194 * If any slots are in use, mark the current test as failed.
195 *
196 * \return 0 if the key store is empty, 1 otherwise.
197 */
198int mbedtls_test_fail_if_psa_leaking(int line_no, const char *filename);
199
Gilles Peskinea08def92023-04-28 21:01:49 +0200200
201
202#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
203/* The #MBEDTLS_PSA_INJECT_ENTROPY feature requires two extra platform
204 * functions, which must be configured as #MBEDTLS_PLATFORM_NV_SEED_READ_MACRO
205 * and #MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO. The job of these functions
206 * is to read and write from the entropy seed file, which is located
207 * in the PSA ITS file whose uid is #PSA_CRYPTO_ITS_RANDOM_SEED_UID.
208 * (These could have been provided as library functions, but for historical
209 * reasons, they weren't, and so each integrator has to provide a copy
210 * of these functions.)
211 *
212 * Provide implementations of these functions for testing. */
213int mbedtls_test_inject_entropy_seed_read(unsigned char *buf, size_t len);
214int mbedtls_test_inject_entropy_seed_write(unsigned char *buf, size_t len);
Gilles Peskinec2d16b22023-04-28 23:39:45 +0200215
216
217/** Make sure that the injected entropy is present.
218 *
219 * When MBEDTLS_PSA_INJECT_ENTROPY is enabled, psa_crypto_init()
220 * will fail if the PSA entropy seed is not present.
221 * This function must be called at least once in a test suite or other
222 * program before any call to psa_crypto_init().
223 * It does not need to be called in each test case.
224 *
225 * The test framework calls this function before running any test case.
226 *
227 * The few tests that might remove the entropy file must call this function
228 * in their cleanup.
229 */
230int mbedtls_test_inject_entropy_restore(void);
Gilles Peskinea08def92023-04-28 21:01:49 +0200231#endif /* MBEDTLS_PSA_INJECT_ENTROPY */
232
Kusumit Ghoderaoac7a04a2023-08-18 13:47:47 +0530233/** Parse binary string and convert it to a long integer
234 */
Kusumit Ghoderao7c61ffc2023-09-05 19:29:47 +0530235uint64_t mbedtls_test_parse_binary_string(data_t *bin_string);
Gilles Peskinea08def92023-04-28 21:01:49 +0200236
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100237/** Skip a test case if the given key is a 192 bits AES key and the AES
238 * implementation is at least partially provided by an accelerator or
Ronald Cron28a45ed2021-02-09 20:35:42 +0100239 * alternative implementation.
240 *
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100241 * Call this macro in a test case when a cryptographic operation that may
242 * involve an AES operation returns a #PSA_ERROR_NOT_SUPPORTED error code.
243 * The macro call will skip and not fail the test case in case the operation
244 * involves a 192 bits AES key and the AES implementation is at least
245 * partially provided by an accelerator or alternative implementation.
246 *
247 * Hardware AES implementations not supporting 192 bits keys commonly exist.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100248 * Consequently, PSA test cases aim at not failing when an AES operation with
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100249 * a 192 bits key performed by an alternative AES implementation returns
250 * with the #PSA_ERROR_NOT_SUPPORTED error code. The purpose of this macro
251 * is to facilitate this and make the test case code more readable.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100252 *
253 * \param key_type Key type
254 * \param key_bits Key length in number of bits.
255 */
256#if defined(MBEDTLS_AES_ALT) || \
257 defined(MBEDTLS_AES_SETKEY_ENC_ALT) || \
258 defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_AES)
259#define MBEDTLS_TEST_HAVE_ALT_AES 1
260#else
261#define MBEDTLS_TEST_HAVE_ALT_AES 0
262#endif
263
Gilles Peskine449bd832023-01-11 14:50:10 +0100264#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192(key_type, key_bits) \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100265 do \
266 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100267 if ((MBEDTLS_TEST_HAVE_ALT_AES) && \
268 ((key_type) == PSA_KEY_TYPE_AES) && \
269 (key_bits == 192)) \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100270 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100271 mbedtls_test_skip("AES-192 not supported", __LINE__, __FILE__); \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100272 goto exit; \
273 } \
274 } \
Gilles Peskine449bd832023-01-11 14:50:10 +0100275 while (0)
Ronald Cron28a45ed2021-02-09 20:35:42 +0100276
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100277/** Skip a test case if a GCM operation with a nonce length different from
278 * 12 bytes fails and was performed by an accelerator or alternative
279 * implementation.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100280 *
281 * Call this macro in a test case when an AEAD cryptography operation that
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100282 * may involve the GCM mode returns with a #PSA_ERROR_NOT_SUPPORTED error
283 * code. The macro call will skip and not fail the test case in case the
284 * operation involves the GCM mode, a nonce with a length different from
285 * 12 bytes and the GCM mode implementation is an alternative one.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100286 *
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100287 * Hardware GCM implementations not supporting nonce lengths different from
288 * 12 bytes commonly exist, as supporting a non-12-byte nonce requires
289 * additional computations involving the GHASH function.
290 * Consequently, PSA test cases aim at not failing when an AEAD operation in
291 * GCM mode with a nonce length different from 12 bytes is performed by an
292 * alternative GCM implementation and returns with a #PSA_ERROR_NOT_SUPPORTED
293 * error code. The purpose of this macro is to facilitate this check and make
294 * the test case code more readable.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100295 *
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100296 * \param alg The AEAD algorithm.
297 * \param nonce_length The nonce length in number of bytes.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100298 */
Ronald Cron28a45ed2021-02-09 20:35:42 +0100299#if defined(MBEDTLS_GCM_ALT) || \
300 defined(MBEDTLS_PSA_ACCEL_ALG_GCM)
301#define MBEDTLS_TEST_HAVE_ALT_GCM 1
302#else
303#define MBEDTLS_TEST_HAVE_ALT_GCM 0
304#endif
305
Gilles Peskine449bd832023-01-11 14:50:10 +0100306#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE(alg, \
307 nonce_length) \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100308 do \
309 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100310 if ((MBEDTLS_TEST_HAVE_ALT_GCM) && \
311 (PSA_ALG_AEAD_WITH_SHORTENED_TAG((alg), 0) == \
312 PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM, 0)) && \
313 ((nonce_length) != 12)) \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100314 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100315 mbedtls_test_skip("GCM with non-12-byte IV is not supported", __LINE__, __FILE__); \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100316 goto exit; \
317 } \
318 } \
Gilles Peskine449bd832023-01-11 14:50:10 +0100319 while (0)
Ronald Cron28a45ed2021-02-09 20:35:42 +0100320
Gilles Peskine9de97e22021-02-02 21:00:11 +0100321#endif /* MBEDTLS_PSA_CRYPTO_C */
322
323/** \def USE_PSA_INIT
324 *
325 * Call this macro to initialize the PSA subsystem if #MBEDTLS_USE_PSA_CRYPTO
Ronald Cron3cec8e82022-03-27 14:34:09 +0200326 * or #MBEDTLS_SSL_PROTO_TLS1_3 (In contrast to TLS 1.2 implementation, the
327 * TLS 1.3 one uses PSA independently of the definition of
Manuel Pégourié-Gonnardfa99afa2023-03-17 11:59:12 +0100328 * #MBEDTLS_USE_PSA_CRYPTO) is enabled and do nothing otherwise.
329 *
330 * If the initialization fails, mark the test case as failed and jump to the
331 * \p exit label.
Gilles Peskine9de97e22021-02-02 21:00:11 +0100332 */
333/** \def USE_PSA_DONE
334 *
335 * Call this macro at the end of a test case if you called #USE_PSA_INIT.
Manuel Pégourié-Gonnardfa99afa2023-03-17 11:59:12 +0100336 *
337 * This is like #PSA_DONE except it does nothing under the same conditions as
338 * #USE_PSA_INIT.
Gilles Peskine9de97e22021-02-02 21:00:11 +0100339 */
Ronald Cron3cec8e82022-03-27 14:34:09 +0200340#if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_SSL_PROTO_TLS1_3)
Gilles Peskine449bd832023-01-11 14:50:10 +0100341#define USE_PSA_INIT() PSA_INIT()
342#define USE_PSA_DONE() PSA_DONE()
Ronald Cron3cec8e82022-03-27 14:34:09 +0200343#else /* MBEDTLS_USE_PSA_CRYPTO || MBEDTLS_SSL_PROTO_TLS1_3 */
Gilles Peskine9de97e22021-02-02 21:00:11 +0100344/* Define empty macros so that we can use them in the preamble and teardown
345 * of every test function that uses PSA conditionally based on
346 * MBEDTLS_USE_PSA_CRYPTO. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100347#define USE_PSA_INIT() ((void) 0)
348#define USE_PSA_DONE() ((void) 0)
Ronald Cron3cec8e82022-03-27 14:34:09 +0200349#endif /* !MBEDTLS_USE_PSA_CRYPTO && !MBEDTLS_SSL_PROTO_TLS1_3 */
Gilles Peskine9de97e22021-02-02 21:00:11 +0100350
Manuel Pégourié-Gonnardfa99afa2023-03-17 11:59:12 +0100351/** \def MD_PSA_INIT
352 *
353 * Call this macro to initialize the PSA subsystem if MD uses a driver,
354 * and do nothing otherwise.
355 *
356 * If the initialization fails, mark the test case as failed and jump to the
357 * \p exit label.
358 */
359/** \def MD_PSA_DONE
360 *
361 * Call this macro at the end of a test case if you called #MD_PSA_INIT.
362 *
363 * This is like #PSA_DONE except it does nothing under the same conditions as
364 * #MD_PSA_INIT.
365 */
366#if defined(MBEDTLS_MD_SOME_PSA)
367#define MD_PSA_INIT() PSA_INIT()
368#define MD_PSA_DONE() PSA_DONE()
369#else /* MBEDTLS_MD_SOME_PSA */
370#define MD_PSA_INIT() ((void) 0)
371#define MD_PSA_DONE() ((void) 0)
372#endif /* MBEDTLS_MD_SOME_PSA */
373
374/** \def MD_OR_USE_PSA_INIT
375 *
376 * Call this macro to initialize the PSA subsystem if MD uses a driver,
Manuel Pégourié-Gonnard161dca62023-03-21 16:22:59 +0100377 * or if #MBEDTLS_USE_PSA_CRYPTO or #MBEDTLS_SSL_PROTO_TLS1_3 is enabled,
Manuel Pégourié-Gonnardfa99afa2023-03-17 11:59:12 +0100378 * and do nothing otherwise.
379 *
380 * If the initialization fails, mark the test case as failed and jump to the
381 * \p exit label.
382 */
383/** \def MD_OR_USE_PSA_DONE
384 *
385 * Call this macro at the end of a test case if you called #MD_OR_USE_PSA_INIT.
386 *
387 * This is like #PSA_DONE except it does nothing under the same conditions as
388 * #MD_OR_USE_PSA_INIT.
389 */
390#if defined(MBEDTLS_MD_SOME_PSA) || \
391 defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_SSL_PROTO_TLS1_3)
392#define MD_OR_USE_PSA_INIT() PSA_INIT()
393#define MD_OR_USE_PSA_DONE() PSA_DONE()
394#else
395#define MD_OR_USE_PSA_INIT() ((void) 0)
396#define MD_OR_USE_PSA_DONE() ((void) 0)
397#endif
398
Gilles Peskine1838e822019-06-20 12:40:56 +0200399#endif /* PSA_CRYPTO_HELPERS_H */