Giter Site home page Giter Site logo

andrewnicolalde / tpm2keyunlock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anedward01/tpm2keyunlock

0.0 1.0 0.0 84 KB

Adds an automated unlock function based on TPM policy installation

License: GNU General Public License v3.0

Shell 90.74% Python 9.26%

tpm2keyunlock's Introduction

tpm2KeyUnlock

Adds automatic decryption function based on TPM policy configuration

Main Source: https://threat.tevora.com/secure-boot-tpm-2/

Using the scripts

setup automatically pulls out the LUKS and EFI boot partition using blkid and grep. The only input it requires is a cryptsetup password and a simple yes. The script supports flags as follows:

  • -b: Manually sets the boot partition by UUID
  • -l: Manually sets the LUKS partition by UUID
  • -p: Provides the cryptsetup password for automation
  • -r: Manually sets the root partition under /dev/mapper/
  • -y Gives the script a clear go-ahead for signed kernel creation

Once it finishes the first round, it will try to set up a GRUB menu entry. If the system does not use GRUB, it will continue running after giving a notice. Next, a systemd file will be added and enabled to run at boot. The setup2 file will be enabled with execution rights as root and will run the TPM policy commands. The service will then disable itself after finishing setting up /etc/crypttab and /usr/local/bin/passphrase-from-tpm with the appropriate PCR hash method and persistent handle.

Detailed walkthrough

The setup of TPM unlocking involves three phases. The first phase installs the TPM tools. The second sets up a TPM-signed kernel and TPM key. The final step verifies the TPM key is working and finishes setting up the TPM kernel.

General requirements

  • A secure-boot enabled system with a custom key authentication setting in BIOS.
  • EFI System Partition (ESP) access for installing custom kernels.
  • General understanding of bash commands.
  • Patience. Quite a bit of it Not so much patience required anymore, just time.

Using cloud-init to automate deployment and installation

I created an overview over at https://www.edwardssite.com/cloud-init outlining the details of how to automate the deployment and installation process of this project using cloud-init and Ubuntu's autoinstall settings. Pretty much everything needed is explained there, and reference files are included.

Post quarantine update

Earlier in the year I received a request to continue developing the project. A lot of progress towards security and automation has been made. The project and its development has been allowed to keep its open source license, so I will leave the project up! As far as development goes, here are the major points:

  • Symbolic linking and regular expressions allow the script to pull up LUKS and boot partitions without interference. A signed TPM kernel is compiled using the latest kernel. Editing to /etc/crypttab and passphrase-from-tpm are also included.
  • SHA 256 is now supported. The script will check for SHA 256 PCR 0. If it doesn't exist or it's value is empty, it will default back to SHA 1. TPM spec 1.x and SHA 256 banks must be enabled to ensure compatibility.
  • A GRUB menu entry is now thrown in. In case you don't use GRUB, it won't force you to have it. It will also set the signed TPM kernel as the default boot option on startup.
  • Initramfs in the signed kernel now requires the root device. This wasn't an issue before, but a fix was found.
  • A systemd service file to pick up after reboot. As soon as the TPM signed kernel is unlocked, in about three minutes the TPM will have the secret key secured and the service will disable itself. Double-checking journalctl is recommended, of course.
  • Boot parameters are now included. If there are multiple LUKS drives, specify -l [UUID] to set the luks drive. A cryptsetup password is needed to add the secret into LUKS, so -p [pass] along with -y allows for automated configurations. Only the first setup script takes and needs parameters.
  • The default PCR banks have been set to 0, 2, 3, 7, 8. This supports both secure boot and non-secure boot devices. Testing has been run on a secure boot laptop and a non-secure boot device and both have worked consistently. Of course, not all devices are the same, so if there are any problems please open an issue.

There is a lot more coming soon. There is definitely a lot of improvement that can be made, and I am looking forward to it. I am glad you read this far, and thank you for your time!

tpm2keyunlock's People

Contributors

anedward01 avatar sidusnare avatar

Watchers

James Cloos 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.