From e1794f2e170ce88db974f19f2221722203dc0dcd Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 14 Jul 2020 14:02:37 +0800 Subject: [PATCH] don't use cpuid-bool in fortanix sgx target --- sha2/Cargo.toml | 2 +- sha2/src/sha256/x86.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sha2/Cargo.toml b/sha2/Cargo.toml index 61449938c..ba6b9c97e 100644 --- a/sha2/Cargo.toml +++ b/sha2/Cargo.toml @@ -21,7 +21,7 @@ opaque-debug = "0.3" cfg-if = "0.1" sha2-asm = { version = "0.5", optional = true } -[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies] +[target.'cfg(all(any(target_arch = "x86", target_arch = "x86_64"), not(target_env = "sgx")))'.dependencies] cpuid-bool = "0.1" [target.'cfg(all(target_arch = "aarch64", target_os = "linux"))'.dependencies] diff --git a/sha2/src/sha256/x86.rs b/sha2/src/sha256/x86.rs index 04a7d26d0..c56ef8ebb 100644 --- a/sha2/src/sha256/x86.rs +++ b/sha2/src/sha256/x86.rs @@ -95,6 +95,7 @@ unsafe fn digest_blocks(state: &mut [u32; 8], blocks: &[[u8; 64]]) { _mm_storeu_si128(state_ptr_mut.add(1), hgef); } +#[cfg(feature = "cpuid_bool")] pub fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) { // TODO: Replace with https://github.com/rust-lang/rfcs/pull/2725 // after stabilization @@ -106,3 +107,8 @@ pub fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) { super::soft::compress(state, blocks); } } + +#[cfg(not(feature = "cpuid_bool"))] +pub fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) { + super::soft::compress(state, blocks); +}