Git Product home page Git Product logo

tcg-boot's Introduction

TCG Boot

This is an EFI application to secure loading Linux with TPM. The project not yet ready for end-users.

How it works?

  1. The system firmware will measure TCG Loader.
  2. The TCG Loader will measure it's all configurations.
  3. The TCG Loader will check Linux's signature and all related files.
  4. If signature passed TCG Loader will execute Linux.

Then Linux need to unseal the secret keys and do something with it after this to establish trusted boot. If the unseal operation is failed that mean the boot processes cannot be trusted anymore.

With this way the Linux and it related files are freely to update without breaking TPM's measurement.

Build from source

Prerequisites

  • Rust on the latest stable channel

Add Rust target

rustup target add TARGET

Replace TARGET with your target machine (e.g. x86_64-unknown-uefi). Use rustup target list to see the available targets.

Build

cargo install --target TARGET --path . --root .

It will output bin/tcg-boot.efi. You can copy this binary to your EFI system partition and boot from it.

Development

The following guide only work on x86-64 machine. First, install the following tools:

  • GNU Parted
  • Mtools
  • OVMF
  • QEMU

Create a Linux VM

Prepare an installation media for any distros you like. The only requirements is it must supports UEFI.

Disable Copy-on-write on BTRFS

If you are using BTRFS and Copy-on-write is enabled you should disable it on vm directory with the following command:

chattr +C vm

Create a disk image

dd if=/dev/zero of=vm/disk1.img count=SECTORS status=progress

Replaces SECTORS with the number you want. 1 sector is equals to 512 bytes. The size of the image depend on your distro.

Install distro

Copy OVMF_VARS.fd from your current system to vm/bios. Then start an installation with the following command:

TCGBOOT_OVMF_CODE=PATH_TO_OVMF_CODE ./start-vm.sh -cdrom MEDIA

Replaces PATH_TO_OVMF_CODE with a full path of OVMF_CODE.fd and MEDIA with a full path of the installation media. Things to be careful durring installation:

  • The kernel and its initial ramdisk must be installed to EFI system partition.
  • The current utility scripts does not supports more than one fat32 partitions so don't create multiple of it.
  • You don't need to install boot loader.

Before shutdown the VM:

  • Create an empty directory EFI/boot in the EFI system partition.
  • Note the kernel file name and its initial ramdisk.
  • Note the required information for constructing a kernel command line.

Install TCG Loader into VM

Prepare a configuration that matched with the VM by duplicating src/default.conf to vm/tcg.conf and edit it. Please note that root of the path in the config refer to the root of EFI system partition. Then run the following command:

./build-vm.sh

Now you can start the VM to test TCG Loader:

TCGBOOT_OVMF_CODE=PATH_TO_OVMF_CODE ./start-vm.sh

You may need to change bios settings in order to boot TCG Loader. You can append -nographic ptions to start-vm.sh to output the QEMU console directly to your terminal. To exit the QEMU, press Ctrl + A then X.

tcg-boot's People

Contributors

ultimaweapon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tcg-boot's Issues

How to find PATH_TO_OVMF_CODE

I don't know how to find PATH_TO_OVMF_CODE, I find /usr/share/OVMF/OVMF_CODE.fd,and run like TCGBOOT_OVMF_CODE=/usr/share/OVMF/OVMF_CODE.fd ./vm/start.sh -cdrom ~/Desktop/ubuntu-20.04.2.0-desktop-amd64.iso . But qemu just said

BdsDxe: loading Boot0001 "UEFI QEMU DVD-ROM QM00005 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x2,0xFFFF,0x0)
BdsDxe: starting Boot0001 "UEFI QEMU DVD-ROM QM00005 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x2,0xFFFF,0x0)

then sttuck.
I want to know how can I fix this, thanks!

Failed to startup

image
I tried to start the vm, but it said that something was not found. I want to know how can I fix this, thanks!

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.