]>
git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c
2 MD4 Digest Wrapper Implementation over OpenSSL.
4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "InternalCryptLib.h"
10 #include <openssl/md4.h>
13 Retrieves the size, in bytes, of the context buffer required for MD4 hash operations.
15 @return The size, in bytes, of the context buffer required for MD4 hash operations.
25 // Retrieves the OpenSSL MD4 Context Size
27 return (UINTN
) (sizeof (MD4_CTX
));
31 Initializes user-supplied memory pointed by Md4Context as MD4 hash context for
34 If Md4Context is NULL, then return FALSE.
36 @param[out] Md4Context Pointer to MD4 context being initialized.
38 @retval TRUE MD4 context initialization succeeded.
39 @retval FALSE MD4 context initialization failed.
49 // Check input parameters.
51 if (Md4Context
== NULL
) {
56 // OpenSSL MD4 Context Initialization
58 return (BOOLEAN
) (MD4_Init ((MD4_CTX
*) Md4Context
));
62 Makes a copy of an existing MD4 context.
64 If Md4Context is NULL, then return FALSE.
65 If NewMd4Context is NULL, then return FALSE.
67 @param[in] Md4Context Pointer to MD4 context being copied.
68 @param[out] NewMd4Context Pointer to new MD4 context.
70 @retval TRUE MD4 context copy succeeded.
71 @retval FALSE MD4 context copy failed.
77 IN CONST VOID
*Md4Context
,
78 OUT VOID
*NewMd4Context
82 // Check input parameters.
84 if (Md4Context
== NULL
|| NewMd4Context
== NULL
) {
88 CopyMem (NewMd4Context
, Md4Context
, sizeof (MD4_CTX
));
94 Digests the input data and updates MD4 context.
96 This function performs MD4 digest on a data buffer of the specified size.
97 It can be called multiple times to compute the digest of long or discontinuous data streams.
98 MD4 context should be already correctly initialized by Md4Init(), and should not be finalized
99 by Md4Final(). Behavior with invalid context is undefined.
101 If Md4Context is NULL, then return FALSE.
103 @param[in, out] Md4Context Pointer to the MD4 context.
104 @param[in] Data Pointer to the buffer containing the data to be hashed.
105 @param[in] DataSize Size of Data buffer in bytes.
107 @retval TRUE MD4 data digest succeeded.
108 @retval FALSE MD4 data digest failed.
114 IN OUT VOID
*Md4Context
,
120 // Check input parameters.
122 if (Md4Context
== NULL
) {
127 // Check invalid parameters, in case that only DataLength was checked in OpenSSL
129 if (Data
== NULL
&& DataSize
!= 0) {
134 // OpenSSL MD4 Hash Update
136 return (BOOLEAN
) (MD4_Update ((MD4_CTX
*) Md4Context
, Data
, DataSize
));
140 Completes computation of the MD4 digest value.
142 This function completes MD4 hash computation and retrieves the digest value into
143 the specified memory. After this function has been called, the MD4 context cannot
145 MD4 context should be already correctly initialized by Md4Init(), and should not be
146 finalized by Md4Final(). Behavior with invalid MD4 context is undefined.
148 If Md4Context is NULL, then return FALSE.
149 If HashValue is NULL, then return FALSE.
151 @param[in, out] Md4Context Pointer to the MD4 context.
152 @param[out] HashValue Pointer to a buffer that receives the MD4 digest
155 @retval TRUE MD4 digest computation succeeded.
156 @retval FALSE MD4 digest computation failed.
162 IN OUT VOID
*Md4Context
,
167 // Check input parameters.
169 if (Md4Context
== NULL
|| HashValue
== NULL
) {
174 // OpenSSL MD4 Hash Finalization
176 return (BOOLEAN
) (MD4_Final (HashValue
, (MD4_CTX
*) Md4Context
));
180 Computes the MD4 message digest of a input data buffer.
182 This function performs the MD4 message digest of a given data buffer, and places
183 the digest value into the specified memory.
185 If this interface is not supported, then return FALSE.
187 @param[in] Data Pointer to the buffer containing the data to be hashed.
188 @param[in] DataSize Size of Data buffer in bytes.
189 @param[out] HashValue Pointer to a buffer that receives the MD4 digest
192 @retval TRUE MD4 digest computation succeeded.
193 @retval FALSE MD4 digest computation failed.
194 @retval FALSE This interface is not supported.
206 // Check input parameters.
208 if (HashValue
== NULL
) {
211 if (Data
== NULL
&& DataSize
!= 0) {
216 // OpenSSL MD4 Hash Computation.
218 if (MD4 (Data
, DataSize
, HashValue
) == NULL
) {