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