mbed TLS library

Dependents:   HTTPClient-SSL WS_SERVER

Committer:
ansond
Date:
Thu Jun 11 03:27:03 2015 +0000
Revision:
0:137634ff4186
initial commit

Who changed what in which revision?

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