summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'SecurityPkg/Library')
-rw-r--r--SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
index 95d4f7c84c..9aa77af97a 100644
--- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
@@ -22,14 +22,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
typedef struct {
TPMI_ALG_HASH HashAlgo;
UINT16 HashSize;
+ UINT32 HashMask;
} INTERNAL_HASH_INFO;
STATIC INTERNAL_HASH_INFO mHashInfo[] = {
- {TPM_ALG_SHA1, SHA1_DIGEST_SIZE},
- {TPM_ALG_SHA256, SHA256_DIGEST_SIZE},
- {TPM_ALG_SM3_256, SM3_256_DIGEST_SIZE},
- {TPM_ALG_SHA384, SHA384_DIGEST_SIZE},
- {TPM_ALG_SHA512, SHA512_DIGEST_SIZE},
+ {TPM_ALG_SHA1, SHA1_DIGEST_SIZE, HASH_ALG_SHA1},
+ {TPM_ALG_SHA256, SHA256_DIGEST_SIZE, HASH_ALG_SHA256},
+ {TPM_ALG_SM3_256, SM3_256_DIGEST_SIZE, HASH_ALG_SM3_256},
+ {TPM_ALG_SHA384, SHA384_DIGEST_SIZE, HASH_ALG_SHA384},
+ {TPM_ALG_SHA512, SHA512_DIGEST_SIZE, HASH_ALG_SHA512},
};
/**
@@ -56,6 +57,29 @@ GetHashSizeFromAlgo (
}
/**
+ 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.
@param [in] AuthSessionIn Input AuthSession data