简体   繁体   English

DESFire写入数据命令失败,出现917E(长度错误)

[英]DESFire write data command fails with 917E (length error)

I am facing a very strange problem with MIFARE DESFire. 我在使用MIFARE DESFire时遇到了一个非常奇怪的问题。 When I write small amounts of data (eg 11 bytes), the write operation succeeds. 当我写少量数据(例如11个字节)时,写操作成功。 However, when I try to write eg 50 byte, the response is 917E, which means there is some length issue in command. 但是,当我尝试写入例如50字节时,响应为917E,这意味着命令中存在一些长度问题。

Try to write 11 bytes: 尝试写11个字节:

<-- 90 3D 00 00 12 01 000000 0B0000 1234567890AABBCC DDEEFF 00
--> 9100 (success)

Try to write 50 bytes: 尝试写50个字节:

<-- 90 3D 00 00 39 01 000000 320000 1234567890AABBCC DDEE1234567890AA
                                    BBCCDDEE12345678 90AABBCCDDEE1234
                                    567890AABBCCDDEE 1234567890AABBCC DDEE 00
--> 917E (length error)

The error indicates that your command is too long. 该错误表示您的命令太长。 You probably use DESFire EV1 which only supports wrapped APDU lengths up to 55 bytes. 您可能使用DESFire EV1,它仅支持最多55个字节的包装APDU长度。 Consequently, the maximum data length for the WriteData command, when packed into a single APDU in wrapped native mode, is 因此,当以压缩的本机模式打包到单个APDU中时,WriteData命令的最大数据长度为

55 - APDU Header - APDU Lc - File ID - Offset - Length - APDU Le =
55 - 4           - 1       - 1       - 3      - 3      - 1       = 42 bytes.

This is slightly smaller than the limit for the WriteData command itself due to the APDU wrapping. 由于APDU包装,这略小于WriteData命令本身的限制。 Note that you could still send (much) more data in one WriteData command by spliting the data across multiple DESFire frames (using the 0xAF status and command codes). 请注意,您仍然可以通过在多个DE​​SFire帧之间拆分数据(使用0xAF状态和命令代码)在一个WriteData命令中发送(更多)更多数据。

Update 更新

The 55 bytes are mentioned in the DESFire EV1 datasheet. DESFire EV1数据表中提到了55个字节。 Actual tests by vikky revealed that this might acutally be 60 bytes (leading to a maximum data length of 47 bytes). vikky的实际测试显示,这可能实际上是60个字节(导致最大数据长度为47个字节)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM