The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Crypt::Noise

PROTOCOL

https://noiseprotocol.org/

EXAMPLE

see also t/ directory

Handshake FUNCTION

noise_pattern

    my $pattern = noise_pattern($pattern_name);

noise_hkdf

    noise_hkdf( $cnf, $chaining_key, $input_key_material, $num_outputs );

init_symmetric_state

    $hs = init_symmetric_state($cnf, $hs);

mix_key

    $ss = mix_key( $cnf, $ss, $dh );

mix_hash

    $ss = mix_hash( $cnf, $ss, $data );

init_key

    $ss = init_key($ss, $k);

has_key

    my $is_has_key = has_key($ss);

set_nonce

    $ss = set_nonce($ss, $n);

mix_keyandhash

    $ss = mix_keyandhash( $cnf, $ss, $data );

noise_split

    my ($c1, $c2) = noise_split( $cnf,     $ss );

init_ciphersuite_name

    my $ciphersuite_name = init_ciphersuite_name($cnf);

init_handshake_pattern

    my $pattern = init_handshake_pattern($hs);

init_protocol_name

    my $protocol_name = init_protocol_name( $cnf, $hs );

new_handshake_state

    $hs = new_handshake_state( $cnf, $hs );

rekey

    my $k = rekey( $cnf, $hs );

encrypt_with_ad

    my $cipher_info = encrypt_with_ad( $cnf, $ss, $ad, $plaintext );

decrypt_with_ad

    my $plaintext = decrypt_with_ad($cnf, $ss, $ad, $cipher_info);

encrypt_and_hash

    my $out = encrypt_and_hash( $cnf, $out, $ss, $plaintext );

decrypt_and_hash

    my $out = decrypt_and_hash( $cnf, $out, $ss, $cipher_info );

write_message

    my $out_msg_pack = write_message( $cnf, $hs, $out, $payload );

read_message

    my $out = read_message( $cnf, $hs, $out, $recv_message_pack );

OPTIONAL SESSION FUNCTION

use c1/c2 with nonce directly

or

derive sub { key, iv } from c1/c2, and calc iv' = iv xor current_time, to make sure iv' is not resuse

derive_session_key_iv

    my ($sk, $siv) = derive_session_key_iv($cnf, $k, $salt);

session_encrypt

    my $cipher_info = session_encrypt( $cnf, $key, $iv, $aad, $plaintext );

session_decrypt

    my $plaintext = session_decrypt( $cnf, $key, $iv, $aad, $cipher_info );