Add more input validation

Based on tlaurion's work done here
ff148e4daf/initrd/bin/factory-reset-libremkey.sh (L53)
This commit is contained in:
alex-nitrokey 2020-03-26 15:05:51 +01:00
parent f0f6e80e95
commit a16b97b6ea
No known key found for this signature in database
GPG Key ID: A8853020E8EE6FBA

View File

@ -89,6 +89,7 @@ gpg_key_reset()
whiptail_error_die "GPG Key automatic keygen failed!\n\n$ERROR"
fi
}
gpg_key_change_pin()
{
# 1 = user PIN, 3 = admin PIN
@ -271,15 +272,33 @@ 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
echo -e "\n\n"
echo -e "We will generate a GnuPG (PGP) keypair identifiable with the following text form:"
echo -e "Real Name (Comment) email@address.org"
echo -e "\nEnter your Real Name (At least 5 characters long):"
read -r GPG_USER_NAME
while [[ ${#GPG_USER_NAME} -lt 5 ]]; do
{
echo -e "\nEnter your Real Name (At least 5 characters long):"
read -r GPG_USER_NAME
};done
echo -e "\nEnter your email@adress.org:"
read -r GPG_USER_MAIL
while ! $(expr "$GPG_USER_MAIL" : '.*@' >/dev/null); do
{
echo -e "\nEnter your email@address.org:"
read -r GPG_USER_MAIL
};done
echo -e "\nEnter Comment (Optional, to distinguish this key from others with same previous attributes. Must be smaller then 60 characters):"
read -r GPG_USER_MAIL
while [[ ${#gpgcard_comment} -gt 60 ]]; do
{
echo -e "\nEnter Comment (Optional, to distinguish this key from others with same previous attributes. Must be smaller then 60 characters):"
read -r GPG_USER_MAIL
};done
fi
## sanity check the USB, GPG key, and boot device before proceeding further