Skip to content

Commit 082012c

Browse files
author
Deren Vural
committed
fixed broken key creation process, added clarifying output for config file completion by user
Signed-off-by: Deren Vural <derenv@live.co.uk>
1 parent bbc1729 commit 082012c

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

bash-kernel-signer.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function create_keys()
223223
{
224224
# Get user input
225225
tput reset
226-
read -r user_input -p "Please specify (existing) directory for new keys & certificates:"
226+
read -p "Please specify (existing) directory for new keys & certificates:" -r user_input
227227

228228
# Validate folder exists
229229
if [[ "$user_input" == "0" ]]; then
@@ -240,10 +240,10 @@ function create_keys()
240240
read -n 1 -s -r -p "Old keys successfully read into files, press any key to continue.."
241241

242242
# Generate keys and certificates
243-
echo "generating keys & certificates..."
244-
openssl req -new -x509 -newkey rsa:2048 -keyout "${user_input}/new_PK.key" -out "${user_input}new_/PK.crt" -days 3650 -nodes -sha256
245-
openssl req -new -x509 -newkey rsa:2048 -keyout "${user_input}/new_KEK.key" -out "${user_input}/new_KEK.crt" -days 3650 -nodes -sha256
246-
openssl req -new -x509 -newkey rsa:2048 -keyout "${user_input}/new_db.key" -out "${user_input}/new_db.crt" -days 3650 -nodes -sha256
243+
echo -e "\ngenerating keys & certificates..."
244+
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=new platform key/" -keyout "${user_input}/new_PK.key" -out "${user_input}/new_PK.crt" -days 3650 -nodes -sha256
245+
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=new key exchange key/" -keyout "${user_input}/new_KEK.key" -out "${user_input}/new_KEK.crt" -days 3650 -nodes -sha256
246+
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=new kernel signing key/" -keyout "${user_input}/new_db.key" -out "${user_input}/new_db.crt" -days 3650 -nodes -sha256
247247
# Change permissions to read-only for root (precaution)
248248
sudo chmod -v 400 "${user_input}/new_PK.key"
249249
sudo chmod -v 400 "${user_input}/new_KEK.key"
@@ -252,7 +252,7 @@ function create_keys()
252252
read -n 1 -s -r -p "Keys successfully generated, press any key to continue.."
253253

254254
# Create update files
255-
echo "creating update files for keystore.."
255+
echo "\ncreating update files for keystore.."
256256
# PK
257257
cert-to-efi-sig-list -g "$(uuidgen)" "${user_input}/new_PK.crt" "${user_input}/new_PK.esl"
258258
sign-efi-sig-list -k "${user_input}/new_PK.key" -c "${user_input}/new_PK.crt" PK "${user_input}/new_PK.esl" "${user_input}/new_PK.auth"
@@ -272,7 +272,7 @@ function create_keys()
272272
openssl x509 -outform DER -in "${user_input}/new_KEK.crt" -out "${user_input}/new_KEK.cer"
273273
openssl x509 -outform DER -in "${user_input}/new_db.crt" -out "${user_input}/new_db.cer"
274274
# (continue)
275-
read -n 1 -s -r -p "DER versions successfully generated, press any key to continue"
275+
read -n 1 -s -r -p "\nDER versions successfully generated, press any key to continue"
276276

277277
# Create compound esl files & auth counterparts
278278
cat "${user_input}/old_KEK.esl" "${user_input}/new_KEK.esl" > "${user_input}/compound_KEK.esl"
@@ -281,6 +281,7 @@ function create_keys()
281281
sign-efi-sig-list -k "${user_input}/new_KEK.key" -c "${user_input}/new_KEK.crt" db "${user_input}/compound_db.esl" "${user_input}/compound_db.auth"
282282
# (continue)
283283
echo "New esl & auth files successfully generated!"
284+
echo "Add /etc/efikeys/db.key abd /etc/efikeys/db.crt to config file!"
284285
echo "See Sakaki's guide (https://wiki.gentoo.org/wiki/User:Sakaki/Sakaki's_EFI_Install_Guide/Configuring_Secure_Boot#Installing_New_Keys_into_the_Keystore) on how to update your keystore!"
285286
read -n 1 -s -r -p "(press any key to continue)"
286287
else

0 commit comments

Comments
 (0)