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