From 289d5b76f2163a3808010341ed1df3cb156d97e1 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 | 7 +++++++ 2 files changed, 8 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..089fd5cac 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,9 @@ pub fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) { super::soft::compress(state, blocks); } } + +/// Use `is_x86_feature_detected` in sgx environment in the future +#[cfg(not(feature = "cpuid_bool"))] +pub fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) { + super::soft::compress(state, blocks); +}