|
@@ -13,9 +13,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
|
|
typedef struct {
|
|
|
- UINT16 FeatureCode;
|
|
|
- TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature;
|
|
|
- UINTN FeatureSize;
|
|
|
+ UINT16 FeatureCode;
|
|
|
+ TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature;
|
|
|
+ UINTN FeatureSize;
|
|
|
} TCG_FIND_FEATURE_CTX;
|
|
|
|
|
|
/**
|
|
@@ -26,39 +26,39 @@ typedef struct {
|
|
|
|
|
|
@retval return the string info.
|
|
|
**/
|
|
|
-CHAR8*
|
|
|
+CHAR8 *
|
|
|
EFIAPI
|
|
|
-TcgMethodStatusString(
|
|
|
- UINT8 MethodStatus
|
|
|
+TcgMethodStatusString (
|
|
|
+ UINT8 MethodStatus
|
|
|
)
|
|
|
{
|
|
|
switch (MethodStatus) {
|
|
|
- #define C(status) case TCG_METHOD_STATUS_CODE_ ## status: return #status
|
|
|
- C(SUCCESS);
|
|
|
- C(NOT_AUTHORIZED);
|
|
|
- C(OBSOLETE);
|
|
|
- C(SP_BUSY);
|
|
|
- C(SP_FAILED);
|
|
|
- C(SP_DISABLED);
|
|
|
- C(SP_FROZEN);
|
|
|
- C(NO_SESSIONS_AVAILABLE);
|
|
|
- C(UNIQUENESS_CONFLICT);
|
|
|
- C(INSUFFICIENT_SPACE);
|
|
|
- C(INSUFFICIENT_ROWS);
|
|
|
- C(INVALID_PARAMETER);
|
|
|
- C(OBSOLETE2);
|
|
|
- C(OBSOLETE3);
|
|
|
- C(TPER_MALFUNCTION);
|
|
|
- C(TRANSACTION_FAILURE);
|
|
|
- C(RESPONSE_OVERFLOW);
|
|
|
- C(AUTHORITY_LOCKED_OUT);
|
|
|
- C(FAIL);
|
|
|
+ #define C(status) case TCG_METHOD_STATUS_CODE_ ## status: return #status
|
|
|
+ C (SUCCESS);
|
|
|
+ C (NOT_AUTHORIZED);
|
|
|
+ C (OBSOLETE);
|
|
|
+ C (SP_BUSY);
|
|
|
+ C (SP_FAILED);
|
|
|
+ C (SP_DISABLED);
|
|
|
+ C (SP_FROZEN);
|
|
|
+ C (NO_SESSIONS_AVAILABLE);
|
|
|
+ C (UNIQUENESS_CONFLICT);
|
|
|
+ C (INSUFFICIENT_SPACE);
|
|
|
+ C (INSUFFICIENT_ROWS);
|
|
|
+ C (INVALID_PARAMETER);
|
|
|
+ C (OBSOLETE2);
|
|
|
+ C (OBSOLETE3);
|
|
|
+ C (TPER_MALFUNCTION);
|
|
|
+ C (TRANSACTION_FAILURE);
|
|
|
+ C (RESPONSE_OVERFLOW);
|
|
|
+ C (AUTHORITY_LOCKED_OUT);
|
|
|
+ C (FAIL);
|
|
|
#undef C
|
|
|
}
|
|
|
+
|
|
|
return "unknown";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
adds call token and method Header (invoking id, and method id).
|
|
|
|
|
@@ -69,25 +69,26 @@ TcgMethodStatusString(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgStartMethodCall(
|
|
|
- TCG_CREATE_STRUCT *CreateStruct,
|
|
|
- TCG_UID InvokingId,
|
|
|
- TCG_UID MethodId
|
|
|
+TcgStartMethodCall (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct,
|
|
|
+ TCG_UID InvokingId,
|
|
|
+ TCG_UID MethodId
|
|
|
)
|
|
|
{
|
|
|
- NULL_CHECK(CreateStruct);
|
|
|
+ NULL_CHECK (CreateStruct);
|
|
|
|
|
|
- if (CreateStruct->ComPacket == NULL ||
|
|
|
- CreateStruct->CurPacket == NULL ||
|
|
|
- CreateStruct->CurSubPacket == NULL
|
|
|
- ) {
|
|
|
+ if ((CreateStruct->ComPacket == NULL) ||
|
|
|
+ (CreateStruct->CurPacket == NULL) ||
|
|
|
+ (CreateStruct->CurSubPacket == NULL)
|
|
|
+ )
|
|
|
+ {
|
|
|
DEBUG ((DEBUG_INFO, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
|
|
|
return (TcgResultFailureInvalidAction);
|
|
|
}
|
|
|
|
|
|
- ERROR_CHECK(TcgAddCall(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddTcgUid(CreateStruct, InvokingId));
|
|
|
- ERROR_CHECK(TcgAddTcgUid(CreateStruct, MethodId));
|
|
|
+ ERROR_CHECK (TcgAddCall (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddTcgUid (CreateStruct, InvokingId));
|
|
|
+ ERROR_CHECK (TcgAddTcgUid (CreateStruct, MethodId));
|
|
|
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
@@ -100,21 +101,22 @@ TcgStartMethodCall(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgStartParameters(
|
|
|
- TCG_CREATE_STRUCT *CreateStruct
|
|
|
+TcgStartParameters (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct
|
|
|
)
|
|
|
{
|
|
|
- NULL_CHECK(CreateStruct);
|
|
|
+ NULL_CHECK (CreateStruct);
|
|
|
|
|
|
- if (CreateStruct->ComPacket == NULL ||
|
|
|
- CreateStruct->CurPacket == NULL ||
|
|
|
- CreateStruct->CurSubPacket == NULL
|
|
|
- ) {
|
|
|
+ if ((CreateStruct->ComPacket == NULL) ||
|
|
|
+ (CreateStruct->CurPacket == NULL) ||
|
|
|
+ (CreateStruct->CurSubPacket == NULL)
|
|
|
+ )
|
|
|
+ {
|
|
|
DEBUG ((DEBUG_INFO, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
|
|
|
return (TcgResultFailureInvalidAction);
|
|
|
}
|
|
|
|
|
|
- return TcgAddStartList(CreateStruct);
|
|
|
+ return TcgAddStartList (CreateStruct);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -125,21 +127,22 @@ TcgStartParameters(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgEndParameters(
|
|
|
- TCG_CREATE_STRUCT *CreateStruct
|
|
|
+TcgEndParameters (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct
|
|
|
)
|
|
|
{
|
|
|
- NULL_CHECK(CreateStruct);
|
|
|
+ NULL_CHECK (CreateStruct);
|
|
|
|
|
|
- if (CreateStruct->ComPacket == NULL ||
|
|
|
- CreateStruct->CurPacket == NULL ||
|
|
|
- CreateStruct->CurSubPacket == NULL
|
|
|
- ) {
|
|
|
+ if ((CreateStruct->ComPacket == NULL) ||
|
|
|
+ (CreateStruct->CurPacket == NULL) ||
|
|
|
+ (CreateStruct->CurSubPacket == NULL)
|
|
|
+ )
|
|
|
+ {
|
|
|
DEBUG ((DEBUG_INFO, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
|
|
|
return (TcgResultFailureInvalidAction);
|
|
|
}
|
|
|
|
|
|
- return TcgAddEndList(CreateStruct);
|
|
|
+ return TcgAddEndList (CreateStruct);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -150,27 +153,28 @@ TcgEndParameters(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgEndMethodCall(
|
|
|
- TCG_CREATE_STRUCT *CreateStruct
|
|
|
+TcgEndMethodCall (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct
|
|
|
)
|
|
|
{
|
|
|
- NULL_CHECK(CreateStruct);
|
|
|
+ NULL_CHECK (CreateStruct);
|
|
|
|
|
|
- if (CreateStruct->ComPacket == NULL ||
|
|
|
- CreateStruct->CurPacket == NULL ||
|
|
|
- CreateStruct->CurSubPacket == NULL
|
|
|
- ) {
|
|
|
+ if ((CreateStruct->ComPacket == NULL) ||
|
|
|
+ (CreateStruct->CurPacket == NULL) ||
|
|
|
+ (CreateStruct->CurSubPacket == NULL)
|
|
|
+ )
|
|
|
+ {
|
|
|
DEBUG ((DEBUG_INFO, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
|
|
|
return (TcgResultFailureInvalidAction);
|
|
|
}
|
|
|
|
|
|
- ERROR_CHECK(TcgAddEndOfData(CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddEndOfData (CreateStruct));
|
|
|
|
|
|
- ERROR_CHECK(TcgAddStartList(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddUINT8(CreateStruct, 0x00)); // expected to complete properly
|
|
|
- ERROR_CHECK(TcgAddUINT8(CreateStruct, 0x00)); // reserved
|
|
|
- ERROR_CHECK(TcgAddUINT8(CreateStruct, 0x00)); // reserved
|
|
|
- ERROR_CHECK(TcgAddEndList(CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddStartList (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddUINT8 (CreateStruct, 0x00)); // expected to complete properly
|
|
|
+ ERROR_CHECK (TcgAddUINT8 (CreateStruct, 0x00)); // reserved
|
|
|
+ ERROR_CHECK (TcgAddUINT8 (CreateStruct, 0x00)); // reserved
|
|
|
+ ERROR_CHECK (TcgAddEndList (CreateStruct));
|
|
|
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
@@ -186,23 +190,23 @@ TcgEndMethodCall(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgGetComIds(
|
|
|
- const TCG_PARSE_STRUCT *ParseStruct,
|
|
|
- UINT16 *ComId,
|
|
|
- UINT16 *ComIdExtension
|
|
|
+TcgGetComIds (
|
|
|
+ const TCG_PARSE_STRUCT *ParseStruct,
|
|
|
+ UINT16 *ComId,
|
|
|
+ UINT16 *ComIdExtension
|
|
|
)
|
|
|
{
|
|
|
- NULL_CHECK(ParseStruct);
|
|
|
- NULL_CHECK(ComId);
|
|
|
- NULL_CHECK(ComIdExtension);
|
|
|
+ NULL_CHECK (ParseStruct);
|
|
|
+ NULL_CHECK (ComId);
|
|
|
+ NULL_CHECK (ComIdExtension);
|
|
|
|
|
|
if (ParseStruct->ComPacket == NULL) {
|
|
|
DEBUG ((DEBUG_INFO, "unexpected state: ComPacket=%p\n", ParseStruct->ComPacket));
|
|
|
return TcgResultFailureInvalidAction;
|
|
|
}
|
|
|
|
|
|
- *ComId = SwapBytes16(ParseStruct->ComPacket->ComIDBE);
|
|
|
- *ComIdExtension = SwapBytes16(ParseStruct->ComPacket->ComIDExtensionBE);
|
|
|
+ *ComId = SwapBytes16 (ParseStruct->ComPacket->ComIDBE);
|
|
|
+ *ComIdExtension = SwapBytes16 (ParseStruct->ComPacket->ComIDExtensionBE);
|
|
|
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
@@ -217,21 +221,22 @@ TcgGetComIds(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgCheckComIds(
|
|
|
- const TCG_PARSE_STRUCT *ParseStruct,
|
|
|
- UINT16 ExpectedComId,
|
|
|
- UINT16 ExpectedComIdExtension
|
|
|
+TcgCheckComIds (
|
|
|
+ const TCG_PARSE_STRUCT *ParseStruct,
|
|
|
+ UINT16 ExpectedComId,
|
|
|
+ UINT16 ExpectedComIdExtension
|
|
|
)
|
|
|
{
|
|
|
- UINT16 ParseComId;
|
|
|
- UINT16 ParseComIdExtension;
|
|
|
+ UINT16 ParseComId;
|
|
|
+ UINT16 ParseComIdExtension;
|
|
|
|
|
|
- ERROR_CHECK(TcgGetComIds(ParseStruct, &ParseComId, &ParseComIdExtension));
|
|
|
- if (ParseComId != ExpectedComId || ParseComIdExtension != ExpectedComIdExtension) {
|
|
|
+ ERROR_CHECK (TcgGetComIds (ParseStruct, &ParseComId, &ParseComIdExtension));
|
|
|
+ if ((ParseComId != ExpectedComId) || (ParseComIdExtension != ExpectedComIdExtension)) {
|
|
|
DEBUG ((DEBUG_INFO, "Com ID: Actual 0x%02X Expected 0x%02X\n", ParseComId, ExpectedComId));
|
|
|
DEBUG ((DEBUG_INFO, "Extended Com ID: 0x%02X Expected 0x%02X\n", ParseComIdExtension, ExpectedComIdExtension));
|
|
|
return TcgResultFailure;
|
|
|
}
|
|
|
+
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
|
|
|
@@ -245,42 +250,43 @@ TcgCheckComIds(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgGetMethodStatus(
|
|
|
- const TCG_PARSE_STRUCT *ParseStruct,
|
|
|
- UINT8 *MethodStatus
|
|
|
+TcgGetMethodStatus (
|
|
|
+ const TCG_PARSE_STRUCT *ParseStruct,
|
|
|
+ UINT8 *MethodStatus
|
|
|
)
|
|
|
{
|
|
|
- TCG_PARSE_STRUCT TmpParseStruct;
|
|
|
- TCG_TOKEN TcgToken;
|
|
|
- UINT8 Reserved1, Reserved2;
|
|
|
-
|
|
|
- NULL_CHECK(ParseStruct);
|
|
|
- NULL_CHECK(MethodStatus);
|
|
|
-
|
|
|
- if (ParseStruct->ComPacket == NULL ||
|
|
|
- ParseStruct->CurPacket == NULL ||
|
|
|
- ParseStruct->CurSubPacket == NULL
|
|
|
- ) {
|
|
|
+ TCG_PARSE_STRUCT TmpParseStruct;
|
|
|
+ TCG_TOKEN TcgToken;
|
|
|
+ UINT8 Reserved1, Reserved2;
|
|
|
+
|
|
|
+ NULL_CHECK (ParseStruct);
|
|
|
+ NULL_CHECK (MethodStatus);
|
|
|
+
|
|
|
+ if ((ParseStruct->ComPacket == NULL) ||
|
|
|
+ (ParseStruct->CurPacket == NULL) ||
|
|
|
+ (ParseStruct->CurSubPacket == NULL)
|
|
|
+ )
|
|
|
+ {
|
|
|
DEBUG ((DEBUG_INFO, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", ParseStruct->ComPacket, ParseStruct->CurPacket, ParseStruct->CurSubPacket));
|
|
|
return TcgResultFailureInvalidAction;
|
|
|
}
|
|
|
|
|
|
// duplicate ParseStruct, then don't need to "reset" location cur ptr
|
|
|
- CopyMem (&TmpParseStruct, ParseStruct, sizeof(TCG_PARSE_STRUCT));
|
|
|
+ CopyMem (&TmpParseStruct, ParseStruct, sizeof (TCG_PARSE_STRUCT));
|
|
|
|
|
|
// method status list exists after the end method call in the subpacket
|
|
|
// skip tokens until ENDDATA is found
|
|
|
do {
|
|
|
- ERROR_CHECK(TcgGetNextToken(&TmpParseStruct, &TcgToken));
|
|
|
+ ERROR_CHECK (TcgGetNextToken (&TmpParseStruct, &TcgToken));
|
|
|
} while (TcgToken.Type != TcgTokenTypeEndOfData);
|
|
|
|
|
|
// only reach here if enddata is found
|
|
|
// at this point, the curptr is pointing at method status list beginning
|
|
|
- ERROR_CHECK(TcgGetNextStartList(&TmpParseStruct));
|
|
|
- ERROR_CHECK(TcgGetNextUINT8(&TmpParseStruct, MethodStatus));
|
|
|
- ERROR_CHECK(TcgGetNextUINT8(&TmpParseStruct, &Reserved1));
|
|
|
- ERROR_CHECK(TcgGetNextUINT8(&TmpParseStruct, &Reserved2));
|
|
|
- ERROR_CHECK(TcgGetNextEndList(&TmpParseStruct));
|
|
|
+ ERROR_CHECK (TcgGetNextStartList (&TmpParseStruct));
|
|
|
+ ERROR_CHECK (TcgGetNextUINT8 (&TmpParseStruct, MethodStatus));
|
|
|
+ ERROR_CHECK (TcgGetNextUINT8 (&TmpParseStruct, &Reserved1));
|
|
|
+ ERROR_CHECK (TcgGetNextUINT8 (&TmpParseStruct, &Reserved2));
|
|
|
+ ERROR_CHECK (TcgGetNextEndList (&TmpParseStruct));
|
|
|
|
|
|
if (Reserved1 != 0) {
|
|
|
DEBUG ((DEBUG_INFO, "Method status reserved1 = 0x%02X (expected 0)\n", Reserved1));
|
|
@@ -303,9 +309,9 @@ TcgGetMethodStatus(
|
|
|
@retval Return the string for this type.
|
|
|
|
|
|
**/
|
|
|
-CHAR8*
|
|
|
+CHAR8 *
|
|
|
EFIAPI
|
|
|
-TcgTokenTypeString(
|
|
|
+TcgTokenTypeString (
|
|
|
TCG_TOKEN_TYPE Type
|
|
|
)
|
|
|
{
|
|
@@ -326,10 +332,10 @@ TcgTokenTypeString(
|
|
|
case TcgTokenTypeEndTransaction: return "End Transaction";
|
|
|
case TcgTokenTypeEmptyAtom: return "Empty atom";
|
|
|
}
|
|
|
+
|
|
|
return "Unknown";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
|
|
|
Adds Start Session call to the data structure. This creates the entire ComPacket structure and
|
|
@@ -349,48 +355,49 @@ TcgTokenTypeString(
|
|
|
**/
|
|
|
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
|
|
|
+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
|
|
|
)
|
|
|
{
|
|
|
- ERROR_CHECK(TcgStartComPacket(CreateStruct, ComId, ComIdExtension));
|
|
|
- ERROR_CHECK(TcgStartPacket(CreateStruct, 0x0, 0x0, 0x0, 0x0, 0x0)) ;
|
|
|
- ERROR_CHECK(TcgStartSubPacket(CreateStruct, 0x0));
|
|
|
- ERROR_CHECK(TcgStartMethodCall(CreateStruct, TCG_UID_SMUID, TCG_UID_SM_START_SESSION));
|
|
|
- ERROR_CHECK(TcgStartParameters(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddUINT32(CreateStruct, HostSessionId));
|
|
|
- ERROR_CHECK(TcgAddTcgUid(CreateStruct, SpId));
|
|
|
- ERROR_CHECK(TcgAddBOOLEAN(CreateStruct, Write));
|
|
|
+ ERROR_CHECK (TcgStartComPacket (CreateStruct, ComId, ComIdExtension));
|
|
|
+ ERROR_CHECK (TcgStartPacket (CreateStruct, 0x0, 0x0, 0x0, 0x0, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartSubPacket (CreateStruct, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartMethodCall (CreateStruct, TCG_UID_SMUID, TCG_UID_SM_START_SESSION));
|
|
|
+ ERROR_CHECK (TcgStartParameters (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddUINT32 (CreateStruct, HostSessionId));
|
|
|
+ ERROR_CHECK (TcgAddTcgUid (CreateStruct, SpId));
|
|
|
+ ERROR_CHECK (TcgAddBOOLEAN (CreateStruct, Write));
|
|
|
|
|
|
// optional parameters
|
|
|
- if (HostChallenge != NULL && HostChallengeLength != 0) {
|
|
|
- ERROR_CHECK(TcgAddStartName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddUINT8(CreateStruct, 0x00)); //TODO Create Enum for Method Optional Parameters?
|
|
|
- ERROR_CHECK(TcgAddByteSequence(CreateStruct, HostChallenge, HostChallengeLength, FALSE));
|
|
|
- ERROR_CHECK(TcgAddEndName(CreateStruct));
|
|
|
+ if ((HostChallenge != NULL) && (HostChallengeLength != 0)) {
|
|
|
+ ERROR_CHECK (TcgAddStartName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddUINT8 (CreateStruct, 0x00)); // TODO Create Enum for Method Optional Parameters?
|
|
|
+ ERROR_CHECK (TcgAddByteSequence (CreateStruct, HostChallenge, HostChallengeLength, FALSE));
|
|
|
+ ERROR_CHECK (TcgAddEndName (CreateStruct));
|
|
|
}
|
|
|
+
|
|
|
// optional parameters
|
|
|
if (HostSigningAuthority != 0) {
|
|
|
- ERROR_CHECK(TcgAddStartName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddUINT8(CreateStruct, 0x03)); //TODO Create Enum for Method Optional Parameters?
|
|
|
- ERROR_CHECK(TcgAddTcgUid(CreateStruct, HostSigningAuthority));
|
|
|
- ERROR_CHECK(TcgAddEndName(CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddStartName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddUINT8 (CreateStruct, 0x03)); // TODO Create Enum for Method Optional Parameters?
|
|
|
+ ERROR_CHECK (TcgAddTcgUid (CreateStruct, HostSigningAuthority));
|
|
|
+ ERROR_CHECK (TcgAddEndName (CreateStruct));
|
|
|
}
|
|
|
|
|
|
- ERROR_CHECK(TcgEndParameters(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndMethodCall(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndSubPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndComPacket(CreateStruct, Size));
|
|
|
+ ERROR_CHECK (TcgEndParameters (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndMethodCall (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndSubPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndComPacket (CreateStruct, Size));
|
|
|
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
@@ -408,7 +415,7 @@ TcgCreateStartSession(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgParseSyncSession(
|
|
|
+TcgParseSyncSession (
|
|
|
const TCG_PARSE_STRUCT *ParseStruct,
|
|
|
UINT16 ComId,
|
|
|
UINT16 ComIdExtension,
|
|
@@ -416,38 +423,39 @@ TcgParseSyncSession(
|
|
|
UINT32 *TperSessionId
|
|
|
)
|
|
|
{
|
|
|
- UINT8 MethodStatus;
|
|
|
- TCG_PARSE_STRUCT TmpParseStruct;
|
|
|
- UINT16 ParseComId;
|
|
|
- UINT16 ParseExtComId;
|
|
|
- TCG_UID InvokingUID;
|
|
|
- TCG_UID MethodUID;
|
|
|
- UINT32 RecvHostSessionId;
|
|
|
+ UINT8 MethodStatus;
|
|
|
+ TCG_PARSE_STRUCT TmpParseStruct;
|
|
|
+ UINT16 ParseComId;
|
|
|
+ UINT16 ParseExtComId;
|
|
|
+ TCG_UID InvokingUID;
|
|
|
+ TCG_UID MethodUID;
|
|
|
+ UINT32 RecvHostSessionId;
|
|
|
|
|
|
- NULL_CHECK(ParseStruct);
|
|
|
- NULL_CHECK(TperSessionId);
|
|
|
+ NULL_CHECK (ParseStruct);
|
|
|
+ NULL_CHECK (TperSessionId);
|
|
|
|
|
|
- CopyMem (&TmpParseStruct, ParseStruct, sizeof(TCG_PARSE_STRUCT));
|
|
|
+ CopyMem (&TmpParseStruct, ParseStruct, sizeof (TCG_PARSE_STRUCT));
|
|
|
|
|
|
// verify method status is good
|
|
|
- ERROR_CHECK(TcgGetMethodStatus(&TmpParseStruct, &MethodStatus));
|
|
|
+ ERROR_CHECK (TcgGetMethodStatus (&TmpParseStruct, &MethodStatus));
|
|
|
METHOD_STATUS_ERROR_CHECK (MethodStatus, TcgResultFailure);
|
|
|
|
|
|
// verify comids
|
|
|
- ERROR_CHECK(TcgGetComIds(&TmpParseStruct, &ParseComId, &ParseExtComId));
|
|
|
+ ERROR_CHECK (TcgGetComIds (&TmpParseStruct, &ParseComId, &ParseExtComId));
|
|
|
|
|
|
if ((ComId != ParseComId) || (ComIdExtension != ParseExtComId)) {
|
|
|
DEBUG ((DEBUG_INFO, "unmatched comid (exp: 0x%X recv: 0x%X) or comid extension (exp: 0x%X recv: 0x%X)\n", ComId, ParseComId, ComIdExtension, ParseExtComId));
|
|
|
return TcgResultFailure;
|
|
|
}
|
|
|
- ERROR_CHECK(TcgGetNextCall(&TmpParseStruct));
|
|
|
- ERROR_CHECK(TcgGetNextTcgUid(&TmpParseStruct, &InvokingUID));
|
|
|
- ERROR_CHECK(TcgGetNextTcgUid(&TmpParseStruct, &MethodUID));
|
|
|
- ERROR_CHECK(TcgGetNextStartList(&TmpParseStruct));
|
|
|
- ERROR_CHECK(TcgGetNextUINT32(&TmpParseStruct, &RecvHostSessionId));
|
|
|
- ERROR_CHECK(TcgGetNextUINT32(&TmpParseStruct, TperSessionId));
|
|
|
- ERROR_CHECK(TcgGetNextEndList(&TmpParseStruct));
|
|
|
- ERROR_CHECK(TcgGetNextEndOfData(&TmpParseStruct));
|
|
|
+
|
|
|
+ ERROR_CHECK (TcgGetNextCall (&TmpParseStruct));
|
|
|
+ ERROR_CHECK (TcgGetNextTcgUid (&TmpParseStruct, &InvokingUID));
|
|
|
+ ERROR_CHECK (TcgGetNextTcgUid (&TmpParseStruct, &MethodUID));
|
|
|
+ ERROR_CHECK (TcgGetNextStartList (&TmpParseStruct));
|
|
|
+ ERROR_CHECK (TcgGetNextUINT32 (&TmpParseStruct, &RecvHostSessionId));
|
|
|
+ ERROR_CHECK (TcgGetNextUINT32 (&TmpParseStruct, TperSessionId));
|
|
|
+ ERROR_CHECK (TcgGetNextEndList (&TmpParseStruct));
|
|
|
+ ERROR_CHECK (TcgGetNextEndOfData (&TmpParseStruct));
|
|
|
|
|
|
if (InvokingUID != TCG_UID_SMUID) {
|
|
|
DEBUG ((DEBUG_INFO, "Invoking UID did not match UID_SMUID\n"));
|
|
@@ -482,22 +490,22 @@ TcgParseSyncSession(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgCreateEndSession(
|
|
|
- TCG_CREATE_STRUCT *CreateStruct,
|
|
|
- UINT32 *Size,
|
|
|
- UINT16 ComId,
|
|
|
- UINT16 ComIdExtension,
|
|
|
- UINT32 HostSessionId,
|
|
|
- UINT32 TpSessionId
|
|
|
+TcgCreateEndSession (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct,
|
|
|
+ UINT32 *Size,
|
|
|
+ UINT16 ComId,
|
|
|
+ UINT16 ComIdExtension,
|
|
|
+ UINT32 HostSessionId,
|
|
|
+ UINT32 TpSessionId
|
|
|
)
|
|
|
{
|
|
|
- ERROR_CHECK(TcgStartComPacket(CreateStruct, ComId, ComIdExtension));
|
|
|
- ERROR_CHECK(TcgStartPacket(CreateStruct, TpSessionId, HostSessionId, 0x0, 0x0, 0x0));
|
|
|
- ERROR_CHECK(TcgStartSubPacket(CreateStruct, 0x0));
|
|
|
- ERROR_CHECK(TcgAddEndOfSession(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndSubPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndComPacket(CreateStruct, Size));
|
|
|
+ ERROR_CHECK (TcgStartComPacket (CreateStruct, ComId, ComIdExtension));
|
|
|
+ ERROR_CHECK (TcgStartPacket (CreateStruct, TpSessionId, HostSessionId, 0x0, 0x0, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartSubPacket (CreateStruct, 0x0));
|
|
|
+ ERROR_CHECK (TcgAddEndOfSession (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndSubPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndComPacket (CreateStruct, Size));
|
|
|
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
@@ -512,19 +520,19 @@ TcgCreateEndSession(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgStartMethodSet(
|
|
|
- TCG_CREATE_STRUCT *CreateStruct,
|
|
|
- TCG_UID Row,
|
|
|
- UINT32 ColumnNumber
|
|
|
+TcgStartMethodSet (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct,
|
|
|
+ TCG_UID Row,
|
|
|
+ UINT32 ColumnNumber
|
|
|
)
|
|
|
{
|
|
|
- ERROR_CHECK(TcgStartMethodCall(CreateStruct, Row, TCG_UID_METHOD_SET));
|
|
|
- ERROR_CHECK(TcgStartParameters(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddStartName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddUINT8(CreateStruct, 0x01)); // "Values"
|
|
|
- ERROR_CHECK(TcgAddStartList(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddStartName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddUINT32(CreateStruct, ColumnNumber));
|
|
|
+ ERROR_CHECK (TcgStartMethodCall (CreateStruct, Row, TCG_UID_METHOD_SET));
|
|
|
+ ERROR_CHECK (TcgStartParameters (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddStartName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddUINT8 (CreateStruct, 0x01)); // "Values"
|
|
|
+ ERROR_CHECK (TcgAddStartList (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddStartName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddUINT32 (CreateStruct, ColumnNumber));
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
|
|
|
@@ -536,15 +544,15 @@ TcgStartMethodSet(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgEndMethodSet(
|
|
|
- TCG_CREATE_STRUCT *CreateStruct
|
|
|
+TcgEndMethodSet (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct
|
|
|
)
|
|
|
{
|
|
|
- ERROR_CHECK(TcgAddEndName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddEndList(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddEndName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndParameters(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndMethodCall(CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddEndName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddEndList (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddEndName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndParameters (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndMethodCall (CreateStruct));
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
|
|
|
@@ -565,28 +573,28 @@ TcgEndMethodSet(
|
|
|
**/
|
|
|
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
|
|
|
+TcgCreateSetCPin (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct,
|
|
|
+ UINT32 *Size,
|
|
|
+ UINT16 ComId,
|
|
|
+ UINT16 ComIdExtension,
|
|
|
+ UINT32 TperSession,
|
|
|
+ UINT32 HostSession,
|
|
|
+ TCG_UID SidRow,
|
|
|
+ const VOID *Password,
|
|
|
+ UINT32 PasswordSize
|
|
|
)
|
|
|
{
|
|
|
// set new SID Password
|
|
|
- ERROR_CHECK(TcgStartComPacket(CreateStruct, ComId, ComIdExtension));
|
|
|
- ERROR_CHECK(TcgStartPacket(CreateStruct, TperSession, HostSession, 0x0, 0x0, 0x0));
|
|
|
- ERROR_CHECK(TcgStartSubPacket(CreateStruct, 0x0));
|
|
|
- ERROR_CHECK(TcgStartMethodSet(CreateStruct, SidRow, 0x03)); // "PIN"
|
|
|
- ERROR_CHECK(TcgAddByteSequence(CreateStruct, Password, PasswordSize, FALSE));
|
|
|
- ERROR_CHECK(TcgEndMethodSet(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndSubPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndComPacket(CreateStruct, Size));
|
|
|
+ ERROR_CHECK (TcgStartComPacket (CreateStruct, ComId, ComIdExtension));
|
|
|
+ ERROR_CHECK (TcgStartPacket (CreateStruct, TperSession, HostSession, 0x0, 0x0, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartSubPacket (CreateStruct, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartMethodSet (CreateStruct, SidRow, 0x03)); // "PIN"
|
|
|
+ ERROR_CHECK (TcgAddByteSequence (CreateStruct, Password, PasswordSize, FALSE));
|
|
|
+ ERROR_CHECK (TcgEndMethodSet (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndSubPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndComPacket (CreateStruct, Size));
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
|
|
|
@@ -606,26 +614,26 @@ TcgCreateSetCPin(
|
|
|
**/
|
|
|
TCG_RESULT
|
|
|
EFIAPI
|
|
|
-TcgSetAuthorityEnabled(
|
|
|
- TCG_CREATE_STRUCT *CreateStruct,
|
|
|
- UINT32 *Size,
|
|
|
- UINT16 ComId,
|
|
|
- UINT16 ComIdExtension,
|
|
|
- UINT32 TperSession,
|
|
|
- UINT32 HostSession,
|
|
|
- TCG_UID AuthorityUid,
|
|
|
- BOOLEAN Enabled
|
|
|
+TcgSetAuthorityEnabled (
|
|
|
+ TCG_CREATE_STRUCT *CreateStruct,
|
|
|
+ UINT32 *Size,
|
|
|
+ UINT16 ComId,
|
|
|
+ UINT16 ComIdExtension,
|
|
|
+ UINT32 TperSession,
|
|
|
+ UINT32 HostSession,
|
|
|
+ TCG_UID AuthorityUid,
|
|
|
+ BOOLEAN Enabled
|
|
|
)
|
|
|
{
|
|
|
- ERROR_CHECK(TcgStartComPacket(CreateStruct, ComId, ComIdExtension));
|
|
|
- ERROR_CHECK(TcgStartPacket(CreateStruct, TperSession, HostSession, 0x0, 0x0, 0x0));
|
|
|
- ERROR_CHECK(TcgStartSubPacket(CreateStruct, 0x0));
|
|
|
- ERROR_CHECK(TcgStartMethodSet(CreateStruct, AuthorityUid, 0x05)); // "Enabled"
|
|
|
- ERROR_CHECK(TcgAddBOOLEAN(CreateStruct, Enabled));
|
|
|
- ERROR_CHECK(TcgEndMethodSet(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndSubPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndComPacket(CreateStruct, Size));
|
|
|
+ ERROR_CHECK (TcgStartComPacket (CreateStruct, ComId, ComIdExtension));
|
|
|
+ ERROR_CHECK (TcgStartPacket (CreateStruct, TperSession, HostSession, 0x0, 0x0, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartSubPacket (CreateStruct, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartMethodSet (CreateStruct, AuthorityUid, 0x05)); // "Enabled"
|
|
|
+ ERROR_CHECK (TcgAddBOOLEAN (CreateStruct, Enabled));
|
|
|
+ ERROR_CHECK (TcgEndMethodSet (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndSubPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndComPacket (CreateStruct, Size));
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
|
|
|
@@ -648,21 +656,21 @@ TcgSetAuthorityEnabled(
|
|
|
**/
|
|
|
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
|
|
|
+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
|
|
|
)
|
|
|
{
|
|
|
- UINT8 HalfUidAuthorityObjectRef[4];
|
|
|
- UINT8 HalfUidBooleanAce[4];
|
|
|
+ UINT8 HalfUidAuthorityObjectRef[4];
|
|
|
+ UINT8 HalfUidBooleanAce[4];
|
|
|
|
|
|
HalfUidAuthorityObjectRef[0] = 0x0;
|
|
|
HalfUidAuthorityObjectRef[1] = 0x0;
|
|
@@ -674,29 +682,29 @@ TcgCreateSetAce(
|
|
|
HalfUidBooleanAce[2] = 0x4;
|
|
|
HalfUidBooleanAce[3] = 0xE;
|
|
|
|
|
|
- ERROR_CHECK(TcgStartComPacket(CreateStruct, ComId, ComIdExtension));
|
|
|
- ERROR_CHECK(TcgStartPacket(CreateStruct, TperSession, HostSession, 0x0, 0x0, 0x0));
|
|
|
- ERROR_CHECK(TcgStartSubPacket(CreateStruct, 0x0));
|
|
|
- ERROR_CHECK(TcgStartMethodSet(CreateStruct, AceRow, 0x03)); // "BooleanExpr"
|
|
|
- ERROR_CHECK(TcgAddStartList(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddStartName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddByteSequence(CreateStruct, HalfUidAuthorityObjectRef, sizeof(HalfUidAuthorityObjectRef), FALSE));
|
|
|
- ERROR_CHECK(TcgAddTcgUid(CreateStruct, Authority1));
|
|
|
- ERROR_CHECK(TcgAddEndName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddStartName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddByteSequence(CreateStruct, HalfUidAuthorityObjectRef, sizeof(HalfUidAuthorityObjectRef), FALSE));
|
|
|
- ERROR_CHECK(TcgAddTcgUid(CreateStruct, Authority2));
|
|
|
- ERROR_CHECK(TcgAddEndName(CreateStruct));
|
|
|
-
|
|
|
- ERROR_CHECK(TcgAddStartName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddByteSequence(CreateStruct, HalfUidBooleanAce, sizeof(HalfUidBooleanAce), FALSE));
|
|
|
- ERROR_CHECK(TcgAddBOOLEAN(CreateStruct, LogicalOperator));
|
|
|
- ERROR_CHECK(TcgAddEndName(CreateStruct));
|
|
|
- ERROR_CHECK(TcgAddEndList(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndMethodSet(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndSubPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndPacket(CreateStruct));
|
|
|
- ERROR_CHECK(TcgEndComPacket(CreateStruct, Size));
|
|
|
+ ERROR_CHECK (TcgStartComPacket (CreateStruct, ComId, ComIdExtension));
|
|
|
+ ERROR_CHECK (TcgStartPacket (CreateStruct, TperSession, HostSession, 0x0, 0x0, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartSubPacket (CreateStruct, 0x0));
|
|
|
+ ERROR_CHECK (TcgStartMethodSet (CreateStruct, AceRow, 0x03)); // "BooleanExpr"
|
|
|
+ ERROR_CHECK (TcgAddStartList (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddStartName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddByteSequence (CreateStruct, HalfUidAuthorityObjectRef, sizeof (HalfUidAuthorityObjectRef), FALSE));
|
|
|
+ ERROR_CHECK (TcgAddTcgUid (CreateStruct, Authority1));
|
|
|
+ ERROR_CHECK (TcgAddEndName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddStartName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddByteSequence (CreateStruct, HalfUidAuthorityObjectRef, sizeof (HalfUidAuthorityObjectRef), FALSE));
|
|
|
+ ERROR_CHECK (TcgAddTcgUid (CreateStruct, Authority2));
|
|
|
+ ERROR_CHECK (TcgAddEndName (CreateStruct));
|
|
|
+
|
|
|
+ ERROR_CHECK (TcgAddStartName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddByteSequence (CreateStruct, HalfUidBooleanAce, sizeof (HalfUidBooleanAce), FALSE));
|
|
|
+ ERROR_CHECK (TcgAddBOOLEAN (CreateStruct, LogicalOperator));
|
|
|
+ ERROR_CHECK (TcgAddEndName (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgAddEndList (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndMethodSet (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndSubPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndPacket (CreateStruct));
|
|
|
+ ERROR_CHECK (TcgEndComPacket (CreateStruct, Size));
|
|
|
return TcgResultSuccess;
|
|
|
}
|
|
|
|
|
@@ -712,21 +720,21 @@ TcgCreateSetAce(
|
|
|
**/
|
|
|
BOOLEAN
|
|
|
EFIAPI
|
|
|
-TcgEnumLevel0Discovery(
|
|
|
+TcgEnumLevel0Discovery (
|
|
|
const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
|
|
|
TCG_LEVEL0_ENUM_CALLBACK Callback,
|
|
|
VOID *Context
|
|
|
)
|
|
|
{
|
|
|
- UINT32 BytesLeft;
|
|
|
- const UINT8 *DiscoveryBufferPtr;
|
|
|
- UINT32 FeatLength;
|
|
|
- TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feat;
|
|
|
+ UINT32 BytesLeft;
|
|
|
+ const UINT8 *DiscoveryBufferPtr;
|
|
|
+ UINT32 FeatLength;
|
|
|
+ TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feat;
|
|
|
|
|
|
//
|
|
|
// Total bytes including descriptors but not including the Length field
|
|
|
//
|
|
|
- BytesLeft = SwapBytes32(DiscoveryHeader->LengthBE);
|
|
|
+ BytesLeft = SwapBytes32 (DiscoveryHeader->LengthBE);
|
|
|
|
|
|
//
|
|
|
// If discovery Header is not valid, exit
|
|
@@ -738,20 +746,20 @@ TcgEnumLevel0Discovery(
|
|
|
//
|
|
|
// Subtract the Length of the Header, except the Length field, which is not included
|
|
|
//
|
|
|
- BytesLeft -= (sizeof(TCG_LEVEL0_DISCOVERY_HEADER) - sizeof(DiscoveryHeader->LengthBE));
|
|
|
+ BytesLeft -= (sizeof (TCG_LEVEL0_DISCOVERY_HEADER) - sizeof (DiscoveryHeader->LengthBE));
|
|
|
|
|
|
//
|
|
|
// Move ptr to first descriptor
|
|
|
//
|
|
|
- DiscoveryBufferPtr = (const UINT8*)DiscoveryHeader + sizeof(TCG_LEVEL0_DISCOVERY_HEADER);
|
|
|
+ DiscoveryBufferPtr = (const UINT8 *)DiscoveryHeader + sizeof (TCG_LEVEL0_DISCOVERY_HEADER);
|
|
|
|
|
|
- while (BytesLeft > sizeof(TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER)) {
|
|
|
+ while (BytesLeft > sizeof (TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER)) {
|
|
|
//
|
|
|
// Pointer to beginning of descriptor (including common Header)
|
|
|
//
|
|
|
- Feat = (TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER*)DiscoveryBufferPtr;
|
|
|
+ Feat = (TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *)DiscoveryBufferPtr;
|
|
|
|
|
|
- FeatLength = Feat->Length + sizeof(TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER);
|
|
|
+ FeatLength = Feat->Length + sizeof (TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER);
|
|
|
|
|
|
//
|
|
|
// Not enough bytes left for Feature descriptor
|
|
@@ -763,14 +771,14 @@ TcgEnumLevel0Discovery(
|
|
|
//
|
|
|
// Report the Feature to the callback
|
|
|
//
|
|
|
- if (Callback(DiscoveryHeader, Feat, FeatLength, Context)) {
|
|
|
+ if (Callback (DiscoveryHeader, Feat, FeatLength, Context)) {
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// Descriptor Length only describes Data after common Header
|
|
|
//
|
|
|
- BytesLeft -= FeatLength;
|
|
|
+ BytesLeft -= FeatLength;
|
|
|
DiscoveryBufferPtr += FeatLength;
|
|
|
}
|
|
|
|
|
@@ -788,21 +796,22 @@ TcgEnumLevel0Discovery(
|
|
|
**/
|
|
|
BOOLEAN
|
|
|
EFIAPI
|
|
|
-TcgFindFeatureCallback(
|
|
|
- const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
|
|
|
- TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature,
|
|
|
- UINTN FeatureSize,
|
|
|
- VOID *Context
|
|
|
+TcgFindFeatureCallback (
|
|
|
+ const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
|
|
|
+ TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature,
|
|
|
+ UINTN FeatureSize,
|
|
|
+ VOID *Context
|
|
|
)
|
|
|
{
|
|
|
- TCG_FIND_FEATURE_CTX* FindCtx;
|
|
|
+ TCG_FIND_FEATURE_CTX *FindCtx;
|
|
|
|
|
|
- FindCtx = (TCG_FIND_FEATURE_CTX*)Context;
|
|
|
- if ( SwapBytes16( Feature->FeatureCode_BE ) == FindCtx->FeatureCode ) {
|
|
|
- FindCtx->Feature = Feature;
|
|
|
+ FindCtx = (TCG_FIND_FEATURE_CTX *)Context;
|
|
|
+ if ( SwapBytes16 (Feature->FeatureCode_BE) == FindCtx->FeatureCode ) {
|
|
|
+ FindCtx->Feature = Feature;
|
|
|
FindCtx->FeatureSize = FeatureSize;
|
|
|
return TRUE; // done enumerating features
|
|
|
}
|
|
|
+
|
|
|
return FALSE; // continue enumerating
|
|
|
}
|
|
|
|
|
@@ -815,24 +824,25 @@ TcgFindFeatureCallback(
|
|
|
|
|
|
@retval return the Feature code data.
|
|
|
**/
|
|
|
-TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER*
|
|
|
+TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *
|
|
|
EFIAPI
|
|
|
-TcgGetFeature(
|
|
|
+TcgGetFeature (
|
|
|
const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
|
|
|
UINT16 FeatureCode,
|
|
|
UINTN *FeatureSize
|
|
|
)
|
|
|
{
|
|
|
- TCG_FIND_FEATURE_CTX FindCtx;
|
|
|
+ TCG_FIND_FEATURE_CTX FindCtx;
|
|
|
|
|
|
FindCtx.FeatureCode = FeatureCode;
|
|
|
- FindCtx.Feature = NULL;
|
|
|
+ FindCtx.Feature = NULL;
|
|
|
FindCtx.FeatureSize = 0;
|
|
|
|
|
|
- TcgEnumLevel0Discovery(DiscoveryHeader, TcgFindFeatureCallback, &FindCtx);
|
|
|
+ TcgEnumLevel0Discovery (DiscoveryHeader, TcgFindFeatureCallback, &FindCtx);
|
|
|
if (FeatureSize != NULL) {
|
|
|
*FeatureSize = FindCtx.FeatureSize;
|
|
|
}
|
|
|
+
|
|
|
return FindCtx.Feature;
|
|
|
}
|
|
|
|
|
@@ -846,19 +856,19 @@ TcgGetFeature(
|
|
|
**/
|
|
|
BOOLEAN
|
|
|
EFIAPI
|
|
|
-TcgIsProtocolSupported(
|
|
|
- const TCG_SUPPORTED_SECURITY_PROTOCOLS *ProtocolList,
|
|
|
- UINT16 Protocol
|
|
|
+TcgIsProtocolSupported (
|
|
|
+ const TCG_SUPPORTED_SECURITY_PROTOCOLS *ProtocolList,
|
|
|
+ UINT16 Protocol
|
|
|
)
|
|
|
{
|
|
|
- UINT16 Index;
|
|
|
- UINT16 ListLength;
|
|
|
+ UINT16 Index;
|
|
|
+ UINT16 ListLength;
|
|
|
|
|
|
- ListLength = SwapBytes16(ProtocolList->ListLength_BE);
|
|
|
+ ListLength = SwapBytes16 (ProtocolList->ListLength_BE);
|
|
|
|
|
|
- if (ListLength > sizeof(ProtocolList->List)) {
|
|
|
+ if (ListLength > sizeof (ProtocolList->List)) {
|
|
|
DEBUG ((DEBUG_INFO, "WARNING: list Length is larger than max allowed Value; truncating\n"));
|
|
|
- ListLength = sizeof(ProtocolList->List);
|
|
|
+ ListLength = sizeof (ProtocolList->List);
|
|
|
}
|
|
|
|
|
|
for (Index = 0; Index < ListLength; Index++) {
|
|
@@ -879,17 +889,17 @@ TcgIsProtocolSupported(
|
|
|
**/
|
|
|
BOOLEAN
|
|
|
EFIAPI
|
|
|
-TcgIsLocked(
|
|
|
- const TCG_LEVEL0_DISCOVERY_HEADER *Discovery
|
|
|
+TcgIsLocked (
|
|
|
+ const TCG_LEVEL0_DISCOVERY_HEADER *Discovery
|
|
|
)
|
|
|
{
|
|
|
- UINTN Size;
|
|
|
- TCG_LOCKING_FEATURE_DESCRIPTOR *LockDescriptor;
|
|
|
+ UINTN Size;
|
|
|
+ TCG_LOCKING_FEATURE_DESCRIPTOR *LockDescriptor;
|
|
|
|
|
|
- Size = 0;
|
|
|
- LockDescriptor =(TCG_LOCKING_FEATURE_DESCRIPTOR*) TcgGetFeature (Discovery, TCG_FEATURE_LOCKING, &Size);
|
|
|
+ Size = 0;
|
|
|
+ LockDescriptor = (TCG_LOCKING_FEATURE_DESCRIPTOR *)TcgGetFeature (Discovery, TCG_FEATURE_LOCKING, &Size);
|
|
|
|
|
|
- if (LockDescriptor != NULL && Size >= sizeof(*LockDescriptor)) {
|
|
|
+ if ((LockDescriptor != NULL) && (Size >= sizeof (*LockDescriptor))) {
|
|
|
DEBUG ((DEBUG_INFO, "locked: %d\n", LockDescriptor->Locked));
|
|
|
return LockDescriptor->Locked;
|
|
|
}
|