1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309 |
- /** @file
- Public API for the Tcg Core library to perform the lowest level TCG Data encoding.
- (TCG Storage Architecture Core Specification, Version 2.01, Revision 1.00,
- https://trustedcomputinggroup.org/tcg-storage-architecture-core-specification/)
- Check http://trustedcomputinggroup.org for latest specification updates.
- Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
- **/
- #ifndef _TCG_CORE_H_
- #define _TCG_CORE_H_
- #include <IndustryStandard/TcgStorageCore.h>
- #define ERROR_CHECK(arg) \
- { \
- TCG_RESULT ret = (arg); \
- if (ret != TcgResultSuccess) { \
- DEBUG ((DEBUG_INFO, "ERROR_CHECK failed at %a:%u\n", __FILE__, __LINE__)); \
- return ret; \
- } \
- }
- #define METHOD_STATUS_ERROR_CHECK(arg, failRet) \
- if ((arg) != TCG_METHOD_STATUS_CODE_SUCCESS) { \
- DEBUG ((DEBUG_INFO, "Method Status error: 0x%02X (%a)\n", arg, TcgMethodStatusString(arg))); \
- return (failRet); \
- }
- #define NULL_CHECK(arg) \
- do { \
- if ((arg) == NULL) { \
- DEBUG ((DEBUG_INFO, "NULL_CHECK(%a) failed at %a:%u\n", #arg, __FILE__, __LINE__)); \
- return TcgResultFailureNullPointer; \
- } \
- } while (0)
- #pragma pack(1)
- /**
- Tcg result codes.
- The result code indicates if the Tcg function call was successful or not
- **/
- typedef enum {
- //
- // This is the return result upon successful completion of a Tcg function call
- //
- TcgResultSuccess,
- //
- // This is the return "catchall" result for the failure of a Tcg function call
- //
- TcgResultFailure,
- //
- // This is the return result if a required parameter was Null for a Tcg function call
- //
- TcgResultFailureNullPointer,
- //
- // This is the return result if a required buffersize was 0 for a Tcg function call
- //
- TcgResultFailureZeroSize,
- //
- // This is the return result if a Tcg function call was executed out of order.
- // For instance, starting a Tcg subpacket before starting its Tcg packet.
- //
- TcgResultFailureInvalidAction,
- //
- // This is the return result if the buffersize provided is not big enough to add a requested Tcg encoded item.
- //
- TcgResultFailureBufferTooSmall,
- //
- // This is the return result for a Tcg parse function if the end of the parsed Buffer is reached, yet Data is still attempted to be retrieved.
- // For instance, attempting to retrieve another Tcg token from the Buffer after it has reached the end of the Tcg subpacket payload.
- //
- TcgResultFailureEndBuffer,
- //
- // This is the return result for a Tcg parse function if the Tcg Token item requested is not the expected type.
- // For instance, the caller requested to receive an integer and the Tcg token was a byte sequence.
- //
- TcgResultFailureInvalidType,
- } TCG_RESULT;
- //
- // Structure that is used to build the Tcg ComPacket. It contains the start Buffer pointer and the current position of the
- // Tcg ComPacket, current Tcg Packet and Tcg SubPacket. This structure must be initialized
- // by calling tcgInitTcgCreateStruct before it is used as parameter to any other Tcg function.
- // This structure should NOT be directly modified by the client of this library.
- //
- // NOTE: WE MAY MAKE THIS AN ABSTRACT STRUCTURE WITH A DEFINED SIZE AND KEEP THE VARIABLES
- // INTERNAL AND ONLY KNOWN TO THE TCG LIBRARY
- //
- // tcgInitTcgCreateStruct
- //
- typedef struct {
- //
- // Buffer allocated and freed by the client of the Tcg library.
- // This is the Buffer that shall contain the final Tcg encoded compacket.
- //
- VOID *Buffer;
- //
- // Size of the Buffer provided.
- //
- UINT32 BufferSize;
- //
- //Pointer to the start of the Tcg ComPacket. It should point to a location within Buffer.
- //
- TCG_COM_PACKET *ComPacket;
- //
- // Current Tcg Packet that is being created. It should point to a location within Buffer.
- //
- TCG_PACKET *CurPacket;
- //
- // Current Tcg SubPacket that is being created. It should point to a location within Buffer.
- //
- TCG_SUB_PACKET *CurSubPacket;
- //
- // Flag used to indicate if the Buffer of the structure should be filled out.
- // This is intended to be used to support a use-case where the client of library
- // can perform all the desired tcg calls to determine what the actual Size of the final compacket will be.
- // Then the client can allocate the required Buffer Size and re-run the tcg calls.
- // THIS MAY NOT BE IMPLEMENTED... REQUIRES MORE THOUGHT BECAUSE YOU CANNOT SOLVE ISSUE FOR RECEIVE
- //
- BOOLEAN DryRun;
- } TCG_CREATE_STRUCT;
- //
- // Structure that is used to parse the Tcg response received. It contains the response Buffer pointer
- // and the current position of the Tcg ComPacket, current Tcg Packet and Tcg SubPacket being parsed.
- // This structure must be initialized by calling tcgInitTcgParseStruct before it is used as parameter to any other Tcg parse function.
- // This structure should NOT be directly modified by the client of this library.
- //
- // NOTE: WE MAY MAKE THIS AN ABSTRACT STRUCTURE WITH A DEFINED SIZE AND KEEP THE VARIABLES
- // INTERNAL AND ONLY KNOWN TO THE TCG LIBRARY
- //
- // @sa tcgInitTcgParseStruct
- //
- typedef struct {
- //
- // Buffer allocated and freed by the client of the Tcg library.
- // This is the Buffer that contains the Tcg response to decode/parse.
- //
- const VOID* Buffer;
- //
- //Size of the Buffer provided.
- //
- UINT32 BufferSize;
- //
- // Pointer to the start of the Tcg ComPacket. It should point to a location within Buffer.
- //
- TCG_COM_PACKET *ComPacket;
- //
- // Current Tcg Packet that is being created. It should point to a location within Buffer.
- //
- TCG_PACKET *CurPacket;
- //
- // Current Tcg SubPacket that is being created. It should point to a location within Buffer.
- //
- TCG_SUB_PACKET *CurSubPacket;
- //
- // Current pointer within the current subpacket payload.
- //
- UINT8 *CurPtr;
- } TCG_PARSE_STRUCT ;
- //
- // Structure that is used to represent a Tcg Token that is retrieved by Tcg parse functions.
- //
- typedef struct {
- //
- // Describes the type of Tcg token the Hdr start points to.
- //
- TCG_TOKEN_TYPE Type;
- //
- // Pointer to the beginning of the Header of the Tcg token
- //
- UINT8 *HdrStart;
- } TCG_TOKEN ;
- /**
- Required to be called before calling any other Tcg functions with the TCG_CREATE_STRUCT.
- Initializes the packet variables to NULL. Additionally, the buffer will be memset.
- @param[in/out] CreateStruct Structure to initialize
- @param[in] Buffer Buffer allocated by client of library. It will contain the Tcg encoded packet. This cannot be null.
- @param[in] BufferSize Size of buffer provided. It cannot be 0.
- **/
- TCG_RESULT
- EFIAPI
- TcgInitTcgCreateStruct(
- TCG_CREATE_STRUCT *CreateStruct,
- VOID *Buffer,
- UINT32 BufferSize
- );
- /**
- Encodes the ComPacket header to the data structure.
- @param[in/out] CreateStruct Structure to initialize
- @param[in] ComId ComID of the Tcg ComPacket.
- @param[in] ComIdExtension ComID Extension of the Tcg ComPacket.
- **/
- TCG_RESULT
- EFIAPI
- TcgStartComPacket(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT16 ComId,
- UINT16 ComIdExtension
- );
- /**
- Starts a new ComPacket in the Data structure.
- @param[in/out] CreateStruct Structure used to add Tcg Packet
- @param[in] Tsn Packet Tper session number
- @param[in] Hsn Packet Host session number
- @param[in] SeqNumber Packet Sequence Number
- @param[in] AckType Packet Acknowledge Type
- @param[in] Ack Packet Acknowledge
- **/
- TCG_RESULT
- EFIAPI
- TcgStartPacket(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT32 Tsn,
- UINT32 Hsn,
- UINT32 SeqNumber,
- UINT16 AckType,
- UINT32 Ack
- );
- /**
- Starts a new SubPacket in the Data structure.
- @param[in/out] CreateStruct Structure used to start Tcg SubPacket
- @param[in] Kind SubPacket kind
- **/
- TCG_RESULT
- EFIAPI
- TcgStartSubPacket(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT16 Kind
- );
- /**
- Ends the current SubPacket in the Data structure. This function will also perform the 4-byte padding
- required for Subpackets.
- @param[in/out] CreateStruct Structure used to end the current Tcg SubPacket
- **/
- TCG_RESULT
- EFIAPI
- TcgEndSubPacket(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Ends the current Packet in the Data structure.
- @param[in/out] CreateStruct Structure used to end the current Tcg Packet
- **/
- TCG_RESULT
- EFIAPI
- TcgEndPacket(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Ends the ComPacket in the Data structure and ret
- @param[in/out] CreateStruct Structure used to end the Tcg ComPacket
- @param[in/out] Size Describes the Size of the entire ComPacket (Header and payload). Filled out by function.
- **/
- TCG_RESULT
- EFIAPI
- TcgEndComPacket(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT32 *Size
- );
- /**
- Adds a single raw token byte to the Data structure.
- @param[in/out] CreateStruct Structure used to add the byte
- @param [in] Byte Byte to add
- **/
- TCG_RESULT
- EFIAPI
- TcgAddRawByte(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT8 Byte
- );
- /**
- Adds the Data parameter as a byte sequence to the Data structure.
- @param [in/out] CreateStruct Structure used to add the byte sequence
- @param[in] Data Byte sequence that will be encoded and copied into Data structure
- @param[in] DataSize Length of Data provided
- @param[in] Continued TRUE if byte sequence is continued or
- FALSE if the Data contains the entire byte sequence to be encoded
- **/
- TCG_RESULT
- EFIAPI
- TcgAddByteSequence(
- TCG_CREATE_STRUCT *CreateStruct,
- const VOID *Data,
- UINT32 DataSize,
- BOOLEAN Continued
- );
- /**
- Adds an arbitrary-Length integer to the Data structure.
- The integer will be encoded using the shortest possible atom.
- @param[in/out] CreateStruct Structure used to add the integer
- @param[in] Data Integer in host byte order that will be encoded and copied into Data structure
- @param[in] DataSize Length in bytes of the Data provided
- @param[in] SignedInteger TRUE if the integer is signed or FALSE if the integer is unsigned
- **/
- TCG_RESULT
- EFIAPI
- TcgAddInteger(
- TCG_CREATE_STRUCT *CreateStruct,
- const VOID *Data,
- UINT32 DataSize,
- BOOLEAN SignedInteger
- );
- /**
- Adds an 8-bit unsigned integer to the Data structure.
- @param[in/out] CreateStruct Structure used to add the integer
- @param[in] Value Integer Value to add
- **/
- TCG_RESULT
- EFIAPI
- TcgAddUINT8(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT8 Value
- );
- /**
- Adds a 16-bit unsigned integer to the Data structure.
- @param[in/out] CreateStruct Structure used to add the integer
- @param[in] Value Integer Value to add
- **/
- TCG_RESULT
- EFIAPI
- TcgAddUINT16 (
- TCG_CREATE_STRUCT *CreateStruct,
- UINT16 Value
- );
- /**
- Adds a 32-bit unsigned integer to the Data structure.
- @param[in/out] CreateStruct Structure used to add the integer
- @param[in] Value Integer Value to add
- **/
- TCG_RESULT
- EFIAPI
- TcgAddUINT32(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT32 Value
- );
- /**
- Adds a 64-bit unsigned integer to the Data structure.
- @param[in/out] CreateStruct Structure used to add the integer
- @param[in] Value Integer Value to add
- **/
- TCG_RESULT
- EFIAPI
- TcgAddUINT64(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT64 Value
- );
- /**
- Adds a BOOLEAN to the Data structure.
- @param[in/out] CreateStruct Structure used to add the integer
- @param[in] Value BOOLEAN Value to add
- **/
- TCG_RESULT
- EFIAPI
- TcgAddBOOLEAN(
- TCG_CREATE_STRUCT *CreateStruct,
- BOOLEAN Value
- );
- /**
- Add tcg uid info.
- @param [in/out] CreateStruct Structure used to add the integer
- @param Uid Input uid info.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgAddTcgUid(
- TCG_CREATE_STRUCT *CreateStruct,
- TCG_UID Uid
- );
- /**
- Adds a Start List token to the Data structure.
- @param[in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddStartList(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds an End List token to the Data structure.
- @param [in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddEndList(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds a Start Name token to the Data structure.
- @param[in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddStartName(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds an End Name token to the Data structure.
- @param [in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddEndName(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds a Call token to the Data structure.
- @param [in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddCall(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds an End of Data token to the Data structure.
- @param[in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddEndOfData(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds an End of Session token to the Data structure.
- @param [in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddEndOfSession(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds a Start Transaction token to the Data structure.
- @param [in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddStartTransaction(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds an End Transaction token to the Data structure.
- @param[in/out] CreateStruct Structure used to add the token
- **/
- TCG_RESULT
- EFIAPI
- TcgAddEndTransaction(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Initial the tcg parse stucture.
- @param ParseStruct Input parse structure.
- @param Buffer Input buffer data.
- @param BufferSize Input buffer size.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgInitTcgParseStruct(
- TCG_PARSE_STRUCT *ParseStruct,
- const VOID *Buffer,
- UINT32 BufferSize
- );
- /**
- Get next token info.
- @param ParseStruct Input parse structure info.
- @param TcgToken return the tcg token info.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextToken(
- TCG_PARSE_STRUCT *ParseStruct,
- TCG_TOKEN *TcgToken
- );
- /**
- Get next token Type.
- @param ParseStruct Input parse structure.
- @param Type Input the type need to check.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextTokenType(
- TCG_PARSE_STRUCT *ParseStruct,
- TCG_TOKEN_TYPE Type
- );
- /**
- Get atom info.
- @param TcgToken Input token info.
- @param HeaderLength return the header length.
- @param DataLength return the data length.
- @param ByteOrInt return the atom Type.
- @param SignOrCont return the sign or count info.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetAtomInfo(
- const TCG_TOKEN *TcgToken,
- UINT32 *HeaderLength,
- UINT32 *DataLength,
- UINT8 *ByteOrInt,
- UINT8 *SignOrCont
- );
- /**
- Get token byte sequence.
- @param TcgToken Input token info.
- @param Length Input the length info.
- @retval Return the value data.
- **/
- UINT8*
- EFIAPI
- TcgGetTokenByteSequence(
- const TCG_TOKEN *TcgToken,
- UINT32 *Length
- );
- /**
- Get token specified value.
- @param TcgToken Input token info.
- @param Value return the value.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetTokenUINT64(
- const TCG_TOKEN *TcgToken,
- UINT64 *Value
- );
- /**
- Get next specify value.
- @param ParseStruct Input parse structure.
- @param Value Return vlaue.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextUINT8(
- TCG_PARSE_STRUCT *ParseStruct,
- UINT8 *Value
- );
- /**
- Get next specify value.
- @param ParseStruct Input parse structure.
- @param Value Return vlaue.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextUINT16(
- TCG_PARSE_STRUCT *ParseStruct,
- UINT16 *Value
- );
- /**
- Get next specify value.
- @param ParseStruct Input parse structure.
- @param Value Return vlaue.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextUINT32(
- TCG_PARSE_STRUCT *ParseStruct,
- UINT32 *Value
- );
- /**
- Get next specify value.
- @param ParseStruct Input parse structure.
- @param Value Return vlaue.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextUINT64(
- TCG_PARSE_STRUCT *ParseStruct,
- UINT64 *Value
- );
- /**
- Get next specify value.
- @param ParseStruct Input parse structure.
- @param Value Return vlaue.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextBOOLEAN(
- TCG_PARSE_STRUCT *ParseStruct,
- BOOLEAN *Value
- );
- /**
- Get next tcg uid info.
- @param ParseStruct Input parse structure.
- @param Uid Get the uid info.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextTcgUid(
- TCG_PARSE_STRUCT *ParseStruct,
- TCG_UID *Uid
- );
- /**
- Get next byte sequence.
- @param ParseStruct Input parse structure.
- @param Data return the data.
- @param Length return the length.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextByteSequence(
- TCG_PARSE_STRUCT *ParseStruct,
- const VOID **Data,
- UINT32 *Length
- );
- /**
- Get next start list.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextStartList(
- TCG_PARSE_STRUCT *ParseStruct
- );
- /**
- Get next end list.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextEndList(
- TCG_PARSE_STRUCT *ParseStruct
- );
- /**
- Get next start name.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextStartName(
- TCG_PARSE_STRUCT *ParseStruct
- );
- /**
- Get next end name.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextEndName(
- TCG_PARSE_STRUCT *ParseStruct
- );
- /**
- Get next call.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextCall(
- TCG_PARSE_STRUCT *ParseStruct
- );
- /**
- Get next end data.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextEndOfData(
- TCG_PARSE_STRUCT *ParseStruct
- );
- /**
- Get next end of session.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextEndOfSession(
- TCG_PARSE_STRUCT *ParseStruct
- );
- /**
- Get next start transaction.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextStartTransaction(
- TCG_PARSE_STRUCT *ParseStruct
- );
- /**
- Get next end transaction.
- @param ParseStruct Input parse structure.
- @retval return the action result.
- **/
- TCG_RESULT
- EFIAPI
- TcgGetNextEndTransaction(
- TCG_PARSE_STRUCT *ParseStruct
- );
- // end of parse functions
- typedef
- BOOLEAN
- (EFIAPI* TCG_LEVEL0_ENUM_CALLBACK) (
- const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
- TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature,
- UINTN FeatureSize, // includes header
- VOID *Context
- );
- /**
- Adds call token and method Header (invoking id, and method id).
- @param CreateStruct The input create structure.
- @param InvokingId Invoking id.
- @param MethodId Method id.
- **/
- TCG_RESULT
- EFIAPI
- TcgStartMethodCall(
- TCG_CREATE_STRUCT *CreateStruct,
- TCG_UID InvokingId,
- TCG_UID MethodId
- );
- /**
- Adds START LIST token.
- @param CreateStruct The input create structure.
- **/
- TCG_RESULT
- EFIAPI
- TcgStartParameters(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds END LIST token.
- @param CreateStruct The input create structure.
- **/
- TCG_RESULT
- EFIAPI
- TcgEndParameters(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- Adds END Data token and method list.
- @param CreateStruct The input create structure.
- **/
- TCG_RESULT
- EFIAPI
- TcgEndMethodCall(
- TCG_CREATE_STRUCT *CreateStruct
- );
- /**
- 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.
- @param [in/out] CreateStruct Structure used to add the start session call
- @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
- @param [in] ComId ComID for the ComPacket
- @param [in] ComIdExtension Extended ComID for the ComPacket
- @param [in] HostSessionId Host Session ID
- @param [in] SpId Security Provider to start session with
- @param [in] Write Write option for start session. TRUE = start session requests write access
- @param [in] HostChallengeLength Length of the host challenge. Length should be 0 if hostChallenge is NULL
- @param [in] HostChallenge Host challenge for Host Signing Authority. If NULL, then no Host Challenge shall be sent.
- @param [in] HostSigningAuthority Host Signing Authority used for start session. If NULL, then no Host Signing Authority shall be sent.
- **/
- 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
- );
- /**
- 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.
- @param [in/out] CreateStruct Structure used to add method call.
- @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
- @param [in] ComId ComID for the ComPacket
- @param [in] ComIdExtension Extended ComID for the ComPacket
- @param [in] TperSession Tper Session ID for the Packet
- @param [in] HostSession Host Session ID for the Packet
- @param [in] SidRow UID of row of current SP to set PIN column
- @param [in] Password value of PIN to set
- @param [in] PasswordSize Size of PIN
- **/
- 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 "Enabled" column for the row specified using the value specified.
- This assumes a start session has already been opened with the desired SP.
- @param [in/out] CreateStruct Structure used to add method call
- @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
- @param [in] ComId ComID for the ComPacket
- @param [in] ComIdExtension Extended ComID for the ComPacket
- @param [in] TperSession Tper Session ID for the Packet
- @param [in] HostSession Host Session ID for the Packet
- @param [in] AuthorityUid Authority UID to modify the "Enabled" column for
- @param [in] Enabled Value to set the "Enabled" column to
- **/
- 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 EndSession.
- This assumes a start session has already been opened.
- @param [in/out] CreateStruct Structure used to add Endsession
- @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
- @param [in] ComId ComID for the ComPacket
- @param [in] ComIdExtension Extended ComID for the ComPacket
- @param [in] HostSessionId Host Session ID for the Packet
- @param [in] TpSessionId Tper Session ID for the Packet
- **/
- TCG_RESULT
- EFIAPI
- TcgCreateEndSession(
- TCG_CREATE_STRUCT *CreateStruct,
- UINT32 *Size,
- UINT16 ComId,
- UINT16 ComIdExtension,
- UINT32 HostSessionId,
- UINT32 TpSessionId
- );
- /**
- Retrieves human-readable token type name.
- @param[in] Type Token type to retrieve
- **/
- CHAR8*
- EFIAPI
- TcgTokenTypeString(
- TCG_TOKEN_TYPE Type
- );
- /**
- 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.
- @param [in/out] ParseStruct Structure used to parse received TCG response
- @param [in/out] MethodStatus Method status retrieved of the current SubPacket
- **/
- TCG_RESULT
- EFIAPI
- TcgGetMethodStatus(
- const TCG_PARSE_STRUCT *ParseStruct,
- UINT8 *MethodStatus
- );
- /**
- Returns a human-readable string representing a method status return code.
- @param[in] MethodStatus Method status to translate to a string
- @retval return the string info.
- **/
- CHAR8*
- EFIAPI
- TcgMethodStatusString(
- UINT8 MethodStatus
- );
- /**
- 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.
- @param [in] ParseStruct Structure used to parse received TCG response.
- @param [in/out] ComId comID retrieved from received ComPacket.
- @param [in/out] ComIdExtension Extended comID retrieved from received ComPacket
- **/
- TCG_RESULT
- EFIAPI
- TcgGetComIds(
- const TCG_PARSE_STRUCT *ParseStruct,
- UINT16 *ComId,
- UINT16 *ComIdExtension
- );
- /**
- Checks if the ComIDs of the response match the expected values.
- @param[in] ParseStruct Structure used to parse received TCG response
- @param[in] ExpectedComId Expected comID
- @param[in] ExpectedComIdExtension Expected extended comID
- **/
- TCG_RESULT
- EFIAPI
- TcgCheckComIds(
- const TCG_PARSE_STRUCT *ParseStruct,
- UINT16 ExpectedComId,
- UINT16 ExpectedComIdExtension
- );
- /**
- 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.
- @param[in/out] ParseStruct Structure used to parse received TCG response, contains Sync Session response.
- @param[in] ComId Expected ComID that is compared to actual ComID of response
- @param[in] ComIdExtension Expected Extended ComID that is compared to actual Extended ComID of response
- @param[in] HostSessionId Expected Host Session ID that is compared to actual Host Session ID of response
- @param[in/out] TperSessionId Tper Session ID retrieved from the Sync Session response.
- **/
- TCG_RESULT
- EFIAPI
- TcgParseSyncSession(
- const TCG_PARSE_STRUCT *ParseStruct,
- UINT16 ComId,
- UINT16 ComIdExtension,
- UINT32 HostSessionId,
- UINT32 *TperSessionId
- );
- /**
- Create set ace.
- @param CreateStruct Input create structure.
- @param Size size info.
- @param ComId ComId info.
- @param ComIdExtension ComId extension info.
- @param TperSession Tper session data.
- @param HostSession Host session data.
- @param AceRow Ace row info.
- @param Authority1 Authority 1 info.
- @param LogicalOperator Logiccal operator info.
- @param Authority2 Authority 2 info.
- @retval Return the action result.
- **/
- 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
- );
- /**
- Enum level 0 discovery.
- @param DiscoveryHeader Discovery header.
- @param Callback Callback function.
- @param Context The context for the function.
- @retval return true if the callback return TRUE, else return FALSE.
- **/
- BOOLEAN
- EFIAPI
- TcgEnumLevel0Discovery(
- const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
- TCG_LEVEL0_ENUM_CALLBACK Callback,
- VOID *Context
- );
- /**
- Get Feature code from the header.
- @param DiscoveryHeader The discovery header.
- @param FeatureCode reutrn the Feature code.
- @param FeatureSize return the Feature size.
- @retval return the Feature code data.
- **/
- TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER*
- EFIAPI
- TcgGetFeature(
- const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
- UINT16 FeatureCode,
- UINTN *FeatureSize
- );
- /**
- Determines if the protocol provided is part of the provided supported protocol list.
- @param[in] ProtocolList Supported protocol list to investigate
- @param[in] Protocol Protocol value to determine if supported
- @return TRUE = protocol is supported, FALSE = protocol is not supported
- **/
- BOOLEAN
- EFIAPI
- TcgIsProtocolSupported(
- const TCG_SUPPORTED_SECURITY_PROTOCOLS *ProtocolList,
- UINT16 Protocol
- );
- /**
- Determines if the Locking Feature "Locked" bit is set in the level 0 discovery response.
- @param[in] Discovery Level 0 discovery response
- @return TRUE = Locked is set, FALSE = Locked is false
- **/
- BOOLEAN
- EFIAPI
- TcgIsLocked(
- const TCG_LEVEL0_DISCOVERY_HEADER *Discovery
- );
- #pragma pack()
- #endif // _TCG_CORE_H_
|