]>
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 - 2012, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "InternalCryptLib.h"
16 #include <openssl/md4.h>
19 Retrieves the size, in bytes, of the context buffer required for MD4 hash operations.
21 @return The size, in bytes, of the context buffer required for MD4 hash operations.
31 // Retrieves the OpenSSL MD4 Context Size
33 return (UINTN
) (sizeof (MD4_CTX
));
37 Initializes user-supplied memory pointed by Md4Context as MD4 hash context for
40 If Md4Context is NULL, then return FALSE.
42 @param[out] Md4Context Pointer to MD4 context being initialized.
44 @retval TRUE MD4 context initialization succeeded.
45 @retval FALSE MD4 context initialization failed.
55 // Check input parameters.
57 if (Md4Context
== NULL
) {
62 // OpenSSL MD4 Context Initialization
64 return (BOOLEAN
) (MD4_Init ((MD4_CTX
*) Md4Context
));
68 Makes a copy of an existing MD4 context.
70 If Md4Context is NULL, then return FALSE.
71 If NewMd4Context is NULL, then return FALSE.
73 @param[in] Md4Context Pointer to MD4 context being copied.
74 @param[out] NewMd4Context Pointer to new MD4 context.
76 @retval TRUE MD4 context copy succeeded.
77 @retval FALSE MD4 context copy failed.
83 IN CONST VOID
*Md4Context
,
84 OUT VOID
*NewMd4Context
88 // Check input parameters.
90 if (Md4Context
== NULL
|| NewMd4Context
== NULL
) {
94 CopyMem (NewMd4Context
, Md4Context
, sizeof (MD4_CTX
));
100 Digests the input data and updates MD4 context.
102 This function performs MD4 digest on a data buffer of the specified size.
103 It can be called multiple times to compute the digest of long or discontinuous data streams.
104 MD4 context should be already correctly intialized by Md4Init(), and should not be finalized
105 by Md4Final(). Behavior with invalid context is undefined.
107 If Md4Context is NULL, then return FALSE.
109 @param[in, out] Md4Context Pointer to the MD4 context.
110 @param[in] Data Pointer to the buffer containing the data to be hashed.
111 @param[in] DataSize Size of Data buffer in bytes.
113 @retval TRUE MD4 data digest succeeded.
114 @retval FALSE MD4 data digest failed.
120 IN OUT VOID
*Md4Context
,
126 // Check input parameters.
128 if (Md4Context
== NULL
) {
133 // Check invalid parameters, in case that only DataLength was checked in OpenSSL
135 if (Data
== NULL
&& DataSize
!= 0) {
140 // OpenSSL MD4 Hash Update
142 return (BOOLEAN
) (MD4_Update ((MD4_CTX
*) Md4Context
, Data
, DataSize
));
146 Completes computation of the MD4 digest value.
148 This function completes MD4 hash computation and retrieves the digest value into
149 the specified memory. After this function has been called, the MD4 context cannot
151 MD4 context should be already correctly intialized by Md4Init(), and should not be
152 finalized by Md4Final(). Behavior with invalid MD4 context is undefined.
154 If Md4Context is NULL, then return FALSE.
155 If HashValue is NULL, then return FALSE.
157 @param[in, out] Md4Context Pointer to the MD4 context.
158 @param[out] HashValue Pointer to a buffer that receives the MD4 digest
161 @retval TRUE MD4 digest computation succeeded.
162 @retval FALSE MD4 digest computation failed.
168 IN OUT VOID
*Md4Context
,
173 // Check input parameters.
175 if (Md4Context
== NULL
|| HashValue
== NULL
) {
180 // OpenSSL MD4 Hash Finalization
182 return (BOOLEAN
) (MD4_Final (HashValue
, (MD4_CTX
*) Md4Context
));