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;
10 /// Wrapper struct to force 16-byte alignment.
12 #[unstable(feature = "sgx_platform", issue = "56975")]
13 pub struct Align16<T>(pub T);
15 /// Wrapper struct to force 128-byte alignment.
17 #[unstable(feature = "sgx_platform", issue = "56975")]
18 pub struct Align128<T>(pub T);
20 /// Wrapper struct to force 512-byte alignment.
22 #[unstable(feature = "sgx_platform", issue = "56975")]
23 pub struct Align512<T>(pub T);
25 const ENCLU_EREPORT: u32 = 0;
26 const ENCLU_EGETKEY: u32 = 1;
28 /// Call the `EGETKEY` instruction to obtain a 128-bit secret key.
29 #[unstable(feature = "sgx_platform", issue = "56975")]
30 pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32> {
32 let mut out = MaybeUninit::uninit();
36 // rbx is reserved by LLVM
40 inout(reg) request => _,
41 inlateout("eax") ENCLU_EGETKEY => error,
42 in("rcx") out.as_mut_ptr(),
43 options(att_syntax, nostack),
47 0 => Ok(out.assume_init()),
53 /// Call the `EREPORT` instruction.
55 /// This creates a cryptographic report describing the contents of the current
56 /// enclave. The report may be verified by the enclave described in
58 #[unstable(feature = "sgx_platform", issue = "56975")]
60 targetinfo: &Align512<[u8; 512]>,
61 reportdata: &Align128<[u8; 64]>,
62 ) -> Align512<[u8; 432]> {
64 let mut report = MaybeUninit::uninit();
67 // rbx is reserved by LLVM
71 inout(reg) targetinfo => _,
72 in("eax") ENCLU_EREPORT,
74 in("rdx") report.as_mut_ptr(),
75 options(att_syntax, preserves_flags, nostack),