Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPG2 Card factory reset addition atop of empty keyring detection (+luks reencryption passwd menu added in Advanced Menu) #2

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7f1288b
Preliminary support for GnuPG2
druimalban Jan 5, 2018
c1c615e
copy gpg2 executables and pass in the libusb include path
osresearch Sep 18, 2018
d61587c
switch to gpg2 for qemu targets
osresearch Sep 18, 2018
b1736d7
use full version names on output libraries
osresearch Sep 18, 2018
b89ed83
enable Unix Domain sockets for gpg-agent
osresearch Sep 19, 2018
49269f2
gpg2 library fixes
tlaurion Sep 19, 2018
c261907
gpg2 pinentry program is required for passwords or PINs
osresearch Sep 19, 2018
82701fb
typo on pinentry
osresearch Sep 19, 2018
8ba3c33
required changes to apply on top of osresearch/gpg2 for gpg2 to actua…
tlaurion Oct 5, 2018
e5a739e
use /bin for libexecdir and disable curses pinentry
osresearch Oct 17, 2018
6335ece
gpg2 pubring extension change from gpg to kbx
tlaurion Nov 15, 2018
44d566a
pinentry-tty path needs to be known from gpg-agent
tlaurion Nov 15, 2018
02728ff
gpg needs to be called with --no-tty at that point, since pintentry-t…
tlaurion Nov 15, 2018
a2a3df2
GPG_TTY is forced to /dev/console under init. Ash console is never ca…
tlaurion Nov 15, 2018
a78c702
instruct gpg to use gpg-agent.
tlaurion Nov 15, 2018
3e18ed9
Port gpg1 patch to gpg2 to force crosscompiling and output to stderr.
tlaurion Nov 15, 2018
b6f2f7d
Set GPG_TTY before calling gpg in key-init
jandryuk Dec 1, 2018
ee12c3a
Removed --no-tty as it disables the card admin PIN pinentry
itay-grudev Jan 3, 2019
a9eaf77
Enabled GPG2 in the Librem board config
itay-grudev Jan 4, 2019
175841d
Disabled libsecret support in the pinentry module
itay-grudev Jan 4, 2019
e270f7d
Code style fix
itay-grudev Jan 7, 2019
9a0b093
Removing CONFIG_GPG in librem boards
tlaurion Jan 26, 2019
4d62428
GPG2 required changes for key and trustdb generation and inclusion in…
tlaurion Jan 26, 2019
2875ecb
module/pinentry: disable-pinentry-qt instead of qt5
tlaurion Jan 26, 2019
7ced37a
Merge remote-tracking branch 'tlaurion/gpg2' into gpg2_add_empty_keyr…
tlaurion Jan 26, 2019
a32ea98
Adds GPG2 card factory reset option in empty keyring detection.
tlaurion Jan 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ bin_modules-$(CONFIG_PCIUTILS) += pciutils
bin_modules-$(CONFIG_FLASHROM) += flashrom
bin_modules-$(CONFIG_CRYPTSETUP) += cryptsetup
bin_modules-$(CONFIG_GPG) += gpg
bin_modules-$(CONFIG_GPG2) += gpg2
bin_modules-$(CONFIG_PINENTRY) += pinentry
bin_modules-$(CONFIG_LVM2) += lvm2
bin_modules-$(CONFIG_DROPBEAR) += dropbear
bin_modules-$(CONFIG_FLASHTOOLS) += flashtools
Expand Down
2 changes: 1 addition & 1 deletion boards/librem13v2/librem13v2.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export CONFIG_COREBOOT=y
CONFIG_CRYPTSETUP=y
CONFIG_FLASHROM=y
CONFIG_FLASHTOOLS=y
CONFIG_GPG=y
CONFIG_GPG2=y
CONFIG_KEXEC=y
CONFIG_UTIL_LINUX=y
CONFIG_LVM2=y
Expand Down
2 changes: 1 addition & 1 deletion boards/librem15v3/librem15v3.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export CONFIG_COREBOOT=y
CONFIG_CRYPTSETUP=y
CONFIG_FLASHROM=y
CONFIG_FLASHTOOLS=y
CONFIG_GPG=y
CONFIG_GPG2=y
CONFIG_KEXEC=y
CONFIG_UTIL_LINUX=y
CONFIG_LVM2=y
Expand Down
2 changes: 1 addition & 1 deletion boards/qemu-coreboot/qemu-coreboot.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CONFIG_FLASHROM=y
CONFIG_PCIUTILS=y
CONFIG_UTIL_LINUX=y
CONFIG_CRYPTSETUP=y
CONFIG_GPG=y
CONFIG_GPG2=y
CONFIG_LVM2=y
CONFIG_MBEDTLS=y
CONFIG_DROPBEAR=y
Expand Down
2 changes: 1 addition & 1 deletion boards/qemu-linuxboot/qemu-linuxboot.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif

CONFIG_FLASHROM=y
CONFIG_FLASHTOOLS=y
CONFIG_GPG=y
CONFIG_GPG2=y
CONFIG_KEXEC=y
CONFIG_UTIL_LINUX=y
CONFIG_DROPBEAR=y
Expand Down
2 changes: 1 addition & 1 deletion boards/x230/x230.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CONFIG_LINUX_CONFIG=config/linux-x230.config
CONFIG_CRYPTSETUP=y
CONFIG_FLASHROM=y
CONFIG_FLASHTOOLS=y
CONFIG_GPG=y
CONFIG_GPG2=y
CONFIG_KEXEC=y
CONFIG_UTIL_LINUX=y
CONFIG_LVM2=y
Expand Down
1 change: 1 addition & 0 deletions config/linux-kgpe-d16.config
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ CONFIG_PCI_PRI=y
# CONFIG_COREDUMP is not set
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_SYN_COOKIES=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
Expand Down
1 change: 1 addition & 0 deletions config/linux-librem13v2.config
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ CONFIG_PCI_PRI=y
# CONFIG_COREDUMP is not set
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_SYN_COOKIES=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
Expand Down
1 change: 1 addition & 0 deletions config/linux-linuxboot.config
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ CONFIG_PCI_PRI=y
CONFIG_IA32_EMULATION=y
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_SYN_COOKIES=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
Expand Down
1 change: 1 addition & 0 deletions config/linux-x230.config
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ CONFIG_PCI_PRI=y
# CONFIG_COREDUMP is not set
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_SYN_COOKIES=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
Expand Down
27 changes: 15 additions & 12 deletions initrd/.ash_history
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
mount /dev/sda1 /boot
mount -o remount,rw /boot
rm /boot/kexec_*
mount-usb
mkdir -p /media/gpg_keys
gpg --home=/media/gpg_keys --card-edit
gpg --home=/media/gpg_keys --export --armor e@mail.address > /media/gpg_keys/public.key
gpg --home=/media/gpg_keys --export-secret-keys --armor e@mail.address > /media/gpg_keys/private.key
cbfs -o /media/coreboot.rom -a "heads/initrd/.gnupg/keys/public.key" -f /media/gpg_keys/public.key
cbfs -o /media/coreboot.rom -a "heads/initrd/.gnupg/keys/private.key" -f /media/gpg_keys/private.key
mount -o remount,ro /media
flash.sh /media/coreboot.com
#remove invalid kexec_* signed files
mount /dev/sda1 /boot && mount -o remount,rw /boot && rm /boot/kexec* && mount -o remount,ro /boot
#Generate keys from GPG smartcard:
mount-usb && gpg --home=/.gnupg/ --card-edit
#Copy generated public key, private_subkey, trustdb and artifacts to external media for backup:
mount -o remount,rw /media && mkdir -p /media/gpg_keys; gpg --export-secret-keys --armor email@address.com > /media/gpg_keys/private.key && gpg --export --armor email@address.com > /media/gpg_keys/public.key && gpg --export-ownertrust > /media/gpg_keys/otrust.txt && cp -r ./.gnupg/* /media/gpg_keys/ 2> /dev/null
#Insert public key and trustdb export into reproducible rom:
cbfs -o /media/coreboot.rom -a "heads/initrd/.gnupg/keys/public.key" -f /media/gpg_keys/public.key && cbfs -o /media/coreboot.rom -a "heads/initrd/.gnupg/keys/otrust.txt" -f /media/gpg_keys/otrust.txt
#Flush changes to external media:
mount -o,remount ro /media
#Flash modified reproducible rom with inserted public key and trustdb export from precedent step. Flushes actual rom's keys (-c: clean):
flash.sh -c /media/coreboot.rom
#Attest integrity of firmware as it is
seal-totp
#Verify Intel ME state:
cbmem --console | grep '^ME'
cbmem --console | less
3 changes: 3 additions & 0 deletions initrd/.gnupg/gpg-agent.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scdaemon-program /bin/scdaemon
pinentry-program /bin/pinentry-tty
daemon
1 change: 1 addition & 0 deletions initrd/.gnupg/gpg.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use-agent
20 changes: 13 additions & 7 deletions initrd/bin/flash-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,22 @@ while true; do

cat $PUBKEY | gpg --import
cp $ROM /tmp/gpg-gui.rom
if (cbfs -o /tmp/gpg-gui.rom -l | grep -q "heads/initrd/.gnupg/pubring.gpg") then
cbfs -o /tmp/gpg-gui.rom -d "heads/initrd/.gnupg/pubring.gpg"
if (cbfs -o /tmp/gpg-gui.rom -l | grep -q "heads/initrd/.gnupg/pubring.kbx") then
cbfs -o /tmp/gpg-gui.rom -d "heads/initrd/.gnupg/pubring.kbx"
fi
cbfs -o /tmp/gpg-gui.rom -a "heads/initrd/.gnupg/pubring.gpg" -f /.gnupg/pubring.gpg

cbfs -o /tmp/gpg-gui.rom -a "heads/initrd/.gnupg/pubring.kbx" -f /.gnupg/pubring.kbx

#TODO: Remove this? Not useful in GPG2
if (cbfs -o /tmp/gpg-gui.rom -l | grep -q "heads/initrd/.gnupg/trustdb.gpg") then
cbfs -o /tmp/gpg-gui.rom -d "heads/initrd/.gnupg/trustdb.gpg"
fi
cbfs -o /tmp/gpg-gui.rom -a "heads/initrd/.gnupg/trustdb.gpg" -f /.gnupg/trustdb.gpg

if (cbfs -o /tmp/gpg-gui.rom -l | grep -q "heads/initrd/.gnupg/otrust.txt") then
cbfs -o /tmp/gpg-gui.rom -d "heads/initrd/.gnupg/otrust.txt"
fi
cbfs -o /tmp/gpg-gui.rom -a "heads/initrd/.gnupg/otrust.txt" -f /.gnupg/otrust.txt

if (whiptail --title 'Flash ROM?' \
--yesno "This will replace your old ROM with $ROM\n\nDo you want to proceed?" 16 90) then
/bin/flash.sh /tmp/gpg-gui.rom
Expand Down Expand Up @@ -180,10 +186,10 @@ while true; do
fi

cat $PUBKEY | gpg --import
if (cbfs -o /tmp/gpg-gui.rom -l | grep -q "heads/initrd/.gnupg/pubring.gpg") then
cbfs -o /tmp/gpg-gui.rom -d "heads/initrd/.gnupg/pubring.gpg"
if (cbfs -o /tmp/gpg-gui.rom -l | grep -q "heads/initrd/.gnupg/pubring.kbx") then
cbfs -o /tmp/gpg-gui.rom -d "heads/initrd/.gnupg/pubring.kbx"
fi
cbfs -o /tmp/gpg-gui.rom -a "heads/initrd/.gnupg/pubring.gpg" -f /.gnupg/pubring.gpg
cbfs -o /tmp/gpg-gui.rom -a "heads/initrd/.gnupg/pubring.kbx" -f /.gnupg/pubring.kbx

if (cbfs -o /tmp/gpg-gui.rom -l | grep -q "heads/initrd/.gnupg/trustdb.gpg") then
cbfs -o /tmp/gpg-gui.rom -d "heads/initrd/.gnupg/trustdb.gpg"
Expand Down
Loading