TestEC.java revision 4479:cb83fe13af98
1/*
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/**
25 * @test
26 * @bug 6840752
27 * @summary  Provide out-of-the-box support for ECC algorithms
28 * @library ../pkcs11
29 * @library ../pkcs11/ec
30 * @library ../pkcs11/sslecc
31 * @library ../../../java/security/testlibrary
32 * @compile -XDignore.symbol.file TestEC.java
33 * @run main TestEC
34 */
35
36import java.security.Provider;
37import java.security.Security;
38
39/*
40 * Leverage the collection of EC tests used by PKCS11
41 *
42 * NOTE: the following 6 files were copied here from the PKCS11 EC Test area
43 *       and must be kept in sync with the originals:
44 *
45 *           ../pkcs11/ec/p12passwords.txt
46 *           ../pkcs11/ec/certs/sunlabscerts.pem
47 *           ../pkcs11/ec/pkcs12/secp256r1server-secp384r1ca.p12
48 *           ../pkcs11/ec/pkcs12/sect193r1server-rsa1024ca.p12
49 *           ../pkcs11/sslecc/keystore
50 *           ../pkcs11/sslecc/truststore
51 */
52
53public class TestEC {
54
55    public static void main(String[] args) throws Exception {
56        ProvidersSnapshot snapshot = ProvidersSnapshot.create();
57        try {
58            main0(args);
59        } finally {
60            snapshot.restore();
61        }
62    }
63
64    public static void main0(String[] args) throws Exception {
65        Provider p = new sun.security.ec.SunEC();
66        System.out.println("Running tests with " + p.getName() +
67            " provider...\n");
68        long start = System.currentTimeMillis();
69
70        /*
71         * The entry point used for each test is its instance method
72         * called main (not its static method called main).
73         */
74        new TestECDH().main(p);
75        new TestECDSA().main(p);
76        new TestCurves().main(p);
77        new TestKeyFactory().main(p);
78        new TestECGenSpec().main(p);
79        new ReadPKCS12().main(p);
80        new ReadCertificates().main(p);
81
82        // ClientJSSEServerJSSE fails on Solaris 11 when both SunEC and
83        // SunPKCS11-Solaris providers are enabled.
84        // Workaround:
85        // Security.removeProvider("SunPKCS11-Solaris");
86        new ClientJSSEServerJSSE().main(p);
87
88        long stop = System.currentTimeMillis();
89        System.out.println("\nCompleted tests with " + p.getName() +
90            " provider (" + ((stop - start) / 1000.0) + " seconds).");
91    }
92}
93