简体   繁体   English

如何永久锁定MIFARE Ultralight C标签中的特定数据页?

[英]How do I permanently lock specific data pages in a MIFARE Ultralight C tag?

I have successfully written some data on data pages 30 to 38. 我已经成功地在数据页30到38上写了一些数据。

After that I want to lock those pages in order to prevent further writing. 之后我想锁定那些页面以防止进一步写入。 The write lock should be permanent, so even if someone knows the authentication key, they should not be able to write to those pages. 写锁定应该是永久性的,因此即使有人知道验证密钥,它们也不应该写入这些页面。

As far as I have understood the datasheet, I have to write some bits on OTP pages. 据我所知,数据表,我必须在OTP页面上写一些位。 But I do not fully understand what command I have to send for locking specifically pages 30 to 38. 但我不完全理解我必须发送什么命令才能锁定第30至38页。

Can somebody help me in identifying the command that needs to be sent to the card? 有人可以帮我识别需要发送到卡的命令吗? My thinking is that I have to write F0 on page 40. However, this might also make pages 28, 29 and 39 locked and, hence, unusable. 我的想法是我必须在第40页写F0。但是,这也可能使第28,29和39页被锁定,因此无法使用。

How to permanently lock pages 30 to 38? 如何永久锁定30到38页?

In order to set the lock-bits that include pages 30 to 38, you would need to set the lock-bits that are located in bits 5, 6, and 7 of byte 0 of page 40. You can do this with the WRITE command. 为了设置包含第30页到第38页的锁定位,您需要设置位于第40页的字节0的第5,6和7位的锁位。您可以使用WRITE命令执行此操作。 For lock bits (or any OTP pages) this command will only program those bits that are set to '1' in the data parameter of the command (essentially resulting into a logical OR). 对于锁定位(或任何OTP页面),此命令将仅编程在命令的数据参数中设置为“1”的那些位(实质上导致逻辑OR)。 Note that the WRITE command always takes one full page (ie 4 bytes) as its data parameter: 请注意,WRITE命令总是需要一整页(即4个字节)作为其数据参数:

byte[] result = nfcA.transceive(new byte[] {
    (byte)0xA2,  /* CMD = WRITE */
    (byte)0x28,  /* PAGE = 40   */
    (byte)0xE0, (byte)0x00, (byte)0x00, (byte)0x00  /* DATA = lock pages 28..39 */
});

But hey, I did not want to lock pages 28, 29, and 39! 但是,嘿,我不想锁定第28,29和39页! How can I only lock pages 30 to 38? 我怎么只能锁定第30页到38?

Unfortunately, you can't! 不幸的是,你不能! The locking mechanism of MIFARE Ultralight C for pages 16 to 39 is organized in blocks of 4 pages. MIFARE Ultralight C对第16页至第39页的锁定机制以4页为单位进行组织。 Hence, you can only lock the following groups of 4 pages: 因此,您只能锁定以下4页的组:

  • Pages 16..19 第16..19页
  • Pages 20..23 第20..23页
  • Pages 24..27 第24..27页
  • Pages 28..31 第28..31页
  • Pages 32..35 第32..35页
  • Pages 36..39 第36..39页

What does the block locking bit do? 块锁定位有什么作用?

The block locking bit sets the write protection for bits within the lock page. 块锁定位为锁定页面内的位设置写保护。 So for instance if the block locking bit for pages 28 to 39 is set to '1', this means that you cannot change the state of the three lock-bits for these pages. 因此,例如,如果第28到39页的块锁定位设置为“1”,则意味着您无法更改这些页面的三个锁定位的状态。 Hence, if you set the lock-bit for pages 28 to 31 but leave the lock-bits for pages 32 to 35 and 36 to 39 unset, and then set the block locking bit, you can no longer activate the write protection for pages 32 to 39. 因此,如果您设置第28页至第31页的锁定位但是未设置第32至35页和第36至39页的锁定位,然后设置块锁定位,则无法再激活第32页的写保护到39岁。

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

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