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

Add impl TryFrom<&[u8]> and other methods for SigData #14

Merged
merged 1 commit into from
Dec 18, 2020

Conversation

lkatalin
Copy link
Contributor

@lkatalin lkatalin commented Dec 16, 2020

Note that the size of SigData isn't known at compilation time, so an impl TryFrom<&[u8]> for SigData is appropriate.

I'm also open to making some of the byte lengths, etc., into constants, but there are so many that I thought it would just be even less readable. Open to suggestions on this.

Related to enarx/enarx#917
related to enarx/enarx#84

@lkatalin lkatalin requested a review from npmccallum as a code owner December 16, 2020 21:41
@lkatalin lkatalin changed the title Sigdata Add impl TryFrom<&[u8]> and other methods for SigData Dec 16, 2020
//! The QuoteHeader is part of the Quote structure. See the Quote module for more.

use super::quote::QuoteError;
use std::convert::TryFrom;
Copy link
Member

Choose a reason for hiding this comment

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

you might get rid of std by using core::convert::TryFrom

@@ -6,5 +6,12 @@

#[cfg(feature = "std")]
pub mod quote;

#[cfg(feature = "std")]
Copy link
Member

Choose a reason for hiding this comment

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

might not be needed


/// A.4, Table 4
#[derive(Default)]
#[repr(C)]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this makes sense with Vec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it can't be #[repr(c)] then I may need to have a different version of the struct that's created from this original once the size is known. Maybe a debt issue...

Copy link
Member

Choose a reason for hiding this comment

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

Why do you need #[repr(C)] ? for FFI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this may potentially get passed around between Rust and C.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may also be possible in the near future to remove the vec fields, which would be ideal. Although the Quote can change in size, I think the version we're using will always be the same size. But I have to test that theory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@haraldh I made a debt issue here: #16

report::{Body, ReportError},
sigdata::SigData,
};
use std::fmt;
Copy link
Member

Choose a reason for hiding this comment

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

could use core::fmt and get rid of std

@enarxbot enarxbot merged commit 867b001 into enarx:master Dec 18, 2020
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.

8 participants