#noise-protocol #noise #protocols

no-std snow

A pure-rust implementation of the Noise Protocol Framework

54 releases

new 0.10.0-alpha.1 Feb 18, 2025
0.9.6 Jan 26, 2024
0.9.4 Nov 11, 2023
0.9.2 Mar 13, 2023
0.0.1-preview.10 Mar 21, 2017

#17 in Cryptography

Download history 103806/week @ 2024-10-30 111398/week @ 2024-11-06 106014/week @ 2024-11-13 103219/week @ 2024-11-20 101630/week @ 2024-11-27 122054/week @ 2024-12-04 116964/week @ 2024-12-11 89580/week @ 2024-12-18 34700/week @ 2024-12-25 74490/week @ 2025-01-01 119093/week @ 2025-01-08 130682/week @ 2025-01-15 122882/week @ 2025-01-22 123857/week @ 2025-01-29 137296/week @ 2025-02-05 110344/week @ 2025-02-12

514,751 downloads per month
Used in 466 crates (44 directly)

Apache-2.0 OR MIT

620KB
3.5K SLoC

Snow

Crates.io Docs.rs Build Status dependency status

totally official snow logo

An implementation of Trevor Perrin's Noise Protocol that is designed to be Hard To Fuck Up™.

🔥 Warning 🔥 This library has not received any formal audit.

What's it look like?

See examples/simple.rs for a more complete TCP client/server example.

let mut noise = snow::Builder::new("Noise_NN_25519_ChaChaPoly_BLAKE2s".parse()?)
                    .build_initiator()?;

let mut buf = [0u8; 65535];

// write first handshake message
noise.write_message(&[], &mut buf)?;

// receive response message
let incoming = receive_message_from_the_mysterious_ether();
noise.read_message(&incoming, &mut buf)?;

// complete handshake, and transition the state machine into transport mode
let mut noise = noise.into_transport_mode()?;

See the full documentation at https://docs.rs/snow.

Implemented

Snow is currently tracking against Noise spec revision 34.

However, a not all features have been implemented yet (pull requests welcome):

Crypto

Cryptographic providers are swappable through Builder::with_resolver(), but by default it chooses select, artisanal pure-Rust implementations (see Cargo.toml for a quick overview).

Other Providers

ring

ring is a crypto library based off of BoringSSL and is significantly faster than most of the pure-Rust implementations.

If you enable the ring-resolver feature, Snow will include a resolvers::ring module as well as a RingAcceleratedResolver available to be used with Builder::with_resolver().

If you enable the ring-accelerated feature, Snow will default to choosing ring's crypto implementations when available.

Resolver primitives supported

default ring
CSPRNG ✔️ ✔️
25519 ✔️ ✔️
448
P-256🏁 ✔️
AESGCM ✔️ ✔️
ChaChaPoly ✔️ ✔️
XChaChaPoly🏁 ✔️
SHA256 ✔️ ✔️
SHA512 ✔️ ✔️
BLAKE2s ✔️
BLAKE2b ✔️

[!Note] 🏁 P-256 and XChaChaPoly are not in the official specification of Noise, and thus need to be enabled via the feature flags use-p256 and use-xchacha20poly1305, respectively.

no_std support and feature selection

Snow can be used in no_std environments if alloc is provided.

By default, Snow uses the standard library, default crypto resolver and a selected collection of crypto primitives. To use Snow in no_std environments or make other kinds of customized setups, use Snow with default-features = false. This way you will individually select the components you wish to use. default-resolver is the only built-in resolver that currently supports no_std.

To use a custom setup with default-resolver, enable your desired selection of cryptographic primitives:

Primitive Feature flag
DHs Curve25519 use-curve25519
P-256🏁 use-p256
Ciphers AES-GCM use-aes-gcm
ChaChaPoly use-chacha20poly1305
XChaChaPoly🏁 use-xchacha20poly1305
Hashes SHA-256 use-sha2
SHA-512 use-sha2
BLAKE2s use-blake2
BLAKE2b use-blake2

[!Note] 🏁 XChaChaPoly and P-256 are not in the official specification of Noise, but they are supported by Snow.

Example configurations

Curve25519 + AES-GCM + SHA-2 with standard library features.

default-features = false
features = [
    "use-curve25519",
    "use-aes-gcm",
    "use-sha2",
    "std",
]

Curve25519 + ChaChaPoly + BLAKE2 without standard library.

default-features = false
features = [
    "use-curve25519",
    "use-chacha20poly1305",
    "use-blake2",
]

getrandom support

Most crypto implementations supported by default-resolver will require getrandom.

If your target platform is not directly supported you might have to provide a custom implementation in your crate root. Check out their documentation for details.

License

snow is offered with a dual choice-of-license between:

where you may choose either of these licenses to follow for this work.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.1–18MB
~239K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy