YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.sendspin.session.ServerHandshake Class Reference

The server's side of the opening exchange of every connection (spec, "Communication" and "Encryption"): read the cleartext client/init, answer with server/init and Noise message 1, read Noise message 2, switch to transport mode. More...

Collaboration diagram for de.yaacc.sendspin.session.ServerHandshake:
Collaboration graph

Classes

class  HandshakeException
 
class  PskChoice
 Which PSK the server references for a client, and as which category.
 
interface  PskResolver
 Chooses the PSK for the client the server is about to speak to (a long-term PSK of a paired client, else the Sentinel). More...
 
class  Result
 What the handshake yields.
 

Static Public Member Functions

static Result perform (WsConnection ws, Identity identity, PskResolver psks, SecureRandom random) throws IOException
 
static Result perform (WsConnection ws, Identity identity, PskResolver psks, SecureRandom random, boolean allowLegacy) throws IOException
 
static void rehandshake (SecureChannel channel, Identity identity, String clientId, NoiseSuite suite, PskChoice choice, SecureRandom random) throws IOException
 The server reruns the Noise handshake inside the open channel (spec, "Re-handshake"): to the Pairing PSK for a pairing, to the long-term PSK after it.
 

Detailed Description

The server's side of the opening exchange of every connection (spec, "Communication" and "Encryption"): read the cleartext client/init, answer with server/init and Noise message 1, read Noise message 2, switch to transport mode.

The server is always the Noise initiator, whichever side opened the WebSocket.

A failure that follows from the cleartext client/init alone (version, suite, shape) is answered with server/error and a close; every other failure is silent: the connection is closed without another message. Both end in a HandshakeException.

Member Function Documentation

◆ perform() [1/2]

static Result de.yaacc.sendspin.session.ServerHandshake.perform ( WsConnection ws,
Identity identity,
PskResolver psks,
SecureRandom random ) throws IOException
static
Parameters
wsa connection whose WebSocket handshake is done; its read timeout bounds each step (the spec suggests 30 s)
identitythe server's identity (its static key stays with it; the handshake does not zero it)

Referenced by de.yaacc.sendspin.session.ServerHandshake.perform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perform() [2/2]

static Result de.yaacc.sendspin.session.ServerHandshake.perform ( WsConnection ws,
Identity identity,
PskResolver psks,
SecureRandom random,
boolean allowLegacy ) throws IOException
static
Parameters
allowLegacytrue if a first message client/hello (the older, unencrypted wire) is accepted as a legacy session instead of an init failure; the user's switch, off by default
Here is the call graph for this function:

◆ rehandshake()

static void de.yaacc.sendspin.session.ServerHandshake.rehandshake ( SecureChannel channel,
Identity identity,
String clientId,
NoiseSuite suite,
PskChoice choice,
SecureRandom random ) throws IOException
static

The server reruns the Noise handshake inside the open channel (spec, "Re-handshake"): to the Pairing PSK for a pairing, to the long-term PSK after it.

Both messages travel as encrypted noise/handshake messages; message 2 is still under the old keys; the prologue is the hash of the handshake before. No application message is sent from message 1 on (the send lock is held until the new keys are in place); messages of the player under the old keys that arrive meanwhile are kept and delivered by SecureChannel#receive() afterwards. There is no Sentinel fallback here: a message 2 under another PSK fails.

Must be called from the thread that reads the channel.

Exceptions
HandshakeExceptionif the player does not answer or does not verify (the caller closes, without a message)

Referenced by de.yaacc.sendspin.session.ServerHandshake.rehandshake().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: