Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nostd support #42

Merged
merged 25 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c74e2f6
first pass nostd, turn off default features and add std/alloc features
xoloki Apr 1, 2019
9a4c220
Update Cargo.toml
xoloki May 9, 2019
25f0f78
Update Cargo.toml
xoloki May 9, 2019
27592d5
use core ops when in alloc mode
xoloki May 9, 2019
8f08d91
chain features
xoloki May 9, 2019
123b446
remove std::ops entirely since we always have core anyway
xoloki May 9, 2019
e482d75
remove hex and debug transcript to get rid of std errors
xoloki May 9, 2019
860e841
alloc default
xoloki May 9, 2019
16493a8
set no_std config attribute
xoloki May 10, 2019
2481ab1
remove core crate extern
xoloki May 10, 2019
6512e9f
import core crate before use
xoloki May 10, 2019
354346b
don't add extern crate core; use global namespace when referring to core
xoloki May 10, 2019
14da0b5
include core explicitly if we're in std mode
xoloki May 10, 2019
9414bba
re-enable debug-transcript feature
xoloki May 15, 2019
abf29bd
re-enable debug-transcript feature
xoloki May 15, 2019
92618c1
fmt fixes
xoloki May 15, 2019
d6d5f87
fmt fix in use statements
xoloki May 29, 2019
d09b6d8
test for nostd compatibility
xoloki May 29, 2019
e13de3f
upgrade rand_core to avoid no_std test failure
xoloki May 29, 2019
6c2a73a
use cargo-nono rather than xargo to test no_std support
xoloki Jun 13, 2019
6c520ab
Update .travis.yml
xoloki Jun 27, 2019
1dc0037
Update .travis.yml
xoloki Jul 1, 2019
49fcc7d
force reinstall of cargo-nono to pick up v1.1.5; specify valid featur…
xoloki Jul 1, 2019
bc3b3fd
remove date tag from nightly version in second test
xoloki Jul 1, 2019
6e07e07
remove alloc feature since it isn't actually used by merlin
xoloki Jul 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ exclude = [".travis.yml", ".gitignore"]
features = ["nightly"]

[dependencies]
keccak = "0.1.0"
byteorder = "1.2.4"
clear_on_drop = "0.2.3"
rand_core = "0.3"
hex = {version = "0.3", optional = true}
keccak = { version = "0.1.0", default-features = false }
byteorder = { version = "1.2.4", default-features = false }
clear_on_drop = { version = "0.2.3", default-features = false }
rand_core = { version = "0.3", default-features = false }
hex = {version = "0.3", default-features = false, optional = true}

[dev-dependencies]
strobe-rs = "0.3"
Expand All @@ -31,5 +31,8 @@ rand_chacha = "0.1"
rand = "0.6"

[features]
default = ["std"]
nightly = ["clear_on_drop/nightly"]
debug-transcript = ["hex"]
std = ["rand_core/std", "byteorder/std"]
alloc = ["rand_core/alloc"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the alloc feature actually get used for anything? I don't think Merlin allocates, so if this feature is only being used to enable a corresponding feature in rand_core, I'm not sure we need it -- since Cargo features are additive, anything else that needs rand_core/alloc can enable it themselves.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
alloc = ["rand_core/alloc"]

6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "alloc", feature(alloc))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#![cfg_attr(feature = "alloc", feature(alloc))]

#![cfg_attr(feature = "nightly", feature(external_doc))]
#![cfg_attr(feature = "nightly", doc(include = "../README.md"))]
#![doc(html_logo_url = "https://doc.dalek.rs/assets/dalek-logo-clear.png")]
Expand All @@ -16,10 +18,12 @@ please file an issue!

extern crate byteorder;
extern crate clear_on_drop;
extern crate core;
extern crate keccak;
extern crate rand_core;

#[cfg(feature = "std")]
extern crate core;

#[cfg(test)]
extern crate curve25519_dalek;
#[cfg(feature = "hex")]
Expand Down
2 changes: 1 addition & 1 deletion src/strobe.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Minimal implementation of (parts of) Strobe.

use keccak;
use std::ops::{Deref, DerefMut};
use ::core::ops::{Deref, DerefMut};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustfmt seems to want this line above use keccak and without the leading ::

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @isislovecruft. I did this locally while on vacation, but failed to push it :O


/// Strobe R value; security level 128 is hardcoded
const STROBE_R: u8 = 166;
Expand Down