Skip to content

Commit

Permalink
Expose sha256_utils with the utils feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dconnolly committed Mar 18, 2020
1 parent 87d1cb0 commit f9b35c0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
1 change: 1 addition & 0 deletions sha2/Cargo.toml
Expand Up @@ -25,6 +25,7 @@ hex-literal = "0.1"
default = ["std"]
std = ["digest/std"]
asm = ["sha2-asm"]
utils = ["utils"]

# TODO: Remove this feature once is_aarch64_feature_detected!() is stabilised.
# Only used on AArch64 Linux systems, when built without the crypto target_feature.
Expand Down
47 changes: 32 additions & 15 deletions sha2/src/lib.rs
Expand Up @@ -55,40 +55,57 @@
//! [1]: https://en.wikipedia.org/wiki/SHA-2
//! [2]: https://github.com/RustCrypto/hashes
#![no_std]
#![doc(html_logo_url =
"https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]

// Give relevant error messages if the user tries to enable AArch64 asm on unsupported platforms.
#[cfg(all(feature = "asm-aarch64", target_arch = "aarch64", not(target_os = "linux")))]
#[cfg(all(
feature = "asm-aarch64",
target_arch = "aarch64",
not(target_os = "linux")
))]
compile_error!("Your OS isn’t yet supported for runtime-checking of AArch64 features.");
#[cfg(all(feature = "asm-aarch64", not(target_arch = "aarch64")))]
compile_error!("Enable the \"asm\" feature instead of \"asm-aarch64\" on non-AArch64 systems.");
#[cfg(all(feature = "asm-aarch64", target_arch = "aarch64", target_feature = "crypto"))]
#[cfg(all(
feature = "asm-aarch64",
target_arch = "aarch64",
target_feature = "crypto"
))]
compile_error!("Enable the \"asm\" feature instead of \"asm-aarch64\" when building for AArch64 systems with crypto extensions.");
#[cfg(all(not(feature = "asm-aarch64"), feature = "asm", target_arch = "aarch64", not(target_feature = "crypto"), target_os = "linux"))]
#[cfg(all(
not(feature = "asm-aarch64"),
feature = "asm",
target_arch = "aarch64",
not(target_feature = "crypto"),
target_os = "linux"
))]
compile_error!("Enable the \"asm-aarch64\" feature on AArch64 if you want to use asm detected at runtime, or build with the crypto extensions support, for instance with RUSTFLAGS='-C target-cpu=native' on a compatible CPU.");

extern crate block_buffer;
extern crate fake_simd as simd;
#[macro_use] extern crate opaque_debug;
#[macro_use] pub extern crate digest;
#[macro_use]
extern crate opaque_debug;
#[macro_use]
pub extern crate digest;
#[cfg(feature = "asm-aarch64")]
extern crate libc;
#[cfg(feature = "asm")]
extern crate sha2_asm;
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "asm-aarch64")]
extern crate libc;

#[cfg(feature = "asm-aarch64")]
mod aarch64;
mod consts;
mod sha256;
#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))]
mod sha256_utils;
mod sha512;
#[cfg(any(not(feature = "asm"), target_arch = "aarch64"))]
mod sha512_utils;
#[cfg(feature = "asm-aarch64")]
mod aarch64;
mod sha256;
mod sha512;

pub use digest::Digest;
pub use sha256::{Sha256, Sha224};
pub use sha512::{Sha512, Sha384, Sha512Trunc224, Sha512Trunc256};
pub use sha256::{Sha224, Sha256};
#[cfg(feature = "utils")]
pub use sha256_utils;
pub use sha512::{Sha384, Sha512, Sha512Trunc224, Sha512Trunc256};

0 comments on commit f9b35c0

Please sign in to comment.