Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/ec/TestEC.java
38838 views
/*1* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223//24// SunJSSE does not support dynamic system properties, no way to re-use25// system properties in samevm/agentvm mode.26//2728/**29* @test30* @bug 684075231* @summary Provide out-of-the-box support for ECC algorithms32* @library ../pkcs1133* @library ../pkcs11/ec34* @library ../pkcs11/sslecc35* @library ../../../java/security/testlibrary36* @library ../../../javax/net/ssl/TLSCommon37* @compile -XDignore.symbol.file TestEC.java38* @run main/othervm -Djdk.tls.namedGroups="secp256r1,sect193r1" TestEC39*/4041import java.security.NoSuchProviderException;42import java.security.Provider;43import java.security.Security;4445/*46* Leverage the collection of EC tests used by PKCS1147*48* NOTE: the following 6 files were copied here from the PKCS11 EC Test area49* and must be kept in sync with the originals:50*51* ../pkcs11/ec/p12passwords.txt52* ../pkcs11/ec/certs/sunlabscerts.pem53* ../pkcs11/ec/pkcs12/secp256r1server-secp384r1ca.p1254* ../pkcs11/ec/pkcs12/sect193r1server-rsa1024ca.p1255* ../pkcs11/sslecc/keystore56* ../pkcs11/sslecc/truststore57*/5859public class TestEC {6061public static void main(String[] args) throws Exception {62// reset security properties to make sure that the algorithms63// and keys used in this test are not disabled.64Security.setProperty("jdk.tls.disabledAlgorithms", "");65Security.setProperty("jdk.certpath.disabledAlgorithms", "");6667ProvidersSnapshot snapshot = ProvidersSnapshot.create();68try {69main0(args);70} finally {71snapshot.restore();72}73}7475public static void main0(String[] args) throws Exception {76Provider p = Security.getProvider("SunEC");7778if (p == null) {79throw new NoSuchProviderException("Can't get SunEC provider");80}8182System.out.println("Running tests with " + p.getName() +83" provider...\n");84long start = System.currentTimeMillis();8586/*87* The entry point used for each test is its instance method88* called main (not its static method called main).89*/90new TestECDH().main(p);91new TestECDSA().main(p);92new TestCurves().main(p);93new TestKeyFactory().main(p);94new TestECGenSpec().main(p);95new ReadPKCS12().main(p);96new ReadCertificates().main(p);9798// ClientJSSEServerJSSE fails on Solaris 11 when both SunEC and99// SunPKCS11-Solaris providers are enabled.100// Workaround:101// Security.removeProvider("SunPKCS11-Solaris");102new ClientJSSEServerJSSE().main(p);103104long stop = System.currentTimeMillis();105System.out.println("\nCompleted tests with " + p.getName() +106" provider (" + ((stop - start) / 1000.0) + " seconds).");107}108}109110111