johnnyb / ntag424-java

A Java library for the NXP NTAG 424 DNA chip
MIT License
21 stars 3 forks source link

FileSettings decodeFromData(byte[] data): SDM Access Rights #16

Open bobvann opened 1 month ago

bobvann commented 1 month ago

FileSettings decodeFromData(byte[] data) has wrong bytes order.

It looks like SDM access rights bytes are inverted

Correct is the following:

settings.sdmSettings.sdmMetaReadPerm = ByteUtil.leftNibble(sdmAccessRights2); settings.sdmSettings.sdmFileReadPerm = ByteUtil.rightNibble(sdmAccessRights2); settings.sdmSettings.sdmReadCounterRetrievalPerm = ByteUtil.rightNibble(sdmAccessRights1);

AndroidCrypto commented 1 month ago

Dear Roberto, Thanks for clarification and support. I launched a similar issue in https://github.com/johnnyb/ntag424-java/issues/5 (FileSettings.encodeToData() is returning to few data) as I tried to "save" the existing file settings in a byte array and later tried to restore the file with the exported/saved file settings. This failed as the export had too few data and the import didn't have enough data so it failed as well. It would be perfect if you could find a solution for both cases, thanks in advance. I know that Jon will be happy to get a "ready to implement" (= copy&paste) solution for the next release. Thanks in advance, Michael