crys_ecpki_ecdsa.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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_ECPKI_ECDSA_H
  35. #define CRYS_ECPKI_ECDSA_H
  36. /*!
  37. @file
  38. @brief Defines the APIs that support the ECDSA functions.
  39. @defgroup crys_ecpki_ecdsa CryptoCell ECDSA APIs
  40. @{
  41. @ingroup cryptocell_ecpki
  42. */
  43. #include "crys_error.h"
  44. #include "crys_ecpki_types.h"
  45. #include "crys_hash.h"
  46. #include "crys_rnd.h"
  47. #ifdef __cplusplus
  48. extern "C"
  49. {
  50. #endif
  51. /**************************************************************************
  52. * CRYS_ECDSA_Sign - integrated function
  53. **************************************************************************/
  54. /*!
  55. @brief This function performs an ECDSA sign operation in integrated form.
  56. \note
  57. Using of HASH functions with HASH size greater than EC modulus size, is not recommended!.
  58. Algorithm according [ANS X9.62] standard.
  59. The message data may be either a non-hashed data or a digest of a hash function.
  60. For a non-hashed data, the message data will be hashed using the hash function indicated by ::CRYS_ECPKI_HASH_OpMode_t.
  61. For a digest, ::CRYS_ECPKI_HASH_OpMode_t should indicate the hash function that the message data was created by, and it will not be hashed.
  62. @return CRYS_OK on success.
  63. @return A non-zero value on failure as defined crys_ecpki_error.h, crys_hash_error.h or crys_rnd_error.h.
  64. **/
  65. CIMPORT_C CRYSError_t CRYS_ECDSA_Sign(
  66. void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */
  67. SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */
  68. CRYS_ECDSA_SignUserContext_t *pSignUserContext, /*!< [in/out] Pointer to the user buffer for signing the database. */
  69. CRYS_ECPKI_UserPrivKey_t *pSignerPrivKey, /*!< [in] A pointer to a user private key structure. */
  70. CRYS_ECPKI_HASH_OpMode_t hashMode, /*!< [in] One of the supported SHA-x HASH modes, as defined in
  71. ::CRYS_ECPKI_HASH_OpMode_t.
  72. \note MD5 is not supported. */
  73. uint8_t *pMessageDataIn, /*!< [in] Pointer to the input data to be signed.
  74. The size of the scatter/gather list representing the data buffer
  75. is limited to 128 entries, and the size of each entry is limited
  76. to 64KB (fragments larger than 64KB are broken into
  77. fragments <= 64KB). */
  78. uint32_t messageSizeInBytes, /*!< [in] Size of message data in bytes. */
  79. uint8_t *pSignatureOut, /*!< [in] Pointer to a buffer for output of signature. */
  80. uint32_t *pSignatureOutSize /*!< [in/out] Pointer to the signature size. Used to pass the size of
  81. the SignatureOut buffer (in), which must be >= 2
  82. * OrderSizeInBytes. When the API returns,
  83. it is replaced with the size of the actual signature (out). */
  84. );
  85. /**************************************************************************
  86. * CRYS_ECDSA_Verify integrated function
  87. **************************************************************************/
  88. /*!
  89. @brief This function performs an ECDSA verify operation in integrated form.
  90. Algorithm according [ANS X9.62] standard.
  91. The message data may be either a non-hashed data or a digest of a hash function.
  92. For a non-hashed data, the message data will be hashed using the hash function indicated by ::CRYS_ECPKI_HASH_OpMode_t.
  93. For a digest, ::CRYS_ECPKI_HASH_OpMode_t should indicate the hash function that the message data was created by, and it will not be hashed.
  94. @return CRYS_OK on success.
  95. @return A non-zero value on failure as defined crys_ecpki_error.h or crys_hash_error.h.
  96. */
  97. CIMPORT_C CRYSError_t CRYS_ECDSA_Verify (
  98. CRYS_ECDSA_VerifyUserContext_t *pVerifyUserContext, /*!< [in] Pointer to the user buffer for signing the database. */
  99. CRYS_ECPKI_UserPublKey_t *pUserPublKey, /*!< [in] Pointer to a user public key structure. */
  100. CRYS_ECPKI_HASH_OpMode_t hashMode, /*!< [in] One of the supported SHA-x HASH modes, as defined in
  101. ::CRYS_ECPKI_HASH_OpMode_t.
  102. \note MD5 is not supported. */
  103. uint8_t *pSignatureIn, /*!< [in] Pointer to the signature to be verified. */
  104. uint32_t SignatureSizeBytes, /*!< [in] Size of the signature (in bytes). */
  105. uint8_t *pMessageDataIn, /*!< [in] Pointer to the input data that was signed (same as given to
  106. the signing function). The size of the scatter/gather list representing
  107. the data buffer is limited to 128 entries, and the size of each entry is
  108. limited to 64KB (fragments larger than 64KB are broken into fragments <= 64KB). */
  109. uint32_t messageSizeInBytes /*!< [in] Size of the input data (in bytes). */
  110. );
  111. /**********************************************************************************************************/
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115. /**
  116. @}
  117. */
  118. #endif