dcap_ql_sys/
lib.rs

1/* Copyright (c) Fortanix, Inc.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7#![doc(html_logo_url = "https://edp.fortanix.com/img/docs/edp-logo.svg",
8       html_favicon_url = "https://edp.fortanix.com/favicon.ico",
9       html_root_url = "https://edp.fortanix.com/docs/api/")]
10
11#[macro_use]
12extern crate num_derive;
13extern crate sgx_isa;
14
15use sgx_isa::{Report, Targetinfo};
16
17/// Possible errors generated by the quote interface.
18#[repr(C)]
19#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, FromPrimitive, ToPrimitive)]
20pub enum Quote3Error {
21    ///< Success
22    Success = 0,
23    ///< The parameter is incorrect
24    InvalidParameter = 0xe002,
25    ///< Not enough memory is available to complete this operation
26    OutOfMemory = 0xe003,
27    ///< Expected ECDSA_ID does not match the value stored in the ECDSA Blob
28    EcdsaIdMismatch = 0xe004,
29    ///< The ECDSA blob pathname is too large
30    PathnameBufferOverflow = 0xe005,
31    ///< Error accessing ECDSA blob
32    FileAccessError = 0xe006,
33    ///< Cached ECDSA key is invalid
34    StoredKeyInvalid = 0xe007,
35    ///< Cached ECDSA key does not match requested key
36    PubKeyIdMismatch = 0xe008,
37    ///< PCE use the incorrect signature scheme
38    InvalidPceSigScheme = 0xe009,
39    ///< There is a problem with the attestation key blob.
40    AttKeyBlobInvalid = 0xe00a,
41    ///< Unsupported attestation key ID.
42    UnsupportedAttKeyId = 0xe00b,
43    ///< Unsupported enclave loading policy.
44    UnsupportedLoadingPolicy = 0xe00c,
45    ///< Unable to load the QE enclave
46    InterfaceUnavailable = 0xe00d,
47    ///< Unable to find the platform library with the dependent APIs.  Not fatal.
48    PlatformLibUnavailable = 0xe00e,
49    ///< The attestation key doesn't exist or has not been certified.
50    AttKeyNotInitialized = 0xe00f,
51    ///< The certification data retrieved from the platform library is invalid.
52    AttKeyCertDataInvalid = 0xe010,
53    ///< The platform library doesn't have any platfrom cert data.
54    NoPlatformCertData = 0xe011,
55    ///< Not enough memory in the EPC to load the enclave.
56    OutOfEpc = 0xe012,
57    ///< There was a problem verifying an SGX REPORT.
58    ReportInvalid = 0xe013,
59    ///< Interfacing to the enclave failed due to a power transition.
60    EnclaveLost = 0xe014,
61    ///< Error verifying the application enclave's report.
62    InvalidReport = 0xe015,
63    ///< Unable to load the enclaves.  Could be due to file I/O error, loading infrastructure error.
64    EnclaveLoadFailure = 0xe016,
65    ///< The QE was unable to generate its own report targeting the application enclave either
66    ///< because the QE doesn't support this feature there is an enclave compatibility issue.
67    ///< Please call again with the p_qe_report_info to NULL.
68    UnableToGenerateQeReport = 0xe017,
69    ///< Caused when the provider library returns an invalid TCB (too high).
70    KeyCertifcationError = 0xe018,
71}
72
73#[cfg(feature = "link")]
74#[link(name = "sgx_dcap_ql")]
75extern "C" {
76    #[link_name = "sgx_qe_get_target_info"]
77    pub fn get_target_info(target_info: &mut Targetinfo) -> u32;
78    #[link_name = "sgx_qe_get_quote_size"]
79    pub fn get_quote_size(quote_size: &mut u32) -> u32;
80    #[link_name = "sgx_qe_get_quote"]
81    pub fn get_quote(report: &Report, quote_size: u32, quote: *mut u8) -> u32;
82}
83
84pub const LIBRARY: &str = "libsgx_dcap_ql.so.1";
85
86pub const SYM_GET_TARGET_INFO: &[u8] = b"sgx_qe_get_target_info\0";
87pub type GetTargetInfoFn = unsafe extern "C" fn(target_info: &mut Targetinfo) -> u32;
88pub const SYM_GET_QUOTE_SIZE: &[u8] = b"sgx_qe_get_quote_size\0";
89pub type GetQuoteSizeFn = unsafe extern "C" fn(quote_size: &mut u32) -> u32;
90pub const SYM_GET_QUOTE: &[u8] = b"sgx_qe_get_quote\0";
91pub type GetQuoteFn = unsafe extern "C" fn(report: &Report, quote_size: u32, quote: *mut u8) -> u32;