@@ -94,18 +94,13 @@ TEST_CASE("Mismatched attestation and endorsements fail")
9494 pal::PlatformAttestationMeasurement measurement;
9595 pal::PlatformAttestationReportData report_data;
9696
97- try
98- {
97+ CHECK_THROWS_WITH_AS (
9998 pal::verify_snp_attestation_report (
100- mismatched_quote, measurement, report_data);
101- }
102- catch (const std::logic_error& e)
103- {
104- const std::string what = e.what ();
105- CHECK (
106- what.find (" SEV-SNP: The root of trust public key for this attestation "
107- " was not the expected one" ) != std::string::npos);
108- }
99+ mismatched_quote, measurement, report_data),
100+ doctest::Contains (
101+ " SEV-SNP: The root of trust public key for this attestation "
102+ " was not the expected one" ),
103+ std::logic_error);
109104}
110105
111106TEST_CASE (" Parsing of Tcb versions from strings" )
@@ -159,6 +154,47 @@ TEST_CASE("Parsing tcb versions from attestaion")
159154 CHECK_EQ (milan_tcb.boot_loader , 0x04 );
160155}
161156
157+ TEST_CASE (" CPUID product mapping roundtrip" )
158+ {
159+ const std::vector<ccf::pal::snp::ProductName> products = {
160+ ccf::pal::snp::ProductName::Milan,
161+ ccf::pal::snp::ProductName::Genoa,
162+ ccf::pal::snp::ProductName::Turin,
163+ };
164+
165+ for (const auto product : products)
166+ {
167+ const auto cpuid_hex = ccf::pal::snp::get_cpuid_of_snp_sev_product (product);
168+ const auto cpuid = ccf::pal::snp::cpuid_from_hex (cpuid_hex);
169+
170+ CHECK_EQ (cpuid.hex_str (), cpuid_hex);
171+ CHECK_EQ (ccf::pal::snp::get_sev_snp_product (cpuid), product);
172+ CHECK_EQ (
173+ ccf::pal::snp::get_sev_snp_product (
174+ cpuid.get_family_id (), cpuid.get_model_id ()),
175+ product);
176+
177+ switch (product)
178+ {
179+ case ccf::pal::snp::ProductName::Milan:
180+ CHECK_EQ (cpuid.get_family_id (), 0x19 );
181+ CHECK_EQ (cpuid.get_model_id (), 0x01 );
182+ break ;
183+ case ccf::pal::snp::ProductName::Genoa:
184+ CHECK_EQ (cpuid.get_family_id (), 0x19 );
185+ CHECK_EQ (cpuid.get_model_id (), 0x11 );
186+ break ;
187+ case ccf::pal::snp::ProductName::Turin:
188+ CHECK_EQ (cpuid.get_family_id (), 0x1A );
189+ CHECK_EQ (cpuid.get_model_id (), 0x02 );
190+ break ;
191+ default :
192+ FAIL (" Unexpected SNP product" );
193+ break ;
194+ }
195+ }
196+ }
197+
162198struct QuoteEndorsementsTestCase
163199{
164200 std::vector<uint8_t > attestation;
0 commit comments