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

feat(sealing-enclave): initial implementation #14

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jdvlio
Copy link
Contributor

@jdvlio jdvlio commented Mar 1, 2023

Initial implementation of the sealing enclave

@jdvlio jdvlio requested review from tshepang and sonasi March 1, 2023 09:05
let user_data_buf = unsafe { slice::from_raw_parts(user_data, sealed_user_data_size) };

let mut rng = SgxRng::new().expect("SGX: RDRAND instruction failed");
let mut user_sealing_key = SecretKey::new([0u8; 32]);
Copy link
Contributor

@tshepang tshepang Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32 feels like it should an associated type of SecretKey, such that...

SecretKey::new([0u8; SecretKey::SIZE])

Maybe even better is to do a Default derive on SecretKey, so that you could just...

SecretKey::default()

I have not tested if it would work, so just a guess.

let mut user_sealing_key = SecretKey::new([0u8; 32]);
rng.fill_bytes(user_sealing_key.as_mut());

let user_data_nonce = Nonce::new([0u8; Nonce::SIZE]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps another candidate for a Default derive.

let sealed_user_data =
match sealing::seal(user_data_buf, user_sealing_key, user_data_nonce, user_id) {
Ok(sealed_data) => sealed_data,
Err(_) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect the seal function would reveal sensitive info, easpecially since the error ultimately comes from ring_compat::aead::Error, which I believe practices good hygiene :)

)
.unwrap(); // never panics due to array usage

let enclave_key_nonce = Nonce::new([0u8; Nonce::SIZE]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more candidate for Default derive.

let enclave_key_nonce = Nonce::new([0u8; Nonce::SIZE]);
let sealed_key = match sealing::seal(user_data_buf, enclave_key, enclave_key_nonce, user_id) {
Ok(sealed_key) => sealed_key,
Err(_) => {
Copy link
Contributor

@tshepang tshepang Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdvlio jdvlio force-pushed the feat-initial-sealing-enclave branch from 09e6e8c to 76b166e Compare March 1, 2023 12:16
@jdvlio jdvlio force-pushed the feat-initial-sealing-enclave branch from 76b166e to 7d0da0b Compare March 3, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants