]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Hash.h
e5cc8ded3a04eb26d59c0a34706ec38c3f3130ef
[mirror_edk2.git] / MdePkg / Include / Protocol / Hash.h
1 /** @file
2 EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.
3 EFI_HASH_PROTOCOL as defined in UEFI 2.0.
4 The EFI Hash Service Binding Protocol is used to locate hashing services support
5 provided by a driver and to create and destroy instances of the EFI Hash Protocol
6 so that a multiple drivers can use the underlying hashing services.
7 The EFI Service Binding Protocol defines the generic Service Binding Protocol functions.
8
9 Copyright (c) 2006 - 2008, Intel Corporation
10 All rights reserved. This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
14
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17
18 **/
19
20 #ifndef __EFI_HASH_PROTOCOL_H__
21 #define __EFI_HASH_PROTOCOL_H__
22
23 #define EFI_HASH_SERVICE_BINDING_PROTOCOL \
24 { \
25 0x42881c98, 0xa4f3, 0x44b0, {0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } \
26 }
27
28 #define EFI_HASH_PROTOCOL_GUID \
29 { \
30 0xc5184932, 0xdba5, 0x46db, {0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } \
31 }
32
33 #define EFI_HASH_ALGORITHM_SHA1_GUID \
34 { \
35 0x2ae9d80f, 0x3fb2, 0x4095, {0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } \
36 }
37
38 #define EFI_HASH_ALGORITHM_SHA224_GUID \
39 { \
40 0x8df01a06, 0x9bd5, 0x4bf7, {0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } \
41 }
42
43 #define EFI_HASH_ALGORITHM_SHA256_GUID \
44 { \
45 0x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } \
46 }
47
48 #define EFI_HASH_ALGORITHM_SHA384_GUID \
49 { \
50 0xefa96432, 0xde33, 0x4dd2, {0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } \
51 }
52
53 #define EFI_HASH_ALGORITHM_SHA512_GUID \
54 { \
55 0xcaa4381e, 0x750c, 0x4770, {0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } \
56 }
57
58 #define EFI_HASH_ALGORTIHM_MD5_GUID \
59 { \
60 0xaf7c79c, 0x65b5, 0x4319, {0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } \
61 }
62
63 typedef struct _EFI_HASH_PROTOCOL EFI_HASH_PROTOCOL;
64
65 typedef UINT8 EFI_MD5_HASH[16];
66 typedef UINT8 EFI_SHA1_HASH[20];
67 typedef UINT8 EFI_SHA224_HASH[28];
68 typedef UINT8 EFI_SHA256_HASH[32];
69 typedef UINT8 EFI_SHA384_HASH[48];
70 typedef UINT8 EFI_SHA512_HASH[64];
71
72 typedef union {
73 EFI_MD5_HASH *Md5Hash;
74 EFI_SHA1_HASH *Sha1Hash;
75 EFI_SHA224_HASH *Sha224Hash;
76 EFI_SHA256_HASH *Sha256Hash;
77 EFI_SHA384_HASH *Sha384Hash;
78 EFI_SHA512_HASH *Sha512Hash;
79 } EFI_HASH_OUTPUT;
80
81 /**
82 Returns the size of the hash that results from a specific algorithm.
83
84 @param This Points to this instance of EFI_HASH_PROTOCOL.
85 @param HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
86 @param HashSize Holds the returned size of the algorithm's hash.
87
88 @retval EFI_SUCCESS Hash size returned successfully.
89 @retval EFI_INVALID_PARAMETER HashSize is NULL
90 @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported
91 by this driver.
92
93 **/
94 typedef
95 EFI_STATUS
96 (EFIAPI *EFI_HASH_GET_HASH_SIZE)(
97 IN CONST EFI_HASH_PROTOCOL *This,
98 IN CONST EFI_GUID *HashAlgorithm,
99 OUT UINTN *HashSize
100 );
101
102 /**
103 Returns the size of the hash that results from a specific algorithm.
104
105 @param This Points to this instance of EFI_HASH_PROTOCOL.
106 @param HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
107 @param Extend Specifies whether to create a new hash (FALSE) or extend the specified
108 existing hash (TRUE).
109 @param Message Points to the start of the message.
110 @param MessageSize The size of Message, in bytes.
111 @param Hash On input, if Extend is TRUE, then this holds the hash to extend. On
112 output, holds the resulting hash computed from the message.
113
114 @retval EFI_SUCCESS Hash returned successfully.
115 @retval EFI_INVALID_PARAMETER Message or Hash is NULL
116 @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this
117 driver. Or extend is TRUE and the algorithm doesn't support extending the hash.
118
119 **/
120 typedef
121 EFI_STATUS
122 (EFIAPI *EFI_HASH_HASH)(
123 IN CONST EFI_HASH_PROTOCOL *This,
124 IN CONST EFI_GUID *HashAlgorithm,
125 IN BOOLEAN Extend,
126 IN CONST UINT8 *Message,
127 IN UINT64 MessageSize,
128 IN OUT EFI_HASH_OUTPUT *Hash
129 );
130
131 ///
132 /// This protocol allows creating a hash of an arbitrary message digest
133 /// using one or more hash algorithms.
134 ///
135 struct _EFI_HASH_PROTOCOL {
136 EFI_HASH_GET_HASH_SIZE GetHashSize;
137 EFI_HASH_HASH Hash;
138 };
139
140 extern EFI_GUID gEfiHashServiceBindingProtocolGuid;
141 extern EFI_GUID gEfiHashProtocolGuid;
142 extern EFI_GUID gEfiHashAlgorithmSha1Guid;
143 extern EFI_GUID gEfiHashAlgorithmSha224Guid;
144 extern EFI_GUID gEfiHashAlgorithmSha256Guid;
145 extern EFI_GUID gEfiHashAlgorithmSha384Guid;
146 extern EFI_GUID gEfiHashAlgorithmSha512Guid;
147 extern EFI_GUID gEfiHashAlgorithmMD5Guid;
148
149 #endif