public abstract class HelloExtension extends Object
See RFC 5246 for the extension format.
In particular this class is an object representation of the Extension struct defined in TLS 1.2, Section 7.4.1.4:
struct {
ExtensionType extension_type;
opaque extension_data<0..2^16-1>;
} Extension;
enum {
signature_algorithms(13), (65535)
} ExtensionType;
| Modifier and Type | Class and Description |
|---|---|
static class |
HelloExtension.ExtensionType
The possible extension types (defined in multiple documents).
|
| Modifier and Type | Field and Description |
|---|---|
static int |
LENGTH_BITS |
protected static int |
TYPE_BITS |
| Modifier | Constructor and Description |
|---|---|
protected |
HelloExtension(HelloExtension.ExtensionType type) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addExtensionData(org.eclipse.californium.elements.util.DatagramWriter writer)
Adds binary encoding of this extension's data.
|
static HelloExtension |
fromExtensionDataReader(int typeCode,
org.eclipse.californium.elements.util.DatagramReader extensionDataReader,
InetSocketAddress peerAddress)
De-serializes a Client or Server Hello handshake message extension from its binary
representation.
|
abstract int |
getLength()
Gets the overall length of this extension's corresponding Extension struct.
|
byte[] |
toByteArray()
Serializes this extension to its byte representation as specified by its
respective RFC.
|
String |
toString() |
protected static final int TYPE_BITS
public static final int LENGTH_BITS
protected HelloExtension(HelloExtension.ExtensionType type)
public abstract int getLength()
Note that this includes the 2 bytes indicating the extension type.
public final byte[] toByteArray()
This method writes this extension's 2-byte code to the result array
and then hands the array over to the addExtensionData(DatagramWriter)
method in order to add the encoded extension data.
protected abstract void addExtensionData(org.eclipse.californium.elements.util.DatagramWriter writer)
This implementation does not do anything. Sub-classes should override this method and use the passed-in writer to add their extension_data bytes to the Extension data structure.
NB: Subclasses MUST NOT write the extension's type code to the writer
as this will already have been done by the toByteArray() method.
writer - the writer to use for serializationpublic static HelloExtension fromExtensionDataReader(int typeCode, org.eclipse.californium.elements.util.DatagramReader extensionDataReader, InetSocketAddress peerAddress) throws HandshakeException
typeCode - the extension type codeextensionDataReader - the serialized extensionpeerAddress - the IP address and port of the peer that sent this extensionnull if the extension
type is not (yet) known to or supported by Scandium.HandshakeException - if the (supported) extension could not be de-serialized, e.g. due
to erroneous encoding etc.Copyright © 2023 Eclipse Foundation. All rights reserved.