8130007: Update security tests to use Security.getProvider to get security provider
Reviewed-by: mullan
Contributed-by: valerie.peng@oracle.com, mandy.chung@oracle.com
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4511676.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4511676.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.Provider;
-import com.sun.crypto.provider.*;
public class Test4511676 {
private static final String ALGO = "AES";
@@ -59,7 +58,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
Test4511676 test = new Test4511676();
String testName = test.getClass().getName() + "[" + ALGO +
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4512524.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4512524.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.Provider;
-import com.sun.crypto.provider.*;
public class Test4512524 {
@@ -65,8 +64,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
Test4512524 test = new Test4512524();
test.execute("CBC");
test.execute("GCM");
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4512704.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4512704.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.Provider;
-import com.sun.crypto.provider.*;
public class Test4512704 {
private static final String ALGO = "AES";
@@ -61,8 +60,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
Test4512704 test = new Test4512704();
test.execute("CBC");
test.execute("GCM");
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4513830.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4513830.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -85,8 +85,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
Test4513830 test = new Test4513830();
String testName = test.getClass().getName() + "[" + ALGO +
"/" + MODE + "/" + PADDING + "]";
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4517355.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4517355.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.Provider;
-import com.sun.crypto.provider.*;
public class Test4517355 {
@@ -93,8 +92,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
Test4517355 test = new Test4517355();
Random rdm = new Random();
rdm.nextBytes(test.plainText);
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4626070.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/Test4626070.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -60,8 +60,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
Test4626070 test = new Test4626070();
test.execute("CBC", "PKCS5Padding");
test.execute("GCM", "NoPadding");
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestKATForECB_IV.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestKATForECB_IV.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -118,8 +118,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
TestKATForECB_IV test = new TestKATForECB_IV();
String testName = test.getClass().getName() + "[" + ALGO +
"/" + MODE + "/" + PADDING + "]";
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VK.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VK.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import java.math.*;
-import com.sun.crypto.provider.*;
import java.util.*;
@@ -746,8 +745,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
TestKATForECB_VK test = new TestKATForECB_VK();
String testName = test.getClass().getName() + "[" + ALGO +
"/" + MODE + "/" + PADDING + "]";
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VT.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VT.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import java.math.*;
-import com.sun.crypto.provider.*;
import java.util.*;
@@ -555,8 +554,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
TestKATForECB_VT test = new TestKATForECB_VT();
String testName = test.getClass().getName() + "[" + ALGO +
"/" + MODE + "/" + PADDING + "]";
--- a/jdk/test/com/sun/crypto/provider/Cipher/Blowfish/BlowfishTestVector.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/Blowfish/BlowfishTestVector.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,10 +68,8 @@
public static void main(String[] argv) throws Exception {
- Provider p = new com.sun.crypto.provider.SunJCE();
- Security.addProvider(p);
String transformation = "Blowfish/ECB/NoPadding";
- Cipher cipher = Cipher.getInstance(transformation);
+ Cipher cipher = Cipher.getInstance(transformation, "SunJCE");
int MAX_KEY_SIZE = Cipher.getMaxAllowedKeyLength(transformation);
//
// test 1
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/DESSecretKeySpec.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/DESSecretKeySpec.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,11 +46,11 @@
System.out.println("Testing DES key");
SecretKeySpec skey = new SecretKeySpec(key, "DES");
c = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
- SecretKeyFactory.getInstance("DES").generateSecret(skey);
+ SecretKeyFactory.getInstance("DES", "SunJCE").generateSecret(skey);
System.out.println("Testing DESede key");
skey = new SecretKeySpec(key, "DESede");
c = Cipher.getInstance("DESede/CBC/PKCS5Padding", "SunJCE");
- SecretKeyFactory.getInstance("TripleDES").generateSecret(skey);
+ SecretKeyFactory.getInstance("TripleDES", "SunJCE").generateSecret(skey);
}
}
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/DesAPITest.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/DesAPITest.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;
-import com.sun.crypto.provider.*;
public class DesAPITest {
@@ -87,9 +86,6 @@
public void init(String crypt, String mode, String padding)
throws Exception {
- SunJCE jce = new SunJCE();
- Security.addProvider(jce);
-
KeySpec desKeySpec = null;
SecretKeyFactory factory = null;
@@ -99,7 +95,7 @@
if (padding.length() != 0)
cipherName.append("/" + padding);
- cipher = Cipher.getInstance(cipherName.toString());
+ cipher = Cipher.getInstance(cipherName.toString(), "SunJCE");
if (crypt.endsWith("ede")) {
desKeySpec = new DESedeKeySpec(key3);
factory = SecretKeyFactory.getInstance("DESede", "SunJCE");
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/DoFinalReturnLen.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/DoFinalReturnLen.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -85,9 +85,7 @@
IvParameterSpec IvParamSpec = null;
SecretKey sKey = null;
- // Step 0: add providers
- Provider sun = new com.sun.crypto.provider.SunJCE();
- Security.addProvider(sun);
+ // Step 0: list providers
Provider[] theProviders = Security.getProviders();
for (int index = 0; index < theProviders.length; index++) {
System.out.println(theProviders[index].getName());
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/FlushBug.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/FlushBug.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,18 +32,13 @@
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
-import com.sun.crypto.provider.SunJCE;
public class FlushBug {
public static void main(String[] args) throws Exception {
-
- Provider prov = new com.sun.crypto.provider.SunJCE();
- Security.addProvider(prov);
-
SecureRandom sr = new SecureRandom();
// Create new DES key.
- KeyGenerator kg = KeyGenerator.getInstance("DES");
+ KeyGenerator kg = KeyGenerator.getInstance("DES", "SunJCE");
kg.init(sr);
Key key = kg.generateKey();
@@ -53,13 +48,13 @@
IvParameterSpec iv = new IvParameterSpec(iv_bytes);
// Create the consumer
- Cipher decrypter = Cipher.getInstance("DES/CFB8/NoPadding");
+ Cipher decrypter = Cipher.getInstance("DES/CFB8/NoPadding", "SunJCE");
decrypter.init(Cipher.DECRYPT_MODE, key, iv);
PipedInputStream consumer = new PipedInputStream();
InputStream in = new CipherInputStream(consumer, decrypter);
// Create the producer
- Cipher encrypter = Cipher.getInstance("DES/CFB8/NoPadding");
+ Cipher encrypter = Cipher.getInstance("DES/CFB8/NoPadding", "SunJCE");
encrypter.init(Cipher.ENCRYPT_MODE, key, iv);
PipedOutputStream producer = new PipedOutputStream();
OutputStream out = new CipherOutputStream(producer, encrypter);
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -118,7 +118,7 @@
if (padding.length() != 0)
cipherName.append("/" + padding);
- cipher = Cipher.getInstance(cipherName.toString());
+ cipher = Cipher.getInstance(cipherName.toString(), "SunJCE");
if (crypt.endsWith("ede")) {
desKeySpec = new DESedeKeySpec(key3);
factory = SecretKeyFactory.getInstance("DESede", "SunJCE");
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -152,7 +152,7 @@
if (padding.length() != 0)
cipherName.append("/" + padding);
- cipher = Cipher.getInstance(cipherName.toString());
+ cipher = Cipher.getInstance(cipherName.toString(), "SunJCE");
if (crypt.endsWith("ede")) {
desKeySpec = new DESedeKeySpec(key3);
factory = SecretKeyFactory.getInstance("DESede", "SunJCE");
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/Sealtest.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/Sealtest.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,19 +35,17 @@
public static void main(String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
// create DSA keypair
KeyPairGenerator kpgen = KeyPairGenerator.getInstance("DSA");
kpgen.initialize(512);
KeyPair kp = kpgen.generateKeyPair();
// create DES key
- KeyGenerator kg = KeyGenerator.getInstance("DES");
+ KeyGenerator kg = KeyGenerator.getInstance("DES", "SunJCE");
SecretKey skey = kg.generateKey();
// create cipher
- Cipher c = Cipher.getInstance("DES/CFB16/PKCS5Padding");
+ Cipher c = Cipher.getInstance("DES/CFB16/PKCS5Padding", "SunJCE");
c.init(Cipher.ENCRYPT_MODE, skey);
// seal the DSA private key
--- a/jdk/test/com/sun/crypto/provider/Cipher/UTIL/SunJCEGetInstance.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Cipher/UTIL/SunJCEGetInstance.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
*/
import java.security.Security;
+import java.security.Provider;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
@@ -40,13 +41,12 @@
try{
// Remove SunJCE from Provider list
+ Provider prov = Security.getProvider("SunJCE");
Security.removeProvider("SunJCE");
-
// Create our own instance of SunJCE provider. Purposefully not
// using SunJCE.getInstance() so we can have our own instance
// for the test.
- jce = Cipher.getInstance("AES/CBC/PKCS5Padding",
- new com.sun.crypto.provider.SunJCE());
+ jce = Cipher.getInstance("AES/CBC/PKCS5Padding", prov);
jce.init(Cipher.ENCRYPT_MODE,
new SecretKeySpec("1234567890abcedf".getBytes(), "AES"));
--- a/jdk/test/com/sun/crypto/provider/KeyAgreement/DHGenSharedSecret.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/DHGenSharedSecret.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
import java.security.interfaces.*;
import javax.crypto.*;
import javax.crypto.spec.*;
-import com.sun.crypto.provider.*;
import java.math.BigInteger;
public class DHGenSharedSecret {
@@ -69,8 +68,6 @@
};
public static void main(String[] args) throws Exception {
- SunJCE jce = new SunJCE();
- Security.addProvider(jce);
DHGenSharedSecret test = new DHGenSharedSecret();
test.run();
}
--- a/jdk/test/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test
* @bug 7146728
* @summary DHKeyAgreement2
+ * @modules java.base/sun.misc
* @author Jan Luehe
*/
@@ -36,7 +37,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.crypto.interfaces.*;
-import com.sun.crypto.provider.SunJCE;
import sun.misc.HexDumpEncoder;
--- a/jdk/test/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement3.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement3.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.crypto.interfaces.*;
-import com.sun.crypto.provider.SunJCE;
/**
* This test utility executes the Diffie-Hellman key agreement protocol
@@ -51,10 +50,6 @@
private DHKeyAgreement3() {}
public static void main(String argv[]) throws Exception {
- // Add JCE to the list of providers
- SunJCE jce = new SunJCE();
- Security.addProvider(jce);
-
DHKeyAgreement3 keyAgree = new DHKeyAgreement3();
keyAgree.run();
System.out.println("Test Passed");
@@ -69,36 +64,36 @@
// Alice creates her own DH key pair
System.err.println("ALICE: Generate DH keypair ...");
- KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
+ KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH", "SunJCE");
aliceKpairGen.initialize(dhSkipParamSpec);
KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
// Bob creates his own DH key pair
System.err.println("BOB: Generate DH keypair ...");
- KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
+ KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH", "SunJCE");
bobKpairGen.initialize(dhSkipParamSpec);
KeyPair bobKpair = bobKpairGen.generateKeyPair();
// Carol creates her own DH key pair
System.err.println("CAROL: Generate DH keypair ...");
- KeyPairGenerator carolKpairGen = KeyPairGenerator.getInstance("DH");
+ KeyPairGenerator carolKpairGen = KeyPairGenerator.getInstance("DH", "SunJCE");
carolKpairGen.initialize(dhSkipParamSpec);
KeyPair carolKpair = carolKpairGen.generateKeyPair();
// Alice initialize
System.err.println("ALICE: Initialize ...");
- KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH");
+ KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH", "SunJCE");
aliceKeyAgree.init(aliceKpair.getPrivate());
// Bob initialize
System.err.println("BOB: Initialize ...");
- KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH");
+ KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH", "SunJCE");
bobKeyAgree.init(bobKpair.getPrivate());
// Carol initialize
System.err.println("CAROL: Initialize ...");
- KeyAgreement carolKeyAgree = KeyAgreement.getInstance("DH");
+ KeyAgreement carolKeyAgree = KeyAgreement.getInstance("DH", "SunJCE");
carolKeyAgree.init(carolKpair.getPrivate());
--- a/jdk/test/com/sun/crypto/provider/KeyAgreement/DHKeyFactory.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/DHKeyFactory.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.crypto.interfaces.*;
-import com.sun.crypto.provider.SunJCE;
/**
* This test creates a DH keypair, retrieves the encodings of the DH public and
@@ -49,10 +48,6 @@
private DHKeyFactory() {}
public static void main(String argv[]) throws Exception {
- // Add JCE to the list of providers
- SunJCE jce = new SunJCE();
- Security.addProvider(jce);
-
DHKeyFactory test = new DHKeyFactory();
test.run();
System.out.println("Test Passed");
@@ -67,7 +62,7 @@
dhSkipParamSpec = new DHParameterSpec(skip1024Modulus,
skip1024Base);
- KeyPairGenerator kpgen = KeyPairGenerator.getInstance("DH");
+ KeyPairGenerator kpgen = KeyPairGenerator.getInstance("DH", "SunJCE");
kpgen.initialize(dhSkipParamSpec);
KeyPair kp = kpgen.generateKeyPair();
@@ -77,7 +72,7 @@
// get the private key encoding
byte[] privKeyEnc = kp.getPrivate().getEncoded();
- KeyFactory kfac = KeyFactory.getInstance("DH");
+ KeyFactory kfac = KeyFactory.getInstance("DH", "SunJCE");
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(pubKeyEnc);
PublicKey pubKey = kfac.generatePublic(x509KeySpec);
--- a/jdk/test/com/sun/crypto/provider/KeyAgreement/DHKeyGenSpeed.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/DHKeyGenSpeed.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
import java.security.interfaces.*;
import javax.crypto.*;
import javax.crypto.spec.*;
-import com.sun.crypto.provider.*;
import java.math.*;
public class DHKeyGenSpeed {
@@ -71,8 +70,6 @@
};
public static void main(String[] args) throws Exception {
- SunJCE jce = new SunJCE();
- Security.addProvider(jce);
DHKeyGenSpeed test = new DHKeyGenSpeed();
test.run();
System.out.println("Test Passed");
--- a/jdk/test/com/sun/crypto/provider/KeyGenerator/Test4628062.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/KeyGenerator/Test4628062.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -78,8 +78,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
-
Test4628062 test = new Test4628062();
String testName = test.getClass().getName();
if (test.execute("AES", AES_SIZES)) {
--- a/jdk/test/com/sun/crypto/provider/KeyGenerator/TestExplicitKeyLength.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/KeyGenerator/TestExplicitKeyLength.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,6 @@
}
public static void main (String[] args) throws Exception {
- Security.addProvider(new com.sun.crypto.provider.SunJCE());
for (int i = 0; i < ALGOS.length; i++) {
System.out.println("Testing " + ALGOS[i] + " KeyGenerator with " +
KEY_SIZES[i] + "-bit keysize");
--- a/jdk/test/com/sun/crypto/provider/Mac/HmacMD5.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/Mac/HmacMD5.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,9 +39,6 @@
int i, j, n;
Mac mac;
- Provider jce = new com.sun.crypto.provider.SunJCE();
- Security.addProvider(jce);
-
byte[][][] test_data = {
{
{ (byte)0x0b, (byte)0x0b, (byte)0x0b, (byte)0x0b,
@@ -92,7 +89,7 @@
}
};
- mac = Mac.getInstance("HmacMD5");
+ mac = Mac.getInstance("HmacMD5", "SunJCE");
for (i=0; i<3; i++) {
j=0;
@@ -109,7 +106,7 @@
}
// now test multiple-part operation, using the 2nd test vector
- mac = Mac.getInstance("HmacMD5");
+ mac = Mac.getInstance("HmacMD5", "SunJCE");
mac.init(new SecretKeySpec("Jefe".getBytes(), "HMAC"));
mac.update("what do ya ".getBytes());
mac.update("want for ".getBytes());
--- a/jdk/test/com/sun/crypto/provider/TLS/TestLeadingZeroes.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/com/sun/crypto/provider/TLS/TestLeadingZeroes.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.crypto.interfaces.*;
-import com.sun.crypto.provider.SunJCE;
/**
* Test that leading zeroes are stripped in TlsPremasterSecret case,
@@ -52,10 +51,6 @@
private TestLeadingZeroes() {}
public static void main(String argv[]) throws Exception {
- // Add JCE to the list of providers
- SunJCE jce = new SunJCE();
- Security.addProvider(jce);
-
TestLeadingZeroes keyAgree = new TestLeadingZeroes();
keyAgree.run();
System.out.println("Test Passed");
--- a/jdk/test/java/security/KeyStore/EntryMethods.java Mon Jun 29 08:39:29 2015 -0700
+++ b/jdk/test/java/security/KeyStore/EntryMethods.java Mon Jun 29 11:38:36 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -348,96 +348,140 @@
public static class Pre15 extends KeyStoreSpi {
- private static KeyStoreSpi jks = getJKS();
+ private static KeyStore jks = getJKS();
- // javac does not allow direct access to class (javac bug?)
- // use reflection instead
- private static KeyStoreSpi getJKS() {
+ private static KeyStore getJKS() {
try {
- Class clazz = Class.forName("sun.security.provider.JavaKeyStore$JKS");
- return (KeyStoreSpi)clazz.newInstance();
+ return (KeyStore) KeyStore.getInstance("JKS");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
+ public Pre15() {
+ }
public Key engineGetKey(String alias, char[] password)
throws NoSuchAlgorithmException, UnrecoverableKeyException {
- return jks.engineGetKey(alias, password);
+ try {
+ return jks.getKey(alias, password);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public java.security.cert.Certificate[] engineGetCertificateChain
(String alias) {
- return jks.engineGetCertificateChain(alias);
+ try {
+ return jks.getCertificateChain(alias);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public java.security.cert.Certificate engineGetCertificate
(String alias) {
- return jks.engineGetCertificate(alias);
+ try {
+ return jks.getCertificate(alias);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public Date engineGetCreationDate(String alias) {
- return jks.engineGetCreationDate(alias);
+ try {
+ return jks.getCreationDate(alias);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public void engineSetKeyEntry(String alias, Key key,
char[] password,
java.security.cert.Certificate[] chain)
throws KeyStoreException {
- jks.engineSetKeyEntry(alias, key, password, chain);
+ jks.setKeyEntry(alias, key, password, chain);
}
public void engineSetKeyEntry(String alias, byte[] key,
java.security.cert.Certificate[] chain)
throws KeyStoreException {
- jks.engineSetKeyEntry(alias, key, chain);
+ jks.setKeyEntry(alias, key, chain);
}
public void engineSetCertificateEntry(String alias,
java.security.cert.Certificate cert)
throws KeyStoreException {
- jks.engineSetCertificateEntry(alias, cert);
+ jks.setCertificateEntry(alias, cert);
}
public void engineDeleteEntry(String alias)
throws KeyStoreException {
- jks.engineDeleteEntry(alias);
+ jks.deleteEntry(alias);
}
public Enumeration engineAliases() {
- return jks.engineAliases();
+ try {
+ return jks.aliases();
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
+
}
public boolean engineContainsAlias(String alias) {
- return jks.engineContainsAlias(alias);
+ try {
+ return jks.containsAlias(alias);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public int engineSize() {
- return jks.engineSize();
+ try {
+ return jks.size();
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public boolean engineIsKeyEntry(String alias) {
- return jks.engineIsKeyEntry(alias);
+ try {
+ return jks.isKeyEntry(alias);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public boolean engineIsCertificateEntry(String alias) {
- return jks.engineIsCertificateEntry(alias);
+ try {
+ return jks.isCertificateEntry(alias);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public String engineGetCertificateAlias
(java.security.cert.Certificate cert) {
- return jks.engineGetCertificateAlias(cert);
+ try {
+ return jks.getCertificateAlias(cert);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public void engineStore(OutputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException {
- jks.engineStore(stream, password);
+ try {
+ jks.store(stream, password);
+ } catch (KeyStoreException ke) {
+ throw new RuntimeException("Unexpected exception", ke);
+ }
}
public void engineLoad(InputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException {
- jks.engineLoad(stream, password);
+ jks.load(stream, password);
}
}