This repository has been archived by the owner on May 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rtc_types::enclave_messages): add ng_set_access_key
Non-generic version of [`set_access_key`], with conversions. This is a workaround for cbindgen not supporting const generics in structs yet, and should be removed once cbindgen implements that. Tracking issue: <mozilla/cbindgen#687>
- Loading branch information
Showing
6 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
//! FIXME: Non-generic version of [`set_access_key`], with conversions. | ||
//! | ||
//! This is a workaround for cbindgen not supporting const generics in structs yet, | ||
//! and should be removed once cbindgen implements that. | ||
//! | ||
//! Tracking issue: <https://github.com/eqrion/cbindgen/issues/687> | ||
//! | ||
//! These sizes should match the ones computed in `set_access_key`. | ||
//! (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 super::{set_access_key, RecommendedAesGcmIv}; | ||
|
||
// Begin FFI types | ||
// (Keep these FFI type comments in sync between set_access_key and ffi_set_access_key, for diffing!) | ||
|
||
// FFI type: REQUEST_SIZE | ||
pub const SET_ACCESS_KEY_REQUEST_SIZE: usize = 40; | ||
|
||
// FFI type: EncryptedRequest | ||
#[repr(C)] | ||
pub struct SetAccessKeyEncryptedRequest { | ||
pub tag: sgx_aes_gcm_128bit_tag_t, | ||
pub ciphertext: [u8; SET_ACCESS_KEY_REQUEST_SIZE], | ||
pub aad: [u8; 0], | ||
pub nonce: RecommendedAesGcmIv, | ||
} | ||
|
||
// FFI type: RESPONSE_SIZE | ||
pub const SET_ACCESS_KEY_RESPONSE_SIZE: usize = 1; | ||
|
||
// FFI type: EncryptedResponse | ||
#[derive(Default)] | ||
#[repr(C)] | ||
pub struct SetAccessKeyEncryptedResponse { | ||
pub tag: sgx_aes_gcm_128bit_tag_t, | ||
pub ciphertext: [u8; SET_ACCESS_KEY_RESPONSE_SIZE], | ||
pub aad: [u8; 0], | ||
pub nonce: RecommendedAesGcmIv, | ||
} | ||
|
||
// End FFI types | ||
|
||
// Boilerplate From implementations: | ||
|
||
impl From<set_access_key::EncryptedRequest> for SetAccessKeyEncryptedRequest { | ||
fn from( | ||
set_access_key::EncryptedRequest { | ||
tag, | ||
ciphertext, | ||
aad, | ||
nonce, | ||
}: set_access_key::EncryptedRequest, | ||
) -> Self { | ||
return SetAccessKeyEncryptedRequest { | ||
tag, | ||
ciphertext, | ||
aad, | ||
nonce, | ||
}; | ||
} | ||
} | ||
|
||
impl From<SetAccessKeyEncryptedRequest> for set_access_key::EncryptedRequest { | ||
fn from( | ||
SetAccessKeyEncryptedRequest { | ||
tag, | ||
ciphertext, | ||
aad, | ||
nonce, | ||
}: SetAccessKeyEncryptedRequest, | ||
) -> Self { | ||
return set_access_key::EncryptedRequest { | ||
tag, | ||
ciphertext, | ||
aad, | ||
nonce, | ||
}; | ||
} | ||
} | ||
|
||
impl From<set_access_key::EncryptedResponse> for SetAccessKeyEncryptedResponse { | ||
fn from( | ||
set_access_key::EncryptedResponse { | ||
tag, | ||
ciphertext, | ||
aad, | ||
nonce, | ||
}: set_access_key::EncryptedResponse, | ||
) -> Self { | ||
return SetAccessKeyEncryptedResponse { | ||
tag, | ||
ciphertext, | ||
aad, | ||
nonce, | ||
}; | ||
} | ||
} | ||
|
||
impl From<SetAccessKeyEncryptedResponse> for set_access_key::EncryptedResponse { | ||
fn from( | ||
SetAccessKeyEncryptedResponse { | ||
tag, | ||
ciphertext, | ||
aad, | ||
nonce, | ||
}: SetAccessKeyEncryptedResponse, | ||
) -> Self { | ||
return set_access_key::EncryptedResponse { | ||
tag, | ||
ciphertext, | ||
aad, | ||
nonce, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters