noise
noise copied to clipboard
.NET Standard 1.3 implementation of the Noise Protocol Framework (revision 33 of the spec)
.NET Standard 1.3 implementation of the Noise Protocol Framework (revision 33 of the spec). It features:
- AESGCM and ChaChaPoly ciphers
- Curve25519 Diffie-Hellman function
- SHA256, SHA512, BLAKE2s, and BLAKE2b hash functions
- Support for multiple pre-shared symmetric keys
- All known one-way and interactive patterns from the specification
- XXfallback handshake pattern
Usage
- Include the Noise namespace.
using Noise;
- Choose the handshake pattern and cryptographic functions.
var protocol = new Protocol(
HandshakePattern.IK,
CipherFunction.ChaChaPoly,
HashFunction.Blake2s,
PatternModifiers.Psk2
);
- Start the handshake by instantiating the protocol with the necessary parameters.
// s is communicated out-of-band
// psk is a 32-byte pre-shared symmetric key
var initiator = protocol.Create(
initiator: true,
rs: rs,
psks: new byte[][] { psk }
);
var responder = protocol.Create(
initiator: false,
s: s,
psks: new byte[][] { psk }
);
- Send and receive messages.
(written, hash, transport) = state.WriteMessage(message, outputBuffer);
(read, hash, transport) = state.ReadMessage(received, inputBuffer);
written = transport.WriteMessage(message, outputBuffer);
read = transport.ReadMessage(received, inputBuffer);
See Noise.Examples for the complete example.
Installation
> dotnet add package Noise.NET --version 1.0.0