1 //! SGX-specific access to architectural features.
3 //! The functionality in this module is further documented in the Intel
4 //! Software Developer's Manual, Volume 3, Chapter 40.
5 #![unstable(feature = "sgx_platform", issue = "56975")]
7 use crate::mem::MaybeUninit;
9 /// Wrapper struct to force 16-byte alignment.
11 #[unstable(feature = "sgx_platform", issue = "56975")]
12 pub struct Align16<T>(pub T);
14 /// Wrapper struct to force 128-byte alignment.
16 #[unstable(feature = "sgx_platform", issue = "56975")]
17 pub struct Align128<T>(pub T);
19 /// Wrapper struct to force 512-byte alignment.
21 #[unstable(feature = "sgx_platform", issue = "56975")]
22 pub struct Align512<T>(pub T);
24 const ENCLU_EREPORT: u32 = 0;
25 const ENCLU_EGETKEY: u32 = 1;
27 /// Call the `EGETKEY` instruction to obtain a 128-bit secret key.
28 #[unstable(feature = "sgx_platform", issue = "56975")]
29 pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32> {
31 let mut out = MaybeUninit::uninit();
35 // rbx is reserved by LLVM
39 inout(reg) request => _,
40 inlateout("eax") ENCLU_EGETKEY => error,
41 in("rcx") out.as_mut_ptr(),
42 options(att_syntax, nostack),
46 0 => Ok(out.assume_init()),
52 /// Call the `EREPORT` instruction.
54 /// This creates a cryptographic report describing the contents of the current
55 /// enclave. The report may be verified by the enclave described in
57 #[unstable(feature = "sgx_platform", issue = "56975")]
59 targetinfo: &Align512<[u8; 512]>,
60 reportdata: &Align128<[u8; 64]>,
61 ) -> Align512<[u8; 432]> {
63 let mut report = MaybeUninit::uninit();
66 // rbx is reserved by LLVM
70 inout(reg) targetinfo => _,
71 in("eax") ENCLU_EREPORT,
73 in("rdx") report.as_mut_ptr(),
74 options(att_syntax, preserves_flags, nostack),