From 4fbafe513bf1bc28aecdab5d26d37693a586a0ae Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Mon, 10 Jan 2022 16:16:38 +0100 Subject: [PATCH] Fix possible implicit extended length usage support --- patches/support_extended_length.patch | 31 ----------------------- src/fr/anssi/smartpgp/Constants.java | 2 +- src/fr/anssi/smartpgp/SmartPGPApplet.java | 5 ++-- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/patches/support_extended_length.patch b/patches/support_extended_length.patch index 5f19483..746cfbf 100644 --- a/patches/support_extended_length.patch +++ b/patches/support_extended_length.patch @@ -2,15 +2,6 @@ diff --git a/src/fr/anssi/smartpgp/Constants.java b/src/fr/anssi/smartpgp/Consta 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 @@ -149,7 +149,7 @@ public final class Constants { (byte)0x73, /* card capabilities */ (byte)0xC0, /* 1st byte: "methods supported" see ISO 7816-4 */ @@ -20,25 +11,3 @@ index b3c0f80..2ee1107 100644 (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(); - diff --git a/src/fr/anssi/smartpgp/Constants.java b/src/fr/anssi/smartpgp/Constants.java index c0b42e2..1cdd733 100644 --- a/src/fr/anssi/smartpgp/Constants.java +++ b/src/fr/anssi/smartpgp/Constants.java @@ -27,7 +27,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 diff --git a/src/fr/anssi/smartpgp/SmartPGPApplet.java b/src/fr/anssi/smartpgp/SmartPGPApplet.java index 1a17103..350a7e7 100644 --- a/src/fr/anssi/smartpgp/SmartPGPApplet.java +++ b/src/fr/anssi/smartpgp/SmartPGPApplet.java @@ -23,8 +23,9 @@ package fr.anssi.smartpgp; import javacard.framework.*; import javacard.security.*; import javacardx.crypto.*; +import javacardx.apdu.ExtendedLength; -public final class SmartPGPApplet extends Applet { +public final class SmartPGPApplet extends Applet implements ExtendedLength { private final Common common; private final Persistent data; @@ -100,7 +101,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();