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