sign.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*############################################################################
  2. # Copyright 2017 Intel Corporation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################*/
  16. /// SDK TPM Sign API.
  17. /*! \file */
  18. #ifndef EPID_MEMBER_TPM2_SIGN_H_
  19. #define EPID_MEMBER_TPM2_SIGN_H_
  20. #include <stddef.h>
  21. #include "epid/common/errors.h"
  22. #include "epid/common/stdtypes.h"
  23. /// \cond
  24. typedef struct Tpm2Ctx Tpm2Ctx;
  25. typedef struct FfElement FfElement;
  26. /// \endcond
  27. /*!
  28. \addtogroup Tpm2Module tpm2
  29. \ingroup EpidMemberModule
  30. @{
  31. */
  32. /// Performs TPM2_Sign TPM command.
  33. /*!
  34. Calculate a pair (k, s) an ECDAA signature.
  35. Private key f must exist in the TPM context.
  36. \param[in] ctx
  37. The TPM context.
  38. \param[in] digest
  39. Digest to be signed.
  40. \param[in] digest_len
  41. The size of digest in bytes.
  42. \param[in] counter
  43. A value associated with the random r generated during TPM2_Commit.
  44. \param[out] k
  45. The ECDAA signature k value. Nonce produced by the TPM during signing.
  46. \param[out] s
  47. The ECDAA signature s value.
  48. \returns ::EpidStatus
  49. \see Tpm2CreateContext
  50. \see Tpm2Commit
  51. */
  52. EpidStatus Tpm2Sign(Tpm2Ctx* ctx, void const* digest, size_t digest_len,
  53. uint16_t counter, FfElement* k, FfElement* s);
  54. /// Erases random r value assosiated with counter.
  55. /*!
  56. \param[in] ctx
  57. The TPM context.
  58. \param[in] counter
  59. To be released value associated with the random r generated during TPM2_Commit.
  60. \note
  61. This function should be used if Tpm2Sign wasn't called after Tpm2Commit
  62. which created counter.
  63. \returns ::EpidStatus
  64. \see Tpm2Commit
  65. */
  66. EpidStatus Tpm2ReleaseCounter(Tpm2Ctx* ctx, uint16_t counter);
  67. /*! @} */
  68. #endif // EPID_MEMBER_TPM2_SIGN_H_