mirror of https://github.com/wolfSSL/wolfTPM.git
Helper to get wolfCrypt hash type. `TPMI_ALG_HASH TPM2_GetTpmHashType(int hashType)`.
parent
a5f6c912ac
commit
fa1cd521a3
20
src/tpm2.c
20
src/tpm2.c
|
@ -5525,6 +5525,26 @@ int TPM2_GetHashDigestSize(TPMI_ALG_HASH hashAlg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TPMI_ALG_HASH TPM2_GetTpmHashType(int hashType)
|
||||||
|
{
|
||||||
|
#ifndef WOLFTPM2_NO_WOLFCRYPT
|
||||||
|
switch (hashType) {
|
||||||
|
case (int)WC_HASH_TYPE_SHA:
|
||||||
|
return TPM_ALG_SHA1;
|
||||||
|
case (int)WC_HASH_TYPE_SHA256:
|
||||||
|
return TPM_ALG_SHA256;
|
||||||
|
case (int)WC_HASH_TYPE_SHA384:
|
||||||
|
return TPM_ALG_SHA384;
|
||||||
|
case (int)WC_HASH_TYPE_SHA512:
|
||||||
|
return TPM_ALG_SHA512;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
(void)hashType;
|
||||||
|
return TPM_ALG_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
int TPM2_GetHashType(TPMI_ALG_HASH hashAlg)
|
int TPM2_GetHashType(TPMI_ALG_HASH hashAlg)
|
||||||
{
|
{
|
||||||
#ifndef WOLFTPM2_NO_WOLFCRYPT
|
#ifndef WOLFTPM2_NO_WOLFCRYPT
|
||||||
|
|
|
@ -3394,6 +3394,28 @@ WOLFTPM_API int TPM2_GetHashDigestSize(TPMI_ALG_HASH hashAlg);
|
||||||
*/
|
*/
|
||||||
WOLFTPM_API int TPM2_GetHashType(TPMI_ALG_HASH hashAlg);
|
WOLFTPM_API int TPM2_GetHashType(TPMI_ALG_HASH hashAlg);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup TPM2_Proprietary
|
||||||
|
\brief Translate a wolfCrypt hash type to TPM2 hash type
|
||||||
|
|
||||||
|
\return a TPM2 hash type (TPM_ALG_*)
|
||||||
|
\return TPM_ALG_ERROR when wolfCrypt hash type is invalid or not found
|
||||||
|
|
||||||
|
\param hashType a wolfCrypt hash type
|
||||||
|
|
||||||
|
_Example_
|
||||||
|
\code
|
||||||
|
int wc_hashType = WC_HASH_TYPE_SHA256;
|
||||||
|
TPMI_ALG_HASH hashAlg;
|
||||||
|
|
||||||
|
hashAlg = TPM2_GetHashDigestSize(wc_hashType);
|
||||||
|
if (hashAlg != TPM_ALG_ERROR) {
|
||||||
|
//hashAlg contains a valid TPM2 hash type
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
*/
|
||||||
|
WOLFTPM_API TPMI_ALG_HASH TPM2_GetTpmHashType(int hashType);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup TPM2_Proprietary
|
\ingroup TPM2_Proprietary
|
||||||
\brief Generate a fresh nonce of random numbers
|
\brief Generate a fresh nonce of random numbers
|
||||||
|
|
Loading…
Reference in New Issue