Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove failure crate #564

Merged
merged 12 commits into from
Mar 13, 2024
52 changes: 15 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions intel-sgx/aesm-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ sgx-isa = { version = "0.4.0", path = "../sgx-isa"}
byteorder = "1.0" # Unlicense/MIT
lazy_static = "1" # MIT/Apache-2.0
protobuf = "2.22.1" # MIT/Apache-2.0
failure = "0.1.1" # MIT/Apache-2.0
failure_derive = "0.1.1" # MIT/Apache-2.0
thiserror = "1.0" # MIT/Apache-2.0
anyhow = "1.0" # MIT/Apache-2.0

[target.'cfg(unix)'.dependencies]
# We require a version of unix-socket with the following change:
Expand Down
17 changes: 9 additions & 8 deletions intel-sgx/aesm-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use std::io::Error as IoError;
use std::result::Result as StdResult;
use thiserror::Error as ThisError;

pub type Result<T> = StdResult<T, Error>;

Expand Down Expand Up @@ -126,19 +127,19 @@ impl From<u32> for AesmError {
}
}

#[derive(Fail, Debug)]
#[derive(ThisError, Debug)]
pub enum Error {
#[fail(display = "aesm error code {:?}", _0)]
#[error("aesm error code {:?}", _0)]
AesmCode(AesmError),
#[fail(display = "error communicating with aesm")]
AesmCommunication(#[cause] IoError),
#[fail(display = "missing expected {} payload in response from aesm", _0)]
#[error("error communicating with aesm")]
AesmCommunication(#[source] IoError),
#[error("missing expected {} payload in response from aesm", _0)]
AesmBadResponse(String),
#[fail(display = "invalid quote type {}", _0)]
#[error("invalid quote type {}", _0)]
InvalidQuoteType(u32),
#[fail(display = "invalid quote size")]
#[error("invalid quote size")]
InvalidQuoteSize,
#[fail(display = "invalid token size")]
#[error("invalid token size")]
InvalidTokenSize,
}

Expand Down
7 changes: 3 additions & 4 deletions intel-sgx/aesm-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
#![deny(warnings)]

extern crate byteorder;
pub extern crate failure;
#[macro_use]
extern crate failure_derive;
pub extern crate anyhow;
pub extern crate thiserror;
#[macro_use]
#[cfg(unix)]
extern crate lazy_static;
Expand Down Expand Up @@ -269,7 +268,7 @@ impl EinittokenProvider for AesmClient {
sigstruct: &Sigstruct,
attributes: Attributes,
_retry: bool,
) -> StdResult<Einittoken, ::failure::Error> {
) -> StdResult<Einittoken, ::anyhow::Error> {
let token = self.get_launch_token(
sigstruct,
attributes,
Expand Down
2 changes: 1 addition & 1 deletion intel-sgx/dcap-ql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ verify = ["mbedtls", "num", "yasna"]

# External dependencies
byteorder = "1.1.0" # Unlicense/MIT
failure = "0.1.1" # MIT/Apache-2.0
anyhow = "1.0" # MIT/Apache-2.0
lazy_static = "1" # MIT/Apache-2.0
libc = { version = "0.2", optional = true } # MIT/Apache-2.0
mbedtls = { version = ">=0.8.0, <0.10.0", default-features = false, features = ["std"], optional = true }
Expand Down
5 changes: 3 additions & 2 deletions intel-sgx/dcap-ql/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ extern crate libc;

extern crate sgxs_loaders;

use failure::Error;
use anyhow::Error;
use anyhow::anyhow;
use num_traits::FromPrimitive;

pub use self::dcap_ql_sys::Quote3Error;
Expand Down Expand Up @@ -76,7 +77,7 @@ pub fn is_loaded() -> bool {
/// Since DCAP is being used, assume that no EINITTOKEN provider is necessary.
pub fn enclave_loader() -> Result<EnclaveCommonLibrary, Error> {
#[cfg(not(feature = "link"))]
dl::load().map_err(failure::err_msg)?;
dl::load().map_err(|e| anyhow!(e))?;
// NB. libsgx_dcap_ql.so.1 transitively links to libsgx_enclave_common.so.1
// so we should be able to find it already loaded.
// We can't use the library from `mod dl` if `not(feature = "link")`,
Expand Down
2 changes: 1 addition & 1 deletion intel-sgx/dcap-ql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

extern crate byteorder;
#[macro_use]
extern crate failure;
extern crate anyhow;
#[cfg(all(feature="bindings", not(feature = "link")))]
#[macro_use]
extern crate lazy_static;
Expand Down
3 changes: 2 additions & 1 deletion intel-sgx/dcap-ql/src/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use serde::{Deserialize, Serialize};
use sgx_isa::Report;
use std::borrow::Cow;
use std::mem;
use anyhow::bail;

// ====================================================
// ================= TYPE DEFINITIONS =================
Expand Down Expand Up @@ -93,7 +94,7 @@ pub struct Qe3CertDataPckCertChain<'a> {

pub type RawQe3CertData<'a> = Cow<'a, [u8]>;

pub type Result<T> = ::std::result::Result<T, ::failure::Error>;
pub type Result<T> = ::std::result::Result<T, anyhow::Error>;

// ===========================================
// ================= PARSING =================
Expand Down
2 changes: 1 addition & 1 deletion intel-sgx/dcap-retrieve-pckid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ categories = ["command-line-utilities"]
"sgxs-loaders" = { version = "0.3.0", path = "../sgxs-loaders" }

# External dependencies
failure = "0.1.1" # MIT/Apache-2.0
anyhow = "1.0" # MIT/Apache-2.0
14 changes: 7 additions & 7 deletions intel-sgx/dcap-retrieve-pckid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use std::convert::TryInto;
use std::fmt;

use anyhow::anyhow;
use aesm_client::AesmClient;
use dcap_ql::quote::{Qe3CertDataPpid, Quote, Quote3SignatureEcdsaP256, QuoteHeader};
use failure::Error as FailureError;
use sgx_isa::Targetinfo;
#[cfg(windows)]
use sgxs_loaders::enclaveapi::Sgx as IsgxDevice;
Expand Down Expand Up @@ -54,35 +54,35 @@ impl ToString for PckId {
}
}

pub fn retrieve_pckid_str() -> Result<PckId, FailureError> {
pub fn retrieve_pckid_str() -> Result<PckId, anyhow::Error> {
const SGX_QL_ALG_ECDSA_P256: u32 = 2;

let mut device = IsgxDevice::new()
.map_err(|err| FailureError::from(err).context("Error opening SGX device"))?
.map_err(|err| anyhow::Error::from(err).context("Error opening SGX device"))?
.einittoken_provider(AesmClient::new())
.build();

let client = AesmClient::new();

let key_ids = client
.get_supported_att_key_ids()
.map_err(|err| FailureError::from(err).context("AESM communication error getting attestation key ID"))?;
.map_err(|err| anyhow::Error::from(err).context("AESM communication error getting attestation key ID"))?;

let ecdsa_key_id = key_ids
.into_iter()
.find(|id| SGX_QL_ALG_ECDSA_P256 == get_algorithm_id(id))
.ok_or(::failure::err_msg("No appropriate attestation key ID"))?;
.ok_or(anyhow!("No appropriate attestation key ID"))?;

let quote_info = client
.init_quote_ex(ecdsa_key_id.clone())
.map_err(|err| FailureError::from(err).context("Error during quote initialization"))?;
.map_err(|err| anyhow::Error::from(err).context("Error during quote initialization"))?;

let ti = Targetinfo::try_copy_from(quote_info.target_info()).unwrap();
let report = report_test::report(&ti, &mut device).unwrap();

let res = client
.get_quote_ex(ecdsa_key_id, report.as_ref().to_owned(), None, vec![0; 16])
.map_err(|err| FailureError::from(err).context("Error obtaining quote"))?;
.map_err(|err| anyhow::Error::from(err).context("Error obtaining quote"))?;

let quote = Quote::parse(res.quote()).map_err(|err| err.context("Error parsing quote"))?;
let QuoteHeader::V3 { user_data, .. } = quote.header();
Expand Down
4 changes: 2 additions & 2 deletions intel-sgx/enclave-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ sgx-isa = { version = "0.4.0", path = "../sgx-isa" }
ipc-queue = { version = "0.2.0", path = "../../ipc-queue" }

# External dependencies
failure = "0.1.1" # MIT/Apache-2.0
failure_derive = "0.1.1" # MIT/Apache-2.0
anyhow = "1.0" # MIT/Apache-2.0
thiserror = "1.0" # MIT/Apache-2.0
fnv = "1" # MIT/Apache-2.0
lazy_static = "1.2.0" # MIT/Apache-2.0
libc = "0.2.48" # MIT/Apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion intel-sgx/enclave-runner/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::path::Path;

use failure::Error;
use anyhow::Error;
use sgxs::loader::{Load, MappingInfo};

use crate::loader::{EnclaveBuilder, ErasedTcs};
Expand Down
2 changes: 1 addition & 1 deletion intel-sgx/enclave-runner/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::path::Path;
use std::sync::Arc;

use failure::Error;
use anyhow::Error;
use sgxs::loader::{Load, MappingInfo};

use crate::loader::{EnclaveBuilder, ErasedTcs};
Expand Down
Loading