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

[remote-reader] Fix ATR for 14443 Type B cards #251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix MBLI calculation
  • Loading branch information
mildsunrise committed Mar 14, 2023
commit 444ab52691eef0d0e0d165c370a16ff48f30c302
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,14 @@ public byte[] getTypeBHistoricalBytes() {
return historicalBytes;
}

private static final int[] ATQB_FRAME_SIZES = { 16, 24, 32, 40, 48, 64, 96, 128, 256 };

public static Byte translateToMbli(byte[] protocolInfo, int maxUnit) {
// retrieve maximum frame size from protocol info
int maxFrameSize = (protocolInfo[1] >> (byte)4) & 0xF;
if (maxFrameSize == 0)
return null;
int maxFrameSizeCode = (protocolInfo[1] >> (byte)4) & 0xF;
if (maxFrameSizeCode >= ATQB_FRAME_SIZES.length)
return null; // values 9..15 are RFU
int maxFrameSize = ATQB_FRAME_SIZES[maxFrameSizeCode];

// there's 3 to 5 bytes of overhead in a buffer.
int predictedMbl = maxUnit + 5; // (can be up to 2 bytes larger)
Expand Down