2009-08-11 15:52:26 +00:00
|
|
|
/*
|
2024-10-30 18:51:02 +00:00
|
|
|
* Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
|
2009-08-11 15:52:26 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-25 22:58:33 +00:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2009-08-11 15:52:26 +00:00
|
|
|
*/
|
|
|
|
|
2013-04-12 01:57:14 +00:00
|
|
|
//
|
|
|
|
// SunJSSE does not support dynamic system properties, no way to re-use
|
|
|
|
// system properties in samevm/agentvm mode.
|
|
|
|
//
|
|
|
|
|
2009-08-11 15:52:26 +00:00
|
|
|
/**
|
|
|
|
* @test
|
2016-10-18 13:18:56 +00:00
|
|
|
* @bug 6840752 8168078
|
2009-08-11 15:52:26 +00:00
|
|
|
* @summary Provide out-of-the-box support for ECC algorithms
|
2018-08-15 18:00:31 +00:00
|
|
|
* @library /test/lib
|
2009-08-11 15:52:26 +00:00
|
|
|
* @library ../pkcs11
|
|
|
|
* @library ../pkcs11/ec
|
2009-09-21 22:01:42 +00:00
|
|
|
* @library ../pkcs11/sslecc
|
2011-08-12 04:26:31 +00:00
|
|
|
* @library ../../../java/security/testlibrary
|
8196584: TLS 1.3 Implementation
Co-authored-by: Adam Petcher <adam.petcher@oracle.com>
Co-authored-by: Amanda Jiang <amanda.jiang@oracle.com>
Co-authored-by: Anthony Scarpino <anthony.scarpino@oracle.com>
Co-authored-by: Bradford Wetmore <bradford.wetmore@oracle.com>
Co-authored-by: Jamil Nimeh <jamil.j.nimeh@oracle.com>
Co-authored-by: John Jiang <sha.jiang@oracle.com>
Co-authored-by: Rajan Halade <rajan.halade@oracle.com>
Co-authored-by: Sibabrata Sahoo <sibabrata.sahoo@oracle.com>
Co-authored-by: Valerie Peng <valerie.peng@oracle.com>
Co-authored-by: Weijun Wang <weijun.wang@oracle.com>
Reviewed-by: ascarpino, coffeys, dfuchs, jjiang, jnimeh, mullan, rhalade, ssahoo, valeriep, weijun, wetmore, xuelei
2018-06-25 20:41:39 +00:00
|
|
|
* @library ../../../javax/net/ssl/TLSCommon
|
2017-01-23 19:49:01 +00:00
|
|
|
* @modules jdk.crypto.cryptoki/sun.security.pkcs11.wrapper
|
2020-09-29 18:05:20 +00:00
|
|
|
* @run main/othervm -Djdk.tls.namedGroups="secp256r1" TestEC
|
2009-08-11 15:52:26 +00:00
|
|
|
*/
|
|
|
|
|
2012-08-30 21:40:57 +00:00
|
|
|
import java.security.NoSuchProviderException;
|
2009-08-11 15:52:26 +00:00
|
|
|
import java.security.Provider;
|
2011-08-12 04:26:31 +00:00
|
|
|
import java.security.Security;
|
2009-08-11 15:52:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Leverage the collection of EC tests used by PKCS11
|
|
|
|
*
|
2020-09-25 02:40:36 +00:00
|
|
|
* NOTE: the following 5 files were copied here from the PKCS11 EC Test area
|
2009-08-11 15:52:26 +00:00
|
|
|
* and must be kept in sync with the originals:
|
|
|
|
*
|
|
|
|
* ../pkcs11/ec/p12passwords.txt
|
2009-09-21 22:01:42 +00:00
|
|
|
* ../pkcs11/ec/certs/sunlabscerts.pem
|
2009-08-11 15:52:26 +00:00
|
|
|
* ../pkcs11/ec/pkcs12/secp256r1server-secp384r1ca.p12
|
2009-09-21 22:01:42 +00:00
|
|
|
* ../pkcs11/sslecc/keystore
|
|
|
|
* ../pkcs11/sslecc/truststore
|
2009-08-11 15:52:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
public class TestEC {
|
|
|
|
|
2016-06-13 07:47:32 +00:00
|
|
|
/*
|
|
|
|
* Turn on SSL debugging
|
|
|
|
*/
|
|
|
|
private static final boolean debug = true;
|
|
|
|
|
2009-08-11 15:52:26 +00:00
|
|
|
public static void main(String[] args) throws Exception {
|
2015-04-22 05:09:54 +00:00
|
|
|
// reset security properties to make sure that the algorithms
|
2014-11-03 08:30:18 +00:00
|
|
|
// and keys used in this test are not disabled.
|
|
|
|
Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
2015-04-22 05:09:54 +00:00
|
|
|
Security.setProperty("jdk.certpath.disabledAlgorithms", "");
|
2014-01-14 05:12:58 +00:00
|
|
|
|
2016-06-13 07:47:32 +00:00
|
|
|
if (debug) {
|
|
|
|
System.setProperty("javax.net.debug", "all");
|
|
|
|
}
|
|
|
|
|
2011-08-12 04:26:31 +00:00
|
|
|
ProvidersSnapshot snapshot = ProvidersSnapshot.create();
|
|
|
|
try {
|
|
|
|
main0(args);
|
|
|
|
} finally {
|
|
|
|
snapshot.restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main0(String[] args) throws Exception {
|
2024-10-30 18:51:02 +00:00
|
|
|
Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunEC"));
|
2012-08-30 21:40:57 +00:00
|
|
|
|
|
|
|
if (p == null) {
|
|
|
|
throw new NoSuchProviderException("Can't get SunEC provider");
|
|
|
|
}
|
|
|
|
|
2009-08-11 15:52:26 +00:00
|
|
|
System.out.println("Running tests with " + p.getName() +
|
|
|
|
" provider...\n");
|
|
|
|
long start = System.currentTimeMillis();
|
2009-09-21 22:01:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The entry point used for each test is its instance method
|
|
|
|
* called main (not its static method called main).
|
|
|
|
*/
|
2020-09-25 02:40:36 +00:00
|
|
|
System.out.println("TestECDH");
|
2009-08-11 15:52:26 +00:00
|
|
|
new TestECDH().main(p);
|
2020-09-25 02:40:36 +00:00
|
|
|
System.out.println("TestECDSA");
|
2009-08-11 15:52:26 +00:00
|
|
|
new TestECDSA().main(p);
|
2020-09-25 02:40:36 +00:00
|
|
|
System.out.println("TestCurves");
|
2009-08-24 17:37:37 +00:00
|
|
|
new TestCurves().main(p);
|
2020-09-25 02:40:36 +00:00
|
|
|
System.out.println("TestKeyFactory");
|
2009-08-11 15:52:26 +00:00
|
|
|
new TestKeyFactory().main(p);
|
2020-09-25 02:40:36 +00:00
|
|
|
System.out.println("TestECGenSpec");
|
2009-08-11 15:52:26 +00:00
|
|
|
new TestECGenSpec().main(p);
|
2020-09-25 02:40:36 +00:00
|
|
|
System.out.println("ReadPKCS12");
|
2009-08-11 15:52:26 +00:00
|
|
|
new ReadPKCS12().main(p);
|
2020-09-25 02:40:36 +00:00
|
|
|
System.out.println("ReadCertificate");
|
2009-09-21 22:01:42 +00:00
|
|
|
new ReadCertificates().main(p);
|
2020-09-25 02:40:36 +00:00
|
|
|
System.out.println("ClientJSSEServerJSSE");
|
2009-09-21 22:01:42 +00:00
|
|
|
new ClientJSSEServerJSSE().main(p);
|
2009-08-11 15:52:26 +00:00
|
|
|
|
2009-09-21 22:01:42 +00:00
|
|
|
long stop = System.currentTimeMillis();
|
2009-08-11 15:52:26 +00:00
|
|
|
System.out.println("\nCompleted tests with " + p.getName() +
|
2009-09-21 22:01:42 +00:00
|
|
|
" provider (" + ((stop - start) / 1000.0) + " seconds).");
|
2009-08-11 15:52:26 +00:00
|
|
|
}
|
|
|
|
}
|