TianoCore EDK2 master
|
#include <Uefi.h>
#include <Protocol/Hash2.h>
#include <Library/BaseLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseCryptLib.h>
#include "Driver.h"
Go to the source code of this file.
Data Structures | |
struct | EFI_HASH_INFO |
Typedefs | |
typedef UINTN(EFIAPI * | EFI_HASH_GET_CONTEXT_SIZE) (VOID) |
typedef BOOLEAN(EFIAPI * | EFI_HASH_INIT) (OUT VOID *HashContext) |
typedef BOOLEAN(EFIAPI * | EFI_HASH_UPDATE) (IN OUT VOID *HashContext, IN CONST VOID *Data, IN UINTN DataSize) |
typedef BOOLEAN(EFIAPI * | EFI_HASH_FINAL) (IN OUT VOID *HashContext, OUT UINT8 *HashValue) |
Functions | |
EFI_STATUS EFIAPI | BaseCrypto2GetHashSize (IN CONST EFI_HASH2_PROTOCOL *This, IN CONST EFI_GUID *HashAlgorithm, OUT UINTN *HashSize) |
EFI_STATUS EFIAPI | BaseCrypto2Hash (IN CONST EFI_HASH2_PROTOCOL *This, IN CONST EFI_GUID *HashAlgorithm, IN CONST UINT8 *Message, IN UINTN MessageSize, IN OUT EFI_HASH2_OUTPUT *Hash) |
EFI_STATUS EFIAPI | BaseCrypto2HashInit (IN CONST EFI_HASH2_PROTOCOL *This, IN CONST EFI_GUID *HashAlgorithm) |
EFI_STATUS EFIAPI | BaseCrypto2HashUpdate (IN CONST EFI_HASH2_PROTOCOL *This, IN CONST UINT8 *Message, IN UINTN MessageSize) |
EFI_STATUS EFIAPI | BaseCrypto2HashFinal (IN CONST EFI_HASH2_PROTOCOL *This, IN OUT EFI_HASH2_OUTPUT *Hash) |
EFI_HASH_INFO * | GetHashInfo (IN CONST EFI_GUID *HashAlgorithm) |
Variables | |
EFI_HASH_INFO | mHashInfo [] |
EFI_HASH2_PROTOCOL | mHash2Protocol |
This module implements Hash2 Protocol.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Hash2DxeCrypto.c.
Completes computation of the Hash digest value.
This function completes hash computation and retrieves the digest value into the specified memory. After this function has been called, the Hash context cannot be used again. Hash context should be already correctly initialized by HashInit(), and should not be finalized by HashFinal(). Behavior with invalid Hash context is undefined.
If HashContext is NULL, then return FALSE. If HashValue is NULL, then return FALSE. If this interface is not supported, then return FALSE.
[in,out] | HashContext | Pointer to the Hash context. |
[out] | HashValue | Pointer to a buffer that receives the Hash digest value. |
TRUE | Hash digest computation succeeded. |
FALSE | Hash digest computation failed. |
FALSE | This interface is not supported. |
Definition at line 107 of file Hash2DxeCrypto.c.
typedef UINTN(EFIAPI * EFI_HASH_GET_CONTEXT_SIZE) (VOID) |
Retrieves the size, in bytes, of the context buffer required for hash operations.
If this interface is not supported, then return zero.
0 | This interface is not supported. |
Definition at line 31 of file Hash2DxeCrypto.c.
typedef BOOLEAN(EFIAPI * EFI_HASH_INIT) (OUT VOID *HashContext) |
Initializes user-supplied memory pointed by Sha1Context as hash context for subsequent use.
If HashContext is NULL, then return FALSE. If this interface is not supported, then return FALSE.
[out] | HashContext | Pointer to Hashcontext being initialized. |
TRUE | Hash context initialization succeeded. |
FALSE | Hash context initialization failed. |
FALSE | This interface is not supported. |
Definition at line 51 of file Hash2DxeCrypto.c.
typedef BOOLEAN(EFIAPI * EFI_HASH_UPDATE) (IN OUT VOID *HashContext, IN CONST VOID *Data, IN UINTN DataSize) |
Digests the input data and updates Hash context.
This function performs Hash digest on a data buffer of the specified size. It can be called multiple times to compute the digest of long or discontinuous data streams. Hash context should be already correctly initialized by HashInit(), and should not be finalized by HashFinal(). Behavior with invalid context is undefined.
If HashContext is NULL, then return FALSE. If this interface is not supported, then return FALSE.
[in,out] | HashContext | Pointer to the Hash context. |
[in] | Data | Pointer to the buffer containing the data to be hashed. |
[in] | DataSize | Size of Data buffer in bytes. |
TRUE | SHA-1 data digest succeeded. |
FALSE | SHA-1 data digest failed. |
FALSE | This interface is not supported. |
Definition at line 77 of file Hash2DxeCrypto.c.
EFI_STATUS EFIAPI BaseCrypto2GetHashSize | ( | IN CONST EFI_HASH2_PROTOCOL * | This, |
IN CONST EFI_GUID * | HashAlgorithm, | ||
OUT UINTN * | HashSize | ||
) |
Returns the size of the hash which results from a specific algorithm.
[in] | This | Points to this instance of EFI_HASH2_PROTOCOL. |
[in] | HashAlgorithm | Points to the EFI_GUID which identifies the algorithm to use. |
[out] | HashSize | Holds the returned size of the algorithm's hash. |
EFI_SUCCESS | Hash size returned successfully. |
EFI_INVALID_PARAMETER | This or HashSize is NULL. |
EFI_UNSUPPORTED | The algorithm specified by HashAlgorithm is not supported by this driver or HashAlgorithm is null. |
Definition at line 294 of file Hash2DxeCrypto.c.
EFI_STATUS EFIAPI BaseCrypto2Hash | ( | IN CONST EFI_HASH2_PROTOCOL * | This, |
IN CONST EFI_GUID * | HashAlgorithm, | ||
IN CONST UINT8 * | Message, | ||
IN UINTN | MessageSize, | ||
IN OUT EFI_HASH2_OUTPUT * | Hash | ||
) |
Creates a hash for the specified message text. The hash is not extendable. The output is final with any algorithm-required padding added by the function.
[in] | This | Points to this instance of EFI_HASH2_PROTOCOL. |
[in] | HashAlgorithm | Points to the EFI_GUID which identifies the algorithm to use. |
[in] | Message | Points to the start of the message. |
[in] | MessageSize | The size of Message, in bytes. |
[in,out] | Hash | On input, points to a caller-allocated buffer of the size returned by GetHashSize() for the specified HashAlgorithm. On output, the buffer holds the resulting hash computed from the message. |
EFI_SUCCESS | Hash returned successfully. |
EFI_INVALID_PARAMETER | This or Hash is NULL. |
EFI_UNSUPPORTED | The algorithm specified by HashAlgorithm is not supported by this driver or HashAlgorithm is Null. |
EFI_OUT_OF_RESOURCES | Some resource required by the function is not available or MessageSize is greater than platform maximum. |
Definition at line 341 of file Hash2DxeCrypto.c.
EFI_STATUS EFIAPI BaseCrypto2HashFinal | ( | IN CONST EFI_HASH2_PROTOCOL * | This, |
IN OUT EFI_HASH2_OUTPUT * | Hash | ||
) |
Finalizes a hash operation in progress and returns calculation result. The output is final with any necessary padding added by the function. The hash may not be further updated or extended after HashFinal().
[in] | This | Points to this instance of EFI_HASH2_PROTOCOL. |
[in,out] | Hash | On input, points to a caller-allocated buffer of the size returned by GetHashSize() for the specified HashAlgorithm specified in preceding HashInit(). On output, the buffer holds the resulting hash computed from the message. |
EFI_SUCCESS | Hash returned successfully. |
EFI_INVALID_PARAMETER | This or Hash is NULL. |
EFI_NOT_READY | This call was not preceded by a valid call to HashInit() and at least one call to HashUpdate(), or the operation in progress was canceled by a call to Hash() on the same instance. |
Definition at line 576 of file Hash2DxeCrypto.c.
EFI_STATUS EFIAPI BaseCrypto2HashInit | ( | IN CONST EFI_HASH2_PROTOCOL * | This, |
IN CONST EFI_GUID * | HashAlgorithm | ||
) |
This function must be called to initialize a digest calculation to be subsequently performed using the EFI_HASH2_PROTOCOL functions HashUpdate() and HashFinal().
[in] | This | Points to this instance of EFI_HASH2_PROTOCOL. |
[in] | HashAlgorithm | Points to the EFI_GUID which identifies the algorithm to use. |
EFI_SUCCESS | Initialized successfully. |
EFI_INVALID_PARAMETER | This is NULL. |
EFI_UNSUPPORTED | The algorithm specified by HashAlgorithm is not supported by this driver or HashAlgorithm is Null. |
EFI_OUT_OF_RESOURCES | Process failed due to lack of required resource. |
EFI_ALREADY_STARTED | This function is called when the operation in progress is still in processing Hash(), or HashInit() is already called before and not terminated by HashFinal() yet on the same instance. |
Definition at line 444 of file Hash2DxeCrypto.c.
EFI_STATUS EFIAPI BaseCrypto2HashUpdate | ( | IN CONST EFI_HASH2_PROTOCOL * | This, |
IN CONST UINT8 * | Message, | ||
IN UINTN | MessageSize | ||
) |
Updates the hash of a computation in progress by adding a message text.
[in] | This | Points to this instance of EFI_HASH2_PROTOCOL. |
[in] | Message | Points to the start of the message. |
[in] | MessageSize | The size of Message, in bytes. |
EFI_SUCCESS | Digest in progress updated successfully. |
EFI_INVALID_PARAMETER | This or Hash is NULL. |
EFI_OUT_OF_RESOURCES | Some resource required by the function is not available or MessageSize is greater than platform maximum. |
EFI_NOT_READY | This call was not preceded by a valid call to HashInit(), or the operation in progress was terminated by a call to Hash() or HashFinal() on the same instance. |
Definition at line 522 of file Hash2DxeCrypto.c.
EFI_HASH_INFO * GetHashInfo | ( | IN CONST EFI_GUID * | HashAlgorithm | ) |
Returns hash information.
[in] | HashAlgorithm | Points to the EFI_GUID which identifies the algorithm to use. |
Definition at line 264 of file Hash2DxeCrypto.c.
EFI_HASH2_PROTOCOL mHash2Protocol |
Definition at line 248 of file Hash2DxeCrypto.c.
EFI_HASH_INFO mHashInfo[] |
Definition at line 122 of file Hash2DxeCrypto.c.