TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptSha1.c
Go to the documentation of this file.
1
9#include "InternalCryptLib.h"
10#include <mbedtls/sha1.h>
11
12#ifndef DISABLE_SHA1_DEPRECATED_INTERFACES
13
21EFIAPI
23 VOID
24 )
25{
26 //
27 // Retrieves MbedTLS SHA Context Size
28 //
29 return (UINTN)(sizeof (mbedtls_sha1_context));
30}
31
44BOOLEAN
45EFIAPI
47 OUT VOID *Sha1Context
48 )
49{
50 INT32 Ret;
51
52 if (Sha1Context == NULL) {
53 return FALSE;
54 }
55
56 mbedtls_sha1_init (Sha1Context);
57
58 Ret = mbedtls_sha1_starts (Sha1Context);
59 if (Ret != 0) {
60 return FALSE;
61 }
62
63 return TRUE;
64}
65
79BOOLEAN
80EFIAPI
82 IN CONST VOID *Sha1Context,
83 OUT VOID *NewSha1Context
84 )
85{
86 if ((Sha1Context == NULL) || (NewSha1Context == NULL)) {
87 return FALSE;
88 }
89
90 mbedtls_sha1_clone (NewSha1Context, Sha1Context);
91
92 return TRUE;
93}
94
113BOOLEAN
114EFIAPI
116 IN OUT VOID *Sha1Context,
117 IN CONST VOID *Data,
118 IN UINTN DataSize
119 )
120{
121 INT32 Ret;
122
123 if (Sha1Context == NULL) {
124 return FALSE;
125 }
126
127 if ((Data == NULL) && (DataSize != 0)) {
128 return FALSE;
129 }
130
131 Ret = mbedtls_sha1_update (Sha1Context, Data, DataSize);
132 if (Ret != 0) {
133 return FALSE;
134 }
135
136 return TRUE;
137}
138
159BOOLEAN
160EFIAPI
162 IN OUT VOID *Sha1Context,
163 OUT UINT8 *HashValue
164 )
165{
166 INT32 Ret;
167
168 if ((Sha1Context == NULL) || (HashValue == NULL)) {
169 return FALSE;
170 }
171
172 Ret = mbedtls_sha1_finish (Sha1Context, HashValue);
173 mbedtls_sha1_free (Sha1Context);
174 if (Ret != 0) {
175 return FALSE;
176 }
177
178 return TRUE;
179}
180
199BOOLEAN
200EFIAPI
202 IN CONST VOID *Data,
203 IN UINTN DataSize,
204 OUT UINT8 *HashValue
205 )
206{
207 INT32 Ret;
208
209 if (HashValue == NULL) {
210 return FALSE;
211 }
212
213 if ((Data == NULL) && (DataSize != 0)) {
214 return FALSE;
215 }
216
217 Ret = mbedtls_sha1 (Data, DataSize, HashValue);
218 if (Ret != 0) {
219 return FALSE;
220 }
221
222 return TRUE;
223}
224
225#endif
UINT64 UINTN
BOOLEAN EFIAPI Sha1Final(IN OUT VOID *Sha1Context, OUT UINT8 *HashValue)
Definition: CryptSha1.c:163
BOOLEAN EFIAPI Sha1Duplicate(IN CONST VOID *Sha1Context, OUT VOID *NewSha1Context)
Definition: CryptSha1.c:78
BOOLEAN EFIAPI Sha1Init(OUT VOID *Sha1Context)
Definition: CryptSha1.c:46
BOOLEAN EFIAPI Sha1HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptSha1.c:201
UINTN EFIAPI Sha1GetContextSize(VOID)
Definition: CryptSha1.c:22
BOOLEAN EFIAPI Sha1Update(IN OUT VOID *Sha1Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha1.c:115
#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