Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
refactor(rtc_types,rtc_tenclave): move SealingError from rtc_tenclave…
Browse files Browse the repository at this point in the history
… to rtc_types::enclave_messages::errors
  • Loading branch information
PiDelport committed Jun 21, 2021
1 parent 61b48f3 commit 328887b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
22 changes: 2 additions & 20 deletions rtc_tenclave/src/dh/sealing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
use core::mem::size_of;

use rkyv::ser::serializers::{BufferSerializer, BufferSerializerError};
use rkyv::ser::serializers::BufferSerializer;
use rkyv::{Aligned, Archive, Deserialize, Infallible, Serialize};
use rtc_types::byte_formats::rkyv_format;
use rtc_types::enclave_messages::errors::SealingError;
use rtc_types::enclave_messages::EncryptedEnclaveMessage;
use sgx_types::sgx_status_t;

use crate::dh::ProtectedChannel;

Expand Down Expand Up @@ -107,24 +107,6 @@ where
unsafe { rkyv_format::view_array::<A>(&sealed.aad) }
}

#[derive(Debug)]
pub enum SealingError {
Rkyv(BufferSerializerError),
Sgx(sgx_status_t),
}

impl From<BufferSerializerError> for SealingError {
fn from(error: BufferSerializerError) -> Self {
SealingError::Rkyv(error)
}
}

impl From<sgx_status_t> for SealingError {
fn from(status: sgx_status_t) -> Self {
SealingError::Sgx(status)
}
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
Expand Down
26 changes: 26 additions & 0 deletions rtc_types/src/enclave_messages/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::sync::PoisonError;

use rkyv::ser::serializers::BufferSerializerError;
use sgx_types::{sgx_enclave_id_t, sgx_status_t};
use thiserror::Error;

Expand Down Expand Up @@ -36,3 +37,28 @@ impl From<sgx_status_t> for AcquireSessionError {
AcquireSessionError::Sgx(err)
}
}

#[derive(Debug)] // core
#[derive(Error)] // thiserror
pub enum SealingError {
#[error("Failed to acquire ProtectedChannel: {0}")]
ChannelNotFound(#[from] AcquireSessionError),

#[error("Failed to rkyv-serialize message: {0:?}")]
RkyvSerializerFailed(BufferSerializerError),

#[error("SGX error: {0:?}")]
Sgx(sgx_status_t),
}

impl From<BufferSerializerError> for SealingError {
fn from(error: BufferSerializerError) -> Self {
SealingError::RkyvSerializerFailed(error)
}
}

impl From<sgx_status_t> for SealingError {
fn from(status: sgx_status_t) -> Self {
SealingError::Sgx(status)
}
}

0 comments on commit 328887b

Please sign in to comment.