- Notifications
You must be signed in to change notification settings - Fork120
A Rust implementation of the Noise Protocol Framework
License
Apache-2.0, MIT licenses found
Licenses found
mcginty/snow
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An implementation of Trevor Perrin'sNoise Protocol thatis designed to be Hard To Fuck Up™.
🔥Warning 🔥 This library has not received any formal audit.
Seeexamples/simple.rs
for a more complete TCP client/server example.
letmut noise = snow::Builder::new("Noise_NN_25519_ChaChaPoly_BLAKE2s".parse()?).build_initiator()?;letmut buf =[0u8;65535];// write first handshake messagenoise.write_message(&[],&mut buf)?;// receive response messagelet incoming =receive_message_from_the_mysterious_ether();noise.read_message(&incoming,&mut buf)?;// complete handshake, and transition the state machine into transport modeletmut noise = noise.into_transport_mode()?;
See the full documentation athttps://docs.rs/snow.
Snow is currently tracking againstNoise spec revision 34.
However, a not all features have been implemented yet (pull requests welcome):
Cryptographic providers are swappable throughBuilder::with_resolver()
, but by defaultit chooses select, artisanal pure-Rust implementations (seeCargo.toml
for a quickoverview).
ring is a crypto library based off of BoringSSLand is significantly faster than most of the pure-Rust implementations.
If you enable thering-resolver
feature, Snow will include aresolvers::ring
moduleas well as aRingAcceleratedResolver
available to be used withBuilder::with_resolver()
.
If you enable thering-accelerated
feature, Snow will default to choosingring
'scrypto implementations when available.
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 enabledvia the feature flagsuse-p256
anduse-xchacha20poly1305
, respectively.
Snow can be used inno_std
environments ifalloc
is provided.
By default, Snow uses the standard library, default crypto resolver and a selected collectionof crypto primitives. To use Snow inno_std
environments or make other kinds of customizedsetups, use Snow withdefault-features = false
. This way you will individually selectthe components you wish to use.default-resolver
is the only built-in resolver thatcurrently supportsno_std
.
To use a custom setup withdefault-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 supportedby Snow.
Curve25519 + AES-GCM + SHA-2 with standard library features.
default-features =falsefeatures = ["use-curve25519","use-aes-gcm","use-sha2","std",]
Curve25519 + ChaChaPoly + BLAKE2 without standard library.
default-features =falsefeatures = ["use-curve25519","use-chacha20poly1305","use-blake2",]
Most crypto implementations supported bydefault-resolver
will requiregetrandom
.
If your target platform is not directly supportedyou might have to provide a custom implementation in your crate root.Check out theirdocumentation for details.
snow
is offered with a dual choice-of-license between:
where you may choose either of these licenses to follow for this work.
Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in the work by you, as defined in the Apache-2.0 license, shall bedual licensed as above, without any additional terms or conditions.
About
A Rust implementation of the Noise Protocol Framework