Skip to contentSkip to conversation

PCR pre-calculation

tpm2 Michael Walz 2 participants 4 messages Apr 28, 2020 – Apr 29, 2020

lore
Share & tools
lore

Michael Walz

author
#0 lore raw

Hi there,
I do not know if this is the right place for this question, so please point me in the right direction when I am wrong here.
We are trying to use the TPM2.0 in embedded devices. My job is to write a verification suite to test if our scripts and tools are working correctly. One point here is that I want to check if the resulting PCRs are as expected.
Microsoft provides a "TPM PCR Calculator" for this purpose. I would need something similar for linux command line and I googled a lot, but I did not find something useful. I tried openssl and commands like

echo -n '86454b08919afa1c912af74dc704b87bc08afe99' | xxd -r -p | openssl dgst -sha1 -mac hmac -macopt hexkey:0000000000000000000000000000000000000000

I tested several options and variations, but the results never match the PCR register I get with tpm2_pcrextend.
Is there some way to get a pre-calculation for the PCRs?

Thanks in advance!!
Michael

#1 lore raw

I've used this function in the past:

pcr_extend() {
( echo -n "$1" | xxd -r -p

    echo -n "$2" | xxd -r -p

) | sha1sum | cut -d " " -f 1
}

PCRVALUE="0000000000000000000000000000000000000000" PCRVALUE="$(pcr_extend "$PCRVALUE" "86454b08919afa1c912af74dc704b87bc08afe99")"

Cheers,
Andreas
________________________________________
From: Michael Walz [m.walz(a)digitalendoscopy.de]
Sent: Tuesday, April 28, 2020 12:58
To: tpm2(a)lists.01.org
Subject: [tpm2] PCR pre-calculation

Hi there,
I do not know if this is the right place for this question, so please point me in the right direction when I am wrong here.
We are trying to use the TPM2.0 in embedded devices. My job is to write a verification suite to test if our scripts and tools are working correctly. One point here is that I want to check if the resulting PCRs are as expected.
Microsoft provides a "TPM PCR Calculator" for this purpose. I would need something similar for linux command line and I googled a lot, but I did not find something useful. I tried openssl and commands like

echo -n '86454b08919afa1c912af74dc704b87bc08afe99' | xxd -r -p | openssl dgst -sha1 -mac hmac -macopt hexkey:0000000000000000000000000000000000000000

I tested several options and variations, but the results never match the PCR register I get with tpm2_pcrextend.
Is there some way to get a pre-calculation for the PCRs?

Thanks in advance!!
Michael
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

#2 lore raw

Yeah theirs no mac, it's just a straight hash of existing + new, which is exactly what Andrea's example is.

Quoted 53 lines

-----Original Message-----
From: Fuchs, Andreas [mailto:andreas.fuchs(a)sit.fraunhofer.de]
Sent: Tuesday, April 28, 2020 7:31 AM
To: Michael Walz <m.walz(a)digitalendoscopy.de>; tpm2(a)lists.01.org
Subject: [tpm2] Re: PCR pre-calculation

I've used this function in the past:

pcr_extend() {
( echo -n "$1" | xxd -r -p

    echo -n "$2" | xxd -r -p

) | sha1sum | cut -d " " -f 1
}

PCRVALUE="0000000000000000000000000000000000000000" PCRVALUE="$(pcr_extend "$PCRVALUE" "86454b08919afa1c912af74dc704b87bc08afe99")"

Cheers,
Andreas
________________________________________
From: Michael Walz [m.walz(a)digitalendoscopy.de]
Sent: Tuesday, April 28, 2020 12:58
To: tpm2(a)lists.01.org
Subject: [tpm2] PCR pre-calculation

Hi there,
I do not know if this is the right place for this question, so please point me in the right direction when I am wrong here.
We are trying to use the TPM2.0 in embedded devices. My job is to write a verification suite to test if our scripts and tools are working correctly. One point here is that I want to check if the resulting PCRs are as expected. Microsoft provides a "TPM PCR Calculator" for this purpose. I would need something similar for linux command line and I googled a lot, but I did not find something useful. I tried openssl and commands like

echo -n '86454b08919afa1c912af74dc704b87bc08afe99' | xxd -r -p | openssl dgst - sha1 -mac hmac -macopt hexkey:0000000000000000000000000000000000000000

I tested several options and variations, but the results never match the PCR register I get with tpm2_pcrextend.
Is there some way to get a pre-calculation for the PCRs?

Thanks in advance!!
Michael
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

author
#3 lore raw

That is perfect for me, got it.
Thanks a lot guys!

Quoted 56 lines · William C

Yeah theirs no mac, it's just a straight hash of existing + new, which is exactly what Andrea's example is.

Quoted 53 lines

-----Original Message-----
From: Fuchs, Andreas [mailto:andreas.fuchs(a)sit.fraunhofer.de]
Sent: Tuesday, April 28, 2020 7:31 AM
To: Michael Walz <m.walz(a)digitalendoscopy.de>; tpm2(a)lists.01.org
Subject: [tpm2] Re: PCR pre-calculation

I've used this function in the past:

pcr_extend() {
   ( echo -n "$1" | xxd -r -p
     echo -n "$2" | xxd -r -p
   ) | sha1sum | cut -d " " -f 1
}

PCRVALUE="0000000000000000000000000000000000000000" PCRVALUE="$(pcr_extend "$PCRVALUE" "86454b08919afa1c912af74dc704b87bc08afe99")"

Cheers,
Andreas
________________________________________
From: Michael Walz [m.walz(a)digitalendoscopy.de]
Sent: Tuesday, April 28, 2020 12:58
To: tpm2(a)lists.01.org
Subject: [tpm2] PCR pre-calculation

Hi there,
I do not know if this is the right place for this question, so please point me in the right direction when I am wrong here.
We are trying to use the TPM2.0 in embedded devices. My job is to write a verification suite to test if our scripts and tools are working correctly. One point here is that I want to check if the resulting PCRs are as expected. Microsoft provides a "TPM PCR Calculator" for this purpose. I would need something similar for linux command line and I googled a lot, but I did not find something useful. I tried openssl and commands like

echo -n '86454b08919afa1c912af74dc704b87bc08afe99' | xxd -r -p | openssl dgst - sha1 -mac hmac -macopt hexkey:0000000000000000000000000000000000000000

I tested several options and variations, but the results never match the PCR register I get with tpm2_pcrextend.
Is there some way to get a pre-calculation for the PCRs?

Thanks in advance!!
Michael
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s