4 * \brief Error to string translation
\r
7 * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved
\r
8 * SPDX-License-Identifier: Apache-2.0
\r
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
\r
11 * not use this file except in compliance with the License.
\r
12 * You may obtain a copy of the License at
\r
14 * http://www.apache.org/licenses/LICENSE-2.0
\r
16 * Unless required by applicable law or agreed to in writing, software
\r
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
\r
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
19 * See the License for the specific language governing permissions and
\r
20 * limitations under the License.
\r
22 * This file is part of mbed TLS (https://tls.mbed.org)
\r
24 #ifndef MBEDTLS_ERROR_H
\r
25 #define MBEDTLS_ERROR_H
\r
27 #if !defined(MBEDTLS_CONFIG_FILE)
\r
30 #include MBEDTLS_CONFIG_FILE
\r
36 * Error code layout.
\r
38 * Currently we try to keep all error codes within the negative space of 16
\r
39 * bits signed integers to support all platforms (-0x0001 - -0x7FFF). In
\r
40 * addition we'd like to give two layers of information on the error if
\r
43 * For that purpose the error codes are segmented in the following manner:
\r
45 * 16 bit error code bit-segmentation
\r
47 * 1 bit - Unused (sign bit)
\r
48 * 3 bits - High level module ID
\r
49 * 5 bits - Module-dependent error code
\r
50 * 7 bits - Low level module errors
\r
52 * For historical reasons, low-level error codes are divided in even and odd,
\r
53 * even codes were assigned first, and -1 is reserved for other errors.
\r
55 * Low-level module errors (0x0002-0x007E, 0x0003-0x007F)
\r
57 * Module Nr Codes assigned
\r
58 * MPI 7 0x0002-0x0010
\r
59 * GCM 3 0x0012-0x0014 0x0013-0x0013
\r
60 * BLOWFISH 3 0x0016-0x0018 0x0017-0x0017
\r
61 * THREADING 3 0x001A-0x001E
\r
62 * AES 5 0x0020-0x0022 0x0021-0x0025
\r
63 * CAMELLIA 3 0x0024-0x0026 0x0027-0x0027
\r
64 * XTEA 2 0x0028-0x0028 0x0029-0x0029
\r
65 * BASE64 2 0x002A-0x002C
\r
66 * OID 1 0x002E-0x002E 0x000B-0x000B
\r
67 * PADLOCK 1 0x0030-0x0030
\r
68 * DES 2 0x0032-0x0032 0x0033-0x0033
\r
69 * CTR_DBRG 4 0x0034-0x003A
\r
70 * ENTROPY 3 0x003C-0x0040 0x003D-0x003F
\r
71 * NET 13 0x0042-0x0052 0x0043-0x0049
\r
72 * ARIA 4 0x0058-0x005E
\r
73 * ASN1 7 0x0060-0x006C
\r
74 * CMAC 1 0x007A-0x007A
\r
75 * PBKDF2 1 0x007C-0x007C
\r
76 * HMAC_DRBG 4 0x0003-0x0009
\r
77 * CCM 3 0x000D-0x0011
\r
78 * ARC4 1 0x0019-0x0019
\r
79 * MD2 1 0x002B-0x002B
\r
80 * MD4 1 0x002D-0x002D
\r
81 * MD5 1 0x002F-0x002F
\r
82 * RIPEMD160 1 0x0031-0x0031
\r
83 * SHA1 1 0x0035-0x0035 0x0073-0x0073
\r
84 * SHA256 1 0x0037-0x0037 0x0074-0x0074
\r
85 * SHA512 1 0x0039-0x0039 0x0075-0x0075
\r
86 * CHACHA20 3 0x0051-0x0055
\r
87 * POLY1305 3 0x0057-0x005B
\r
88 * CHACHAPOLY 2 0x0054-0x0056
\r
89 * PLATFORM 1 0x0070-0x0072
\r
91 * High-level module nr (3 bits - 0x0...-0x7...)
\r
92 * Name ID Nr of Errors
\r
94 * PKCS#12 1 4 (Started from top)
\r
96 * PKCS5 2 4 (Started from top)
\r
98 * PK 3 15 (Started from top)
\r
100 * ECP 4 10 (Started from top)
\r
102 * HKDF 5 1 (Started from top)
\r
103 * CIPHER 6 8 (Started from 0x6080)
\r
104 * SSL 6 24 (Started from top, plus 0x6000)
\r
107 * Module dependent error code (5 bits 0x.00.-0x.F8.)
\r
115 * \brief Translate a mbed TLS error code into a string representation,
\r
116 * Result is truncated if necessary and always includes a terminating
\r
119 * \param errnum error code
\r
120 * \param buffer buffer to place representation in
\r
121 * \param buflen length of the buffer
\r
123 void mbedtls_strerror( int errnum, char *buffer, size_t buflen );
\r
129 #endif /* error.h */
\r