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

The Noise handshake KKpsk2 (Noise Protocol Framework, revision 34) that every Sendspin connection uses: More...

Collaboration diagram for de.yaacc.sendspin.secure.NoiseKkPsk2:
Collaboration graph

Public Member Functions

byte[] writeMessage1 (byte[] payload, SecureRandom random) throws NoiseException
 Message 1, written by the initiator: e, es, ss and the payload.
 
byte[] readMessage1 (byte[] message) throws NoiseException
 Message 1, read by the responder;.
 
byte[] writeMessage2 (byte[] payload, byte[] psk, SecureRandom random) throws NoiseException
 Message 2, written by the responder: e, ee, se, psk and the payload.
 
byte[] readMessage2 (byte[] message, byte[] psk) throws NoiseException
 Message 2, read by the initiator;.
 
int readMessage2Any (byte[] message, byte[]... psks) throws NoiseException
 Message 2 against several PSKs in order, from the state after message 1: the first that verifies wins.
 
byte[] lastPayload ()
 The payload of the message 2 that readMessage2Any(byte[], byte[]...) read.
 
byte[] handshakeHash ()
 The handshake hash h: the prologue of a re-handshake in transport mode.
 
NoiseTransport split ()
 Ends the handshake: the two transport ciphers; the handshake state is zeroed.
 
void destroy ()
 

Static Public Member Functions

static NoiseKkPsk2 initiator (NoiseSuite suite, byte[] prologue, X25519Keys.KeyPair staticKey, byte[] remoteStatic)
 The server's side.
 
static NoiseKkPsk2 responder (NoiseSuite suite, byte[] prologue, X25519Keys.KeyPair staticKey, byte[] remoteStatic)
 The client's side.
 

Detailed Description

The Noise handshake KKpsk2 (Noise Protocol Framework, revision 34) that every Sendspin connection uses:

  -> s            (pre-message: the static key of the initiator, the server)
  <- s            (pre-message: the static key of the responder, the client)
  ...
  -> e, es, ss
  <- e, ee, se, psk

With a psk token in the pattern every e token also mixes the public ephemeral key into the chaining key (section 9.2 of the Noise specification). The PSK is mixed in by the second message, which is why the first message can be read before the responder has chosen the PSK. The hash is SHA-256, the suites are NoiseSuite.

The initiator writes message 1 and reads message 2, the responder reads message 1 and writes message 2; afterwards split() gives the transport. An instance is used by one thread, for one handshake. The secrets of the handshake are zeroed by destroy(), which split() calls; the static key is the caller's and stays.

Member Function Documentation

◆ handshakeHash()

byte[] de.yaacc.sendspin.secure.NoiseKkPsk2.handshakeHash ( )

The handshake hash h: the prologue of a re-handshake in transport mode.

Valid after message 2 was written or read.

◆ initiator()

static NoiseKkPsk2 de.yaacc.sendspin.secure.NoiseKkPsk2.initiator ( NoiseSuite suite,
byte[] prologue,
X25519Keys.KeyPair staticKey,
byte[] remoteStatic )
static

The server's side.

Parameters
prologuethe exact bytes of client/init followed by those of server/init

◆ readMessage1()

byte[] de.yaacc.sendspin.secure.NoiseKkPsk2.readMessage1 ( byte[] message) throws NoiseException

Message 1, read by the responder;.

Returns
the payload (not yet authenticated by the PSK, which the second message adds).

Referenced by de.yaacc.sendspin.session.ClientHandshake.perform(), and de.yaacc.sendspin.session.ClientHandshake.rehandshake().

Here is the caller graph for this function:

◆ readMessage2()

byte[] de.yaacc.sendspin.secure.NoiseKkPsk2.readMessage2 ( byte[] message,
byte[] psk ) throws NoiseException

Message 2, read by the initiator;.

Returns
the payload. A message that does not verify leaves this object unusable; to try another PSK on the same message (the Sentinel fallback of the protocol) use readMessage2Any(byte[], byte[]...).

Referenced by de.yaacc.sendspin.secure.NoiseKkPsk2.readMessage2Any().

Here is the caller graph for this function:

◆ readMessage2Any()

int de.yaacc.sendspin.secure.NoiseKkPsk2.readMessage2Any ( byte[] message,
byte...[] psks ) throws NoiseException

Message 2 against several PSKs in order, from the state after message 1: the first that verifies wins.

The server uses it to try the PSK its first message referenced and then the Sentinel PSK (credential mismatch).

Returns
the index of the PSK that verified; the payload is in lastPayload()
Exceptions
NoiseExceptionif none verifies; this object is then unusable

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

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: