diff options
author | Star Zeng <star.zeng@intel.com> | 2016-11-18 13:13:21 +0800 |
---|---|---|
committer | Star Zeng <star.zeng@intel.com> | 2016-11-21 10:38:31 +0800 |
commit | b8ae1f4de75260f48e1459692bac0d1b84246cc1 (patch) | |
tree | 8079f994ce9e1f73b9da551534eddec2dcf43eb0 /SecurityPkg/Library | |
parent | 697c30b157c90c9c1a6c6610d73a49e4f5fd56b3 (diff) | |
download | edk2-b8ae1f4de75260f48e1459692bac0d1b84246cc1.tar.gz edk2-b8ae1f4de75260f48e1459692bac0d1b84246cc1.tar.bz2 edk2-b8ae1f4de75260f48e1459692bac0d1b84246cc1.zip |
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>
Diffstat (limited to 'SecurityPkg/Library')
-rw-r--r-- | SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 34 |
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
|