1 /* |
1 /* |
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
18 * |
18 * |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
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 |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
|
23 |
23 /* |
24 /* |
24 * @test |
25 * @test |
25 * @bug 7200306 8029158 |
26 * @bug 7200306 8029158 |
26 * @summary verify that P11Signature impl will error out when initialized |
27 * @summary verify that P11Signature impl will error out when initialized |
27 * with unsupported key sizes |
28 * with unsupported key sizes |
28 * @library .. |
29 * @library .. |
29 * @key randomness |
30 * @key randomness |
|
31 * @run main/othervm TestDSAKeyLength |
|
32 * @run main/othervm TestDSAKeyLength sm |
30 */ |
33 */ |
31 |
34 |
32 |
35 import java.security.InvalidKeyException; |
33 import java.security.*; |
36 import java.security.KeyPair; |
34 import java.security.spec.*; |
37 import java.security.KeyPairGenerator; |
35 import java.security.interfaces.*; |
38 import java.security.Provider; |
|
39 import java.security.SecureRandom; |
|
40 import java.security.Signature; |
36 |
41 |
37 public class TestDSAKeyLength extends PKCS11Test { |
42 public class TestDSAKeyLength extends PKCS11Test { |
38 |
43 |
39 public static void main(String[] args) throws Exception { |
44 public static void main(String[] args) throws Exception { |
40 main(new TestDSAKeyLength()); |
45 main(new TestDSAKeyLength(), args); |
41 } |
46 } |
42 |
47 |
|
48 @Override |
43 public void main(Provider provider) throws Exception { |
49 public void main(Provider provider) throws Exception { |
44 if (isNSS(provider) && getNSSVersion() >= 3.14) { |
50 if (isNSS(provider) && getNSSVersion() >= 3.14) { |
45 System.out.println("Skip testing NSS " + getNSSVersion()); |
51 System.out.println("Skip testing NSS " + getNSSVersion()); |
46 return; |
52 return; |
47 } |
53 } |
49 /* |
55 /* |
50 * Use Solaris SPARC 11.2 or later to avoid an intermittent failure |
56 * Use Solaris SPARC 11.2 or later to avoid an intermittent failure |
51 * when running SunPKCS11-Solaris (8044554) |
57 * when running SunPKCS11-Solaris (8044554) |
52 */ |
58 */ |
53 if (provider.getName().equals("SunPKCS11-Solaris") && |
59 if (provider.getName().equals("SunPKCS11-Solaris") && |
54 System.getProperty("os.name").equals("SunOS") && |
60 props.getProperty("os.name").equals("SunOS") && |
55 System.getProperty("os.arch").equals("sparcv9") && |
61 props.getProperty("os.arch").equals("sparcv9") && |
56 System.getProperty("os.version").compareTo("5.11") <= 0 && |
62 props.getProperty("os.version").compareTo("5.11") <= 0 && |
57 getDistro().compareTo("11.2") < 0) { |
63 getDistro().compareTo("11.2") < 0) { |
58 |
64 |
59 System.out.println("SunPKCS11-Solaris provider requires " + |
65 System.out.println("SunPKCS11-Solaris provider requires " + |
60 "Solaris SPARC 11.2 or later, skipping"); |
66 "Solaris SPARC 11.2 or later, skipping"); |
61 return; |
67 return; |