Skip to content

Commit

Permalink
Compatability improvement when using 7816-4 chaining.
Browse files Browse the repository at this point in the history
Some FIDO implementations specify a requested length of zero, which
means 256 bytes. This implementation was interpreting that as a literal
zero.

This change makes is so that such FIDO platform implementations can
still use these authenticators.
  • Loading branch information
darconeous committed Mar 22, 2020
1 parent 554b071 commit 8fe3d48
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/ledger/u2f/U2FApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ private void handleGetData(APDU apdu) throws ISOException {
}
short requestedSize = apdu.setOutgoing();
short outOffset = (short)0;

if (requestedSize == 0) {
requestedSize = (short)buffer.length;
if (requestedSize > 0xFF) {
requestedSize = 256;
}
}

if (scratch[SCRATCH_TRANSPORT_STATE] == TRANSPORT_NOT_EXTENDED) {
short dataSize = Util.getShort(scratch, SCRATCH_NONCERT_LENGTH);
short blockSize = ((short)(dataSize - currentOffset) > requestedSize ? requestedSize : (short)(dataSize - currentOffset));
Expand Down

0 comments on commit 8fe3d48

Please sign in to comment.