TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptMd5.c
Go to the documentation of this file.
1
9#include "InternalCryptLib.h"
10#include <openssl/md5.h>
11
12#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
13
21EFIAPI
23 VOID
24 )
25{
26 //
27 // Retrieves the OpenSSL MD5 Context Size
28 //
29 return (UINTN)(sizeof (MD5_CTX));
30}
31
44BOOLEAN
45EFIAPI
46Md5Init (
47 OUT VOID *Md5Context
48 )
49{
50 //
51 // Check input parameters.
52 //
53 if (Md5Context == NULL) {
54 return FALSE;
55 }
56
57 //
58 // OpenSSL MD5 Context Initialization
59 //
60 return (BOOLEAN)(MD5_Init ((MD5_CTX *)Md5Context));
61}
62
76BOOLEAN
77EFIAPI
79 IN CONST VOID *Md5Context,
80 OUT VOID *NewMd5Context
81 )
82{
83 //
84 // Check input parameters.
85 //
86 if ((Md5Context == NULL) || (NewMd5Context == NULL)) {
87 return FALSE;
88 }
89
90 CopyMem (NewMd5Context, Md5Context, sizeof (MD5_CTX));
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 //
122 // Check input parameters.
123 //
124 if (Md5Context == NULL) {
125 return FALSE;
126 }
127
128 //
129 // Check invalid parameters, in case that only DataLength was checked in OpenSSL
130 //
131 if ((Data == NULL) && (DataSize != 0)) {
132 return FALSE;
133 }
134
135 //
136 // OpenSSL MD5 Hash Update
137 //
138 return (BOOLEAN)(MD5_Update ((MD5_CTX *)Md5Context, Data, DataSize));
139}
140
161BOOLEAN
162EFIAPI
163Md5Final (
164 IN OUT VOID *Md5Context,
165 OUT UINT8 *HashValue
166 )
167{
168 //
169 // Check input parameters.
170 //
171 if ((Md5Context == NULL) || (HashValue == NULL)) {
172 return FALSE;
173 }
174
175 //
176 // OpenSSL MD5 Hash Finalization
177 //
178 return (BOOLEAN)(MD5_Final (HashValue, (MD5_CTX *)Md5Context));
179}
180
199BOOLEAN
200EFIAPI
202 IN CONST VOID *Data,
203 IN UINTN DataSize,
204 OUT UINT8 *HashValue
205 )
206{
207 //
208 // Check input parameters.
209 //
210 if (HashValue == NULL) {
211 return FALSE;
212 }
213
214 if ((Data == NULL) && (DataSize != 0)) {
215 return FALSE;
216 }
217
218 //
219 // OpenSSL MD5 Hash Computation.
220 //
221 if (MD5 (Data, DataSize, HashValue) == NULL) {
222 return FALSE;
223 } else {
224 return TRUE;
225 }
226}
227
228#endif
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
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