AndyQ / NFCPassportReader

NFCPassportReader for iOS 13
MIT License
749 stars 242 forks source link

Chip Authentication 6F error code #150

Closed emreyasar closed 2 years ago

emreyasar commented 2 years ago

When I try to Chip Authentication with passport, in the sendMSESetATIntAuth method, APDU command completes with error. The error log is below.

Performing Chip Authentication - number of public keys found - 1 Starting Chip Authentication! Error reading tag: sw1 - 0x6F, sw2 - 0x00 reason: No precise diagnosis ERROR! - No precise diagnosis Finished Chip Authentication - success - false

What does "No precise diagnosis" mean ? Can you help me ?

Groops78 commented 2 years ago

Coule you send me a complete log of apdu?

emreyasar commented 2 years ago

In order not to be too long, I deleted the data group read logs except for DG14. I can add them if you want.

tagReaderSessionDidBecomeActive tagReaderSession:didDetect - iso7816(<NFCISO7816Tag: 0x2836acd80>) tagReaderSession:connecting to tag - iso7816(<NFCISO7816Tag: 0x2836acd80>) tagReaderSession:connected to tag - starting authentication TagReader - sending [0x00, 0xA4, 0x00, 0x0C, 0x02, 0x3F, 0x00, 0x00] TagReader - Received response TagReader [unprotected] [], sw1:0x90 sw2:0x00 TagReader - sending [0x00, 0xA4, 0x02, 0x0C, 0x02, 0x01, 0x1C] TagReader - Received response TagReader [unprotected] [], sw1:0x90 sw2:0x00 TagReader - sending [0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x04] TagReader - Received response TagReader [unprotected] [0x31, 0x14, 0x30, 0x12, ], sw1:0x90 sw2:0x00 TagReader - Number of data bytes to read - 20 TagReader - sending [0x00, 0xB0, 0x00, 0x02, 0x14] TagReader - Received response TagReader [unprotected] [0x30, 0x12, 0x06, 0x0a, 0x04, 0x00, 0x7f, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x04, 0x02, 0x01, 0x02, 0x02, 0x01, 0x12, ], sw1:0x90 sw2:0x00 Read CardAccess - data 31143012060A04007F00070202040404020102020112 Starting Password Authenticated Connection Establishment (PACE) Performing PACE with id-PACE-ECDH-IM-AES-CBC-CMAC-256 TagReader - sending [0x00, 0x22, 0xC1, 0xA4, 0x0F, 0x80, 0x0A, 0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x04, 0x83, 0x01, 0x01, 0x00] TagReader - Received response TagReader [unprotected] [], sw1:0x90 sw2:0x00 Doing PACE Step1... TagReader - sending [0x10, 0x86, 0x00, 0x00, 0x02, 0x7C, 0x00, 0x00] TagReader - Received response TagReader [unprotected] [0x7c, 0x22, 0x80, 0x20, 0x77, 0x91, 0x4f, 0xcc, 0x53, 0x23, 0x52, 0x14, 0xdd, 0xdd, 0x40, 0xa7, 0xb2, 0x64, 0xa9, 0x28, 0x59, 0x1c, 0xb1, 0xf6, 0xde, 0x51, 0xd6, 0x7b, 0xab, 0x34, 0xf4, 0x63, 0x22, 0x71, 0x8e, 0x56, ], sw1:0x90 sw2:0x00 Doing PACE Step2... Using Integrated Mapping (IM)... PACEHandler: Step2IM - IM not yet implemented OpenSSLError: PACE Failed - Invalid data passed - PACE Failed Re-selecting eMRTD Application TagReader - sending [0x00, 0xA4, 0x04, 0x0C, 0x07, 0xA0, 0x00, 0x00, 0x02, 0x47, 0x10, 0x01, 0x00] TagReader - Received response TagReader [unprotected] [], sw1:0x90 sw2:0x00 Starting Basic Access Control (BAC) BACHandler - deriving Document Basic Access Keys BACHandler - Getting initial challenge TagReader - sending [0x00, 0x84, 0x00, 0x00, 0x08] TagReader - Received response TagReader [unprotected] [0xf2, 0x52, 0xe7, 0x36, 0x8b, 0xc2, 0xce, 0x92, ], sw1:0x90 sw2:0x00 BACHandler - Doing mutual authentication TagReader - sending [0x00, 0x82, 0x00, 0x00, 0x28, 0x10, 0x4D, 0x72, 0x42, 0xA0, 0x46, 0xAE, 0x4D, 0x9E, 0x16, 0xCF, 0x2E, 0x57, 0x03, 0xB5, 0x55, 0xA6, 0x4A, 0x1C, 0xBE, 0x82, 0x98, 0xE1, 0x04, 0xD8, 0x10, 0x76, 0xAD, 0x1E, 0x7D, 0xCE, 0x0F, 0x61, 0x6D, 0x69, 0x6E, 0xB1, 0x74, 0x25, 0x3D, 0x00] TagReader - Received response TagReader [unprotected] [0x5e, 0x4f, 0x7f, 0xe2, 0x30, 0xa3, 0x28, 0x9e, 0x04, 0xdb, 0xd7, 0x13, 0x67, 0x68, 0xa1, 0x3f, 0x59, 0xef, 0xe0, 0xce, 0x2a, 0xfb, 0xe9, 0xef, 0xef, 0x6f, 0x86, 0xe2, 0x12, 0xec, 0x59, 0x71, 0xf7, 0x0a, 0x51, 0x7e, 0x17, 0x92, 0x50, 0x24, ], sw1:0x90 sw2:0x00 BACHandler - complete BAC Successful Reading tag - COM TagReader - sending [0x00, 0xA4, 0x02, 0x0C, 0x02, 0x01, 0x1E] TagReader - Received response TagReader [SM - unprotected] [], sw1:0x90 sw2:0x00 TagReader - sending [0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x04] TagReader - Received response TagReader [SM - unprotected] [0x60, 0x18, 0x5f, 0x01, ], sw1:0x90 sw2:0x00 TagReader - Number of data bytes to read - 24 TagReader - sending [0x00, 0xB0, 0x00, 0x02, 0x18] TagReader - Received response TagReader [SM - unprotected] [0x5f, 0x01, 0x04, 0x30, 0x31, 0x30, 0x37, 0x5f, 0x36, 0x06, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x5c, 0x06, 0x61, 0x75, 0x63, 0x6b, 0x6c, 0x6e, ], sw1:0x90 sw2:0x00 DG Found - ["DG1", "DG2", "DG3", "DG11", "DG12", "DG14"] Reading tag - DG14 TagReader - sending [0x00, 0xA4, 0x02, 0x0C, 0x02, 0x01, 0x0E] TagReader - Received response TagReader [SM - unprotected] [], sw1:0x90 sw2:0x00 TagReader - sending [0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x04] TagReader - Received response TagReader [SM - unprotected] [0x6e, 0x82, 0x02, 0x91, ], sw1:0x90 sw2:0x00 TagReader - Number of data bytes to read - 657 TagReader - sending [0x00, 0xB0, 0x00, 0x04, 0xA0] TagReader - Received response TagReader [SM - unprotected] [0x31, 0x82, 0x02, 0x8d, 0x30, 0x0d, 0x06, 0x08, 0x04, 0x00, 0x7f, 0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x30, 0x0f, 0x06, 0x0a, 0x04, 0x00, 0x7f, 0x00, 0x07, 0x02, 0x02, 0x03, 0x02, 0x04, 0x02, 0x01, 0x01, 0x30, 0x12, 0x06, 0x0a, 0x04, 0x00, 0x7f, 0x00, 0x07, 0x02, 0x02, 0x04, 0x04, 0x04, 0x02, 0x01, 0x02, 0x02, 0x01, 0x12, 0x30, 0x82, 0x02, 0x55, 0x06, 0x09, 0x04, 0x00, 0x7f, 0x00, 0x07, 0x02, 0x02, 0x01, 0x02, 0x30, 0x82, 0x02, 0x46, 0x30, 0x82, 0x01, 0xb9, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x30, 0x82, 0x01, 0xac, 0x02, 0x01, 0x01, 0x30, 0x4d, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01, 0x02, 0x42, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, ], sw1:0x90 sw2:0x00 TagReader - sending [0x00, 0xB0, 0x00, 0xA4, 0xA0] TagReader - Received response TagReader [SM - unprotected] [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x30, 0x81, 0x88, 0x04, 0x42, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x04, 0x42, 0x00, 0x51, 0x95, 0x3e, 0xb9, 0x61, 0x8e, 0x1c, 0x9a, 0x1f, 0x92, 0x9a, 0x21, 0xa0, 0xb6, 0x85, 0x40, 0xee, 0xa2, 0xda, 0x72, 0x5b, 0x99, 0xb3, 0x15, 0xf3, 0xb8, 0xb4, 0x89, 0x91, 0x8e, 0xf1, 0x09, 0xe1, 0x56, 0x19, 0x39, 0x51, 0xec, 0x7e, 0x93, 0x7b, 0x16, 0x52, 0xc0, 0xbd, 0x3b, 0xb1, 0xbf, 0x07, 0x35, 0x73, 0xdf, 0x88, 0x3d, 0x2c, 0x34, 0xf1, 0xef, 0x45, 0x1f, 0xd4, 0x6b, 0x50, 0x3f, 0x00, 0x04, 0x81, 0x85, 0x04, 0x00, 0xc6, 0x85, ], sw1:0x90 sw2:0x00 TagReader - sending [0x00, 0xB0, 0x01, 0x44, 0xA0] TagReader - Received response TagReader [SM - unprotected] [0x8e, 0x06, 0xb7, 0x04, 0x04, 0xe9, 0xcd, 0x9e, 0x3e, 0xcb, 0x66, 0x23, 0x95, 0xb4, 0x42, 0x9c, 0x64, 0x81, 0x39, 0x05, 0x3f, 0xb5, 0x21, 0xf8, 0x28, 0xaf, 0x60, 0x6b, 0x4d, 0x3d, 0xba, 0xa1, 0x4b, 0x5e, 0x77, 0xef, 0xe7, 0x59, 0x28, 0xfe, 0x1d, 0xc1, 0x27, 0xa2, 0xff, 0xa8, 0xde, 0x33, 0x48, 0xb3, 0xc1, 0x85, 0x6a, 0x42, 0x9b, 0xf9, 0x7e, 0x7e, 0x31, 0xc2, 0xe5, 0xbd, 0x66, 0x01, 0x18, 0x39, 0x29, 0x6a, 0x78, 0x9a, 0x3b, 0xc0, 0x04, 0x5c, 0x8a, 0x5f, 0xb4, 0x2c, 0x7d, 0x1b, 0xd9, 0x98, 0xf5, 0x44, 0x49, 0x57, 0x9b, 0x44, 0x68, 0x17, 0xaf, 0xbd, 0x17, 0x27, 0x3e, 0x66, 0x2c, 0x97, 0xee, 0x72, 0x99, 0x5e, 0xf4, 0x26, 0x40, 0xc5, 0x50, 0xb9, 0x01, 0x3f, 0xad, 0x07, 0x61, 0x35, 0x3c, 0x70, 0x86, 0xa2, 0x72, 0xc2, 0x40, 0x88, 0xbe, 0x94, 0x76, 0x9f, 0xd1, 0x66, 0x50, 0x02, 0x42, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, ], sw1:0x90 sw2:0x00 TagReader - sending [0x00, 0xB0, 0x01, 0xE4, 0xA0] TagReader - Received response TagReader [SM - unprotected] [0xff, 0xff, 0xff, 0xff, 0xfa, 0x51, 0x86, 0x87, 0x83, 0xbf, 0x2f, 0x96, 0x6b, 0x7f, 0xcc, 0x01, 0x48, 0xf7, 0x09, 0xa5, 0xd0, 0x3b, 0xb5, 0xc9, 0xb8, 0x89, 0x9c, 0x47, 0xae, 0xbb, 0x6f, 0xb7, 0x1e, 0x91, 0x38, 0x64, 0x09, 0x02, 0x01, 0x01, 0x03, 0x81, 0x86, 0x00, 0x04, 0x01, 0x86, 0x54, 0x8e, 0x6b, 0x2f, 0xc1, 0xeb, 0x09, 0x64, 0xac, 0xc6, 0xb7, 0x35, 0x2f, 0xc4, 0x26, 0x4f, 0x88, 0xdb, 0x9e, 0xf8, 0xe2, 0xd9, 0xed, 0xea, 0x26, 0x59, 0xe9, 0x6f, 0xac, 0x03, 0x64, 0x4a, 0x47, 0x3b, 0xc4, 0x68, 0x6e, 0x61, 0xfd, 0x88, 0x7c, 0xc6, 0x12, 0x73, 0x31, 0x8b, 0x13, 0xe3, 0xaa, 0x57, 0x9d, 0xa1, 0x38, 0x56, 0x37, 0xfb, 0x8c, 0x39, 0xb6, 0x06, 0xcb, 0x0f, 0xf3, 0x7b, 0x01, 0x0e, 0x8f, 0xbc, 0x1c, 0xe0, 0x0b, 0x63, 0x3a, 0xfe, 0xb9, 0xbc, 0xd7, 0x22, 0xb3, 0x72, 0x5a, 0x8a, 0x93, 0xa3, 0xc7, 0x72, 0xf3, 0xb9, 0x75, 0xd3, 0xa2, 0x4f, 0x93, 0x14, 0x4e, 0xb7, 0xe3, 0x97, 0xfa, 0xa8, 0xa5, 0x73, 0x8b, 0x6c, 0x0a, 0x06, 0x03, 0xaa, 0xa8, 0xa1, 0xd8, 0x12, 0xc7, ], sw1:0x90 sw2:0x00 TagReader - sending [0x00, 0xB0, 0x02, 0x84, 0x11] TagReader - Received response TagReader [SM - unprotected] [0xf1, 0x98, 0x49, 0x5b, 0x63, 0xd2, 0x43, 0x2d, 0x50, 0x95, 0x41, 0xb3, 0x90, 0xe7, 0xf1, 0xf2, 0xab, ], sw1:0x90 sw2:0x00 Performing Chip Authentication - number of public keys found - 1 Starting Chip Authentication! TagReader - sending [0x00, 0x22, 0x41, 0xA4, 0x0C, 0x80, 0x0A, 0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x03, 0x02, 0x04, 0x00] TagReader - Received response TagReader [SM - unprotected] [0x99, 0x02, 0x6f, 0x00, 0x8e, 0x08, 0x8d, 0x88, 0x1f, 0x9d, 0xd9, 0x70, 0x58, 0x9e, ], sw1:0x6f sw2:0x00 Error reading tag: sw1 - 0x6F, sw2 - 0x00 reason: No precise diagnosis ERROR! - No precise diagnosis Finished Chip Authentication - success - false Reading tag - SOD TagReader - sending [0x00, 0xA4, 0x02, 0x0C, 0x02, 0x01, 0x1D] ... .... .... .... .... .... error 20 at 0 depth lookup:unable to get local issuer certificate Parse SOD - Using Algo - SHA512

emreyasar commented 2 years ago

Is there any comment about this error ?

Groops78 commented 2 years ago

I think the implicit selection is not well configured

emreyasar commented 2 years ago

@AndyQ do you have any comment ?

Groops78 commented 2 years ago

Do you have the atr/ats answer?

AndyQ commented 2 years ago

I'll take a look in a day or so when I'm back. It's possible it's not correctly selecting the correct certificate for some reason or I need to explicitly select the certificate rather than relying on the fact that as there is only one then passport will automatically just use that.

emreyasar commented 2 years ago

Solved! The reason was because I haven't imported the latest changes in SecureMessaging to my local :( Now it completed CA successfully. Thanks for your help.