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

Removing flipping endianness of tci_type bytes when forming cert #352

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dpe/src/commands/certify_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ mod tests {
let second = parsed_tcb_infos.next().unwrap();

assert_eq!(first.tci_type.unwrap(), &[0, 0, 0, 0]);
assert_eq!(second.tci_type.unwrap(), &[0, 0, 0, 1]);
assert_eq!(second.tci_type.unwrap(), &[1, 0, 0, 0]);
assert!(parsed_tcb_infos.next().is_none());
}
}
9 changes: 4 additions & 5 deletions dpe/src/x509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use platform::CertValidity;
#[cfg(not(feature = "disable_csr"))]
use platform::SignerIdentifier;
use platform::{OtherName, SubjectAltName, MAX_KEY_IDENTIFIER_SIZE};
use zerocopy::AsBytes;

pub enum DirectoryString<'a> {
PrintableString(&'a [u8]),
Expand Down Expand Up @@ -1246,7 +1247,7 @@ impl CertWriter<'_> {
// IMPLICIT[9] Primitive
bytes_written += self.encode_byte(Self::CONTEXT_SPECIFIC | 0x09)?;
bytes_written += self.encode_size_field(core::mem::size_of::<u32>())?;
bytes_written += self.encode_bytes(&node.tci_type.to_be_bytes())?;
bytes_written += self.encode_bytes(node.tci_type.as_bytes())?;

Ok(bytes_written)
}
Expand Down Expand Up @@ -2239,6 +2240,7 @@ pub(crate) mod tests {
use x509_parser::nom::Parser;
use x509_parser::oid_registry::asn1_rs::oid;
use x509_parser::prelude::*;
use zerocopy::AsBytes;

#[derive(asn1::Asn1Read)]
pub struct Fwid<'a> {
Expand Down Expand Up @@ -2396,10 +2398,7 @@ pub(crate) mod tests {
assert_eq!(expected_current, node.tci_current.0);
assert_eq!(expected_cumulative, node.tci_cumulative.0);

assert_eq!(
parsed_tcb_info.tci_type.unwrap(),
node.tci_type.to_be_bytes()
);
assert_eq!(parsed_tcb_info.tci_type.unwrap(), node.tci_type.as_bytes());
assert_eq!(
parsed_tcb_info.vendor_info.unwrap(),
node.locality.to_be_bytes()
Expand Down
Loading