github-af / SmartPGP

SmartPGP is a JavaCard implementation of the OpenPGP card specifications
GNU General Public License v2.0
227 stars 47 forks source link

AID weirdness on J3R180 #51

Closed 65a closed 1 year ago

65a commented 1 year ago

Card is J3R180. Close this bug if I somehow mangled my custom AID.

If I use the default AID, I can generate keys and use the card as expected.

If I use (I believe) a formally valid random AID such as D276000124010304FFD6EB4A3E2600, any attempt to generate keys results in an error: gpg: error checking the PIN: Invalid ID

scdaemon trace of this failure condition (with a different random AID) looks like:

2023-08-19 03:36:19 scdaemon[791287] DBG: chan_7 <- CHECKPIN D276000124010304FF2408C38DEB00 2023-08-19 03:36:19 scdaemon[791287] DBG: send apdu: c=00 i=47 p1=81 p2=00 lc=2 le=256 em=0 2023-08-19 03:36:19 scdaemon[791287] DBG: PCSC_data: 00 47 81 00 02 B6 00 00 2023-08-19 03:36:19 scdaemon[791287] DBG: response: sw=6A88 datalen=0 2023-08-19 03:36:19 scdaemon[791287] reading public key failed: Missing item in object 2023-08-19 03:36:19 scdaemon[791287] DBG: send apdu: c=00 i=47 p1=81 p2=00 lc=2 le=256 em=0 2023-08-19 03:36:19 scdaemon[791287] DBG: PCSC_data: 00 47 81 00 02 B8 00 00 2023-08-19 03:36:19 scdaemon[791287] DBG: response: sw=6A88 datalen=0 2023-08-19 03:36:19 scdaemon[791287] reading public key failed: Missing item in object 2023-08-19 03:36:19 scdaemon[791287] DBG: send apdu: c=00 i=47 p1=81 p2=00 lc=2 le=256 em=0 2023-08-19 03:36:19 scdaemon[791287] DBG: PCSC_data: 00 47 81 00 02 A4 00 00 2023-08-19 03:36:19 scdaemon[791287] DBG: response: sw=6A88 datalen=0 2023-08-19 03:36:19 scdaemon[791287] reading public key failed: Missing item in object 2023-08-19 03:36:19 scdaemon[791287] operation check_pin result: Invalid ID 2023-08-19 03:36:19 scdaemon[791287] app_check_pin failed: Invalid ID 2023-08-19 03:36:19 scdaemon[791287] DBG: chan_7 -> ERR 100663414 Invalid ID 2023-08-19 03:36:19 scdaemon[791287] DBG: chan_7 <- SETATTR CHV-STATUS-1 %00 2023-08-19 03:36:19 scdaemon[791287] DBG: send apdu: c=00 i=DA p1=00 p2=C4 lc=1 le=-1 em=0 2023-08-19 03:36:19 scdaemon[791287] DBG: PCSC_data: 00 DA 00 C4 01 00 2023-08-19 03:36:19 scdaemon[791287] DBG: response: sw=9000 datalen=0 2023-08-19 03:36:19 scdaemon[791287] DBG: dump: [all zero] 2023-08-19 03:36:19 scdaemon[791287] DBG: chan_7 -> OK

65a commented 1 year ago

Indeed, my custom AID is mangled. RFU section is 2 bytes, but 4 zeros.

65a commented 1 year ago

Leaving as a tombstone if anyone else runs into this