Class ClientHello
java.lang.Object
tech.kwik.agent15.handshake.HandshakeMessage
tech.kwik.agent15.handshake.ClientHello
https://datatracker.ietf.org/doc/html/rfc8446#section-4.1.2
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClientHello(byte[] clientRandom, byte[] sessionId, List<TlsConstants.CipherSuite> cipherSuites, List<Extension> extensions, byte[] transcriptPrefix, BinderCalculator binderCalculator) Creates a ClientHello message from its constituent parts, with a transcript prefix for computing the binder of a pre-shared key extension.ClientHello(byte[] clientRandom, byte[] sessionId, List<TlsConstants.CipherSuite> cipherSuites, List<Extension> extensions, BinderCalculator binderCalculator) Creates a ClientHello message from its constituent parts.ClientHello(String serverName, List<KeyShareExtension.KeyShareEntry> keyShares, boolean compatibilityMode, List<TlsConstants.CipherSuite> supportedCiphers, List<TlsConstants.SignatureScheme> supportedSignatures, List<TlsConstants.NamedGroup> supportedGroups, List<Extension> extraExtensions, BinderCalculator binderCalculator, ClientHello.PskKeyEstablishmentMode pskKeyEstablishmentMode) Creates a (first) ClientHello that offers a key share for each of the given groups. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getBytes()byte[]intReturns the start position of the PreSharedKeyExtension in the serialized ClientHello.byte[]getType()static ClientHelloparse(ByteBuffer buffer, ExtensionParser customExtensionParser) Parses a ClientHello message from a byte stream.toString()Methods inherited from class HandshakeMessage
parseHandshakeHeader
-
Field Details
-
SUPPORTED_CIPHERS
-
-
Constructor Details
-
ClientHello
public ClientHello(String serverName, List<KeyShareExtension.KeyShareEntry> keyShares, boolean compatibilityMode, List<TlsConstants.CipherSuite> supportedCiphers, List<TlsConstants.SignatureScheme> supportedSignatures, List<TlsConstants.NamedGroup> supportedGroups, List<Extension> extraExtensions, BinderCalculator binderCalculator, ClientHello.PskKeyEstablishmentMode pskKeyEstablishmentMode) Creates a (first) ClientHello that offers a key share for each of the given groups. https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.8 "Clients MAY send an empty client_shares vector in order to request group selection from the server, at the cost of an additional round trip"; this implementation always sends at least one key share.- Parameters:
serverName-keyShares- the key shares to offer, in descending order of preference; must not be empty and each of its groups must occur in supportedGroups, in the same order.compatibilityMode-supportedCiphers-supportedSignatures-supportedGroups-extraExtensions-binderCalculator- can be null when no ClientHelloPreSharedKeyExtension is present, must be non-null when ClientHelloPreSharedKeyExtension is present.pskKeyEstablishmentMode-
-
ClientHello
public ClientHello(byte[] clientRandom, byte[] sessionId, List<TlsConstants.CipherSuite> cipherSuites, List<Extension> extensions, BinderCalculator binderCalculator) Creates a ClientHello message from its constituent parts. In contrast to the other constructors, this one does not add any extension by itself: the given extensions are serialized as they are, in the order given. This is what makes it possible to create the second ClientHello that must be sent in response to a HelloRetryRequest, which must be identical to the first one except for a limited set of changes, see https://datatracker.ietf.org/doc/html/rfc8446#section-4.1.2.- Parameters:
clientRandom- the client random; 32 bytessessionId- the legacy session id; empty when not using compatibility modecipherSuites- the symmetric cipher options supported, in descending order of preferenceextensions- the extensions, in the order in which they must be serializedbinderCalculator- can be null when no ClientHelloPreSharedKeyExtension is present, must be non-null when ClientHelloPreSharedKeyExtension is present.
-
ClientHello
public ClientHello(byte[] clientRandom, byte[] sessionId, List<TlsConstants.CipherSuite> cipherSuites, List<Extension> extensions, byte[] transcriptPrefix, BinderCalculator binderCalculator) Creates a ClientHello message from its constituent parts, with a transcript prefix for computing the binder of a pre-shared key extension. This is what the second ClientHello (the one sent in response to a HelloRetryRequest) needs, see https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.11.2.- Parameters:
clientRandom- the client random; 32 bytessessionId- the legacy session id; empty when not using compatibility modecipherSuites- the symmetric cipher options supported, in descending order of preferenceextensions- the extensions, in the order in which they must be serializedtranscriptPrefix- the transcript that precedes this client hello; empty for a first client hellobinderCalculator- can be null when no ClientHelloPreSharedKeyExtension is present, must be non-null when ClientHelloPreSharedKeyExtension is present.
-
-
Method Details
-
parse
public static ClientHello parse(ByteBuffer buffer, ExtensionParser customExtensionParser) throws TlsProtocolException, IllegalParameterAlert Parses a ClientHello message from a byte stream.- Parameters:
buffer- the buffer to read the message fromcustomExtensionParser- parser for extensions not known to this implementation; may be null- Throws:
TlsProtocolExceptionIllegalParameterAlert
-
getType
- Specified by:
getTypein classHandshakeMessage
-
getBytes
public byte[] getBytes()- Specified by:
getBytesin classHandshakeMessage
-
getClientRandom
public byte[] getClientRandom() -
getSessionId
public byte[] getSessionId() -
getCipherSuites
-
getExtensions
-
getPskExtensionStartPosition
public int getPskExtensionStartPosition()Returns the start position of the PreSharedKeyExtension in the serialized ClientHello. This is needed for computing binders.- Returns:
- the start position or -1 if not present.
-
toString
-