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

Can we add password protection on write on NFC tag? #11

Open
GauravCreed opened this issue Nov 14, 2022 · 11 comments
Open

Can we add password protection on write on NFC tag? #11

GauravCreed opened this issue Nov 14, 2022 · 11 comments

Comments

@GauravCreed
Copy link

Hi @romellfudi

Can we add password protection on NFC write tag? i want develop like NFC tag only write from my application, not other application can write on that NFC tag,

yes but read NFC can possible on all other applications.
Thanks(_)

@romellfudi
Copy link
Owner

Yes, it could be possible pass a pin into nfcA by using tranceive(command) instead of writeNdefMessage(message)

Please see the following page:
https://stackoverflow.com/q/73222079

@romellfudi
Copy link
Owner

romellfudi commented Nov 15, 2022

Can you send a pull request with the feature?

@GauravCreed
Copy link
Author

Hi @romellfudi

I am the same user which is comment in this stackoverflow link which you posted,

I already follow your instruction for write data with password security, but unfortunately I lost the Nfc tag, I am not able to write again on this tag, only we can read this tag.

code for write data into tag with set Tag Lock
byte[] result = ultralight.transceive(new byte[]{ (byte)0xA2, // Command: WRITE (byte)0x02, // Address: page 0x02 (2) (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF // Data: set bytes 2-3 to all '1' });

code for write data into tag with set Tag UnLock
byte[] result = ultralight.transceive(new byte[]{ (byte)0xA2, // Command: WRITE (byte)0x02, // Address: page 0x02 (2) (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 });

am i did right or wrong?
Thanks.

@romellfudi
Copy link
Owner

Please attach the log and video

@GauravCreed
Copy link
Author

@romellfudi
Copy link
Owner

@GauravCreed I've said your error log

1 similar comment
@romellfudi
Copy link
Owner

@GauravCreed I've said your error log

@GauravCreed
Copy link
Author

android.nfc.TagLostException: Tag was lost.
at android.nfc.TransceiveResult.getResponseOrThrow(TransceiveResult.java:48)
at android.nfc.tech.BasicTagTechnology.transceive(BasicTagTechnology.java:151)
at android.nfc.tech.MifareUltralight.writePage(MifareUltralight.java:193)
at com.nfctagsecurity.security.WriteNFCActivity.writeMethodMifareUltralight(WriteNFCActivity.java:89)
at com.nfctagsecurity.security.WriteNFCActivity.onNewIntent(WriteNFCActivity.java:47)
at android.app.Activity.performNewIntent(Activity.java:7162)
at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1431)
at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1450)
at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:3232)
at android.app.ActivityThread.performNewIntents(ActivityThread.java:3248)
at android.app.ActivityThread.handleNewIntent(ActivityThread.java:3265)
at android.app.servertransaction.NewIntentItem.execute(NewIntentItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

@romellfudi
Copy link
Owner

@romellfudi
Copy link
Owner

romellfudi commented Nov 26, 2022

Did you ask to @MichaelsPlayground, what happens when you run the activity created by him when passing your NFC tag

@MichaelsPlayground
Copy link

@GauravCreed: In my comment to your SO question I kindly asked to modify my activity ("https://github.com/MichaelsPlayground/NfcNfcaAuthProtection/blob/master/app/src/main/java/de/androidcrypto/nfcnfcaauthprotection/SetWriteProtectionActivity.java") to run with a NTAG213 (I don't own one, so I cannot test it).

Have a look at the official datasheet for NTAG 213/215/216 to find out which addresses should have written to write a password protection to your tag.

You are using the "MifareUltralight" class, why don't you use the "NfcA" class directly ?

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

3 participants