Skip to content

Commit

Permalink
Removing flipping endianness of tci_type bytes when forming cert
Browse files Browse the repository at this point in the history
  • Loading branch information
nquarton authored and jhand2 committed Sep 12, 2024
1 parent 2e02db5 commit 80c5ed6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
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

0 comments on commit 80c5ed6

Please sign in to comment.