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