Ronald Cron | b6d6d4c | 2020-06-03 10:11:18 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file helpers.h |
| 3 | * |
| 4 | * \brief This file contains the prototypes of helper functions for the |
| 5 | * purpose of testing. |
| 6 | */ |
| 7 | |
Bence Szépkúti | 8697465 | 2020-06-15 11:59:37 +0200 | [diff] [blame] | 8 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 9 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame] | 10 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Ronald Cron | b6d6d4c | 2020-06-03 10:11:18 +0200 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #ifndef TEST_HELPERS_H |
| 14 | #define TEST_HELPERS_H |
| 15 | |
Mateusz Starzyk | b198272 | 2021-05-27 14:46:48 +0200 | [diff] [blame] | 16 | /* Most fields of publicly available structs are private and are wrapped with |
| 17 | * MBEDTLS_PRIVATE macro. This define allows tests to access the private fields |
| 18 | * directly (without using the MBEDTLS_PRIVATE wrapper). */ |
Mateusz Starzyk | 2c09c9b | 2021-05-14 22:20:10 +0200 | [diff] [blame] | 19 | #define MBEDTLS_ALLOW_PRIVATE_ACCESS |
| 20 | |
Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 21 | #include "mbedtls/build_info.h" |
Ronald Cron | b6d6d4c | 2020-06-03 10:11:18 +0200 | [diff] [blame] | 22 | |
Gilles Peskine | fa8ec26 | 2023-11-22 17:55:43 +0100 | [diff] [blame] | 23 | #if defined(__SANITIZE_ADDRESS__) /* gcc -fsanitize=address */ |
| 24 | # define MBEDTLS_TEST_HAVE_ASAN |
| 25 | #endif |
| 26 | #if defined(__has_feature) |
| 27 | # if __has_feature(address_sanitizer) /* clang -fsanitize=address */ |
| 28 | # define MBEDTLS_TEST_HAVE_ASAN |
| 29 | # endif |
| 30 | # if __has_feature(memory_sanitizer) /* clang -fsanitize=memory */ |
| 31 | # define MBEDTLS_TEST_HAVE_MSAN |
| 32 | # endif |
| 33 | # if __has_feature(thread_sanitizer) /* clang -fsanitize=thread */ |
| 34 | # define MBEDTLS_TEST_HAVE_TSAN |
| 35 | # endif |
| 36 | #endif |
| 37 | |
Gilles Peskine | 2a4c598 | 2021-01-29 21:18:09 +0100 | [diff] [blame] | 38 | #if defined(MBEDTLS_THREADING_C) && defined(MBEDTLS_THREADING_PTHREAD) && \ |
| 39 | defined(MBEDTLS_TEST_HOOKS) |
| 40 | #define MBEDTLS_TEST_MUTEX_USAGE |
| 41 | #endif |
| 42 | |
Ronald Cron | f40529d | 2020-06-09 16:27:37 +0200 | [diff] [blame] | 43 | #include "mbedtls/platform.h" |
Ronald Cron | f40529d | 2020-06-09 16:27:37 +0200 | [diff] [blame] | 44 | |
| 45 | #include <stddef.h> |
| 46 | #include <stdint.h> |
| 47 | |
Gilles Peskine | ebc49e5 | 2021-06-11 14:13:53 +0200 | [diff] [blame] | 48 | #if defined(MBEDTLS_BIGNUM_C) |
| 49 | #include "mbedtls/bignum.h" |
| 50 | #endif |
| 51 | |
Gilles Peskine | 571576f | 2022-09-20 21:37:56 +0200 | [diff] [blame] | 52 | /** The type of test case arguments that contain binary data. */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 53 | typedef struct data_tag { |
| 54 | uint8_t *x; |
Gilles Peskine | 571576f | 2022-09-20 21:37:56 +0200 | [diff] [blame] | 55 | uint32_t len; |
| 56 | } data_t; |
| 57 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 58 | typedef enum { |
Chris Jones | e60e2ae | 2021-01-20 17:51:47 +0000 | [diff] [blame] | 59 | MBEDTLS_TEST_RESULT_SUCCESS = 0, |
| 60 | MBEDTLS_TEST_RESULT_FAILED, |
| 61 | MBEDTLS_TEST_RESULT_SKIPPED |
| 62 | } mbedtls_test_result_t; |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 63 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 64 | typedef struct { |
Chris Jones | e60e2ae | 2021-01-20 17:51:47 +0000 | [diff] [blame] | 65 | mbedtls_test_result_t result; |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 66 | const char *test; |
| 67 | const char *filename; |
| 68 | int line_no; |
| 69 | unsigned long step; |
Gilles Peskine | 89615ee | 2021-04-29 20:28:54 +0200 | [diff] [blame] | 70 | char line1[76]; |
| 71 | char line2[76]; |
Gilles Peskine | 2a4c598 | 2021-01-29 21:18:09 +0100 | [diff] [blame] | 72 | #if defined(MBEDTLS_TEST_MUTEX_USAGE) |
| 73 | const char *mutex_usage_error; |
| 74 | #endif |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 75 | } |
Chris Jones | e60e2ae | 2021-01-20 17:51:47 +0000 | [diff] [blame] | 76 | mbedtls_test_info_t; |
Paul Elliott | 4580d4d | 2023-10-27 18:41:02 +0100 | [diff] [blame^] | 77 | |
| 78 | /** |
| 79 | * \brief Get the current test result status |
| 80 | * |
| 81 | * \return The current test result status |
| 82 | */ |
| 83 | mbedtls_test_result_t mbedtls_test_get_result(void); |
| 84 | |
| 85 | /** |
| 86 | * \brief Get the current test name/description |
| 87 | * |
| 88 | * \return The current test name/description |
| 89 | */ |
| 90 | const char *mbedtls_test_get_test(void); |
| 91 | |
| 92 | /** |
| 93 | * \brief Get the current test filename |
| 94 | * |
| 95 | * \return The current test filename |
| 96 | */ |
| 97 | const char *mbedtls_get_test_filename(void); |
| 98 | |
| 99 | /** |
| 100 | * \brief Get the current test file line number (for failure / skip) |
| 101 | * |
| 102 | * \return The current test file line number (for failure / skip) |
| 103 | */ |
| 104 | int mbedtls_test_get_line_no(void); |
| 105 | |
| 106 | /** |
| 107 | * \brief Increment the current test step. |
| 108 | */ |
| 109 | void mbedtls_test_increment_step(void); |
| 110 | |
| 111 | /** |
| 112 | * \brief Get the current test step |
| 113 | * |
| 114 | * \return The current test step |
| 115 | */ |
| 116 | unsigned long mbedtls_test_get_step(void); |
| 117 | |
| 118 | /** |
| 119 | * \brief Get the current test line buffer 1 |
| 120 | * |
| 121 | * \return The current test line buffer 1 |
| 122 | */ |
| 123 | const char *mbedtls_test_get_line1(void); |
| 124 | |
| 125 | /** |
| 126 | * \brief Get the current test line buffer 2 |
| 127 | * |
| 128 | * \return The current test line buffer 2 |
| 129 | */ |
| 130 | const char *mbedtls_test_get_line2(void); |
| 131 | |
| 132 | #if defined(MBEDTLS_TEST_MUTEX_USAGE) |
| 133 | /** |
| 134 | * \brief Get the current mutex usage error message |
| 135 | * |
| 136 | * \return The current mutex error message (may be NULL if no error) |
| 137 | */ |
| 138 | const char *mbedtls_test_get_mutex_usage_error(void); |
| 139 | |
| 140 | /** |
| 141 | * \brief Set the current mutex usage error message |
| 142 | * |
| 143 | * \note This will only set the mutex error message if one has not |
| 144 | * already been set, or if we are clearing the message (msg is |
| 145 | * NULL) |
| 146 | * |
| 147 | * \param msg Error message to set (can be NULL to clear) |
| 148 | */ |
| 149 | void mbedtls_test_set_mutex_usage_error(const char *msg); |
| 150 | #endif |
| 151 | |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 152 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 153 | int mbedtls_test_platform_setup(void); |
| 154 | void mbedtls_test_platform_teardown(void); |
Ronald Cron | f40529d | 2020-06-09 16:27:37 +0200 | [diff] [blame] | 155 | |
Ronald Cron | a0c2539 | 2020-06-18 10:10:46 +0200 | [diff] [blame] | 156 | /** |
Chris Jones | 39ddb0a | 2021-02-03 16:15:00 +0000 | [diff] [blame] | 157 | * \brief Record the current test case as a failure. |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 158 | * |
Chris Jones | 39ddb0a | 2021-02-03 16:15:00 +0000 | [diff] [blame] | 159 | * This function can be called directly however it is usually |
| 160 | * called via macros such as TEST_ASSERT, TEST_EQUAL, |
| 161 | * PSA_ASSERT, etc... |
| 162 | * |
| 163 | * \note If the test case was already marked as failed, calling |
| 164 | * `mbedtls_test_fail( )` again will not overwrite any |
| 165 | * previous information about the failure. |
| 166 | * |
| 167 | * \param test Description of the failure or assertion that failed. This |
| 168 | * MUST be a string literal. |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 169 | * \param line_no Line number where the failure originated. |
| 170 | * \param filename Filename where the failure originated. |
| 171 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 172 | void mbedtls_test_fail(const char *test, int line_no, const char *filename); |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 173 | |
| 174 | /** |
Chris Jones | 39ddb0a | 2021-02-03 16:15:00 +0000 | [diff] [blame] | 175 | * \brief Record the current test case as skipped. |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 176 | * |
Chris Jones | 39ddb0a | 2021-02-03 16:15:00 +0000 | [diff] [blame] | 177 | * This function can be called directly however it is usually |
| 178 | * called via the TEST_ASSUME macro. |
| 179 | * |
| 180 | * \param test Description of the assumption that caused the test case to |
| 181 | * be skipped. This MUST be a string literal. |
| 182 | * \param line_no Line number where the test case was skipped. |
| 183 | * \param filename Filename where the test case was skipped. |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 184 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 185 | void mbedtls_test_skip(const char *test, int line_no, const char *filename); |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 186 | |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 187 | /** |
| 188 | * \brief Set the test step number for failure reports. |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 189 | * |
Chris Jones | 39ddb0a | 2021-02-03 16:15:00 +0000 | [diff] [blame] | 190 | * Call this function to display "step NNN" in addition to the |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 191 | * line number and file name if a test fails. Typically the "step |
| 192 | * number" is the index of a for loop but it can be whatever you |
| 193 | * want. |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 194 | * |
| 195 | * \param step The step number to report. |
| 196 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 197 | void mbedtls_test_set_step(unsigned long step); |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 198 | |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 199 | /** |
| 200 | * \brief Reset mbedtls_test_info to a ready/starting state. |
Chris Jones | 567e0ad | 2021-02-03 12:07:01 +0000 | [diff] [blame] | 201 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 202 | void mbedtls_test_info_reset(void); |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 203 | |
Ronald Cron | a0c2539 | 2020-06-18 10:10:46 +0200 | [diff] [blame] | 204 | /** |
Gilles Peskine | 89615ee | 2021-04-29 20:28:54 +0200 | [diff] [blame] | 205 | * \brief Record the current test case as a failure if two integers |
| 206 | * have a different value. |
| 207 | * |
| 208 | * This function is usually called via the macro |
| 209 | * #TEST_EQUAL. |
| 210 | * |
| 211 | * \param test Description of the failure or assertion that failed. This |
| 212 | * MUST be a string literal. This normally has the form |
| 213 | * "EXPR1 == EXPR2" where EXPR1 has the value \p value1 |
| 214 | * and EXPR2 has the value \p value2. |
| 215 | * \param line_no Line number where the failure originated. |
| 216 | * \param filename Filename where the failure originated. |
| 217 | * \param value1 The first value to compare. |
| 218 | * \param value2 The second value to compare. |
| 219 | * |
| 220 | * \return \c 1 if the values are equal, otherwise \c 0. |
| 221 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 222 | int mbedtls_test_equal(const char *test, int line_no, const char *filename, |
| 223 | unsigned long long value1, unsigned long long value2); |
Gilles Peskine | 89615ee | 2021-04-29 20:28:54 +0200 | [diff] [blame] | 224 | |
| 225 | /** |
Gilles Peskine | d146542 | 2022-04-13 23:59:52 +0200 | [diff] [blame] | 226 | * \brief Record the current test case as a failure based |
| 227 | * on comparing two unsigned integers. |
| 228 | * |
| 229 | * This function is usually called via the macro |
| 230 | * #TEST_LE_U. |
| 231 | * |
| 232 | * \param test Description of the failure or assertion that failed. This |
| 233 | * MUST be a string literal. This normally has the form |
| 234 | * "EXPR1 <= EXPR2" where EXPR1 has the value \p value1 |
| 235 | * and EXPR2 has the value \p value2. |
| 236 | * \param line_no Line number where the failure originated. |
| 237 | * \param filename Filename where the failure originated. |
| 238 | * \param value1 The first value to compare. |
| 239 | * \param value2 The second value to compare. |
| 240 | * |
| 241 | * \return \c 1 if \p value1 <= \p value2, otherwise \c 0. |
| 242 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 243 | int mbedtls_test_le_u(const char *test, int line_no, const char *filename, |
| 244 | unsigned long long value1, unsigned long long value2); |
Gilles Peskine | d146542 | 2022-04-13 23:59:52 +0200 | [diff] [blame] | 245 | |
| 246 | /** |
| 247 | * \brief Record the current test case as a failure based |
| 248 | * on comparing two signed integers. |
| 249 | * |
| 250 | * This function is usually called via the macro |
| 251 | * #TEST_LE_S. |
| 252 | * |
| 253 | * \param test Description of the failure or assertion that failed. This |
| 254 | * MUST be a string literal. This normally has the form |
| 255 | * "EXPR1 <= EXPR2" where EXPR1 has the value \p value1 |
| 256 | * and EXPR2 has the value \p value2. |
| 257 | * \param line_no Line number where the failure originated. |
| 258 | * \param filename Filename where the failure originated. |
| 259 | * \param value1 The first value to compare. |
| 260 | * \param value2 The second value to compare. |
| 261 | * |
| 262 | * \return \c 1 if \p value1 <= \p value2, otherwise \c 0. |
| 263 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 264 | int mbedtls_test_le_s(const char *test, int line_no, const char *filename, |
| 265 | long long value1, long long value2); |
Gilles Peskine | d146542 | 2022-04-13 23:59:52 +0200 | [diff] [blame] | 266 | |
| 267 | /** |
Ronald Cron | ab500cb | 2020-07-01 17:09:10 +0200 | [diff] [blame] | 268 | * \brief This function decodes the hexadecimal representation of |
| 269 | * data. |
Ronald Cron | a0c2539 | 2020-06-18 10:10:46 +0200 | [diff] [blame] | 270 | * |
| 271 | * \note The output buffer can be the same as the input buffer. For |
| 272 | * any other overlapping of the input and output buffers, the |
| 273 | * behavior is undefined. |
| 274 | * |
| 275 | * \param obuf Output buffer. |
| 276 | * \param obufmax Size in number of bytes of \p obuf. |
| 277 | * \param ibuf Input buffer. |
| 278 | * \param len The number of unsigned char written in \p obuf. This must |
| 279 | * not be \c NULL. |
| 280 | * |
| 281 | * \return \c 0 on success. |
| 282 | * \return \c -1 if the output buffer is too small or the input string |
Ronald Cron | ab500cb | 2020-07-01 17:09:10 +0200 | [diff] [blame] | 283 | * is not a valid hexadecimal representation. |
Ronald Cron | a0c2539 | 2020-06-18 10:10:46 +0200 | [diff] [blame] | 284 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 285 | int mbedtls_test_unhexify(unsigned char *obuf, size_t obufmax, |
| 286 | const char *ibuf, size_t *len); |
Ronald Cron | a0c2539 | 2020-06-18 10:10:46 +0200 | [diff] [blame] | 287 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 288 | void mbedtls_test_hexify(unsigned char *obuf, |
| 289 | const unsigned char *ibuf, |
| 290 | int len); |
Ronald Cron | f40529d | 2020-06-09 16:27:37 +0200 | [diff] [blame] | 291 | |
| 292 | /** |
Gilles Peskine | 881447d | 2022-12-08 15:24:52 +0100 | [diff] [blame] | 293 | * \brief Convert hexadecimal digit to an integer. |
| 294 | * |
| 295 | * \param c The digit to convert (`'0'` to `'9'`, `'A'` to `'F'` or |
| 296 | * `'a'` to `'f'`). |
| 297 | * \param[out] uc On success, the value of the digit (0 to 15). |
| 298 | * |
| 299 | * \return 0 on success, -1 if \p c is not a hexadecimal digit. |
| 300 | */ |
| 301 | int mbedtls_test_ascii2uc(const char c, unsigned char *uc); |
| 302 | |
| 303 | /** |
Ronald Cron | f40529d | 2020-06-09 16:27:37 +0200 | [diff] [blame] | 304 | * Allocate and zeroize a buffer. |
| 305 | * |
| 306 | * If the size if zero, a pointer to a zeroized 1-byte buffer is returned. |
| 307 | * |
| 308 | * For convenience, dies if allocation fails. |
| 309 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 310 | unsigned char *mbedtls_test_zero_alloc(size_t len); |
Ronald Cron | f40529d | 2020-06-09 16:27:37 +0200 | [diff] [blame] | 311 | |
| 312 | /** |
| 313 | * Allocate and fill a buffer from hex data. |
| 314 | * |
| 315 | * The buffer is sized exactly as needed. This allows to detect buffer |
| 316 | * overruns (including overreads) when running the test suite under valgrind. |
| 317 | * |
| 318 | * If the size if zero, a pointer to a zeroized 1-byte buffer is returned. |
| 319 | * |
| 320 | * For convenience, dies if allocation fails. |
| 321 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 322 | unsigned char *mbedtls_test_unhexify_alloc(const char *ibuf, size_t *olen); |
Ronald Cron | f40529d | 2020-06-09 16:27:37 +0200 | [diff] [blame] | 323 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 324 | int mbedtls_test_hexcmp(uint8_t *a, uint8_t *b, |
| 325 | uint32_t a_len, uint32_t b_len); |
Ronald Cron | f40529d | 2020-06-09 16:27:37 +0200 | [diff] [blame] | 326 | |
Gilles Peskine | 1dc19ff | 2021-02-08 20:59:39 +0100 | [diff] [blame] | 327 | #if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) |
Gilles Peskine | 1af872d | 2021-01-20 20:02:01 +0100 | [diff] [blame] | 328 | #include "test/fake_external_rng_for_test.h" |
| 329 | #endif |
| 330 | |
Gilles Peskine | 2a4c598 | 2021-01-29 21:18:09 +0100 | [diff] [blame] | 331 | #if defined(MBEDTLS_TEST_MUTEX_USAGE) |
Paul Elliott | f25d831 | 2023-11-23 18:49:43 +0000 | [diff] [blame] | 332 | /** |
| 333 | * Activate the mutex usage verification framework. See threading_helpers.c for |
| 334 | * information. |
| 335 | * */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 336 | void mbedtls_test_mutex_usage_init(void); |
Gilles Peskine | 2a4c598 | 2021-01-29 21:18:09 +0100 | [diff] [blame] | 337 | |
Paul Elliott | f25d831 | 2023-11-23 18:49:43 +0000 | [diff] [blame] | 338 | /** |
| 339 | * Deactivate the mutex usage verification framework. See threading_helpers.c |
| 340 | * for information. |
| 341 | */ |
| 342 | void mbedtls_test_mutex_usage_end(void); |
| 343 | |
Gilles Peskine | 2a4c598 | 2021-01-29 21:18:09 +0100 | [diff] [blame] | 344 | /** Call this function after executing a test case to check for mutex usage |
| 345 | * errors. */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 346 | void mbedtls_test_mutex_usage_check(void); |
Gilles Peskine | 1061ec6 | 2021-01-29 21:17:11 +0100 | [diff] [blame] | 347 | #endif /* MBEDTLS_TEST_MUTEX_USAGE */ |
| 348 | |
Chris Jones | 96ae73b | 2021-01-08 17:04:59 +0000 | [diff] [blame] | 349 | #if defined(MBEDTLS_TEST_HOOKS) |
| 350 | /** |
Chris Jones | 3f613c1 | 2021-03-31 09:34:22 +0100 | [diff] [blame] | 351 | * \brief Check that only a pure high-level error code is being combined with |
| 352 | * a pure low-level error code as otherwise the resultant error code |
Chris Jones | 5e8805a | 2021-01-12 15:21:57 +0000 | [diff] [blame] | 353 | * would be corrupted. |
Chris Jones | 3f613c1 | 2021-03-31 09:34:22 +0100 | [diff] [blame] | 354 | * |
| 355 | * \note Both high-level and low-level error codes cannot be greater than |
| 356 | * zero however can be zero. If one error code is zero then the |
| 357 | * other error code is returned even if both codes are zero. |
| 358 | * |
| 359 | * \note If the check fails, fail the test currently being run. |
Chris Jones | 96ae73b | 2021-01-08 17:04:59 +0000 | [diff] [blame] | 360 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 361 | void mbedtls_test_err_add_check(int high, int low, |
| 362 | const char *file, int line); |
Chris Jones | 96ae73b | 2021-01-08 17:04:59 +0000 | [diff] [blame] | 363 | #endif |
| 364 | |
Ronald Cron | b6d6d4c | 2020-06-03 10:11:18 +0200 | [diff] [blame] | 365 | #endif /* TEST_HELPERS_H */ |