TianoCore EDK2 master
Loading...
Searching...
No Matches
Hash2DxeCrypto.c File Reference

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_INFOGetHashInfo (IN CONST EFI_GUID *HashAlgorithm)
 

Variables

EFI_HASH_INFO mHashInfo []
 
EFI_HASH2_PROTOCOL mHash2Protocol
 

Detailed Description

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.

Typedef Documentation

◆ EFI_HASH_FINAL

typedef BOOLEAN(EFIAPI * EFI_HASH_FINAL) (IN OUT VOID *HashContext, OUT UINT8 *HashValue)

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.

Parameters
[in,out]HashContextPointer to the Hash context.
[out]HashValuePointer to a buffer that receives the Hash digest value.
Return values
TRUEHash digest computation succeeded.
FALSEHash digest computation failed.
FALSEThis interface is not supported.

Definition at line 107 of file Hash2DxeCrypto.c.

◆ EFI_HASH_GET_CONTEXT_SIZE

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.

Returns
The size, in bytes, of the context buffer required for hash operations.
Return values
0This interface is not supported.

Definition at line 31 of file Hash2DxeCrypto.c.

◆ EFI_HASH_INIT

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.

Parameters
[out]HashContextPointer to Hashcontext being initialized.
Return values
TRUEHash context initialization succeeded.
FALSEHash context initialization failed.
FALSEThis interface is not supported.

Definition at line 51 of file Hash2DxeCrypto.c.

◆ EFI_HASH_UPDATE

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.

Parameters
[in,out]HashContextPointer to the Hash context.
[in]DataPointer to the buffer containing the data to be hashed.
[in]DataSizeSize of Data buffer in bytes.
Return values
TRUESHA-1 data digest succeeded.
FALSESHA-1 data digest failed.
FALSEThis interface is not supported.

Definition at line 77 of file Hash2DxeCrypto.c.

Function Documentation

◆ BaseCrypto2GetHashSize()

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.

Parameters
[in]ThisPoints to this instance of EFI_HASH2_PROTOCOL.
[in]HashAlgorithmPoints to the EFI_GUID which identifies the algorithm to use.
[out]HashSizeHolds the returned size of the algorithm's hash.
Return values
EFI_SUCCESSHash size returned successfully.
EFI_INVALID_PARAMETERThis or HashSize is NULL.
EFI_UNSUPPORTEDThe algorithm specified by HashAlgorithm is not supported by this driver or HashAlgorithm is null.

Definition at line 294 of file Hash2DxeCrypto.c.

◆ BaseCrypto2Hash()

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.

Parameters
[in]ThisPoints to this instance of EFI_HASH2_PROTOCOL.
[in]HashAlgorithmPoints to the EFI_GUID which identifies the algorithm to use.
[in]MessagePoints to the start of the message.
[in]MessageSizeThe size of Message, in bytes.
[in,out]HashOn 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.
Return values
EFI_SUCCESSHash returned successfully.
EFI_INVALID_PARAMETERThis or Hash is NULL.
EFI_UNSUPPORTEDThe algorithm specified by HashAlgorithm is not supported by this driver or HashAlgorithm is Null.
EFI_OUT_OF_RESOURCESSome resource required by the function is not available or MessageSize is greater than platform maximum.

Definition at line 341 of file Hash2DxeCrypto.c.

◆ BaseCrypto2HashFinal()

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().

Parameters
[in]ThisPoints to this instance of EFI_HASH2_PROTOCOL.
[in,out]HashOn 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.
Return values
EFI_SUCCESSHash returned successfully.
EFI_INVALID_PARAMETERThis or Hash is NULL.
EFI_NOT_READYThis 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.

◆ BaseCrypto2HashInit()

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().

Parameters
[in]ThisPoints to this instance of EFI_HASH2_PROTOCOL.
[in]HashAlgorithmPoints to the EFI_GUID which identifies the algorithm to use.
Return values
EFI_SUCCESSInitialized successfully.
EFI_INVALID_PARAMETERThis is NULL.
EFI_UNSUPPORTEDThe algorithm specified by HashAlgorithm is not supported by this driver or HashAlgorithm is Null.
EFI_OUT_OF_RESOURCESProcess failed due to lack of required resource.
EFI_ALREADY_STARTEDThis 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.

◆ BaseCrypto2HashUpdate()

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.

Parameters
[in]ThisPoints to this instance of EFI_HASH2_PROTOCOL.
[in]MessagePoints to the start of the message.
[in]MessageSizeThe size of Message, in bytes.
Return values
EFI_SUCCESSDigest in progress updated successfully.
EFI_INVALID_PARAMETERThis or Hash is NULL.
EFI_OUT_OF_RESOURCESSome resource required by the function is not available or MessageSize is greater than platform maximum.
EFI_NOT_READYThis 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.

◆ GetHashInfo()

EFI_HASH_INFO * GetHashInfo ( IN CONST EFI_GUID HashAlgorithm)

Returns hash information.

Parameters
[in]HashAlgorithmPoints to the EFI_GUID which identifies the algorithm to use.
Returns
Hash information.

Definition at line 264 of file Hash2DxeCrypto.c.

Variable Documentation

◆ mHash2Protocol

EFI_HASH2_PROTOCOL mHash2Protocol
Initial value:
= {
}
EFI_STATUS EFIAPI BaseCrypto2HashInit(IN CONST EFI_HASH2_PROTOCOL *This, IN CONST EFI_GUID *HashAlgorithm)
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 BaseCrypto2GetHashSize(IN CONST EFI_HASH2_PROTOCOL *This, IN CONST EFI_GUID *HashAlgorithm, OUT UINTN *HashSize)
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)

Definition at line 248 of file Hash2DxeCrypto.c.

◆ mHashInfo

EFI_HASH_INFO mHashInfo[]
Initial value:
= {
{ &gEfiHashAlgorithmSha256Guid, sizeof (EFI_SHA256_HASH2), Sha256GetContextSize, Sha256Init, Sha256Update, Sha256Final },
{ &gEfiHashAlgorithmSha384Guid, sizeof (EFI_SHA384_HASH2), Sha384GetContextSize, Sha384Init, Sha384Update, Sha384Final },
{ &gEfiHashAlgorithmSha512Guid, sizeof (EFI_SHA512_HASH2), Sha512GetContextSize, Sha512Init, Sha512Update, Sha512Final },
}
UINTN EFIAPI Sha256GetContextSize(VOID)
Definition: CryptSha256.c:20
UINTN EFIAPI Sha384GetContextSize(VOID)
Definition: CryptSha512.c:20
BOOLEAN EFIAPI Sha512Final(IN OUT VOID *Sha512Context, OUT UINT8 *HashValue)
Definition: CryptSha512.c:389
UINTN EFIAPI Sha512GetContextSize(VOID)
Definition: CryptSha512.c:246
BOOLEAN EFIAPI Sha512Init(OUT VOID *Sha512Context)
Definition: CryptSha512.c:270
BOOLEAN EFIAPI Sha256Init(OUT VOID *Sha256Context)
Definition: CryptSha256.c:44
BOOLEAN EFIAPI Sha256Final(IN OUT VOID *Sha256Context, OUT UINT8 *HashValue)
Definition: CryptSha256.c:161
BOOLEAN EFIAPI Sha384Update(IN OUT VOID *Sha384Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha512.c:115
BOOLEAN EFIAPI Sha256Update(IN OUT VOID *Sha256Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha256.c:113
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
Definition: CryptSha512.c:163
BOOLEAN EFIAPI Sha384Init(OUT VOID *Sha384Context)
Definition: CryptSha512.c:44
BOOLEAN EFIAPI Sha512Update(IN OUT VOID *Sha512Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha512.c:341

Definition at line 122 of file Hash2DxeCrypto.c.