From 6ef85723cca938e298b318dc6d564318b83ab4ba Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Mon, 11 Apr 2022 16:30:32 +0200 Subject: use one provider only within validation --- .../org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java | 8 ++++++-- .../java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java | 8 +------- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/test') diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java index bd0f9a4..6533938 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java @@ -5,6 +5,7 @@ import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import java.security.SecureRandom; import java.security.Security; import java.security.SignatureException; @@ -37,6 +38,8 @@ public class DynamicFrameDoubleSignatureTest { public IUicRailTicket testFCBticket = null; + public Provider provider = null; + @Before public void initialize() { @@ -44,10 +47,11 @@ public class DynamicFrameDoubleSignatureTest { signatureAlgorithmOID = Constants.ECDSA_SHA256; keyPairAlgorithmOID = Constants.KG_EC_256; - elipticCurve = "secp256r1"; + elipticCurve = "secp256k1"; testFCBticket = SimpleUICTestTicket.getUicTestTicket(); + provider = new BouncyCastleProvider(); Security.addProvider(new BouncyCastleProvider()); try { @@ -155,7 +159,7 @@ public class DynamicFrameDoubleSignatureTest { 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())); + KeyPair kp = new KeyPair(SecurityUtils.convert(keyPair.getPublic(), provider),SecurityUtils.convert(keyPair.getPrivate(), provider)); return kp; } diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java index f8a03ba..7f03658 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java @@ -159,13 +159,7 @@ public class DynamicFrameFcbVersion3Test { } - 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"; -- cgit v1.2.3