1 /** @file
2   Header file for Md5.
3 
4 Copyright (c) 2004 - 2008, 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
9 
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.
12 
13 **/
14 
15 #ifndef _MD5_H_
16 #define _MD5_H_
17 
18 #include <Uefi.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/NetLib.h>
22 
23 #define MD5_HASHSIZE  16
24 
25 typedef struct _MD5_CTX {
26   EFI_STATUS  Status;
27   UINT64      Length;
28   UINT32      States[MD5_HASHSIZE / sizeof (UINT32)];
29   UINT8       M[64];
30   UINTN       Count;
31 } MD5_CTX;
32 
33 /**
34   Initialize four 32-bits chaining variables and use them to do the Md5 transform.
35 
36   @param[out]  Md5Ctx The data structure of Md5.
37 
38   @retval EFI_SUCCESS Initialization is ok.
39 **/
40 EFI_STATUS
41 MD5Init (
42   OUT MD5_CTX  *Md5Ctx
43   );
44 
45 /**
46   the external interface of Md5 algorithm
47 
48   @param[in, out]  Md5Ctx  The data structure of storing the original data
49                            segment and the final result.
50   @param[in]       Data    The data wanted to be transformed.
51   @param[in]       DataLen The length of data.
52 
53   @retval EFI_SUCCESS The transform is ok.
54   @retval Others      Other errors as indicated.
55 **/
56 EFI_STATUS
57 MD5Update (
58   IN  OUT MD5_CTX  *Md5Ctx,
59   IN  VOID         *Data,
60   IN  UINTN        DataLen
61   );
62 
63 /**
64   Accumulate the MD5 value of every data segment and generate the finial
65   result according to MD5 algorithm.
66 
67   @param[in, out]   Md5Ctx  The data structure of storing the original data
68                             segment and the final result.
69   @param[out]      HashVal  The final 128-bits output.
70 
71   @retval EFI_SUCCESS  The transform is ok.
72   @retval Others       Other errors as indicated.
73 **/
74 EFI_STATUS
75 MD5Final (
76   IN  OUT MD5_CTX  *Md5Ctx,
77   OUT UINT8        *HashVal
78   );
79 
80 #endif
81