oem-factory-reset: reset nk3 secure app PIN early since we need physical presence, put nk3 secure APP PIN after TPM but before GPG PINS in output for consistency

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
This commit is contained in:
Thierry Laurion 2024-12-05 14:37:48 -05:00
parent c372370210
commit e25fb595b6
No known key found for this signature in database
GPG Key ID: 9A53E1BB3FF00461

View File

@ -148,8 +148,6 @@ reset_nk3_secret_app() {
echo echo
echo "Resetting Nitrokey 3 Secret App PIN. Physical presence (touch) will be required" echo "Resetting Nitrokey 3 Secret App PIN. Physical presence (touch) will be required"
#TODO, change message when https://github.com/Nitrokey/nitrokey-hotp-verification/issues/41 is fixed #TODO, change message when https://github.com/Nitrokey/nitrokey-hotp-verification/issues/41 is fixed
DEBUG "Restarting scdaemon to remove possible exclusive lock of dongle"
killall -9 scdaemon 2>&1 >/dev/null || true
# Reset Nitrokey 3 secret app with PIN # Reset Nitrokey 3 secret app with PIN
/bin/hotp_verification reset "${ADMIN_PIN}" /bin/hotp_verification reset "${ADMIN_PIN}"
fi fi
@ -537,6 +535,9 @@ gpg_key_factory_reset() {
#enable usb storage #enable usb storage
enable_usb enable_usb
#Reset Nitrokey 3 secret app
reset_nk3_secret_app
# Factory reset GPG card # Factory reset GPG card
echo "GPG factory reset of USB Security Dongle's smartcard..." echo "GPG factory reset of USB Security Dongle's smartcard..."
{ {
@ -551,8 +552,6 @@ gpg_key_factory_reset() {
whiptail_error_die "GPG Key factory reset failed!\n\n$ERROR" whiptail_error_die "GPG Key factory reset failed!\n\n$ERROR"
fi fi
#Reset Nitrokey 3 secret app
reset_nk3_secret_app
# If Nitrokey Storage is inserted, reset AES keys as well # If Nitrokey Storage is inserted, reset AES keys as well
if lsusb | grep -q "20a0:4109" && [ -x /bin/hotp_verification ]; then if lsusb | grep -q "20a0:4109" && [ -x /bin/hotp_verification ]; then
@ -1387,14 +1386,13 @@ if [ "$CONFIG_TPM" = "y" ]; then
passphrases+="TPM Owner Password: ${TPM_PASS}\n" passphrases+="TPM Owner Password: ${TPM_PASS}\n"
fi fi
#GPG PINs output
passphrases+="GPG Admin PIN: ${ADMIN_PIN}\n"
#if nk3 detected, we add the NK3 Secre App PIN. Detect by product ID #if nk3 detected, we add the NK3 Secre App PIN. Detect by product ID
if lsusb | grep -q "20a0:42b2"; then if lsusb | grep -q "20a0:42b2"; then
passphrases+="Nitrokey 3 Secret App PIN: ${ADMIN_PIN}\n" passphrases+="Nitrokey 3 Secret App PIN: ${ADMIN_PIN}\n"
fi fi
#GPG PINs output
passphrases+="GPG Admin PIN: ${ADMIN_PIN}\n"
#USER PIN was configured if GPG_GEN_KEY_IN_MEMORY is not active or if GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD is active #USER PIN was configured if GPG_GEN_KEY_IN_MEMORY is not active or if GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD is active
if [ "$GPG_GEN_KEY_IN_MEMORY" = "n" -o "$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD" = "y" ]; then if [ "$GPG_GEN_KEY_IN_MEMORY" = "n" -o "$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD" = "y" ]; then
passphrases+="GPG User PIN: ${USER_PIN}\n" passphrases+="GPG User PIN: ${USER_PIN}\n"