From f1df66711b7e81159ac0a998f2764efb55fc468d Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 4 Nov 2010 10:14:12 +0000 Subject: e-card sig cert git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@818 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../test/java/at/gv/egiz/pkcs15test/PKCS15Test.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'smccTest/src') diff --git a/smccTest/src/test/java/at/gv/egiz/pkcs15test/PKCS15Test.java b/smccTest/src/test/java/at/gv/egiz/pkcs15test/PKCS15Test.java index 324ec1d4..a80210c5 100644 --- a/smccTest/src/test/java/at/gv/egiz/pkcs15test/PKCS15Test.java +++ b/smccTest/src/test/java/at/gv/egiz/pkcs15test/PKCS15Test.java @@ -8,8 +8,10 @@ import iaik.asn1.ASN1Object; import iaik.asn1.CodingException; import iaik.asn1.DerCoder; //import iaik.security.provider.IAIK; +import iaik.security.ecc.provider.ECCProvider; import iaik.security.provider.IAIK; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.Charset; @@ -68,6 +70,7 @@ public class PKCS15Test { public void setUp() throws NoSuchAlgorithmException, CardException { IAIK.addAsJDK14Provider(); + ECCProvider.addAsProvider(); System.out.println("create terminalFactory...\n"); TerminalFactory terminalFactory = TerminalFactory.getInstance("PC/SC", null); @@ -336,6 +339,24 @@ public class PKCS15Test { System.out.println(" -> " + toString(resp.getBytes()) + "\n"); System.out.println(new TLVSequence(new TLVSequence(resp.getData()).getValue(0x6f))); + System.out.println("SELECT CERTIFICATE"); + cmdAPDU = new CommandAPDU(0x00, 0xA4, 0x02, 0x00, new byte[] { (byte) 0xc0, (byte) 0x00 }, 256); + System.out.println(" cmd apdu " + toString(cmdAPDU.getBytes())); + resp = basicChannel.transmit(cmdAPDU); + System.out.println(" -> " + toString(resp.getBytes()) + "\n"); + + X509Certificate certificate = null; + try { + System.out.println("READ cert?"); + CertificateFactory certificateFactory = CertificateFactory.getInstance("X509"); + certificate = (X509Certificate) certificateFactory.generateCertificate(ISO7816Utils.openTransparentFileInputStream(basicChannel, -1)); +// certificate = certificateFactory.generateCertificate(new BASE64DecoderStream(new ByteArrayInputStream(CERT.getBytes()))); +// System.out.println("certificate: \n" + toString(certificate.getEncoded())); + System.out.println("certificate: \n" + certificate); + } catch (CertificateException e) { + e.printStackTrace(); + } + byte[] fid = new byte[] {(byte) 0x00, (byte) 0x30 }; System.out.println("SELECT EF FID=" + toString(fid)); cmdAPDU = new CommandAPDU(0x00, 0xA4, 0x02, 0x04, fid, 256); -- cgit v1.2.3