]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Include/Library/HashApiLib.h
MdeModulePkg: Make retval in UninstallMultipleProtocol follow Spec
[mirror_edk2.git] / CryptoPkg / Include / Library / HashApiLib.h
CommitLineData
3feea54e
AS
1/** @file\r
2 Unified Hash API Defines\r
3\r
4 This API when called will calculate the Hash using the\r
5 hashing algorithm specified by PcdHashApiLibPolicy.\r
6\r
7 Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
9\r
10**/\r
11\r
12#ifndef __BASEHASHAPILIB_H_\r
13#define __BASEHASHAPILIB_H_\r
14\r
15typedef VOID *HASH_API_CONTEXT;\r
16\r
17//\r
18// Hash Algorithms\r
19//\r
20#define HASH_API_ALGO_INVALID 0x00000000\r
21#define HASH_API_ALGO_MD4 0x00000001\r
22#define HASH_API_ALGO_MD5 0x00000002\r
23#define HASH_API_ALGO_SHA1 0x00000003\r
24#define HASH_API_ALGO_SHA256 0x00000004\r
25#define HASH_API_ALGO_SHA384 0x00000005\r
26#define HASH_API_ALGO_SHA512 0x00000006\r
27#define HASH_API_ALGO_SM3_256 0x00000007\r
28\r
29/**\r
30 Retrieves the size, in bytes, of the context buffer required for hash operations.\r
31\r
32 @return The size, in bytes, of the context buffer required for hash operations.\r
33**/\r
34UINTN\r
35EFIAPI\r
36HashApiGetContextSize (\r
37 VOID\r
38 );\r
39\r
40/**\r
41 Init hash sequence.\r
42\r
43 @param[out] HashContext Hash context.\r
44\r
45 @retval TRUE Hash start and HashHandle returned.\r
46 @retval FALSE Hash Init unsuccessful.\r
47**/\r
48BOOLEAN\r
49EFIAPI\r
50HashApiInit (\r
51 OUT HASH_API_CONTEXT HashContext\r
52 );\r
53\r
54/**\r
55 Makes a copy of an existing hash context.\r
56\r
57 @param[in] HashContext Hash context.\r
58 @param[out] NewHashContext New copy of hash context.\r
59\r
60 @retval TRUE Hash context copy succeeded.\r
61 @retval FALSE Hash context copy failed.\r
62**/\r
63BOOLEAN\r
64EFIAPI\r
65HashApiDuplicate (\r
66 IN HASH_API_CONTEXT HashContext,\r
67 OUT HASH_API_CONTEXT NewHashContext\r
68 );\r
69\r
70/**\r
71 Update hash data.\r
72\r
73 @param[in] HashContext Hash context.\r
74 @param[in] DataToHash Data to be hashed.\r
75 @param[in] DataToHashLen Data size.\r
76\r
77 @retval TRUE Hash updated.\r
78 @retval FALSE Hash updated unsuccessful.\r
79**/\r
80BOOLEAN\r
81EFIAPI\r
82HashApiUpdate (\r
83 IN HASH_API_CONTEXT HashContext,\r
84 IN VOID *DataToHash,\r
85 IN UINTN DataToHashLen\r
86 );\r
87\r
88/**\r
89 Hash complete.\r
90\r
91 @param[in] HashContext Hash context.\r
92 @param[out] Digest Hash Digest.\r
93\r
94 @retval TRUE Hash complete and Digest is returned.\r
95 @retval FALSE Hash complete unsuccessful.\r
96**/\r
97BOOLEAN\r
98EFIAPI\r
99HashApiFinal (\r
100 IN HASH_API_CONTEXT HashContext,\r
101 OUT UINT8 *Digest\r
102 );\r
103\r
104/**\r
105 Computes hash message digest of a input data buffer.\r
106\r
107 @param[in] DataToHash Data to be hashed.\r
108 @param[in] DataToHashLen Data size.\r
109 @param[out] Digest Hash Digest.\r
110\r
111 @retval TRUE Hash digest computation succeeded.\r
112 @retval FALSE Hash digest computation failed.\r
113**/\r
114BOOLEAN\r
115EFIAPI\r
116HashApiHashAll (\r
117 IN CONST VOID *DataToHash,\r
118 IN UINTN DataToHashLen,\r
119 OUT UINT8 *Digest\r
120 );\r
121\r
122#endif\r