How to initialize a used TPM2 module and thoughts on clevis
tpm2 at bitzap.e4ward.com
Hello -
New to TPM2 here. I'm adding a *used* TPM2 module to a mobo that has a header. What are best practices to initialize the TPM2 module? Should I clear it first, possibly via the BIOS? Should I set an owner password?
So far I found echo 5 > /sys/class/tpm/tpm0/ppi/request which is probably a good idea to do as I don't know where the module comes from and whether anyone has messed with it before.
I'd appreciate any pointers in the right direction and the correct commands to start with a clean TPM2. Running Ubuntu 20.04 and I installed tpm2-tools.
Also, is clevis encrypt tpm2 a good wrapper if I just want to a simple way to encrypt/decrypt a file on disk that holds other credentials?
Thank you!
Roberts
Quoted 5 lines · On Mon, 2022-07-11 at 06:23 +0000, tpm2(a)bitzap.e4ward.com wrote:
Hello -
New to TPM2 here. I'm adding a *used* TPM2 module to a mobo that has a header. What are best practices to initialize the TPM2 module? Should I clear it first, possibly via the BIOS?
Yes
Quoted 1 line
Should I set an owner password?
and YES. This is required to keep someone from wiping all the keys in the owner hierarchy which would include your disk encryption keys. You also want to set the lockoutauth as well.
Quoted 8 lines
So far I found
echo 5 > /sys/class/tpm/tpm0/ppi/requestwhich is probably a good idea to do as I don't know where the module comes from and whether anyone has messed with it before.I'd appreciate any pointers in the right direction and the correct commands to start with a clean TPM2. Running Ubuntu 20.04 and I installed tpm2-tools.
I think I'd clear it using the BIOS and usetpm2_changeauth -C o <newownerpass>tpm2_changeauth -C l <newlockoutpass>
You'd probably also want to create the "Storage Root Key" or SRK which is a key at certain fixed address without a password so you can put subordinate keys under:
# Specify -G ecc for an ecc key over RSA, but it really doesn't matter. tpm2_createprimary -c primary.ctxtpm2_evictcontrol -c primary.ctx 0x81000001
to initialize the TPM.
The address 0x81000001 comes from a guidance document on how to provision the TPM:
-
https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-v2.0-Provisioning-Guidance-Published-v1r1.pdf
Quoted 4 lines
Also, is
clevis encrypt tpm2a good wrapper if I just want to a simple way to encrypt/decrypt a file on disk that holds other credentials?
Yeah clevis works great for those purposes. However, I don't know how clevis manages it's keys so you may need to do something else, but as far as I know its a simple way to use TPM2.
Quoted 6 lines
Thank you!
_______________________________________________
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
Roberts
Quoted 20 lines · William C
Quoted 6 lines · On Mon, 2022-07-11 at 06:23 +0000, tpm2(a)bitzap.e4ward.com wrote:
Hello -
New to TPM2 here. I'm adding a *used* TPM2 module to a mobo that has
a header. What are best practices to initialize the TPM2 module? Should I clear it first, possibly via the BIOS?Yes
Quoted 1 line
Should I set an owner password?
and YES. This is required to keep someone from wiping all the keys in the owner hierarchy which would include your disk encryption keys. You also want to set the lockoutauth as well.
Quoted 4 lines
So far I found
echo 5 > /sys/class/tpm/tpm0/ppi/requestwhich is probably a good idea to do as I don't know where the module comes from and whether anyone has messed with it before.
Quoted 7 lines
Quoted 3 lines
I'd appreciate any pointers in the right direction and the correct commands to start with a clean TPM2. Running Ubuntu 20.04 and I installed tpm2-tools.
I think I'd clear it using the BIOS and use
tpm2_changeauth-C o <newownerpass>tpm2_changeauth-C l <newlockoutpass>
Oh don't forget about the endorsement hiearchy:tpm2_changeauth -c e <newendorsepass>
Also I accidentally put uppercase -C options for tpm2_changeauth when it is lowercase -c, sorry :-p
Quoted 37 lines
You'd probably also want to create the "Storage Root Key" or SRK which
is a key at certain fixed address without a password so you can put subordinate keys under:# Specify -G ecc for an ecc key over RSA, but it really doesn't matter.
tpm2_createprimary-c primary.ctxtpm2_evictcontrol-c primary.ctx0x81000001to initialize the TPM.
The address
0x81000001comes from a guidance document on how to provision the TPM:
-
https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-v2.0-Provisioning-Guidance-Published-v1r1.pdfQuoted 3 lines
Also, is
clevis encrypt tpm2a good wrapper if I just want to a simple way to encrypt/decrypt a file on disk that holds other credentials?Yeah clevis works great for those purposes. However, I don't know how clevis manages it's keys so you may need to do something else, but as far as I know its a simple way to use TPM2.
Quoted 5 lines
Thank you!
_______________________________________________
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
Tim K
Very useful, thank you!
Quoted 3 lines
and YES. This is required to keep someone from wiping all the keys in the owner hierarchy which would include your disk encryption keys. You also want to set the lockoutauth as well.
It appears clevis uses the owner hierarchy by default. If I set an owner password, what are the implications, does clevis need to know the owner password when it creates its own key and then encrypts/decrypts its own key?
This is how I'm trying to use it to encrypt a single file on disk (not the entire disk/LUKS):
https://manpages.ubuntu.com/manpages/focal/man1/clevis-encrypt-tpm2.1.html
Roberts
+ Javier
Quoted 7 lines · Tim K
Very useful, thank you!
Quoted 4 lines
and YES. This is required to keep someone from wiping all the keys in
the owner hierarchy which would include your disk encryption keys. You also want to set the lockoutauth as well.
Quoted 8 lines
It appears clevis uses the owner hierarchy by default. If I set an owner password, what are the implications, does clevis need to know the owner password when it creates its own key and then encrypts/decrypts its own key?
This is how I'm trying to use it to encrypt a single file on disk (not the entire disk/LUKS):
https://manpages.ubuntu.com/manpages/focal/man1/clevis-encrypt-tpm2.1.html
Looking at the source[1,2], it appears they call tpm2_createprimary on encrypt which would require owner auth, call tpm2_create save the key and then on decrypt call tpm2_createprimary which requires owner auth and then call tpm2_load to load the key under that primary object.
I don't see an option to use the SRK, this looks like an oversight or I am missing something. Javier, do you know?
[1]
https://github.com/latchset/clevis/blob/master/src/pins/tpm2/clevis-encrypt-tpm2
[2]
https://github.com/latchset/clevis/blob/master/src/pins/tpm2/clevis-decrypt-tpm2
Quoted 4 lines
_______________________________________________
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
Tim K
My goal is to automate a cron job that requires credentials by keeping the credentials in a file that is encrypted using TPM2 via clevis. I am fully aware this does not add much protection if someone gets access to the OS, it is just so credentials do not sit in plain text in a file on disk, just protected by file permissions and it somewhat protects me from accidentally sync'ing the file to cloud or to some other backup (the file would at least be encrypted).
In order to do this, I don't think I can password protect the TPM2 hierarchies, otherwise there would be no way to automate it, I'd have to put the TPM2 passwords in the script for clevis to use (assuming clevis adds the option or that I just call the tpm2_* commands myself).
Any other suggestions how to make this better? My original idea was to use systemd-creds but it is not available in systemd v249 that Ubuntu 22.04 LTS ships with.
Roberts
Quoted 8 lines · William C
Quoted 6 lines · On Mon, 2022-07-11 at 06:23 +0000, tpm2(a)bitzap.e4ward.com wrote:
Hello -
New to TPM2 here. I'm adding a *used* TPM2 module to a mobo that has
a header. What are best practices to initialize the TPM2 module? Should I clear it first, possibly via the BIOS?
Quoted 7 lines
Yes
Quoted 1 line
Should I set an owner password?
and YES. This is required to keep someone from wiping all the keys in the owner hierarchy which would include your disk encryption keys. You also want to set the lockoutauth as well.
FYI at KGoldman pointed out that tpm2_clear is not protected by owener auth but rather platform or lockout auth. Also, FYI, tpm2_clearcontrol during boot will disable tpm2_clear command all together.
Quoted 5 lines
Quoted 5 lines
So far I found
echo 5 > /sys/class/tpm/tpm0/ppi/requestwhich is probably a good idea to do as I don't know where the module comes from and whether anyone has messed with it before.
Quoted 7 lines
Quoted 3 lines
I'd appreciate any pointers in the right direction and the correct commands to start with a clean TPM2. Running Ubuntu 20.04 and I installed tpm2-tools.
I think I'd clear it using the BIOS and use
tpm2_changeauth-C o <newownerpass>tpm2_changeauth-C l <newlockoutpass>
This sets out lockout auth, your OS/FW during boot set platform auth.
Quoted 37 lines
You'd probably also want to create the "Storage Root Key" or SRK which
is a key at certain fixed address without a password so you can put subordinate keys under:# Specify -G ecc for an ecc key over RSA, but it really doesn't matter.
tpm2_createprimary-c primary.ctxtpm2_evictcontrol-c primary.ctx0x81000001to initialize the TPM.
The address
0x81000001comes from a guidance document on how to provision the TPM:
-
https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-v2.0-Provisioning-Guidance-Published-v1r1.pdfQuoted 3 lines
Also, is
clevis encrypt tpm2a good wrapper if I just want to a simple way to encrypt/decrypt a file on disk that holds other credentials?Yeah clevis works great for those purposes. However, I don't know how clevis manages it's keys so you may need to do something else, but as far as I know its a simple way to use TPM2.
Quoted 5 lines
Thank you!
_______________________________________________
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