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

TestLogin & static key location map #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

f-israel
Copy link
Contributor

@f-israel f-israel commented Sep 29, 2018

Had some trouble when changing key (A or B doesn't matter) while keeping same instance/session. Even with calling abort() directly before this one didn't fix. I couldn't track down the error but stumbled over one case while searching for workaround:
MiFareCard inherits IDisposable which enables the following usage:
using(MiFareCard mCard = smartcard.e.SmartCard.CreateMiFareCard()){ }

Using this approach multiple times (for example as workaround for error named above) generated multiple keyLocationMaps for same underlying card reader. Without fully disposing the smartcard object the reader won't get in sync again. Just chaning it to static should do the trick.

While adding trace methodes I added TestLogin(...). As my project strongly depends on knowing which keytype-key combination was successful the integrated key failover (method Login(...) in MiFareStandardCardReaderBase) wasn't the right. The most of the method is plain copy&paste based on Login() just without key determination logic.

Hope this will be usefull for others as well.

f-israel and others added 3 commits September 29, 2018 15:45
@@ -22,9 +22,9 @@ abstract class MiFareStandardCardReaderBase : ICardReader, IDisposable

private Dictionary<SectorKey, byte[]> keyMap = new Dictionary<SectorKey, byte[]>();

private byte nextKeySlot;
private static byte nextKeySlot;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can't be static since it wouldn't apply to a different card if placed under the reader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry didn't think about this case. Maybe instead it would make sense to just remove the IDisposable interface? Or use as static and clear when card's removed?

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

Successfully merging this pull request may close these issues.

2 participants