Skip to content

Instantly share code, notes, and snippets.

@benbenbenbenbenben
Created July 13, 2018 10:00
Show Gist options
  • Save benbenbenbenbenben/cfe31b2f6abb38bdf503b4679d783d9a to your computer and use it in GitHub Desktop.
Save benbenbenbenbenben/cfe31b2f6abb38bdf503b4679d783d9a to your computer and use it in GitHub Desktop.
package de.tsenger.u2f;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
public class AcosJPatch {
public static short getOffsetCdata(APDU apdu) {
byte[] buffer = apdu.getBuffer();
short offset = apdu.getOffsetCdata();
if (offset == ISO7816.OFFSET_EXT_CDATA) {
try {
short lc = apdu.getIncomingLength();
short blc = (short)(0x00FF & buffer[ISO7816.OFFSET_LC]);
if (lc <= 0xFF) {
if (blc == lc) {
return ISO7816.OFFSET_CDATA;
}
}
} finally {
// nothing to do
}
return ISO7816.OFFSET_EXT_CDATA;
} else {
return ISO7816.OFFSET_CDATA;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment