Access ftpm pcr registers

Hello Team,
We wanted to write the ftpm’s PCR registers, requirement is to have disk encryption during the runtime instead of having it during flashing time or build time. How to save hashes persistently in ftpm?

We are trying to implement our own disk encryption for Jetson Orin Nano using cryptsetup with ftpm using this scripts in initramfs.

https://gitlab.com/cip-project/cip-core/isar-cip-core/-/blob/master/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete
https://gitlab.com/cip-project/cip-core/isar-cip-core/-/blob/master/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.systemd.script

During the first boot we are able to enroll the keys and see the system is encrypted, as below, But for further successive boot, we are noticing that the ftpm PCR:7:sha256 keys were not updated or reset from UEFI when we reboot the device. Note that we are not using optee related utilities for writing the keys.

root@orin-nano:~# lsblk
NAME                                     MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
loop0                                      7:0    0    16M  1 loop
mmcblk0                                  179:0    0  59.5G  0 disk
├─mmcblk0p1                              179:1    0   512M  0 part  /boot
├─mmcblk0p2                              179:2    0     4G  0 part
│ └─fedcba98-7654-3210-cafe-5e0710000001 253:0    0     4G  0 crypt /
├─mmcblk0p3                              179:3    0   512M  0 part
├─mmcblk0p4                              179:4    0     1G  0 part
├─mmcblk0p5                              179:5    0     1G  0 part  /config
└─mmcblk0p6                              179:6    0  52.5G  0 part  /data
zram0                                    252:0    0 635.1M  0 disk  [SWAP]
zram1                                    252:1    0 635.1M  0 disk  [SWAP]
zram2                                    252:2    0 635.1M  0 disk  [SWAP]
zram3                                    252:3    0 635.1M  0 disk  [SWAP]
zram4                                    252:4    0 635.1M  0 disk  [SWAP]
zram5                                    252:5    0 635.1M  0 disk  [SWAP]
root@orin-nano:~# blkid
/dev/mmcblk0p5: LABEL="config" UUID="fa6ce894-6cad-427d-bab2-febf98ea74b6" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="config" PARTUUID="75370038-84d1-4222-ae7f-6797d7463555"
/dev/mmcblk0p1: LABEL_FATBOOT="efi" LABEL="efi" UUID="C6EB-FC22" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="efi" PARTUUID="b6d2cdb8-e497-4a3a-a2f5-8c45d2a9a872"
/dev/mmcblk0p6: LABEL="data" UUID="4865e64d-3bb1-45e0-9068-42e105223d5f" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="data" PARTUUID="0baf7e65-4dc3-4fe8-9c47-fb64c599dec4"
/dev/mmcblk0p4: LABEL="config" UUID="92306f2a-6c45-4f66-bd88-bcfcc59ed3a1" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="systemb" PARTUUID="fedcba98-7654-3210-cafe-5e0710000002"
/dev/mmcblk0p2: UUID="51287939-ea90-46ed-9a33-7b96dbab9ed3" TYPE="crypto_LUKS" PARTLABEL="systema" PARTUUID="fedcba98-7654-3210-cafe-5e0710000001"
/dev/mapper/fedcba98-7654-3210-cafe-5e0710000001: LABEL="systema" UUID="bde4f047-0fe7-42c7-a6af-6ed7f51e1e16" BLOCK_SIZE="4096" TYPE="ext4"
/dev/zram5: UUID="4a634188-6cca-4732-a6b7-7cd490bf6f25" TYPE="swap"
/dev/zram3: UUID="c59c9db9-17af-4f4a-a285-1af3598de6d1" TYPE="swap"
/dev/mmcblk0p3: PARTLABEL="efi" PARTUUID="d2601b2d-89f7-4b44-9e4d-5900b418c67e"
/dev/zram1: UUID="15d41412-d092-4685-8316-c440f9131db8" TYPE="swap"
/dev/loop0: SEC_TYPE="msdos" LABEL_FATBOOT="L4T-README" LABEL="L4T-README" UUID="1234-ABCD" BLOCK_SIZE="512" TYPE="vfat"
/dev/zram4: UUID="34932517-0bf4-4f1e-8ed2-10675fb05f8f" TYPE="swap"
/dev/zram2: UUID="dd70b4a8-0cc2-4447-ae68-cd9cbedcf2b9" TYPE="swap"
/dev/zram0: UUID="bc45f4ed-32a6-426f-b2e9-102871ad0908" TYPE="swap"
root@orin-nano:~#

Kindly help us here, how do we proceed further with the disk encryptions?

hello arulpandiyan.vadivel,

here’re commands check PCR,
it’s also an example to confirm whether measured boot is active.
for instance,
$ sudo modprobe tpm_ftpm_tee
$ sudo tpm2_pcrread

Thanks for the response, tpm_pcrread does help to show the the PCR Register values,

When we write and read back after reboot it was not updated as expected, Seems like it is getting updated from BootLoader(UEFI) itself upon reboot?

Kindly refer the below logs

root@orin-nano:~# cat /proc/uptime
322773.70 1933899.56
root@orin-nano:~#
root@orin-nano:~# tpm2_pcrread sha256:7
  sha256:
    7 : 0x65CAF8DD1E0EA7A6347B635D2B379C93B9A1351EDC2AFC3ECDA700E534EB3068
root@orin-nano:~# tpm2_pcrextend 7:sha256=b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944cread
root@orin-nano:~# tpm2_pcrread sha256:7
  sha256:
    7 : 0x272217BBFC9DD898B421D99A968D223AAF30755E13B18872C97BD54602FDAC49
root@orin-nano:~#

After Reboot


root@orin-nano:~#  tpm2_pcrread sha256:7
  sha256:
    7 : 0x65CAF8DD1E0EA7A6347B635D2B379C93B9A1351EDC2AFC3ECDA700E534EB3068
root@orin-nano:~#
root@orin-nano:~# cat /proc/uptime
218.36 1264.94
root@orin-nano:~#

hello arulpandiyan.vadivel,

are you trying to update the hash value?
you may see-also Measured Boot | Intel® Trust Authority for reference, btw.

Yes, we wanted to update the hash values,

@JerryChang This is the blocker for our perusals, Kindly help to prioritize to have the solutions

hello arulpandiyan.vadivel,

please refer to The fTPM Boot Flow and fTPM Measured Boot.
The fTPM boot flow is a process that verifies and measures the integrity of firmware components during the boot process.
it’s hash value to verify the authenticity and consistency of various components within the boot chain.

I have tried enabling the IMA but it was not using ftpm, Even I have enabled the TCG_FTPM_TEE as a static modules, (Note that IMA cannot be configured as loadable modules) Kindly refer the below logs

root@orin-nano:~# zcat /proc/config.gz |grep -i FTPM
CONFIG_TCG_FTPM_TEE=y
root@orin-nano:~# dmesg |grep -i ima
[    0.000000] Kernel command line: initrd=\initrd.img-5.15.148-1 LABEL=Boot root=PARTUUID=fedcba98-7654-3210-cafe-5e0710000001   nvidia-drm.fbdev=1 rootwait rw firmware_cl
ass.path=/etc/firmware fbcon=map:0 nv-auto-config video=efifb:off  ima_tcb ima_appraise=fix ima_appraise_tcb rootflags=i_version  debug log_buf_len=4M
[    0.266636] device-mapper: core: CONFIG_IMA_DISABLE_HTABLE is disabled. Duplicate IMA measurements will not be recorded in the IMA log.
[    1.666929] ima: No TPM chip found, activating TPM-bypass!
[    1.666963] ima: Allocated hash algorithm: sha256
[    1.667083] ima: No architecture policies found
[    4.720359] systemd[1]: No IMA custom policy file /etc/ima/ima-policy, ignoring: No such file or directory
[    4.807368] systemd[1]: systemd 254.22-1~bpo12+1 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +
ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVI
NIT default-hierarchy=unified)
[   10.320380] systemd[1]: systemd-pcrphase.service: ConditionPathExists=/sys/firmware/efi/efivars/StubPcrKernelImage-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f failed.
root@orin-nano:~#
root@orin-nano:~# ls -la /dev/tpm*
crw-rw---- 1 tss root  10,   224 Mar  4  2024 /dev/tpm0
crw-rw---- 1 tss tss  252, 65536 Mar  4  2024 /dev/tpmrm0
root@orin-nano:~#

Is there any utility available from nvidia to update/extend the ftpm pcr registers permanently (not reset from UEFI).

according to the documentation, you’ll need to update the firmware components (such as mb1, mb2, TOS..etc) for changing hash values.

1 Like

Can you please point me to the documentation how i can update the firmware components?

I have added below configurations for enabling IMA in the kernel 5.15.148 (JP 6.2)

CONFIG_IMA=m
CONFIG_HAVE_IMA_KEXEC=y
CONFIG_IMA_MEASURE_PCR_IDX=10
CONFIG_IMA_LSM_RULES=y
CONFIG_IMA_NG_TEMPLATE=y
CONFIG_IMA_DEFAULT_TEMPLATE="ima-ng"
CONFIG_IMA_DEFAULT_HASH_SHA256=y
CONFIG_IMA_DEFAULT_HASH="sha256"
CONFIG_IMA_APPRAISE=y
CONFIG_IMA_APPRAISE_BOOTPARAM=y
CONFIG_TCG_CRB=y
CONFIG_TCG_FTPM_TEE=y

hello arulpandiyan.vadivel,

please refer to developer guide, Flashing Support.
BTW, may I double check what’s the Jetson security you’ve enabled? for instance, did you fuse a target to burn PKC/SBK..etc?

No, We did not have fused the target with PKC and SBK keys

Do you mean to say, PCR hashes will get updated only when flashing MB1/MB2/TOS, It cannot be modified persistently on our own, as the scope of the PCRs are limited to only firmwares as per this boot flow

you may Flashing a Specific Partition to flash a specific partition instead of flashing the whole device by using the command line option -k.

Question for this ticket to update the PCR registers persistently on fTPM

please update the firmware components (such as mb1, mb2, TOS..etc).
since you’re not fusing a target, you may flash a specific partition instead of flashing the whole device.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

@JerryChang
What would be the recommended way to store credential (private keys, certificates etc.) in a secure manner (ARM Trust Zone?) on the Jetson Orin Nano module? Are there tutorials / best practices available from Nvidia side how to do that? Where can we get a general overview about them? Are there any limitations on that for using it together with Ubuntu or should this way work with Debian as well?

As discussed over call with @DanieleTafani below it seems that we are not able to bring your recommended way of storing in the PCR registers to our Debian base for example:

As discussed over weekly meeting, I am adding more details for accessing fTPM’s PCR registers persistently.

We wanted to utilize the ftpm’s PCR registers to be precisely PCR7 for disk encryption support during the runtime.

We are trying to implement our own disk encryption for Jetson Orin Nano using cryptsetup with fTPM’s PCR7 using the scripts from initramfs.

https://gitlab.com/cip-project/cip-core/isar-cip-core/-/blob/master/recipes-initramfs/initramfs-crypt-hook/files/local-top-complete
https://gitlab.com/cip-project/cip-core/isar-cip-core/-/blob/master/recipes-initramfs/initramfs-crypt-hook/files/encrypt_partition.systemd.script

During the first boot we are able to enroll the keys and see the system is encrypted, as below, but for further successive boot, we are noticing that the ftpm PCR:7:sha256 keys were not updated or reset from UEFI when we reboot the device.

Kindly refer the below logs

root*@orin*-nano:~# cat /proc/uptime
322773.70 1933899.56
root*@orin*-nano:~#
root*@orin*-nano:~# tpm2_pcrread sha256:7
sha256:
7 : 0x65CAF8DD1E0EA7A6347B635D2B379C93B9A1351EDC2AFC3ECDA700E534EB3068
root*@orin*-nano:~# tpm2_pcrextend 7:sha256=b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944cread
root*@orin*-nano:~# tpm2_pcrread sha256:7
sha256:
7 : 0x272217BBFC9DD898B421D99A968D223AAF30755E13B18872C97BD54602FDAC49
root*@orin*-nano:~#

After Reboot

root*@orin*-nano:~# tpm2_pcrread sha256:7
sha256:
7 : 0x65CAF8DD1E0EA7A6347B635D2B379C93B9A1351EDC2AFC3ECDA700E534EB3068
root*@orin*-nano:~#

root*@orin*-nano:~# cat /proc/uptime
218.36 1264.94
root*@orin*-nano:~#