Добавлены все ExtensionType
This commit is contained in:
@@ -106,6 +106,8 @@ public class TlsPacket extends AbstractPacket {
|
|||||||
this.record = ApplicationDataRecord.newInstance(rawData, offset + RECORD_OFFSET, recordLength);
|
this.record = ApplicationDataRecord.newInstance(rawData, offset + RECORD_OFFSET, recordLength);
|
||||||
} else if (contentType == ContentType.ALERT) {
|
} else if (contentType == ContentType.ALERT) {
|
||||||
//TODO
|
//TODO
|
||||||
|
} else if (contentType == ContentType.HEARTBEAT) {
|
||||||
|
//TODO
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown content type: " + contentType);
|
throw new IllegalArgumentException("Unknown content type: " + contentType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class CompressionMethod extends NamedNumber<Byte, CompressionMethod> {
|
public class CompressionMethod extends NamedNumber<Byte, CompressionMethod> {
|
||||||
|
|
||||||
|
// https://www.iana.org/assignments/comp-meth-ids/comp-meth-ids.xhtml
|
||||||
|
|
||||||
public static final CompressionMethod NULL = new CompressionMethod((byte) 0, "null");
|
public static final CompressionMethod NULL = new CompressionMethod((byte) 0, "null");
|
||||||
|
public static final CompressionMethod DEFLATE = new CompressionMethod((byte) 1, "Deflate");
|
||||||
|
public static final CompressionMethod LZS = new CompressionMethod((byte) 64, "LZS");
|
||||||
|
|
||||||
private static final Map<Byte, CompressionMethod> registry = new HashMap<>();
|
private static final Map<Byte, CompressionMethod> registry = new HashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public class ContentType extends NamedNumber<Byte, ContentType> {
|
|||||||
registry.put(ALERT.value(), ALERT);
|
registry.put(ALERT.value(), ALERT);
|
||||||
registry.put(HANDSHAKE.value(), HANDSHAKE);
|
registry.put(HANDSHAKE.value(), HANDSHAKE);
|
||||||
registry.put(APPLICATION_DATA.value(), APPLICATION_DATA);
|
registry.put(APPLICATION_DATA.value(), APPLICATION_DATA);
|
||||||
|
registry.put(HEARTBEAT.value(), HEARTBEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentType(Byte value, String name) {
|
public ContentType(Byte value, String name) {
|
||||||
|
|||||||
@@ -5,21 +5,82 @@ import org.pcap4j.packet.namednumber.NamedNumber;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class ExtensionType extends NamedNumber<Short, ExtensionType> {
|
public class ExtensionType extends NamedNumber<Short, ExtensionType> {
|
||||||
|
|
||||||
public static final ExtensionType RESERVED_GREASE = new ExtensionType((short) 14906, "Reserved (GREASE)");
|
|
||||||
public static final ExtensionType PADDING = new ExtensionType((short) 21, "Padding");
|
|
||||||
|
|
||||||
private static final Map<Short, ExtensionType> registry = new HashMap<>();
|
private static final Map<Short, ExtensionType> registry = new HashMap<>();
|
||||||
|
|
||||||
static {
|
public static final ExtensionType SERVER_NAME = new ExtensionType((short) 0, "server_name");
|
||||||
registry.put(RESERVED_GREASE.value(), RESERVED_GREASE);
|
public static final ExtensionType MAX_FRAGMENT_LENGTH = new ExtensionType((short) 1, "max_fragment_length");
|
||||||
registry.put(PADDING.value(), PADDING);
|
public static final ExtensionType CLIENT_CERTIFICATE_URL = new ExtensionType((short) 2, "client_certificate_url");
|
||||||
//TODO add all
|
public static final ExtensionType TRUSTED_CA_KEYS = new ExtensionType((short) 3, "trusted_ca_keys");
|
||||||
}
|
public static final ExtensionType TRUNCATED_HMAC = new ExtensionType((short) 4, "truncated_hmac");
|
||||||
|
public static final ExtensionType STATUS_REQUEST = new ExtensionType((short) 5, "status_request");
|
||||||
|
public static final ExtensionType USER_MAPPING = new ExtensionType((short) 6, "user_mapping");
|
||||||
|
public static final ExtensionType CLIENT_AUTHZ = new ExtensionType((short) 7, "client_authz");
|
||||||
|
public static final ExtensionType SERVER_AUTHZ = new ExtensionType((short) 8, "server_authz");
|
||||||
|
public static final ExtensionType CERT_TYPE = new ExtensionType((short) 9, "cert_type");
|
||||||
|
public static final ExtensionType SUPPORTED_GROUPS = new ExtensionType((short) 10, "supported_groups");
|
||||||
|
public static final ExtensionType EC_POINT_FORMATS = new ExtensionType((short) 11, "ec_point_formats");
|
||||||
|
public static final ExtensionType SRP = new ExtensionType((short) 12, "srp");
|
||||||
|
public static final ExtensionType SIGNATURE_ALGORITHMS = new ExtensionType((short) 13, "signature_algorithms");
|
||||||
|
public static final ExtensionType USE_SRTP = new ExtensionType((short) 14, "use_srtp");
|
||||||
|
public static final ExtensionType HEARTBEAT = new ExtensionType((short) 15, "heartbeat");
|
||||||
|
public static final ExtensionType APPLICATION_LAYER_PROTOCOL_NEGOTIATION = new ExtensionType((short) 16, "application_layer_protocol_negotiation");
|
||||||
|
public static final ExtensionType STATUS_REQUEST_V2 = new ExtensionType((short) 17, "status_request_v2");
|
||||||
|
public static final ExtensionType SIGNED_CERTIFICATE_TIMESTAMP = new ExtensionType((short) 18, "signed_certificate_timestamp");
|
||||||
|
public static final ExtensionType CLIENT_CERTIFICATE_TYPE = new ExtensionType((short) 19, "client_certificate_type");
|
||||||
|
public static final ExtensionType SERVER_CERTIFICATE_TYPE = new ExtensionType((short) 20, "server_certificate_type");
|
||||||
|
public static final ExtensionType PADDING = new ExtensionType((short) 21, "padding");
|
||||||
|
public static final ExtensionType ENCRYPT_THEN_MAC = new ExtensionType((short) 22, "encrypt_then_mac");
|
||||||
|
public static final ExtensionType EXTENDED_MASTER_SECRET = new ExtensionType((short) 23, "extended_master_secret");
|
||||||
|
public static final ExtensionType TOKEN_BINDING = new ExtensionType((short) 24, "token_binding");
|
||||||
|
public static final ExtensionType CACHED_INFO = new ExtensionType((short) 25, "cached_info");
|
||||||
|
public static final ExtensionType TLS_LTS = new ExtensionType((short) 26, "tls_lts");
|
||||||
|
public static final ExtensionType COMPRESS_CERTIFICATE = new ExtensionType((short) 27, "compress_certificate");
|
||||||
|
public static final ExtensionType RECORD_SIZE_LIMIT = new ExtensionType((short) 28, "record_size_limit");
|
||||||
|
public static final ExtensionType PWD_PROTECT = new ExtensionType((short) 29, "pwd_protect");
|
||||||
|
public static final ExtensionType PWD_CLEAR = new ExtensionType((short) 30, "pwd_clear");
|
||||||
|
public static final ExtensionType PASSWORD_SALT = new ExtensionType((short) 31, "password_salt");
|
||||||
|
public static final ExtensionType TICKET_PINNING = new ExtensionType((short) 32, "ticket_pinning");
|
||||||
|
public static final ExtensionType TLS_CERT_WITH_EXTERN_PSK = new ExtensionType((short) 33, "tls_cert_with_extern_psk");
|
||||||
|
public static final ExtensionType DELEGATED_CREDENTIALS = new ExtensionType((short) 34, "delegated_credentials");
|
||||||
|
public static final ExtensionType SESSION_TICKET = new ExtensionType((short) 35, "session_ticket");
|
||||||
|
public static final ExtensionType PRE_SHARED_KEY = new ExtensionType((short) 41, "pre_shared_key");
|
||||||
|
public static final ExtensionType EARLY_DATA = new ExtensionType((short) 42, "early_data");
|
||||||
|
public static final ExtensionType SUPPORTED_VERSIONS = new ExtensionType((short) 43, "supported_versions");
|
||||||
|
public static final ExtensionType COOKIE = new ExtensionType((short) 44, "cookie");
|
||||||
|
public static final ExtensionType PSK_KEY_EXCHANGE_MODES = new ExtensionType((short) 45, "psk_key_exchange_modes");
|
||||||
|
public static final ExtensionType CERTIFICATE_AUTHORITIES = new ExtensionType((short) 47, "certificate_authorities");
|
||||||
|
public static final ExtensionType OID_FILTERS = new ExtensionType((short) 48, "oid_filters");
|
||||||
|
public static final ExtensionType POST_HANDSHAKE_AUTH = new ExtensionType((short) 49, "post_handshake_auth");
|
||||||
|
public static final ExtensionType SIGNATURE_ALGORITHMS_CERT = new ExtensionType((short) 50, "signature_algorithms_cert");
|
||||||
|
public static final ExtensionType KEY_SHARE = new ExtensionType((short) 51, "key_share");
|
||||||
|
public static final ExtensionType TRANSPARENCY_INFO = new ExtensionType((short) 52, "transparency_info");
|
||||||
|
public static final ExtensionType CONNECTION_ID = new ExtensionType((short) 53, "connection_id");
|
||||||
|
public static final ExtensionType EXTERNAL_ID_HASH = new ExtensionType((short) 55, "external_id_hash");
|
||||||
|
public static final ExtensionType EXTERNAL_SESSION_ID = new ExtensionType((short) 56, "external_session_id");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_2570 = new ExtensionType((short) 2570, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_6682 = new ExtensionType((short) 6682, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_10794 = new ExtensionType((short) 10794, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_14906 = new ExtensionType((short) 14906, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_19018 = new ExtensionType((short) 19018, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_23130 = new ExtensionType((short) 23130, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_27242 = new ExtensionType((short) 27242, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_31354 = new ExtensionType((short) 31354, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_35466 = new ExtensionType((short) 35466, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_39578 = new ExtensionType((short) 39578, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_43690 = new ExtensionType((short) 43690, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_47802 = new ExtensionType((short) 47802, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_51914 = new ExtensionType((short) 51914, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_56026 = new ExtensionType((short) 56026, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_60138 = new ExtensionType((short) 60138, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RESERVED_GREASE_64250 = new ExtensionType((short) 64250, "Reserved (GREASE)");
|
||||||
|
public static final ExtensionType RENEGOTIATION_INFO = new ExtensionType((short) 65281, "renegotiation_info");
|
||||||
|
|
||||||
public ExtensionType(Short value, String name) {
|
public ExtensionType(Short value, String name) {
|
||||||
super(value, name);
|
super(value, name);
|
||||||
|
registry.put(value, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ExtensionType getInstance(Short value) {
|
public static ExtensionType getInstance(Short value) {
|
||||||
|
|||||||
@@ -8,13 +8,17 @@ import java.util.Map;
|
|||||||
public class TlsVersion extends NamedNumber<Short, TlsVersion> {
|
public class TlsVersion extends NamedNumber<Short, TlsVersion> {
|
||||||
|
|
||||||
public static final TlsVersion TLS_1_0 = new TlsVersion((short) 0x0301, "TLS 1.0");
|
public static final TlsVersion TLS_1_0 = new TlsVersion((short) 0x0301, "TLS 1.0");
|
||||||
|
public static final TlsVersion TLS_1_1 = new TlsVersion((short) 0x0302, "TLS 1.1");
|
||||||
public static final TlsVersion TLS_1_2 = new TlsVersion((short) 0x0303, "TLS 1.2");
|
public static final TlsVersion TLS_1_2 = new TlsVersion((short) 0x0303, "TLS 1.2");
|
||||||
|
public static final TlsVersion TLS_1_3 = new TlsVersion((short) 0x0304, "TLS 1.3");
|
||||||
|
|
||||||
private static final Map<Short, TlsVersion> registry = new HashMap<>();
|
private static final Map<Short, TlsVersion> registry = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
registry.put(TLS_1_0.value(), TLS_1_0);
|
registry.put(TLS_1_0.value(), TLS_1_0);
|
||||||
|
registry.put(TLS_1_1.value(), TLS_1_1);
|
||||||
registry.put(TLS_1_2.value(), TLS_1_2);
|
registry.put(TLS_1_2.value(), TLS_1_2);
|
||||||
|
registry.put(TLS_1_3.value(), TLS_1_3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TlsVersion(Short value, String name) {
|
public TlsVersion(Short value, String name) {
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package ru.serega6531.packmate.service.optimization.tls.records;
|
package ru.serega6531.packmate.service.optimization.tls.records;
|
||||||
|
|
||||||
|
import org.pcap4j.util.ByteArrays;
|
||||||
|
|
||||||
public class ApplicationDataRecord extends TlsRecord {
|
public class ApplicationDataRecord extends TlsRecord {
|
||||||
|
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
|
|
||||||
public static ApplicationDataRecord newInstance(byte[] rawData, int offset, int length) {
|
public static ApplicationDataRecord newInstance(byte[] rawData, int offset, int length) {
|
||||||
|
ByteArrays.validateBounds(rawData, offset, length);
|
||||||
return new ApplicationDataRecord(rawData, offset, length);
|
return new ApplicationDataRecord(rawData, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public class ChangeCipherSpecRecord extends TlsRecord {
|
|||||||
private byte changeCipherSpecMessage;
|
private byte changeCipherSpecMessage;
|
||||||
|
|
||||||
public static ChangeCipherSpecRecord newInstance(byte[] rawData, int offset, int length) {
|
public static ChangeCipherSpecRecord newInstance(byte[] rawData, int offset, int length) {
|
||||||
|
ByteArrays.validateBounds(rawData, offset, length);
|
||||||
return new ChangeCipherSpecRecord(rawData, offset);
|
return new ChangeCipherSpecRecord(rawData, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,11 @@ public class HandshakeRecord extends TlsRecord {
|
|||||||
private HandshakeRecordContent content;
|
private HandshakeRecordContent content;
|
||||||
|
|
||||||
public static HandshakeRecord newInstance(byte[] rawData, int offset, int length) {
|
public static HandshakeRecord newInstance(byte[] rawData, int offset, int length) {
|
||||||
return new HandshakeRecord(rawData, offset, length);
|
ByteArrays.validateBounds(rawData, offset, length);
|
||||||
|
return new HandshakeRecord(rawData, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HandshakeRecord(byte[] rawData, int offset, int length) {
|
private HandshakeRecord(byte[] rawData, int offset) {
|
||||||
this.handshakeType = HandshakeType.getInstance(ByteArrays.getByte(rawData, HANDSHAKE_TYPE_OFFSET + offset));
|
this.handshakeType = HandshakeType.getInstance(ByteArrays.getByte(rawData, HANDSHAKE_TYPE_OFFSET + offset));
|
||||||
this.handshakeLength = BytesUtils.getThreeBytesInt(rawData, LENGTH_OFFSET + offset);
|
this.handshakeLength = BytesUtils.getThreeBytesInt(rawData, LENGTH_OFFSET + offset);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user