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

Implement lockWithPin #5

Open
gjuchault opened this issue May 15, 2018 · 2 comments
Open

Implement lockWithPin #5

gjuchault opened this issue May 15, 2018 · 2 comments

Comments

@gjuchault
Copy link
Contributor

gjuchault commented May 15, 2018

Hello,

You implemented unlockWithPin, and I was wondering if you were opened to a lockWithPin method.

Some good links for it:
https://stackoverflow.com/questions/44395283/how-to-set-and-unset-password-on-a-mifare-ultralight-ev1-tag
https://stackoverflow.com/questions/22719465/ntag212-mifare-ultralight-with-authentication

Unlock

send: Ox1B 0xPIN1 0xPIN2 0xPIN3 0xPIN4
receive: 0xPACK1 0xPACK2
compare PACK1 and PACK2 with values given in lock (or don't compare)

Lock

  1. Write PIN

PAGE:
NTAG212 = page 39
MF0UL11 = page 12
MF0UL21 = page 27

send: 0xA2 0xPAGE 0xPIN1 0xPIN2 0xPIN3 0xPIN4

  1. Write PIN ACK (PACK)

PAGE:
NTAG212 = page 40
MF0UL11 = page 13
MF0UL21 = page 28

send: 0xA2 0xPAGE 0xPACK1 0xPACK2 0x00 0x00

  1. Write protection wanted (PROT)

Protection can be set to 0 (PIN needed for write operations) or 1 (PIN needed for read or write operations)

PAGE:
NTAG212 = page 38, byte 0, bit 7
MF0UL11 = page 11, byte 0, bit 7
MF0UL21 = page 26, byte 0, bit 7

send: 0x30 0xPAGE (get the complete page to only modify wanted bits)
recieve: 0xRES1 0xRES2 0xRES3 0xRES4

ACCESS = 0xRES1 & 0x07F # PIN needed for write
ACCESS = ACCESS | 0x80 # PIN needed for read

send: 0xA2 0xPAGE 0xACCESS 0xRES2 0xRES3 0xRES4

  1. Write first page being protected (AUTH0)

PAGE:
NTAG212 = page 37, byte 3
MF0UL11 = page 10, byte 3
MF0UL21 = page 25, byte 3

send: 0x30 0xPAGE (get the complete page to only modify wanted bits)
receive: 0xRES1 0xRES2 0xRES3 0xRES4 ...
send: 0xA2 0xPAGE 0xRES1 0xRES2 0xRES3 0xAUTH0

@RoopeHakulinen
Copy link
Owner

Hey @gjuchault and thanks for the issue. Sorry it took quite some time to react.

I took a look into this and it seemed doable so I did a basic implementation. Could you please review the PR (#6) carefully and test if it works at all? I don't have any tags to try this out. The version should be installable with

npm install cordova-plugin-mifare-ultralight@beta

The documentation can be found in the README of the branch implementing the feature.

Let me know how it is :)

@gjuchault
Copy link
Contributor Author

@RoopeHakulinen Hi that's so cool ! I'm a bit busy until 2th of July, I'll check around this date :)

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

2 participants