Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/net/ssl/compatibility/HrrTest.java
41152 views
1
/*
2
* Copyright (c) 2020, 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
* @summary This is an interop compatibility test on TLSv1.3 hello retry request.
27
*
28
* @library /test/lib
29
* ../TLSCommon
30
* ../TLSCommon/interop
31
* @compile -source 1.8 -target 1.8
32
* JdkInfoUtils.java
33
* ../TLSCommon/interop/JdkProcServer.java
34
* ../TLSCommon/interop/JdkProcClient.java
35
* @run main/manual HrrTest true
36
* @run main/manual HrrTest false
37
*/
38
39
import java.util.ArrayList;
40
import java.util.List;
41
import java.util.Set;
42
43
import jdk.test.lib.security.CertUtils;
44
45
public class HrrTest extends ExtInteropTest {
46
47
private JdkInfo serverJdkInfo;
48
private JdkInfo clientJdkInfo;
49
50
public HrrTest(JdkInfo serverJdkInfo, JdkInfo clientJdkInfo) {
51
super(new Jdk(serverJdkInfo.version, serverJdkInfo.javaPath),
52
new Jdk(clientJdkInfo.version, clientJdkInfo.javaPath));
53
54
this.serverJdkInfo = serverJdkInfo;
55
this.clientJdkInfo = clientJdkInfo;
56
}
57
58
@Override
59
protected boolean skipExecute() {
60
return super.skipExecute() || !supportsTLSv1_3();
61
}
62
63
private boolean supportsTLSv1_3() {
64
boolean supported = true;
65
66
if (!serverJdkInfo.enablesProtocol(Protocol.TLSV1_3)) {
67
System.out.println("The server doesn't support TLSv1.3.");
68
supported = false;
69
}
70
71
if (!clientJdkInfo.enablesProtocol(Protocol.TLSV1_3)) {
72
System.out.println("The client doesn't support TLSv1.3.");
73
supported = false;
74
}
75
76
return supported;
77
}
78
79
/*
80
* It takes the server to support secp384r1 only, and the client to support
81
* secp256r1 and secp384r1 in order, the server should respond hello retry
82
* request message.
83
* Please note that it has to specify the supported groups via property
84
* jdk.tls.namedGroups for JSSE peers.
85
*/
86
@Override
87
protected List<TestCase<ExtUseCase>> getTestCases() {
88
List<TestCase<ExtUseCase>> testCases = new ArrayList<>();
89
for (CipherSuite cipherSuite : new CipherSuite[] {
90
CipherSuite.TLS_AES_128_GCM_SHA256,
91
CipherSuite.TLS_AES_256_GCM_SHA384,
92
CipherSuite.TLS_CHACHA20_POLY1305_SHA256}) {
93
testCases.add(createTestCase(cipherSuite));
94
}
95
return testCases;
96
}
97
98
private TestCase<ExtUseCase> createTestCase(CipherSuite cipherSuite) {
99
Cert cert = new Cert(KeyAlgorithm.RSA, SignatureAlgorithm.RSA,
100
HashAlgorithm.SHA256, CertUtils.RSA_CERT, CertUtils.RSA_KEY);
101
CertTuple certTuple = new CertTuple(cert, cert);
102
103
ExtUseCase serverCase = ExtUseCase.newInstance();
104
serverCase.setCertTuple(certTuple);
105
serverCase.setNamedGroups(NamedGroup.SECP384R1);
106
107
ExtUseCase clientCase = ExtUseCase.newInstance();
108
clientCase.setCertTuple(certTuple);
109
clientCase.setProtocols(Protocol.TLSV1_3);
110
clientCase.setCipherSuites(cipherSuite);
111
clientCase.setNamedGroups(NamedGroup.SECP256R1, NamedGroup.SECP384R1);
112
113
return new TestCase<ExtUseCase>(serverCase, clientCase);
114
}
115
116
@Override
117
protected boolean ignoreTestCase(TestCase<ExtUseCase> testCase) {
118
CipherSuite cipherSuite = testCase.clientCase.getCipherSuite();
119
return !serverJdkInfo.enablesCipherSuite(cipherSuite)
120
|| !clientJdkInfo.supportsCipherSuite(cipherSuite);
121
}
122
123
@Override
124
protected JdkProcServer.Builder createServerBuilder(ExtUseCase useCase)
125
throws Exception {
126
JdkProcServer.Builder builder = new JdkProcServer.Builder();
127
builder.setJdk((Jdk) serverProduct);
128
builder.setCertTuple(useCase.getCertTuple());
129
builder.setProtocols(useCase.getProtocols());
130
builder.setCipherSuites(useCase.getCipherSuites());
131
builder.setClientAuth(useCase.isClientAuth());
132
builder.setServerNames(useCase.getServerNames());
133
builder.setAppProtocols(useCase.getAppProtocols());
134
builder.setNamedGroups(useCase.getNamedGroups());
135
return builder;
136
}
137
138
@Override
139
protected JdkProcClient.Builder createClientBuilder(ExtUseCase useCase)
140
throws Exception {
141
JdkProcClient.Builder builder = new JdkProcClient.Builder();
142
builder.setJdk((Jdk) clientProduct);
143
builder.setCertTuple(useCase.getCertTuple());
144
builder.setProtocols(useCase.getProtocols());
145
builder.setCipherSuites(useCase.getCipherSuites());
146
builder.setServerNames(useCase.getServerNames());
147
builder.setAppProtocols(useCase.getAppProtocols());
148
builder.setNamedGroups(useCase.getNamedGroups());
149
return builder;
150
}
151
152
public static void main(String[] args) throws Exception {
153
Boolean defaultJdkAsServer = Boolean.valueOf(args[0]);
154
155
Set<JdkInfo> jdkInfos = Utils.jdkInfoList();
156
for (JdkInfo jdkInfo : jdkInfos) {
157
HrrTest test = new HrrTest(
158
defaultJdkAsServer ? JdkInfo.DEFAULT : jdkInfo,
159
defaultJdkAsServer ? jdkInfo : JdkInfo.DEFAULT);
160
test.execute();
161
}
162
}
163
}
164
165