-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.sh
executable file
·65 lines (53 loc) · 1.56 KB
/
keys.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh -eu
#
# Naming scheme:
# PK - Platform Key
# KEK - Key Exchange Key
# ALTDB - mimics Microsoft Windows UEFI Driver Publisher
# ALTCA - ALT UEFI SB CA
# ALTSIG - ALT UEFI SB SIGNER
# NOTALT - Not signed by ALTCA
#
# What signes what
# - PK and KEK required to enable SB in OVMF
# - ALTDB signs shim{ia32,x64}.efi
# - ALTCA signs ALTSIG
# - ALTSIG signs {mm,fb}{ia32,x64}.efi and grub{ia32,x64}.efi
# - NOTALT ...
#
# Verification
# - ALTDB enrolled in DB verifies shim{ia32,x64}.efi
# - ALTCA gose into shim{ia32,x64}.efi
# - shim verifies binaries signed with ALTSIG
# - grub uses shim_lock uefi interface for verification
# - shim(thus grub) fails to verify binaries signed with NOTALT
#
DIR=$(dirname $(readlink -f $0))
source $DIR/config.sh
#NOTE(egori): this fails if KEYDIR exists
mkdir -v $KEYDIR
source $DIR/hasher.sh
hsh-install -v $HASHERDIR nss-utils pesign
hsh-run -v $HASHERDIR -- bash <<EOF
cd /.out
rm -rf ./keys
mkdir -pv keys/nss
cd keys
certutil -d "./nss" -N --empty-password
# Create CAs
for t in PK KEK ALTDB ALTCA NOTALT; do
efikeygen -d "./nss" --ca --self-sign --kernel \
--nickname="SB TEST \$t" \
--common-name="CN=SB TEST \$t"
certutil -d "./nss" -L -n "SB TEST \$t" -a > \$t.crt
done
# Create signer
efikeygen -d "./nss" --signer="SB TEST ALTCA" --kernel \
--nickname="SB TEST ALTSIG" \
--common-name="CN=SB TEST ALTSIG"
certutil -d "./nss" -L -n "SB TEST ALTCA" -r > ALTCA.cer
certutil -d "./nss" -L -n "SB TEST ALTDB" -r > ALTDB.cer
chmod +r -R .
EOF
cp -r $HASHERDIR/chroot/.out/keys/* $KEYDIR
hsh-run -v $HASHERDIR -- rm -rf /.out/keys