Skip to content
Snippets Groups Projects
Commit 5c6294ae authored by Joe Richey's avatar Joe Richey
Browse files

Add error for sgx && !rdrand

parent fc8ab62f
No related branches found
No related tags found
No related merge requests found
......@@ -31,13 +31,14 @@ unsafe fn rdrand() -> Result<[u8; WORD_SIZE], Error> {
Err(Error::UNKNOWN)
}
#[cfg(and(target_env = "sgx", not(target_feature = "rdrand")))]
compile_error!("SGX targets must enable RDRAND to get randomness");
// TODO use is_x86_feature_detected!("rdrand") when that works in core. See:
// https://github.com/rust-lang-nursery/stdsimd/issues/464
fn is_rdrand_supported() -> bool {
if cfg!(target_feature = "rdrand") {
true
} else if cfg!(target_env = "sgx") {
false // No CPUID in SGX enclaves
} else {
// SAFETY: All x86_64 CPUs support CPUID leaf 1
const FLAG: u32 = 1 << 30;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment