Path: blob/main/sys/contrib/edk2/Include/Protocol/Hash.h
96339 views
/** @file1EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.2EFI_HASH_PROTOCOL as defined in UEFI 2.0.3The EFI Hash Service Binding Protocol is used to locate hashing services support4provided by a driver and to create and destroy instances of the EFI Hash Protocol5so that a multiple drivers can use the underlying hashing services.67Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>8SPDX-License-Identifier: BSD-2-Clause-Patent910**/1112#ifndef __EFI_HASH_PROTOCOL_H__13#define __EFI_HASH_PROTOCOL_H__1415#define EFI_HASH_SERVICE_BINDING_PROTOCOL_GUID \16{ \170x42881c98, 0xa4f3, 0x44b0, {0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } \18}1920#define EFI_HASH_PROTOCOL_GUID \21{ \220xc5184932, 0xdba5, 0x46db, {0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } \23}2425#define EFI_HASH_ALGORITHM_SHA1_GUID \26{ \270x2ae9d80f, 0x3fb2, 0x4095, {0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } \28}2930#define EFI_HASH_ALGORITHM_SHA224_GUID \31{ \320x8df01a06, 0x9bd5, 0x4bf7, {0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } \33}3435#define EFI_HASH_ALGORITHM_SHA256_GUID \36{ \370x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } \38}3940#define EFI_HASH_ALGORITHM_SHA384_GUID \41{ \420xefa96432, 0xde33, 0x4dd2, {0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } \43}4445#define EFI_HASH_ALGORITHM_SHA512_GUID \46{ \470xcaa4381e, 0x750c, 0x4770, {0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } \48}4950#define EFI_HASH_ALGORTIHM_MD5_GUID \51{ \520xaf7c79c, 0x65b5, 0x4319, {0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } \53}5455#define EFI_HASH_ALGORITHM_SHA1_NOPAD_GUID \56{ \570x24c5dc2f, 0x53e2, 0x40ca, {0x9e, 0xd6, 0xa5, 0xd9, 0xa4, 0x9f, 0x46, 0x3b } \58}5960#define EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID \61{ \620x8628752a, 0x6cb7, 0x4814, {0x96, 0xfc, 0x24, 0xa8, 0x15, 0xac, 0x22, 0x26 } \63}6465//66// Note: Use of the following algorithms with EFI_HASH_PROTOCOL is deprecated.67// EFI_HASH_ALGORITHM_SHA1_GUID68// EFI_HASH_ALGORITHM_SHA224_GUID69// EFI_HASH_ALGORITHM_SHA256_GUID70// EFI_HASH_ALGORITHM_SHA384_GUID71// EFI_HASH_ALGORITHM_SHA512_GUID72// EFI_HASH_ALGORTIHM_MD5_GUID73//7475typedef struct _EFI_HASH_PROTOCOL EFI_HASH_PROTOCOL;7677typedef UINT8 EFI_MD5_HASH[16];78typedef UINT8 EFI_SHA1_HASH[20];79typedef UINT8 EFI_SHA224_HASH[28];80typedef UINT8 EFI_SHA256_HASH[32];81typedef UINT8 EFI_SHA384_HASH[48];82typedef UINT8 EFI_SHA512_HASH[64];8384typedef union {85EFI_MD5_HASH *Md5Hash;86EFI_SHA1_HASH *Sha1Hash;87EFI_SHA224_HASH *Sha224Hash;88EFI_SHA256_HASH *Sha256Hash;89EFI_SHA384_HASH *Sha384Hash;90EFI_SHA512_HASH *Sha512Hash;91} EFI_HASH_OUTPUT;9293/**94Returns the size of the hash which results from a specific algorithm.9596@param[in] This Points to this instance of EFI_HASH_PROTOCOL.97@param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.98@param[out] HashSize Holds the returned size of the algorithm's hash.99100@retval EFI_SUCCESS Hash size returned successfully.101@retval EFI_INVALID_PARAMETER HashSize is NULL or HashAlgorithm is NULL.102@retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported103by this driver.104105**/106typedef107EFI_STATUS108(EFIAPI *EFI_HASH_GET_HASH_SIZE)(109IN CONST EFI_HASH_PROTOCOL *This,110IN CONST EFI_GUID *HashAlgorithm,111OUT UINTN *HashSize112);113114/**115Creates a hash for the specified message text.116117@param[in] This Points to this instance of EFI_HASH_PROTOCOL.118@param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.119@param[in] Extend Specifies whether to create a new hash (FALSE) or extend the specified120existing hash (TRUE).121@param[in] Message Points to the start of the message.122@param[in] MessageSize The size of Message, in bytes.123@param[in,out] Hash On input, if Extend is TRUE, then this parameter holds a pointer124to a pointer to an array containing the hash to extend. If Extend125is FALSE, then this parameter holds a pointer to a pointer to a126caller-allocated array that will receive the result of the hash127computation. On output (regardless of the value of Extend), the128array will contain the result of the hash computation.129130@retval EFI_SUCCESS Hash returned successfully.131@retval EFI_INVALID_PARAMETER Message or Hash, HashAlgorithm is NULL or MessageSize is 0.132MessageSize is not an integer multiple of block size.133@retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this134driver. Or, Extend is TRUE, and the algorithm doesn't support extending the hash.135136**/137typedef138EFI_STATUS139(EFIAPI *EFI_HASH_HASH)(140IN CONST EFI_HASH_PROTOCOL *This,141IN CONST EFI_GUID *HashAlgorithm,142IN BOOLEAN Extend,143IN CONST UINT8 *Message,144IN UINT64 MessageSize,145IN OUT EFI_HASH_OUTPUT *Hash146);147148///149/// This protocol allows creating a hash of an arbitrary message digest150/// using one or more hash algorithms.151///152struct _EFI_HASH_PROTOCOL {153EFI_HASH_GET_HASH_SIZE GetHashSize;154EFI_HASH_HASH Hash;155};156157extern EFI_GUID gEfiHashServiceBindingProtocolGuid;158extern EFI_GUID gEfiHashProtocolGuid;159extern EFI_GUID gEfiHashAlgorithmSha1Guid;160extern EFI_GUID gEfiHashAlgorithmSha224Guid;161extern EFI_GUID gEfiHashAlgorithmSha256Guid;162extern EFI_GUID gEfiHashAlgorithmSha384Guid;163extern EFI_GUID gEfiHashAlgorithmSha512Guid;164extern EFI_GUID gEfiHashAlgorithmMD5Guid;165extern EFI_GUID gEfiHashAlgorithmSha1NoPadGuid;166extern EFI_GUID gEfiHashAlgorithmSha256NoPadGuid;167168#endif169170171