Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/ssl/DHKeyExchange/UseStrongDHSizes.java
38853 views
1
/*
2
* Copyright (c) 2017, 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
// SunJSSE does not support dynamic system properties, no way to re-use
26
// system properties in samevm/agentvm mode.
27
//
28
29
/*
30
* @test
31
* @bug 8140436
32
* @library /javax/net/ssl/templates
33
* @summary Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
34
* @run main/othervm UseStrongDHSizes 2048
35
* @run main/othervm -Djdk.tls.namedGroups=ffdhe2048 UseStrongDHSizes 2048
36
* @run main/othervm -Djdk.tls.namedGroups=ffdhe3072 UseStrongDHSizes 2048
37
* @run main/othervm -Djdk.tls.namedGroups=ffdhe4096 UseStrongDHSizes 2048
38
* @run main/othervm -Djdk.tls.namedGroups=ffdhe6144 UseStrongDHSizes 2048
39
* @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 2048
40
* @run main/othervm UseStrongDHSizes 3072
41
* @run main/othervm -Djdk.tls.namedGroups=ffdhe3072 UseStrongDHSizes 3072
42
* @run main/othervm -Djdk.tls.namedGroups=ffdhe4096 UseStrongDHSizes 3072
43
* @run main/othervm -Djdk.tls.namedGroups=ffdhe6144 UseStrongDHSizes 3072
44
* @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 3072
45
* @run main/othervm UseStrongDHSizes 4096
46
* @run main/othervm -Djdk.tls.namedGroups=ffdhe4096 UseStrongDHSizes 4096
47
* @run main/othervm -Djdk.tls.namedGroups=ffdhe6144 UseStrongDHSizes 4096
48
* @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 4096
49
* @run main/othervm UseStrongDHSizes 6144
50
* @run main/othervm -Djdk.tls.namedGroups=ffdhe6144 UseStrongDHSizes 6144
51
* @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 6144
52
* @run main/othervm UseStrongDHSizes 8192
53
* @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 8192
54
*/
55
56
import java.io.InputStream;
57
import java.io.OutputStream;
58
import java.security.Security;
59
import javax.net.ssl.SSLSocket;
60
61
public class UseStrongDHSizes extends SSLSocketTemplate {
62
/*
63
* Run the test case.
64
*/
65
public static void main(String[] args) throws Exception {
66
// reset the security property to make sure that the algorithms
67
// and keys used in this test are not disabled unexpectedly.
68
String constraint = "DH keySize < " + Integer.valueOf(args[0]);
69
Security.setProperty("jdk.tls.disabledAlgorithms", constraint);
70
Security.setProperty("jdk.certpath.disabledAlgorithms", "");
71
72
(new UseStrongDHSizes()).run();
73
}
74
75
@Override
76
protected void runServerApplication(SSLSocket socket) throws Exception {
77
String ciphers[] = {
78
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
79
"TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
80
"SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
81
"SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"};
82
83
socket.setEnabledCipherSuites(ciphers);
84
socket.setWantClientAuth(true);
85
86
InputStream sslIS = socket.getInputStream();
87
OutputStream sslOS = socket.getOutputStream();
88
89
sslIS.read();
90
sslOS.write(85);
91
sslOS.flush();
92
}
93
94
@Override
95
protected void runClientApplication(SSLSocket socket) throws Exception {
96
String ciphers[] = {
97
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
98
"TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
99
"SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
100
"SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"};
101
socket.setEnabledCipherSuites(ciphers);
102
socket.setUseClientMode(true);
103
104
InputStream sslIS = socket.getInputStream();
105
OutputStream sslOS = socket.getOutputStream();
106
107
sslOS.write(280);
108
sslOS.flush();
109
sslIS.read();
110
}
111
}
112
113