Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers error.h Source File

error.h

00001 /**
00002  * \file error.h
00003  *
00004  * \brief Error to string translation
00005  */
00006 /*
00007  *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
00008  *  SPDX-License-Identifier: Apache-2.0
00009  *
00010  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
00011  *  not use this file except in compliance with the License.
00012  *  You may obtain a copy of the License at
00013  *
00014  *  http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  *  Unless required by applicable law or agreed to in writing, software
00017  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00018  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  *  See the License for the specific language governing permissions and
00020  *  limitations under the License.
00021  *
00022  *  This file is part of mbed TLS (https://tls.mbed.org)
00023  */
00024 #ifndef MBEDTLS_ERROR_H
00025 #define MBEDTLS_ERROR_H
00026 
00027 #include <stddef.h>
00028 
00029 /**
00030  * Error code layout.
00031  *
00032  * Currently we try to keep all error codes within the negative space of 16
00033  * bits signed integers to support all platforms (-0x0001 - -0x7FFF). In
00034  * addition we'd like to give two layers of information on the error if
00035  * possible.
00036  *
00037  * For that purpose the error codes are segmented in the following manner:
00038  *
00039  * 16 bit error code bit-segmentation
00040  *
00041  * 1 bit  - Unused (sign bit)
00042  * 3 bits - High level module ID
00043  * 5 bits - Module-dependent error code
00044  * 7 bits - Low level module errors
00045  *
00046  * For historical reasons, low-level error codes are divided in even and odd,
00047  * even codes were assigned first, and -1 is reserved for other errors.
00048  *
00049  * Low-level module errors (0x0002-0x007E, 0x0003-0x007F)
00050  *
00051  * Module   Nr  Codes assigned
00052  * MPI       7  0x0002-0x0010
00053  * GCM       3  0x0012-0x0014   0x0013-0x0013
00054  * BLOWFISH  3  0x0016-0x0018   0x0017-0x0017
00055  * THREADING 3  0x001A-0x001E
00056  * AES       4  0x0020-0x0022   0x0023-0x0025
00057  * CAMELLIA  3  0x0024-0x0026   0x0027-0x0027
00058  * XTEA      2  0x0028-0x0028   0x0029-0x0029
00059  * BASE64    2  0x002A-0x002C
00060  * OID       1  0x002E-0x002E   0x000B-0x000B
00061  * PADLOCK   1  0x0030-0x0030
00062  * DES       2  0x0032-0x0032   0x0033-0x0033
00063  * CTR_DBRG  4  0x0034-0x003A
00064  * ENTROPY   3  0x003C-0x0040   0x003D-0x003F
00065  * NET      11  0x0042-0x0052   0x0043-0x0045
00066  * ASN1      7  0x0060-0x006C
00067  * CMAC      1  0x007A-0x007A
00068  * PBKDF2    1  0x007C-0x007C
00069  * HMAC_DRBG 4                  0x0003-0x0009
00070  * CCM       3                  0x000D-0x0011
00071  * ARC4      1                  0x0019-0x0019
00072  * MD2       1                  0x002B-0x002B
00073  * MD4       1                  0x002D-0x002D
00074  * MD5       1                  0x002F-0x002F
00075  * RIPEMD160 1                  0x0031-0x0031
00076  * SHA1      1                  0x0035-0x0035
00077  * SHA256    1                  0x0037-0x0037
00078  * SHA512    1                  0x0039-0x0039
00079  *
00080  * High-level module nr (3 bits - 0x0...-0x7...)
00081  * Name      ID  Nr of Errors
00082  * PEM       1   9
00083  * PKCS#12   1   4 (Started from top)
00084  * X509      2   20
00085  * PKCS5     2   4 (Started from top)
00086  * DHM       3   11
00087  * PK        3   15 (Started from top)
00088  * RSA       4   11
00089  * ECP       4   9 (Started from top)
00090  * MD        5   5
00091  * CIPHER    6   8
00092  * SSL       6   17 (Started from top)
00093  * SSL       7   31
00094  *
00095  * Module dependent error code (5 bits 0x.00.-0x.F8.)
00096  */
00097 
00098 #ifdef __cplusplus
00099 extern "C" {
00100 #endif
00101 
00102 /**
00103  * \brief Translate a mbed TLS error code into a string representation,
00104  *        Result is truncated if necessary and always includes a terminating
00105  *        null byte.
00106  *
00107  * \param errnum    error code
00108  * \param buffer    buffer to place representation in
00109  * \param buflen    length of the buffer
00110  */
00111 void mbedtls_strerror( int errnum, char *buffer, size_t buflen );
00112 
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116 
00117 #endif /* error.h */