#authenticated-encryption #elliptic-curve #encryption-key #x25519 #public-key #nacl #libsodium

no-std crypto_box

Pure Rust implementation of NaCl's crypto_box public-key authenticated encryption primitive which combines the X25519 Elliptic Curve Diffie-Hellman function and the XSalsa20Poly1305 authenticated encryption cipher

16 releases (8 breaking)

0.9.1 Aug 17, 2023
0.9.0 Jul 22, 2023
0.9.0-rc.1 Jun 29, 2023
0.8.2 Oct 29, 2022
0.1.0 Feb 25, 2020

#2162 in Cryptography

Download history 21158/week @ 2024-07-21 20956/week @ 2024-07-28 23801/week @ 2024-08-04 20231/week @ 2024-08-11 19898/week @ 2024-08-18 16874/week @ 2024-08-25 18452/week @ 2024-09-01 18971/week @ 2024-09-08 21434/week @ 2024-09-15 21770/week @ 2024-09-22 21100/week @ 2024-09-29 25672/week @ 2024-10-06 23068/week @ 2024-10-13 29666/week @ 2024-10-20 29192/week @ 2024-10-27 22554/week @ 2024-11-03

105,751 downloads per month
Used in 119 crates (40 directly)

Apache-2.0 OR MIT

49KB
573 lines

RustCrypto: crypto_box

crate Docs Apache2/MIT licensed Rust Version Project Chat Build Status

Pure Rust implementation of NaCl's crypto_box primitive, providing public-key authenticated encryption which combines the X25519 Diffie-Hellman function and the XSalsa20Poly1305 authenticated encryption cipher into an Elliptic Curve Integrated Encryption Scheme (ECIES).

Documentation

About

Imagine Alice wants something valuable shipped to her. Because it's valuable, she wants to make sure it arrives securely (i.e. hasn't been opened or tampered with) and that it's not a forgery (i.e. it's actually from the sender she's expecting it to be from and nobody's pulling the old switcheroo).

One way she can do this is by providing the sender (let's call him Bob) with a high-security box of her choosing. She provides Bob with this box, and something else: a padlock, but a padlock without a key. Alice is keeping that key all to herself. Bob can put items in the box then put the padlock onto it, but once the padlock snaps shut, the box cannot be opened by anyone who doesn't have Alice's private key.

Here's the twist though, Bob also puts a padlock onto the box. This padlock uses a key Bob has published to the world, such that if you have one of Bob's keys, you know a box came from him because Bob's keys will open Bob's padlocks (let's imagine a world where padlocks cannot be forged even if you know the key). Bob then sends the box to Alice.

In order for Alice to open the box, she needs two keys: her private key that opens her own padlock, and Bob's well-known key. If Bob's key doesn't open the second padlock then Alice knows that this is not the box she was expecting from Bob, it's a forgery.

Security Notes

This crate has received one security audit by Cure53 (version 0.7.1), with no significant findings. We would like to thank Threema for funding the audit.

License

Licensed under either of:

at your option.

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

~1.7–2.8MB
~58K SLoC