File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5525,6 +5525,26 @@ int TPM2_GetHashDigestSize(TPMI_ALG_HASH hashAlg)
55255525 return 0 ;
55265526}
55275527
5528+ TPMI_ALG_HASH TPM2_GetTpmHashType (int hashType )
5529+ {
5530+ #ifndef WOLFTPM2_NO_WOLFCRYPT
5531+ switch (hashType ) {
5532+ case (int )WC_HASH_TYPE_SHA :
5533+ return TPM_ALG_SHA1 ;
5534+ case (int )WC_HASH_TYPE_SHA256 :
5535+ return TPM_ALG_SHA256 ;
5536+ case (int )WC_HASH_TYPE_SHA384 :
5537+ return TPM_ALG_SHA384 ;
5538+ case (int )WC_HASH_TYPE_SHA512 :
5539+ return TPM_ALG_SHA512 ;
5540+ default :
5541+ break ;
5542+ }
5543+ #endif
5544+ (void )hashType ;
5545+ return TPM_ALG_ERROR ;
5546+ }
5547+
55285548int TPM2_GetHashType (TPMI_ALG_HASH hashAlg )
55295549{
55305550#ifndef WOLFTPM2_NO_WOLFCRYPT
Original file line number Diff line number Diff line change @@ -3394,6 +3394,28 @@ WOLFTPM_API int TPM2_GetHashDigestSize(TPMI_ALG_HASH hashAlg);
33943394*/
33953395WOLFTPM_API int TPM2_GetHashType (TPMI_ALG_HASH hashAlg );
33963396
3397+ /*!
3398+ \ingroup TPM2_Proprietary
3399+ \brief Translate a wolfCrypt hash type to TPM2 hash type
3400+
3401+ \return a TPM2 hash type (TPM_ALG_*)
3402+ \return TPM_ALG_ERROR when wolfCrypt hash type is invalid or not found
3403+
3404+ \param hashType a wolfCrypt hash type
3405+
3406+ _Example_
3407+ \code
3408+ int wc_hashType = WC_HASH_TYPE_SHA256;
3409+ TPMI_ALG_HASH hashAlg;
3410+
3411+ hashAlg = TPM2_GetHashDigestSize(wc_hashType);
3412+ if (hashAlg != TPM_ALG_ERROR) {
3413+ //hashAlg contains a valid TPM2 hash type
3414+ }
3415+ \endcode
3416+ */
3417+ WOLFTPM_API TPMI_ALG_HASH TPM2_GetTpmHashType (int hashType );
3418+
33973419/*!
33983420 \ingroup TPM2_Proprietary
33993421 \brief Generate a fresh nonce of random numbers
You can’t perform that action at this time.
0 commit comments