Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers crys_error.h Source File

crys_error.h

Go to the documentation of this file.
00001 /**************************************************************************************
00002 * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved         *
00003 *                                                                                     *
00004 * This file and the related binary are licensed under the following license:          *
00005 *                                                                                     *
00006 * ARM Object Code and Header Files License, v1.0 Redistribution.                      *
00007 *                                                                                     *
00008 * Redistribution and use of object code, header files, and documentation, without     *
00009 * modification, are permitted provided that the following conditions are met:         *
00010 *                                                                                     *
00011 * 1) Redistributions must reproduce the above copyright notice and the                *
00012 *    following disclaimer in the documentation and/or other materials                 *
00013 *    provided with the distribution.                                                  *
00014 *                                                                                     *
00015 * 2) Unless to the extent explicitly permitted by law, no reverse                     *
00016 *    engineering, decompilation, or disassembly of is permitted.                      *
00017 *                                                                                     *
00018 * 3) Redistribution and use is permitted solely for the purpose of                    *
00019 *    developing or executing applications that are targeted for use                   *
00020 *    on an ARM-based product.                                                         *
00021 *                                                                                     *
00022 * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND                  *
00023 * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT             *
00024 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT,        *
00025 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE          *
00026 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   *
00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED            *
00028 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR              *
00029 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF              *
00030 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING                *
00031 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS                  *
00032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                        *
00033 **************************************************************************************/
00034 
00035 
00036 #ifndef CRYS_ERROR_H
00037 #define CRYS_ERROR_H
00038 
00039 #include "ssi_pal_types.h"
00040 
00041 #ifdef __cplusplus
00042 extern "C"
00043 {
00044 #endif
00045 
00046 /*! @file
00047 @brief This module defines the error return code types and the numbering spaces of the error codes
00048 for each module of the layers listed below.
00049 @defgroup crys_error CryptoCell general base error codes
00050 @{
00051 @ingroup cryptocell_api
00052 */
00053 
00054 /*! The definitions of the error number space used for the different modules */
00055 
00056 /* ........... Error base numeric mapping definitions ................... */
00057 /* ----------------------------------------------------------------------- */
00058 
00059  /*! CRYS error base number. */
00060 #define CRYS_ERROR_BASE          0x00F00000UL
00061 
00062 /*! Error range number assigned for each layer. */
00063 #define CRYS_ERROR_LAYER_RANGE   0x00010000UL
00064 
00065 /*! Error range number assigned to each module on its specified layer. */
00066 #define CRYS_ERROR_MODULE_RANGE  0x00000100UL
00067 
00068 /* Defines the layer index for the error mapping. */
00069 /*! CRYS error layer index. */
00070 #define CRYS_LAYER_ERROR_IDX     0x00UL
00071 /*! Low level functions error layer index. */
00072 #define LLF_LAYER_ERROR_IDX      0x01UL
00073 /*! Generic error layer index. */
00074 #define GENERIC_ERROR_IDX        0x05UL
00075 
00076 /* Defines the module index for error mapping */
00077 /*! AES error index.*/
00078 #define AES_ERROR_IDX            0x00UL
00079 /*! DES error index.*/
00080 #define DES_ERROR_IDX            0x01UL
00081 /*! HASH error index.*/
00082 #define HASH_ERROR_IDX           0x02UL
00083 /*! HMAC error index.*/
00084 #define HMAC_ERROR_IDX           0x03UL
00085 /*! RSA error index.*/
00086 #define RSA_ERROR_IDX            0x04UL
00087 /*! DH error index.*/
00088 #define DH_ERROR_IDX             0x05UL
00089 
00090 /*! ECPKI error index.*/
00091 #define ECPKI_ERROR_IDX          0x08UL
00092 /*! RND error index.*/
00093 #define RND_ERROR_IDX            0x0CUL
00094 /*! Common error index.*/
00095 #define COMMON_ERROR_IDX         0x0DUL
00096 /*! KDF error index.*/
00097 #define KDF_ERROR_IDX            0x11UL
00098 /*! HKDF error index.*/
00099 #define HKDF_ERROR_IDX           0x12UL
00100 /*! AESCCM error index.*/
00101 #define AESCCM_ERROR_IDX         0x15UL
00102 /*! FIPS error index.*/
00103 #define FIPS_ERROR_IDX           0x17UL
00104 
00105 /*! PKA error index.*/
00106 #define PKA_MODULE_ERROR_IDX     0x21UL
00107 /*! CHACHA error index.*/
00108 #define CHACHA_ERROR_IDX         0x22UL
00109 /*! EC montgomery and edwards error index.*/
00110 #define EC_MONT_EDW_ERROR_IDX    0x23UL
00111 /*! CHACHA POLY error index.*/
00112 #define CHACHA_POLY_ERROR_IDX    0x24UL
00113 /*! POLY error index.*/
00114 #define POLY_ERROR_IDX           0x25UL
00115 /*! SRP error index.*/
00116 #define SRP_ERROR_IDX            0x26UL
00117 
00118 
00119 
00120 /* .......... defining the error spaces for each module on each layer ........... */
00121 /* ------------------------------------------------------------------------------ */
00122 
00123 /*! AES module error base address - 0x00F00000. */
00124 #define CRYS_AES_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00125                                      (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00126                                      (CRYS_ERROR_MODULE_RANGE * AES_ERROR_IDX ) )
00127 
00128 /*! DES module error base address - 0x00F00100. */
00129 #define CRYS_DES_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00130                                      (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00131                                      (CRYS_ERROR_MODULE_RANGE * DES_ERROR_IDX ) )
00132 
00133 /*! HASH module error base address - 0x00F00200. */
00134 #define CRYS_HASH_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00135                                      (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00136                                      (CRYS_ERROR_MODULE_RANGE * HASH_ERROR_IDX ) )
00137 
00138 /*! HMAC module error base address - 0x00F00300. */
00139 #define CRYS_HMAC_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00140                                      (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00141                                      (CRYS_ERROR_MODULE_RANGE * HMAC_ERROR_IDX ) )
00142 
00143 /*! RSA module error base address - 0x00F00400. */
00144 #define CRYS_RSA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00145                                    (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00146                                    (CRYS_ERROR_MODULE_RANGE * RSA_ERROR_IDX ) )
00147 
00148 /*! DH module error base address - 0x00F00500. */
00149 #define CRYS_DH_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00150                                    (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00151                                    (CRYS_ERROR_MODULE_RANGE * DH_ERROR_IDX ) )
00152 
00153 /*! ECPKI module error base address - 0x00F00800. */
00154 #define CRYS_ECPKI_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00155                                      (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00156                                      (CRYS_ERROR_MODULE_RANGE * ECPKI_ERROR_IDX ) )
00157 
00158 /*! Low level ECPKI module error base address -  0x00F10800. */
00159 #define LLF_ECPKI_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00160                                      (CRYS_ERROR_LAYER_RANGE * LLF_LAYER_ERROR_IDX) + \
00161                                      (CRYS_ERROR_MODULE_RANGE * ECPKI_ERROR_IDX ) )
00162 
00163 /*! RND module error base address - 0x00F00C00. */
00164 #define CRYS_RND_MODULE_ERROR_BASE   (CRYS_ERROR_BASE + \
00165                                      (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00166                                      (CRYS_ERROR_MODULE_RANGE * RND_ERROR_IDX ) )
00167 
00168 /*! Low level RND module error base address -  0x00F10C00. */
00169 #define LLF_RND_MODULE_ERROR_BASE    (CRYS_ERROR_BASE + \
00170                                      (CRYS_ERROR_LAYER_RANGE * LLF_LAYER_ERROR_IDX) + \
00171                                      (CRYS_ERROR_MODULE_RANGE * RND_ERROR_IDX ) )
00172 
00173 /*! COMMMON module error base address - 0x00F00D00. */
00174 #define CRYS_COMMON_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00175                                      (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00176                                      (CRYS_ERROR_MODULE_RANGE * COMMON_ERROR_IDX ) )
00177 
00178 /*! KDF module error base address - 0x00F01100. */
00179 #define CRYS_KDF_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00180                                   (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00181                                   (CRYS_ERROR_MODULE_RANGE * KDF_ERROR_IDX ) )
00182 
00183 /*! HKDF module error base address - 0x00F01100. */
00184 #define CRYS_HKDF_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00185                                   (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00186                                   (CRYS_ERROR_MODULE_RANGE * HKDF_ERROR_IDX ) )
00187 
00188 /*! AESCCM module error base address - 0x00F01500. */
00189 #define CRYS_AESCCM_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00190                                        (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00191                                        (CRYS_ERROR_MODULE_RANGE * AESCCM_ERROR_IDX ) )
00192 
00193 /*! FIPS module error base address - 0x00F01700. */
00194 #define CRYS_FIPS_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00195                                        (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00196                                        (CRYS_ERROR_MODULE_RANGE * FIPS_ERROR_IDX ) )
00197 
00198 /*! PKA module error base address - 0x00F02100. */
00199 #define PKA_MODULE_ERROR_BASE             (CRYS_ERROR_BASE + \
00200                                            (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00201                                            (CRYS_ERROR_MODULE_RANGE * PKA_MODULE_ERROR_IDX ) )
00202 
00203 /*! CHACHA module error base address - 0x00F02200. */
00204 #define CRYS_CHACHA_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00205                                            (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00206                                            (CRYS_ERROR_MODULE_RANGE * CHACHA_ERROR_IDX ) )
00207 /*! CHACHA POLY module error base address - 0x00F02400. */
00208 #define CRYS_CHACHA_POLY_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00209                                            (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00210                                            (CRYS_ERROR_MODULE_RANGE * CHACHA_POLY_ERROR_IDX ) )
00211 /*! POLY module error base address - 0x00F02500. */
00212 #define CRYS_POLY_MODULE_ERROR_BASE  (CRYS_ERROR_BASE + \
00213                                            (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00214                                            (CRYS_ERROR_MODULE_RANGE * POLY_ERROR_IDX ) )
00215 
00216 /*! SRP module error base address - 0x00F02600. */
00217 #define CRYS_SRP_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00218                                            (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00219                                            (CRYS_ERROR_MODULE_RANGE * SRP_ERROR_IDX ) )
00220 
00221 
00222 /*! EC MONT_EDW module error base address - 0x00F02300.  */
00223 #define CRYS_EC_MONT_EDW_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
00224                                            (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
00225                                            (CRYS_ERROR_MODULE_RANGE * EC_MONT_EDW_ERROR_IDX ) )
00226 
00227 
00228 /*! User generic error base address - 0x00F50000 */
00229 #define GENERIC_ERROR_BASE ( CRYS_ERROR_BASE + (CRYS_ERROR_LAYER_RANGE * GENERIC_ERROR_IDX) )
00230 /*! CRYS fatal error. */
00231 #define CRYS_FATAL_ERROR            (GENERIC_ERROR_BASE + 0x00UL)
00232 /*! CRYS out of resources error. */
00233 #define CRYS_OUT_OF_RESOURCE_ERROR      (GENERIC_ERROR_BASE + 0x01UL)
00234 /*! CRYS illegal resource value error. */
00235 #define CRYS_ILLEGAL_RESOURCE_VAL_ERROR     (GENERIC_ERROR_BASE + 0x02UL)
00236 
00237 
00238 
00239 /* ............ The OK (success) definition ....................... */
00240 /*! Success defintion. */
00241 #define CRYS_OK 0
00242 
00243 /*! MACRO that defines crys return value. */
00244 #define SASI_CRYS_RETURN_ERROR(retCode, retcodeInfo, funcHandler) \
00245     ((retCode) == 0 ? CRYS_OK : funcHandler(retCode, retcodeInfo))
00246 
00247 /************************ Enums ********************************/
00248 
00249 
00250 /************************ Typedefs  ****************************/
00251 
00252 /*! The typedef definition of all of the error codes that are returned from the CRYS functions */
00253 typedef uint32_t CRYSError_t ;
00254 
00255 /************************ Structs  ******************************/
00256 
00257 
00258 /************************ Public Variables **********************/
00259 
00260 
00261 /************************ Public Functions **********************/
00262 
00263 #ifdef __cplusplus
00264 }
00265 #endif
00266 /**
00267 @}
00268  */
00269 #endif
00270 
00271 
00272 
00273