Добавлена структура блоков
This commit is contained in:
@@ -78,6 +78,13 @@ public class TlsPacket extends AbstractPacket {
|
||||
|
||||
public static final class TlsHeader extends AbstractHeader {
|
||||
|
||||
/*
|
||||
0x0 - Content Type
|
||||
0x1 - Version
|
||||
0x3 - Length
|
||||
0x5 - Record content
|
||||
*/
|
||||
|
||||
private static final int CONTENT_TYPE_OFFSET = 0;
|
||||
private static final int VERSION_OFFSET = CONTENT_TYPE_OFFSET + BYTE_SIZE_IN_BYTES;
|
||||
private static final int LENGTH_OFFSET = VERSION_OFFSET + SHORT_SIZE_IN_BYTES;
|
||||
|
||||
@@ -6,6 +6,13 @@ import ru.serega6531.packmate.service.optimization.tls.numbers.ExtensionType;
|
||||
|
||||
public abstract class TlsExtension {
|
||||
|
||||
/*
|
||||
0x0 - Type
|
||||
0x2 - Length
|
||||
0x4 - Content
|
||||
0x4+length - End
|
||||
*/
|
||||
|
||||
protected ExtensionType type;
|
||||
protected short extensionLength;
|
||||
|
||||
|
||||
@@ -2,7 +2,12 @@ package ru.serega6531.packmate.service.optimization.tls.records;
|
||||
|
||||
import org.pcap4j.util.ByteArrays;
|
||||
|
||||
public class ApplicationDataRecord extends TlsRecord {
|
||||
public class ApplicationDataRecord implements TlsRecord {
|
||||
|
||||
/**
|
||||
* 0x0 - Encrypted Application Data
|
||||
* 0x0 + length - End
|
||||
*/
|
||||
|
||||
private byte[] data;
|
||||
|
||||
|
||||
@@ -2,7 +2,12 @@ package ru.serega6531.packmate.service.optimization.tls.records;
|
||||
|
||||
import org.pcap4j.util.ByteArrays;
|
||||
|
||||
public class ChangeCipherSpecRecord extends TlsRecord {
|
||||
public class ChangeCipherSpecRecord implements TlsRecord {
|
||||
|
||||
/*
|
||||
0x0 - Change Cipher Spec Message
|
||||
0x1 - End
|
||||
*/
|
||||
|
||||
private byte changeCipherSpecMessage;
|
||||
|
||||
|
||||
@@ -10,7 +10,14 @@ import ru.serega6531.packmate.utils.BytesUtils;
|
||||
|
||||
import static org.pcap4j.util.ByteArrays.BYTE_SIZE_IN_BYTES;
|
||||
|
||||
public class HandshakeRecord extends TlsRecord {
|
||||
public class HandshakeRecord implements TlsRecord {
|
||||
|
||||
/*
|
||||
0x0 - Handshake type
|
||||
0x1 - Handshake length
|
||||
0x4 - Handshake version
|
||||
0x6 - Handshake content
|
||||
*/
|
||||
|
||||
private static final int HANDSHAKE_TYPE_OFFSET = 0;
|
||||
private static final int LENGTH_OFFSET = HANDSHAKE_TYPE_OFFSET + BYTE_SIZE_IN_BYTES;
|
||||
|
||||
@@ -2,6 +2,6 @@ package ru.serega6531.packmate.service.optimization.tls.records;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class TlsRecord implements Serializable {
|
||||
public interface TlsRecord extends Serializable {
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,19 @@ import static org.pcap4j.util.ByteArrays.SHORT_SIZE_IN_BYTES;
|
||||
|
||||
public class ClientHelloHandshakeRecordContent extends HelloHandshakeRecordContent {
|
||||
|
||||
/*
|
||||
0x0 - Client random
|
||||
0x20 - Session id length (sidl)
|
||||
0x21 - Session id
|
||||
0x21+sidl - Cipher suites length (csl)
|
||||
0x23+sidl - Cipher suite 1..(csl/2)
|
||||
0x23+sidl+csl - Compression methods length (cml)
|
||||
0x24+sidl+csl - Compression method 1..cml
|
||||
0x24+sidl+csl+cml - Extensions Length (el)
|
||||
0x26+sidl+csl+cml - Extension 1..N
|
||||
0x26+sidl+csl+cml+el - End
|
||||
*/
|
||||
|
||||
private static final int CIPHER_SUITES_LENGTH_OFFSET = HelloHandshakeRecordContent.SESSION_ID_OFFSET; // + sessionIdLength
|
||||
private static final int CIPHER_SUITE_OFFSET =
|
||||
CIPHER_SUITES_LENGTH_OFFSET + SHORT_SIZE_IN_BYTES; // + sessionIdLength + SHORT_SIZE_IN_BYTES*i
|
||||
|
||||
@@ -9,6 +9,17 @@ import static org.pcap4j.util.ByteArrays.SHORT_SIZE_IN_BYTES;
|
||||
|
||||
public class ServerHelloHandshakeRecordContent extends HelloHandshakeRecordContent {
|
||||
|
||||
/*
|
||||
0x0 - Server random
|
||||
0x20 - Session id length (sidl)
|
||||
0x21 - Session id
|
||||
0x21+si - Cipher suite
|
||||
0x23+sidl - Compression method
|
||||
0x24+sidl - Extensions Length (el)
|
||||
0x26+sidl - Extension 1..N
|
||||
0x26+sidl+el - End
|
||||
*/
|
||||
|
||||
private static final int CIPHER_SUITE_OFFSET = HelloHandshakeRecordContent.SESSION_ID_OFFSET; // + sessionIdLength
|
||||
private static final int COMPRESSION_METHOD_OFFSET = CIPHER_SUITE_OFFSET + SHORT_SIZE_IN_BYTES; // + sessionIdLength
|
||||
private static final int EXTENSIONS_LENGTH_OFFSET = COMPRESSION_METHOD_OFFSET + BYTE_SIZE_IN_BYTES; // + sessionIdLength
|
||||
|
||||
@@ -4,6 +4,11 @@ import org.pcap4j.util.ByteArrays;
|
||||
|
||||
public class UnknownRecordContent implements HandshakeRecordContent {
|
||||
|
||||
/**
|
||||
* 0x0 - Content
|
||||
* 0x0 + length - End
|
||||
*/
|
||||
|
||||
private byte[] content;
|
||||
|
||||
public static UnknownRecordContent newInstance(byte[] rawData, int offset, int length) {
|
||||
|
||||
Reference in New Issue
Block a user