blob: 8b7c19aa5fab102d83227a8532823da6cf4e6ea8 [file] [log] [blame]
Paul Bakker9d781402011-05-09 16:17:09 +00001/**
2 * \file error.h
3 *
4 * \brief Error to string translation
Darryl Greena40a1012018-01-05 15:33:17 +00005 */
6/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02007 * Copyright The Mbed TLS Contributors
Dave Rodgman16799db2023-11-02 19:47:20 +00008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Paul Bakker9d781402011-05-09 16:17:09 +00009 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020010#ifndef MBEDTLS_ERROR_H
11#define MBEDTLS_ERROR_H
Paul Bakker9d781402011-05-09 16:17:09 +000012
Bence Szépkútic662b362021-05-27 11:25:03 +020013#include "mbedtls/build_info.h"
Harry Ramsey69b67c82024-10-10 13:13:37 +010014#include "mbedtls/error_common.h"
Ron Eldor9cbd1b22018-12-16 12:14:37 +020015
Rich Evans00ab4702015-02-06 13:43:58 +000016#include <stddef.h>
Paul Bakker3c2122f2013-06-24 19:03:14 +020017
Paul Bakkerbcd5db42011-05-20 12:30:59 +000018#ifdef __cplusplus
19extern "C" {
20#endif
21
Paul Bakker9d781402011-05-09 16:17:09 +000022/**
Gilles Peskine2e38a0d2023-09-12 19:19:31 +020023 * \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 Bakker9d781402011-05-09 16:17:09 +000026 *
27 * \param errnum error code
28 * \param buffer buffer to place representation in
29 * \param buflen length of the buffer
30 */
Gilles Peskine449bd832023-01-11 14:50:10 +010031void mbedtls_strerror(int errnum, char *buffer, size_t buflen);
Paul Bakkere2ab84f2013-06-29 18:24:32 +020032
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070033/**
Gaurav Aggarwal6ea4fc72020-04-20 16:03:46 -070034 * \brief Translate the high-level part of an Mbed TLS error code into a string
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070035 * representation.
36 *
37 * This function returns a const pointer to an un-modifiable string. The caller
Gaurav Aggarwal6ea4fc72020-04-20 16:03:46 -070038 * must not try to modify the string. It is intended to be used mostly for
39 * logging purposes.
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070040 *
41 * \param error_code error code
42 *
Gaurav Aggarwal6ea4fc72020-04-20 16:03:46 -070043 * \return The string representation of the error code, or \c NULL if the error
44 * code is unknown.
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070045 */
Gilles Peskine449bd832023-01-11 14:50:10 +010046const char *mbedtls_high_level_strerr(int error_code);
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070047
48/**
Gaurav Aggarwal6ea4fc72020-04-20 16:03:46 -070049 * \brief Translate the low-level part of an Mbed TLS error code into a string
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070050 * representation.
51 *
52 * This function returns a const pointer to an un-modifiable string. The caller
Gaurav Aggarwal6ea4fc72020-04-20 16:03:46 -070053 * must not try to modify the string. It is intended to be used mostly for
54 * logging purposes.
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070055 *
56 * \param error_code error code
57 *
Gaurav Aggarwal6ea4fc72020-04-20 16:03:46 -070058 * \return The string representation of the error code, or \c NULL if the error
59 * code is unknown.
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070060 */
Gilles Peskine449bd832023-01-11 14:50:10 +010061const char *mbedtls_low_level_strerr(int error_code);
Gaurav Aggarwala9f64002020-04-09 01:44:52 -070062
Paul Bakkerbcd5db42011-05-20 12:30:59 +000063#ifdef __cplusplus
64}
65#endif
66
Paul Bakker9d781402011-05-09 16:17:09 +000067#endif /* error.h */