Noise. Protocol
(Noise Protocol v0.3.0)
View Source
A parsed Noise protocol name (spec §8): handshake pattern plus the DH, cipher and hash functions it names, resolved to implementation modules.
Build one with Noise.protocol/1. Supported components:
- DH:
25519,448,secp256k1(needs the optionallib_secp256k1dep) - Cipher:
AESGCM,ChaChaPoly - Hash:
SHA256,SHA512,BLAKE2s,BLAKE2b
Summary
Functions
Parses a protocol name such as "Noise_XX_25519_ChaChaPoly_BLAKE2s".
Types
@type t() :: %Noise.Protocol{ cipher: module(), dh: module(), dhlen: pos_integer(), hash: module(), hashlen: 32 | 64, name: String.t(), pattern: Noise.Pattern.t() }
Functions
@spec decrypt( t(), Noise.Crypto.Cipher.key(), Noise.Crypto.Cipher.nonce(), binary(), binary() ) :: binary() | :error
@spec dh(t(), Noise.Crypto.DH.keypair(), Noise.Crypto.DH.pubkey()) :: {:ok, binary()} | {:error, :invalid_public_key}
@spec encrypt( t(), Noise.Crypto.Cipher.key(), Noise.Crypto.Cipher.nonce(), binary(), binary() ) :: binary()
Parses a protocol name such as "Noise_XX_25519_ChaChaPoly_BLAKE2s".
Raises ArgumentError for names that are malformed, longer than 255 bytes
(spec §8), or that reference an unsupported pattern, modifier or primitive.
@spec generate_keypair(t()) :: Noise.Crypto.DH.keypair()
@spec hash(t(), iodata()) :: Noise.Crypto.Hash.hash()
@spec hkdf(t(), Noise.Crypto.Hash.hash(), binary(), 2 | 3) :: tuple()
@spec rekey(t(), Noise.Crypto.Cipher.key()) :: Noise.Crypto.Cipher.key()