crys_error.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /**************************************************************************************
  2. * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
  3. * *
  4. * This file and the related binary are licensed under the following license: *
  5. * *
  6. * ARM Object Code and Header Files License, v1.0 Redistribution. *
  7. * *
  8. * Redistribution and use of object code, header files, and documentation, without *
  9. * modification, are permitted provided that the following conditions are met: *
  10. * *
  11. * 1) Redistributions must reproduce the above copyright notice and the *
  12. * following disclaimer in the documentation and/or other materials *
  13. * provided with the distribution. *
  14. * *
  15. * 2) Unless to the extent explicitly permitted by law, no reverse *
  16. * engineering, decompilation, or disassembly of is permitted. *
  17. * *
  18. * 3) Redistribution and use is permitted solely for the purpose of *
  19. * developing or executing applications that are targeted for use *
  20. * on an ARM-based product. *
  21. * *
  22. * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
  23. * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
  24. * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
  25. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
  26. * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
  28. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
  33. **************************************************************************************/
  34. #ifndef CRYS_ERROR_H
  35. #define CRYS_ERROR_H
  36. #include "ssi_pal_types.h"
  37. #ifdef __cplusplus
  38. extern "C"
  39. {
  40. #endif
  41. /*! @file
  42. @brief This module defines the error return code types and the numbering spaces of the error codes
  43. for each module of the layers listed below.
  44. @defgroup crys_error CryptoCell general base error codes
  45. @{
  46. @ingroup cryptocell_api
  47. */
  48. /*! The definitions of the error number space used for the different modules */
  49. /* ........... Error base numeric mapping definitions ................... */
  50. /* ----------------------------------------------------------------------- */
  51. /*! CRYS error base number. */
  52. #define CRYS_ERROR_BASE 0x00F00000UL
  53. /*! Error range number assigned for each layer. */
  54. #define CRYS_ERROR_LAYER_RANGE 0x00010000UL
  55. /*! Error range number assigned to each module on its specified layer. */
  56. #define CRYS_ERROR_MODULE_RANGE 0x00000100UL
  57. /* Defines the layer index for the error mapping. */
  58. /*! CRYS error layer index. */
  59. #define CRYS_LAYER_ERROR_IDX 0x00UL
  60. /*! Low level functions error layer index. */
  61. #define LLF_LAYER_ERROR_IDX 0x01UL
  62. /*! Generic error layer index. */
  63. #define GENERIC_ERROR_IDX 0x05UL
  64. /* Defines the module index for error mapping */
  65. /*! AES error index.*/
  66. #define AES_ERROR_IDX 0x00UL
  67. /*! DES error index.*/
  68. #define DES_ERROR_IDX 0x01UL
  69. /*! HASH error index.*/
  70. #define HASH_ERROR_IDX 0x02UL
  71. /*! HMAC error index.*/
  72. #define HMAC_ERROR_IDX 0x03UL
  73. /*! RSA error index.*/
  74. #define RSA_ERROR_IDX 0x04UL
  75. /*! DH error index.*/
  76. #define DH_ERROR_IDX 0x05UL
  77. /*! ECPKI error index.*/
  78. #define ECPKI_ERROR_IDX 0x08UL
  79. /*! RND error index.*/
  80. #define RND_ERROR_IDX 0x0CUL
  81. /*! Common error index.*/
  82. #define COMMON_ERROR_IDX 0x0DUL
  83. /*! KDF error index.*/
  84. #define KDF_ERROR_IDX 0x11UL
  85. /*! HKDF error index.*/
  86. #define HKDF_ERROR_IDX 0x12UL
  87. /*! AESCCM error index.*/
  88. #define AESCCM_ERROR_IDX 0x15UL
  89. /*! FIPS error index.*/
  90. #define FIPS_ERROR_IDX 0x17UL
  91. /*! PKA error index.*/
  92. #define PKA_MODULE_ERROR_IDX 0x21UL
  93. /*! CHACHA error index.*/
  94. #define CHACHA_ERROR_IDX 0x22UL
  95. /*! EC montgomery and edwards error index.*/
  96. #define EC_MONT_EDW_ERROR_IDX 0x23UL
  97. /*! CHACHA POLY error index.*/
  98. #define CHACHA_POLY_ERROR_IDX 0x24UL
  99. /*! POLY error index.*/
  100. #define POLY_ERROR_IDX 0x25UL
  101. /*! SRP error index.*/
  102. #define SRP_ERROR_IDX 0x26UL
  103. /* .......... defining the error spaces for each module on each layer ........... */
  104. /* ------------------------------------------------------------------------------ */
  105. /*! AES module error base address - 0x00F00000. */
  106. #define CRYS_AES_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  107. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  108. (CRYS_ERROR_MODULE_RANGE * AES_ERROR_IDX ) )
  109. /*! DES module error base address - 0x00F00100. */
  110. #define CRYS_DES_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  111. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  112. (CRYS_ERROR_MODULE_RANGE * DES_ERROR_IDX ) )
  113. /*! HASH module error base address - 0x00F00200. */
  114. #define CRYS_HASH_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  115. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  116. (CRYS_ERROR_MODULE_RANGE * HASH_ERROR_IDX ) )
  117. /*! HMAC module error base address - 0x00F00300. */
  118. #define CRYS_HMAC_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  119. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  120. (CRYS_ERROR_MODULE_RANGE * HMAC_ERROR_IDX ) )
  121. /*! RSA module error base address - 0x00F00400. */
  122. #define CRYS_RSA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  123. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  124. (CRYS_ERROR_MODULE_RANGE * RSA_ERROR_IDX ) )
  125. /*! DH module error base address - 0x00F00500. */
  126. #define CRYS_DH_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  127. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  128. (CRYS_ERROR_MODULE_RANGE * DH_ERROR_IDX ) )
  129. /*! ECPKI module error base address - 0x00F00800. */
  130. #define CRYS_ECPKI_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  131. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  132. (CRYS_ERROR_MODULE_RANGE * ECPKI_ERROR_IDX ) )
  133. /*! Low level ECPKI module error base address - 0x00F10800. */
  134. #define LLF_ECPKI_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  135. (CRYS_ERROR_LAYER_RANGE * LLF_LAYER_ERROR_IDX) + \
  136. (CRYS_ERROR_MODULE_RANGE * ECPKI_ERROR_IDX ) )
  137. /*! RND module error base address - 0x00F00C00. */
  138. #define CRYS_RND_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  139. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  140. (CRYS_ERROR_MODULE_RANGE * RND_ERROR_IDX ) )
  141. /*! Low level RND module error base address - 0x00F10C00. */
  142. #define LLF_RND_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  143. (CRYS_ERROR_LAYER_RANGE * LLF_LAYER_ERROR_IDX) + \
  144. (CRYS_ERROR_MODULE_RANGE * RND_ERROR_IDX ) )
  145. /*! COMMMON module error base address - 0x00F00D00. */
  146. #define CRYS_COMMON_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  147. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  148. (CRYS_ERROR_MODULE_RANGE * COMMON_ERROR_IDX ) )
  149. /*! KDF module error base address - 0x00F01100. */
  150. #define CRYS_KDF_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  151. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  152. (CRYS_ERROR_MODULE_RANGE * KDF_ERROR_IDX ) )
  153. /*! HKDF module error base address - 0x00F01100. */
  154. #define CRYS_HKDF_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  155. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  156. (CRYS_ERROR_MODULE_RANGE * HKDF_ERROR_IDX ) )
  157. /*! AESCCM module error base address - 0x00F01500. */
  158. #define CRYS_AESCCM_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  159. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  160. (CRYS_ERROR_MODULE_RANGE * AESCCM_ERROR_IDX ) )
  161. /*! FIPS module error base address - 0x00F01700. */
  162. #define CRYS_FIPS_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  163. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  164. (CRYS_ERROR_MODULE_RANGE * FIPS_ERROR_IDX ) )
  165. /*! PKA module error base address - 0x00F02100. */
  166. #define PKA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  167. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  168. (CRYS_ERROR_MODULE_RANGE * PKA_MODULE_ERROR_IDX ) )
  169. /*! CHACHA module error base address - 0x00F02200. */
  170. #define CRYS_CHACHA_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  171. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  172. (CRYS_ERROR_MODULE_RANGE * CHACHA_ERROR_IDX ) )
  173. /*! CHACHA POLY module error base address - 0x00F02400. */
  174. #define CRYS_CHACHA_POLY_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  175. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  176. (CRYS_ERROR_MODULE_RANGE * CHACHA_POLY_ERROR_IDX ) )
  177. /*! POLY module error base address - 0x00F02500. */
  178. #define CRYS_POLY_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  179. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  180. (CRYS_ERROR_MODULE_RANGE * POLY_ERROR_IDX ) )
  181. /*! SRP module error base address - 0x00F02600. */
  182. #define CRYS_SRP_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  183. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  184. (CRYS_ERROR_MODULE_RANGE * SRP_ERROR_IDX ) )
  185. /*! EC MONT_EDW module error base address - 0x00F02300. */
  186. #define CRYS_EC_MONT_EDW_MODULE_ERROR_BASE (CRYS_ERROR_BASE + \
  187. (CRYS_ERROR_LAYER_RANGE * CRYS_LAYER_ERROR_IDX) + \
  188. (CRYS_ERROR_MODULE_RANGE * EC_MONT_EDW_ERROR_IDX ) )
  189. /*! User generic error base address - 0x00F50000 */
  190. #define GENERIC_ERROR_BASE ( CRYS_ERROR_BASE + (CRYS_ERROR_LAYER_RANGE * GENERIC_ERROR_IDX) )
  191. /*! CRYS fatal error. */
  192. #define CRYS_FATAL_ERROR (GENERIC_ERROR_BASE + 0x00UL)
  193. /*! CRYS out of resources error. */
  194. #define CRYS_OUT_OF_RESOURCE_ERROR (GENERIC_ERROR_BASE + 0x01UL)
  195. /*! CRYS illegal resource value error. */
  196. #define CRYS_ILLEGAL_RESOURCE_VAL_ERROR (GENERIC_ERROR_BASE + 0x02UL)
  197. /* ............ The OK (success) definition ....................... */
  198. /*! Success defintion. */
  199. #define CRYS_OK 0
  200. /*! MACRO that defines crys return value. */
  201. #define SASI_CRYS_RETURN_ERROR(retCode, retcodeInfo, funcHandler) \
  202. ((retCode) == 0 ? CRYS_OK : funcHandler(retCode, retcodeInfo))
  203. /************************ Enums ********************************/
  204. /************************ Typedefs ****************************/
  205. /*! The typedef definition of all of the error codes that are returned from the CRYS functions */
  206. typedef uint32_t CRYSError_t;
  207. /************************ Structs ******************************/
  208. /************************ Public Variables **********************/
  209. /************************ Public Functions **********************/
  210. #ifdef __cplusplus
  211. }
  212. #endif
  213. /**
  214. @}
  215. */
  216. #endif