Skip to content

Commit

Permalink
Fix no_std with get_random
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkforest committed Mar 12, 2023
1 parent 8c9c94a commit fdc992d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand All @@ -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"]
15 changes: 10 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
//!
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
///
Expand Down

0 comments on commit fdc992d

Please sign in to comment.