[tpm2] Re: How do I use Microsoft's sim (TSS.MSR) with lib tss2-esys
Markus Willhelm Schmid <willhelm.schmid at gmail.com>
| Newsgroups | dev.linux.lists.tpm2 |
|---|---|
| Message-ID | <CAMs2GArBD5c5M-CPxUiUd4F2Gq7qChkFfwKxOyPXiG0v67C5HQ@mail.gmail.com> |
Thanks Bill, I am a noob and I am just trying to learn. I have no TPM on my computer so I have to use a simulator. I am a little confused since this page: https://sourceforge.net/projects/ibmswtpm2/ Says: The latter implements the protocol exposed by the Microsoft software TPM2 simulator. Google sent me to: https://www.microsoft.com/en-us/download/details.aspx?id=52507 When you say IBM simulator, are you referring to: https://sourceforge.net/projects/ibmtpm20tss/ If so, this code will not compile on Windows or Linux. I tried to bypass the ifdef for OpenSSL version check in the headers, but I then got a lot of errors. I believe this code requires an ancient (unspecified) OpenSSL version. Also, I could not find anything pre-built. -Markus On Wed, Mar 9, 2022 at 7:41 AM Roberts, William C < william.c.roberts(a)intel.com> wrote: > 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, 12.9 KB)
<div dir="ltr">Thanks Bill, <div><br></div><div>I am a noob and I am just trying to learn. I have no TPM on my computer so I have to use a simulator.<div><br></div><div>I am a little confused since this page: <a href="https://sourceforge.net/projects/ibmswtpm2/" target="_blank">https://sourceforge.net/projects/ibmswtpm2/</a><br>Says: The latter implements the protocol exposed by the Microsoft software TPM2 simulator. Google sent me to: <a href="https://www.microsoft.com/en-us/download/details.aspx?id=52507" target="_blank">https://www.microsoft.com/en-us/download/details.aspx?id=52507</a></div><div><br></div><div>When you say IBM simulator, are you referring to: <a href="https://sourceforge.net/projects/ibmtpm20tss/" target="_blank">https://sourceforge.net/projects/ibmtpm20tss/</a></div><div>If so, this code will not compile on Windows or Linux. I tried to bypass the ifdef for OpenSSL version check in the headers, but I then got a lot of errors. I believe this code requires an ancient (unspecified) OpenSSL version. Also, I could not find anything pre-built.</div><font color="#888888"><div><br></div><div>-Markus</div></font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 9, 2022 at 7:41 AM Roberts, William C <<a href="mailto:[email protected]">[email protected]</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div 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-size:15px;background-color:rgb(255,255,255);display:inline">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-size:15px;background-color:rgb(255,255,255);display:inline">./configure --enable-tcti-mssim</span><br style="color:rgb(32,31,30);font-size:15px;background-color:rgb(255,255,255)"> <span style="color:rgb(32,31,30);font-size:15px;background-color:rgb(255,255,255);display:inline">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-size:15px;background-color:rgb(255,255,255);display:inline">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-size:15px;background-color:rgb(255,255,255);display:inline">ERROR:tcti:tctildr-nodl.c:152:tctildr_get_default() No standard TCTI could be loaded</span><br style="color:rgb(32,31,30);font-size:15px;background-color:rgb(255,255,255)"> <span style="color:rgb(32,31,30);font-size:15px;background-color:rgb(255,255,255);display:inline">ERROR:tcti:tctildr.c:428:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI</span><br style="color:rgb(32,31,30);font-size:15px;background-color:rgb(255,255,255)"> <span style="color:rgb(32,31,30);font-size:15px;background-color:rgb(255,255,255);display:inline">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-size:15px;background-color:rgb(255,255,255);display:inline"><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-size:15px;background-color:rgb(255,255,255);display:inline"><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">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-size:15px;background-color:rgb(255,255,255);display:inline"><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">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-size:15px;background-color:rgb(255,255,255);display:inline"><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"><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-size:15px;background-color:rgb(255,255,255);display:inline"><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">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="gmail-m_-8904761660201080067LPNoLPOWALinkPreview" target="_blank"> https://blog.andrewbeacock.com/2007/10/how-to-add-shared-libraries-to-linuxs.html</a>).</span></span></div> <div></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="gmail-m_-8904761660201080067appendonsend"></div> <hr style="display:inline-block;width:98%"> <div id="gmail-m_-8904761660201080067divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Markus Willhelm Schmid <<a href="mailto:[email protected]" target="_blank">[email protected]</a>><br> <b>Sent:</b> Tuesday, March 8, 2022 5:52 PM<br> <b>To:</b> <a href="mailto:[email protected]" target="_blank">[email protected]</a> <<a href="mailto:[email protected]" target="_blank">[email protected]</a>><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" target="_blank">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> </div> </blockquote></div>