|
1 |
| -//! Pure Rust implementation of the [`crypto_kx`] key exchange |
2 |
| -//! from [NaCl]-family libraries (e.g. libsodium, TweetNaCl) |
3 |
| -//! which uses [BLAKE2]. |
4 |
| -//! |
5 |
| -//! # Introduction |
6 |
| -//! |
7 |
| -//! Imagine Alice wants to open a safe communication channel with Betty, |
8 |
| -//! using something like [`crypto_secretstream`]. They first need to agree on |
9 |
| -//! a shared secret. |
10 |
| -//! |
11 |
| -//! To obtain this shared secret, Diffie-Hellman can be used, which works as follows: |
12 |
| -//! Suppose both Alice and Betty know the public key of each other. |
13 |
| -//! Then they use their private key and the other's public key to generate a |
14 |
| -//! secret. This secret is the same for both Alice and Betty, as described by |
15 |
| -//! the Diffie-Hellman algorithm. |
16 |
| -//! No eavesdropper can know what the secret is, as they only know the public keys, but |
17 |
| -//! not the private keys. |
18 |
| -//! |
19 |
| -//! Using the same key for sending and receiving might pose cryptographic |
20 |
| -//! issues and/or reduce the overall throughput. |
21 |
| -//! So when computing the shared secret, you actually get two keys, |
22 |
| -//! one for each direction. |
23 |
| -//! |
24 |
| -//! # Usage |
| 1 | +#![no_std] |
| 2 | +#![doc( |
| 3 | + html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", |
| 4 | + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" |
| 5 | +)] |
| 6 | +#![warn(missing_docs, rust_2018_idioms)] |
| 7 | + |
| 8 | +//! ## Usage |
25 | 9 | //!
|
26 | 10 | //! ```rust
|
27 | 11 | //! use crypto_kx::*;
|
|
46 | 30 | //! [`crypto_secretstream`]: https://github.com/RustCrypto/nacl-compat/tree/master/crypto_secretstream
|
47 | 31 | //! [BLAKE2]: https://github.com/RustCrypto/hashes/tree/master/blake2
|
48 | 32 |
|
49 |
| -#![no_std] |
50 |
| -#![doc( |
51 |
| - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", |
52 |
| - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" |
53 |
| -)] |
54 |
| -#![warn(missing_docs, rust_2018_idioms)] |
| 33 | +#[cfg(not(any(target_pointer_width = "32", target_pointer_width = "64")))] |
| 34 | +compile_error!("`crypto-box` requires either a 32-bit or 64-bit target"); |
55 | 35 |
|
56 | 36 | mod keypair;
|
57 | 37 | mod keys;
|
|
0 commit comments