author | skovalev |
Thu, 15 Sep 2016 13:03:03 +0300 | |
changeset 40975 | 680639c9b307 |
parent 37361 | a790f7bc3878 |
child 42693 | 6645de32a866 |
permissions | -rw-r--r-- |
37361
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
1 |
/* |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
4 |
* |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
8 |
* |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
13 |
* accompanied this code). |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
14 |
* |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
18 |
* |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
21 |
* questions. |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
22 |
*/ |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
23 |
|
40975
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
37361
diff
changeset
|
24 |
/* |
37361
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
25 |
* @test |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
26 |
* @bug 8072452 |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
27 |
* @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
28 |
* @library .. |
40975
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
37361
diff
changeset
|
29 |
* @modules jdk.crypto.pkcs11 |
37361
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
30 |
* @run main/othervm UnsupportedDHKeys |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
31 |
* @run main/othervm UnsupportedDHKeys sm |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
32 |
*/ |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
33 |
|
40975
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
37361
diff
changeset
|
34 |
import java.security.InvalidParameterException; |
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
37361
diff
changeset
|
35 |
import java.security.KeyPairGenerator; |
680639c9b307
8165689: Fix module dependencies for sun/security/pkcs11/* tests
skovalev
parents:
37361
diff
changeset
|
36 |
import java.security.Provider; |
37361
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
37 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
38 |
public class UnsupportedDHKeys extends PKCS11Test { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
39 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
40 |
/* |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
41 |
* Sizes and values for various lengths. |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
42 |
*/ |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
43 |
private enum UnsupportedKeySize { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
44 |
// not multiple of 64 |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
45 |
dhp513(513), dhp769(769), dhp895(895), |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
46 |
dhp1023(1023), dhp1535(1535), dhp2047(2047), |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
47 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
48 |
// unsupported |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
49 |
dhp2176(2176), dhp3008(3008), dhp4032(4032), |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
50 |
dhp5120(5120), dhp6400(6400), dhp7680(7680), |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
51 |
dhp8191(8191), dhp8128(8128), dhp8260(8260); |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
52 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
53 |
final int primeSize; |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
54 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
55 |
UnsupportedKeySize(int primeSize) { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
56 |
this.primeSize = primeSize; |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
57 |
} |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
58 |
} |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
59 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
60 |
@Override |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
61 |
public void main(Provider provider) throws Exception { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
62 |
if (provider.getService("KeyPairGenerator", "DiffieHellman") == null) { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
63 |
System.out.println("No supported of DH KeyPairGenerator, skipping"); |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
64 |
return; |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
65 |
} |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
66 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
67 |
for (UnsupportedKeySize keySize : UnsupportedKeySize.values()) { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
68 |
try { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
69 |
System.out.println("Checking " + keySize.primeSize + " ..."); |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
70 |
KeyPairGenerator kpg = |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
71 |
KeyPairGenerator.getInstance("DiffieHellman", provider); |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
72 |
kpg.initialize(keySize.primeSize); |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
73 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
74 |
throw new Exception("Should not support " + keySize.primeSize); |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
75 |
} catch (InvalidParameterException ipe) { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
76 |
System.out.println("\tOk, unsupported"); |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
77 |
} |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
78 |
} |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
79 |
} |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
80 |
|
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
81 |
public static void main(String[] args) throws Exception { |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
82 |
main(new UnsupportedDHKeys(), args); |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
83 |
} |
a790f7bc3878
8072452: Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits
xuelei
parents:
diff
changeset
|
84 |
} |