176 lines
6.2 KiB
Rust
176 lines
6.2 KiB
Rust
#![allow(non_upper_case_globals)]
|
|
#![allow(non_camel_case_types)]
|
|
#![allow(unused_attributes)]
|
|
#![allow(non_snake_case)]
|
|
#![allow(dead_code)]
|
|
|
|
pub type int8_t = i8;
|
|
pub type int16_t = i16;
|
|
pub type int32_t = i32;
|
|
pub type int64_t = i64;
|
|
pub type uint8_t = u8;
|
|
pub type uint16_t = u16;
|
|
pub type uint32_t = u32;
|
|
pub type uint64_t = u64;
|
|
pub type size_t = usize;
|
|
pub type sgx_epid_group_id_t = [uint8_t; 4];
|
|
pub const SGX_REPORT_DATA_SIZE: size_t = 64;
|
|
pub struct sgx_report_data_t {
|
|
pub d: [uint8_t; SGX_REPORT_DATA_SIZE],
|
|
}
|
|
pub struct sgx_spid_t {
|
|
pub id: [uint8_t; 16],
|
|
}
|
|
pub struct sgx_quote_nonce_t {
|
|
pub rand: [uint8_t; 16],
|
|
}
|
|
pub const SGX_HASH_SIZE: size_t = 32;
|
|
pub struct sgx_measurement_t {
|
|
pub m: [uint8_t; SGX_HASH_SIZE],
|
|
}
|
|
pub struct sgx_attributes_t {
|
|
pub flags: uint64_t,
|
|
pub xfrm: uint64_t,
|
|
}
|
|
pub type sgx_config_svn_t = uint16_t;
|
|
pub type sgx_misc_select_t = uint32_t;
|
|
pub const SGX_CONFIGID_SIZE: size_t = 64;
|
|
pub type sgx_config_id_t = [uint8_t; SGX_CONFIGID_SIZE];
|
|
pub const SGX_TARGET_INFO_RESERVED1_BYTES: size_t = 2;
|
|
pub const SGX_TARGET_INFO_RESERVED2_BYTES: size_t = 8;
|
|
pub const SGX_TARGET_INFO_RESERVED3_BYTES: size_t = 384;
|
|
pub struct sgx_target_info_t {
|
|
pub mr_enclave: sgx_measurement_t,
|
|
pub attributes: sgx_attributes_t,
|
|
pub reserved1: [uint8_t; SGX_TARGET_INFO_RESERVED1_BYTES],
|
|
pub config_svn: sgx_config_svn_t,
|
|
pub misc_select: sgx_misc_select_t,
|
|
pub reserved2: [uint8_t; SGX_TARGET_INFO_RESERVED2_BYTES],
|
|
pub config_id: sgx_config_id_t,
|
|
pub reserved3: [uint8_t; SGX_TARGET_INFO_RESERVED3_BYTES],
|
|
}
|
|
|
|
#[repr(u32)]
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
|
pub enum sgx_quote_sign_type_t {
|
|
SGX_UNLINKABLE_SIGNATURE = 0,
|
|
SGX_LINKABLE_SIGNATURE = 1,
|
|
}
|
|
pub const SGX_KEYID_SIZE: size_t = 32;
|
|
pub const SGX_CPUSVN_SIZE: size_t = 16;
|
|
pub const SGX_KEY_REQUEST_RESERVED2_BYTES: size_t = 434;
|
|
pub const SGX_REPORT_BODY_RESERVED1_BYTES: size_t = 12;
|
|
pub const SGX_REPORT_BODY_RESERVED2_BYTES: size_t = 32;
|
|
pub const SGX_REPORT_BODY_RESERVED3_BYTES: size_t = 32;
|
|
pub const SGX_REPORT_BODY_RESERVED4_BYTES: size_t = 42;
|
|
pub struct sgx_cpu_svn_t {
|
|
pub svn: [uint8_t; SGX_CPUSVN_SIZE],
|
|
}
|
|
pub const SGX_ISVEXT_PROD_ID_SIZE: size_t = 16;
|
|
pub const SGX_ISV_FAMILY_ID_SIZE: size_t = 16;
|
|
|
|
pub type sgx_isvext_prod_id_t = [uint8_t; SGX_ISVEXT_PROD_ID_SIZE];
|
|
pub type sgx_isvfamily_id_t = [uint8_t; SGX_ISV_FAMILY_ID_SIZE];
|
|
pub type sgx_prod_id_t = uint16_t;
|
|
pub type sgx_isv_svn_t = uint16_t;
|
|
pub type sgx_key_128bit_t = [uint8_t; 16];
|
|
|
|
pub struct sgx_report_body_t {
|
|
pub cpu_svn: sgx_cpu_svn_t,
|
|
pub misc_select: sgx_misc_select_t,
|
|
pub reserved1: [uint8_t; SGX_REPORT_BODY_RESERVED1_BYTES],
|
|
pub isv_ext_prod_id: sgx_isvext_prod_id_t,
|
|
pub attributes: sgx_attributes_t,
|
|
pub mr_enclave: sgx_measurement_t,
|
|
pub reserved2: [uint8_t; SGX_REPORT_BODY_RESERVED2_BYTES],
|
|
pub mr_signer: sgx_measurement_t,
|
|
pub reserved3: [uint8_t; SGX_REPORT_BODY_RESERVED3_BYTES],
|
|
pub config_id: sgx_config_id_t,
|
|
pub isv_prod_id: sgx_prod_id_t,
|
|
pub isv_svn: sgx_isv_svn_t,
|
|
pub config_svn: sgx_config_svn_t,
|
|
pub reserved4: [uint8_t; SGX_REPORT_BODY_RESERVED4_BYTES],
|
|
pub isv_family_id: sgx_isvfamily_id_t,
|
|
pub report_data: sgx_report_data_t,
|
|
}
|
|
pub struct sgx_key_id_t {
|
|
pub id: [uint8_t; SGX_KEYID_SIZE],
|
|
}
|
|
pub const SGX_MAC_SIZE: size_t = 16;
|
|
pub type sgx_mac_t = [uint8_t; SGX_MAC_SIZE];
|
|
|
|
pub struct sgx_report_t {
|
|
pub body: sgx_report_body_t,
|
|
pub key_id: sgx_key_id_t,
|
|
pub mac: sgx_mac_t,
|
|
}
|
|
#[repr(u32)]
|
|
#[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Debug)]
|
|
pub enum sgx_ql_qv_result_t {
|
|
SGX_QL_QV_RESULT_OK = 0x0000_0000,
|
|
// SGX_QL_QV_RESULT_MIN = 0x0000_A001,
|
|
SGX_QL_QV_RESULT_CONFIG_NEEDED = 0x0000_A001,
|
|
SGX_QL_QV_RESULT_OUT_OF_DATE = 0x0000_A002,
|
|
SGX_QL_QV_RESULT_OUT_OF_DATE_CONFIG_NEEDED = 0x0000_A003,
|
|
SGX_QL_QV_RESULT_INVALID_SIGNATURE = 0x0000_A004,
|
|
SGX_QL_QV_RESULT_REVOKED = 0x0000_A005,
|
|
SGX_QL_QV_RESULT_UNSPECIFIED = 0x0000_A006,
|
|
SGX_QL_QV_RESULT_SW_HARDENING_NEEDED = 0x0000_A007,
|
|
SGX_QL_QV_RESULT_CONFIG_AND_SW_HARDENING_NEEDED = 0x0000_A008,
|
|
SGX_QL_QV_RESULT_MAX = 0x0000_A0FF,
|
|
}
|
|
pub struct sgx_key_request_t {
|
|
pub key_name: uint16_t,
|
|
pub key_policy: uint16_t,
|
|
pub isv_svn: sgx_isv_svn_t,
|
|
pub reserved1: uint16_t,
|
|
pub cpu_svn: sgx_cpu_svn_t,
|
|
pub attribute_mask: sgx_attributes_t,
|
|
pub key_id: sgx_key_id_t,
|
|
pub misc_mask: sgx_misc_select_t,
|
|
pub config_svn: sgx_config_svn_t,
|
|
pub reserved2: [uint8_t; SGX_KEY_REQUEST_RESERVED2_BYTES],
|
|
}
|
|
|
|
#[repr(C)]
|
|
pub struct IoctlGenEPIDQuoteArg {
|
|
report_data: sgx_report_data_t, // Input
|
|
quote_type: sgx_quote_sign_type_t, // Input
|
|
spid: sgx_spid_t, // Input
|
|
nonce: sgx_quote_nonce_t, // Input
|
|
sigrl_ptr: *const u8, // Input (optional)
|
|
sigrl_len: u32, // Input (optional)
|
|
quote_buf_len: u32, // Input
|
|
quote_buf: *mut u8, // Output
|
|
}
|
|
|
|
#[repr(C)]
|
|
pub struct IoctlCreateReportArg {
|
|
target_info: *const sgx_target_info_t, // Input (optional)
|
|
report_data: *const sgx_report_data_t, // Input (optional)
|
|
report: *mut sgx_report_t, // Output
|
|
}
|
|
|
|
#[repr(C)]
|
|
pub struct IoctlGenDCAPQuoteArg {
|
|
report_data: *const sgx_report_data_t, // Input
|
|
quote_size: *mut u32, // Input/output
|
|
quote_buf: *mut u8, // Output
|
|
}
|
|
|
|
#[repr(C)]
|
|
pub struct IoctlVerDCAPQuoteArg {
|
|
quote_buf: *const u8, // Input
|
|
quote_size: u32, // Input
|
|
collateral_expiration_status: *mut u32, // Output
|
|
quote_verification_result: *mut sgx_ql_qv_result_t, // Output
|
|
supplemental_data_size: u32, // Input (optional)
|
|
supplemental_data: *mut u8, // Output (optional)
|
|
}
|
|
|
|
#[repr(C)]
|
|
pub struct IoctlGetKeyArg {
|
|
key_request: *const sgx_key_request_t, // Input
|
|
key: *mut sgx_key_128bit_t, // Output
|
|
}
|