mc_sgx_dcap_quoteverify/
lib.rs

1// Copyright (c) 2022-2024 The MobileCoin Foundation
2
3#![doc = include_str!("../README.md")]
4#![deny(missing_docs, missing_debug_implementations)]
5
6mod collateral;
7mod quote_enclave;
8mod verify;
9
10pub use collateral::Collateral;
11use mc_sgx_dcap_types::{CollateralError, QlError};
12pub use quote_enclave::{LoadPolicyInitializer, PathInitializer};
13pub use verify::supplemental_data_size;
14
15/// Errors interacting with quote verification library functions
16#[derive(Clone, Debug, displaydoc::Display, Eq, PartialEq)]
17#[non_exhaustive]
18pub enum Error {
19    /// Paths have already been initialized
20    PathsInitialized,
21    /// Error from SGX quoting library function: {0}
22    QuoteLibrary(QlError),
23    /// Failed to convert a path to a string.  Path {0}
24    PathStringConversion(String),
25    /// Path does not exist
26    PathDoesNotExist(String),
27    /// Path length is longer than the 259 character bytes allowed
28    PathLengthTooLong(String),
29    /// The quote verification enclave load policy has already been initialized
30    LoadPolicyInitialized,
31    /// Collateral data size is too small: should be at least {0}, got {1}
32    CollateralSizeTooSmall(u32, u32),
33    /// Error converting C data to rust Collateral type {0}
34    CollateralConversion(CollateralError),
35}
36
37impl From<QlError> for Error {
38    fn from(src: QlError) -> Self {
39        Self::QuoteLibrary(src)
40    }
41}
42
43impl From<CollateralError> for Error {
44    fn from(src: CollateralError) -> Self {
45        Self::CollateralConversion(src)
46    }
47}