TestEC.java revision 5798:0a2565113920
14Srgrimes/*
24Srgrimes * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
34Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44Srgrimes *
54Srgrimes * This code is free software; you can redistribute it and/or modify it
64Srgrimes * under the terms of the GNU General Public License version 2 only, as
74Srgrimes * published by the Free Software Foundation.
84Srgrimes *
94Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
104Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
114Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
124Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
134Srgrimes * accompanied this code).
144Srgrimes *
154Srgrimes * You should have received a copy of the GNU General Public License version
164Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
174Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
184Srgrimes *
194Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
204Srgrimes * or visit www.oracle.com if you need additional information or have any
214Srgrimes * questions.
224Srgrimes */
234Srgrimes
244Srgrimes/**
254Srgrimes * @test
264Srgrimes * @bug 6840752
274Srgrimes * @summary  Provide out-of-the-box support for ECC algorithms
284Srgrimes * @library ../pkcs11
294Srgrimes * @library ../pkcs11/ec
304Srgrimes * @library ../pkcs11/sslecc
314Srgrimes * @library ../../../java/security/testlibrary
324Srgrimes * @compile -XDignore.symbol.file TestEC.java
334Srgrimes * @run main TestEC
344Srgrimes */
354Srgrimes
36557Srgrimesimport java.security.NoSuchProviderException;
3750477Speterimport java.security.Provider;
384Srgrimesimport java.security.Security;
394Srgrimes
40557Srgrimes/*
41557Srgrimes * Leverage the collection of EC tests used by PKCS11
42557Srgrimes *
434Srgrimes * NOTE: the following 6 files were copied here from the PKCS11 EC Test area
444Srgrimes *       and must be kept in sync with the originals:
454Srgrimes *
4646129Sluoqi *           ../pkcs11/ec/p12passwords.txt
472056Swollman *           ../pkcs11/ec/certs/sunlabscerts.pem
484Srgrimes *           ../pkcs11/ec/pkcs12/secp256r1server-secp384r1ca.p12
494Srgrimes *           ../pkcs11/ec/pkcs12/sect193r1server-rsa1024ca.p12
5024690Speter *           ../pkcs11/sslecc/keystore
5124690Speter *           ../pkcs11/sslecc/truststore
5224690Speter */
5324690Speter
5424690Speterpublic class TestEC {
5524690Speter
5624690Speter    public static void main(String[] args) throws Exception {
5748691Sjlemon        ProvidersSnapshot snapshot = ProvidersSnapshot.create();
5848691Sjlemon        try {
5948691Sjlemon            main0(args);
6048691Sjlemon        } finally {
6148691Sjlemon            snapshot.restore();
6248691Sjlemon        }
6348691Sjlemon    }
6448691Sjlemon
6554188Sluoqi    public static void main0(String[] args) throws Exception {
6654188Sluoqi        Provider p = Security.getProvider("SunEC");
6754188Sluoqi
6854188Sluoqi        if (p == null) {
6954188Sluoqi            throw new NoSuchProviderException("Can't get SunEC provider");
704Srgrimes        }
7110092Sdg
7210092Sdg        System.out.println("Running tests with " + p.getName() +
7348691Sjlemon            " provider...\n");
744Srgrimes        long start = System.currentTimeMillis();
7533051Sbde
7625164Speter        /*
7733051Sbde         * The entry point used for each test is its instance method
7833051Sbde         * called main (not its static method called main).
7933051Sbde         */
8026494Sbde        new TestECDH().main(p);
8127993Sdyson        new TestECDSA().main(p);
8254188Sluoqi        new TestCurves().main(p);
834Srgrimes        new TestKeyFactory().main(p);
844Srgrimes        new TestECGenSpec().main(p);
851549Srgrimes        new ReadPKCS12().main(p);
861549Srgrimes        new ReadCertificates().main(p);
871549Srgrimes
881549Srgrimes        // ClientJSSEServerJSSE fails on Solaris 11 when both SunEC and
891549Srgrimes        // SunPKCS11-Solaris providers are enabled.
901549Srgrimes        // Workaround:
911549Srgrimes        // Security.removeProvider("SunPKCS11-Solaris");
9255205Speter        new ClientJSSEServerJSSE().main(p);
9325164Speter
9446129Sluoqi        long stop = System.currentTimeMillis();
95719Swollman        System.out.println("\nCompleted tests with " + p.getName() +
9646129Sluoqi            " provider (" + ((stop - start) / 1000.0) + " seconds).");
9725164Speter    }
9830274Speter}
994Srgrimes