Skip to content

Commit 7ad7860

Browse files
authored
Merge pull request #36 from oasisprotocol/anzoman/attestation-tool-add-cpu-aes-instruction-check
attestation-tool: Add CPU AES instruction check
2 parents ff9824d + bd13d33 commit 7ad7860

3 files changed

Lines changed: 56 additions & 13 deletions

File tree

attestation-tool/Cargo.lock

Lines changed: 29 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

attestation-tool/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ serde_json = { version = "1.0.87", features = ["raw_value"] }
3434
tokio = { version = "1.29.1", features = ["macros"] }
3535
ureq = "2.8.0"
3636
yasna = { version = "0.5.0", features = ["num-bigint"] }
37+
raw-cpuid = "11.0.2"

attestation-tool/src/main.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use pkix::pem::{self, PEM_CERTIFICATE};
2020
use sgx_isa::Targetinfo;
2121
use sgxs_loaders::isgx::Device as IsgxDevice;
2222
use std::process;
23+
use raw_cpuid::CpuId;
2324

2425
mod ecdsa;
2526

@@ -57,6 +58,8 @@ async fn main() {
5758
(@arg SPID: --("spid") +takes_value "SPID to use")
5859
).get_matches();
5960

61+
check_bios_settings();
62+
6063
let mut loader = IsgxDevice::new()
6164
.unwrap()
6265
.einittoken_provider(AesmClient::new())
@@ -284,6 +287,29 @@ async fn main() {
284287
}
285288
}
286289

290+
fn check_bios_settings() {
291+
let cpuid = CpuId::new();
292+
if let Some(extended_features) = cpuid.get_extended_feature_info() {
293+
if !extended_features.has_sgx() {
294+
println!("SGX is not supported or not enabled in the BIOS.");
295+
process::exit(1);
296+
}
297+
} else {
298+
println!("Unable to get the extended CPU feature information.");
299+
process::exit(1);
300+
}
301+
302+
if let Some(features) = cpuid.get_feature_info() {
303+
if !features.has_aesni() {
304+
println!("AES-NI is not supported by the CPU or not enabled in the BIOS.");
305+
process::exit(1);
306+
}
307+
} else {
308+
println!("Unable to get the CPU feature information.");
309+
process::exit(1);
310+
}
311+
}
312+
287313
fn from_hex(mut hex: &str) -> Vec<u8> {
288314
let mut ret = Vec::with_capacity(hex.len() / 2);
289315
loop {

0 commit comments

Comments
 (0)