1*f334afcfSToomas Soome /** @file 2*f334afcfSToomas Soome EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0. 3*f334afcfSToomas Soome EFI_HASH_PROTOCOL as defined in UEFI 2.0. 4*f334afcfSToomas Soome The EFI Hash Service Binding Protocol is used to locate hashing services support 5*f334afcfSToomas Soome provided by a driver and to create and destroy instances of the EFI Hash Protocol 6*f334afcfSToomas Soome so that a multiple drivers can use the underlying hashing services. 7*f334afcfSToomas Soome 8*f334afcfSToomas Soome Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 9*f334afcfSToomas Soome SPDX-License-Identifier: BSD-2-Clause-Patent 10*f334afcfSToomas Soome 11*f334afcfSToomas Soome **/ 12*f334afcfSToomas Soome 13*f334afcfSToomas Soome #ifndef __EFI_HASH_PROTOCOL_H__ 14*f334afcfSToomas Soome #define __EFI_HASH_PROTOCOL_H__ 15*f334afcfSToomas Soome 16*f334afcfSToomas Soome #define EFI_HASH_SERVICE_BINDING_PROTOCOL_GUID \ 17*f334afcfSToomas Soome { \ 18*f334afcfSToomas Soome 0x42881c98, 0xa4f3, 0x44b0, {0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } \ 19*f334afcfSToomas Soome } 20*f334afcfSToomas Soome 21*f334afcfSToomas Soome #define EFI_HASH_PROTOCOL_GUID \ 22*f334afcfSToomas Soome { \ 23*f334afcfSToomas Soome 0xc5184932, 0xdba5, 0x46db, {0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } \ 24*f334afcfSToomas Soome } 25*f334afcfSToomas Soome 26*f334afcfSToomas Soome #define EFI_HASH_ALGORITHM_SHA1_GUID \ 27*f334afcfSToomas Soome { \ 28*f334afcfSToomas Soome 0x2ae9d80f, 0x3fb2, 0x4095, {0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } \ 29*f334afcfSToomas Soome } 30*f334afcfSToomas Soome 31*f334afcfSToomas Soome #define EFI_HASH_ALGORITHM_SHA224_GUID \ 32*f334afcfSToomas Soome { \ 33*f334afcfSToomas Soome 0x8df01a06, 0x9bd5, 0x4bf7, {0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } \ 34*f334afcfSToomas Soome } 35*f334afcfSToomas Soome 36*f334afcfSToomas Soome #define EFI_HASH_ALGORITHM_SHA256_GUID \ 37*f334afcfSToomas Soome { \ 38*f334afcfSToomas Soome 0x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } \ 39*f334afcfSToomas Soome } 40*f334afcfSToomas Soome 41*f334afcfSToomas Soome #define EFI_HASH_ALGORITHM_SHA384_GUID \ 42*f334afcfSToomas Soome { \ 43*f334afcfSToomas Soome 0xefa96432, 0xde33, 0x4dd2, {0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } \ 44*f334afcfSToomas Soome } 45*f334afcfSToomas Soome 46*f334afcfSToomas Soome #define EFI_HASH_ALGORITHM_SHA512_GUID \ 47*f334afcfSToomas Soome { \ 48*f334afcfSToomas Soome 0xcaa4381e, 0x750c, 0x4770, {0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } \ 49*f334afcfSToomas Soome } 50*f334afcfSToomas Soome 51*f334afcfSToomas Soome #define EFI_HASH_ALGORTIHM_MD5_GUID \ 52*f334afcfSToomas Soome { \ 53*f334afcfSToomas Soome 0xaf7c79c, 0x65b5, 0x4319, {0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } \ 54*f334afcfSToomas Soome } 55*f334afcfSToomas Soome 56*f334afcfSToomas Soome #define EFI_HASH_ALGORITHM_SHA1_NOPAD_GUID \ 57*f334afcfSToomas Soome { \ 58*f334afcfSToomas Soome 0x24c5dc2f, 0x53e2, 0x40ca, {0x9e, 0xd6, 0xa5, 0xd9, 0xa4, 0x9f, 0x46, 0x3b } \ 59*f334afcfSToomas Soome } 60*f334afcfSToomas Soome 61*f334afcfSToomas Soome #define EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID \ 62*f334afcfSToomas Soome { \ 63*f334afcfSToomas Soome 0x8628752a, 0x6cb7, 0x4814, {0x96, 0xfc, 0x24, 0xa8, 0x15, 0xac, 0x22, 0x26 } \ 64*f334afcfSToomas Soome } 65*f334afcfSToomas Soome 66*f334afcfSToomas Soome // 67*f334afcfSToomas Soome // Note: Use of the following algorithms with EFI_HASH_PROTOCOL is deprecated. 68*f334afcfSToomas Soome // EFI_HASH_ALGORITHM_SHA1_GUID 69*f334afcfSToomas Soome // EFI_HASH_ALGORITHM_SHA224_GUID 70*f334afcfSToomas Soome // EFI_HASH_ALGORITHM_SHA256_GUID 71*f334afcfSToomas Soome // EFI_HASH_ALGORITHM_SHA384_GUID 72*f334afcfSToomas Soome // EFI_HASH_ALGORITHM_SHA512_GUID 73*f334afcfSToomas Soome // EFI_HASH_ALGORTIHM_MD5_GUID 74*f334afcfSToomas Soome // 75*f334afcfSToomas Soome 76*f334afcfSToomas Soome typedef struct _EFI_HASH_PROTOCOL EFI_HASH_PROTOCOL; 77*f334afcfSToomas Soome 78*f334afcfSToomas Soome typedef UINT8 EFI_MD5_HASH[16]; 79*f334afcfSToomas Soome typedef UINT8 EFI_SHA1_HASH[20]; 80*f334afcfSToomas Soome typedef UINT8 EFI_SHA224_HASH[28]; 81*f334afcfSToomas Soome typedef UINT8 EFI_SHA256_HASH[32]; 82*f334afcfSToomas Soome typedef UINT8 EFI_SHA384_HASH[48]; 83*f334afcfSToomas Soome typedef UINT8 EFI_SHA512_HASH[64]; 84*f334afcfSToomas Soome 85*f334afcfSToomas Soome typedef union { 86*f334afcfSToomas Soome EFI_MD5_HASH *Md5Hash; 87*f334afcfSToomas Soome EFI_SHA1_HASH *Sha1Hash; 88*f334afcfSToomas Soome EFI_SHA224_HASH *Sha224Hash; 89*f334afcfSToomas Soome EFI_SHA256_HASH *Sha256Hash; 90*f334afcfSToomas Soome EFI_SHA384_HASH *Sha384Hash; 91*f334afcfSToomas Soome EFI_SHA512_HASH *Sha512Hash; 92*f334afcfSToomas Soome } EFI_HASH_OUTPUT; 93*f334afcfSToomas Soome 94*f334afcfSToomas Soome /** 95*f334afcfSToomas Soome Returns the size of the hash which results from a specific algorithm. 96*f334afcfSToomas Soome 97*f334afcfSToomas Soome @param[in] This Points to this instance of EFI_HASH_PROTOCOL. 98*f334afcfSToomas Soome @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. 99*f334afcfSToomas Soome @param[out] HashSize Holds the returned size of the algorithm's hash. 100*f334afcfSToomas Soome 101*f334afcfSToomas Soome @retval EFI_SUCCESS Hash size returned successfully. 102*f334afcfSToomas Soome @retval EFI_INVALID_PARAMETER HashSize is NULL or HashAlgorithm is NULL. 103*f334afcfSToomas Soome @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported 104*f334afcfSToomas Soome by this driver. 105*f334afcfSToomas Soome 106*f334afcfSToomas Soome **/ 107*f334afcfSToomas Soome typedef 108*f334afcfSToomas Soome EFI_STATUS 109*f334afcfSToomas Soome (EFIAPI *EFI_HASH_GET_HASH_SIZE)( 110*f334afcfSToomas Soome IN CONST EFI_HASH_PROTOCOL *This, 111*f334afcfSToomas Soome IN CONST EFI_GUID *HashAlgorithm, 112*f334afcfSToomas Soome OUT UINTN *HashSize 113*f334afcfSToomas Soome ); 114*f334afcfSToomas Soome 115*f334afcfSToomas Soome /** 116*f334afcfSToomas Soome Creates a hash for the specified message text. 117*f334afcfSToomas Soome 118*f334afcfSToomas Soome @param[in] This Points to this instance of EFI_HASH_PROTOCOL. 119*f334afcfSToomas Soome @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. 120*f334afcfSToomas Soome @param[in] Extend Specifies whether to create a new hash (FALSE) or extend the specified 121*f334afcfSToomas Soome existing hash (TRUE). 122*f334afcfSToomas Soome @param[in] Message Points to the start of the message. 123*f334afcfSToomas Soome @param[in] MessageSize The size of Message, in bytes. 124*f334afcfSToomas Soome @param[in,out] Hash On input, if Extend is TRUE, then this parameter holds a pointer 125*f334afcfSToomas Soome to a pointer to an array containing the hash to extend. If Extend 126*f334afcfSToomas Soome is FALSE, then this parameter holds a pointer to a pointer to a 127*f334afcfSToomas Soome caller-allocated array that will receive the result of the hash 128*f334afcfSToomas Soome computation. On output (regardless of the value of Extend), the 129*f334afcfSToomas Soome array will contain the result of the hash computation. 130*f334afcfSToomas Soome 131*f334afcfSToomas Soome @retval EFI_SUCCESS Hash returned successfully. 132*f334afcfSToomas Soome @retval EFI_INVALID_PARAMETER Message or Hash, HashAlgorithm is NULL or MessageSize is 0. 133*f334afcfSToomas Soome MessageSize is not an integer multiple of block size. 134*f334afcfSToomas Soome @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this 135*f334afcfSToomas Soome driver. Or, Extend is TRUE, and the algorithm doesn't support extending the hash. 136*f334afcfSToomas Soome 137*f334afcfSToomas Soome **/ 138*f334afcfSToomas Soome typedef 139*f334afcfSToomas Soome EFI_STATUS 140*f334afcfSToomas Soome (EFIAPI *EFI_HASH_HASH)( 141*f334afcfSToomas Soome IN CONST EFI_HASH_PROTOCOL *This, 142*f334afcfSToomas Soome IN CONST EFI_GUID *HashAlgorithm, 143*f334afcfSToomas Soome IN BOOLEAN Extend, 144*f334afcfSToomas Soome IN CONST UINT8 *Message, 145*f334afcfSToomas Soome IN UINT64 MessageSize, 146*f334afcfSToomas Soome IN OUT EFI_HASH_OUTPUT *Hash 147*f334afcfSToomas Soome ); 148*f334afcfSToomas Soome 149*f334afcfSToomas Soome /// 150*f334afcfSToomas Soome /// This protocol allows creating a hash of an arbitrary message digest 151*f334afcfSToomas Soome /// using one or more hash algorithms. 152*f334afcfSToomas Soome /// 153*f334afcfSToomas Soome struct _EFI_HASH_PROTOCOL { 154*f334afcfSToomas Soome EFI_HASH_GET_HASH_SIZE GetHashSize; 155*f334afcfSToomas Soome EFI_HASH_HASH Hash; 156*f334afcfSToomas Soome }; 157*f334afcfSToomas Soome 158*f334afcfSToomas Soome extern EFI_GUID gEfiHashServiceBindingProtocolGuid; 159*f334afcfSToomas Soome extern EFI_GUID gEfiHashProtocolGuid; 160*f334afcfSToomas Soome extern EFI_GUID gEfiHashAlgorithmSha1Guid; 161*f334afcfSToomas Soome extern EFI_GUID gEfiHashAlgorithmSha224Guid; 162*f334afcfSToomas Soome extern EFI_GUID gEfiHashAlgorithmSha256Guid; 163*f334afcfSToomas Soome extern EFI_GUID gEfiHashAlgorithmSha384Guid; 164*f334afcfSToomas Soome extern EFI_GUID gEfiHashAlgorithmSha512Guid; 165*f334afcfSToomas Soome extern EFI_GUID gEfiHashAlgorithmMD5Guid; 166*f334afcfSToomas Soome extern EFI_GUID gEfiHashAlgorithmSha1NoPadGuid; 167*f334afcfSToomas Soome extern EFI_GUID gEfiHashAlgorithmSha256NoPadGuid; 168*f334afcfSToomas Soome 169*f334afcfSToomas Soome #endif 170