TianoCore EDK2 master
Loading...
Searching...
No Matches
HashLib.h File Reference
#include <Uefi.h>
#include <Protocol/Hash.h>
#include <IndustryStandard/Tpm20.h>

Go to the source code of this file.

Data Structures

struct  HASH_INTERFACE
 

Macros

#define HASH_ALGORITHM_SHA1_GUID   EFI_HASH_ALGORITHM_SHA1_GUID
 
#define HASH_ALGORITHM_SHA256_GUID   EFI_HASH_ALGORITHM_SHA256_GUID
 
#define HASH_ALGORITHM_SHA384_GUID   EFI_HASH_ALGORITHM_SHA384_GUID
 
#define HASH_ALGORITHM_SHA512_GUID   EFI_HASH_ALGORITHM_SHA512_GUID
 
#define HASH_ALGORITHM_SM3_256_GUID
 

Typedefs

typedef UINTN HASH_HANDLE
 
typedef EFI_STATUS(EFIAPI * HASH_INIT) (OUT HASH_HANDLE *HashHandle)
 
typedef EFI_STATUS(EFIAPI * HASH_UPDATE) (IN HASH_HANDLE HashHandle, IN VOID *DataToHash, IN UINTN DataToHashLen)
 
typedef EFI_STATUS(EFIAPI * HASH_FINAL) (IN HASH_HANDLE HashHandle, OUT TPML_DIGEST_VALUES *DigestList)
 

Functions

EFI_STATUS EFIAPI HashStart (OUT HASH_HANDLE *HashHandle)
 
EFI_STATUS EFIAPI HashUpdate (IN HASH_HANDLE HashHandle, IN VOID *DataToHash, IN UINTN DataToHashLen)
 
EFI_STATUS EFIAPI HashCompleteAndExtend (IN HASH_HANDLE HashHandle, IN TPMI_DH_PCR PcrIndex, IN VOID *DataToHash, IN UINTN DataToHashLen, OUT TPML_DIGEST_VALUES *DigestList)
 
EFI_STATUS EFIAPI HashAndExtend (IN TPMI_DH_PCR PcrIndex, IN VOID *DataToHash, IN UINTN DataToHashLen, OUT TPML_DIGEST_VALUES *DigestList)
 
EFI_STATUS EFIAPI RegisterHashInterfaceLib (IN HASH_INTERFACE *HashInterface)
 

Detailed Description

This library abstract TPM2 hash calculation. The platform can choose multiply hash, while caller just need invoke these API. Then all hash value will be returned and/or extended.

Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file HashLib.h.

Macro Definition Documentation

◆ HASH_ALGORITHM_SHA1_GUID

#define HASH_ALGORITHM_SHA1_GUID   EFI_HASH_ALGORITHM_SHA1_GUID

Definition at line 136 of file HashLib.h.

◆ HASH_ALGORITHM_SHA256_GUID

#define HASH_ALGORITHM_SHA256_GUID   EFI_HASH_ALGORITHM_SHA256_GUID

Definition at line 137 of file HashLib.h.

◆ HASH_ALGORITHM_SHA384_GUID

#define HASH_ALGORITHM_SHA384_GUID   EFI_HASH_ALGORITHM_SHA384_GUID

Definition at line 138 of file HashLib.h.

◆ HASH_ALGORITHM_SHA512_GUID

#define HASH_ALGORITHM_SHA512_GUID   EFI_HASH_ALGORITHM_SHA512_GUID

Definition at line 139 of file HashLib.h.

◆ HASH_ALGORITHM_SM3_256_GUID

#define HASH_ALGORITHM_SM3_256_GUID
Value:
{ \
0x251C7818, 0x0DBF, 0xE619, { 0x7F, 0xC2, 0xD6, 0xAC, 0x43, 0x42, 0x7D, 0xA3 } \
}

Definition at line 140 of file HashLib.h.

Typedef Documentation

◆ HASH_FINAL

typedef EFI_STATUS(EFIAPI * HASH_FINAL) (IN HASH_HANDLE HashHandle, OUT TPML_DIGEST_VALUES *DigestList)

Complete hash sequence complete.

Parameters
HashHandleHash handle.
DigestListDigest list.
Return values
EFI_SUCCESSHash sequence complete and DigestList is returned.

Definition at line 130 of file HashLib.h.

◆ HASH_HANDLE

typedef UINTN HASH_HANDLE

Definition at line 17 of file HashLib.h.

◆ HASH_INIT

typedef EFI_STATUS(EFIAPI * HASH_INIT) (OUT HASH_HANDLE *HashHandle)

Start hash sequence.

Parameters
HashHandleHash handle.
Return values
EFI_SUCCESSHash sequence start and HandleHandle returned.
EFI_OUT_OF_RESOURCESNo enough resource to start hash.

Definition at line 99 of file HashLib.h.

◆ HASH_UPDATE

typedef EFI_STATUS(EFIAPI * HASH_UPDATE) (IN HASH_HANDLE HashHandle, IN VOID *DataToHash, IN UINTN DataToHashLen)

Update hash sequence data.

Parameters
HashHandleHash handle.
DataToHashData to be hashed.
DataToHashLenData size.
Return values
EFI_SUCCESSHash sequence updated.

Definition at line 114 of file HashLib.h.

Function Documentation

◆ HashAndExtend()

EFI_STATUS EFIAPI HashAndExtend ( IN TPMI_DH_PCR  PcrIndex,
IN VOID *  DataToHash,
IN UINTN  DataToHashLen,
OUT TPML_DIGEST_VALUES DigestList 
)

Hash data and extend to PCR.

Parameters
PcrIndexPCR to be extended.
DataToHashData to be hashed.
DataToHashLenData size.
DigestListDigest list.
Return values
EFI_SUCCESSHash data and DigestList is returned.

Hash data and extend to RTMR.

Parameters
PcrIndexPCR to be extended.
DataToHashData to be hashed.
DataToHashLenData size.
DigestListDigest list.
Return values
EFI_SUCCESSHash data and DigestList is returned.

Definition at line 150 of file HashLibTdx.c.

◆ HashCompleteAndExtend()

EFI_STATUS EFIAPI HashCompleteAndExtend ( IN HASH_HANDLE  HashHandle,
IN TPMI_DH_PCR  PcrIndex,
IN VOID *  DataToHash,
IN UINTN  DataToHashLen,
OUT TPML_DIGEST_VALUES DigestList 
)

Hash sequence complete and extend to PCR.

Parameters
HashHandleHash handle.
PcrIndexPCR to be extended.
DataToHashData to be hashed.
DataToHashLenData size.
DigestListDigest list.
Return values
EFI_SUCCESSHash sequence complete and DigestList is returned.

Definition at line 98 of file HashLibTdx.c.

◆ HashStart()

EFI_STATUS EFIAPI HashStart ( OUT HASH_HANDLE *  HashHandle)

Start hash sequence.

Parameters
HashHandleHash handle.
Return values
EFI_SUCCESSHash sequence start and HandleHandle returned.
EFI_OUT_OF_RESOURCESNo enough resource to start hash.

Definition at line 39 of file HashLibTdx.c.

◆ HashUpdate()

EFI_STATUS EFIAPI HashUpdate ( IN HASH_HANDLE  HashHandle,
IN VOID *  DataToHash,
IN UINTN  DataToHashLen 
)

Update hash sequence data.

Parameters
HashHandleHash handle.
DataToHashData to be hashed.
DataToHashLenData size.
Return values
EFI_SUCCESSHash sequence updated.

Definition at line 69 of file HashLibTdx.c.

◆ RegisterHashInterfaceLib()

EFI_STATUS EFIAPI RegisterHashInterfaceLib ( IN HASH_INTERFACE HashInterface)

This service register Hash.

Parameters
HashInterfaceHash interface
Return values
EFI_SUCCESSThis hash interface is registered successfully.
EFI_UNSUPPORTEDSystem does not support register this interface.
EFI_ALREADY_STARTEDSystem already register this interface.

Definition at line 185 of file HashLibTdx.c.