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