bcda3203d1da9e7686b3c7e24752f740622bda71
[reactos.git] / reactos / sdk / include / reactos / libs / mbedtls / error.h
1 /**
2 * \file error.h
3 *
4 * \brief Error to string translation
5 *
6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: GPL-2.0
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * This file is part of mbed TLS (https://tls.mbed.org)
24 */
25 #ifndef MBEDTLS_ERROR_H
26 #define MBEDTLS_ERROR_H
27
28 #include <stddef.h>
29
30 /**
31 * Error code layout.
32 *
33 * Currently we try to keep all error codes within the negative space of 16
34 * bits signed integers to support all platforms (-0x0001 - -0x7FFF). In
35 * addition we'd like to give two layers of information on the error if
36 * possible.
37 *
38 * For that purpose the error codes are segmented in the following manner:
39 *
40 * 16 bit error code bit-segmentation
41 *
42 * 1 bit - Unused (sign bit)
43 * 3 bits - High level module ID
44 * 5 bits - Module-dependent error code
45 * 7 bits - Low level module errors
46 *
47 * For historical reasons, low-level error codes are divided in even and odd,
48 * even codes were assigned first, and -1 is reserved for other errors.
49 *
50 * Low-level module errors (0x0002-0x007E, 0x0003-0x007F)
51 *
52 * Module Nr Codes assigned
53 * MPI 7 0x0002-0x0010
54 * GCM 2 0x0012-0x0014
55 * BLOWFISH 2 0x0016-0x0018
56 * THREADING 3 0x001A-0x001E
57 * AES 2 0x0020-0x0022
58 * CAMELLIA 2 0x0024-0x0026
59 * XTEA 1 0x0028-0x0028
60 * BASE64 2 0x002A-0x002C
61 * OID 1 0x002E-0x002E 0x000B-0x000B
62 * PADLOCK 1 0x0030-0x0030
63 * DES 1 0x0032-0x0032
64 * CTR_DBRG 4 0x0034-0x003A
65 * ENTROPY 3 0x003C-0x0040 0x003D-0x003F
66 * NET 11 0x0042-0x0052 0x0043-0x0045
67 * ASN1 7 0x0060-0x006C
68 * PBKDF2 1 0x007C-0x007C
69 * HMAC_DRBG 4 0x0003-0x0009
70 * CCM 2 0x000D-0x000F
71 *
72 * High-level module nr (3 bits - 0x0...-0x7...)
73 * Name ID Nr of Errors
74 * PEM 1 9
75 * PKCS#12 1 4 (Started from top)
76 * X509 2 19
77 * PKCS5 2 4 (Started from top)
78 * DHM 3 9
79 * PK 3 14 (Started from top)
80 * RSA 4 9
81 * ECP 4 8 (Started from top)
82 * MD 5 4
83 * CIPHER 6 6
84 * SSL 6 17 (Started from top)
85 * SSL 7 31
86 *
87 * Module dependent error code (5 bits 0x.00.-0x.F8.)
88 */
89
90 #ifdef __cplusplus
91 extern "C" {
92 #endif
93
94 /**
95 * \brief Translate a mbed TLS error code into a string representation,
96 * Result is truncated if necessary and always includes a terminating
97 * null byte.
98 *
99 * \param errnum error code
100 * \param buffer buffer to place representation in
101 * \param buflen length of the buffer
102 */
103 void mbedtls_strerror( int errnum, char *buffer, size_t buflen );
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif /* error.h */