TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptSha512.c
Go to the documentation of this file.
1
9#include "InternalCryptLib.h"
10#include <mbedtls/sha512.h>
11
19EFIAPI
21 VOID
22 )
23{
24 return (UINTN)(sizeof (mbedtls_sha512_context));
25}
26
39BOOLEAN
40EFIAPI
42 OUT VOID *Sha384Context
43 )
44{
45 INT32 Ret;
46
47 if (Sha384Context == NULL) {
48 return FALSE;
49 }
50
51 mbedtls_sha512_init (Sha384Context);
52
53 Ret = mbedtls_sha512_starts (Sha384Context, TRUE);
54 if (Ret != 0) {
55 return FALSE;
56 }
57
58 return TRUE;
59}
60
76BOOLEAN
77EFIAPI
79 IN CONST VOID *Sha384Context,
80 OUT VOID *NewSha384Context
81 )
82{
83 if ((Sha384Context == NULL) || (NewSha384Context == NULL)) {
84 return FALSE;
85 }
86
87 mbedtls_sha512_clone (NewSha384Context, Sha384Context);
88
89 return TRUE;
90}
91
110BOOLEAN
111EFIAPI
113 IN OUT VOID *Sha384Context,
114 IN CONST VOID *Data,
115 IN UINTN DataSize
116 )
117{
118 INT32 Ret;
119
120 if (Sha384Context == NULL) {
121 return FALSE;
122 }
123
124 if ((Data == NULL) && (DataSize != 0)) {
125 return FALSE;
126 }
127
128 Ret = mbedtls_sha512_update (Sha384Context, Data, DataSize);
129 if (Ret != 0) {
130 return FALSE;
131 }
132
133 return TRUE;
134}
135
156BOOLEAN
157EFIAPI
159 IN OUT VOID *Sha384Context,
160 OUT UINT8 *HashValue
161 )
162{
163 INT32 Ret;
164
165 if ((Sha384Context == NULL) || (HashValue == NULL)) {
166 return FALSE;
167 }
168
169 Ret = mbedtls_sha512_finish (Sha384Context, HashValue);
170 mbedtls_sha512_free (Sha384Context);
171 if (Ret != 0) {
172 return FALSE;
173 }
174
175 return TRUE;
176}
177
196BOOLEAN
197EFIAPI
199 IN CONST VOID *Data,
200 IN UINTN DataSize,
201 OUT UINT8 *HashValue
202 )
203{
204 INT32 Ret;
205
206 if (HashValue == NULL) {
207 return FALSE;
208 }
209
210 if ((Data == NULL) && (DataSize != 0)) {
211 return FALSE;
212 }
213
214 Ret = mbedtls_sha512 (Data, DataSize, HashValue, TRUE);
215 if (Ret != 0) {
216 return FALSE;
217 }
218
219 return TRUE;
220}
221
228UINTN
229EFIAPI
231 VOID
232 )
233{
234 return (UINTN)(sizeof (mbedtls_sha512_context));
235}
236
249BOOLEAN
250EFIAPI
252 OUT VOID *Sha512Context
253 )
254{
255 INT32 Ret;
256
257 if (Sha512Context == NULL) {
258 return FALSE;
259 }
260
261 mbedtls_sha512_init (Sha512Context);
262
263 Ret = mbedtls_sha512_starts (Sha512Context, FALSE);
264 if (Ret != 0) {
265 return FALSE;
266 }
267
268 return TRUE;
269}
270
286BOOLEAN
287EFIAPI
289 IN CONST VOID *Sha512Context,
290 OUT VOID *NewSha512Context
291 )
292{
293 if ((Sha512Context == NULL) || (NewSha512Context == NULL)) {
294 return FALSE;
295 }
296
297 mbedtls_sha512_clone (NewSha512Context, Sha512Context);
298
299 return TRUE;
300}
301
320BOOLEAN
321EFIAPI
323 IN OUT VOID *Sha512Context,
324 IN CONST VOID *Data,
325 IN UINTN DataSize
326 )
327{
328 INT32 Ret;
329
330 if (Sha512Context == NULL) {
331 return FALSE;
332 }
333
334 if ((Data == NULL) && (DataSize != 0)) {
335 return FALSE;
336 }
337
338 Ret = mbedtls_sha512_update (Sha512Context, Data, DataSize);
339 if (Ret != 0) {
340 return FALSE;
341 }
342
343 return TRUE;
344}
345
366BOOLEAN
367EFIAPI
369 IN OUT VOID *Sha512Context,
370 OUT UINT8 *HashValue
371 )
372{
373 INT32 Ret;
374
375 if ((Sha512Context == NULL) || (HashValue == NULL)) {
376 return FALSE;
377 }
378
379 Ret = mbedtls_sha512_finish (Sha512Context, HashValue);
380 mbedtls_sha512_free (Sha512Context);
381 if (Ret != 0) {
382 return FALSE;
383 }
384
385 return TRUE;
386}
387
406BOOLEAN
407EFIAPI
409 IN CONST VOID *Data,
410 IN UINTN DataSize,
411 OUT UINT8 *HashValue
412 )
413{
414 INT32 Ret;
415
416 if (HashValue == NULL) {
417 return FALSE;
418 }
419
420 if ((Data == NULL) && (DataSize != 0)) {
421 return FALSE;
422 }
423
424 Ret = mbedtls_sha512 (Data, DataSize, HashValue, FALSE);
425 if (Ret != 0) {
426 return FALSE;
427 }
428
429 return TRUE;
430}
UINT64 UINTN
UINTN EFIAPI Sha384GetContextSize(VOID)
Definition: CryptSha512.c:20
BOOLEAN EFIAPI Sha512HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptSha512.c:427
BOOLEAN EFIAPI Sha512Final(IN OUT VOID *Sha512Context, OUT UINT8 *HashValue)
Definition: CryptSha512.c:389
BOOLEAN EFIAPI Sha384Duplicate(IN CONST VOID *Sha384Context, OUT VOID *NewSha384Context)
Definition: CryptSha512.c:78
UINTN EFIAPI Sha512GetContextSize(VOID)
Definition: CryptSha512.c:246
BOOLEAN EFIAPI Sha512Init(OUT VOID *Sha512Context)
Definition: CryptSha512.c:270
BOOLEAN EFIAPI Sha384HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptSha512.c:201
BOOLEAN EFIAPI Sha384Update(IN OUT VOID *Sha384Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha512.c:115
BOOLEAN EFIAPI Sha512Duplicate(IN CONST VOID *Sha512Context, OUT VOID *NewSha512Context)
Definition: CryptSha512.c:304
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
Definition: CryptSha512.c:163
BOOLEAN EFIAPI Sha384Init(OUT VOID *Sha384Context)
Definition: CryptSha512.c:44
BOOLEAN EFIAPI Sha512Update(IN OUT VOID *Sha512Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha512.c:341
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284