使用 rAPDU 6988(不正确的安全消息数据对象)在 READ BINARY 处从电子护照读取 EF.COM 失败

Reading EF.COM from ePassport fails at READ BINARY with rAPDU 6988 (Incorrect Secure Messaging Data Objects)

首先,我知道这可能看起来像以下内容的副本:ePassport reading with PN532, Keep Getting SW1 SW2 = 0x69 0x88 (Incorrect Secure Messaging Data Objects)

..但我在这个过程中更进了一步。

我正在尝试使用 python 和 PN7120 nfc reader 读取机读旅行证件(电子护照)。我使用 pyPassport 2.0 作为基础。

我知道 reader 没问题,因为我可以使用相同的设备使用 Android 设置读取护照。

我跟着the ICAO 9303 Part 11 documentation,模拟了"worked example"(附录D,同一个文件)。

问题

使用真实护照时,"select applet"、"get challenge"、"do bac" 和 "select file" 步骤工作正常,但读取二进制结果为 69 88(不正确的安全消息数据对象)。

当我通过注入 ksmac/ssc 来模拟 "worked example" 时,我得到与第 75 页 (AppD-7) 点 g 中所述完全相同的 ProtectedAPDU 结果。

此外,步骤 "select file" 几乎使用完全相同的过程(参见 def protect)并成功 (rAPDU 90 00)。

我已经将所有内容进行了至少两次非常详细的比较,但真的不知道下一步该看哪里。希望有人能给点建议或见解。

相关日志(最后报错)

Calculate Session Keys (KSenc and KSmac) using Appendix 5.1
        KSenc: 3DE649F8AEA41C04FB6D4CD9043757AD
        KSmac: 8C34AD61974F68CEBA3E0EAEA1456476
Calculate Send Sequence Counter
        SSC: AB1D2F337FD997D6

Reading Common
Select File
    APDU 00 A4 02 0C 02 [011E]
Mask class byte and pad command header
        CmdHeader: 0CA4020C80000000
Pad data
        Data: 011E800000000000
Encrypt data with KSenc 3DE649F8AEA41C04FB6D4CD9043757AD
        EncryptedData: FF0E241E2F94B508
Build DO'87
        DO87: 870901FF0E241E2F94B508
Concatenate CmdHeader and DO87
        M: 0CA4020C80000000870901FF0E241E2F94B508
Compute MAC of M
        Increment SSC with 1
                SSC: AB1D2F337FD997D7
        Concatenate SSC and M and add padding
                N: AB1D2F337FD997D70CA4020C80000000870901FF0E241E2F94B5088000000000
        Compute MAC over N with KSmac 8C34AD61974F68CEBA3E0EAEA1456476
                CC: 22FF803EC3104336
Build DO'8E
        DO8E: 8E0822FF803EC3104336
Construct and send protected APDU
        ProtectedAPDU: 0CA4020C15870901FF0E241E2F94B5088E0822FF803EC310433600
[SM] - 0C A4 02 0C 15 [870901FF0E241E2F94B5088E0822FF803EC3104336] 00
[SM] - [990290008E08AAEA3B783FD6CA9D] 90 00
Receive response APDU of MRTD's chip
        RAPDU: 990290008E08AAEA3B783FD6CA9DC29000

Read Binary
    APDU 00 B0 00 00  [] 04
Mask class byte and pad command header
        CmdHeader: 0CB0000080000000
Build DO'97
        DO97: 970104
Concatenate CmdHeader and DO97
        M: 0CB0000080000000970104
Compute MAC of M
        Increment SSC with 1
                SSC: AB1D2F337FD997D8
        Concatenate SSC and M and add padding
                N: AB1D2F337FD997D80CB00000800000009701048000000000
        Compute MAC over N with KSmac 8C34AD61974F68CEBA3E0EAEA1456476
                CC: 68DD9FD88472834A
Build DO'8E
        DO8E: 8E0868DD9FD88472834A
Construct and send protected APDU
        ProtectedAPDU: 0CB000000D9701048E0868DD9FD88472834A00
[SM] - 0C B0 00 00 0D [9701048E0868DD9FD88472834A] 00
[SM] - [] 69 88 //SM data objects incorrect

谢谢!!

想通了:

由于 binary/hex/string 转换错误 (here) SELECT FILE 响应的 SM 验证步骤被跳过,因此 SSC 没有正确递增。