GithubHelp home page GithubHelp logo

elkozmon / tpm_futurepcr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grawity/tpm_futurepcr

0.0 0.0 0.0 1.19 MB

Calculate future (next boot) TPM PCRs after a kernel upgrade

License: MIT License

Python 100.00%

tpm_futurepcr's Introduction

The tpm_futurepcr script allows pre-calculating what the future PCR4 value will be after a kernel upgrade, before you reboot. This is useful when your rootfs is LUKS-encrypted with a key sealed by the TPM against PCR4 (among others).

This script only recognizes measurements done by native UEFI LoadImage() โ€“ i.e. hashes of PE/COFF executables such as vmlinuz.efi. (Although it does parse the TPM 1.2 event log, it does not (yet) recognize measurements done by TrustedGRUB on BIOS systems, and in fact I'm not entirely sure whether the entire premise of sealing data against user-specified PCR values is even possible in the TPM 1.2 API.)

As an additional hack, this script also recognizes systemd-boot and updates its EV_IPL event according to the future kernel command line.

This script will understand the event log in both SHA1-only (TPM 1.2) and Crypto-Agile (TPM 2.0, Linux kernel 5.3+) formats.

Warning

Until Linux 5.17, neither systemd-boot nor EFISTUB measure the loaded initrd images, making it unsafe to rely on PCR4 alone. (Starting with Linux 5.17, the initrd measurements are now stored in PCR9; this script does not yet support pre-calculating it.) Additionally, only systemd-boot measures the command line into PCR8; EFISTUB on its own does not.

It is recommended to use PCR-based sealing (whether it is PCR4 with tpm_futurepcr or PCR7 with Secure Boot) only with a combined systemd-stub "kernel + initramfs" image, such as the one produced by mkinitcpio -U.

Dependencies

  • python-signify (for calculating Authenticode digests)
  • tpm2-tools (for reading current PCR values in kernels older than v5.12)

Installation

python setup.py install

Usage

Normally sealing data against PCRs starts by creating a "policy" which specifies the PCR values. In the Intel TPM 2.0 stack, this is done with tpm2_createpolicy:

tpm2_createpolicy --policy-pcr --pcr-list=sha256:0,2,4,7 --policy=policy.bin

This automatically uses current PCR values, and can be written to do so explicitly:

tpm2_pcrread sha256:0,2,4,7 -Q -o pcrvalues.bin
tpm2_createpolicy --policy-pcr --pcr-list=sha256:0,2,4,7 --pcr=pcrvalues.bin --policy=policy.bin

To do the same with future PCR values, use tpm_futurepcr:

tpm_futurepcr -L 0,2,4,7 -o pcrvalues.bin
tpm2_createpolicy --policy-pcr --pcr-list=sha256:0,2,4,7 --pcr=pcrvalues.bin --policy=policy.bin

tpm_futurepcr's People

Contributors

grawity avatar electrickite avatar squarooticus avatar foxboron avatar yangzhaofeng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.