nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: chipsalliance/caliptra-sw
Pull request #781 (2023-09-14 06:49:26)

Use actual FMC digest in PCR log test


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 3b4cb3e8..3804fbbc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -598,6 +598,7 @@ dependencies = [
  "caliptra-kat",
  "caliptra-lms-types",
  "caliptra-registers",
+ "caliptra-test",
  "caliptra-x509",
  "caliptra_common",
  "cfg-if 1.0.0",
diff --git a/rom/dev/Cargo.toml b/rom/dev/Cargo.toml
index d003679b..8aeeecbd 100644
--- a/rom/dev/Cargo.toml
+++ b/rom/dev/Cargo.toml
@@ -33,6 +33,7 @@ caliptra-image-fake-keys.workspace = true
 caliptra-image-gen.workspace = true
 caliptra-image-openssl.workspace = true
 caliptra-image-types.workspace = true
+caliptra-test.workspace = true
 hex.workspace = true
 memoffset.workspace = true
 openssl.workspace = true


Test patch:
diff --git a/rom/dev/tests/test_fmcalias_derivation.rs b/rom/dev/tests/test_fmcalias_derivation.rs
index 5de48231..bca0a9b0 100644
--- a/rom/dev/tests/test_fmcalias_derivation.rs
+++ b/rom/dev/tests/test_fmcalias_derivation.rs
@@ -15,6 +15,7 @@ use caliptra_image_fake_keys::{OWNER_CONFIG, VENDOR_CONFIG_KEY_1};
 use caliptra_image_gen::ImageGenerator;
 use caliptra_image_openssl::OsslCrypto;
 use caliptra_image_types::IMAGE_BYTE_SIZE;
+use caliptra_test::swap_word_bytes;
 use openssl::hash::{Hasher, MessageDigest};
 use zerocopy::{AsBytes, FromBytes};
 pub mod helpers;
@@ -80,7 +81,6 @@ const PCR_ENTRY_SIZE: usize = core::mem::size_of::<PcrLogEntry>();
 const MEASUREMENT_ENTRY_SIZE: usize = core::mem::size_of::<MeasurementLogEntry>();
 const MEASUREMENT_MAX_COUNT: usize = 8;
 
-// Skips checking `data` if empty.
 fn check_pcr_log_entry(
     pcr_entry_arr: &[u8],
     pcr_entry_index: usize,
@@ -93,10 +93,7 @@ fn check_pcr_log_entry(
 
     assert_eq!(entry.id, entry_id as u16);
     assert_eq!(entry.pcr_ids, pcr_ids);
-
-    if !pcr_data.is_empty() {
-        assert_eq!(entry.measured_data(), pcr_data);
-    }
+    assert_eq!(entry.measured_data(), pcr_data);
 }
 
 fn check_measurement_log_entry(
@@ -242,7 +239,7 @@ fn test_pcr_log() {
         6,
         PcrLogEntryId::FmcTci,
         PCR0_AND_PCR1_EXTENDED_ID,
-        &[],
+        swap_word_bytes(&image_bundle.manifest.fmc.digest).as_bytes(),
     );
 
     check_pcr_log_entry(