#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

#2205 in Cryptography

Download history 19023/week @ 2024-08-15 17346/week @ 2024-08-22 16845/week @ 2024-08-29 20341/week @ 2024-09-05 21293/week @ 2024-09-12 19555/week @ 2024-09-19 21723/week @ 2024-09-26 24485/week @ 2024-10-03 23145/week @ 2024-10-10 29098/week @ 2024-10-17 29754/week @ 2024-10-24 22869/week @ 2024-10-31 22500/week @ 2024-11-07 25932/week @ 2024-11-14 28149/week @ 2024-11-21 24963/week @ 2024-11-28

104,980 downloads per month
Used in 128 crates (43 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