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")]
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::uninitialized();
37 : "{eax}"(ENCLU_EGETKEY),
39 "{rcx}"(out.as_mut_ptr())
44 0 => Ok(out.into_inner()),
50 /// Call the `EREPORT` instruction.
52 /// This creates a cryptographic report describing the contents of the current
53 /// enclave. The report may be verified by the enclave described in
55 #[unstable(feature = "sgx_platform", issue = "56975")]
57 targetinfo: &Align512<[u8; 512]>,
58 reportdata: &Align128<[u8; 64]>,
59 ) -> Align512<[u8; 432]> {
61 let mut report = MaybeUninit::uninitialized();
65 : /* no output registers */
66 : "{eax}"(ENCLU_EREPORT),
69 "{rdx}"(report.as_mut_ptr())