TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptMd5.c
Go to the documentation of this file.
1
9#include "InternalCryptLib.h"
10#include <mbedtls/md5.h>
11
12#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
13
21EFIAPI
23 VOID
24 )
25{
26 //
27 // Retrieves the MD5 Context Size
28 //
29 return (UINTN)(sizeof (mbedtls_md5_context));
30}
31
44BOOLEAN
45EFIAPI
46Md5Init (
47 OUT VOID *Md5Context
48 )
49{
50 INT32 Ret;
51
52 if (Md5Context == NULL) {
53 return FALSE;
54 }
55
56 mbedtls_md5_init (Md5Context);
57
58 Ret = mbedtls_md5_starts (Md5Context);
59 if (Ret != 0) {
60 return FALSE;
61 }
62
63 return TRUE;
64}
65
79BOOLEAN
80EFIAPI
82 IN CONST VOID *Md5Context,
83 OUT VOID *NewMd5Context
84 )
85{
86 if ((Md5Context == NULL) || (NewMd5Context == NULL)) {
87 return FALSE;
88 }
89
90 mbedtls_md5_clone (NewMd5Context, Md5Context);
91
92 return TRUE;
93}
94
113BOOLEAN
114EFIAPI
115Md5Update (
116 IN OUT VOID *Md5Context,
117 IN CONST VOID *Data,
118 IN UINTN DataSize
119 )
120{
121 INT32 Ret;
122
123 if (Md5Context == NULL) {
124 return FALSE;
125 }
126
127 if ((Data == NULL) && (DataSize != 0)) {
128 return FALSE;
129 }
130
131 Ret = mbedtls_md5_update (Md5Context, Data, DataSize);
132 if (Ret != 0) {
133 return FALSE;
134 }
135
136 return TRUE;
137}
138
159BOOLEAN
160EFIAPI
161Md5Final (
162 IN OUT VOID *Md5Context,
163 OUT UINT8 *HashValue
164 )
165{
166 INT32 Ret;
167
168 if ((Md5Context == NULL) || (HashValue == NULL)) {
169 return FALSE;
170 }
171
172 Ret = mbedtls_md5_finish (Md5Context, HashValue);
173 mbedtls_md5_free (Md5Context);
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_md5 (Data, DataSize, HashValue);
218 if (Ret != 0) {
219 return FALSE;
220 }
221
222 return TRUE;
223}
224
225#endif
UINT64 UINTN
BOOLEAN EFIAPI Md5Duplicate(IN CONST VOID *Md5Context, OUT VOID *NewMd5Context)
Definition: CryptMd5Null.c:65
BOOLEAN EFIAPI Md5Final(IN OUT VOID *Md5Context, OUT UINT8 *HashValue)
Definition: CryptMd5Null.c:126
BOOLEAN EFIAPI Md5Update(IN OUT VOID *Md5Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptMd5Null.c:94
BOOLEAN EFIAPI Md5Init(OUT VOID *Md5Context)
Definition: CryptMd5Null.c:42
BOOLEAN EFIAPI Md5HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptMd5Null.c:155
UINTN EFIAPI Md5GetContextSize(VOID)
Definition: CryptMd5Null.c:20
#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