[tpm2] Re: How do I use Microsoft's sim (TSS.MSR) with lib tss2-esys
Roberts, William C <william.c.roberts at intel.com>
| Newsgroups | dev.linux.lists.tpm2 |
|---|---|
| Message-ID | <SN6PR11MB343703EFD83D9309BA392869B80A9@SN6PR11MB3437.namprd11.prod.outlook.com> |
TL;DR So Esys_Initialize with NULL parameters essentially invokes the auto-discovery feature to look for a TCTI that can connect with default parameters. Depending on the version, you'll see a lot of superfluous errors as it searches around, this was fixed recently but cannot recall the version that's fixed in. Below you mention: I also tried to run the code using the Linux subsystem and I configured it as follows: ./configure --enable-tcti-mssim BTW, could not find any documentation on above, but it seemed to work? I think the tcti you needed just wasn't get built by default. mssim is for the ibm tpm simulator. So auto-discovery was failing. You could also configure with --with-tctidefaultmodule to set the default as described below to silence those errors. Documentation is in configure --help, less than ideal, but we don't document the build configure options in full right now. Gory Details of what I considered Considering that you mentioned "linux subsystem", I've never tried using any of this on Windows, I am predominately a Linux engineer. TBS TCTI would connect you to the TBS service on windows, which is our equivalent of tpm2-abrmd for linux. Device TCTI is linux only. mssim TCTI is the one you want to use for this connection and you MUST have the ibm tpm simulator running with no arguments (default ports). In the first block of error codes: WARNING:tcti:tcti-tbs.c:292:Tss2_Tcti_Tbs_Init() Failed to create context with TBS error: 0x8028400f ERROR:tcti:tctildr-nodl.c:152:tctildr_get_default() No standard TCTI could be loaded ERROR:tcti:tctildr.c:428:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI ERROR:esys:esys_context.c:69:Esys_Initialize() Initialize default tcti. ErrorCode (0x000a000a) I don't see it try the mssim simulator, I wonder if it wasn't built or not found on the library path (no idea how to check that on windows). For linux something like ldconfig -v -N | grep mssim should come back with a result. As you can see its on my path. If it isn't you can set env variable LD_LIBRARY_PATH to include it or configure ld to include it (see https://blog.andrewbeacock.com/2007/10/how-to-add-shared-libraries-to-linuxs.html). Additionally you could look at using configure time option --with-tctidefaultmodule to set it to tss2-tcti-mssim.so (I guess it would be dll for windows?) Sorry I cannot be of much help with windows, maybe something in there will help point you to what to look at. Bill ________________________________ From: Markus Willhelm Schmid <willhelm.schmid(a)gmail.com> Sent: Tuesday, March 8, 2022 5:52 PM To: tpm2(a)lists.01.org <tpm2(a)lists.01.org> Subject: [tpm2] How do I use Microsoft's sim (TSS.MSR) with lib tss2-esys I have compiled the libraries using the included Visual Studio solution and copied the following C example: https://tpm2-software.github.io/tpm2-tss/getting-started/2019/02/05/Getting-Started.html When I run the code, I get the following error when function Esys_Initialize is called: WARNING:tcti:tcti-tbs.c:292:Tss2_Tcti_Tbs_Init() Failed to create context with TBS error: 0x8028400f ERROR:tcti:tctildr-nodl.c:152:tctildr_get_default() No standard TCTI could be loaded ERROR:tcti:tctildr.c:428:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI ERROR:esys:esys_context.c:69:Esys_Initialize() Initialize default tcti. ErrorCode (0x000a000a) I also tried to run the code using the Linux subsystem and I configured it as follows: ./configure --enable-tcti-mssim BTW, could not find any documentation on above, but it seemed to work? When run without the simulator, I get a list of errors including: WARNING:tcti:src/util/io.c:251:socket_connect() Failed to connect to host 127.0.0.1, port 2321: errno 111: Connection refused I do not get the above socket error when the simulator is running, but it still does not work: ERROR:tcti:src/tss2-tcti/tcti-device.c:439:Tss2_Tcti_Device_Init() Failed to open device file /dev/tpmrm0: No such file or directory WARNING:tcti:src/tss2-tcti/tctildr.c:62:tcti_from_init() TCTI init for function 0x7f9b65ec1fb0 failed with a000a WARNING:tcti:src/tss2-tcti/tctildr.c:92:tcti_from_info() Could not initialize TCTI named: tcti-device ERROR:tcti:src/tss2-tcti/tctildr-dl.c:150:tcti_from_file() Could not initialize TCTI file: libtss2-tcti-device.so.0 ERROR:tcti:src/tss2-tcti/tcti-device.c:439:Tss2_Tcti_Device_Init() Failed to open device file /dev/tpm0: No such file or directory WARNING:tcti:src/tss2-tcti/tctildr.c:62:tcti_from_init() TCTI init for function 0x7f9b65ec1fb0 failed with a000a WARNING:tcti:src/tss2-tcti/tctildr.c:92:tcti_from_info() Could not initialize TCTI named: tcti-device ERROR:tcti:src/tss2-tcti/tctildr-dl.c:150:tcti_from_file() Could not initialize TCTI file: libtss2-tcti-device.so.0 WARNING:esys:src/tss2-esys/api/Esys_GetRandom.c:277:Esys_GetRandom_Finish() Received TPM Error ERROR:esys:src/tss2-esys/api/Esys_GetRandom.c:95:Esys_GetRandom() Esys Finish ErrorCode (0x00000100)
attachment.htm
(text/html, 14.7 KB)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
TL;DR</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
So Esys_Initialize with NULL parameters essentially invokes the auto-discovery feature to look for a TCTI that can connect with default parameters. Depending on the version, you'll see a lot of superfluous errors as it searches around, this was fixed recently
but cannot recall the version that's fixed in.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Below you mention:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">I also
tried to run the code using the Linux subsystem and I configured it as follows:</span><br>
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">./configure
--enable-tcti-mssim</span><br style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255)">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">BTW,
could not find any documentation on above, but it seemed to work?</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I think the tcti you needed just wasn't get built by default. mssim is for the ibm tpm simulator. So auto-discovery was failing.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
You could also configure with --with-tctidefaultmodule to set the default as described below to silence those errors.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Documentation is in configure --help, less than ideal, but we don't document the build configure options in full right now.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">Gory Details of what I considered</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Considering that you mentioned "linux subsystem", I've never tried using any of this on Windows, I am predominately a Linux engineer.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
TBS TCTI would connect you to the TBS service on windows, which is our equivalent of tpm2-abrmd for linux.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Device TCTI is linux only.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
mssim TCTI is the one you want to use for this connection and you MUST have the ibm tpm simulator running with no arguments (default ports).</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
In the first block of error codes:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">WARNING:tcti:tcti-tbs.c:292:Tss2_Tcti_Tbs_Init()
Failed to create context with TBS error: 0x8028400f</span><br>
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">ERROR:tcti:tctildr-nodl.c:152:tctildr_get_default()
No standard TCTI could be loaded</span><br style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255)">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">ERROR:tcti:tctildr.c:428:Tss2_TctiLdr_Initialize_Ex()
Failed to instantiate TCTI</span><br style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255)">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important">ERROR:esys:esys_context.c:69:Esys_Initialize()
Initialize default tcti. ErrorCode (0x000a000a)</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important"><span style="color:rgb(0, 0, 0);font-family:Calibri, Arial, Helvetica, sans-serif;font-size:16px;background-color:rgb(255, 255, 255);display:inline !important">I
don't see it try the mssim simulator, I wonder if it wasn't built or not found on the library path (no idea how to check that on windows). For linux</span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important"><span style="color:rgb(0, 0, 0);font-family:Calibri, Arial, Helvetica, sans-serif;font-size:16px;background-color:rgb(255, 255, 255);display:inline !important">something
like ldconfig -v -N | grep mssim should</span></span><span style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"> come back with a result. </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important"><span style="color:rgb(0, 0, 0);font-family:Calibri, Arial, Helvetica, sans-serif;font-size:16px;background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:15px;background-color:rgb(255, 255, 255);display:inline !important"><span style="color:rgb(0, 0, 0);font-family:Calibri, Arial, Helvetica, sans-serif;font-size:16px;background-color:rgb(255, 255, 255);display:inline !important">As
you can see its on my path. If it isn't you can set env variable LD_LIBRARY_PATH to include it or configure ld to include it (see
<a href="https://blog.andrewbeacock.com/2007/10/how-to-add-shared-libraries-to-linuxs.html" id="LPNoLPOWALinkPreview">
https://blog.andrewbeacock.com/2007/10/how-to-add-shared-libraries-to-linuxs.html</a>).</span></span></div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1"></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Additionally you could look at using configure time option --with-tctidefaultmodule to set it to tss2-tcti-mssim.so (I guess it would be dll for windows?)</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Sorry I cannot be of much help with windows, maybe something in there will help point you to what to look at.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Bill</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Markus Willhelm Schmid <[email protected]><br>
<b>Sent:</b> Tuesday, March 8, 2022 5:52 PM<br>
<b>To:</b> [email protected] <[email protected]><br>
<b>Subject:</b> [tpm2] How do I use Microsoft's sim (TSS.MSR) with lib tss2-esys</font>
<div> </div>
</div>
<div>
<div dir="ltr">I have compiled the libraries using the included Visual Studio solution and copied the following C example: <a href="https://tpm2-software.github.io/tpm2-tss/getting-started/2019/02/05/Getting-Started.html">https://tpm2-software.github.io/tpm2-tss/getting-started/2019/02/05/Getting-Started.html</a>
<div><br>
</div>
<div>When I run the code, I get the following error when function Esys_Initialize is called:</div>
<div>WARNING:tcti:tcti-tbs.c:292:Tss2_Tcti_Tbs_Init() Failed to create context with TBS error: 0x8028400f<br>
ERROR:tcti:tctildr-nodl.c:152:tctildr_get_default() No standard TCTI could be loaded<br>
ERROR:tcti:tctildr.c:428:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI<br>
ERROR:esys:esys_context.c:69:Esys_Initialize() Initialize default tcti. ErrorCode (0x000a000a)<br>
</div>
<div><br>
</div>
<div>I also tried to run the code using the Linux subsystem and I configured it as follows:<br>
./configure --enable-tcti-mssim<br>
BTW, could not find any documentation on above, but it seemed to work?</div>
<div><br>
</div>
<div>When run without the simulator, I get a list of errors including:<br>
WARNING:tcti:src/util/io.c:251:socket_connect() Failed to connect to host 127.0.0.1, port 2321: errno 111: Connection refused<br>
</div>
<div><br>
</div>
<div>I do not get the above socket error when the simulator is running, but it still does not work:<br>
ERROR:tcti:src/tss2-tcti/tcti-device.c:439:Tss2_Tcti_Device_Init() Failed to open device file /dev/tpmrm0: No such file or directory<br>
WARNING:tcti:src/tss2-tcti/tctildr.c:62:tcti_from_init() TCTI init for function 0x7f9b65ec1fb0 failed with a000a<br>
WARNING:tcti:src/tss2-tcti/tctildr.c:92:tcti_from_info() Could not initialize TCTI named: tcti-device<br>
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:150:tcti_from_file() Could not initialize TCTI file: libtss2-tcti-device.so.0<br>
ERROR:tcti:src/tss2-tcti/tcti-device.c:439:Tss2_Tcti_Device_Init() Failed to open device file /dev/tpm0: No such file or directory<br>
WARNING:tcti:src/tss2-tcti/tctildr.c:62:tcti_from_init() TCTI init for function 0x7f9b65ec1fb0 failed with a000a<br>
WARNING:tcti:src/tss2-tcti/tctildr.c:92:tcti_from_info() Could not initialize TCTI named: tcti-device<br>
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:150:tcti_from_file() Could not initialize TCTI file: libtss2-tcti-device.so.0<br>
WARNING:esys:src/tss2-esys/api/Esys_GetRandom.c:277:Esys_GetRandom_Finish() Received TPM Error<br>
ERROR:esys:src/tss2-esys/api/Esys_GetRandom.c:95:Esys_GetRandom() Esys Finish ErrorCode (0x00000100)<br>
</div>
</div>
</div>
</body>
</html>