Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java
41152 views
1
/*
2
* Copyright (c) 2019, 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
// 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 8215790 8219389
32
* @summary Verify exception
33
* @library /test/lib
34
* @modules java.base/sun.security.util
35
* @run main/othervm ClientHelloBufferUnderflowException
36
*/
37
38
import javax.net.ssl.SSLHandshakeException;
39
40
import jdk.test.lib.hexdump.HexPrinter;
41
42
public class ClientHelloBufferUnderflowException extends ClientHelloInterOp {
43
/*
44
* Main entry point for this test.
45
*/
46
public static void main(String args[]) throws Exception {
47
try {
48
(new ClientHelloBufferUnderflowException()).run();
49
} catch (SSLHandshakeException e) {
50
System.out.println("Correct exception thrown: " + e);
51
return;
52
} catch (Exception e) {
53
System.out.println("Failed: Exception not SSLHandShakeException");
54
System.out.println(e.getMessage());
55
throw e;
56
}
57
58
throw new Exception("No expected exception");
59
}
60
61
@Override
62
protected byte[] createClientHelloMessage() {
63
// The ClientHello message in hex: 16 03 01 00 05 01 00 00 01 03
64
// Record Header:
65
// 16 - type is 0x16 (handshake record)
66
// 03 01 - protocol version is 3.1 (also known as TLS 1.0)
67
// 00 05 - 0x05 (5) bytes of handshake message follows
68
// Handshake Header:
69
// 01 - handshake message type 0x01 (client hello)
70
// 00 00 01 - 0x01 (1) bytes of client hello follows
71
// Client Version:
72
// 03 - incomplete client version
73
//
74
// (Based on https://tls.ulfheim.net)
75
byte[] bytes = {
76
0x16, 0x03, 0x01, 0x00, 0x05, 0x01, 0x00, 0x00, 0x01, 0x03};
77
78
System.out.println("The ClientHello message used");
79
try {
80
HexPrinter.simple().format(bytes);
81
} catch (Exception e) {
82
// ignore
83
}
84
85
return bytes;
86
}
87
}
88
89