summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java13
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java27
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java2
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java4
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java2
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java2
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java2
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java2
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java2
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java2
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java2
11 files changed, 24 insertions, 36 deletions
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java
index f531f70..59f3b47 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java
@@ -1,12 +1,10 @@
package org.uic.barcode.test;
import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
@@ -28,6 +26,7 @@ import org.uic.barcode.test.utils.Level2TestDataFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.utils.AlgorithmNameResolver;
public class DynamicFrameDoubleSignatureProviderSelectionTest {
@@ -48,7 +47,7 @@ public class DynamicFrameDoubleSignatureProviderSelectionTest {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
@@ -152,16 +151,10 @@ public class DynamicFrameDoubleSignatureProviderSelectionTest {
}
- public KeyPair generateECDSAKeys(String keyAlgorithmName, String paramName) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException{
- ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(paramName);
- KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
- g.initialize(ecSpec, new SecureRandom());
- return g.generateKeyPair();
- }
public KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
- String keyAlgorithmName = "ECDSA";
+ String keyAlgorithmName = AlgorithmNameResolver.getName(AlgorithmNameResolver.TYPE_KEY_GENERATOR_ALG, keyAlgorithmOid);
ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(curve);
KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
g.initialize(ecSpec, new SecureRandom());
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java
index 160ebc1..bd0f9a4 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java
@@ -1,21 +1,18 @@
package org.uic.barcode.test;
import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
+import java.security.spec.ECGenParameterSpec;
import java.util.Arrays;
import java.util.zip.DataFormatException;
-import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.jce.spec.ECParameterSpec;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.Decoder;
@@ -27,6 +24,7 @@ import org.uic.barcode.test.utils.Level2TestDataFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.utils.SecurityUtils;
public class DynamicFrameDoubleSignatureTest {
@@ -46,7 +44,7 @@ public class DynamicFrameDoubleSignatureTest {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
@@ -148,20 +146,17 @@ public class DynamicFrameDoubleSignatureTest {
}
- public KeyPair generateECDSAKeys(String keyAlgorithmName, String paramName) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException{
- ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(paramName);
- KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
- g.initialize(ecSpec, new SecureRandom());
- return g.generateKeyPair();
- }
public KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
- String keyAlgorithmName = "ECDSA";
- ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(curve);
- KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
- g.initialize(ecSpec, new SecureRandom());
- return g.generateKeyPair();
+ //ECNamedCurveGenParameterSpec namedParamSpec = new ECNamedCurveGenParameterSpec(elipticCurve);
+
+ ECGenParameterSpec namedParamSpec = new ECGenParameterSpec(elipticCurve);
+ KeyPairGenerator ecKPGen = KeyPairGenerator.getInstance("EC", "BC");
+ ecKPGen.initialize(namedParamSpec, new SecureRandom());
+ KeyPair keyPair = ecKPGen.generateKeyPair();
+ KeyPair kp = new KeyPair(SecurityUtils.convertPublicKey(keyPair.getPublic()),SecurityUtils.convertPrivateKey(keyPair.getPrivate()));
+ return kp;
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java
index 4c039ff..da701bd 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java
@@ -54,7 +54,7 @@ public class DynamicFrameDynamicContentApiTest {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
index 656dbb4..b91cd0c 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
@@ -57,10 +57,10 @@ public class DynamicFrameDynamicContentTest {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
-
+
Security.addProvider(new BouncyCastleProvider());
try {
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java
index f5a4705..dafeb49 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java
@@ -43,7 +43,7 @@ public class DynamicFrameFcbVersion1Test {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java
index 4eb821a..f8a03ba 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java
@@ -43,7 +43,7 @@ public class DynamicFrameFcbVersion3Test {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java
index 2c7cce3..931324d 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java
@@ -42,7 +42,7 @@ public class DynamicFrameSimpleTest {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java
index 5fcb07a..ab4c39e 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java
@@ -43,7 +43,7 @@ public class DynamicFrameV2FcbVersion3Test {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java
index c50172b..5b5a8ae 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java
@@ -54,7 +54,7 @@ public class DynamicFrameV2SignatureInsert2Test {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java
index 90d3c2b..68be52e 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java
@@ -54,7 +54,7 @@ public class DynamicFrameV2SignatureInsertTest {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java
index d4f5d6a..a198b97 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java
@@ -47,7 +47,7 @@ public class DynamicFrameV2ValidityDateTest {
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();