self.desFireEV2?.authenticate(withCardKeyNo: 1, withAuthenticationType: .AES, withAuthKeyType: .AES128, withCommandSetForAuth: .ISO, withAuthkey: "AES_KEY".hexStringToData()!, onCompletion: { [unowned self] success in
print(success)
}
on authentication, the app crashes with untraceable records, even in crashlaytics not getting the traces.
-----------------------------
Debug Print
-----------------------------
Response received : AFD7AF4F60A515551FD8332907BDA43BAA
DES Session Key Before - <ComNxpNfclibDefaultimplKeyData: 0x1056e7340>
AES Session Key Data After - <ComNxpNfclibDefaultimplKeyData: 0x1056e7340>
AES Session Key Data Array After - {length = 16, bytes = AES_KEY}
------ AES, {length = 16, bytes = 0xd7af4f60a515551fd8332907bda43baa}, {length = 16, bytes = 0xAES_KEY}, {length = 16, bytes = 0x00000000000000000000000000000000} ------
Debug executable option already disabled.
Hi!
As you probably know, all documentation from MIFARE DESFire is available only under NDA, so we can not discuss any details here. However, i see a descrepancy here, that might solve the problem:
you are using the authenticate command, withCommandSetForAuth: .ISO and try to use AES keys. This seems not to fit together. MIFARE DESFire supports several authentication methods, each resulting in different secure messaging modes and each using different keys ONLY (e.g. AuthenticateISO only can be used with 3DES keys. Its crucial to use the correct combination of key and authentication. All of this can be found in the datasheet of MIFARE DESFire. In case of deeper support needed, please open a ticket with our online support team that enables us also to discuss topics protected by NDA.
Thanks,
Br,
Florian
Hi Florian,
I checked with both withCommandSetForAuth: .ISO, and .native but in both cases getting crash that are untraceable.
Can you please share the link of the data sheet?
hello,
For the datasheet, please log in at nxp.com, and then request secure file access for your account. This will only be possible if an active NDA with nxp is in place. If you do not have an active NDA, please request one in the support section of nxp.com.
Only once this is in place, the datasheet can be provided to your account.
regards,
Florian
Hello sir,
Thank you for using our community.
This is NXP's customer support, would you mind sharing if the crashing only happens when trying to read the DESFire card with authentication?
Can you read an NDEF of the card? It is also important to know what procedure are you following for configuring the card. The more information we have about your setup the better we can assist.
in other functions, I am getting success, such as selectApplication, getApplicationId and others. but while authenticating, getting untraced crashes.
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
guard let tag = tags.first else { return }
// Connect to the tag
session.connect(to: tag) { [weak self] error in
guard let self = self else { return }
if let error = error {
session.invalidate(errorMessage: "Failed to connect: \(error.localizedDescription)")
return
}
switch tag {
case .miFare(let mifare):
let reader = TL_IOSNFCReader(uid: mifare.identifier, historicalBytes: mifare.historicalBytes!)
self.handler = TapLinxApduHandler(reader: reader)
self.handler?.delegate = self
self.tagManager = TLLibraryManager.shared()
self.tagManager?.setApduHandlerWithApduHandler(self.handler)
var desfireWrapper = TL_DESFireWrapper(libraryManager: self.tagManager!)
print(desfireWrapper)
desfireWrapper.setCommandSet(.Native)
desFireEV2 = self.tagManager?.getDESFireEV2Instance()
self.desFireEV2?.selectApplication(withAppID: Int32("0")!) { success in
print("selectApplication: success \(success)")
}
self.desFireEV2?.getApplicationIDs() { success in
print("Get application IDs: success \(success)")
}
self.desFireEV2?.selectApplication(withAppID: Int32(applicationId)!) { success in
print("selectApplication: success \(success)")
}
self.desFireEV2?.getKeyVersion(forKeyNumber: 1) { value, success in
print("Get key version: success \(success)")
}
self.desFireEV2?.getFileIDs() { value, success in
print("Get file IDs: success \(success)")
}
self.desFireEV2?.authenticate(withCardKeyNo: 1, withAuthenticationType: .AES, withAuthKeyType: .AES128, withCommandSetForAuth: .ISO, withAuthkey: aesKeyData, onCompletion: { [weak self] success in
print("authenticate: success", success)
if success {
self?.desFireEV2?.readData(withFileNo: 1, withOffset: 0, withLength: 4) { data, success in
print("readDataWithFileNo: success \(success) - data = \(data)")
}
}
})
}
func apduExchange(withByteArray apduData: Data) -> TL_TagAPDUResponse? {
var dataToreturn = Data()
let semaphore = DispatchSemaphore(value: 0)
mtag?.sendMiFareCommand(commandPacket: apduData) { data, error in
dataToreturn = data
semaphore.signal()
}
_ = semaphore.wait(timeout: .now() + 3.0)
let tl = TL_TagAPDUResponse(responseData: dataToreturn, tag: tagInfo)
return tl
}
I had the same issue. Please see the answer in the following post: https://community.nxp.com/t5/TapLinx-SDK-TagWriter-and/Taplinx-iOS-app-reading-Desfire-EV2/td-p/2013...
The short answer is: Disable Debugging when running the app in Xcode.