Skip to contentSkip to conversation

swtpm tests question

tpm2 Stone 1 participant 4 messages Sep 18, 2019 – Sep 19, 2019

lore
Share & tools
lore

Stone

#0 lore raw

I am trying, unsuccessfully, to see how the TPM_CC_Hash value 0x0000017D gets sent to the swtpm. Additionally, the _test_hashing script is sending the string "1234" to the swtpm and then verifies a twenty byte return, which is 160 bits, against the hash code "97 e9 76 e4 f2 2c d6 d2 4a fd 21 20 85 ad 7a 86 64 7f 2a e5" which does not appear to correspond to to any hash that I separately calculate. Nor do I see where the hashing algorithm to be used is sent to the swtpm (eg 0x0004 for sha1 or 0x000b for sha2.

I was hoping to use the existing tests as templates for new tests such as testing TPM_CC_GetRandom. I can't do that if I cannot find where the TPM_CC_Hash is specified or where the hashing algorithm to use is specified.

The _test_hashing code is

run_swtpm_ioctl ${SWTPM_INTERFACE} -h 1234
if [ $? -ne 0 ]; then
echo "Error: Hash command did not work."
exit 1
fi

# Read PCR 17
Swtpm_open_cmddev ${SWTPM_INTERFACE} 100
RES=$(swtpm_cmd_tx ${SWTPM_INTERFACE} '\x00\xC1\x00\x00\x00\x0E\x00\x00\x00\x15\x00\x00\x00\x11') exp=' 00 c4 00 00 00 1e 00 00 00 00 97 e9 76 e4 f2 2c d6 d2 4a fd 21 20 85 ad 7a 86 64 7f 2a e5' if [ "$RES" != "$exp" ]; then
echo "Error: (1) Did not get expected result from TPM_PCRRead(17)"
echo "expected: $exp"
echo "received: $RES"
exit 1
fi

Any pointers will be appreciated. This is the first time I have attempted to use a tpm so the answer is probably something obvious that I am overlooking.

Thomas Stone, CISSP
Information Assurance Engineer Staff
Lockheed Martin Missiles and Fire Control
Phone (407) 356-6913
Cell (919) 812-0607
Email: thomas.g.stone(a)lmco.com<mailto:thomas.g.stone(a)lmco.com>

#1 lore raw

That's a different project, I would reach out to that development community.

Bill

Quoted 82 lines

-----Original Message-----
From: tpm2 [mailto:tpm2-bounces(a)lists.01.org] On Behalf Of Stone, Thomas G
Sent: Wednesday, September 18, 2019 9:35 AM
To: tpm2(a)lists.01.org
Subject: [tpm2] swtpm tests question

I am trying, unsuccessfully, to see how the TPM_CC_Hash value 0x0000017D gets
sent to the swtpm. Additionally, the _test_hashing script is sending the string
"1234" to the swtpm and then verifies a twenty byte return, which is 160 bits, against the hash code "97 e9 76 e4 f2 2c d6 d2 4a fd 21 20 85 ad 7a 86 64 7f 2a e5" which does not appear to correspond to to any hash that I separately calculate. Nor do I see where the hashing algorithm to be used is sent to the swtpm (eg 0x0004 for sha1 or 0x000b for sha2.

I was hoping to use the existing tests as templates for new tests such as testing TPM_CC_GetRandom. I can't do that if I cannot find where the TPM_CC_Hash is specified or where the hashing algorithm to use is specified.

The _test_hashing code is

run_swtpm_ioctl ${SWTPM_INTERFACE} -h 1234

if [ $? -ne 0 ]; then

echo "Error: Hash command did not work."

exit 1

fi

# Read PCR 17

Swtpm_open_cmddev ${SWTPM_INTERFACE} 100

RES=$(swtpm_cmd_tx ${SWTPM_INTERFACE} '\x00\xC1\x00\x00\x00\x0E\x00\x00\x00\x15\x00\x00\x00\x11')

exp=' 00 c4 00 00 00 1e 00 00 00 00 97 e9 76 e4 f2 2c d6 d2 4a fd 21 20 85 ad 7a 86 64 7f 2a e5'

if [ "$RES" != "$exp" ]; then

echo "Error: (1) Did not get expected result from TPM_PCRRead(17)"

echo "expected: $exp"

echo "received: $RES"

exit 1

fi

Any pointers will be appreciated. This is the first time I have attempted to use a tpm so the answer is probably something obvious that I am overlooking.

Thomas Stone, CISSP

Information Assurance Engineer Staff

Lockheed Martin Missiles and Fire Control

Phone (407) 356-6913

Cell (919) 812-0607

Email: thomas.g.stone(a)lmco.com <mailto:thomas.g.stone(a)lmco.com>

#2 lore raw

Hi Thomas,

Some additional data:
Stefan Berger maintains the swtpm here: https://github.com/stefanberger/swtpm. This question may be more related to libtpms (https://github.com/stefanberger/libtpms) than swtpm though. Microsoft maintains the TPM2 reference code here: https://github.com/microsoft/ms-tpm-20-ref.

NOTE: the reference code from MS is re-packaged by Stefan in libtpms.

I don't believe either of these projects have a dedicated mailing list but (as Bill points out below) I doubt that they monitor this one for questions.

Good luck,
Philip

-----Original Message-----
From: tpm2 [mailto:tpm2-bounces(a)lists.01.org] On Behalf Of Roberts, William C
Sent: 19 September, 2019 07:34
To: Stone, Thomas G <thomas.g.stone(a)lmco.com>; tpm2(a)lists.01.org
Subject: Re: [tpm2] swtpm tests question

That's a different project, I would reach out to that development community.

Bill

Quoted 73 lines

-----Original Message-----
From: tpm2 [mailto:tpm2-bounces(a)lists.01.org] On Behalf Of Stone, Thomas G
Sent: Wednesday, September 18, 2019 9:35 AM
To: tpm2(a)lists.01.org
Subject: [tpm2] swtpm tests question

I am trying, unsuccessfully, to see how the TPM_CC_Hash value 0x0000017D gets
sent to the swtpm. Additionally, the _test_hashing script is sending the string
"1234" to the swtpm and then verifies a twenty byte return, which is
160 bits, against the hash code "97 e9 76 e4 f2 2c d6 d2 4a fd 21 20 85 ad 7a 86 64 7f 2a e5" which does not appear to correspond to to any hash that I separately calculate. Nor do I see where the hashing algorithm to be used is sent to the
swtpm (eg
0x0004 for sha1 or 0x000b for sha2.

I was hoping to use the existing tests as templates for new tests such as testing TPM_CC_GetRandom. I can't do that if I cannot find where the TPM_CC_Hash is specified or where the hashing algorithm to use is specified.

The _test_hashing code is

run_swtpm_ioctl ${SWTPM_INTERFACE} -h 1234

if [ $? -ne 0 ]; then

echo "Error: Hash command did not work."

exit 1

fi

# Read PCR 17

Swtpm_open_cmddev ${SWTPM_INTERFACE} 100

RES=$(swtpm_cmd_tx ${SWTPM_INTERFACE} '\x00\xC1\x00\x00\x00\x0E\x00\x00\x00\x15\x00\x00\x00\x11')

exp=' 00 c4 00 00 00 1e 00 00 00 00 97 e9 76 e4 f2 2c d6 d2 4a fd 21 20 85 ad 7a 86 64 7f 2a e5'

if [ "$RES" != "$exp" ]; then

echo "Error: (1) Did not get expected result from TPM_PCRRead(17)"

echo "expected: $exp"

echo "received: $RES"

exit 1

fi

Any pointers will be appreciated. This is the first time I have
attempted to use a tpm so the answer is probably something obvious that I am overlooking.

Thomas Stone, CISSP

Information Assurance Engineer Staff

Quoted 11 lines

Lockheed Martin Missiles and Fire Control

Phone (407) 356-6913

Cell (919) 812-0607

Email: thomas.g.stone(a)lmco.com <mailto:thomas.g.stone(a)lmco.com>

_______________________________________________
tpm2 mailing list
tpm2(a)lists.01.org
https://lists.01.org/mailman/listinfo/tpm2

#3 lore raw
Quoted 9 lines

-----Original Message-----
From: Tricca, Philip B
Sent: Thursday, September 19, 2019 8:47 AM
To: Stone, Thomas G <thomas.g.stone(a)lmco.com>; tpm2(a)lists.01.org
Cc: Roberts, William C <william.c.roberts(a)intel.com>
Subject: RE: swtpm tests question

Quoted 6 lines

Hi Thomas,

Some additional data:
Stefan Berger maintains the swtpm here:
https://github.com/stefanberger/swtpm. This question may be more related to libtpms (https://github.com/stefanberger/libtpms) than swtpm though.

I wasn't 100% sure if that was upstream for that, good to know. AFAICT, they have no mailing list but they are active on issues. So perhaps file a github issue on that project.

Quoted 114 lines

Microsoft maintains the TPM2 reference code here:
https://github.com/microsoft/ms-tpm-20-ref.

NOTE: the reference code from MS is re-packaged by Stefan in libtpms.

I don't believe either of these projects have a dedicated mailing list but (as Bill points out below) I doubt that they monitor this one for questions.

Good luck,
Philip

-----Original Message-----
From: tpm2 [mailto:tpm2-bounces(a)lists.01.org] On Behalf Of Roberts, William C
Sent: 19 September, 2019 07:34
To: Stone, Thomas G <thomas.g.stone(a)lmco.com>; tpm2(a)lists.01.org
Subject: Re: [tpm2] swtpm tests question

That's a different project, I would reach out to that development community.

Bill

Quoted 8 lines

-----Original Message-----
From: tpm2 [mailto:tpm2-bounces(a)lists.01.org] On Behalf Of Stone, Thomas G
Sent: Wednesday, September 18, 2019 9:35 AM
To: tpm2(a)lists.01.org
Subject: [tpm2] swtpm tests question

I am trying, unsuccessfully, to see how the TPM_CC_Hash value 0x0000017D

gets

Quoted 3 lines

sent to the swtpm. Additionally, the _test_hashing script is sending the string
"1234" to the swtpm and then verifies a twenty byte return, which is 160 bits, against the hash code "97 e9 76 e4 f2 2c d6 d2 4a fd 21 20 85 ad 7a 86 64

7f 2a e5"

Quoted 10 lines

which does not appear to correspond to to any hash that I separately calculate. Nor do I see where the hashing algorithm to be used is sent to the swtpm (eg
0x0004 for sha1 or 0x000b for sha2.

I was hoping to use the existing tests as templates for new tests such as testing TPM_CC_GetRandom. I can't do that if I cannot find where the TPM_CC_Hash is specified or where the hashing algorithm to use is

specified.

Quoted 37 lines

The _test_hashing code is

run_swtpm_ioctl ${SWTPM_INTERFACE} -h 1234

if [ $? -ne 0 ]; then

echo "Error: Hash command did not work."

exit 1

fi

# Read PCR 17

Swtpm_open_cmddev ${SWTPM_INTERFACE} 100

RES=$(swtpm_cmd_tx ${SWTPM_INTERFACE} '\x00\xC1\x00\x00\x00\x0E\x00\x00\x00\x15\x00\x00\x00\x11')

exp=' 00 c4 00 00 00 1e 00 00 00 00 97 e9 76 e4 f2 2c d6 d2 4a fd 21 20 85 ad 7a 86 64 7f 2a e5'

if [ "$RES" != "$exp" ]; then

echo "Error: (1) Did not get expected result from TPM_PCRRead(17)"

echo "expected: $exp"

echo "received: $RES"

Quoted 8 lines

exit 1

fi

Any pointers will be appreciated. This is the first time I have attempted to use a tpm so the answer is probably something obvious that I am

overlooking.

Quoted 7 lines

Thomas Stone, CISSP

Information Assurance Engineer Staff

Quoted 11 lines

Lockheed Martin Missiles and Fire Control

Phone (407) 356-6913

Cell (919) 812-0607

Email: thomas.g.stone(a)lmco.com <mailto:thomas.g.stone(a)lmco.com>

_______________________________________________
tpm2 mailing list
tpm2(a)lists.01.org
https://lists.01.org/mailman/listinfo/tpm2