From a9334172e2222b8df44ae82b70336a446ba1c73c Mon Sep 17 00:00:00 2001 From: mcentner Date: Wed, 14 Jul 2010 18:25:49 +0000 Subject: Fixed bug MOCCA-734. Fixed support for eCard G3b (infobox container). git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@769 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- smcc/src/main/java/at/gv/egiz/smcc/EstEIDCard.java | 10 +++++----- smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java | 13 +++++++++++-- .../test/ecard/ECardG3InfoboxContainerEncryptedTest.xml | 1 + .../gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerTest.xml | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/smcc/src/main/java/at/gv/egiz/smcc/EstEIDCard.java b/smcc/src/main/java/at/gv/egiz/smcc/EstEIDCard.java index 21028a8a..9d889d79 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/EstEIDCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/EstEIDCard.java @@ -189,23 +189,23 @@ public class EstEIDCard extends AbstractSignatureCard { protected void execSELECT_MF(CardChannel channel) throws SignatureCardException, CardException { - execSELECT(channel, 0x00, MF); + execSELECT(channel, 0x00, 0x04, MF); } protected void execSELECT_DF(CardChannel channel, byte[] fid) throws SignatureCardException, CardException { - execSELECT(channel, 0x01, fid); + execSELECT(channel, 0x01, 0x04, fid); } protected void execSELECT_EF(CardChannel channel, byte[] fid) throws SignatureCardException, CardException { - execSELECT(channel, 0x02, fid); + execSELECT(channel, 0x02, 0x04, fid); } - protected void execSELECT(CardChannel channel, int p1, byte[] fid) + protected void execSELECT(CardChannel channel, int p1, int p2, byte[] fid) throws SignatureCardException, CardException { - CommandAPDU command = new CommandAPDU(0x00, 0xA4, p1, 0x0C, fid, 256); + CommandAPDU command = new CommandAPDU(0x00, 0xA4, p1, p2, fid, 256); ResponseAPDU resp = channel.transmit(command); diff --git a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java index f092b3fc..7eb86601 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java @@ -90,7 +90,9 @@ public class STARCOSCard extends AbstractSignatureCard implements PINMgmtSignatu (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00, (byte) 0x18, (byte) 0x01 }; - public static final byte[] EF_INFOBOX = new byte[] { (byte) 0xef, (byte) 0x01 }; + public static final byte[] EF_INFOBOX_LEGACY = new byte[] { (byte) 0xef, (byte) 0x01 }; + + public static final byte[] EF_INFOBOX = { (byte) 0xc0, (byte) 0x02 }; public static final byte[] AID_SVSIG_CERT = new byte[] { (byte) 0xd0, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00, @@ -232,7 +234,14 @@ public class STARCOSCard extends AbstractSignatureCard implements PINMgmtSignatu // SELECT application execSELECT_AID(channel, AID_INFOBOX); // SELECT file - execSELECT_FID(channel, EF_INFOBOX); + try { + // the file identifier has changed with version G3b + execSELECT_FID(channel, EF_INFOBOX); + } catch (FileNotFoundException e) { + // fallback for < G3b + log.debug("Not an eCard G3b, falling back to legacy FID for EF_Infobox."); + execSELECT_FID(channel, EF_INFOBOX_LEGACY); + } InfoboxContainer infoboxContainer = null; while (infoboxContainer == null) { diff --git a/smcc/src/test/resources/at/gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerEncryptedTest.xml b/smcc/src/test/resources/at/gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerEncryptedTest.xml index 951d903a..963f7ebf 100644 --- a/smcc/src/test/resources/at/gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerEncryptedTest.xml +++ b/smcc/src/test/resources/at/gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerEncryptedTest.xml @@ -31,6 +31,7 @@ + diff --git a/smcc/src/test/resources/at/gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerTest.xml b/smcc/src/test/resources/at/gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerTest.xml index 0d872ffb..357f1fd8 100644 --- a/smcc/src/test/resources/at/gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerTest.xml +++ b/smcc/src/test/resources/at/gv/egiz/smcc/test/ecard/ECardG3InfoboxContainerTest.xml @@ -31,6 +31,7 @@ + -- cgit v1.2.3