[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 <CAMs2GAqF=oqPqqC53+QCA0xySrwbdR-wgwDD2DZj1-2DZGDQdw@mail.gmail.com>
I made an error in my previous email, I pasted in the URL to IBM's TCC
stack and not to IBM's SW TPM. This is what I am trying to compile.
https://sourceforge.net/projects/ibmswtpm2/

On Windows, my OpenSSL version is 3.0.1 and on Linux, it's 1.1.1f  (31 Mar
2020). The version number triggers when I compile SW TPM on Windows and
when I bypass this version check, the following fails:
#if    defined THIRTY_TWO_BIT && (RADIX_BITS != 32) \
    || ((defined SIXTY_FOUR_BIT_LONG || defined SIXTY_FOUR_BIT) \
&& (RADIX_BITS != 64))
#   error Ossl library is using different radix
#endif

The above compiles after changing the Visual Studio project from 32 bit to
64 bit. In other words, there appears to be a problem with this project
file.

So I managed to compile for both Linux and Windows. When I run the
simulator on Linux and try the test program I mentioned in my first email,
I see this being printed by the simulator:

Command IPv4 client accepted
Platform IPv4 client accepted

However, the client still prints:
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 0x7f56f5701fb0 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 0x7f56f5701fb0 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)
Error: Esys_GetRandom

The last error is from my test program:
    Esys_Initialize ..... *this seems to be OK*
    r = Esys_GetRandom(ctx, ESYS_TR_NONE, ESYS_TR_NONE, ESYS_TR_NONE, 20,
                       &random_bytes);

    if (r != TSS2_RC_SUCCESS){
        printf("\n*Error: Esys_GetRandom*\n");
        exit(1);
    }

Questions:
How do I make the test program work (Esys_GetRandom) with the simulator?
if the IBM simulator is required (IBM SW TPM), why does the documentation
state that I have to use the Microsoft simulator (ref:
https://github.com/tpm2-software/tpm2-tss/blob/master/README.md)?
If tpm2-tss library is compliant, should the stack not work with any
compatible TPM 2.0 simulator, including Microsoft's simulator and IBM's
simulator?

On Thu, Mar 10, 2022 at 6:11 AM Kenneth Goldman <kgoldman(a)us.ibm.com> wrote:

>
>
>
>
> *From:* Markus Willhelm Schmid <willhelm.schmid(a)gmail.com>
> *Sent:* Wednesday, March 9, 2022 4:08 PM
> *Cc:* tpm2(a)lists.01.org
> *Subject:* [EXTERNAL] [tpm2] Re: How do I use Microsoft's sim (TSS.MSR)
> with lib tss2-esys
>
>
>
> 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.
>
> [kgold]
>
> [kgold] I support the IBM SW TPM.  I test it on Windows and many Linux,
> with various OpenSS, gcc, mingw, Visual Studio.  If something doesn't work,
> file a bug report, email me, post here, but don't just give up.  It's
> widely used.
>
attachment.htm (text/html, 5.6 KB)
<div dir="ltr">I made an error in my previous email, I pasted in the URL to IBM&#39;s TCC stack and not to IBM&#39;s SW TPM. This is what I am trying to compile.<br><a href="https://sourceforge.net/projects/ibmswtpm2/">https://sourceforge.net/projects/ibmswtpm2/</a><div><br>On Windows, my OpenSSL version is 3.0.1 and on Linux, it&#39;s 1.1.1f  (31 Mar 2020). The version number triggers when I compile SW TPM on Windows and when I bypass this version check, the following fails:</div><div>#if    defined THIRTY_TWO_BIT &amp;&amp; (RADIX_BITS != 32)			\<br>    || ((defined SIXTY_FOUR_BIT_LONG || defined SIXTY_FOUR_BIT)		\<br>	&amp;&amp; (RADIX_BITS != 64))<br>#   error Ossl library is using different radix<br>#endif<br><br>The above compiles after changing the Visual Studio project from 32 bit to 64 bit. In other words, there appears to be a problem with this project file.<br><br>So I managed to compile for both Linux and Windows. When I run the simulator on Linux and try the test program I mentioned in my first email, I see this being printed by the simulator:<br><br>Command IPv4 client accepted<br>Platform IPv4 client accepted<br><br>However, the client still prints:<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 0x7f56f5701fb0 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 0x7f56f5701fb0 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>Error: Esys_GetRandom<br><div><br></div><div>The last error is from my test program:</div><div>    Esys_Initialize ..... <b>this seems to be OK</b><br>    r = Esys_GetRandom(ctx, ESYS_TR_NONE, ESYS_TR_NONE, ESYS_TR_NONE, 20,<br>                       &amp;random_bytes);<br><br>    if (r != TSS2_RC_SUCCESS){<br>        printf(&quot;\n<b>Error: Esys_GetRandom</b>\n&quot;);<br>        exit(1);<br>    }<br><br>Questions: <br>How do I make the test program work (Esys_GetRandom) with the simulator?<br>if the IBM simulator is required (IBM SW TPM), why does the documentation state that I have to use the Microsoft simulator (ref: <a href="https://github.com/tpm2-software/tpm2-tss/blob/master/README.md">https://github.com/tpm2-software/tpm2-tss/blob/master/README.md</a>)?<br>If tpm2-tss library is compliant, should the stack not work with any compatible TPM 2.0 simulator, including Microsoft&#39;s simulator and IBM&#39;s simulator?<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 10, 2022 at 6:11 AM Kenneth Goldman &lt;<a href="mailto:[email protected]">[email protected]</a>&gt; 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 lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_-9054569216962538835WordSection1">
<p class="MsoNormal"><span style="font-family:&quot;DejaVu Sans&quot;,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:&quot;DejaVu Sans&quot;,sans-serif"><u></u> <u></u></span></p>
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-left:0.5in"><b>From:</b> Markus Willhelm Schmid &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;
<br>
<b>Sent:</b> Wednesday, March 9, 2022 4:08 PM<br>
<b>Cc:</b> <a href="mailto:[email protected]" target="_blank">[email protected]</a><br>
<b>Subject:</b> [EXTERNAL] [tpm2] Re: How do I use Microsoft&#39;s sim (TSS.MSR) with lib tss2-esys<u></u><u></u></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:0.5in"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:0.5in">When you say IBM simulator, are you referring to: <a href="https://sourceforge.net/projects/ibmtpm20tss/" target="_blank">https://sourceforge.net/projects/ibmtpm20tss/</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:0.5in">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.<u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:&quot;DejaVu Sans&quot;,sans-serif">[kgold] <u></u>
<u></u></span></p>
<p class="MsoNormal"><span style="font-family:&quot;DejaVu Sans&quot;,sans-serif">[kgold] I support the IBM SW TPM.  I test it on Windows and many Linux, with various OpenSS, gcc, mingw, Visual Studio.  If something doesn&#39;t work, file a bug report, email me, post here,
 but don&#39;t just give up.  It&#39;s widely used.<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>

</blockquote></div>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.