|
|
|||
File indexing completed on 2026-05-10 08:44:50
0001 /** 0002 * \file error_common.h 0003 * 0004 * \brief Error codes 0005 */ 0006 /* 0007 * Copyright The Mbed TLS Contributors 0008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 0009 */ 0010 #ifndef MBEDTLS_ERROR_COMMON_H 0011 #define MBEDTLS_ERROR_COMMON_H 0012 0013 #include "tf-psa-crypto/build_info.h" 0014 #include <psa/crypto_values.h> 0015 #include <stddef.h> 0016 0017 #ifdef __cplusplus 0018 extern "C" { 0019 #endif 0020 0021 /* Generic error */ 0022 #define MBEDTLS_ERR_ERROR_GENERIC_ERROR PSA_ERROR_GENERIC_ERROR 0023 /* This is a bug in the library */ 0024 #define MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED PSA_ERROR_CORRUPTION_DETECTED 0025 0026 /* Hardware accelerator failed */ 0027 #define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED PSA_ERROR_HARDWARE_FAILURE 0028 /* The requested feature is not supported by the platform */ 0029 #define MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED PSA_ERROR_NOT_SUPPORTED 0030 0031 /** 0032 * \brief Combines a high-level and low-level error code together. 0033 * 0034 * Wrapper macro for mbedtls_error_add(). See that function for 0035 * more details. 0036 */ 0037 #define MBEDTLS_ERROR_ADD(high, low) \ 0038 mbedtls_error_add(high, low) 0039 0040 /** 0041 * \brief Combines a high-level and low-level error code together. 0042 * 0043 * This function can be called directly however it is usually 0044 * called via the #MBEDTLS_ERROR_ADD macro. 0045 * 0046 * While a value of zero is not a negative error code, it is still an 0047 * error code (that denotes success) and can be combined with both a 0048 * negative error code or another value of zero. 0049 * 0050 * \note The distinction between low-level and high-level error codes is 0051 * obsolete since TF-PSA-Crypto 1.0 and Mbed TLS 4.0. It is still 0052 * present in the code due to the heritage from Mbed TLS <=3, 0053 * where low-level and high-level error codes could be added. 0054 * New code should not make this distinction and should just 0055 * propagate errors returned by lower-level modules unless there 0056 * is a good reason to report a different error code in the 0057 * higher-level module. 0058 * 0059 * \param high High-level error code, i.e. error code from the module 0060 * that is reporting the error. 0061 * This can be 0 to just propagate a low-level error. 0062 * \param low Low-level error code, i.e. error code returned by 0063 * a lower-level function. 0064 * This can be 0 to just return a high-level error. 0065 */ 0066 static inline int mbedtls_error_add(int high, int low) 0067 { 0068 /* We give priority to the lower-level error code, because this 0069 * is usually the right choice. For example, if a low-level module 0070 * runs out of memory, this should not be converted to a high-level 0071 * error code such as invalid-signature. */ 0072 return low ? low : high; 0073 } 0074 0075 #ifdef __cplusplus 0076 } 0077 #endif 0078 0079 #endif /* error_common.h */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|