Nitrokey / opcard-rs

OpenPGP card implementation
49 stars 1 forks source link

Allow gpg to run factory-reset when the state is corrupted #103

Closed sosthene-nitrokey closed 1 year ago

sosthene-nitrokey commented 1 year ago

This PR makes some GET DATA commands return placeholder data when the state is corrupted. That way the card can still be factory reset even if the state fails to load. This avoids having to send raw commends as we recommend in the second alpha release notes.

When the state is corrupted, the card puts as a placeholder name: Card state corrupted. Factory reset recommended, so gpg --card-status looks like:

Reader ...........: Virtual PCD 00 00
Application ID ...: D2760001240103040000000000000000
Application type .: OpenPGP
Version ..........: 3.4
Manufacturer .....: test card
Serial number ....: 00000000
Name of cardholder: Card state corrupted. Factory reset recommended
Language prefs ...: [not set]
Salutation .......: 
URL of public key : [not set]
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: rsa2048 rsa2048 rsa2048
Max. PIN lengths .: 127 127 127
PIN retry counter : 3 3 3
Signature counter : 0
KDF setting ......: off
Signature key ....: [none]
Encryption key....: [none]
Authentication key: [none]
General key info..: [none]