-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add io
and arch
modules to std::os::fortanix_sgx
#57119
Conversation
|
||
/// Call the `EGETKEY` instruction to obtain a 128-bit secret key. | ||
#[unstable(feature = "sgx_platform", issue = "56975")] | ||
pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use more meaningful structs here, rather than Align16<[u8; 16]>
? For instance, a struct Key
with the appropriate alignment and contents?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the PR description:
I tried using the actual types (from the sgx-isa crate) instead of byte arrays, but that would make std dependent on the bitflags crate which I didn't want to do at this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see! I didn't realize those were the types you meant.
We do need a better solution for bitfields, in-tree.
In the meantime, would you please add a comment to these types, explicitly saying to consider a more type-safe version before stabilizing? That way it doesn't get lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about I'll add a note on the tracking issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jethrogb Alright, that works.
@bors r+ |
📌 Commit be56561 has been approved by |
Add `io` and `arch` modules to `std::os::fortanix_sgx` This PR adds two more (unstable) modules to `std::os::fortanix_sgx` for the `x86_64-fortanix-unknown-sgx` target. ### io `io` allows conversion between raw file descriptors and Rust types, similar to `std::os::unix::io`. ### arch `arch` exposes the `ENCLU[EREPORT]` and `ENCLU[EGETKEY]` instructions. The current functions are very likely not going to be the final form of these functions (see also fortanix/rust-sgx#15), but this should be sufficient to enable experimentation in libraries. I tried using the actual types (from the [`sgx-isa` crate](https://crates.io/crates/sgx-isa)) instead of byte arrays, but that would make `std` dependent on the `bitflags` crate which I didn't want to do at this time.
☀️ Test successful - status-appveyor, status-travis |
This PR adds two more (unstable) modules to
std::os::fortanix_sgx
for thex86_64-fortanix-unknown-sgx
target.io
io
allows conversion between raw file descriptors and Rust types, similar tostd::os::unix::io
.arch
arch
exposes theENCLU[EREPORT]
andENCLU[EGETKEY]
instructions. The current functions are very likely not going to be the final form of these functions (see also fortanix/rust-sgx#15), but this should be sufficient to enable experimentation in libraries. I tried using the actual types (from thesgx-isa
crate) instead of byte arrays, but that would makestd
dependent on thebitflags
crate which I didn't want to do at this time.