blob: 959308af9c86e5494b064fa9e2b2d0c4b76b605c [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
Gilles Peskine952f4092019-05-23 20:25:48 +02006 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
Gilles Peskine952f4092019-05-23 20:25:48 +020019 */
20
Gilles Peskine1838e822019-06-20 12:40:56 +020021#ifndef PSA_CRYPTO_HELPERS_H
22#define PSA_CRYPTO_HELPERS_H
23
Ronald Cron28a45ed2021-02-09 20:35:42 +010024#include "test/helpers.h"
Gilles Peskine9de97e22021-02-02 21:00:11 +010025
26#if defined(MBEDTLS_PSA_CRYPTO_C)
Ronald Cron02c78b72020-05-27 09:22:32 +020027#include "test/psa_helpers.h"
Gilles Peskine3cff7682019-06-20 12:54:43 +020028#include <psa/crypto.h>
Manuel Pégourié-Gonnard9f132b72023-03-14 10:26:46 +010029#endif
Gilles Peskine952f4092019-05-23 20:25:48 +020030
Manuel Pégourié-Gonnardffcda562023-03-14 23:37:18 +010031
Manuel Pégourié-Gonnard9f132b72023-03-14 10:26:46 +010032#if defined(MBEDTLS_PSA_CRYPTO_C)
33/** Initialize the PSA Crypto subsystem. */
34#define PSA_INIT() PSA_ASSERT(psa_crypto_init())
35
36/** Shut down the PSA Crypto subsystem and destroy persistent keys.
37 * Expect a clean shutdown, with no slots in use.
38 *
39 * If some key slots are still in use, record the test case as failed,
40 * but continue executing. This macro is suitable (and primarily intended)
41 * for use in the cleanup section of test functions.
42 *
43 * \note Persistent keys must be recorded with #TEST_USES_KEY_ID before
44 * creating them.
45 */
46#define PSA_DONE() \
47 do \
48 { \
49 mbedtls_test_fail_if_psa_leaking(__LINE__, __FILE__); \
50 mbedtls_test_psa_purge_key_storage(); \
51 mbedtls_psa_crypto_free(); \
52 } \
53 while (0)
54#else /*MBEDTLS_PSA_CRYPTO_C */
55#define PSA_INIT() ((void) 0)
56#define PSA_DONE() ((void) 0)
57#endif /* MBEDTLS_PSA_CRYPTO_C */
58
59#if defined(MBEDTLS_PSA_CRYPTO_C)
60
Gilles Peskine313ffb82021-02-14 12:51:14 +010061#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
Gilles Peskinee09ef872021-02-14 13:10:38 +010062
63/* Internal function for #TEST_USES_KEY_ID. Return 1 on success, 0 on failure. */
Gilles Peskine449bd832023-01-11 14:50:10 +010064int mbedtls_test_uses_key_id(mbedtls_svc_key_id_t key_id);
Gilles Peskinee09ef872021-02-14 13:10:38 +010065
66/** Destroy persistent keys recorded with #TEST_USES_KEY_ID.
67 */
Gilles Peskine449bd832023-01-11 14:50:10 +010068void mbedtls_test_psa_purge_key_storage(void);
Gilles Peskinee09ef872021-02-14 13:10:38 +010069
Gilles Peskineaae718c2021-02-14 13:46:39 +010070/** Purge the in-memory cache of persistent keys recorded with
71 * #TEST_USES_KEY_ID.
Gilles Peskine65048ad2021-02-14 14:08:22 +010072 *
73 * Call this function before calling PSA_DONE() if it's ok for
74 * persistent keys to still exist at this point.
Gilles Peskineaae718c2021-02-14 13:46:39 +010075 */
Gilles Peskine449bd832023-01-11 14:50:10 +010076void mbedtls_test_psa_purge_key_cache(void);
Gilles Peskineaae718c2021-02-14 13:46:39 +010077
Gilles Peskinee09ef872021-02-14 13:10:38 +010078/** \def TEST_USES_KEY_ID
79 *
80 * Call this macro in a test function before potentially creating a
81 * persistent key. Test functions that use this mechanism must call
82 * mbedtls_test_psa_purge_key_storage() in their cleanup code.
83 *
84 * This macro records a persistent key identifier as potentially used in the
85 * current test case. Recorded key identifiers will be cleaned up at the end
86 * of the test case, even on failure.
87 *
88 * This macro has no effect on volatile keys. Therefore, it is safe to call
89 * this macro in a test function that creates either volatile or persistent
90 * keys depending on the test data.
91 *
92 * This macro currently has no effect on special identifiers
93 * used to store implementation-specific files.
94 *
95 * Calling this macro multiple times on the same key identifier in the same
96 * test case has no effect.
97 *
98 * This macro can fail the test case if there isn't enough memory to
99 * record the key id.
100 *
101 * \param key_id The PSA key identifier to record.
102 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100103#define TEST_USES_KEY_ID(key_id) \
104 TEST_ASSERT(mbedtls_test_uses_key_id(key_id))
Gilles Peskinee09ef872021-02-14 13:10:38 +0100105
Gilles Peskine313ffb82021-02-14 12:51:14 +0100106#else /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
Gilles Peskinee09ef872021-02-14 13:10:38 +0100107
Gilles Peskine449bd832023-01-11 14:50:10 +0100108#define TEST_USES_KEY_ID(key_id) ((void) (key_id))
109#define mbedtls_test_psa_purge_key_storage() ((void) 0)
110#define mbedtls_test_psa_purge_key_cache() ((void) 0)
Gilles Peskinee09ef872021-02-14 13:10:38 +0100111
Gilles Peskine313ffb82021-02-14 12:51:14 +0100112#endif /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
113
Gilles Peskine1e005652020-11-24 17:41:07 +0100114/** Check for things that have not been cleaned up properly in the
115 * PSA subsystem.
116 *
117 * \return NULL if nothing has leaked.
118 * \return A string literal explaining what has not been cleaned up
119 * if applicable.
120 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100121const char *mbedtls_test_helper_is_psa_leaking(void);
Gilles Peskinedd413d32019-05-28 15:06:43 +0200122
Gilles Peskine3cff7682019-06-20 12:54:43 +0200123/** Check that no PSA Crypto key slots are in use.
Gilles Peskinec85c2012021-01-06 20:47:16 +0100124 *
125 * If any slots are in use, mark the current test as failed and jump to
126 * the exit label. This is equivalent to
127 * `TEST_ASSERT( ! mbedtls_test_helper_is_psa_leaking( ) )`
128 * but with a more informative message.
Gilles Peskinedd413d32019-05-28 15:06:43 +0200129 */
Yanray Wange64b4052022-10-28 18:12:01 +0800130#define ASSERT_PSA_PRISTINE() \
Gilles Peskinec85c2012021-01-06 20:47:16 +0100131 do \
132 { \
Yanray Wange64b4052022-10-28 18:12:01 +0800133 if (mbedtls_test_fail_if_psa_leaking(__LINE__, __FILE__)) \
134 goto exit; \
Gilles Peskinec85c2012021-01-06 20:47:16 +0100135 } \
Gilles Peskine449bd832023-01-11 14:50:10 +0100136 while (0)
Gilles Peskinea6d252a2019-05-23 20:34:30 +0200137
Gilles Peskine65048ad2021-02-14 14:08:22 +0100138/** Shut down the PSA Crypto subsystem, allowing persistent keys to survive.
139 * Expect a clean shutdown, with no slots in use.
140 *
141 * If some key slots are still in use, record the test case as failed and
142 * jump to the `exit` label.
143 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100144#define PSA_SESSION_DONE() \
Gilles Peskine65048ad2021-02-14 14:08:22 +0100145 do \
146 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100147 mbedtls_test_psa_purge_key_cache(); \
148 ASSERT_PSA_PRISTINE(); \
149 mbedtls_psa_crypto_free(); \
Gilles Peskinec85c2012021-01-06 20:47:16 +0100150 } \
Gilles Peskine449bd832023-01-11 14:50:10 +0100151 while (0)
Gilles Peskinea6d252a2019-05-23 20:34:30 +0200152
Gilles Peskine51681552019-05-20 19:35:37 +0200153
154
155#if defined(RECORD_PSA_STATUS_COVERAGE_LOG)
Gilles Peskine449bd832023-01-11 14:50:10 +0100156psa_status_t mbedtls_test_record_status(psa_status_t status,
157 const char *func,
158 const char *file, int line,
159 const char *expr);
Gilles Peskine51681552019-05-20 19:35:37 +0200160
161/** Return value logging wrapper macro.
162 *
163 * Evaluate \p expr. Write a line recording its value to the log file
164 * #STATUS_LOG_FILE_NAME and return the value. The line is a colon-separated
165 * list of fields:
166 * ```
167 * value of expr:string:__FILE__:__LINE__:expr
168 * ```
169 *
170 * The test code does not call this macro explicitly because that would
171 * be very invasive. Instead, we instrument the source code by defining
172 * a bunch of wrapper macros like
173 * ```
174 * #define psa_crypto_init() RECORD_STATUS("psa_crypto_init", psa_crypto_init())
175 * ```
176 * These macro definitions must be present in `instrument_record_status.h`
177 * when building the test suites.
178 *
179 * \param string A string, normally a function name.
180 * \param expr An expression to evaluate, normally a call of the function
181 * whose name is in \p string. This expression must return
182 * a value of type #psa_status_t.
183 * \return The value of \p expr.
184 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100185#define RECORD_STATUS(string, expr) \
186 mbedtls_test_record_status((expr), string, __FILE__, __LINE__, #expr)
Gilles Peskine51681552019-05-20 19:35:37 +0200187
188#include "instrument_record_status.h"
189
190#endif /* defined(RECORD_PSA_STATUS_COVERAGE_LOG) */
191
gabor-mezei-arm4ff73032021-05-13 12:05:01 +0200192/** Return extended key usage policies.
193 *
194 * Do a key policy permission extension on key usage policies always involves
195 * permissions of other usage policies
Tom Cosgrove1797b052022-12-04 17:19:59 +0000196 * (like PSA_KEY_USAGE_SIGN_HASH involves PSA_KEY_USAGE_SIGN_MESSAGE).
gabor-mezei-arm4ff73032021-05-13 12:05:01 +0200197 */
Gilles Peskine449bd832023-01-11 14:50:10 +0100198psa_key_usage_t mbedtls_test_update_key_usage_flags(psa_key_usage_t usage_flags);
gabor-mezei-arm4ff73032021-05-13 12:05:01 +0200199
Yanray Wange64b4052022-10-28 18:12:01 +0800200/** Check that no PSA Crypto key slots are in use.
201 *
202 * If any slots are in use, mark the current test as failed.
203 *
204 * \return 0 if the key store is empty, 1 otherwise.
205 */
206int mbedtls_test_fail_if_psa_leaking(int line_no, const char *filename);
207
Gilles Peskinea08def92023-04-28 21:01:49 +0200208
209
210#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
211/* The #MBEDTLS_PSA_INJECT_ENTROPY feature requires two extra platform
212 * functions, which must be configured as #MBEDTLS_PLATFORM_NV_SEED_READ_MACRO
213 * and #MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO. The job of these functions
214 * is to read and write from the entropy seed file, which is located
215 * in the PSA ITS file whose uid is #PSA_CRYPTO_ITS_RANDOM_SEED_UID.
216 * (These could have been provided as library functions, but for historical
217 * reasons, they weren't, and so each integrator has to provide a copy
218 * of these functions.)
219 *
220 * Provide implementations of these functions for testing. */
221int mbedtls_test_inject_entropy_seed_read(unsigned char *buf, size_t len);
222int mbedtls_test_inject_entropy_seed_write(unsigned char *buf, size_t len);
Gilles Peskinec2d16b22023-04-28 23:39:45 +0200223
224
225/** Make sure that the injected entropy is present.
226 *
227 * When MBEDTLS_PSA_INJECT_ENTROPY is enabled, psa_crypto_init()
228 * will fail if the PSA entropy seed is not present.
229 * This function must be called at least once in a test suite or other
230 * program before any call to psa_crypto_init().
231 * It does not need to be called in each test case.
232 *
233 * The test framework calls this function before running any test case.
234 *
235 * The few tests that might remove the entropy file must call this function
236 * in their cleanup.
237 */
238int mbedtls_test_inject_entropy_restore(void);
Gilles Peskinea08def92023-04-28 21:01:49 +0200239#endif /* MBEDTLS_PSA_INJECT_ENTROPY */
240
Kusumit Ghoderaoac7a04a2023-08-18 13:47:47 +0530241/** Parse binary string and convert it to a long integer
242 */
Kusumit Ghoderao7c61ffc2023-09-05 19:29:47 +0530243uint64_t mbedtls_test_parse_binary_string(data_t *bin_string);
Gilles Peskinea08def92023-04-28 21:01:49 +0200244
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100245/** Skip a test case if the given key is a 192 bits AES key and the AES
246 * implementation is at least partially provided by an accelerator or
Ronald Cron28a45ed2021-02-09 20:35:42 +0100247 * alternative implementation.
248 *
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100249 * Call this macro in a test case when a cryptographic operation that may
250 * involve an AES operation returns a #PSA_ERROR_NOT_SUPPORTED error code.
251 * The macro call will skip and not fail the test case in case the operation
252 * involves a 192 bits AES key and the AES implementation is at least
253 * partially provided by an accelerator or alternative implementation.
254 *
255 * Hardware AES implementations not supporting 192 bits keys commonly exist.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100256 * Consequently, PSA test cases aim at not failing when an AES operation with
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100257 * a 192 bits key performed by an alternative AES implementation returns
258 * with the #PSA_ERROR_NOT_SUPPORTED error code. The purpose of this macro
259 * is to facilitate this and make the test case code more readable.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100260 *
261 * \param key_type Key type
262 * \param key_bits Key length in number of bits.
263 */
264#if defined(MBEDTLS_AES_ALT) || \
265 defined(MBEDTLS_AES_SETKEY_ENC_ALT) || \
266 defined(MBEDTLS_PSA_ACCEL_KEY_TYPE_AES)
267#define MBEDTLS_TEST_HAVE_ALT_AES 1
268#else
269#define MBEDTLS_TEST_HAVE_ALT_AES 0
270#endif
271
Gilles Peskine449bd832023-01-11 14:50:10 +0100272#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_AES_192(key_type, key_bits) \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100273 do \
274 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100275 if ((MBEDTLS_TEST_HAVE_ALT_AES) && \
276 ((key_type) == PSA_KEY_TYPE_AES) && \
277 (key_bits == 192)) \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100278 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100279 mbedtls_test_skip("AES-192 not supported", __LINE__, __FILE__); \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100280 goto exit; \
281 } \
282 } \
Gilles Peskine449bd832023-01-11 14:50:10 +0100283 while (0)
Ronald Cron28a45ed2021-02-09 20:35:42 +0100284
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100285/** Skip a test case if a GCM operation with a nonce length different from
286 * 12 bytes fails and was performed by an accelerator or alternative
287 * implementation.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100288 *
289 * Call this macro in a test case when an AEAD cryptography operation that
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100290 * may involve the GCM mode returns with a #PSA_ERROR_NOT_SUPPORTED error
291 * code. The macro call will skip and not fail the test case in case the
292 * operation involves the GCM mode, a nonce with a length different from
293 * 12 bytes and the GCM mode implementation is an alternative one.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100294 *
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100295 * Hardware GCM implementations not supporting nonce lengths different from
296 * 12 bytes commonly exist, as supporting a non-12-byte nonce requires
297 * additional computations involving the GHASH function.
298 * Consequently, PSA test cases aim at not failing when an AEAD operation in
299 * GCM mode with a nonce length different from 12 bytes is performed by an
300 * alternative GCM implementation and returns with a #PSA_ERROR_NOT_SUPPORTED
301 * error code. The purpose of this macro is to facilitate this check and make
302 * the test case code more readable.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100303 *
Steven Cooreman1e9c0422021-02-10 17:02:05 +0100304 * \param alg The AEAD algorithm.
305 * \param nonce_length The nonce length in number of bytes.
Ronald Cron28a45ed2021-02-09 20:35:42 +0100306 */
Ronald Cron28a45ed2021-02-09 20:35:42 +0100307#if defined(MBEDTLS_GCM_ALT) || \
308 defined(MBEDTLS_PSA_ACCEL_ALG_GCM)
309#define MBEDTLS_TEST_HAVE_ALT_GCM 1
310#else
311#define MBEDTLS_TEST_HAVE_ALT_GCM 0
312#endif
313
Gilles Peskine449bd832023-01-11 14:50:10 +0100314#define MBEDTLS_TEST_PSA_SKIP_IF_ALT_GCM_NOT_12BYTES_NONCE(alg, \
315 nonce_length) \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100316 do \
317 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100318 if ((MBEDTLS_TEST_HAVE_ALT_GCM) && \
319 (PSA_ALG_AEAD_WITH_SHORTENED_TAG((alg), 0) == \
320 PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_GCM, 0)) && \
321 ((nonce_length) != 12)) \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100322 { \
Gilles Peskine449bd832023-01-11 14:50:10 +0100323 mbedtls_test_skip("GCM with non-12-byte IV is not supported", __LINE__, __FILE__); \
Ronald Cron28a45ed2021-02-09 20:35:42 +0100324 goto exit; \
325 } \
326 } \
Gilles Peskine449bd832023-01-11 14:50:10 +0100327 while (0)
Ronald Cron28a45ed2021-02-09 20:35:42 +0100328
Gilles Peskine9de97e22021-02-02 21:00:11 +0100329#endif /* MBEDTLS_PSA_CRYPTO_C */
330
331/** \def USE_PSA_INIT
332 *
333 * Call this macro to initialize the PSA subsystem if #MBEDTLS_USE_PSA_CRYPTO
Ronald Cron3cec8e82022-03-27 14:34:09 +0200334 * or #MBEDTLS_SSL_PROTO_TLS1_3 (In contrast to TLS 1.2 implementation, the
335 * TLS 1.3 one uses PSA independently of the definition of
Manuel Pégourié-Gonnardfa99afa2023-03-17 11:59:12 +0100336 * #MBEDTLS_USE_PSA_CRYPTO) is enabled and do nothing otherwise.
337 *
338 * If the initialization fails, mark the test case as failed and jump to the
339 * \p exit label.
Gilles Peskine9de97e22021-02-02 21:00:11 +0100340 */
341/** \def USE_PSA_DONE
342 *
343 * 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 +0100344 *
345 * This is like #PSA_DONE except it does nothing under the same conditions as
346 * #USE_PSA_INIT.
Gilles Peskine9de97e22021-02-02 21:00:11 +0100347 */
Ronald Cron3cec8e82022-03-27 14:34:09 +0200348#if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_SSL_PROTO_TLS1_3)
Gilles Peskine449bd832023-01-11 14:50:10 +0100349#define USE_PSA_INIT() PSA_INIT()
350#define USE_PSA_DONE() PSA_DONE()
Ronald Cron3cec8e82022-03-27 14:34:09 +0200351#else /* MBEDTLS_USE_PSA_CRYPTO || MBEDTLS_SSL_PROTO_TLS1_3 */
Gilles Peskine9de97e22021-02-02 21:00:11 +0100352/* Define empty macros so that we can use them in the preamble and teardown
353 * of every test function that uses PSA conditionally based on
354 * MBEDTLS_USE_PSA_CRYPTO. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100355#define USE_PSA_INIT() ((void) 0)
356#define USE_PSA_DONE() ((void) 0)
Ronald Cron3cec8e82022-03-27 14:34:09 +0200357#endif /* !MBEDTLS_USE_PSA_CRYPTO && !MBEDTLS_SSL_PROTO_TLS1_3 */
Gilles Peskine9de97e22021-02-02 21:00:11 +0100358
Manuel Pégourié-Gonnardfa99afa2023-03-17 11:59:12 +0100359/** \def MD_PSA_INIT
360 *
361 * Call this macro to initialize the PSA subsystem if MD uses a driver,
362 * and do nothing otherwise.
363 *
364 * If the initialization fails, mark the test case as failed and jump to the
365 * \p exit label.
366 */
367/** \def MD_PSA_DONE
368 *
369 * Call this macro at the end of a test case if you called #MD_PSA_INIT.
370 *
371 * This is like #PSA_DONE except it does nothing under the same conditions as
372 * #MD_PSA_INIT.
373 */
374#if defined(MBEDTLS_MD_SOME_PSA)
375#define MD_PSA_INIT() PSA_INIT()
376#define MD_PSA_DONE() PSA_DONE()
377#else /* MBEDTLS_MD_SOME_PSA */
378#define MD_PSA_INIT() ((void) 0)
379#define MD_PSA_DONE() ((void) 0)
380#endif /* MBEDTLS_MD_SOME_PSA */
381
382/** \def MD_OR_USE_PSA_INIT
383 *
384 * Call this macro to initialize the PSA subsystem if MD uses a driver,
Manuel Pégourié-Gonnard161dca62023-03-21 16:22:59 +0100385 * or if #MBEDTLS_USE_PSA_CRYPTO or #MBEDTLS_SSL_PROTO_TLS1_3 is enabled,
Manuel Pégourié-Gonnardfa99afa2023-03-17 11:59:12 +0100386 * and do nothing otherwise.
387 *
388 * If the initialization fails, mark the test case as failed and jump to the
389 * \p exit label.
390 */
391/** \def MD_OR_USE_PSA_DONE
392 *
393 * Call this macro at the end of a test case if you called #MD_OR_USE_PSA_INIT.
394 *
395 * This is like #PSA_DONE except it does nothing under the same conditions as
396 * #MD_OR_USE_PSA_INIT.
397 */
398#if defined(MBEDTLS_MD_SOME_PSA) || \
399 defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_SSL_PROTO_TLS1_3)
400#define MD_OR_USE_PSA_INIT() PSA_INIT()
401#define MD_OR_USE_PSA_DONE() PSA_DONE()
402#else
403#define MD_OR_USE_PSA_INIT() ((void) 0)
404#define MD_OR_USE_PSA_DONE() ((void) 0)
405#endif
406
Gilles Peskine1838e822019-06-20 12:40:56 +0200407#endif /* PSA_CRYPTO_HELPERS_H */