sns_silib.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. /*!
  35. @file
  36. @brief This file contains all of the enums and definitions that are used for the
  37. CryptoCell Lib init and finish APIs, as well as the APIs themselves.
  38. @defgroup sns_silib CryptoCell library basic APIs
  39. @{
  40. @ingroup cryptocell_api
  41. */
  42. #ifndef __SNS_SILIB_H__
  43. #define __SNS_SILIB_H__
  44. #include "ssi_pal_types.h"
  45. #include "crys_rnd.h"
  46. #ifdef __cplusplus
  47. extern "C"
  48. {
  49. #endif
  50. /*! Definitions for error returns from SaSi_LibInit or SaSi_LibFini functions. */
  51. typedef enum {
  52. SA_SILIB_RET_OK = 0, /*!< Success defintion.*/
  53. SA_SILIB_RET_EINVAL_CTX_PTR, /*!< Illegal context pointer.*/
  54. SA_SILIB_RET_EINVAL_WORK_BUF_PTR, /*!< Illegal work buffer pointer.*/
  55. SA_SILIB_RET_HAL, /*!< Error returned from HAL layer.*/
  56. SA_SILIB_RET_PAL, /*!< Error returned from PAL layer.*/
  57. SA_SILIB_RET_EINVAL_HW_VERSION, /*!< Invalid HW version. */
  58. SA_SILIB_RET_EINVAL_HW_SIGNATURE, /*!< Invalid HW signature. */
  59. SA_SILIB_RESERVE32B = 0x7FFFFFFFL /*!< Reserved.*/
  60. } SA_SilibRetCode_t;
  61. /*! Internal defintion for the product register. */
  62. #define DX_VERSION_PRODUCT_BIT_SHIFT 0x18UL
  63. /*! Internal defintion for the product register size. */
  64. #define DX_VERSION_PRODUCT_BIT_SIZE 0x8UL
  65. /*!
  66. @brief This function Perform global initialization of the ARM CryptoCell 3xx runtime library;
  67. it must be called once per ARM CryptoCell for 3xx cold boot cycle.
  68. \note The Mutexes, if used, are initialized by this API. Therefore, unlike the other APIs in the library,
  69. this API is not thread-safe.
  70. @return SA_SILIB_RET_OK on success.
  71. @return A non-zero value in case of failure.
  72. */
  73. SA_SilibRetCode_t SaSi_LibInit(void);
  74. /*!
  75. @brief This function finalize the library operations. It frees the associated resources (mutexes) and call hal and pal terminate functions.
  76. in case of active instansiation - one must call CRYS_RND_UnInstantiation to clean the rnd state.
  77. */
  78. void SaSi_LibFini(void);
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. /**
  83. @}
  84. */
  85. #endif /*__DX_CCLIB_H__*/