Skip to content

Commit cc40c8e

Browse files
authored
Re-enable COSE- UVM endorsements test (#7598)
1 parent a01de73 commit cc40c8e

4 files changed

Lines changed: 25 additions & 16 deletions

File tree

src/node/cose_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace ccf::cose
3131

3232
static constexpr auto CONTENT_TYPE_APPLICATION_JSON_VALUE =
3333
"application/json";
34+
static constexpr auto CONTENT_TYPE_APPLICATION_OCTET_STREAM =
35+
"application/octet-stream";
3436
}
3537

3638
using Signature = std::span<const uint8_t>;

src/node/test/endorsements.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ TEST_CASE("Check Test endorsement for UVM 0.2.10")
151151
REQUIRE(!endorsement.empty());
152152

153153
ccf::pal::SnpAttestationMeasurement measurement(
154-
"6d6c354511d6f7c6d7504668903dc5bdc066a048b651840d8d03fb85299ebfa142fccf1d1b"
155-
"0baca496841bdf243619d4");
154+
"4904167aa9102a7557b97ac102469f50289d5be76036fcbb8107897ee146a6184772c4ea6e"
155+
"3f050a1bac6951c285bc89");
156156
ccf::pal::PlatformAttestationMeasurement uvm_measurement(measurement);
157157

158158
std::vector<ccf::pal::UVMEndorsements> custom_roots_of_trust = {
159159
ccf::pal::UVMEndorsements{
160160
"did:x509:0:sha256:I__iuL25oXEVFdTP_aBLx_eT1RPHbCQ_ECBQfYZpt9s::eku:1.3."
161-
"6.1.4.1.311.76.59.1.1",
161+
"6.1.4.1.311.76.59.1.2",
162162
"Malicious-ContainerPlat-AMD-UVM",
163163
"104"}};
164164

@@ -167,20 +167,16 @@ TEST_CASE("Check Test endorsement for UVM 0.2.10")
167167
endorsement, uvm_measurement, custom_roots_of_trust),
168168
"UVM endorsements did "
169169
"did:x509:0:sha256:I__iuL25oXEVFdTP_aBLx_eT1RPHbCQ_ECBQfYZpt9s::eku:1.3.6."
170-
"1.4.1.311.76.59.1.1, feed ContainerPlat-AMD-UVM, svn 104 do not match any "
170+
"1.4.1.311.76.59.1.2, feed ContainerPlat-AMD-UVM, svn 104 do not match any "
171171
"of the known UVM roots of trust",
172172
std::logic_error);
173173

174-
/* Commented out awaiting on UVM endorsements with fixed EKUs (ending .2
175-
instead of .1).
176-
177174
auto endorsements = ccf::verify_uvm_endorsements_against_roots_of_trust(
178175
endorsement, uvm_measurement, ccf::default_uvm_roots_of_trust);
179176

180177
REQUIRE(endorsements.did == ccf::default_uvm_roots_of_trust[0].did);
181178
REQUIRE(endorsements.feed == ccf::default_uvm_roots_of_trust[0].feed);
182179
REQUIRE(endorsements.svn == "104");
183-
*/
184180
}
185181

186182
TEST_CASE("Check UVM roots of trust matching")

src/node/uvm_endorsements.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,18 @@ namespace ccf
326326
auto raw_payload =
327327
cose::verify_uvm_endorsements_signature(pubk, uvm_endorsements_raw);
328328

329-
if (phdr.content_type != cose::headers::CONTENT_TYPE_APPLICATION_JSON_VALUE)
330-
{
331-
throw std::logic_error(fmt::format(
332-
"Unexpected payload content type {}, expected {}",
333-
phdr.content_type,
334-
cose::headers::CONTENT_TYPE_APPLICATION_JSON_VALUE));
335-
}
336-
337329
std::string sevsnpvm_launch_measurement{};
338330
if (sevsnpvm_guest_svn.empty())
339331
{
332+
if (
333+
phdr.content_type != cose::headers::CONTENT_TYPE_APPLICATION_JSON_VALUE)
334+
{
335+
throw std::logic_error(fmt::format(
336+
"Unexpected payload content type {}, expected {}",
337+
phdr.content_type,
338+
cose::headers::CONTENT_TYPE_APPLICATION_JSON_VALUE));
339+
}
340+
340341
auto payload = nlohmann::json::parse(raw_payload);
341342
sevsnpvm_launch_measurement =
342343
payload["x-ms-sevsnpvm-launchmeasurement"].get<std::string>();
@@ -373,6 +374,16 @@ namespace ccf
373374
}
374375
else
375376
{
377+
if (
378+
phdr.content_type !=
379+
cose::headers::CONTENT_TYPE_APPLICATION_OCTET_STREAM)
380+
{
381+
throw std::logic_error(fmt::format(
382+
"Unexpected payload content type {}, expected {}",
383+
phdr.content_type,
384+
cose::headers::CONTENT_TYPE_APPLICATION_OCTET_STREAM));
385+
}
386+
376387
sevsnpvm_launch_measurement =
377388
ccf::ds::to_hex(raw_payload.begin(), raw_payload.end());
378389
}
-27 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)