Skip to content

Commit 9330f24

Browse files
committed
Add error for sgx && !rdrand
1 parent 8ae20b5 commit 9330f24

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/rdrand.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ unsafe fn rdrand() -> Result<[u8; WORD_SIZE], Error> {
3131
Err(Error::UNKNOWN)
3232
}
3333

34+
#[cfg(and(target_env = "sgx", not(target_feature = "rdrand")))]
35+
compile_error!("SGX targets must enable RDRAND to get randomness");
36+
3437
// TODO use is_x86_feature_detected!("rdrand") when that works in core. See:
3538
// https://github.com/rust-lang-nursery/stdsimd/issues/464
3639
fn is_rdrand_supported() -> bool {
3740
if cfg!(target_feature = "rdrand") {
3841
true
39-
} else if cfg!(target_env = "sgx") {
40-
false // No CPUID in SGX enclaves
4142
} else {
4243
// SAFETY: All x86_64 CPUs support CPUID leaf 1
4344
const FLAG: u32 = 1 << 30;

0 commit comments

Comments
 (0)