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

Commit

Permalink
feat(rtc_types::enclave_messages::set_access_key): add SetAccessKeyRe…
Browse files Browse the repository at this point in the history
…sult type
  • Loading branch information
PiDelport committed Jun 21, 2021
1 parent 616e985 commit d69de3a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
25 changes: 24 additions & 1 deletion rtc_types/src/enclave_messages/ffi_set_access_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
//! (The Rust compiler should report an error if these don't line up:
//! this can be used to update these if `set_access_key` changes.)
use sgx_types::sgx_aes_gcm_128bit_tag_t;
use sgx_types::{sgx_aes_gcm_128bit_tag_t, sgx_status_t};

use super::{set_access_key, RecommendedAesGcmIv};
use crate::enclave_messages::errors::SealingError;
use crate::EcallResult;

// See enclave_messages::ARCHIVED_ENCLAVE_ID_SIZE
pub const ARCHIVED_ENCLAVE_ID_SIZE: usize = 8;
Expand Down Expand Up @@ -44,8 +46,17 @@ pub struct SetAccessKeyEncryptedResponse {
pub nonce: RecommendedAesGcmIv,
}

// FFI type: SetAccessKeyResult
pub type SetAccessKeyResult = EcallResult<SetAccessKeyEncryptedResponse, SealingError>;

// End FFI types

impl Default for SetAccessKeyResult {
fn default() -> Self {
EcallResult::Err(SealingError::Sgx(sgx_status_t::SGX_ERROR_UNEXPECTED))
}
}

// Boilerplate From implementations:

impl From<set_access_key::EncryptedRequest> for SetAccessKeyEncryptedRequest {
Expand Down Expand Up @@ -119,3 +130,15 @@ impl From<SetAccessKeyEncryptedResponse> for set_access_key::EncryptedResponse {
};
}
}

impl From<set_access_key::SetAccessKeyResult> for SetAccessKeyResult {
fn from(result: set_access_key::SetAccessKeyResult) -> Self {
Self::from(result.map(SetAccessKeyEncryptedResponse::from))
}
}

impl From<SetAccessKeyResult> for set_access_key::SetAccessKeyResult {
fn from(result: SetAccessKeyResult) -> Self {
Self::from(result.map(set_access_key::EncryptedResponse::from))
}
}
4 changes: 4 additions & 0 deletions rtc_types/src/enclave_messages/set_access_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use core::mem;

use rkyv::{Archive, Deserialize, Serialize};

use crate::enclave_messages::errors::SealingError;
use crate::enclave_messages::{EncryptedEnclaveMessage, ARCHIVED_ENCLAVE_ID_SIZE};

#[derive(Archive, Deserialize, Serialize, Debug, PartialEq, Clone)]
Expand Down Expand Up @@ -32,6 +33,9 @@ pub const RESPONSE_SIZE: usize = mem::size_of::<ArchivedResponse>();
// FFI type: EncryptedResponse
pub type EncryptedResponse = EncryptedEnclaveMessage<RESPONSE_SIZE, 0>;

// FFI type: SetAccessKeyResult
pub type SetAccessKeyResult = Result<EncryptedResponse, SealingError>;

// End FFI types

#[cfg(test)]
Expand Down

0 comments on commit d69de3a

Please sign in to comment.