]>
Commit | Line | Data |
---|---|---|
0b1a1bdc QZ |
1 | /** @file\r |
2 | HMAC-SHA256/SHA384 Wrapper Implementation which does not provide real capabilities.\r | |
3 | \r | |
4 | Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #include "InternalCryptLib.h"\r | |
10 | \r | |
11 | /**\r | |
12 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.\r | |
13 | \r | |
14 | Return NULL to indicate this interface is not supported.\r | |
15 | \r | |
16 | @return NULL This interface is not supported..\r | |
17 | \r | |
18 | **/\r | |
19 | VOID *\r | |
20 | EFIAPI\r | |
21 | HmacSha256New (\r | |
22 | VOID\r | |
23 | )\r | |
24 | {\r | |
25 | ASSERT (FALSE);\r | |
26 | return NULL;\r | |
27 | }\r | |
28 | \r | |
29 | /**\r | |
30 | Release the specified HMAC_CTX context.\r | |
31 | \r | |
32 | This function will do nothing.\r | |
33 | \r | |
34 | @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.\r | |
35 | \r | |
36 | **/\r | |
37 | VOID\r | |
38 | EFIAPI\r | |
39 | HmacSha256Free (\r | |
40 | IN VOID *HmacSha256Ctx\r | |
41 | )\r | |
42 | {\r | |
43 | ASSERT (FALSE);\r | |
44 | return;\r | |
45 | }\r | |
46 | \r | |
47 | /**\r | |
48 | Set user-supplied key for subsequent use. It must be done before any\r | |
49 | calling to HmacSha256Update().\r | |
50 | \r | |
51 | Return FALSE to indicate this interface is not supported.\r | |
52 | \r | |
53 | @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.\r | |
54 | @param[in] Key Pointer to the user-supplied key.\r | |
55 | @param[in] KeySize Key size in bytes.\r | |
56 | \r | |
57 | @retval FALSE This interface is not supported.\r | |
58 | \r | |
59 | **/\r | |
60 | BOOLEAN\r | |
61 | EFIAPI\r | |
62 | HmacSha256SetKey (\r | |
63 | OUT VOID *HmacSha256Context,\r | |
64 | IN CONST UINT8 *Key,\r | |
65 | IN UINTN KeySize\r | |
66 | )\r | |
67 | {\r | |
68 | ASSERT (FALSE);\r | |
69 | return FALSE;\r | |
70 | }\r | |
71 | \r | |
72 | /**\r | |
73 | Makes a copy of an existing HMAC-SHA256 context.\r | |
74 | \r | |
75 | Return FALSE to indicate this interface is not supported.\r | |
76 | \r | |
77 | @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.\r | |
78 | @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.\r | |
79 | \r | |
80 | @retval FALSE This interface is not supported.\r | |
81 | \r | |
82 | **/\r | |
83 | BOOLEAN\r | |
84 | EFIAPI\r | |
85 | HmacSha256Duplicate (\r | |
86 | IN CONST VOID *HmacSha256Context,\r | |
87 | OUT VOID *NewHmacSha256Context\r | |
88 | )\r | |
89 | {\r | |
90 | ASSERT (FALSE);\r | |
91 | return FALSE;\r | |
92 | }\r | |
93 | \r | |
94 | /**\r | |
95 | Digests the input data and updates HMAC-SHA256 context.\r | |
96 | \r | |
97 | Return FALSE to indicate this interface is not supported.\r | |
98 | \r | |
99 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
100 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
101 | @param[in] DataSize Size of Data buffer in bytes.\r | |
102 | \r | |
103 | @retval FALSE This interface is not supported.\r | |
104 | \r | |
105 | **/\r | |
106 | BOOLEAN\r | |
107 | EFIAPI\r | |
108 | HmacSha256Update (\r | |
109 | IN OUT VOID *HmacSha256Context,\r | |
110 | IN CONST VOID *Data,\r | |
111 | IN UINTN DataSize\r | |
112 | )\r | |
113 | {\r | |
114 | ASSERT (FALSE);\r | |
115 | return FALSE;\r | |
116 | }\r | |
117 | \r | |
118 | /**\r | |
119 | Completes computation of the HMAC-SHA256 digest value.\r | |
120 | \r | |
121 | Return FALSE to indicate this interface is not supported.\r | |
122 | \r | |
123 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
124 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest\r | |
125 | value (32 bytes).\r | |
126 | \r | |
127 | @retval FALSE This interface is not supported.\r | |
128 | \r | |
129 | **/\r | |
130 | BOOLEAN\r | |
131 | EFIAPI\r | |
132 | HmacSha256Final (\r | |
133 | IN OUT VOID *HmacSha256Context,\r | |
134 | OUT UINT8 *HmacValue\r | |
135 | )\r | |
136 | {\r | |
137 | ASSERT (FALSE);\r | |
138 | return FALSE;\r | |
139 | }\r | |
140 | \r | |
141 | /**\r | |
142 | Computes the HMAC-SHA256 digest of a input data buffer.\r | |
143 | \r | |
144 | This function performs the HMAC-SHA256 digest of a given data buffer, and places\r | |
145 | the digest value into the specified memory.\r | |
146 | \r | |
147 | If this interface is not supported, then return FALSE.\r | |
148 | \r | |
149 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
150 | @param[in] DataSize Size of Data buffer in bytes.\r | |
151 | @param[in] Key Pointer to the user-supplied key.\r | |
152 | @param[in] KeySize Key size in bytes.\r | |
153 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest\r | |
154 | value (32 bytes).\r | |
155 | \r | |
156 | @retval TRUE HMAC-SHA256 digest computation succeeded.\r | |
157 | @retval FALSE HMAC-SHA256 digest computation failed.\r | |
158 | @retval FALSE This interface is not supported.\r | |
159 | \r | |
160 | **/\r | |
161 | BOOLEAN\r | |
162 | EFIAPI\r | |
163 | HmacSha256All (\r | |
164 | IN CONST VOID *Data,\r | |
165 | IN UINTN DataSize,\r | |
166 | IN CONST UINT8 *Key,\r | |
167 | IN UINTN KeySize,\r | |
168 | OUT UINT8 *HmacValue\r | |
169 | )\r | |
170 | {\r | |
171 | ASSERT (FALSE);\r | |
172 | return FALSE;\r | |
173 | }\r | |
174 | \r | |
175 | /**\r | |
176 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA384 use.\r | |
177 | \r | |
178 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
179 | If the allocations fails, HmacSha384New() returns NULL.\r | |
180 | \r | |
181 | **/\r | |
182 | VOID *\r | |
183 | EFIAPI\r | |
184 | HmacSha384New (\r | |
185 | VOID\r | |
186 | )\r | |
187 | {\r | |
188 | ASSERT (FALSE);\r | |
189 | return NULL;\r | |
190 | }\r | |
191 | \r | |
192 | /**\r | |
193 | Release the specified HMAC_CTX context.\r | |
194 | \r | |
195 | @param[in] HmacSha384Ctx Pointer to the HMAC_CTX context to be released.\r | |
196 | \r | |
197 | **/\r | |
198 | VOID\r | |
199 | EFIAPI\r | |
200 | HmacSha384Free (\r | |
201 | IN VOID *HmacSha384Ctx\r | |
202 | )\r | |
203 | {\r | |
204 | ASSERT (FALSE);\r | |
205 | return;\r | |
206 | }\r | |
207 | \r | |
208 | /**\r | |
209 | Set user-supplied key for subsequent use. It must be done before any\r | |
210 | calling to HmacSha384Update().\r | |
211 | \r | |
212 | If HmacSha384Context is NULL, then return FALSE.\r | |
213 | If this interface is not supported, then return FALSE.\r | |
214 | \r | |
215 | @param[out] HmacSha384Context Pointer to HMAC-SHA384 context.\r | |
216 | @param[in] Key Pointer to the user-supplied key.\r | |
217 | @param[in] KeySize Key size in bytes.\r | |
218 | \r | |
219 | @retval TRUE The Key is set successfully.\r | |
220 | @retval FALSE The Key is set unsuccessfully.\r | |
221 | @retval FALSE This interface is not supported.\r | |
222 | \r | |
223 | **/\r | |
224 | BOOLEAN\r | |
225 | EFIAPI\r | |
226 | HmacSha384SetKey (\r | |
227 | OUT VOID *HmacSha384Context,\r | |
228 | IN CONST UINT8 *Key,\r | |
229 | IN UINTN KeySize\r | |
230 | )\r | |
231 | {\r | |
232 | ASSERT (FALSE);\r | |
233 | return FALSE;\r | |
234 | }\r | |
235 | \r | |
236 | /**\r | |
237 | Makes a copy of an existing HMAC-SHA384 context.\r | |
238 | \r | |
239 | If HmacSha384Context is NULL, then return FALSE.\r | |
240 | If NewHmacSha384Context is NULL, then return FALSE.\r | |
241 | If this interface is not supported, then return FALSE.\r | |
242 | \r | |
243 | @param[in] HmacSha384Context Pointer to HMAC-SHA384 context being copied.\r | |
244 | @param[out] NewHmacSha384Context Pointer to new HMAC-SHA384 context.\r | |
245 | \r | |
246 | @retval TRUE HMAC-SHA384 context copy succeeded.\r | |
247 | @retval FALSE HMAC-SHA384 context copy failed.\r | |
248 | @retval FALSE This interface is not supported.\r | |
249 | \r | |
250 | **/\r | |
251 | BOOLEAN\r | |
252 | EFIAPI\r | |
253 | HmacSha384Duplicate (\r | |
254 | IN CONST VOID *HmacSha384Context,\r | |
255 | OUT VOID *NewHmacSha384Context\r | |
256 | )\r | |
257 | {\r | |
258 | ASSERT (FALSE);\r | |
259 | return FALSE;\r | |
260 | }\r | |
261 | \r | |
262 | /**\r | |
263 | Digests the input data and updates HMAC-SHA384 context.\r | |
264 | \r | |
265 | This function performs HMAC-SHA384 digest on a data buffer of the specified size.\r | |
266 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
267 | HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized\r | |
268 | by HmacSha384Final(). Behavior with invalid context is undefined.\r | |
269 | \r | |
270 | If HmacSha384Context is NULL, then return FALSE.\r | |
271 | If this interface is not supported, then return FALSE.\r | |
272 | \r | |
273 | @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.\r | |
274 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
275 | @param[in] DataSize Size of Data buffer in bytes.\r | |
276 | \r | |
277 | @retval TRUE HMAC-SHA384 data digest succeeded.\r | |
278 | @retval FALSE HMAC-SHA384 data digest failed.\r | |
279 | @retval FALSE This interface is not supported.\r | |
280 | \r | |
281 | **/\r | |
282 | BOOLEAN\r | |
283 | EFIAPI\r | |
284 | HmacSha384Update (\r | |
285 | IN OUT VOID *HmacSha384Context,\r | |
286 | IN CONST VOID *Data,\r | |
287 | IN UINTN DataSize\r | |
288 | )\r | |
289 | {\r | |
290 | ASSERT (FALSE);\r | |
291 | return FALSE;\r | |
292 | }\r | |
293 | \r | |
294 | /**\r | |
295 | Completes computation of the HMAC-SHA384 digest value.\r | |
296 | \r | |
297 | This function completes HMAC-SHA384 hash computation and retrieves the digest value into\r | |
298 | the specified memory. After this function has been called, the HMAC-SHA384 context cannot\r | |
299 | be used again.\r | |
300 | HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized\r | |
301 | by HmacSha384Final(). Behavior with invalid HMAC-SHA384 context is undefined.\r | |
302 | \r | |
303 | If HmacSha384Context is NULL, then return FALSE.\r | |
304 | If HmacValue is NULL, then return FALSE.\r | |
305 | If this interface is not supported, then return FALSE.\r | |
306 | \r | |
307 | @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.\r | |
308 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest\r | |
309 | value (48 bytes).\r | |
310 | \r | |
311 | @retval TRUE HMAC-SHA384 digest computation succeeded.\r | |
312 | @retval FALSE HMAC-SHA384 digest computation failed.\r | |
313 | @retval FALSE This interface is not supported.\r | |
314 | \r | |
315 | **/\r | |
316 | BOOLEAN\r | |
317 | EFIAPI\r | |
318 | HmacSha384Final (\r | |
319 | IN OUT VOID *HmacSha384Context,\r | |
320 | OUT UINT8 *HmacValue\r | |
321 | )\r | |
322 | {\r | |
323 | ASSERT (FALSE);\r | |
324 | return FALSE;\r | |
325 | }\r | |
326 | \r | |
327 | /**\r | |
328 | Computes the HMAC-SHA384 digest of a input data buffer.\r | |
329 | \r | |
330 | This function performs the HMAC-SHA384 digest of a given data buffer, and places\r | |
331 | the digest value into the specified memory.\r | |
332 | \r | |
333 | If this interface is not supported, then return FALSE.\r | |
334 | \r | |
335 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
336 | @param[in] DataSize Size of Data buffer in bytes.\r | |
337 | @param[in] Key Pointer to the user-supplied key.\r | |
338 | @param[in] KeySize Key size in bytes.\r | |
339 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest\r | |
340 | value (48 bytes).\r | |
341 | \r | |
342 | @retval TRUE HMAC-SHA384 digest computation succeeded.\r | |
343 | @retval FALSE HMAC-SHA384 digest computation failed.\r | |
344 | @retval FALSE This interface is not supported.\r | |
345 | \r | |
346 | **/\r | |
347 | BOOLEAN\r | |
348 | EFIAPI\r | |
349 | HmacSha384All (\r | |
350 | IN CONST VOID *Data,\r | |
351 | IN UINTN DataSize,\r | |
352 | IN CONST UINT8 *Key,\r | |
353 | IN UINTN KeySize,\r | |
354 | OUT UINT8 *HmacValue\r | |
355 | )\r | |
356 | {\r | |
357 | ASSERT (FALSE);\r | |
358 | return FALSE;\r | |
359 | }\r |