--- /dev/null
+/** @file\r
+ EFI_HASH2_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.5.\r
+ EFI_HASH2_PROTOCOL as defined in UEFI 2.5.\r
+ The EFI Hash2 Service Binding Protocol is used to locate hashing services support\r
+ provided by a driver and to create and destroy instances of the EFI Hash2 Protocol\r
+ so that a multiple drivers can use the underlying hashing services.\r
+ EFI_HASH2_PROTOCOL describes hashing functions for which the algorithm-required\r
+ message padding and finalization are performed by the supporting driver.\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under\r
+the terms and conditions of the BSD License that accompanies this distribution.\r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __EFI_HASH2_PROTOCOL_H__\r
+#define __EFI_HASH2_PROTOCOL_H__\r
+\r
+#define EFI_HASH2_SERVICE_BINDING_PROTOCOL_GUID \\r
+ { \\r
+ 0xda836f8d, 0x217f, 0x4ca0, { 0x99, 0xc2, 0x1c, 0xa4, 0xe1, 0x60, 0x77, 0xea } \\r
+ }\r
+\r
+#define EFI_HASH2_PROTOCOL_GUID \\r
+ { \\r
+ 0x55b1d734, 0xc5e1, 0x49db, { 0x96, 0x47, 0xb1, 0x6a, 0xfb, 0xe, 0x30, 0x5b } \\r
+ }\r
+\r
+#include <Protocol/Hash.h>\r
+\r
+//\r
+// NOTE:\r
+// Algorithms EFI_HASH_ALGORITHM_SHA1_NOPAD and\r
+// EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID are not compatible with\r
+// EFI_HASH2_PROTOCOL and will return EFI_UNSUPPORTED if used with any\r
+// EFI_HASH2_PROTOCOL function.\r
+//\r
+\r
+//\r
+// Note: SHA-1 and MD5 are included for backwards compatibility.\r
+// New driver implementations are encouraged to consider stronger algorithms.\r
+//\r
+\r
+typedef struct _EFI_HASH2_PROTOCOL EFI_HASH2_PROTOCOL;\r
+\r
+typedef UINT8 EFI_MD5_HASH2[16];\r
+typedef UINT8 EFI_SHA1_HASH2[20];\r
+typedef UINT8 EFI_SHA224_HASH2[28];\r
+typedef UINT8 EFI_SHA256_HASH2[32];\r
+typedef UINT8 EFI_SHA384_HASH2[48];\r
+typedef UINT8 EFI_SHA512_HASH2[64];\r
+\r
+typedef union {\r
+ EFI_MD5_HASH2 Md5Hash;\r
+ EFI_SHA1_HASH2 Sha1Hash;\r
+ EFI_SHA224_HASH2 Sha224Hash;\r
+ EFI_SHA256_HASH2 Sha256Hash;\r
+ EFI_SHA384_HASH2 Sha384Hash;\r
+ EFI_SHA512_HASH2 Sha512Hash;\r
+} EFI_HASH2_OUTPUT;\r
+\r
+/**\r
+ Returns the size of the hash which results from a specific algorithm.\r
+\r
+ @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.\r
+ @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.\r
+ @param[out] HashSize Holds the returned size of the algorithm's hash.\r
+\r
+ @retval EFI_SUCCESS Hash size returned successfully.\r
+ @retval EFI_INVALID_PARAMETER This or HashSize is NULL.\r
+ @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver\r
+ or HashAlgorithm is null.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HASH2_GET_HASH_SIZE)(\r
+ IN CONST EFI_HASH2_PROTOCOL *This,\r
+ IN CONST EFI_GUID *HashAlgorithm,\r
+ OUT UINTN *HashSize\r
+ );\r
+\r
+/**\r
+ Creates a hash for the specified message text. The hash is not extendable.\r
+ The output is final with any algorithm-required padding added by the function.\r
+\r
+ @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.\r
+ @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.\r
+ @param[in] Message Points to the start of the message.\r
+ @param[in] MessageSize The size of Message, in bytes.\r
+ @param[in,out] Hash On input, points to a caller-allocated buffer of the size\r
+ returned by GetHashSize() for the specified HashAlgorithm.\r
+ On output, the buffer holds the resulting hash computed from the message.\r
+\r
+ @retval EFI_SUCCESS Hash returned successfully.\r
+ @retval EFI_INVALID_PARAMETER This or Hash is NULL.\r
+ @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver\r
+ or HashAlgorithm is Null.\r
+ @retval EFI_OUT_OF_RESOURCES Some resource required by the function is not available\r
+ or MessageSize is greater than platform maximum.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HASH2_HASH)(\r
+ IN CONST EFI_HASH2_PROTOCOL *This,\r
+ IN CONST EFI_GUID *HashAlgorithm,\r
+ IN CONST UINT8 *Message,\r
+ IN UINTN MessageSize,\r
+ IN OUT EFI_HASH2_OUTPUT *Hash\r
+ );\r
+\r
+/**\r
+ This function must be called to initialize a digest calculation to be subsequently performed using the\r
+ EFI_HASH2_PROTOCOL functions HashUpdate() and HashFinal().\r
+\r
+ @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.\r
+ @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.\r
+\r
+ @retval EFI_SUCCESS Initialized successfully.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver\r
+ or HashAlgorithm is Null.\r
+ @retval EFI_OUT_OF_RESOURCES Process failed due to lack of required resource.\r
+ @retval EFI_ALREADY_STARTED This function is called when the operation in progress is still in processing Hash(),\r
+ or HashInit() is already called before and not terminated by HashFinal() yet on the same instance.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HASH2_HASH_INIT)(\r
+ IN CONST EFI_HASH2_PROTOCOL *This,\r
+ IN CONST EFI_GUID *HashAlgorithm\r
+ );\r
+\r
+/**\r
+ Updates the hash of a computation in progress by adding a message text.\r
+\r
+ @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.\r
+ @param[in] Message Points to the start of the message.\r
+ @param[in] MessageSize The size of Message, in bytes.\r
+\r
+ @retval EFI_SUCCESS Digest in progress updated successfully.\r
+ @retval EFI_INVALID_PARAMETER This or Hash is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES Some resource required by the function is not available\r
+ or MessageSize is greater than platform maximum.\r
+ @retval EFI_NOT_READY This call was not preceded by a valid call to HashInit(),\r
+ or the operation in progress was terminated by a call to Hash() or HashFinal() on the same instance.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HASH2_HASH_UPDATE)(\r
+ IN CONST EFI_HASH2_PROTOCOL *This,\r
+ IN CONST UINT8 *Message,\r
+ IN UINTN MessageSize\r
+ );\r
+\r
+/**\r
+ Finalizes a hash operation in progress and returns calculation result.\r
+ The output is final with any necessary padding added by the function.\r
+ The hash may not be further updated or extended after HashFinal().\r
+\r
+ @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.\r
+ @param[in,out] Hash On input, points to a caller-allocated buffer of the size\r
+ returned by GetHashSize() for the specified HashAlgorithm specified in preceding HashInit().\r
+ On output, the buffer holds the resulting hash computed from the message.\r
+\r
+ @retval EFI_SUCCESS Hash returned successfully.\r
+ @retval EFI_INVALID_PARAMETER This or Hash is NULL.\r
+ @retval EFI_NOT_READY This call was not preceded by a valid call to HashInit() and at least one call to HashUpdate(),\r
+ or the operation in progress was canceled by a call to Hash() on the same instance.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_HASH2_HASH_FINAL)(\r
+ IN CONST EFI_HASH2_PROTOCOL *This,\r
+ IN OUT EFI_HASH2_OUTPUT *Hash\r
+ );\r
+\r
+///\r
+/// This protocol describes hashing functions for which the algorithm-required message padding and\r
+/// finalization are performed by the supporting driver.\r
+///\r
+struct _EFI_HASH2_PROTOCOL {\r
+ EFI_HASH2_GET_HASH_SIZE GetHashSize;\r
+ EFI_HASH2_HASH Hash;\r
+ EFI_HASH2_HASH_INIT HashInit;\r
+ EFI_HASH2_HASH_UPDATE HashUpdate;\r
+ EFI_HASH2_HASH_FINAL HashFinal;\r
+};\r
+\r
+extern EFI_GUID gEfiHash2ServiceBindingProtocolGuid;\r
+extern EFI_GUID gEfiHash2ProtocolGuid;\r
+\r
+#endif\r