Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write to password protected NFC #659

Open
ShriramKhandbahale opened this issue Feb 16, 2024 · 6 comments
Open

Write to password protected NFC #659

ShriramKhandbahale opened this issue Feb 16, 2024 · 6 comments

Comments

@ShriramKhandbahale
Copy link

ShriramKhandbahale commented Feb 16, 2024

In the Android NFC Tools app, there is an option to set a password for the NFC to make it write-protected, and next time I try to write to that NFC it gives a write error, so If I want to update it, I have to remove the password by providing it my old password and then write the data to it and then again protect it with the password.

but now when I try to write it with web nfc api, It gives me the write error, is there a way I can write to a write-protected nfc through web nfc api by providing it the password that I set from NFC tools app?

I wanted to write to the nfc by providing it my old password --> set new data in the nfc --> and again write-protect it with the password. (is it possible with web NFC api ?)

@beaufortfrancois
Copy link
Collaborator

I'm not familiar with how the NFC Tools app works. It would help us understand how/if we can make Web NFC works better if we knew how write-protected nfc tags with this app.

@dtinth
Copy link

dtinth commented Apr 10, 2024

The NFC tools app has these 2 menu items:

  • Set password
  • Remove password

Screenshot_20240410_173938_NFC Tools

The Set password, when pressed, asks for a password. Then it makes the NFC tag read-only (writes will fail). It is similar to locking the NFC tag with .makeReadOnly() but it is temporary. If you can provide the same password to the Remove password function, the unlocks the NFC, making it read-write.

Therefore, I'd suggest the following API (name should be changed but you get the idea):

NDEFReader.makeReadOnlyWithUnlockPassword('the-unlock-password') // => Promise

NDEFReader.unlockWithPassword('the-unlock-password') // => Promise

@dtinth
Copy link

dtinth commented Apr 11, 2024

From my additional research, it seems that this Password feature is not NFC Forum standard, but is an additional feature by some NFC manufacturers. For example, here’s the C code for setting up password in NTAG213/215/216 tags, and the related data sheet.

See also, https://stackoverflow.com/a/36592599/559913

@wakdev
Copy link

wakdev commented Jun 28, 2024

The password feature is not a NFC Forum standard but a NTAG21x feature. You can check the datasheet to see how it's works in detail. In NFC Tools, we use the first bytes of the MD5 hash of your password. Because NTAG chips requires a 4 bytes password. For non-tech-savvy users, we decided to ask for a simple text password instead of four Hex values (or more depending of the chips type).

@wakdev
Copy link

wakdev commented Jun 28, 2024

The password feature is not a NFC Forum standard but a chip related feature. You can check the datasheet to see how it's works in detail. In NFC Tools, we use the first bytes of the MD5 hash of your password. Because, as an example, NTAG chips requires a 4 bytes password. For non-tech-savvy users, we decided to ask for a simple text password instead of four Hex values (or more depending of the chips type).

@beaufortfrancois
Copy link
Collaborator

beaufortfrancois commented Jul 1, 2024

Thank you @wakdev!

Since it's not a NFC Forum Standard, I believe we won't be implementing this in Web NFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants