]>
Commit | Line | Data |
---|---|---|
c1d93242 JY |
1 | /** @file\r |
2 | Ihis is BaseCrypto router support function.\r | |
3 | \r | |
4 | Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include <PiPei.h>\r | |
16 | #include <Library/BaseLib.h>\r | |
17 | #include <Library/BaseMemoryLib.h>\r | |
18 | #include <Library/Tpm2CommandLib.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/MemoryAllocationLib.h>\r | |
21 | #include <Library/HashLib.h>\r | |
22 | #include <Protocol/TrEEProtocol.h>\r | |
23 | \r | |
24 | typedef struct {\r | |
25 | EFI_GUID Guid;\r | |
26 | UINT32 Mask;\r | |
27 | } TPM2_HASH_MASK;\r | |
28 | \r | |
29 | TPM2_HASH_MASK mTpm2HashMask[] = {\r | |
30 | {HASH_ALGORITHM_SHA1_GUID, TREE_BOOT_HASH_ALG_SHA1},\r | |
31 | {HASH_ALGORITHM_SHA256_GUID, TREE_BOOT_HASH_ALG_SHA256},\r | |
32 | {HASH_ALGORITHM_SHA384_GUID, TREE_BOOT_HASH_ALG_SHA384},\r | |
33 | {HASH_ALGORITHM_SHA512_GUID, TREE_BOOT_HASH_ALG_SHA512},\r | |
34 | };\r | |
35 | \r | |
36 | /**\r | |
37 | The function get hash mask info from algorithm.\r | |
38 | \r | |
39 | @param HashGuid Hash Guid\r | |
40 | \r | |
41 | @return HashMask\r | |
42 | **/\r | |
43 | UINT32\r | |
44 | EFIAPI\r | |
45 | Tpm2GetHashMaskFromAlgo (\r | |
46 | IN EFI_GUID *HashGuid\r | |
47 | )\r | |
48 | {\r | |
49 | UINTN Index;\r | |
50 | for (Index = 0; Index < sizeof(mTpm2HashMask)/sizeof(mTpm2HashMask[0]); Index++) {\r | |
51 | if (CompareGuid (HashGuid, &mTpm2HashMask[Index].Guid)) {\r | |
52 | return mTpm2HashMask[Index].Mask;\r | |
53 | }\r | |
54 | }\r | |
55 | return 0;\r | |
56 | }\r | |
57 | \r | |
58 | /**\r | |
59 | The function set digest to digest list.\r | |
60 | \r | |
61 | @param DigestList digest list\r | |
62 | @param Digest digest data\r | |
63 | **/\r | |
64 | VOID\r | |
65 | EFIAPI\r | |
66 | Tpm2SetHashToDigestList (\r | |
67 | IN OUT TPML_DIGEST_VALUES *DigestList,\r | |
68 | IN TPML_DIGEST_VALUES *Digest\r | |
69 | )\r | |
70 | {\r | |
71 | CopyMem (\r | |
72 | &DigestList->digests[DigestList->count],\r | |
73 | &Digest->digests[0],\r | |
74 | sizeof(Digest->digests[0])\r | |
75 | );\r | |
76 | DigestList->count ++;\r | |
77 | }\r |