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

support no_std #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ categories = [ "cryptography" ]
cryptoxide = "0.4"

[features]
default = []
with-bench = []
default = ["std"]
std = []
with-bench = []
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly
3 changes: 3 additions & 0 deletions src/derivation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(not(feature = "std"))]
use core as std;

mod common;
pub mod v2;

Expand Down
6 changes: 6 additions & 0 deletions src/hex.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#[cfg(not(feature = "std"))]
use alloc::string::String;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

const ALPHABET: &'static [u8] = b"0123456789abcdef";

pub fn encode(input: &[u8]) -> String {
Expand Down
3 changes: 3 additions & 0 deletions src/key.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(not(feature = "std"))]
use core as std;

use std::fmt;

use cryptoxide::constant_time::CtEqual;
Expand Down
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@
//! In soft derivation, the important property is that given the parent public key,
//! one can derive all softly derived children public key.
#![cfg_attr(feature = "with-bench", feature(test))]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(error_in_core))]

#![cfg_attr(feature = "with-bench", feature(test))]
#[cfg(test)]
#[cfg(feature = "with-bench")]
extern crate test;

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

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

mod derivation;
mod hex;
mod key;
Expand Down
3 changes: 3 additions & 0 deletions src/securemem.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(not(feature = "std"))]
use core as std;

pub fn zero(to_zero: &mut [u8]) {
// the unsafety of this call is bounded to the existence of the pointer
// and the accuracy of the length of the array.
Expand Down
3 changes: 3 additions & 0 deletions src/signature.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(not(feature = "std"))]
use core as std;

use super::hex;
use std::error::Error;
use std::fmt;
Expand Down