Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/ssl/CipherSuite/SupportedGroups.java
41152 views
1
/*
2
* Copyright (c) 2019, 2021, 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 8171279
27
* @library /javax/net/ssl/templates
28
* @summary Test TLS connection with each individual supported group
29
* @run main/othervm SupportedGroups x25519
30
* @run main/othervm SupportedGroups x448
31
* @run main/othervm SupportedGroups secp256r1
32
* @run main/othervm SupportedGroups secp384r1
33
* @run main/othervm SupportedGroups secp521r1
34
* @run main/othervm SupportedGroups ffdhe2048
35
* @run main/othervm SupportedGroups ffdhe3072
36
* @run main/othervm SupportedGroups ffdhe4096
37
* @run main/othervm SupportedGroups ffdhe6144
38
* @run main/othervm SupportedGroups ffdhe8192
39
*/
40
import java.net.InetAddress;
41
import java.util.Arrays;
42
import javax.net.ssl.SSLSocket;
43
import javax.net.ssl.SSLServerSocket;
44
45
public class SupportedGroups extends SSLSocketTemplate {
46
47
private static volatile int index;
48
private static final String[][][] protocols = {
49
{{"TLSv1.3"}, {"TLSv1.3"}},
50
{{"TLSv1.3", "TLSv1.2"}, {"TLSv1.2"}},
51
{{"TLSv1.2"}, {"TLSv1.3", "TLSv1.2"}},
52
{{"TLSv1.2"}, {"TLSv1.2"}}
53
};
54
55
public SupportedGroups() {
56
this.serverAddress = InetAddress.getLoopbackAddress();
57
}
58
59
// Servers are configured before clients, increment test case after.
60
@Override
61
protected void configureClientSocket(SSLSocket socket) {
62
String[] ps = protocols[index][0];
63
64
System.out.print("Setting client protocol(s): ");
65
Arrays.stream(ps).forEachOrdered(System.out::print);
66
System.out.println();
67
68
socket.setEnabledProtocols(ps);
69
}
70
71
@Override
72
protected void configureServerSocket(SSLServerSocket serverSocket) {
73
String[] ps = protocols[index][1];
74
75
System.out.print("Setting server protocol(s): ");
76
Arrays.stream(ps).forEachOrdered(System.out::print);
77
System.out.println();
78
79
serverSocket.setEnabledProtocols(ps);
80
}
81
82
/*
83
* Run the test case.
84
*/
85
public static void main(String[] args) throws Exception {
86
System.setProperty("jdk.tls.namedGroups", args[0]);
87
88
for (index = 0; index < protocols.length; index++) {
89
(new SupportedGroups()).run();
90
}
91
}
92
}
93
94