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 19 #ifndef EPID_MEMBER_TPM2_SIGN_H_ 20 #define EPID_MEMBER_TPM2_SIGN_H_ 21 22 #include <stddef.h> 23 24 #include "epid/common/errors.h" 25 #include "epid/common/stdtypes.h" 26 27 /// \cond 28 typedef struct Tpm2Ctx Tpm2Ctx; 29 typedef struct FfElement FfElement; 30 /// \endcond 31 32 /*! 33 \addtogroup Tpm2Module tpm2 34 \ingroup EpidMemberModule 35 @{ 36 */ 37 38 /// Performs TPM2_Sign TPM command. 39 /*! 40 Calculate a pair (k, s) an ECDAA signature. 41 42 Private key f must exist in the TPM context. 43 44 \param[in] ctx 45 The TPM context. 46 \param[in] digest 47 Digest to be signed. 48 \param[in] digest_len 49 The size of digest in bytes. 50 \param[in] counter 51 A value associated with the random r generated during TPM2_Commit. 52 \param[out] k 53 The ECDAA signature k value. Nonce produced by the TPM during signing. 54 \param[out] s 55 The ECDAA signature s value. 56 57 \returns ::EpidStatus 58 59 \see Tpm2CreateContext 60 \see Tpm2Commit 61 */ 62 EpidStatus Tpm2Sign(Tpm2Ctx* ctx, void const* digest, size_t digest_len, 63 uint16_t counter, FfElement* k, FfElement* s); 64 65 /// Erases random r value assosiated with counter. 66 /*! 67 68 \param[in] ctx 69 The TPM context. 70 \param[in] counter 71 To be released value associated with the random r generated during TPM2_Commit. 72 73 \note 74 This function should be used if Tpm2Sign wasn't called after Tpm2Commit 75 which created counter. 76 77 \returns ::EpidStatus 78 79 \see Tpm2Commit 80 */ 81 EpidStatus Tpm2ReleaseCounter(Tpm2Ctx* ctx, uint16_t counter); 82 83 /*! @} */ 84 85 #endif // EPID_MEMBER_TPM2_SIGN_H_ 86