Skip to content

CoreExtendedNFC 2.1.0

Latest

Choose a tag to compare

@Lakr233 Lakr233 released this 17 Oct 15:25
· 18 commits to main since this release
c0ea036

2.1.0 is a minor release: it adds public API (an experimental NTAG 424 DNA module, DESFireVersionInfo.ntagHardwareType, FeliCaFrame.REQUEST_RESPONSE, DESFireStatus.authenticationDelay and the passport and ISO 15693 helpers listed below) and fixes conformance issues found by checking every supported card family against its standard, cross-checked with closed-source readers. Not yet confirmed on real hardware: the passport Chip Access Procedure order and extended-length Active Authentication, ISO 15693 Extended Get System Information, and the NTAG 424 DNA module.

Added

  • NTAG 424 DNA module (Cards/NTAG424/, issue #14) for plain native file operations over the ISO 7816 wrapped transport:
    • NTAG424Commands.getFileSettings(fileID:) (F5h) and CoreExtendedNFC.getNTAG424FileSettings(fileID:transport:) return the new NTAG424FileSettings. Its parser is strict: it decodes FileType, FileOption (communication mode, SDM bit 6), the Read / Write / ReadWrite / Change access-right nibbles and the 24-bit file size, and, when SDM is enabled, SDMOptions, SDMAccessRights and the offsets that SDMOptions and SDMAccessRights make present (UID, SDMReadCtr, PICCData, TTStatus on NTAG 424 DNA TT, SDMMACInput, SDMENC offset and length, SDMMAC, SDMReadCtrLimit). Truncated responses, trailing bytes (such as a response MAC), a file type other than StandardData and a reserved SDMMetaRead value throw invalidResponse.
    • NTAG424Commands.writeDataPlain(fileID:offset:data:chunkSize:) and CoreExtendedNFC.writeNTAG424DataPlain(fileID:offset:data:chunkSize:transport:) send the NTAG 424 native WriteData 8Dh (not the DESFire 3Dh) in CommMode.Plain, with 3-byte little-endian offset and length. Data is split into commands of at most chunkSize bytes (default 111, so each command fits one tearing-protected 128-byte ISO 14443-4 frame; at most 248, the datasheet limit per WriteData). Arguments are checked before anything is sent (invalidParameter), and the first non-9100 status stops the write.
    • dumpCard on an NTAG 424 DNA that iOS reports as DESFire no longer fails with desfireError(.illegalCommand): when GetApplicationIDs answers 91 1C and GetVersion reports hardware type 04h (DESFireVersionInfo.ntagHardwareType), the tag is dumped as a Type 4 tag (CC and NDEF file).
    • CommMode.MAC / Full, ChangeFileSettings / SDM provisioning and EV2 command counters are not implemented.

Fixed

  • FeliCaFrame.POLLING is 0x00, the JIS X 6319-4 Polling command; it was 0x04, which is Request Response (now FeliCaFrame.REQUEST_RESPONSE).
  • DESFireStatus.authenticationDelay (91 AD) is decoded instead of surfacing as unexpectedStatusWord. A switch over every DESFireStatus case without default needs the new case.
  • authenticateEV2First rejects PCD capabilities with PCDCap2.1 bit 1 set before sending anything: that bit requests LRP secure messaging (NT4H2421Gx §9.1), whose answer the EV2 path would misread.
  • Japan IC history records with stations carry metadata["entryRegion"] / metadata["exitRegion"] from byte 15, and process type 17h (bus auto-charge) is a top-up.
  • Passport reading follows the Chip Access Procedure order of ICAO 9303-11 §4.2. PACE now runs right after EF.CardAccess, with the Master File as current DF, and the eMRTD application is then selected under the PACE Secure Messaging. Before, the application was selected in plain before PACE and never again under Secure Messaging. The plain SELECT now happens only before BAC (no usable PACEInfo, or PACE failed). A protected SELECT after PACE that the chip refuses with a protected status throws NFCError.secureMessagingError; a refusal sent as a plain status word surfaces as NFCError.unexpectedStatusWord. The new open PassportReader.selectPassportApplication(transport:) performs the SELECT.
  • Active Authentication asks for an extended response (Ne 65 536: DO'97 00 00, outer Le 00 00) when the DG15 signature or its Secure Messaging reply does not fit 256 bytes (ISO/IEC 7816-4 §5.1, ICAO 9303-11 §6.1.4). RSA keys above 1 848 bits (3DES Secure Messaging) or 1 784 bits (AES), including RSA-2048 and RSA-3072, could not return their signature with the short Le 00. Smaller RSA keys and ECDSA keys keep the short Le. New API: CommandAPDU.internalAuthenticate(data:expectedResponseLength:), PassportReader.activeAuthenticationExpectedResponseLength(for:mode:) and SMEncryptionMode.protectedResponseLength(plaintextLength:).
  • ISO 15693: block lock flags read only Lock_flag (bit b1) of each block security status byte, as ISO/IEC 15693-3 defines; the other bits are RFU, and ST tags that use them for password protection were reported as locked. The mapping lives in the new ISO15693BlockSecurityStatus.
  • ISO 15693: tags with more than 256 blocks are sized with EXTENDED GET SYSTEM INFORMATION (3Bh, ISO/IEC 15693-3:2019) when GET SYSTEM INFORMATION reports 256 blocks or no memory size. 2Bh holds the block count in one byte, so a 2048-block ST25DV64K was dumped, read and formatted as 256 blocks. ISO15693Reader.getSystemInfo() does the query and is used by getISO15693SystemInfo, the dump and the Type 5 NDEF paths; the parser is ISO15693ExtendedSystemInfo, and transports gain extendedGetSystemInfo(infoFlags:) (default: unsupported). A tag that rejects 3Bh keeps the 2Bh result.
  • NDEF: Type 2 readNDEF reads up to the data area the CC declares (CC byte 2 × 8 bytes, NFC Forum T2T 1.0 §6.1) instead of stopping at the product memory map, which is 16 pages for unidentified products such as NTAG I2C and NTAG203; a message past page 15 was reported as ndefMessageNotFound. It reads further only when the scan of the map found no complete NDEF TLV (an erased tag's 03 00 reads nothing more), stops at the first page the tag refuses, and writes are unchanged.
  • NDEF: the parser rejects a message whose first record lacks MB or whose later record sets MB (NDEF 1.0 §3.2.1). Only the presence of MB somewhere was checked before.

Full Changelog: 2.0.0...2.1.0