Add option to choose GnuPG userinfo during OEM reset

This commit is contained in:
alex-nitrokey 2020-01-02 17:29:11 +01:00
parent 8af849cadc
commit f0f6e80e95
No known key found for this signature in database
GPG Key ID: A8853020E8EE6FBA

View File

@ -20,6 +20,10 @@ ADMIN_PIN_DEF=12345678
TPM_PASS_DEF=12345678
CUSTOM_PASS=""
GPG_USER_NAME="OEM Key"
GPG_KEY_NAME=`date +%Y%m%d%H%M%S`
GPG_USER_MAIL="oem-${GPG_KEY_NAME}@example.com"
GPG_USER_COMMENT="OEM-generated key"
## External files sourced
. /etc/functions
@ -54,7 +58,6 @@ whiptail_error_die()
gpg_key_reset()
{
GPG_KEY_NAME=`date +%Y%m%d%H%M%S`
# Factory reset GPG card
{
echo admin
@ -76,9 +79,9 @@ gpg_key_reset()
echo ${USER_PIN_DEF}
echo 0
echo y
echo "OEM Key"
echo "oem-${GPG_KEY_NAME}@example.com"
echo "OEM-generated key"
echo ${GPG_USER_NAME}
echo ${GPG_USER_MAIL}
echo ${GPG_USER_COMMENT}
} | gpg --command-fd=0 --status-fd=2 --pinentry-mode=loopback --card-edit \
> /tmp/gpg_card_edit_output 2>/dev/null
if [ $? -ne 0 ]; then
@ -261,6 +264,24 @@ It must be at least 8 characters in length.\n"
TPM_PASS_DEF=$CUSTOM_PASS
fi
# Prompt to change default GnuPG key information
echo -e -n "Would you like to set custom user information for the GnuPG key? [y/N]: "
read -n 1 prompt_output
echo
if [ "$prompt_output" == "y" \
-o "$prompt_output" == "Y" ] \
; then
echo -e "\nPlease enter the following information...\n"
echo
echo -e -n "Real name: "
read GPG_USER_NAME
echo -e -n "Email address: "
read GPG_USER_MAIL
echo -e -n "Comment: "
read GPG_USER_COMMENT
echo
fi
## sanity check the USB, GPG key, and boot device before proceeding further
# mount USB, then remount rw