在MIFARE Classic中更改扇区的身份验证密钥 [英] Changing authentication key of a sector in MIFARE Classic

查看:697
本文介绍了在MIFARE Classic中更改扇区的身份验证密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Evan在此页面中的回答,更改扇区的身份验证密钥,我们需要在该扇区的第4块(最终块)中覆盖密钥.

According to Evan's answer in this page, in order to change the authentication key of a sector we need to overwrite the key in the 4th block (final block) of that sector.

默认密钥始终为"FF FF FF FF FF FF",这是一个六字节的密钥.现在,如果我尝试使用write方法进行更改> pi-rc522库,它会引发一个Index Error,因为每个块必须为16个字节,但是身份验证密钥只有6个字节长.

The default key is always 'FF FF FF FF FF FF' which is a six bytes key. Now if I try to change it using the write method from the pi-rc522 library, it raises an Index Error because each block has to be 16 bytes, but the authentication key is only 6 bytes long.

我要去哪里错了?

设备为RC522,我在Raspberry Pi 3上使用Raspbian.

The device is RC522 and I am using Raspbian on Raspberry Pi 3.

推荐答案

您只能在MIFARE Classic卡上写入整个块.因此,您需要编写完整的扇区预告片,而不仅仅是密钥A(前6个字节).

You can only write whole blocks on MIFARE Classic cards. Consequently, you need to write the complete sector trailer and not just key A (the first 6 bytes).

完整的部门预告片如下所示:

The complete sector trailer looks like this:


+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
| KEY A                       | ACCESS BITS  | GP | KEY B                       |
+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+

如果您只希望使用键A来读取/写入扇区的所有块(即不使用键B),则可以使用访问位FF 07 80.因此,如果要将键A设置为11 22 33 44 55 66,则可以将以下值用于尾部块:

If you want all blocks of the sector to be readable/writable with key A only (i.e. no key B is used), you could used the access bits FF 07 80. Thus, if you want to set key A to 11 22 33 44 55 66, you could use this value for the trailer block:


+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
| KEY A                       | ACCESS BITS  | GP | KEY B                       |
| 11   22   33   44   55   66 | FF   07   80 | 00 | 00   00   00   00   00   00 |
+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+

最后,请注意您写到扇区预告片中的内容.访问位受冗余机制保护.如果将无效的访问位写入尾部块,则整个扇区将被不可逆转地阻塞.

Finally, be careful with what you write into the sector trailer. The access bits are protected by a redundancy mechanism. If you write invalid access bits into the trailer block, the whole sector is irreversibly blocked.

这篇关于在MIFARE Classic中更改扇区的身份验证密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆