Fix no_std with get_random

This commit is contained in:
pinkforest 2023-03-12 14:18:07 +11:00
parent 8c9c94add9
commit fdc992d6cd
No known key found for this signature in database
3 changed files with 15 additions and 7 deletions

View file

@ -36,7 +36,7 @@ features = ["nightly", "reusable_secrets", "serde"]
[dependencies]
curve25519-dalek = { version = "4.0.0-rc.0", default-features = false }
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
rand_core = { version = "0.6", default-features = false }
serde = { version = "1", default-features = false, optional = true, features = ["derive"] }
zeroize = { version = "1", default-features = false, optional = true, features = ["zeroize_derive"] }
@ -55,3 +55,5 @@ serde = ["dep:serde", "curve25519-dalek/serde"]
alloc = ["curve25519-dalek/alloc", "serde?/alloc", "zeroize?/alloc"]
precomputed-tables = ["curve25519-dalek/precomputed-tables"]
reusable_secrets = []
# docs: docsrs and doctest features
docsrs = ["rand_core/getrandom"]

View file

@ -53,7 +53,8 @@
//! First, Alice uses `EphemeralSecret::new()` and then
//! `PublicKey::from()` to produce her secret and public keys:
//!
//! ```rust
#![cfg_attr(feature = "docsrs", doc = "```")]
#![cfg_attr(not(feature = "docsrs"), doc = "```ignore")]
//! use rand_core::OsRng;
//! use x25519_dalek::{EphemeralSecret, PublicKey};
//!
@ -63,7 +64,8 @@
//!
//! Bob does the same:
//!
//! ```rust
#![cfg_attr(feature = "docsrs", doc = "```")]
#![cfg_attr(not(feature = "docsrs"), doc = "```ignore")]
//! # use rand_core::OsRng;
//! # use x25519_dalek::{EphemeralSecret, PublicKey};
//! let bob_secret = EphemeralSecret::new(OsRng);
@ -74,7 +76,8 @@
//! loudly meows `bob_public` back to Alice. Alice now computes her
//! shared secret with Bob by doing:
//!
//! ```rust
#![cfg_attr(feature = "docsrs", doc = "```")]
#![cfg_attr(not(feature = "docsrs"), doc = "```ignore")]
//! # use rand_core::OsRng;
//! # use x25519_dalek::{EphemeralSecret, PublicKey};
//! # let alice_secret = EphemeralSecret::new(OsRng);
@ -86,7 +89,8 @@
//!
//! Similarly, Bob computes a shared secret by doing:
//!
//! ```rust
#![cfg_attr(feature = "docsrs", doc = "```")]
#![cfg_attr(not(feature = "docsrs"), doc = "```ignore")]
//! # use rand_core::OsRng;
//! # use x25519_dalek::{EphemeralSecret, PublicKey};
//! # let alice_secret = EphemeralSecret::new(OsRng);
@ -98,7 +102,8 @@
//!
//! These secrets are the same:
//!
//! ```rust
#![cfg_attr(feature = "docsrs", doc = "```")]
#![cfg_attr(not(feature = "docsrs"), doc = "```ignore")]
//! # use rand_core::OsRng;
//! # use x25519_dalek::{EphemeralSecret, PublicKey};
//! # let alice_secret = EphemeralSecret::new(OsRng);

View file

@ -267,7 +267,8 @@ impl SharedSecret {
/// cannot use the better, safer, and faster ephemeral DH API.
///
/// # Example
/// ```
#[cfg_attr(feature = "docsrs", doc = "```")]
#[cfg_attr(not(feature = "docsrs"), doc = "```ignore")]
/// use rand_core::OsRng;
/// use rand_core::RngCore;
///