summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorAdam Vartanian <flooey@google.com>2018-10-25 13:24:46 +0100
committerAdam Vartanian <flooey@google.com>2018-10-25 13:24:46 +0100
commit7a303618edefae1737c78e48c5f10b289f169dbe (patch)
tree8218eb45d39e8688bdb1e0df0d2452c9f461c8a4 /support
parentdba00a250ab3428773796bf3fcde3065ee1fa304 (diff)
Remove tlswire classes
These classes have only ever been used by Conscrypt, so they've been moved to the Conscrypt repo and can be deleted from here. Test: make checkbuild Change-Id: I9c18e18f1ede89a0d882300b5970030042328bf5
Diffstat (limited to 'support')
-rw-r--r--support/src/test/java/libcore/tlswire/handshake/CipherSuite.java471
-rw-r--r--support/src/test/java/libcore/tlswire/handshake/ClientHello.java108
-rw-r--r--support/src/test/java/libcore/tlswire/handshake/CompressionMethod.java76
-rw-r--r--support/src/test/java/libcore/tlswire/handshake/EllipticCurve.java83
-rw-r--r--support/src/test/java/libcore/tlswire/handshake/EllipticCurvesHelloExtension.java56
-rw-r--r--support/src/test/java/libcore/tlswire/handshake/HandshakeMessage.java62
-rw-r--r--support/src/test/java/libcore/tlswire/handshake/HelloExtension.java106
-rw-r--r--support/src/test/java/libcore/tlswire/handshake/ServerNameHelloExtension.java56
-rw-r--r--support/src/test/java/libcore/tlswire/record/TlsProtocols.java30
-rw-r--r--support/src/test/java/libcore/tlswire/record/TlsRecord.java40
-rw-r--r--support/src/test/java/libcore/tlswire/util/IoUtils.java59
-rw-r--r--support/src/test/java/libcore/tlswire/util/TlsProtocolVersion.java97
12 files changed, 0 insertions, 1244 deletions
diff --git a/support/src/test/java/libcore/tlswire/handshake/CipherSuite.java b/support/src/test/java/libcore/tlswire/handshake/CipherSuite.java
deleted file mode 100644
index af9e103053..0000000000
--- a/support/src/test/java/libcore/tlswire/handshake/CipherSuite.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.handshake;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * {@code CipherSuite} enum from TLS 1.2 RFC 5246.
- */
-public class CipherSuite {
- // The list of cipher suites below is based on IANA registry
- // https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml
- private static final CipherSuite[] CIPHER_SUITES = new CipherSuite[] {
- new CipherSuite(0x0000, "TLS_NULL_WITH_NULL_NULL"),
- new CipherSuite(0x0001, "TLS_RSA_WITH_NULL_MD5", "SSL_RSA_WITH_NULL_MD5"),
- new CipherSuite(0x0002, "TLS_RSA_WITH_NULL_SHA", "SSL_RSA_WITH_NULL_SHA"),
- new CipherSuite(0x0003, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_RC4_40_MD5"),
- new CipherSuite(0x0004, "TLS_RSA_WITH_RC4_128_MD5", "SSL_RSA_WITH_RC4_128_MD5"),
- new CipherSuite(0x0005, "TLS_RSA_WITH_RC4_128_SHA", "SSL_RSA_WITH_RC4_128_SHA"),
- new CipherSuite(0x0006, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5"),
- new CipherSuite(0x0007, "TLS_RSA_WITH_IDEA_CBC_SHA"),
- new CipherSuite(0x0008, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA",
- "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA"),
- new CipherSuite(0x0009, "TLS_RSA_WITH_DES_CBC_SHA", "SSL_RSA_WITH_DES_CBC_SHA"),
- new CipherSuite(0x000a, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x000b, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA"),
- new CipherSuite(0x000c, "TLS_DH_DSS_WITH_DES_CBC_SHA"),
- new CipherSuite(0x000d, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x000e, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA"),
- new CipherSuite(0x000f, "TLS_DH_RSA_WITH_DES_CBC_SHA"),
- new CipherSuite(0x0010, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x0011, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA",
- "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"),
- new CipherSuite(0x0012, "TLS_DHE_DSS_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA"),
- new CipherSuite(0x0013, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
- "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x0014, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
- "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA"),
- new CipherSuite(0x0015, "TLS_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA"),
- new CipherSuite(0x0016, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
- "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x0017, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5",
- "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5"),
- new CipherSuite(0x0018, "TLS_DH_anon_WITH_RC4_128_MD5", "SSL_DH_anon_WITH_RC4_128_MD5"),
- new CipherSuite(0x0019, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
- "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA"),
- new CipherSuite(0x001a, "TLS_DH_anon_WITH_DES_CBC_SHA", "SSL_DH_anon_WITH_DES_CBC_SHA"),
- new CipherSuite(0x001b, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA",
- "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x001e, "TLS_KRB5_WITH_DES_CBC_SHA"),
- new CipherSuite(0x001f, "TLS_KRB5_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x0020, "TLS_KRB5_WITH_RC4_128_SHA"),
- new CipherSuite(0x0021, "TLS_KRB5_WITH_IDEA_CBC_SHA"),
- new CipherSuite(0x0022, "TLS_KRB5_WITH_DES_CBC_MD5"),
- new CipherSuite(0x0023, "TLS_KRB5_WITH_3DES_EDE_CBC_MD5"),
- new CipherSuite(0x0024, "TLS_KRB5_WITH_RC4_128_MD5"),
- new CipherSuite(0x0025, "TLS_KRB5_WITH_IDEA_CBC_MD5"),
- new CipherSuite(0x0026, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA"),
- new CipherSuite(0x0027, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA"),
- new CipherSuite(0x0028, "TLS_KRB5_EXPORT_WITH_RC4_40_SHA"),
- new CipherSuite(0x0029, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5"),
- new CipherSuite(0x002a, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5"),
- new CipherSuite(0x002b, "TLS_KRB5_EXPORT_WITH_RC4_40_MD5"),
- new CipherSuite(0x002c, "TLS_PSK_WITH_NULL_SHA"),
- new CipherSuite(0x002d, "TLS_DHE_PSK_WITH_NULL_SHA"),
- new CipherSuite(0x002e, "TLS_RSA_PSK_WITH_NULL_SHA"),
- new CipherSuite(0x002f, "TLS_RSA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x0030, "TLS_DH_DSS_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x0031, "TLS_DH_RSA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x0032, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x0033, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x0034, "TLS_DH_anon_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x0035, "TLS_RSA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x0036, "TLS_DH_DSS_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x0037, "TLS_DH_RSA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x0038, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x0039, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x003a, "TLS_DH_anon_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x003b, "TLS_RSA_WITH_NULL_SHA256"),
- new CipherSuite(0x003c, "TLS_RSA_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x003d, "TLS_RSA_WITH_AES_256_CBC_SHA256"),
- new CipherSuite(0x003e, "TLS_DH_DSS_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x003f, "TLS_DH_RSA_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x0040, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x0041, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA"),
- new CipherSuite(0x0042, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA"),
- new CipherSuite(0x0043, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA"),
- new CipherSuite(0x0044, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA"),
- new CipherSuite(0x0045, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA"),
- new CipherSuite(0x0046, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA"),
- new CipherSuite(0x0060, "TLS_RSA_EXPORT1024_WITH_RC4_56_MD5"),
- new CipherSuite(0x0061, "TLS_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5"),
- new CipherSuite(0x0062, "TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA"),
- new CipherSuite(0x0063, "TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA"),
- new CipherSuite(0x0064, "TLS_RSA_EXPORT1024_WITH_RC4_56_SHA"),
- new CipherSuite(0x0065, "TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA"),
- new CipherSuite(0x0066, "TLS_DHE_DSS_WITH_RC4_128_SHA"),
- new CipherSuite(0x0067, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x0068, "TLS_DH_DSS_WITH_AES_256_CBC_SHA256"),
- new CipherSuite(0x0069, "TLS_DH_RSA_WITH_AES_256_CBC_SHA256"),
- new CipherSuite(0x006a, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256"),
- new CipherSuite(0x006b, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256"),
- new CipherSuite(0x006c, "TLS_DH_anon_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x006d, "TLS_DH_anon_WITH_AES_256_CBC_SHA256"),
- new CipherSuite(0x0084, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA"),
- new CipherSuite(0x0085, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA"),
- new CipherSuite(0x0086, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA"),
- new CipherSuite(0x0087, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA"),
- new CipherSuite(0x0088, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA"),
- new CipherSuite(0x0089, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA"),
- new CipherSuite(0x008a, "TLS_PSK_WITH_RC4_128_SHA"),
- new CipherSuite(0x008b, "TLS_PSK_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x008c, "TLS_PSK_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x008d, "TLS_PSK_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x008e, "TLS_DHE_PSK_WITH_RC4_128_SHA"),
- new CipherSuite(0x008f, "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x0090, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x0091, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x0092, "TLS_RSA_PSK_WITH_RC4_128_SHA"),
- new CipherSuite(0x0093, "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0x0094, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0x0095, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0x0096, "TLS_RSA_WITH_SEED_CBC_SHA"),
- new CipherSuite(0x0097, "TLS_DH_DSS_WITH_SEED_CBC_SHA"),
- new CipherSuite(0x0098, "TLS_DH_RSA_WITH_SEED_CBC_SHA"),
- new CipherSuite(0x0099, "TLS_DHE_DSS_WITH_SEED_CBC_SHA"),
- new CipherSuite(0x009a, "TLS_DHE_RSA_WITH_SEED_CBC_SHA"),
- new CipherSuite(0x009b, "TLS_DH_anon_WITH_SEED_CBC_SHA"),
- new CipherSuite(0x009c, "TLS_RSA_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x009d, "TLS_RSA_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x009e, "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x009f, "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x00a0, "TLS_DH_RSA_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x00a1, "TLS_DH_RSA_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x00a2, "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x00a3, "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x00a4, "TLS_DH_DSS_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x00a5, "TLS_DH_DSS_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x00a6, "TLS_DH_anon_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x00a7, "TLS_DH_anon_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x00a8, "TLS_PSK_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x00a9, "TLS_PSK_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x00aa, "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x00ab, "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x00ac, "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0x00ad, "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0x00ae, "TLS_PSK_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x00af, "TLS_PSK_WITH_AES_256_CBC_SHA384"),
- new CipherSuite(0x00b0, "TLS_PSK_WITH_NULL_SHA256"),
- new CipherSuite(0x00b1, "TLS_PSK_WITH_NULL_SHA384"),
- new CipherSuite(0x00b2, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x00b3, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384"),
- new CipherSuite(0x00b4, "TLS_DHE_PSK_WITH_NULL_SHA256"),
- new CipherSuite(0x00b5, "TLS_DHE_PSK_WITH_NULL_SHA384"),
- new CipherSuite(0x00b6, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0x00b7, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384"),
- new CipherSuite(0x00b8, "TLS_RSA_PSK_WITH_NULL_SHA256"),
- new CipherSuite(0x00b9, "TLS_RSA_PSK_WITH_NULL_SHA384"),
- new CipherSuite(0x00ba, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0x00bb, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0x00bc, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0x00bd, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0x00be, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0x00bf, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0x00c0, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256"),
- new CipherSuite(0x00c1, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256"),
- new CipherSuite(0x00c2, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256"),
- new CipherSuite(0x00c3, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256"),
- new CipherSuite(0x00c4, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256"),
- new CipherSuite(0x00c5, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256"),
- new CipherSuite(0x00ff, "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"),
- new CipherSuite(0x5600, "TLS_FALLBACK_SCSV"),
- new CipherSuite(0xc001, "TLS_ECDH_ECDSA_WITH_NULL_SHA"),
- new CipherSuite(0xc002, "TLS_ECDH_ECDSA_WITH_RC4_128_SHA"),
- new CipherSuite(0xc003, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc004, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc005, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc006, "TLS_ECDHE_ECDSA_WITH_NULL_SHA"),
- new CipherSuite(0xc007, "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA"),
- new CipherSuite(0xc008, "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc009, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc00a, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc00b, "TLS_ECDH_RSA_WITH_NULL_SHA"),
- new CipherSuite(0xc00c, "TLS_ECDH_RSA_WITH_RC4_128_SHA"),
- new CipherSuite(0xc00d, "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc00e, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc00f, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc010, "TLS_ECDHE_RSA_WITH_NULL_SHA"),
- new CipherSuite(0xc011, "TLS_ECDHE_RSA_WITH_RC4_128_SHA"),
- new CipherSuite(0xc012, "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc013, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc014, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc015, "TLS_ECDH_anon_WITH_NULL_SHA"),
- new CipherSuite(0xc016, "TLS_ECDH_anon_WITH_RC4_128_SHA"),
- new CipherSuite(0xc017, "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc018, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc019, "TLS_ECDH_anon_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc01a, "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc01b, "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc01c, "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc01d, "TLS_SRP_SHA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc01e, "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc01f, "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc020, "TLS_SRP_SHA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc021, "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc022, "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc023, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0xc024, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384"),
- new CipherSuite(0xc025, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0xc026, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384"),
- new CipherSuite(0xc027, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0xc028, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"),
- new CipherSuite(0xc029, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0xc02a, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384"),
- new CipherSuite(0xc02b, "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0xc02c, "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0xc02d, "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0xc02e, "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0xc02f, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0xc030, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0xc031, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256"),
- new CipherSuite(0xc032, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384"),
- new CipherSuite(0xc033, "TLS_ECDHE_PSK_WITH_RC4_128_SHA"),
- new CipherSuite(0xc034, "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA"),
- new CipherSuite(0xc035, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA"),
- new CipherSuite(0xc036, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA"),
- new CipherSuite(0xc037, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256"),
- new CipherSuite(0xc038, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384"),
- new CipherSuite(0xc039, "TLS_ECDHE_PSK_WITH_NULL_SHA"),
- new CipherSuite(0xc03a, "TLS_ECDHE_PSK_WITH_NULL_SHA256"),
- new CipherSuite(0xc03b, "TLS_ECDHE_PSK_WITH_NULL_SHA384"),
- new CipherSuite(0xc03c, "TLS_RSA_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc03d, "TLS_RSA_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc03e, "TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc03f, "TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc040, "TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc041, "TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc042, "TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc043, "TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc044, "TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc045, "TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc046, "TLS_DH_anon_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc047, "TLS_DH_anon_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc048, "TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc049, "TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc04a, "TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc04b, "TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc04c, "TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc04d, "TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc04e, "TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc04f, "TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc050, "TLS_RSA_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc051, "TLS_RSA_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc052, "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc053, "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc054, "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc055, "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc056, "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc057, "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc058, "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc059, "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc05a, "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc05b, "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc05c, "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc05d, "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc05e, "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc05f, "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc060, "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc061, "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc062, "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc063, "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc064, "TLS_PSK_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc065, "TLS_PSK_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc066, "TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc067, "TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc068, "TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc069, "TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc06a, "TLS_PSK_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc06b, "TLS_PSK_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc06c, "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc06d, "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc06e, "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256"),
- new CipherSuite(0xc06f, "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384"),
- new CipherSuite(0xc070, "TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256"),
- new CipherSuite(0xc071, "TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384"),
- new CipherSuite(0xc072, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0xc073, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384"),
- new CipherSuite(0xc074, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0xc075, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384"),
- new CipherSuite(0xc076, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0xc077, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384"),
- new CipherSuite(0xc078, "TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0xc079, "TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384"),
- new CipherSuite(0xc07a, "TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc07b, "TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc07c, "TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc07d, "TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc07e, "TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc07f, "TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc080, "TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc081, "TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc082, "TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc083, "TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc084, "TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc085, "TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc086, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc087, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc088, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc089, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc08a, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc08b, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc08c, "TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc08d, "TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc08e, "TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc08f, "TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc090, "TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc091, "TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc092, "TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256"),
- new CipherSuite(0xc093, "TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384"),
- new CipherSuite(0xc094, "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0xc095, "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384"),
- new CipherSuite(0xc096, "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0xc097, "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384"),
- new CipherSuite(0xc098, "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0xc099, "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384"),
- new CipherSuite(0xc09a, "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256"),
- new CipherSuite(0xc09b, "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384"),
- new CipherSuite(0xc09c, "TLS_RSA_WITH_AES_128_CCM"),
- new CipherSuite(0xc09d, "TLS_RSA_WITH_AES_256_CCM"),
- new CipherSuite(0xc09e, "TLS_DHE_RSA_WITH_AES_128_CCM"),
- new CipherSuite(0xc09f, "TLS_DHE_RSA_WITH_AES_256_CCM"),
- new CipherSuite(0xc0a0, "TLS_RSA_WITH_AES_128_CCM_8"),
- new CipherSuite(0xc0a1, "TLS_RSA_WITH_AES_256_CCM_8"),
- new CipherSuite(0xc0a2, "TLS_DHE_RSA_WITH_AES_128_CCM_8"),
- new CipherSuite(0xc0a3, "TLS_DHE_RSA_WITH_AES_256_CCM_8"),
- new CipherSuite(0xc0a4, "TLS_PSK_WITH_AES_128_CCM"),
- new CipherSuite(0xc0a5, "TLS_PSK_WITH_AES_256_CCM"),
- new CipherSuite(0xc0a6, "TLS_DHE_PSK_WITH_AES_128_CCM"),
- new CipherSuite(0xc0a7, "TLS_DHE_PSK_WITH_AES_256_CCM"),
- new CipherSuite(0xc0a8, "TLS_PSK_WITH_AES_128_CCM_8"),
- new CipherSuite(0xc0a9, "TLS_PSK_WITH_AES_256_CCM_8"),
- new CipherSuite(0xc0aa, "TLS_PSK_DHE_WITH_AES_128_CCM_8"),
- new CipherSuite(0xc0ab, "TLS_PSK_DHE_WITH_AES_256_CCM_8"),
- new CipherSuite(0xc0ac, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM"),
- new CipherSuite(0xc0ad, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM"),
- new CipherSuite(0xc0ae, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8"),
- new CipherSuite(0xc0af, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8"),
- new CipherSuite(0xcc13, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_OLD"),
- new CipherSuite(0xcc14, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_OLD"),
- new CipherSuite(0xcc15, "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_OLD"),
- new CipherSuite(0xcca8, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"),
- new CipherSuite(0xcca9, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"),
- new CipherSuite(0xccaa, "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256"),
- new CipherSuite(0xccab, "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256"),
- new CipherSuite(0xccac, "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256"),
- new CipherSuite(0xccad, "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256"),
- new CipherSuite(0xccae, "TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256"),
- };
-
- private static final Map<Integer, CipherSuite> CODE_TO_CIPHER_SUITE;
- private static final Map<String, CipherSuite> NAME_TO_CIPHER_SUITE;
-
-
- static {
- Map<Integer, CipherSuite> byCode = new HashMap<Integer, CipherSuite>();
- Map<String, CipherSuite> byName = new HashMap<String, CipherSuite>();
- for (CipherSuite cipherSuite : CIPHER_SUITES) {
- if (byCode.put(cipherSuite.code, cipherSuite) != null) {
- throw new RuntimeException(
- "Cipher suite multiply defined: " + Integer.toHexString(cipherSuite.code));
- }
- String name = cipherSuite.name;
- if (byName.put(name, cipherSuite) != null) {
- throw new RuntimeException(
- "Cipher suite multiply defined: " + cipherSuite.name);
- }
- String androidName = cipherSuite.getAndroidName();
- if (!name.equals(androidName)) {
- if (byName.put(androidName, cipherSuite) != null) {
- throw new RuntimeException(
- "Cipher suite multiply defined: " + cipherSuite.androidName);
- }
- }
- }
-
- CODE_TO_CIPHER_SUITE = byCode;
- NAME_TO_CIPHER_SUITE = byName;
- }
-
- public final int code;
- public final String name;
- private final String androidName;
-
- private CipherSuite(int code, String name) {
- this.code = code;
- this.name = name;
- this.androidName = null;
- }
-
- private CipherSuite(int code, String name, String androidName) {
- this.code = code;
- this.name = name;
- this.androidName = androidName;
- }
-
- public static CipherSuite valueOf(String name) {
- CipherSuite result = NAME_TO_CIPHER_SUITE.get(name);
- if (result != null) {
- return result;
- }
- throw new IllegalArgumentException("Unknown cipher suite: " + name);
- }
-
- public static CipherSuite valueOf(int code) {
- CipherSuite result = CODE_TO_CIPHER_SUITE.get(code);
- if (result != null) {
- return result;
- }
- return new CipherSuite(code, Integer.toHexString(code));
- }
-
- public String getAndroidName() {
- return (androidName != null) ? androidName : name;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + code;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- CipherSuite other = (CipherSuite) obj;
- if (code != other.code) {
- return false;
- }
- return true;
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/handshake/ClientHello.java b/support/src/test/java/libcore/tlswire/handshake/ClientHello.java
deleted file mode 100644
index dd42cb1b0c..0000000000
--- a/support/src/test/java/libcore/tlswire/handshake/ClientHello.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.handshake;
-
-import libcore.tlswire.util.TlsProtocolVersion;
-import libcore.tlswire.util.IoUtils;
-import java.io.ByteArrayInputStream;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * {@link ClientHello} {@link HandshakeMessage} from TLS 1.2 RFC 5246.
- */
-public class ClientHello extends HandshakeMessage {
- public TlsProtocolVersion clientVersion;
- public byte[] random;
- public byte[] sessionId;
- public List<CipherSuite> cipherSuites;
- public List<CompressionMethod> compressionMethods;
-
- /** Extensions or {@code null} for no extensions. */
- public List<HelloExtension> extensions;
-
- @Override
- protected void parseBody(DataInput in) throws IOException {
- clientVersion = TlsProtocolVersion.read(in);
- random = new byte[32];
- in.readFully(random);
- sessionId = IoUtils.readTlsVariableLengthByteVector(in, 32);
- int[] cipherSuiteCodes = IoUtils.readTlsVariableLengthUnsignedShortVector(in, 0xfffe);
- cipherSuites = new ArrayList<CipherSuite>(cipherSuiteCodes.length);
- for (int i = 0; i < cipherSuiteCodes.length; i++) {
- cipherSuites.add(CipherSuite.valueOf(cipherSuiteCodes[i]));
- }
- byte[] compressionMethodCodes = IoUtils.readTlsVariableLengthByteVector(in, 0xff);
- compressionMethods = new ArrayList<CompressionMethod>(compressionMethodCodes.length);
- for (int i = 0; i < compressionMethodCodes.length; i++) {
- int code = compressionMethodCodes[i] & 0xff;
- compressionMethods.add(CompressionMethod.valueOf(code));
- }
-
- int extensionsSectionSize;
- try {
- extensionsSectionSize = in.readUnsignedShort();
- } catch (EOFException e) {
- // No extensions present
- extensionsSectionSize = 0;
- }
-
- if (extensionsSectionSize > 0) {
- extensions = new ArrayList<HelloExtension>();
- byte[] extensionsBytes = new byte[extensionsSectionSize];
- in.readFully(extensionsBytes);
- ByteArrayInputStream extensionsIn = new ByteArrayInputStream(extensionsBytes);
- DataInput extensionsDataIn = new DataInputStream(extensionsIn);
- while (extensionsIn.available() > 0) {
- try {
- extensions.add(HelloExtension.read(extensionsDataIn));
- } catch (IOException e) {
- throw new IOException(
- "Failed to read HelloExtension #" + (extensions.size() + 1));
- }
- }
- }
- }
-
- public HelloExtension findExtensionByType(int extensionType) {
- if (extensions == null) {
- return null;
- }
- for (HelloExtension extension : extensions) {
- if (extension.type == extensionType) {
- return extension;
- }
- }
- return null;
- }
-
- @Override
- public String toString() {
- return "ClientHello{client version: " + clientVersion
- + ", random: " + new BigInteger(1, random).toString(16)
- + ", sessionId: " + new BigInteger(1, sessionId).toString(16)
- + ", cipher suites: " + cipherSuites
- + ", compression methods: " + compressionMethods
- + ((extensions != null) ? (", extensions: " + String.valueOf(extensions)) : "")
- + "}";
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/handshake/CompressionMethod.java b/support/src/test/java/libcore/tlswire/handshake/CompressionMethod.java
deleted file mode 100644
index 0f4f61937f..0000000000
--- a/support/src/test/java/libcore/tlswire/handshake/CompressionMethod.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.handshake;
-
-/**
- * {@code CompressionMethod} enum from TLS 1.2 RFC 5246.
- */
-public class CompressionMethod {
-
- public static final CompressionMethod NULL = new CompressionMethod(0, "null");
- public static final CompressionMethod DEFLATE = new CompressionMethod(1, "deflate");
-
- public final int type;
- public final String name;
-
- private CompressionMethod(int type, String name) {
- this.type = type;
- this.name = name;
- }
-
- public static CompressionMethod valueOf(int type) {
- switch (type) {
- case 0:
- return NULL;
- case 1:
- return DEFLATE;
- default:
- return new CompressionMethod(type, String.valueOf(type));
- }
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + type;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- CompressionMethod other = (CompressionMethod) obj;
- if (type != other.type) {
- return false;
- }
- return true;
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/handshake/EllipticCurve.java b/support/src/test/java/libcore/tlswire/handshake/EllipticCurve.java
deleted file mode 100644
index 51bcf8e855..0000000000
--- a/support/src/test/java/libcore/tlswire/handshake/EllipticCurve.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.handshake;
-
-/**
- * {@code EllipticCurve} enum from RFC 4492 section 5.1.1. Curves are assigned
- * via the
- * <a href="https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8">IANA registry</a>.
- */
-public enum EllipticCurve {
- SECT163K1(1, "sect163k1"),
- SECT163R1(2, "sect163r1"),
- SECT163R2(3, "sect163r2"),
- SECT193R1(4, "sect193r1"),
- SECT193R2(5, "sect193r2"),
- SECT233K1(6, "sect233k1"),
- SECT233R1(7, "sect233r1"),
- SECT239K1(8, "sect239k1"),
- SECT283K1(9, "sect283k1"),
- SECT283R1(10, "sect283r1"),
- SECT409K1(11, "sect409k1"),
- SECT409R1(12, "sect409r1"),
- SECT571K1(13, "sect571k1"),
- SECT571R1(14, "sect571r1"),
- SECP160K1(15, "secp160k1"),
- SECP160R1(16, "secp160r1"),
- SECP160R2(17, "secp160r2"),
- SECP192K1(18, "secp192k1"),
- SECP192R1(19, "secp192r1"),
- SECP224K1(20, "secp224k1"),
- SECP224R1(21, "secp224r1"),
- SECP256K1(22, "secp256k1"),
- SECP256R1(23, "secp256r1"),
- SECP384R1(24, "secp384r1"),
- SECP521R1(25, "secp521r1"),
- BRAINPOOLP256R1(26, "brainpoolP256r1"),
- BRAINPOOLP384R1(27, "brainpoolP384r1"),
- BRAINPOOLP521R1(28, "brainpoolP521r1"),
- X25519(29, "x25519"),
- X448(30, "x448"),
- ARBITRARY_PRIME(0xFF01, "arbitrary_explicit_prime_curves"),
- ARBITRARY_CHAR2(0xFF02, "arbitrary_explicit_char2_curves");
-
- public final int identifier;
- public final String name;
-
- private EllipticCurve(int identifier, String name) {
- this.identifier = identifier;
- this.name = name;
- }
-
- public static EllipticCurve fromIdentifier(int identifier) {
- for (EllipticCurve curve : values()) {
- if (curve.identifier == identifier) {
- return curve;
- }
- }
- throw new AssertionError("Unknown curve identifier " + identifier);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(name);
- sb.append(" (");
- sb.append(identifier);
- sb.append(')');
- return sb.toString();
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/handshake/EllipticCurvesHelloExtension.java b/support/src/test/java/libcore/tlswire/handshake/EllipticCurvesHelloExtension.java
deleted file mode 100644
index 19749a37ec..0000000000
--- a/support/src/test/java/libcore/tlswire/handshake/EllipticCurvesHelloExtension.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.handshake;
-
-import libcore.tlswire.util.IoUtils;
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * {@code elliptic_curves} {@link HelloExtension} from RFC 4492 section 5.1.1.
- */
-public class EllipticCurvesHelloExtension extends HelloExtension {
- public List<EllipticCurve> supported;
- public boolean wellFormed;
-
- @Override
- protected void parseData() throws IOException {
- byte[] ellipticCurvesListBytes = IoUtils.readTlsVariableLengthByteVector(
- new DataInputStream(new ByteArrayInputStream(data)), 0xffff);
- ByteArrayInputStream ellipticCurvesListIn = new ByteArrayInputStream(ellipticCurvesListBytes);
- DataInputStream in = new DataInputStream(ellipticCurvesListIn);
- wellFormed = (ellipticCurvesListIn.available() % 2) == 0;
- supported = new ArrayList<EllipticCurve>(ellipticCurvesListIn.available() / 2);
- while (ellipticCurvesListIn.available() >= 2) {
- int curve_id = in.readUnsignedShort();
- supported.add(EllipticCurve.fromIdentifier(curve_id));
- }
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("HelloExtension{type: elliptic_curves, wellFormed: ");
- sb.append(wellFormed);
- sb.append(", supported: ");
- sb.append(supported);
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/handshake/HandshakeMessage.java b/support/src/test/java/libcore/tlswire/handshake/HandshakeMessage.java
deleted file mode 100644
index a855b46e22..0000000000
--- a/support/src/test/java/libcore/tlswire/handshake/HandshakeMessage.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.handshake;
-
-import libcore.tlswire.util.IoUtils;
-import java.io.ByteArrayInputStream;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.IOException;
-
-/**
- * Handshake Protocol message from TLS 1.2 RFC 5246.
- */
-public class HandshakeMessage {
- public static final int TYPE_CLIENT_HELLO = 1;
-
- public int type;
- public byte[] body;
-
- /**
- * Parses the provided TLS record as a handshake message.
- */
- public static HandshakeMessage read(DataInput in) throws IOException {
- int type = in.readUnsignedByte();
- HandshakeMessage result;
- switch (type) {
- case TYPE_CLIENT_HELLO:
- result = new ClientHello();
- break;
- default:
- result = new HandshakeMessage();
- break;
- }
- result.type = type;
- int bodyLength = IoUtils.readUnsignedInt24(in);
- result.body = new byte[bodyLength];
- in.readFully(result.body);
- result.parseBody(new DataInputStream(new ByteArrayInputStream(result.body)));
- return result;
- }
-
- /**
- * Parses the provided body. The default implementation does nothing.
- *
- * @throws IOException if an I/O error occurs.
- */
- protected void parseBody(@SuppressWarnings("unused") DataInput in) throws IOException {}
-}
diff --git a/support/src/test/java/libcore/tlswire/handshake/HelloExtension.java b/support/src/test/java/libcore/tlswire/handshake/HelloExtension.java
deleted file mode 100644
index 567c082c88..0000000000
--- a/support/src/test/java/libcore/tlswire/handshake/HelloExtension.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.handshake;
-
-import libcore.tlswire.util.IoUtils;
-import java.io.DataInput;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * {@code HelloExtension} struct from TLS 1.2 RFC 5246.
- */
-public class HelloExtension {
-
- public static final int TYPE_SERVER_NAME = 0;
- public static final int TYPE_ELLIPTIC_CURVES = 10;
- public static final int TYPE_PADDING = 21;
- public static final int TYPE_SESSION_TICKET = 35;
- public static final int TYPE_RENEGOTIATION_INFO = 65281;
-
- private static final Map<Integer, String> TYPE_TO_NAME = new HashMap<Integer, String>();
- static {
- TYPE_TO_NAME.put(TYPE_SERVER_NAME, "server_name");
- TYPE_TO_NAME.put(1, "max_fragment_length");
- TYPE_TO_NAME.put(2, "client_certificate_url");
- TYPE_TO_NAME.put(3, "trusted_ca_keys");
- TYPE_TO_NAME.put(4, "truncated_hmac");
- TYPE_TO_NAME.put(5, "status_request");
- TYPE_TO_NAME.put(6, "user_mapping");
- TYPE_TO_NAME.put(7, "client_authz");
- TYPE_TO_NAME.put(8, "server_authz");
- TYPE_TO_NAME.put(9, "cert_type");
- TYPE_TO_NAME.put(TYPE_ELLIPTIC_CURVES, "elliptic_curves");
- TYPE_TO_NAME.put(11, "ec_point_formats");
- TYPE_TO_NAME.put(12, "srp");
- TYPE_TO_NAME.put(13, "signature_algorithms");
- TYPE_TO_NAME.put(14, "use_srtp");
- TYPE_TO_NAME.put(15, "heartbeat");
- TYPE_TO_NAME.put(16, "application_layer_protocol_negotiation");
- TYPE_TO_NAME.put(17, "status_request_v2");
- TYPE_TO_NAME.put(18, "signed_certificate_timestamp");
- TYPE_TO_NAME.put(19, "client_certificate_type");
- TYPE_TO_NAME.put(20, "server_certificate_type");
- TYPE_TO_NAME.put(TYPE_PADDING, "padding");
- TYPE_TO_NAME.put(TYPE_SESSION_TICKET, "SessionTicket");
- TYPE_TO_NAME.put(13172, "next_protocol_negotiation");
- TYPE_TO_NAME.put(30031, "Channel ID (old)");
- TYPE_TO_NAME.put(30032, "Channel ID (new)");
- TYPE_TO_NAME.put(TYPE_RENEGOTIATION_INFO, "renegotiation_info");
- }
-
- public int type;
- public String name;
- public byte[] data;
-
- public static HelloExtension read(DataInput in) throws IOException {
- int type = in.readUnsignedShort();
- HelloExtension result;
- switch (type) {
- case TYPE_SERVER_NAME:
- result = new ServerNameHelloExtension();
- break;
- case TYPE_ELLIPTIC_CURVES:
- result = new EllipticCurvesHelloExtension();
- break;
- default:
- result = new HelloExtension();
- break;
- }
- result.type = type;
- result.name = TYPE_TO_NAME.get(result.type);
- if (result.name == null) {
- result.name = String.valueOf(result.type);
- }
- result.data = IoUtils.readTlsVariableLengthByteVector(in, 0xffff);
- result.parseData();
- return result;
- }
-
- /**
- * @throws IOException
- */
- protected void parseData() throws IOException {}
-
- @Override
- public String toString() {
- return "HelloExtension{type: " + name + ", data: " + new BigInteger(1, data).toString(16)
- + "}";
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/handshake/ServerNameHelloExtension.java b/support/src/test/java/libcore/tlswire/handshake/ServerNameHelloExtension.java
deleted file mode 100644
index 5b062460c0..0000000000
--- a/support/src/test/java/libcore/tlswire/handshake/ServerNameHelloExtension.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.handshake;
-
-import libcore.tlswire.util.IoUtils;
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * {@code server_name} (SNI) {@link HelloExtension} from TLS 1.2 RFC 5246.
- */
-public class ServerNameHelloExtension extends HelloExtension {
- private static final int TYPE_HOST_NAME = 0;
-
- public List<String> hostnames;
-
- @Override
- protected void parseData() throws IOException {
- byte[] serverNameListBytes = IoUtils.readTlsVariableLengthByteVector(
- new DataInputStream(new ByteArrayInputStream(data)), 0xffff);
- ByteArrayInputStream serverNameListIn = new ByteArrayInputStream(serverNameListBytes);
- DataInputStream in = new DataInputStream(serverNameListIn);
- hostnames = new ArrayList<String>();
- while (serverNameListIn.available() > 0) {
- int type = in.readUnsignedByte();
- if (type != TYPE_HOST_NAME) {
- throw new IOException("Unsupported ServerName type: " + type);
- }
- byte[] hostnameBytes = IoUtils.readTlsVariableLengthByteVector(in, 0xffff);
- String hostname = new String(hostnameBytes, "US-ASCII");
- hostnames.add(hostname);
- }
- }
-
- @Override
- public String toString() {
- return "HelloExtension{type: server_name, hostnames: " + hostnames + "}";
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/record/TlsProtocols.java b/support/src/test/java/libcore/tlswire/record/TlsProtocols.java
deleted file mode 100644
index 0ce0d35bf9..0000000000
--- a/support/src/test/java/libcore/tlswire/record/TlsProtocols.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.record;
-
-/**
- * Protocols that can run over the TLS Record Protocol from TLS 1.2 RFC 5246.
- */
-public class TlsProtocols {
- public static final int CHANGE_CIPHER_SPEC = 20;
- public static final int ALERT = 21;
- public static final int HANDSHAKE = 22;
- public static final int APPLICATION_DATA = 23;
- public static final int HEARTBEAT = 24;
-
- private TlsProtocols() {}
-}
diff --git a/support/src/test/java/libcore/tlswire/record/TlsRecord.java b/support/src/test/java/libcore/tlswire/record/TlsRecord.java
deleted file mode 100644
index 1b6040765b..0000000000
--- a/support/src/test/java/libcore/tlswire/record/TlsRecord.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.record;
-
-import libcore.tlswire.util.TlsProtocolVersion;
-import java.io.DataInput;
-import java.io.IOException;
-
-/**
- * TLS Record Protocol record from TLS 1.2 RFC 5246.
- */
-public class TlsRecord {
- public int type;
- public TlsProtocolVersion version;
- public byte[] fragment;
-
- public static TlsRecord read(DataInput in) throws IOException {
- TlsRecord result = new TlsRecord();
- result.type = in.readUnsignedByte();
- result.version = TlsProtocolVersion.read(in);
- int fragmentLength = in.readUnsignedShort();
- result.fragment = new byte[fragmentLength];
- in.readFully(result.fragment);
- return result;
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/util/IoUtils.java b/support/src/test/java/libcore/tlswire/util/IoUtils.java
deleted file mode 100644
index 1e2d8f2ef7..0000000000
--- a/support/src/test/java/libcore/tlswire/util/IoUtils.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.util;
-
-import java.io.DataInput;
-import java.io.IOException;
-
-public class IoUtils {
-
- public static int readUnsignedInt24(DataInput in) throws IOException {
- return (in.readUnsignedByte() << 16) | in.readUnsignedShort();
- }
-
- public static byte[] readTlsVariableLengthByteVector(DataInput in, int maxSizeBytes)
- throws IOException {
- int sizeBytes = readTlsVariableLengthVectorSizeBytes(in, maxSizeBytes);
- byte[] result = new byte[sizeBytes];
- in.readFully(result);
- return result;
- }
-
- public static int[] readTlsVariableLengthUnsignedShortVector(DataInput in, int maxSizeBytes)
- throws IOException {
- int sizeBytes = readTlsVariableLengthVectorSizeBytes(in, maxSizeBytes);
- int elementCount = sizeBytes / 2;
- int[] result = new int[elementCount];
- for (int i = 0; i < elementCount; i++) {
- result[i] = in.readUnsignedShort();
- }
- return result;
- }
-
- private static int readTlsVariableLengthVectorSizeBytes(DataInput in, int maxSizeBytes)
- throws IOException {
- if (maxSizeBytes < 0x100) {
- return in.readUnsignedByte();
- } else if (maxSizeBytes < 0x10000) {
- return in.readUnsignedShort();
- } else if (maxSizeBytes < 0x1000000) {
- return readUnsignedInt24(in);
- } else {
- return in.readInt();
- }
- }
-}
diff --git a/support/src/test/java/libcore/tlswire/util/TlsProtocolVersion.java b/support/src/test/java/libcore/tlswire/util/TlsProtocolVersion.java
deleted file mode 100644
index f58faf21b7..0000000000
--- a/support/src/test/java/libcore/tlswire/util/TlsProtocolVersion.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.tlswire.util;
-
-import java.io.DataInput;
-import java.io.IOException;
-
-/**
- * {@code ProtovolVersion} struct from TLS 1.2 RFC 5246.
- */
-public class TlsProtocolVersion {
- public static final TlsProtocolVersion SSLV3 = new TlsProtocolVersion(3, 0, "SSLv3");
- public static final TlsProtocolVersion TLSv1_0 = new TlsProtocolVersion(3, 1, "TLSv1.0");
- public static final TlsProtocolVersion TLSv1_1 = new TlsProtocolVersion(3, 2, "TLSv1.1");
- public static final TlsProtocolVersion TLSv1_2 = new TlsProtocolVersion(3, 3, "TLSv1.2");
-
- public final int major;
- public final int minor;
- public final String name;
-
- private TlsProtocolVersion(int major, int minor, String name) {
- this.major = major;
- this.minor = minor;
- this.name = name;
- }
-
- public static TlsProtocolVersion valueOf(int major, int minor) {
- if (major == 3) {
- switch (minor) {
- case 0:
- return SSLV3;
- case 1:
- return TLSv1_0;
- case 2:
- return TLSv1_1;
- case 3:
- return TLSv1_2;
- }
- }
- return new TlsProtocolVersion(major, minor, major + "." + minor);
- }
-
- public static TlsProtocolVersion read(DataInput in) throws IOException {
- int major = in.readUnsignedByte();
- int minor = in.readUnsignedByte();
- return TlsProtocolVersion.valueOf(major, minor);
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + major;
- result = prime * result + minor;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- TlsProtocolVersion other = (TlsProtocolVersion) obj;
- if (major != other.major) {
- return false;
- }
- if (minor != other.minor) {
- return false;
- }
- return true;
- }
-}