3

In the Windows SDK (Vista and above), there exists tbs.h/dll/lib to interace with TPM Base Services. I want to execute some TPM commands, and see MSDN reference to the following http://msdn.microsoft.com/en-us/library/windows/desktop/aa446799(v=vs.85).aspx

I am not sure how to construct my "command buffer" and pass any specific commands. I can't find any specific examples of this anywhere.

I want to use TPM_Seal, but haven't the slightest on how to setup the command.

I setup a basic C++ app that creates the TBS context below, and this is successful.

TBS_CONTEXT_PARAMS    pContextParams;
TBS_HCONTEXT        hContext;
TBS_RESULT            rv;
pContextParams.version = TBS_CONTEXT_VERSION_ONE;

rv = Tbsi_Context_Create(&pContextParams, &hContext);
printf("\n1 RESULT : %x  STATUS : %x", rv, hContext);

BYTE data[10] = {0,0xc0,0,0,0,0x0a,0,0,0,0x50};
BYTE buf[512];
UINT32 buf_len = 512;

rv = Tbsip_Submit_Command(hContext,0,TBS_COMMAND_PRIORITY_NORMAL,data,10,buf,&buf_len);
printf("\n2 RESULT : %x  STATUS : %x", rv, hContext);

rv = Tbsip_Context_Close(hContext);
printf("\n3 RESULT : %x  STATUS : %x", rv, hContext);

This example works and seems to pass the commands correctly -- I just need to find some info on how to get the "right" command sequence into the command buffer.

The function references are here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa446799(v=vs.85).aspx

And the tbs.h does not include any structures relating to the commands. Most of the examples I see are using TSS API (which I don't think I can use on windows.)

Information I've gathered so far:
TPM Data Structures are Listed here: http://www.trustedcomputinggroup.org/files/static_page_files/E55A303C-1A4B-B294-D066E66A82DAE27D/TPM%20Main-Part%202%20TPM%20Structures_v1.2_rev116_01032011.pdf

TrouSerS (http://trousers.sourceforge.net/) has a set of include files that painstakingly defines all of the various bytecodes defined above.

Yablargo
  • 3,520
  • 7
  • 37
  • 58
  • I've looked at the includes (tss.h, tpm.h) on The Trousers project @ http://trousers.sourceforge.net/ and this at least defines most of the hex codes used. – Yablargo Jun 12 '14 at 21:12
  • This doc http://www.trustedcomputinggroup.org/files/static_page_files/E55A303C-1A4B-B294-D066E66A82DAE27D/TPM%20Main-Part%202%20TPM%20Structures_v1.2_rev116_01032011.pdf lists the TPM structures. including all of the various byte commands. – Yablargo Jun 12 '14 at 21:16

1 Answers1

1

The commands are not described in Part 2 of the Specification but rather in Part 3 - Commands.

The TPM_seal command is defined in section 10.1 on page 72. Line 1331 shows you how the command has to look like.

Also note that the returnvalue rv does not tell you whether the command was successfully executed on the TPM. It just tells you whether TBS was able to send the command and recieve the response. You have to decode the pabResult buffer.

You should also look at my answer to your other question.

Community
  • 1
  • 1
Scolytus
  • 16,338
  • 6
  • 46
  • 69