I'm having issues with authenticating an NTAG424 tag in iOS. I tried using the command 9071000002000000 as the NXP documentation suggests but I keep getting a (Sw1 - 145 and Sw2 - 126 ) 917E length error message. Can you help me fix this? I've included my iOS Swift code for you to check.
I tried to change expectedResponseLength is 0 so it'll gave
Invalid expectedResponseLength value; should be from 1 to 65536 or -1.
Then I change it to -1 so it will gave same (Sw1 - 145 and Sw2 - 126 ) 917E.
Can you please help me in that I have also included my code snippet:
func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
guard let firstTag = tags.first else { return }
session.connect(to: firstTag) { (error) in
if case let .iso7816(tag) = firstTag {
let instructionClass: UInt8 = 0x90
let instructionCode: UInt8 = 0x71
let p1Parameter: UInt8 = 0x00
let p2Parameter: UInt8 = 0x00
let data: Data = Data([0x02, 0x00, 0x00])
let expectedResponseLength = -1
let command = NFCISO7816APDU(instructionClass: instructionClass, instructionCode: instructionCode, p1Parameter: p1Parameter, p2Parameter: p2Parameter, data: data, expectedResponseLength: expectedResponseLength)
tag.sendCommand(apdu: command) { (response, sw1, sw2, error) in
guard error == nil else {
print("Error sending command: \(error!)")
return
}
print("Response: \(response)")
print("SW1: \(sw1), SW2: \(sw2)")
}
}
}
}
Hello @tusharv
Please refer to Chapter 6 of AN12196 to modify your debugging code.
https://www.nxp.com.cn/docs/en/application-note/AN12196.pdf
BR
kelly