summaryrefslogtreecommitdiff
path: root/smcc/src/test/java/at
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-11-11 15:51:08 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-11-11 15:51:08 +0000
commit68941b57df2caeead67a5bede2ef5a635d07db32 (patch)
tree78c93c71a20b4775af3991f4395c2267cc39fab8 /smcc/src/test/java/at
parentcaca721368d8c24559b1cd5ea2018884b4874f6b (diff)
downloadmocca-68941b57df2caeead67a5bede2ef5a635d07db32.tar.gz
mocca-68941b57df2caeead67a5bede2ef5a635d07db32.tar.bz2
mocca-68941b57df2caeead67a5bede2ef5a635d07db32.zip
Added support for SHA-256 and partial support for e-card G3, BELPIC and Italian cards.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@540 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smcc/src/test/java/at')
-rw-r--r--smcc/src/test/java/at/gv/egiz/smcc/CardTest.java62
-rw-r--r--smcc/src/test/java/at/gv/egiz/smcc/acos/ACOSCardTest.java62
-rw-r--r--smcc/src/test/java/at/gv/egiz/smcc/starcos/STARCOSCardTest.java62
3 files changed, 78 insertions, 108 deletions
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java
index 2a55357d..b3bd07ab 100644
--- a/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java
+++ b/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java
@@ -18,6 +18,8 @@ package at.gv.egiz.smcc;
import static org.junit.Assert.*;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -178,13 +180,10 @@ public abstract class CardTest {
@Test(expected = CancelledException.class)
public void testSignSIGCancel() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
PINProvider pinProvider = new PINProvider() {
@Override
public char[] providePIN(PINSpec spec, int retries)
@@ -193,21 +192,19 @@ public abstract class CardTest {
}
};
- signatureCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.SECURE_SIGNATURE_KEYPAIR, pinProvider,
+ null);
}
@Test(expected = CancelledException.class)
public void testSignDECCancel() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
PINProvider pinProvider = new PINProvider() {
@Override
public char[] providePIN(PINSpec spec, int retries)
@@ -216,21 +213,19 @@ public abstract class CardTest {
}
};
- signatureCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.CERITIFIED_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = InterruptedException.class)
public void testSignSIGInterrrupted() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
PINProvider pinProvider = new PINProvider() {
@Override
public char[] providePIN(PINSpec spec, int retries)
@@ -239,21 +234,19 @@ public abstract class CardTest {
}
};
- signatureCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.SECURE_SIGNATURE_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = InterruptedException.class)
public void testSignDECInterrrupted() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
PINProvider pinProvider = new PINProvider() {
@Override
public char[] providePIN(PINSpec spec, int retries)
@@ -262,21 +255,19 @@ public abstract class CardTest {
}
};
- signatureCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.CERITIFIED_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = CancelledException.class)
public void testSignSIGConcurrent() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
final SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
PINProvider pinProvider = new PINProvider() {
@Override
public char[] providePIN(PINSpec spec, int retries)
@@ -294,21 +285,19 @@ public abstract class CardTest {
}
};
- signatureCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.SECURE_SIGNATURE_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = CancelledException.class)
public void testSignDECConcurrent() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
final SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
PINProvider pinProvider = new PINProvider() {
@Override
public char[] providePIN(PINSpec spec, int retries)
@@ -326,8 +315,9 @@ public abstract class CardTest {
}
};
- signatureCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.CERITIFIED_KEYPAIR,
+ pinProvider, null);
}
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/acos/ACOSCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/acos/ACOSCardTest.java
index 90bb039e..56d1e4b2 100644
--- a/smcc/src/test/java/at/gv/egiz/smcc/acos/ACOSCardTest.java
+++ b/smcc/src/test/java/at/gv/egiz/smcc/acos/ACOSCardTest.java
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -125,7 +127,7 @@ public abstract class ACOSCardTest extends CardTest {
@Test
public void testSignSIG() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
char[] pin = "123456".toCharArray();
@@ -134,11 +136,9 @@ public abstract class ACOSCardTest extends CardTest {
ACOSApplSIG appl = (ACOSApplSIG) card.getApplication(ACOSAppl.AID_SIG);
appl.setPin(ACOSApplSIG.KID_PIN_SIG, pin);
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
- byte[] signature = signatureCard.createSignature(hash,
- KeyboxName.SECURE_SIGNATURE_KEYPAIR, new TestPINProvider(pin));
+ byte[] signature = signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")),
+ KeyboxName.SECURE_SIGNATURE_KEYPAIR, new TestPINProvider(pin), null);
assertNotNull(signature);
@@ -147,7 +147,7 @@ public abstract class ACOSCardTest extends CardTest {
@Test
public void testSignDEC() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
char[] pin = "1234".toCharArray();
@@ -156,11 +156,9 @@ public abstract class ACOSCardTest extends CardTest {
ACOSApplDEC appl = (ACOSApplDEC) card.getApplication(ACOSAppl.AID_DEC);
appl.setPin(ACOSApplDEC.KID_PIN_DEC, pin);
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
- byte[] signature = signatureCard.createSignature(hash,
- KeyboxName.CERITIFIED_KEYPAIR, new TestPINProvider(pin));
+ byte[] signature = signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")),
+ KeyboxName.CERITIFIED_KEYPAIR, new TestPINProvider(pin), null);
assertNotNull(signature);
@@ -169,74 +167,66 @@ public abstract class ACOSCardTest extends CardTest {
@Test(expected = LockedException.class)
public void testSignSIGInvalidPin() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
TestPINProvider pinProvider = new TestPINProvider("000000".toCharArray());
- signatureCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.SECURE_SIGNATURE_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = LockedException.class)
public void testSignDECInvalidPin() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
TestPINProvider pinProvider = new TestPINProvider("0000".toCharArray());
- signatureCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.CERITIFIED_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = LockedException.class)
public void testSignSIGBlockedPin() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
CardEmul card = (CardEmul) signatureCard.getCard();
ACOSApplSIG appl = (ACOSApplSIG) card.getApplication(ACOSAppl.AID_SIG);
appl.setPin(ACOSApplSIG.KID_PIN_SIG, null);
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
TestPINProvider pinProvider = new TestPINProvider("000000".toCharArray());
- signatureCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.SECURE_SIGNATURE_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = LockedException.class)
public void testSignDECBlockedPin() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
CardEmul card = (CardEmul) signatureCard.getCard();
ACOSApplDEC appl = (ACOSApplDEC) card.getApplication(ACOSAppl.AID_DEC);
appl.setPin(ACOSApplDEC.KID_PIN_DEC, null);
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
TestPINProvider pinProvider = new TestPINProvider("0000".toCharArray());
- signatureCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.CERITIFIED_KEYPAIR,
+ pinProvider, null);
}
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/starcos/STARCOSCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/starcos/STARCOSCardTest.java
index 89e2ca65..b7dc9a0c 100644
--- a/smcc/src/test/java/at/gv/egiz/smcc/starcos/STARCOSCardTest.java
+++ b/smcc/src/test/java/at/gv/egiz/smcc/starcos/STARCOSCardTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -147,7 +149,7 @@ public class STARCOSCardTest extends CardTest {
@Test
public void testSignSichereSignatur() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
char[] pin = "123456".toCharArray();
@@ -156,11 +158,9 @@ public class STARCOSCardTest extends CardTest {
STARCOSApplSichereSignatur appl = (STARCOSApplSichereSignatur) card.getApplication(STARCOSApplSichereSignatur.AID_SichereSignatur);
appl.setPin(STARCOSApplSichereSignatur.KID_PIN_SS, pin);
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
- byte[] signature = signatureCard.createSignature(hash,
- KeyboxName.SECURE_SIGNATURE_KEYPAIR, new TestPINProvider(pin));
+ byte[] signature = signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")),
+ KeyboxName.SECURE_SIGNATURE_KEYPAIR, new TestPINProvider(pin), null);
assertNotNull(signature);
@@ -169,7 +169,7 @@ public class STARCOSCardTest extends CardTest {
@Test
public void testSignGewoehnlicheSignatur() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
char[] pin = "1234".toCharArray();
@@ -178,11 +178,9 @@ public class STARCOSCardTest extends CardTest {
STARCOSCardChannelEmul channel = (STARCOSCardChannelEmul) card.getBasicChannel();
channel.setPin(STARCOSCardChannelEmul.KID_PIN_Glob, pin);
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
- byte[] signature = signatureCard.createSignature(hash,
- KeyboxName.CERITIFIED_KEYPAIR, new TestPINProvider(pin));
+ byte[] signature = signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")),
+ KeyboxName.CERITIFIED_KEYPAIR, new TestPINProvider(pin), null);
assertNotNull(signature);
@@ -191,75 +189,67 @@ public class STARCOSCardTest extends CardTest {
@Test(expected = LockedException.class)
public void testSignSichereSignaturInvalidPin() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
TestPINProvider pinProvider = new TestPINProvider("000000".toCharArray());
- signatureCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.SECURE_SIGNATURE_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = LockedException.class)
public void testSignGewoehnlicheSignaturInvalidPin() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
TestPINProvider pinProvider = new TestPINProvider("1234".toCharArray());
- signatureCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.CERITIFIED_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = LockedException.class)
public void testSignSichereSignaturBlockedPin() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
CardEmul card = (CardEmul) signatureCard.getCard();
STARCOSApplSichereSignatur appl = (STARCOSApplSichereSignatur) card.getApplication(STARCOSApplSichereSignatur.AID_SichereSignatur);
appl.setPin(STARCOSApplSichereSignatur.KID_PIN_SS, null);
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
TestPINProvider pinProvider = new TestPINProvider("000000".toCharArray());
assertTrue(pinProvider.getProvided() <= 0);
- signatureCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.SECURE_SIGNATURE_KEYPAIR,
+ pinProvider, null);
}
@Test(expected = LockedException.class)
public void testSignGewoehnlicheSignaturBlockedPin() throws SignatureCardException,
InterruptedException, CardNotSupportedException,
- NoSuchAlgorithmException, UnsupportedEncodingException {
+ NoSuchAlgorithmException, IOException {
SignatureCard signatureCard = createSignatureCard();
CardEmul card = (CardEmul) signatureCard.getCard();
STARCOSCardChannelEmul channel = (STARCOSCardChannelEmul) card.getBasicChannel();
channel.setPin(STARCOSCardChannelEmul.KID_PIN_Glob, null);
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] hash = md.digest("MOCCA".getBytes("ASCII"));
-
TestPINProvider pinProvider = new TestPINProvider("0000".toCharArray());
- signatureCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR,
- pinProvider);
+ signatureCard.createSignature(new ByteArrayInputStream("MOCCA"
+ .getBytes("ASCII")), KeyboxName.CERITIFIED_KEYPAIR,
+ pinProvider, null);
}