[noise] Susurrus: Noise implementation in Rust

Tiffany Bennett tiffany at stormbit.net
Wed Jul 22 08:56:18 PDT 2015


I've just finished adding support for handshakes to
Susurrus. Currently, I have code for HandshakeNN and HandshakeXX, but
barring bugs it should be very easy to add new handshakes.

Here's sample code testing to make sure that HandshakeXX works (it
does no IO, simply demonstrates the flow of the API):

    let mut client = HandshakeXX::new(gen_keypair());
    let mut server = HandshakeXX::new(gen_keypair());

    server.recv(&client.send()[..]).unwrap();
    client.recv(&server.send()[..]).unwrap();
    server.recv(&client.send()[..]).unwrap();
    let (c1, c2) = client.finish();
    let (s1, s2) = server.finish();
    assert!(c1.k.unwrap().0 == s1.k.unwrap().0);
    assert!(c2.k.unwrap().0 == s2.k.unwrap().0);
    assert!(&c1.h.0[..] == &s1.h.0[..]);
    assert!(&c2.h.0[..] == &s2.h.0[..]);

And here is the implementation of HandshakeXX, to show how simple it
is to add new handshake types:

    pub struct HandshakeXX;

    impl HandshakeXX {
        pub fn new(local: KeyPair) -> Handshake {
            static DESCS: &'static [&'static [Descriptor]] = &[
                &[Descriptor::Ephemeral],
                &[Descriptor::Ephemeral, Descriptor::DHEE,
Descriptor::Static, Descriptor::DHSE],
                &[Descriptor::Static, Descriptor::DHSE]
            ];
        Handshake::new(Some(local), None, DESCS)
        }
    }

Next up I'll likely be adding a simple TCP client/server to the CLI
utility, akin to `openssl s_client` / `openssl s_server`.


More information about the Noise mailing list