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

Go to the source code of this file.

Data Structures

struct  TCG_FIND_FEATURE_CTX
 

Macros

#define C(status)   case TCG_METHOD_STATUS_CODE_ ## status: return #status
 

Functions

CHAR8 *EFIAPI TcgMethodStatusString (UINT8 MethodStatus)
 
TCG_RESULT EFIAPI TcgStartMethodCall (TCG_CREATE_STRUCT *CreateStruct, TCG_UID InvokingId, TCG_UID MethodId)
 
TCG_RESULT EFIAPI TcgStartParameters (TCG_CREATE_STRUCT *CreateStruct)
 
TCG_RESULT EFIAPI TcgEndParameters (TCG_CREATE_STRUCT *CreateStruct)
 
TCG_RESULT EFIAPI TcgEndMethodCall (TCG_CREATE_STRUCT *CreateStruct)
 
TCG_RESULT EFIAPI TcgGetComIds (const TCG_PARSE_STRUCT *ParseStruct, UINT16 *ComId, UINT16 *ComIdExtension)
 
TCG_RESULT EFIAPI TcgCheckComIds (const TCG_PARSE_STRUCT *ParseStruct, UINT16 ExpectedComId, UINT16 ExpectedComIdExtension)
 
TCG_RESULT EFIAPI TcgGetMethodStatus (const TCG_PARSE_STRUCT *ParseStruct, UINT8 *MethodStatus)
 
CHAR8 *EFIAPI TcgTokenTypeString (TCG_TOKEN_TYPE Type)
 
TCG_RESULT EFIAPI TcgCreateStartSession (TCG_CREATE_STRUCT *CreateStruct, UINT32 *Size, UINT16 ComId, UINT16 ComIdExtension, UINT32 HostSessionId, TCG_UID SpId, BOOLEAN Write, UINT32 HostChallengeLength, const VOID *HostChallenge, TCG_UID HostSigningAuthority)
 
TCG_RESULT EFIAPI TcgParseSyncSession (const TCG_PARSE_STRUCT *ParseStruct, UINT16 ComId, UINT16 ComIdExtension, UINT32 HostSessionId, UINT32 *TperSessionId)
 
TCG_RESULT EFIAPI TcgCreateEndSession (TCG_CREATE_STRUCT *CreateStruct, UINT32 *Size, UINT16 ComId, UINT16 ComIdExtension, UINT32 HostSessionId, UINT32 TpSessionId)
 
TCG_RESULT EFIAPI TcgStartMethodSet (TCG_CREATE_STRUCT *CreateStruct, TCG_UID Row, UINT32 ColumnNumber)
 
TCG_RESULT EFIAPI TcgEndMethodSet (TCG_CREATE_STRUCT *CreateStruct)
 
TCG_RESULT EFIAPI TcgCreateSetCPin (TCG_CREATE_STRUCT *CreateStruct, UINT32 *Size, UINT16 ComId, UINT16 ComIdExtension, UINT32 TperSession, UINT32 HostSession, TCG_UID SidRow, const VOID *Password, UINT32 PasswordSize)
 
TCG_RESULT EFIAPI TcgSetAuthorityEnabled (TCG_CREATE_STRUCT *CreateStruct, UINT32 *Size, UINT16 ComId, UINT16 ComIdExtension, UINT32 TperSession, UINT32 HostSession, TCG_UID AuthorityUid, BOOLEAN Enabled)
 
TCG_RESULT EFIAPI TcgCreateSetAce (TCG_CREATE_STRUCT *CreateStruct, UINT32 *Size, UINT16 ComId, UINT16 ComIdExtension, UINT32 TperSession, UINT32 HostSession, TCG_UID AceRow, TCG_UID Authority1, BOOLEAN LogicalOperator, TCG_UID Authority2)
 
BOOLEAN EFIAPI TcgEnumLevel0Discovery (const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader, TCG_LEVEL0_ENUM_CALLBACK Callback, VOID *Context)
 
BOOLEAN EFIAPI TcgFindFeatureCallback (const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader, TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature, UINTN FeatureSize, VOID *Context)
 
TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *EFIAPI TcgGetFeature (const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader, UINT16 FeatureCode, UINTN *FeatureSize)
 
BOOLEAN EFIAPI TcgIsProtocolSupported (const TCG_SUPPORTED_SECURITY_PROTOCOLS *ProtocolList, UINT16 Protocol)
 
BOOLEAN EFIAPI TcgIsLocked (const TCG_LEVEL0_DISCOVERY_HEADER *Discovery)
 

Detailed Description

Provide functions to provide tcg storage core spec related functions.

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

Definition in file TcgStorageUtil.c.

Function Documentation

◆ TcgCheckComIds()

TCG_RESULT EFIAPI TcgCheckComIds ( const TCG_PARSE_STRUCT ParseStruct,
UINT16  ExpectedComId,
UINT16  ExpectedComIdExtension 
)

Checks if the ComIDs of the response match the expected values.

Parameters
[in]ParseStructStructure used to parse received TCG response
[in]ExpectedComIdExpected comID
[in]ExpectedComIdExtensionExpected extended comID

Definition at line 224 of file TcgStorageUtil.c.

◆ TcgCreateEndSession()

TCG_RESULT EFIAPI TcgCreateEndSession ( TCG_CREATE_STRUCT CreateStruct,
UINT32 *  Size,
UINT16  ComId,
UINT16  ComIdExtension,
UINT32  HostSessionId,
UINT32  TpSessionId 
)

Creates ComPacket with EndSession. This assumes a start session has already been opened.

Parameters
[in/out]CreateStruct Structure used to add Endsession
[in/out]Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
[in]ComIdComID for the ComPacket
[in]ComIdExtensionExtended ComID for the ComPacket
[in]HostSessionIdHost Session ID for the Packet
[in]TpSessionIdTper Session ID for the Packet

Definition at line 493 of file TcgStorageUtil.c.

◆ TcgCreateSetAce()

TCG_RESULT EFIAPI TcgCreateSetAce ( TCG_CREATE_STRUCT CreateStruct,
UINT32 *  Size,
UINT16  ComId,
UINT16  ComIdExtension,
UINT32  TperSession,
UINT32  HostSession,
TCG_UID  AceRow,
TCG_UID  Authority1,
BOOLEAN  LogicalOperator,
TCG_UID  Authority2 
)

Create set ace.

Parameters
CreateStructInput create structure.
Sizesize info.
ComIdComId info.
ComIdExtensionComId extension info.
TperSessionTper session data.
HostSessionHost session data.
AceRowAce row info.
Authority1Authority 1 info.
LogicalOperatorLogical operator info.
Authority2Authority 2 info.
Return values
Returnthe action result.

Definition at line 659 of file TcgStorageUtil.c.

◆ TcgCreateSetCPin()

TCG_RESULT EFIAPI TcgCreateSetCPin ( TCG_CREATE_STRUCT CreateStruct,
UINT32 *  Size,
UINT16  ComId,
UINT16  ComIdExtension,
UINT32  TperSession,
UINT32  HostSession,
TCG_UID  SidRow,
const VOID *  Password,
UINT32  PasswordSize 
)

Creates ComPacket with a Method call that sets the PIN column for the row specified. This assumes a start session has already been opened with the desired SP.

Parameters
[in/out]CreateStruct Structure used to add method call.
[in/out]Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
[in]ComIdComID for the ComPacket
[in]ComIdExtensionExtended ComID for the ComPacket
[in]TperSessionTper Session ID for the Packet
[in]HostSessionHost Session ID for the Packet
[in]SidRowUID of row of current SP to set PIN column
[in]Passwordvalue of PIN to set
[in]PasswordSizeSize of PIN

Definition at line 576 of file TcgStorageUtil.c.

◆ TcgCreateStartSession()

TCG_RESULT EFIAPI TcgCreateStartSession ( TCG_CREATE_STRUCT CreateStruct,
UINT32 *  Size,
UINT16  ComId,
UINT16  ComIdExtension,
UINT32  HostSessionId,
TCG_UID  SpId,
BOOLEAN  Write,
UINT32  HostChallengeLength,
const VOID *  HostChallenge,
TCG_UID  HostSigningAuthority 
)

Adds Start Session call to the data structure. This creates the entire ComPacket structure and returns the size of the entire compacket in the size parameter.

Parameters
[in/out]CreateStruct Structure used to add the start session call
[in/out]Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
[in]ComIdComID for the ComPacket
[in]ComIdExtensionExtended ComID for the ComPacket
[in]HostSessionIdHost Session ID
[in]SpIdSecurity Provider to start session with
[in]WriteWrite option for start session. TRUE = start session requests write access
[in]HostChallengeLengthLength of the host challenge. Length should be 0 if hostChallenge is NULL
[in]HostChallengeHost challenge for Host Signing Authority. If NULL, then no Host Challenge shall be sent.
[in]HostSigningAuthorityHost Signing Authority used for start session. If NULL, then no Host Signing Authority shall be sent.

Definition at line 358 of file TcgStorageUtil.c.

◆ TcgEndMethodCall()

TCG_RESULT EFIAPI TcgEndMethodCall ( TCG_CREATE_STRUCT CreateStruct)

Adds END Data token and method list.

Parameters
CreateStructThe input create structure.

Definition at line 156 of file TcgStorageUtil.c.

◆ TcgEndMethodSet()

TCG_RESULT EFIAPI TcgEndMethodSet ( TCG_CREATE_STRUCT CreateStruct)

Set end method.

Parameters
CreateStructInput create structure.

Definition at line 547 of file TcgStorageUtil.c.

◆ TcgEndParameters()

TCG_RESULT EFIAPI TcgEndParameters ( TCG_CREATE_STRUCT CreateStruct)

Adds END LIST token.

Parameters
CreateStructThe input create structure.

Definition at line 130 of file TcgStorageUtil.c.

◆ TcgEnumLevel0Discovery()

BOOLEAN EFIAPI TcgEnumLevel0Discovery ( const TCG_LEVEL0_DISCOVERY_HEADER DiscoveryHeader,
TCG_LEVEL0_ENUM_CALLBACK  Callback,
VOID *  Context 
)

Enum level 0 discovery.

Parameters
DiscoveryHeaderDiscovery header.
CallbackCallback function.
ContextThe context for the function.
Return values
returntrue if the callback return TRUE, else return FALSE.

Definition at line 723 of file TcgStorageUtil.c.

◆ TcgFindFeatureCallback()

BOOLEAN EFIAPI TcgFindFeatureCallback ( const TCG_LEVEL0_DISCOVERY_HEADER DiscoveryHeader,
TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER Feature,
UINTN  FeatureSize,
VOID *  Context 
)

The callback function for Get Feature function.

Parameters
DiscoveryHeaderInput discovery header.
FeatureInput Feature.
FeatureSizeInput Feature size.
ContextThe context.

Definition at line 799 of file TcgStorageUtil.c.

◆ TcgGetComIds()

TCG_RESULT EFIAPI TcgGetComIds ( const TCG_PARSE_STRUCT ParseStruct,
UINT16 *  ComId,
UINT16 *  ComIdExtension 
)

Retrieves the comID and Extended comID of the ComPacket in the Tcg response. It is intended to be used to confirm the received Tcg response is intended for user that received it.

Parameters
[in]ParseStructStructure used to parse received TCG response.
[in/out]ComId comID retrieved from received ComPacket.
[in/out]ComIdExtension Extended comID retrieved from received ComPacket

Definition at line 193 of file TcgStorageUtil.c.

◆ TcgGetFeature()

TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *EFIAPI TcgGetFeature ( const TCG_LEVEL0_DISCOVERY_HEADER DiscoveryHeader,
UINT16  FeatureCode,
UINTN FeatureSize 
)

Get Feature code from the header.

Parameters
DiscoveryHeaderThe discovery header.
FeatureCodereturn the Feature code.
FeatureSizereturn the Feature size.
Return values
returnthe Feature code data.

Definition at line 829 of file TcgStorageUtil.c.

◆ TcgGetMethodStatus()

TCG_RESULT EFIAPI TcgGetMethodStatus ( const TCG_PARSE_STRUCT ParseStruct,
UINT8 *  MethodStatus 
)

Returns the method status of the current subpacket. Does not affect the current position in the ComPacket. In other words, it can be called whenever you have a valid SubPacket.

Parameters
[in/out]ParseStruct Structure used to parse received TCG response
[in/out]MethodStatus Method status retrieved of the current SubPacket

Definition at line 253 of file TcgStorageUtil.c.

◆ TcgIsLocked()

BOOLEAN EFIAPI TcgIsLocked ( const TCG_LEVEL0_DISCOVERY_HEADER Discovery)

Check whether lock or not.

Parameters
Discovery
Return values
TRUEif lock, FALSE if not lock.

Definition at line 892 of file TcgStorageUtil.c.

◆ TcgIsProtocolSupported()

BOOLEAN EFIAPI TcgIsProtocolSupported ( const TCG_SUPPORTED_SECURITY_PROTOCOLS ProtocolList,
UINT16  Protocol 
)

Determines if the protocol provided is part of the provided supported protocol list.

Parameters
[in]ProtocolListSupported protocol list to investigate
[in]ProtocolProtocol value to determine if supported
Returns
TRUE = protocol is supported, FALSE = protocol is not supported

Definition at line 859 of file TcgStorageUtil.c.

◆ TcgMethodStatusString()

CHAR8 *EFIAPI TcgMethodStatusString ( UINT8  MethodStatus)

Returns a human-readable string representing a method status return code.

Parameters
[in]MethodStatusMethod status to translate to a string
Return values
returnthe string info.

Definition at line 31 of file TcgStorageUtil.c.

◆ TcgParseSyncSession()

TCG_RESULT EFIAPI TcgParseSyncSession ( const TCG_PARSE_STRUCT ParseStruct,
UINT16  ComId,
UINT16  ComIdExtension,
UINT32  HostSessionId,
UINT32 *  TperSessionId 
)

Parses the Sync Session response contained in the parseStruct to retrieve Tper session ID. If the Sync Session response parameters do not match the comID, extended ComID and host session ID then a failure is returned.

Parameters
[in/out]ParseStruct Structure used to parse received TCG response, contains Sync Session response.
[in]ComIdExpected ComID that is compared to actual ComID of response
[in]ComIdExtensionExpected Extended ComID that is compared to actual Extended ComID of response
[in]HostSessionIdExpected Host Session ID that is compared to actual Host Session ID of response
[in/out]TperSessionId Tper Session ID retrieved from the Sync Session response.

Definition at line 418 of file TcgStorageUtil.c.

◆ TcgSetAuthorityEnabled()

TCG_RESULT EFIAPI TcgSetAuthorityEnabled ( TCG_CREATE_STRUCT CreateStruct,
UINT32 *  Size,
UINT16  ComId,
UINT16  ComIdExtension,
UINT32  TperSession,
UINT32  HostSession,
TCG_UID  AuthorityUid,
BOOLEAN  Enabled 
)

Creates ComPacket with a Method call that sets the "Enabled" column for the row specified using the value specified. This assumes a start session has already been opened with the desired SP.

Parameters
[in/out]CreateStruct Structure used to add method call
[in/out]Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
[in]ComIdComID for the ComPacket
[in]ComIdExtensionExtended ComID for the ComPacket
[in]TperSessionTper Session ID for the Packet
[in]HostSessionHost Session ID for the Packet
[in]AuthorityUidAuthority UID to modify the "Enabled" column for
[in]EnabledValue to set the "Enabled" column to

Definition at line 617 of file TcgStorageUtil.c.

◆ TcgStartMethodCall()

TCG_RESULT EFIAPI TcgStartMethodCall ( TCG_CREATE_STRUCT CreateStruct,
TCG_UID  InvokingId,
TCG_UID  MethodId 
)

adds call token and method Header (invoking id, and method id).

Parameters
CreateStructThe input create structure.
InvokingIdInvoking id.
MethodIdMethod id.

Definition at line 72 of file TcgStorageUtil.c.

◆ TcgStartMethodSet()

TCG_RESULT EFIAPI TcgStartMethodSet ( TCG_CREATE_STRUCT CreateStruct,
TCG_UID  Row,
UINT32  ColumnNumber 
)

Set start method.

Parameters
CreateStructInput create structure.
RowInput the row info.
ColumnNumberthe column info.

Definition at line 523 of file TcgStorageUtil.c.

◆ TcgStartParameters()

TCG_RESULT EFIAPI TcgStartParameters ( TCG_CREATE_STRUCT CreateStruct)

Adds START LIST token.

Parameters
CreateStructThe input create structure.

Definition at line 104 of file TcgStorageUtil.c.

◆ TcgTokenTypeString()

CHAR8 *EFIAPI TcgTokenTypeString ( TCG_TOKEN_TYPE  Type)

Return the toke type string info.

Parameters
TypeInput the type info.
Return values
Returnthe string for this type.

Definition at line 314 of file TcgStorageUtil.c.