blob: 0910798e1c98171f50cfc52656255c2c2cc60b85 [file] [log] [blame]
Gilles Peskine33406b62023-11-02 18:48:39 +01001/** \file metatest.c
2 *
3 * \brief Test features of the test framework.
Gilles Peskinecce00122023-11-10 15:36:15 +01004 *
5 * When you run this program, it runs a single "meta-test". A meta-test
6 * performs an operation which should be caught as a failure by our
7 * test framework. The meta-test passes if this program calls `exit` with
8 * a nonzero status, or aborts, or is terminated by a signal, or if the
9 * framework running the program considers the run an error (this happens
10 * with Valgrind for a memory leak). The non-success of the meta-test
11 * program means that the test failure has been caught correctly.
12 *
13 * Some failures are purely functional: the logic of the code causes the
14 * test result to be set to FAIL. Other failures come from extra
15 * instrumentation which is not present in a normal build; for example,
16 * Asan or Valgrind to detect memory leaks. This is reflected by the
17 * "platform" associated with each meta-test.
18 *
19 * Use the companion script `tests/scripts/run-metatests.sh` to run all
20 * the meta-tests for a given platform and validate that they trigger a
21 * detected failure as expected.
Gilles Peskine33406b62023-11-02 18:48:39 +010022 */
23
24/*
25 * Copyright The Mbed TLS Contributors
26 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
27 */
28
29#define MBEDTLS_ALLOW_PRIVATE_ACCESS
30
Gilles Peskinee0acf872023-11-03 19:41:44 +010031#include <mbedtls/debug.h>
Gilles Peskine33406b62023-11-02 18:48:39 +010032#include <mbedtls/platform.h>
Gilles Peskine69e8db02023-11-02 19:52:32 +010033#include <mbedtls/platform_util.h>
Gilles Peskine33406b62023-11-02 18:48:39 +010034#include "test/helpers.h"
Gilles Peskine102aea22023-11-03 18:05:38 +010035#include "test/macros.h"
Gilles Peskined29cce92023-11-02 20:49:34 +010036#include "test/memory.h"
Gilles Peskine33406b62023-11-02 18:48:39 +010037
38#include <stdio.h>
39#include <string.h>
40
Gilles Peskine102aea22023-11-03 18:05:38 +010041#if defined(MBEDTLS_THREADING_C)
42#include <mbedtls/threading.h>
43#endif
44
Gilles Peskinef5dd0022023-11-03 17:01:32 +010045/* C99 feature missing from older versions of MSVC */
46#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
47#define /*no-check-names*/ __func__ __FUNCTION__
48#endif
49
Gilles Peskine33406b62023-11-02 18:48:39 +010050
Gilles Peskine69e8db02023-11-02 19:52:32 +010051/* This is an external variable, so the compiler doesn't know that we're never
52 * changing its value.
Gilles Peskine69e8db02023-11-02 19:52:32 +010053 */
Gilles Peskined2fa6982023-11-09 21:46:24 +010054volatile int false_but_the_compiler_does_not_know = 0;
55
Gilles Peskine7a715c42023-11-21 13:42:40 +010056/* Hide calls to calloc/free from static checkers such as
57 * `gcc-12 -Wuse-after-free`, to avoid compile-time complaints about
58 * code where we do mean to cause a runtime error. */
59void * (* volatile calloc_but_the_compiler_does_not_know)(size_t, size_t) = mbedtls_calloc;
60void(*volatile free_but_the_compiler_does_not_know)(void *) = mbedtls_free;
61
Gilles Peskined2fa6982023-11-09 21:46:24 +010062/* Set n bytes at the address p to all-bits-zero, in such a way that
63 * the compiler should not know that p is all-bits-zero. */
Gilles Peskineda6e7a22023-11-10 10:09:27 +010064static void set_to_zero_but_the_compiler_does_not_know(volatile void *p, size_t n)
Gilles Peskined2fa6982023-11-09 21:46:24 +010065{
Gilles Peskineda6e7a22023-11-10 10:09:27 +010066 memset((void *) p, false_but_the_compiler_does_not_know, n);
Gilles Peskined2fa6982023-11-09 21:46:24 +010067}
Gilles Peskine69e8db02023-11-02 19:52:32 +010068
69
Gilles Peskine33406b62023-11-02 18:48:39 +010070/****************************************************************/
Gilles Peskinef309fbf2023-11-02 18:49:52 +010071/* Test framework features */
72/****************************************************************/
73
74void meta_test_fail(const char *name)
75{
76 (void) name;
77 mbedtls_test_fail("Forced test failure", __LINE__, __FILE__);
78}
79
80
81/****************************************************************/
Gilles Peskine80ba8322023-11-02 19:23:26 +010082/* Platform features */
83/****************************************************************/
84
85void null_pointer_dereference(const char *name)
86{
87 (void) name;
Gilles Peskineda6e7a22023-11-10 10:09:27 +010088 volatile char *volatile p;
Gilles Peskined2fa6982023-11-09 21:46:24 +010089 set_to_zero_but_the_compiler_does_not_know(&p, sizeof(p));
Gilles Peskine2f40cc02023-11-16 15:11:44 +010090 /* Undefined behavior (read from null data pointer) */
Gilles Peskine69e8db02023-11-02 19:52:32 +010091 mbedtls_printf("%p -> %u\n", p, (unsigned) *p);
Gilles Peskine80ba8322023-11-02 19:23:26 +010092}
93
94void null_pointer_call(const char *name)
95{
96 (void) name;
Gilles Peskineda6e7a22023-11-10 10:09:27 +010097 unsigned(*volatile p)(void);
Gilles Peskined2fa6982023-11-09 21:46:24 +010098 set_to_zero_but_the_compiler_does_not_know(&p, sizeof(p));
Gilles Peskine2f40cc02023-11-16 15:11:44 +010099 /* Undefined behavior (execute null function pointer) */
Gilles Peskinef0d5cf92023-11-03 10:58:57 +0100100 /* The pointer representation may be truncated, but we don't care:
101 * the only point of printing it is to have some use of the pointer
102 * to dissuade the compiler from optimizing it away. */
103 mbedtls_printf("%lx() -> %u\n", (unsigned long) (uintptr_t) p, p());
Gilles Peskine80ba8322023-11-02 19:23:26 +0100104}
105
106
107/****************************************************************/
Gilles Peskine102aea22023-11-03 18:05:38 +0100108/* Memory */
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100109/****************************************************************/
110
111void read_after_free(const char *name)
112{
113 (void) name;
Gilles Peskine7a715c42023-11-21 13:42:40 +0100114 volatile char *p = calloc_but_the_compiler_does_not_know(1, 1);
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100115 *p = 'a';
Gilles Peskine7a715c42023-11-21 13:42:40 +0100116 free_but_the_compiler_does_not_know((void *) p);
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100117 /* Undefined behavior (read after free) */
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100118 mbedtls_printf("%u\n", (unsigned) *p);
119}
120
121void double_free(const char *name)
122{
123 (void) name;
Gilles Peskine7a715c42023-11-21 13:42:40 +0100124 volatile char *p = calloc_but_the_compiler_does_not_know(1, 1);
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100125 *p = 'a';
Gilles Peskine7a715c42023-11-21 13:42:40 +0100126 free_but_the_compiler_does_not_know((void *) p);
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100127 /* Undefined behavior (double free) */
Gilles Peskine7a715c42023-11-21 13:42:40 +0100128 free_but_the_compiler_does_not_know((void *) p);
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100129}
130
131void read_uninitialized_stack(const char *name)
132{
133 (void) name;
Gilles Peskineccb12152023-11-10 11:35:36 +0100134 char buf[1];
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100135 if (false_but_the_compiler_does_not_know) {
136 buf[0] = '!';
137 }
Gilles Peskineccb12152023-11-10 11:35:36 +0100138 char *volatile p = buf;
139 if (*p != 0) {
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100140 /* Unspecified result (read from uninitialized memory) */
Gilles Peskineccb12152023-11-10 11:35:36 +0100141 mbedtls_printf("%u\n", (unsigned) *p);
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100142 }
143}
144
145void memory_leak(const char *name)
146{
147 (void) name;
Gilles Peskine7a715c42023-11-21 13:42:40 +0100148 volatile char *p = calloc_but_the_compiler_does_not_know(1, 1);
Gilles Peskined2fa6982023-11-09 21:46:24 +0100149 mbedtls_printf("%u\n", (unsigned) *p);
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100150 /* Leak of a heap object */
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100151}
152
Gilles Peskineef0f01f2023-11-22 18:22:07 +0100153/* name = "test_memory_poison_%(start)_%(offset)_%(count)_%(direction)"
Gilles Peskined29cce92023-11-02 20:49:34 +0100154 * Poison a region starting at start from an 8-byte aligned origin,
155 * encompassing count bytes. Access the region at offset from the start.
Gilles Peskineef0f01f2023-11-22 18:22:07 +0100156 * %(start), %(offset) and %(count) are decimal integers.
157 * %(direction) is either the character 'r' for read or 'w' for write.
Gilles Peskined29cce92023-11-02 20:49:34 +0100158 */
159void test_memory_poison(const char *name)
160{
161 size_t start = 0, offset = 0, count = 0;
Gilles Peskineef0f01f2023-11-22 18:22:07 +0100162 char direction = 'r';
Gilles Peskinee0acf872023-11-03 19:41:44 +0100163 if (sscanf(name,
164 "%*[^0-9]%" MBEDTLS_PRINTF_SIZET
165 "%*[^0-9]%" MBEDTLS_PRINTF_SIZET
Gilles Peskineef0f01f2023-11-22 18:22:07 +0100166 "%*[^0-9]%" MBEDTLS_PRINTF_SIZET
167 "_%c",
168 &start, &offset, &count, &direction) != 4) {
Gilles Peskined29cce92023-11-02 20:49:34 +0100169 mbedtls_fprintf(stderr, "%s: Bad name format: %s\n", __func__, name);
170 return;
171 }
172
173 union {
174 long long ll;
175 unsigned char buf[32];
176 } aligned;
177 memset(aligned.buf, 'a', sizeof(aligned.buf));
178
179 if (start > sizeof(aligned.buf)) {
Gilles Peskinee0acf872023-11-03 19:41:44 +0100180 mbedtls_fprintf(stderr,
181 "%s: start=%" MBEDTLS_PRINTF_SIZET
182 " > size=%" MBEDTLS_PRINTF_SIZET,
183 __func__, start, sizeof(aligned.buf));
Gilles Peskined29cce92023-11-02 20:49:34 +0100184 return;
185 }
186 if (start + count > sizeof(aligned.buf)) {
Gilles Peskinee0acf872023-11-03 19:41:44 +0100187 mbedtls_fprintf(stderr,
188 "%s: start+count=%" MBEDTLS_PRINTF_SIZET
189 " > size=%" MBEDTLS_PRINTF_SIZET,
190 __func__, start + count, sizeof(aligned.buf));
Gilles Peskined29cce92023-11-02 20:49:34 +0100191 return;
192 }
193 if (offset >= count) {
Gilles Peskinee0acf872023-11-03 19:41:44 +0100194 mbedtls_fprintf(stderr,
195 "%s: offset=%" MBEDTLS_PRINTF_SIZET
196 " >= count=%" MBEDTLS_PRINTF_SIZET,
197 __func__, offset, count);
Gilles Peskined29cce92023-11-02 20:49:34 +0100198 return;
199 }
200
201 MBEDTLS_TEST_MEMORY_POISON(aligned.buf + start, count);
Gilles Peskineef0f01f2023-11-22 18:22:07 +0100202
203 if (direction == 'w') {
204 aligned.buf[start + offset] = 'b';
205 } else {
206 mbedtls_printf("%u\n", (unsigned) aligned.buf[start + offset]);
207 }
Gilles Peskined29cce92023-11-02 20:49:34 +0100208}
209
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100210
211/****************************************************************/
Gilles Peskine102aea22023-11-03 18:05:38 +0100212/* Threading */
213/****************************************************************/
214
215void mutex_lock_not_initialized(const char *name)
216{
217 (void) name;
Gilles Peskinead2a17e2023-11-16 15:09:48 +0100218#if defined(MBEDTLS_THREADING_C)
Gilles Peskine102aea22023-11-03 18:05:38 +0100219 mbedtls_threading_mutex_t mutex;
220 memset(&mutex, 0, sizeof(mutex));
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100221 /* This mutex usage error is detected by our test framework's mutex usage
222 * verification framework. See tests/src/threading_helpers.c. Other
223 * threading implementations (e.g. pthread without our instrumentation)
224 * might consider this normal usage. */
Gilles Peskine102aea22023-11-03 18:05:38 +0100225 TEST_ASSERT(mbedtls_mutex_lock(&mutex) == 0);
226exit:
227 ;
228#endif
229}
230
231void mutex_unlock_not_initialized(const char *name)
232{
233 (void) name;
Gilles Peskine102aea22023-11-03 18:05:38 +0100234#if defined(MBEDTLS_THREADING_C)
235 mbedtls_threading_mutex_t mutex;
236 memset(&mutex, 0, sizeof(mutex));
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100237 /* This mutex usage error is detected by our test framework's mutex usage
238 * verification framework. See tests/src/threading_helpers.c. Other
239 * threading implementations (e.g. pthread without our instrumentation)
240 * might consider this normal usage. */
Gilles Peskine102aea22023-11-03 18:05:38 +0100241 TEST_ASSERT(mbedtls_mutex_unlock(&mutex) == 0);
242exit:
243 ;
244#endif
245}
246
247void mutex_free_not_initialized(const char *name)
248{
249 (void) name;
Gilles Peskine102aea22023-11-03 18:05:38 +0100250#if defined(MBEDTLS_THREADING_C)
251 mbedtls_threading_mutex_t mutex;
252 memset(&mutex, 0, sizeof(mutex));
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100253 /* This mutex usage error is detected by our test framework's mutex usage
254 * verification framework. See tests/src/threading_helpers.c. Other
255 * threading implementations (e.g. pthread without our instrumentation)
256 * might consider this normal usage. */
Gilles Peskine102aea22023-11-03 18:05:38 +0100257 mbedtls_mutex_free(&mutex);
258#endif
259}
260
261void mutex_double_init(const char *name)
262{
263 (void) name;
264#if defined(MBEDTLS_THREADING_C)
265 mbedtls_threading_mutex_t mutex;
266 mbedtls_mutex_init(&mutex);
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100267 /* This mutex usage error is detected by our test framework's mutex usage
268 * verification framework. See tests/src/threading_helpers.c. Other
269 * threading implementations (e.g. pthread without our instrumentation)
270 * might consider this normal usage. */
Gilles Peskine102aea22023-11-03 18:05:38 +0100271 mbedtls_mutex_init(&mutex);
272 mbedtls_mutex_free(&mutex);
273#endif
274}
275
276void mutex_double_free(const char *name)
277{
278 (void) name;
279#if defined(MBEDTLS_THREADING_C)
280 mbedtls_threading_mutex_t mutex;
281 mbedtls_mutex_init(&mutex);
282 mbedtls_mutex_free(&mutex);
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100283 /* This mutex usage error is detected by our test framework's mutex usage
284 * verification framework. See tests/src/threading_helpers.c. Other
285 * threading implementations (e.g. pthread without our instrumentation)
286 * might consider this normal usage. */
Gilles Peskine102aea22023-11-03 18:05:38 +0100287 mbedtls_mutex_free(&mutex);
288#endif
289}
290
291void mutex_leak(const char *name)
292{
293 (void) name;
Gilles Peskinead2a17e2023-11-16 15:09:48 +0100294#if defined(MBEDTLS_THREADING_C)
Gilles Peskine102aea22023-11-03 18:05:38 +0100295 mbedtls_threading_mutex_t mutex;
296 mbedtls_mutex_init(&mutex);
297#endif
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100298 /* This mutex usage error is detected by our test framework's mutex usage
299 * verification framework. See tests/src/threading_helpers.c. Other
300 * threading implementations (e.g. pthread without our instrumentation)
301 * might consider this normal usage. */
Gilles Peskine102aea22023-11-03 18:05:38 +0100302}
303
304
305/****************************************************************/
Gilles Peskine33406b62023-11-02 18:48:39 +0100306/* Command line entry point */
307/****************************************************************/
308
309typedef struct {
Gilles Peskinecce00122023-11-10 15:36:15 +0100310 /** Command line argument that will trigger that metatest.
311 *
312 * Conventionally matches "[a-z0-9_]+". */
Gilles Peskine33406b62023-11-02 18:48:39 +0100313 const char *name;
Gilles Peskinecce00122023-11-10 15:36:15 +0100314
315 /** Platform under which that metatest is valid.
316 *
317 * - "any": should work anywhere.
318 * - "asan": triggers ASan (Address Sanitizer).
319 * - "msan": triggers MSan (Memory Sanitizer).
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100320 * - "pthread": requires MBEDTLS_THREADING_PTHREAD and MBEDTLS_TEST_HOOKS,
321 * which enables MBEDTLS_TEST_MUTEX_USAGE internally in the test
322 * framework (see tests/src/threading_helpers.c).
Gilles Peskinecce00122023-11-10 15:36:15 +0100323 */
Gilles Peskine33406b62023-11-02 18:48:39 +0100324 const char *platform;
Gilles Peskinecce00122023-11-10 15:36:15 +0100325
326 /** Function that performs the metatest.
327 *
328 * The function receives the name as an argument. This allows using the
329 * same function to perform multiple variants of a test based on the name.
330 *
331 * When executed on a conforming platform, the function is expected to
332 * either cause a test failure (mbedtls_test_fail()), or cause the
333 * program to abort in some way (e.g. by causing a segfault or by
334 * triggering a sanitizer).
335 *
336 * When executed on a non-conforming platform, the function may return
337 * normally or may have unpredictable behavior.
338 */
Gilles Peskine33406b62023-11-02 18:48:39 +0100339 void (*entry_point)(const char *name);
340} metatest_t;
341
Gilles Peskinecce00122023-11-10 15:36:15 +0100342/* The list of availble meta-tests. Remember to register new functions here!
343 *
344 * Note that we always compile all the functions, so that `metatest --list`
345 * will always list all the available meta-tests.
Gilles Peskine2f40cc02023-11-16 15:11:44 +0100346 *
347 * See the documentation of metatest_t::platform for the meaning of
348 * platform values.
Gilles Peskinecce00122023-11-10 15:36:15 +0100349 */
Gilles Peskine33406b62023-11-02 18:48:39 +0100350metatest_t metatests[] = {
Gilles Peskinef309fbf2023-11-02 18:49:52 +0100351 { "test_fail", "any", meta_test_fail },
Gilles Peskine80ba8322023-11-02 19:23:26 +0100352 { "null_dereference", "any", null_pointer_dereference },
353 { "null_call", "any", null_pointer_call },
Gilles Peskineb0f0a642023-11-02 19:42:13 +0100354 { "read_after_free", "asan", read_after_free },
355 { "double_free", "asan", double_free },
356 { "read_uninitialized_stack", "msan", read_uninitialized_stack },
357 { "memory_leak", "asan", memory_leak },
Gilles Peskineef0f01f2023-11-22 18:22:07 +0100358 { "test_memory_poison_0_0_8_r", "asan", test_memory_poison },
359 { "test_memory_poison_0_0_8_w", "asan", test_memory_poison },
360 { "test_memory_poison_0_7_8_r", "asan", test_memory_poison },
361 { "test_memory_poison_0_7_8_w", "asan", test_memory_poison },
362 { "test_memory_poison_0_0_1_r", "asan", test_memory_poison },
363 { "test_memory_poison_0_0_1_w", "asan", test_memory_poison },
364 { "test_memory_poison_0_1_2_r", "asan", test_memory_poison },
365 { "test_memory_poison_0_1_2_w", "asan", test_memory_poison },
366 { "test_memory_poison_7_0_8_r", "asan", test_memory_poison },
367 { "test_memory_poison_7_0_8_w", "asan", test_memory_poison },
368 { "test_memory_poison_7_7_8_r", "asan", test_memory_poison },
369 { "test_memory_poison_7_7_8_w", "asan", test_memory_poison },
370 { "test_memory_poison_7_0_1_r", "asan", test_memory_poison },
371 { "test_memory_poison_7_0_1_w", "asan", test_memory_poison },
372 { "test_memory_poison_7_1_2_r", "asan", test_memory_poison },
373 { "test_memory_poison_7_1_2_w", "asan", test_memory_poison },
Gilles Peskine102aea22023-11-03 18:05:38 +0100374 { "mutex_lock_not_initialized", "pthread", mutex_lock_not_initialized },
375 { "mutex_unlock_not_initialized", "pthread", mutex_unlock_not_initialized },
376 { "mutex_free_not_initialized", "pthread", mutex_free_not_initialized },
377 { "mutex_double_init", "pthread", mutex_double_init },
378 { "mutex_double_free", "pthread", mutex_double_free },
379 { "mutex_leak", "pthread", mutex_leak },
Gilles Peskine33406b62023-11-02 18:48:39 +0100380 { NULL, NULL, NULL }
381};
382
383static void help(FILE *out, const char *argv0)
384{
385 mbedtls_fprintf(out, "Usage: %s list|TEST\n", argv0);
386 mbedtls_fprintf(out, "Run a meta-test that should cause a test failure.\n");
387 mbedtls_fprintf(out, "With 'list', list the available tests and their platform requirement.\n");
388}
389
390int main(int argc, char *argv[])
391{
392 const char *argv0 = argc > 0 ? argv[0] : "metatest";
393 if (argc != 2) {
394 help(stderr, argv0);
395 mbedtls_exit(MBEDTLS_EXIT_FAILURE);
396 }
397
398 /* Support "-help", "--help", "--list", etc. */
399 const char *command = argv[1];
400 while (*command == '-') {
401 ++command;
402 }
403
404 if (strcmp(argv[1], "help") == 0) {
405 help(stdout, argv0);
406 mbedtls_exit(MBEDTLS_EXIT_SUCCESS);
407 }
408 if (strcmp(argv[1], "list") == 0) {
409 for (const metatest_t *p = metatests; p->name != NULL; p++) {
410 mbedtls_printf("%s %s\n", p->name, p->platform);
411 }
412 mbedtls_exit(MBEDTLS_EXIT_SUCCESS);
413 }
414
Gilles Peskine102aea22023-11-03 18:05:38 +0100415#if defined(MBEDTLS_TEST_MUTEX_USAGE)
416 mbedtls_test_mutex_usage_init();
417#endif
418
Gilles Peskine33406b62023-11-02 18:48:39 +0100419 for (const metatest_t *p = metatests; p->name != NULL; p++) {
420 if (strcmp(argv[1], p->name) == 0) {
421 mbedtls_printf("Running metatest %s...\n", argv[1]);
422 p->entry_point(argv[1]);
Gilles Peskine102aea22023-11-03 18:05:38 +0100423#if defined(MBEDTLS_TEST_MUTEX_USAGE)
424 mbedtls_test_mutex_usage_check();
425#endif
Gilles Peskine33406b62023-11-02 18:48:39 +0100426 mbedtls_printf("Running metatest %s... done, result=%d\n",
427 argv[1], (int) mbedtls_test_info.result);
428 mbedtls_exit(mbedtls_test_info.result == MBEDTLS_TEST_RESULT_SUCCESS ?
429 MBEDTLS_EXIT_SUCCESS :
430 MBEDTLS_EXIT_FAILURE);
431 }
432 }
433
434 mbedtls_fprintf(stderr, "%s: FATAL: No such metatest: %s\n",
435 argv0, command);
436 mbedtls_exit(MBEDTLS_EXIT_FAILURE);
437}