Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file error.h |
| 3 | * |
| 4 | * \brief Error to string translation |
Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 5 | */ |
| 6 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 7 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame] | 8 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 9 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 10 | #ifndef MBEDTLS_ERROR_H |
| 11 | #define MBEDTLS_ERROR_H |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 12 | |
Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 13 | #include "mbedtls/build_info.h" |
Harry Ramsey | 69b67c8 | 2024-10-10 13:13:37 +0100 | [diff] [blame] | 14 | #include "mbedtls/error_common.h" |
Ron Eldor | 9cbd1b2 | 2018-12-16 12:14:37 +0200 | [diff] [blame] | 15 | |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 16 | #include <stddef.h> |
Paul Bakker | 3c2122f | 2013-06-24 19:03:14 +0200 | [diff] [blame] | 17 | |
Paul Bakker | bcd5db4 | 2011-05-20 12:30:59 +0000 | [diff] [blame] | 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 22 | /** |
Gilles Peskine | 2e38a0d | 2023-09-12 19:19:31 +0200 | [diff] [blame] | 23 | * \brief Translate an Mbed TLS error code into a string representation. |
| 24 | * The result is truncated if necessary and always includes a |
| 25 | * terminating null byte. |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 26 | * |
| 27 | * \param errnum error code |
| 28 | * \param buffer buffer to place representation in |
| 29 | * \param buflen length of the buffer |
| 30 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 31 | void mbedtls_strerror(int errnum, char *buffer, size_t buflen); |
Paul Bakker | e2ab84f | 2013-06-29 18:24:32 +0200 | [diff] [blame] | 32 | |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 33 | /** |
Gaurav Aggarwal | 6ea4fc7 | 2020-04-20 16:03:46 -0700 | [diff] [blame] | 34 | * \brief Translate the high-level part of an Mbed TLS error code into a string |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 35 | * representation. |
| 36 | * |
| 37 | * This function returns a const pointer to an un-modifiable string. The caller |
Gaurav Aggarwal | 6ea4fc7 | 2020-04-20 16:03:46 -0700 | [diff] [blame] | 38 | * must not try to modify the string. It is intended to be used mostly for |
| 39 | * logging purposes. |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 40 | * |
| 41 | * \param error_code error code |
| 42 | * |
Gaurav Aggarwal | 6ea4fc7 | 2020-04-20 16:03:46 -0700 | [diff] [blame] | 43 | * \return The string representation of the error code, or \c NULL if the error |
| 44 | * code is unknown. |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 45 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 46 | const char *mbedtls_high_level_strerr(int error_code); |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
Gaurav Aggarwal | 6ea4fc7 | 2020-04-20 16:03:46 -0700 | [diff] [blame] | 49 | * \brief Translate the low-level part of an Mbed TLS error code into a string |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 50 | * representation. |
| 51 | * |
| 52 | * This function returns a const pointer to an un-modifiable string. The caller |
Gaurav Aggarwal | 6ea4fc7 | 2020-04-20 16:03:46 -0700 | [diff] [blame] | 53 | * must not try to modify the string. It is intended to be used mostly for |
| 54 | * logging purposes. |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 55 | * |
| 56 | * \param error_code error code |
| 57 | * |
Gaurav Aggarwal | 6ea4fc7 | 2020-04-20 16:03:46 -0700 | [diff] [blame] | 58 | * \return The string representation of the error code, or \c NULL if the error |
| 59 | * code is unknown. |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 60 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 61 | const char *mbedtls_low_level_strerr(int error_code); |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 62 | |
Paul Bakker | bcd5db4 | 2011-05-20 12:30:59 +0000 | [diff] [blame] | 63 | #ifdef __cplusplus |
| 64 | } |
| 65 | #endif |
| 66 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 67 | #endif /* error.h */ |