• API Reference
Show / Hide Table of Contents
  • Noise
    • CipherFunction
    • DhFunction
    • HandshakePattern
    • HandshakeState
    • HashFunction
    • KeyPair
    • MessagePattern
    • PatternModifiers
    • PreMessagePattern
    • Protocol
    • ProtocolConfig
    • Token
    • Transport

Interface HandshakeState

A HandshakeState object contains a SymmetricState plus the local and remote keys (any of which may be empty), a boolean indicating the initiator or responder role, and the remaining portion of the handshake pattern.

Inherited Members
System.IDisposable.Dispose()
Namespace: Noise
Assembly: Noise.dll
Syntax
public interface HandshakeState : IDisposable

Properties

| Improve this Doc View Source

RemoteStaticPublicKey

The remote party's static public key.

Declaration
ReadOnlySpan<byte> RemoteStaticPublicKey { get; }
Property Value
Type Description
System.ReadOnlySpan<System.Byte>
Exceptions
Type Condition
System.ObjectDisposedException

Thrown if the current instance has already been disposed.

Methods

| Improve this Doc View Source

Fallback(Protocol, ProtocolConfig)

Converts an Alice-initiated pattern to a Bob-initiated pattern. The only fallback pattern currently supported is XXfallback. PSK modifiers are currently not supported with fallback protocols.

Declaration
void Fallback(Protocol protocol, ProtocolConfig config)
Parameters
Type Name Description
Protocol protocol

A concrete Noise protocol (e.g. Noise_XXfallback_25519_AESGCM_BLAKE2b).

ProtocolConfig config

A set of parameters used to instantiate a HandshakeState.

Exceptions
Type Condition
System.ObjectDisposedException

Thrown if the current instance has already been disposed.

System.ArgumentNullException

Thrown if either protocol or config is null.

System.ArgumentException

Thrown if protocol is not XXfallback, or if the provided local static private key is empty.

System.InvalidOperationException

Throw if the initial handshake pattern is Bob-initiated, or if this method was not called immediately after the first handshake message.

| Improve this Doc View Source

ReadMessage(ReadOnlySpan<Byte>, Span<Byte>)

Performs the next step of the handshake, decrypts the message, and writes the result into payloadBuffer. The result is undefined if the message and payloadBuffer overlap.

Declaration
ReadMessage(ReadOnlySpan<byte> message, Span<byte> payloadBuffer)
Parameters
Type Name Description
System.ReadOnlySpan<System.Byte> message

The message to decrypt.

System.Span<System.Byte> payloadBuffer

The buffer for the decrypted payload.

Returns
Type Description
System.

The tuple containing the plaintext size in bytes, the handshake hash, and the Transport object for encrypting transport messages. If the handshake is still in progress, the handshake hash and the transport will both be null.

Exceptions
Type Condition
System.ObjectDisposedException

Thrown if the current instance has already been disposed.

System.InvalidOperationException

Thrown if the call to WriteMessage(ReadOnlySpan<Byte>, Span<Byte>) was expected or the handshake has already been completed.

System.ArgumentException

Thrown if the message was greater than MaxMessageLength bytes in length, or if the output buffer did not have enough space to hold the plaintext.

System.Security.Cryptography.CryptographicException

Thrown if the decryption of the message has failed.

| Improve this Doc View Source

WriteMessage(ReadOnlySpan<Byte>, Span<Byte>)

Performs the next step of the handshake, encrypts the payload, and writes the result into messageBuffer. The result is undefined if the payload and messageBuffer overlap.

Declaration
WriteMessage(ReadOnlySpan<byte> payload, Span<byte> messageBuffer)
Parameters
Type Name Description
System.ReadOnlySpan<System.Byte> payload

The payload to encrypt.

System.Span<System.Byte> messageBuffer

The buffer for the encrypted message.

Returns
Type Description
System.

The tuple containing the ciphertext size in bytes, the handshake hash, and the Transport object for encrypting transport messages. If the handshake is still in progress, the handshake hash and the transport will both be null.

Exceptions
Type Condition
System.ObjectDisposedException

Thrown if the current instance has already been disposed.

System.InvalidOperationException

Thrown if the call to ReadMessage(ReadOnlySpan<Byte>, Span<Byte>) was expected or the handshake has already been completed.

System.ArgumentException

Thrown if the output was greater than MaxMessageLength bytes in length, or if the output buffer did not have enough space to hold the ciphertext.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX