]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Ihis library abstract TPM2 hash calculation.\r | |
3 | The platform can choose multiply hash, while caller just need invoke these API.\r | |
4 | Then all hash value will be returned and/or extended.\r | |
5 | \r | |
6 | Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r | |
7 | This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef _HASH_LIB_H_\r | |
18 | #define _HASH_LIB_H_\r | |
19 | \r | |
20 | #include <Uefi.h>\r | |
21 | #include <Protocol/Hash.h>\r | |
22 | \r | |
23 | typedef UINTN HASH_HANDLE;\r | |
24 | \r | |
25 | /**\r | |
26 | Start hash sequence.\r | |
27 | \r | |
28 | @param HashHandle Hash handle.\r | |
29 | \r | |
30 | @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.\r | |
31 | @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.\r | |
32 | **/\r | |
33 | EFI_STATUS\r | |
34 | EFIAPI\r | |
35 | HashStart (\r | |
36 | OUT HASH_HANDLE *HashHandle\r | |
37 | );\r | |
38 | \r | |
39 | /**\r | |
40 | Update hash sequence data.\r | |
41 | \r | |
42 | @param HashHandle Hash handle.\r | |
43 | @param DataToHash Data to be hashed.\r | |
44 | @param DataToHashLen Data size.\r | |
45 | \r | |
46 | @retval EFI_SUCCESS Hash sequence updated.\r | |
47 | **/\r | |
48 | EFI_STATUS\r | |
49 | EFIAPI\r | |
50 | HashUpdate (\r | |
51 | IN HASH_HANDLE HashHandle,\r | |
52 | IN VOID *DataToHash,\r | |
53 | IN UINTN DataToHashLen\r | |
54 | );\r | |
55 | \r | |
56 | /**\r | |
57 | Hash sequence complete and extend to PCR.\r | |
58 | \r | |
59 | @param HashHandle Hash handle.\r | |
60 | @param PcrIndex PCR to be extended.\r | |
61 | @param DataToHash Data to be hashed.\r | |
62 | @param DataToHashLen Data size.\r | |
63 | @param DigestList Digest list.\r | |
64 | \r | |
65 | @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.\r | |
66 | **/\r | |
67 | EFI_STATUS\r | |
68 | EFIAPI\r | |
69 | HashCompleteAndExtend (\r | |
70 | IN HASH_HANDLE HashHandle,\r | |
71 | IN TPMI_DH_PCR PcrIndex,\r | |
72 | IN VOID *DataToHash,\r | |
73 | IN UINTN DataToHashLen,\r | |
74 | OUT TPML_DIGEST_VALUES *DigestList\r | |
75 | );\r | |
76 | \r | |
77 | /**\r | |
78 | Hash data and extend to PCR.\r | |
79 | \r | |
80 | @param PcrIndex PCR to be extended.\r | |
81 | @param DataToHash Data to be hashed.\r | |
82 | @param DataToHashLen Data size.\r | |
83 | @param DigestList Digest list.\r | |
84 | \r | |
85 | @retval EFI_SUCCESS Hash data and DigestList is returned.\r | |
86 | **/\r | |
87 | EFI_STATUS\r | |
88 | EFIAPI\r | |
89 | HashAndExtend (\r | |
90 | IN TPMI_DH_PCR PcrIndex,\r | |
91 | IN VOID *DataToHash,\r | |
92 | IN UINTN DataToHashLen,\r | |
93 | OUT TPML_DIGEST_VALUES *DigestList\r | |
94 | );\r | |
95 | \r | |
96 | /**\r | |
97 | Start hash sequence.\r | |
98 | \r | |
99 | @param HashHandle Hash handle.\r | |
100 | \r | |
101 | @retval EFI_SUCCESS Hash sequence start and HandleHandle returned.\r | |
102 | @retval EFI_OUT_OF_RESOURCES No enough resource to start hash.\r | |
103 | **/\r | |
104 | typedef\r | |
105 | EFI_STATUS\r | |
106 | (EFIAPI *HASH_INIT) (\r | |
107 | OUT HASH_HANDLE *HashHandle\r | |
108 | );\r | |
109 | \r | |
110 | /**\r | |
111 | Update hash sequence data.\r | |
112 | \r | |
113 | @param HashHandle Hash handle.\r | |
114 | @param DataToHash Data to be hashed.\r | |
115 | @param DataToHashLen Data size.\r | |
116 | \r | |
117 | @retval EFI_SUCCESS Hash sequence updated.\r | |
118 | **/\r | |
119 | typedef\r | |
120 | EFI_STATUS\r | |
121 | (EFIAPI *HASH_UPDATE) (\r | |
122 | IN HASH_HANDLE HashHandle,\r | |
123 | IN VOID *DataToHash,\r | |
124 | IN UINTN DataToHashLen\r | |
125 | );\r | |
126 | \r | |
127 | /**\r | |
128 | Complete hash sequence complete.\r | |
129 | \r | |
130 | @param HashHandle Hash handle.\r | |
131 | @param DigestList Digest list.\r | |
132 | \r | |
133 | @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.\r | |
134 | **/\r | |
135 | typedef\r | |
136 | EFI_STATUS\r | |
137 | (EFIAPI *HASH_FINAL) (\r | |
138 | IN HASH_HANDLE HashHandle,\r | |
139 | OUT TPML_DIGEST_VALUES *DigestList\r | |
140 | );\r | |
141 | \r | |
142 | #define HASH_ALGORITHM_SHA1_GUID EFI_HASH_ALGORITHM_SHA1_GUID\r | |
143 | #define HASH_ALGORITHM_SHA256_GUID EFI_HASH_ALGORITHM_SHA256_GUID\r | |
144 | #define HASH_ALGORITHM_SHA384_GUID EFI_HASH_ALGORITHM_SHA384_GUID\r | |
145 | #define HASH_ALGORITHM_SHA512_GUID EFI_HASH_ALGORITHM_SHA512_GUID\r | |
146 | \r | |
147 | typedef struct {\r | |
148 | EFI_GUID HashGuid;\r | |
149 | HASH_INIT HashInit;\r | |
150 | HASH_UPDATE HashUpdate;\r | |
151 | HASH_FINAL HashFinal;\r | |
152 | } HASH_INTERFACE;\r | |
153 | \r | |
154 | /**\r | |
155 | This service register Hash.\r | |
156 | \r | |
157 | @param HashInterface Hash interface\r | |
158 | \r | |
159 | @retval EFI_SUCCESS This hash interface is registered successfully.\r | |
160 | @retval EFI_UNSUPPORTED System does not support register this interface.\r | |
161 | @retval EFI_ALREADY_STARTED System already register this interface.\r | |
162 | **/\r | |
163 | EFI_STATUS\r | |
164 | EFIAPI\r | |
165 | RegisterHashInterfaceLib (\r | |
166 | IN HASH_INTERFACE *HashInterface\r | |
167 | );\r | |
168 | \r | |
169 | #endif\r |