From b5567df6746871b6778c08ee4aeaa2f8da2ba750 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Fri, 30 Nov 2018 14:12:27 +0100 Subject: [PATCH] patches: support_extended_length APDU patch --- patches/support_extended_length.patch | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 patches/support_extended_length.patch diff --git a/patches/support_extended_length.patch b/patches/support_extended_length.patch new file mode 100644 index 0000000..68b5984 --- /dev/null +++ b/patches/support_extended_length.patch @@ -0,0 +1,44 @@ +diff --git a/src/fr/anssi/smartpgp/Constants.java b/src/fr/anssi/smartpgp/Constants.java +index b3c0f80..2ee1107 100644 +--- a/src/fr/anssi/smartpgp/Constants.java ++++ b/src/fr/anssi/smartpgp/Constants.java +@@ -30,7 +30,7 @@ public final class Constants { + protected static final short INTERNAL_BUFFER_MAX_LENGTH = + (short)0x500; + +- protected static final short APDU_MAX_LENGTH = (short)256; ++ protected static final short APDU_MAX_LENGTH = (short)0x400; + + protected static final byte[] KEY_DERIVATION_FUNCTION_DEFAULT = { + (byte)0x81, (byte)0x01, (byte)0x00 +@@ -147,7 +147,7 @@ public final class Constants { + (byte)0x73, /* card capabilities */ + (byte)0xC0, /* 1st byte: "methods supported" see ISO 7816-4 */ + (byte)0x01, /* 2nd byte: "data coding byte" idem */ +- (byte)0x80, /* 3rd byte: command chaining (not extended length by default as all readers do not support them...) */ ++ (byte)0xC0, /* 3rd byte: command chaining + extended length */ + + (byte)0x05, /* status indicator byte : operational state */ + (byte)0x90, /* SW1 */ +diff --git a/src/fr/anssi/smartpgp/SmartPGPApplet.java b/src/fr/anssi/smartpgp/SmartPGPApplet.java +index c47870f..78d446d 100644 +--- a/src/fr/anssi/smartpgp/SmartPGPApplet.java ++++ b/src/fr/anssi/smartpgp/SmartPGPApplet.java +@@ -25,7 +25,7 @@ import javacard.security.*; + import javacardx.apdu.*; + import javacardx.crypto.*; + +-public final class SmartPGPApplet extends Applet { ++public final class SmartPGPApplet extends Applet implements ExtendedLength { + + private final Persistent data; + +@@ -104,7 +104,7 @@ public final class SmartPGPApplet extends Applet { + short blen = apdu.setIncomingAndReceive(); + + final short lc = apdu.getIncomingLength(); +- final short offcdata = ISO7816.OFFSET_CDATA; ++ final short offcdata = apdu.getOffsetCdata(); + + short off = transients.chainingInputLength(); +