Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/ssl/HandshakeHash/HandshakeHashCloneExhaustion.java
41152 views
1
/*
2
* Copyright (c) 2016, 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
// Please run in othervm mode. SunJSSE does not support dynamic system
26
// properties, no way to re-use system properties in samevm/agentvm mode.
27
//
28
29
/*
30
* @test
31
* @bug 8148421 8193683 8234728
32
* @summary Transport Layer Security (TLS) Session Hash and Extended
33
* Master Secret Extension
34
* @summary Increase the number of clones in the CloneableDigest
35
* @library /javax/net/ssl/templates
36
* @library /test/lib
37
* @compile DigestBase.java
38
* @run main/othervm HandshakeHashCloneExhaustion
39
* TLSv1.3 TLS_AES_128_GCM_SHA256
40
* @run main/othervm HandshakeHashCloneExhaustion
41
* TLSv1.2 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
42
* @run main/othervm HandshakeHashCloneExhaustion
43
* TLSv1.1 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
44
*/
45
46
import java.io.InputStream;
47
import java.io.OutputStream;
48
import java.security.MessageDigest;
49
import java.security.Security;
50
import javax.net.ssl.SSLSocket;
51
52
import jdk.test.lib.security.SecurityUtils;
53
54
public class HandshakeHashCloneExhaustion extends SSLSocketTemplate {
55
56
private static String[] protocol;
57
private static String[] ciphersuite;
58
private static String[] mds = { "SHA", "MD5", "SHA-256" };
59
60
/*
61
* ==================
62
* Run the test case.
63
*/
64
public static void main(String[] args) throws Exception {
65
// Add in a non-cloneable MD5/SHA1/SHA-256 implementation
66
Security.insertProviderAt(new MyProvider(), 1);
67
// make sure our provider is functioning
68
for (String s : mds) {
69
MessageDigest md = MessageDigest.getInstance(s);
70
String p = md.getProvider().getName();
71
if (!p.equals("MyProvider")) {
72
throw new RuntimeException("Unexpected provider: " + p);
73
}
74
}
75
76
if (args.length != 2) {
77
throw new Exception(
78
"Usage: HandshakeHashCloneExhaustion protocol ciphersuite");
79
}
80
81
System.out.println("Testing: " + args[0] + " " + args[1]);
82
protocol = new String [] { args[0] };
83
ciphersuite = new String[] { args[1] };
84
85
// Re-enable TLSv1.1 when test depends on it.
86
if (protocol[0].equals("TLSv1.1")) {
87
SecurityUtils.removeFromDisabledTlsAlgs(protocol[0]);
88
}
89
(new HandshakeHashCloneExhaustion()).run();
90
}
91
92
@Override
93
protected void runServerApplication(SSLSocket socket) throws Exception {
94
socket.setNeedClientAuth(true);
95
socket.setEnabledProtocols(protocol);
96
socket.setEnabledCipherSuites(ciphersuite);
97
98
// here comes the test logic
99
InputStream sslIS = socket.getInputStream();
100
OutputStream sslOS = socket.getOutputStream();
101
102
sslIS.read();
103
sslOS.write(85);
104
sslOS.flush();
105
}
106
107
@Override
108
protected void runClientApplication(SSLSocket socket) throws Exception {
109
InputStream sslIS = socket.getInputStream();
110
OutputStream sslOS = socket.getOutputStream();
111
112
sslOS.write(280);
113
sslOS.flush();
114
sslIS.read();
115
}
116
}
117
118