4 * \brief Error to string translation
6 * Copyright (C) 2006-2013, ARM Limited, All Rights Reserved
8 * This file is part of mbed TLS (https://polarssl.org)
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.
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.
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.
24 #ifndef POLARSSL_ERROR_H
25 #define POLARSSL_ERROR_H
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
37 * For that purpose the error codes are segmented in the following manner:
39 * 16 bit error code bit-segmentation
42 * 3 bits - High level module ID
43 * 5 bits - Module-dependent error code
44 * 7 bits - Low level module errors
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.
49 * Low-level module errors (0x0002-0x007E, 0x0003-0x007F)
51 * Module Nr Codes assigned
54 * BLOWFISH 2 0x0016-0x0018
55 * THREADING 3 0x001A-0x001E
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
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
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
79 * High-level module nr (3 bits - 0x0...-0x7...)
80 * Name ID Nr of Errors
82 * PKCS#12 1 4 (Started from top)
84 * PK 2 14 (Started from top, plus 0x2000)
86 * PKCS5 3 4 (Started from top)
88 * ECP 4 8 (Started from top)
91 * SSL 6 11 (Started from top)
94 * Module dependent error code (5 bits 0x.00.-0x.F8.)
102 * \brief Translate a mbed TLS error code into a string representation,
103 * Result is truncated if necessary and always includes a terminating
106 * \param errnum error code
107 * \param buffer buffer to place representation in
108 * \param buflen length of the buffer
110 void polarssl_strerror( int errnum
, char *buffer
, size_t buflen
);
112 #if defined(POLARSSL_ERROR_STRERROR_BC)
113 void error_strerror( int errnum
, char *buffer
, size_t buflen
);