mirror of https://github.com/acidanthera/audk.git
SecurityPkg TPM2: Add GetHashMaskFromAlgo() into Tpm2CommandLib
Add GetHashMaskFromAlgo() into Tpm2CommandLib for coming consumer. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Chao Zhang <chao.b.zhang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by : Chao Zhang <chao.b.zhang@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
parent
697c30b157
commit
b8ae1f4de7
|
@ -1006,6 +1006,19 @@ GetHashSizeFromAlgo (
|
||||||
IN TPMI_ALG_HASH HashAlgo
|
IN TPMI_ALG_HASH HashAlgo
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get hash mask from algorithm.
|
||||||
|
|
||||||
|
@param[in] HashAlgo Hash algorithm
|
||||||
|
|
||||||
|
@return Hash mask
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
GetHashMaskFromAlgo (
|
||||||
|
IN TPMI_ALG_HASH HashAlgo
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return if hash alg is supported in HashAlgorithmMask.
|
Return if hash alg is supported in HashAlgorithmMask.
|
||||||
|
|
||||||
|
|
|
@ -22,14 +22,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
TPMI_ALG_HASH HashAlgo;
|
TPMI_ALG_HASH HashAlgo;
|
||||||
UINT16 HashSize;
|
UINT16 HashSize;
|
||||||
|
UINT32 HashMask;
|
||||||
} INTERNAL_HASH_INFO;
|
} INTERNAL_HASH_INFO;
|
||||||
|
|
||||||
STATIC INTERNAL_HASH_INFO mHashInfo[] = {
|
STATIC INTERNAL_HASH_INFO mHashInfo[] = {
|
||||||
{TPM_ALG_SHA1, SHA1_DIGEST_SIZE},
|
{TPM_ALG_SHA1, SHA1_DIGEST_SIZE, HASH_ALG_SHA1},
|
||||||
{TPM_ALG_SHA256, SHA256_DIGEST_SIZE},
|
{TPM_ALG_SHA256, SHA256_DIGEST_SIZE, HASH_ALG_SHA256},
|
||||||
{TPM_ALG_SM3_256, SM3_256_DIGEST_SIZE},
|
{TPM_ALG_SM3_256, SM3_256_DIGEST_SIZE, HASH_ALG_SM3_256},
|
||||||
{TPM_ALG_SHA384, SHA384_DIGEST_SIZE},
|
{TPM_ALG_SHA384, SHA384_DIGEST_SIZE, HASH_ALG_SHA384},
|
||||||
{TPM_ALG_SHA512, SHA512_DIGEST_SIZE},
|
{TPM_ALG_SHA512, SHA512_DIGEST_SIZE, HASH_ALG_SHA512},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,6 +56,29 @@ GetHashSizeFromAlgo (
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get hash mask from algorithm.
|
||||||
|
|
||||||
|
@param[in] HashAlgo Hash algorithm
|
||||||
|
|
||||||
|
@return Hash mask
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
GetHashMaskFromAlgo (
|
||||||
|
IN TPMI_ALG_HASH HashAlgo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Index;
|
||||||
|
|
||||||
|
for (Index = 0; Index < sizeof(mHashInfo)/sizeof(mHashInfo[0]); Index++) {
|
||||||
|
if (mHashInfo[Index].HashAlgo == HashAlgo) {
|
||||||
|
return mHashInfo[Index].HashMask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Copy AuthSessionIn to TPM2 command buffer.
|
Copy AuthSessionIn to TPM2 command buffer.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue