File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ opaque-debug = "0.3"
21
21
cfg-if = " 0.1"
22
22
sha2-asm = { version = " 0.5" , optional = true }
23
23
24
- [target .'cfg(any(target_arch = "x86", target_arch = "x86_64"))' .dependencies ]
24
+ [target .'cfg(all( any(target_arch = "x86", target_arch = "x86_64"), not(target_env = "sgx") ))' .dependencies ]
25
25
cpuid-bool = " 0.1"
26
26
27
27
[target .'cfg(all(target_arch = "aarch64", target_os = "linux"))' .dependencies ]
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ unsafe fn digest_blocks(state: &mut [u32; 8], blocks: &[[u8; 64]]) {
95
95
_mm_storeu_si128 ( state_ptr_mut. add ( 1 ) , hgef) ;
96
96
}
97
97
98
+ #[ cfg( feature = "cpuid_bool" ) ]
98
99
pub fn compress ( state : & mut [ u32 ; 8 ] , blocks : & [ [ u8 ; 64 ] ] ) {
99
100
// TODO: Replace with https://github.com/rust-lang/rfcs/pull/2725
100
101
// after stabilization
@@ -106,3 +107,18 @@ pub fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) {
106
107
super :: soft:: compress ( state, blocks) ;
107
108
}
108
109
}
110
+
111
+ /// Just use `std::is_x86_feature_detected` in sgx environment
112
+ #[ cfg( not( feature = "cpuid_bool" ) ) ]
113
+ pub fn compress ( state : & mut [ u32 ; 8 ] , blocks : & [ [ u8 ; 64 ] ] ) {
114
+ if std:: is_x86_feature_detected!( "sse2" )
115
+ || std:: is_x86_feature_detected!( "ssse3" )
116
+ || std:: is_x86_feature_detected!( "sse4.1" )
117
+ {
118
+ unsafe {
119
+ digest_blocks ( state, blocks) ;
120
+ }
121
+ } else {
122
+ super :: soft:: compress ( state, blocks) ;
123
+ }
124
+ }
You can’t perform that action at this time.
0 commit comments