Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers error.h Source File

error.h

Go to the documentation of this file.
00001 /**
00002  * \file error.h
00003  *
00004  * \brief Error to string translation
00005  */
00006 /*
00007  *  Copyright (C) 2006-2018, 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 #if !defined(MBEDTLS_CONFIG_FILE)
00028 #include "mbedtls/config.h"
00029 #else
00030 #include MBEDTLS_CONFIG_FILE
00031 #endif
00032 
00033 #include <stddef.h>
00034 
00035 /**
00036  * Error code layout.
00037  *
00038  * Currently we try to keep all error codes within the negative space of 16
00039  * bits signed integers to support all platforms (-0x0001 - -0x7FFF). In
00040  * addition we'd like to give two layers of information on the error if
00041  * possible.
00042  *
00043  * For that purpose the error codes are segmented in the following manner:
00044  *
00045  * 16 bit error code bit-segmentation
00046  *
00047  * 1 bit  - Unused (sign bit)
00048  * 3 bits - High level module ID
00049  * 5 bits - Module-dependent error code
00050  * 7 bits - Low level module errors
00051  *
00052  * For historical reasons, low-level error codes are divided in even and odd,
00053  * even codes were assigned first, and -1 is reserved for other errors.
00054  *
00055  * Low-level module errors (0x0002-0x007E, 0x0003-0x007F)
00056  *
00057  * Module   Nr  Codes assigned
00058  * MPI       7  0x0002-0x0010
00059  * GCM       3  0x0012-0x0014   0x0013-0x0013
00060  * BLOWFISH  3  0x0016-0x0018   0x0017-0x0017
00061  * THREADING 3  0x001A-0x001E
00062  * AES       5  0x0020-0x0022   0x0021-0x0025
00063  * CAMELLIA  3  0x0024-0x0026   0x0027-0x0027
00064  * XTEA      2  0x0028-0x0028   0x0029-0x0029
00065  * BASE64    2  0x002A-0x002C
00066  * OID       1  0x002E-0x002E   0x000B-0x000B
00067  * PADLOCK   1  0x0030-0x0030
00068  * DES       2  0x0032-0x0032   0x0033-0x0033
00069  * CTR_DBRG  4  0x0034-0x003A
00070  * ENTROPY   3  0x003C-0x0040   0x003D-0x003F
00071  * NET      13  0x0042-0x0052   0x0043-0x0049
00072  * ARIA      4  0x0058-0x005E
00073  * ASN1      7  0x0060-0x006C
00074  * CMAC      1  0x007A-0x007A
00075  * PBKDF2    1  0x007C-0x007C
00076  * HMAC_DRBG 4                  0x0003-0x0009
00077  * CCM       3                  0x000D-0x0011
00078  * ARC4      1                  0x0019-0x0019
00079  * MD2       1                  0x002B-0x002B
00080  * MD4       1                  0x002D-0x002D
00081  * MD5       1                  0x002F-0x002F
00082  * RIPEMD160 1                  0x0031-0x0031
00083  * SHA1      1                  0x0035-0x0035 0x0073-0x0073
00084  * SHA256    1                  0x0037-0x0037 0x0074-0x0074
00085  * SHA512    1                  0x0039-0x0039 0x0075-0x0075
00086  * CHACHA20  3                  0x0051-0x0055
00087  * POLY1305  3                  0x0057-0x005B
00088  * CHACHAPOLY 2 0x0054-0x0056
00089  * PLATFORM  1  0x0070-0x0072
00090  *
00091  * High-level module nr (3 bits - 0x0...-0x7...)
00092  * Name      ID  Nr of Errors
00093  * PEM       1   9
00094  * PKCS#12   1   4 (Started from top)
00095  * X509      2   20
00096  * PKCS5     2   4 (Started from top)
00097  * DHM       3   11
00098  * PK        3   15 (Started from top)
00099  * RSA       4   11
00100  * ECP       4   10 (Started from top)
00101  * MD        5   5
00102  * HKDF      5   1 (Started from top)
00103  * SSL       5   1 (Started from 0x5F00)
00104  * CIPHER    6   8 (Started from 0x6080)
00105  * SSL       6   24 (Started from top, plus 0x6000)
00106  * SSL       7   32
00107  *
00108  * Module dependent error code (5 bits 0x.00.-0x.F8.)
00109  */
00110 
00111 #ifdef __cplusplus
00112 extern "C" {
00113 #endif
00114 
00115 /**
00116  * \brief Translate a mbed TLS error code into a string representation,
00117  *        Result is truncated if necessary and always includes a terminating
00118  *        null byte.
00119  *
00120  * \param errnum    error code
00121  * \param buffer    buffer to place representation in
00122  * \param buflen    length of the buffer
00123  */
00124 void mbedtls_strerror( int errnum, char *buffer, size_t buflen );
00125 
00126 #ifdef __cplusplus
00127 }
00128 #endif
00129 
00130 #endif /* error.h */