Class SNISSLExplorer
- java.lang.Object
-
- org.wildfly.security.ssl.SNISSLExplorer
-
final class SNISSLExplorer extends Object
Instances of this class acts as an explorer of the network data of an SSL/TLS connection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classSNISSLExplorer.ExtensionInfo(package private) static classSNISSLExplorer.UnknownServerName
-
Field Summary
Fields Modifier and Type Field Description static intRECORD_HEADER_SIZEThe header size of TLS/SSL records.
-
Constructor Summary
Constructors Modifier Constructor Description privateSNISSLExplorer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<SNIServerName>explore(byte[] source, int offset, int length)Launch and explore the security capabilities from byte array.static List<SNIServerName>explore(ByteBuffer source)Launch and explore the security capabilities from byte buffer.private static List<String>exploreALPN(ByteBuffer input, int extLen)private static List<SNIServerName>exploreClientHello(ByteBuffer input, byte recordMajorVersion, byte recordMinorVersion)private static SNISSLExplorer.ExtensionInfoexploreExtensions(ByteBuffer input)private static List<SNIServerName>exploreHandshake(ByteBuffer input, byte recordMajorVersion, byte recordMinorVersion, int recordLength)private static List<SNIServerName>exploreSNIExt(ByteBuffer input, int extLen)private static List<SNIServerName>exploreTLSRecord(ByteBuffer input, byte firstByte, byte secondByte, byte thirdByte)private static intgetInt16(ByteBuffer input)private static intgetInt24(ByteBuffer input)private static intgetInt8(ByteBuffer input)static intgetRequiredSize(byte[] source, int offset, int length)Returns the required number of bytes in thesourcebyte array necessary to explore SSL/TLS connection.static intgetRequiredSize(ByteBuffer source)Returns the required number of bytes in thesourceByteBuffernecessary to explore SSL/TLS connection.private static voidignoreByteVector(ByteBuffer input, int length)private static voidignoreByteVector8(ByteBuffer input)
-
-
-
Field Detail
-
RECORD_HEADER_SIZE
public static final int RECORD_HEADER_SIZE
The header size of TLS/SSL records.The value of this constant is 5.
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRequiredSize
public static int getRequiredSize(ByteBuffer source)
Returns the required number of bytes in thesourceByteBuffernecessary to explore SSL/TLS connection.This method tries to parse as few bytes as possible from
sourcebyte buffer to get the length of an SSL/TLS record.This method accesses the
sourceparameter in read-only mode, and does not update the buffer's properties such as capacity, limit, position, and mark values.- Parameters:
source- aByteBuffercontaining inbound or outbound network data for an SSL/TLS connection.- Returns:
- the required size in byte to explore an SSL/TLS connection
- Throws:
BufferUnderflowException- if less thanRECORD_HEADER_SIZEbytes remaining insource
-
getRequiredSize
public static int getRequiredSize(byte[] source, int offset, int length) throws IOExceptionReturns the required number of bytes in thesourcebyte array necessary to explore SSL/TLS connection.This method tries to parse as few bytes as possible from
sourcebyte array to get the length of an SSL/TLS record.- Parameters:
source- a byte array containing inbound or outbound network data for an SSL/TLS connection.offset- the start offset in arraysourceat which the network data is read from.length- the maximum number of bytes to read.- Returns:
- the required size in byte to explore an SSL/TLS connection
- Throws:
BufferUnderflowException- if less thanRECORD_HEADER_SIZEbytes remaining insourceIOException
-
explore
public static List<SNIServerName> explore(ByteBuffer source) throws SSLException
Launch and explore the security capabilities from byte buffer.This method tries to parse as few records as possible from
sourcebyte buffer to get the capabilities of an SSL/TLS connection.Please NOTE that this method must be called before any handshaking occurs. The behavior of this method is not defined in this release if the handshake has begun, or has completed.
This method accesses the
sourceparameter in read-only mode, and does not update the buffer's properties such as capacity, limit, position, and mark values.- Parameters:
source- aByteBuffercontaining inbound or outbound network data for an SSL/TLS connection.- Returns:
- the explored capabilities of the SSL/TLS connection
- Throws:
IOException- on network data errorBufferUnderflowException- if not enough source bytes available to make a complete exploration.SSLException
-
explore
public static List<SNIServerName> explore(byte[] source, int offset, int length) throws IOException
Launch and explore the security capabilities from byte array.Please NOTE that this method must be called before any handshaking occurs. The behavior of this method is not defined in this release if the handshake has begun, or has completed. Once handshake has begun, or has completed, the security capabilities can not and should not be launched with this method.
- Parameters:
source- a byte array containing inbound or outbound network data for an SSL/TLS connection.offset- the start offset in arraysourceat which the network data is read from.length- the maximum number of bytes to read.- Returns:
- the explored capabilities of the SSL/TLS connection
- Throws:
IOException- on network data errorBufferUnderflowException- if not enough source bytes available to make a complete exploration.- See Also:
explore(ByteBuffer)
-
exploreTLSRecord
private static List<SNIServerName> exploreTLSRecord(ByteBuffer input, byte firstByte, byte secondByte, byte thirdByte) throws SSLException
- Throws:
SSLException
-
exploreHandshake
private static List<SNIServerName> exploreHandshake(ByteBuffer input, byte recordMajorVersion, byte recordMinorVersion, int recordLength) throws SSLException
- Throws:
SSLException
-
exploreClientHello
private static List<SNIServerName> exploreClientHello(ByteBuffer input, byte recordMajorVersion, byte recordMinorVersion) throws SSLException
- Throws:
SSLException
-
exploreExtensions
private static SNISSLExplorer.ExtensionInfo exploreExtensions(ByteBuffer input) throws SSLException
- Throws:
SSLException
-
exploreALPN
private static List<String> exploreALPN(ByteBuffer input, int extLen) throws SSLException
- Throws:
SSLException
-
exploreSNIExt
private static List<SNIServerName> exploreSNIExt(ByteBuffer input, int extLen) throws SSLException
- Throws:
SSLException
-
getInt8
private static int getInt8(ByteBuffer input)
-
getInt16
private static int getInt16(ByteBuffer input)
-
getInt24
private static int getInt24(ByteBuffer input)
-
ignoreByteVector8
private static void ignoreByteVector8(ByteBuffer input)
-
ignoreByteVector
private static void ignoreByteVector(ByteBuffer input, int length)
-
-