mbed TLS v3.1.0
error.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License"); you may
11  * not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 #ifndef MBEDTLS_ERROR_H
23 #define MBEDTLS_ERROR_H
24 
25 #include "mbedtls/build_info.h"
26 
27 #include <stddef.h>
28 
29 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
30  !defined(inline) && !defined(__cplusplus)
31 #define inline __inline
32 #endif
33 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
112 #define MBEDTLS_ERR_ERROR_GENERIC_ERROR -0x0001
113 
114 #define MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED -0x006E
115 
117 #define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070
118 
119 #define MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED -0x0072
120 
127 #define MBEDTLS_ERROR_ADD( high, low ) \
128  mbedtls_error_add( high, low, __FILE__, __LINE__ )
129 
130 #if defined(MBEDTLS_TEST_HOOKS)
131 
135 extern void (*mbedtls_test_hook_error_add)( int, int, const char *, int );
136 #endif
137 
156 static inline int mbedtls_error_add( int high, int low,
157  const char *file, int line )
158 {
159 #if defined(MBEDTLS_TEST_HOOKS)
160  if( *mbedtls_test_hook_error_add != NULL )
161  ( *mbedtls_test_hook_error_add )( high, low, file, line );
162 #endif
163  (void)file;
164  (void)line;
165 
166  return( high + low );
167 }
168 
178 void mbedtls_strerror( int errnum, char *buffer, size_t buflen );
179 
193 const char * mbedtls_high_level_strerr( int error_code );
194 
208 const char * mbedtls_low_level_strerr( int error_code );
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif /* error.h */
void(* mbedtls_test_hook_error_add)(int, int, const char *, int)
Testing hook called before adding/combining two error codes together. Only used when invasive testing...
void mbedtls_strerror(int errnum, char *buffer, size_t buflen)
Translate a mbed TLS error code into a string representation, Result is truncated if necessary and al...
static int mbedtls_error_add(int high, int low, const char *file, int line)
Combines a high-level and low-level error code together.
Definition: error.h:156
const char * mbedtls_high_level_strerr(int error_code)
Translate the high-level part of an Mbed TLS error code into a string representation.
Build-time configuration info.
const char * mbedtls_low_level_strerr(int error_code)
Translate the low-level part of an Mbed TLS error code into a string representation.