如何保护包含 NDEF 消息的 Mifare Classic 标签?
使用 Android 保护 Mifare Ultralight 很容易,有一个 Ndef.makeReadonly()
方法。但 Mifare Classic 标签返回 Ndef.canMakeReadonly() == false
,因此这是不可能的。我听说可以使这样的标签只读,或者至少通过设置 a 或 b 键来使用密钥保护它。
MifareClassic 技术中有这种方法: authenticateSectorWithKeyB(intectorIndex, byte[] key)
有谁知道这是否可以用于使 mifare classic 标签上的 ndef 消息变为只读?或者我怎样才能将 ndef 消息写入标签,然后以某种方式锁定它以防止新的写入?
It's easy to protect a Mifare Ultralight with Android, there is the Ndef.makeReadonly()
method for that. But Mifare Classic tags return Ndef.canMakeReadonly() == false
, so this is not possible. I heard that one can make such a tag readonly or at least protect it with a key by setting the a or b keys.
There's this methid in MifareClassic tech: authenticateSectorWithKeyB(int sectorIndex, byte[] key)
Does anyone know if this can be used to make a ndef message on a mifare classic tag read-only? Or how else could I write a ndef message onto the tag and then somehow lock it against new writes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以使用身份验证方法。
首先,这是 Mifare Classic 4k 的数据表:
http://www.nxp.com /documents/data_sheet/MF1S703x.pdf
对您来说重要的章节是:
简而言之,写保护的工作原理如下:
Mifare Classic 被分为每个 4*16 字节的扇区(仅适用于前 1k 左右......较高的块有点不同,但这在规范中记录)。这 64 个字节中的 16 个用于身份验证/保护。对于卡的每个扇区,您执行以下操作:
Mifare Classics 的 KeyA 值为:
适用于未格式化的出厂新卡。
对于卡的第一个扇区
对于所有其他部门。
重要提示:您必须将原始 KeyA 密钥写回到卡中。如果这些键与上面显示的键不同,则该卡将不再符合 Ndef 标准。
对于修改的访问位,您有两种选择:
仅启用 KeyA 的读取。这将为您提供无法撤销的 100% 写保护。
启用 KeyA 的读取和 KeyB 的读取/写入。还在 KeyB 中存储一个秘密密钥。这将允许您使用您的秘密 KeyB 来验证写保护扇区,以取消对卡的保护。
背景:Android 将仅使用上面显示的 KeyA 值来验证 Ndef 格式的标签。 Ndef 检测代码从不单独尝试 KeyB,因此您可以将 KeyB 用于您自己的目的。
It is possible using the authenticate methods.
First, here is the datasheet for the Mifare Classic 4k:
http://www.nxp.com/documents/data_sheet/MF1S703x.pdf
The important chapters for your are:
In short a write protection works like this:
The Mifare Classic is divided into sectors of 4*16 bytes each (only applies to the first 1k or so... the higher blocks are a bit different, but thats documented in the spec). Of these 64 bytes 16 are used for authentication/protection. For each sector of the card you do the following:
The KeyA values for Mifare Classics are:
For unformatted, factory fresh cards.
For the first sector of the card
For all other sectors.
Important: You have to write back the original KeyA keys to the card. If these differ from the keys shown above the card will not be Ndef compliant anymore.
For the modified access bits you have two choices:
Only enable Read for KeyA. This will give you a 100% write protection that can't be revoked.
Enable Read for KeyA and Read/Write for KeyB. Also store a secret key in KeyB. This will allow you to authenticate a write protected sector using your secret KeyB to unprotect the card.
Background: Android will only authenticate a Ndef formatted tag using the KeyA values shown above. The Ndef detection code never tries KeyB on its own, therefore you can use KeyB for your own purposes.