Skip to content

Commit 70a1f2d

Browse files
committed
Extract identity from ReportBody, not Report
This updates ParseSgxIdentityFromHardwareReport to accept a ReportBody parameter, as the identity is extracted from the ReportBody. None of the other fields in Report are used by this function. PiperOrigin-RevId: 302560636 Change-Id: I30ed1e7540f75bf479ddfc1c3aca47d00e18d786
1 parent 5faf116 commit 70a1f2d

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

asylo/identity/attestation/sgx/internal/attestation_key_certificate_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ AttestationKeyCertificateImpl::Create(const Certificate &certificate) {
205205
}
206206

207207
SgxIdentity AttestationKeyCertificateImpl::GetAssertedSgxIdentity() const {
208-
return ParseSgxIdentityFromHardwareReport(report_);
208+
return ParseSgxIdentityFromHardwareReport(report_.body);
209209
}
210210

211211
bool AttestationKeyCertificateImpl::operator==(

asylo/identity/sgx/self_identity_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ SelfIdentity::SelfIdentity() {
5353
isvprodid = report.body.isvprodid;
5454
isvsvn = report.body.isvsvn;
5555

56-
sgx_identity = ParseSgxIdentityFromHardwareReport(report);
56+
sgx_identity = ParseSgxIdentityFromHardwareReport(report.body);
5757
}
5858

5959
} // namespace sgx

asylo/identity/sgx/sgx_identity_util_internal.cc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,16 @@ bool IsValidMatchSpec(const CodeIdentityMatchSpec &match_spec) {
184184
match_spec.has_attributes_match_mask();
185185
}
186186

187-
CodeIdentity ParseCodeIdentityFromHardwareReport(const Report &report) {
187+
CodeIdentity ParseCodeIdentityFromHardwareReport(const ReportBody &report) {
188188
CodeIdentity identity;
189-
identity.mutable_mrenclave()->set_hash(report.body.mrenclave.data(),
190-
report.body.mrenclave.size());
189+
identity.mutable_mrenclave()->set_hash(report.mrenclave.data(),
190+
report.mrenclave.size());
191191
identity.mutable_signer_assigned_identity()->mutable_mrsigner()->set_hash(
192-
report.body.mrsigner.data(), report.body.mrsigner.size());
193-
identity.mutable_signer_assigned_identity()->set_isvprodid(
194-
report.body.isvprodid);
195-
identity.mutable_signer_assigned_identity()->set_isvsvn(report.body.isvsvn);
196-
*identity.mutable_attributes() = report.body.attributes.ToProtoAttributes();
197-
identity.set_miscselect(report.body.miscselect);
192+
report.mrsigner.data(), report.mrsigner.size());
193+
identity.mutable_signer_assigned_identity()->set_isvprodid(report.isvprodid);
194+
identity.mutable_signer_assigned_identity()->set_isvsvn(report.isvsvn);
195+
*identity.mutable_attributes() = report.attributes.ToProtoAttributes();
196+
identity.set_miscselect(report.miscselect);
198197
return identity;
199198
}
200199

@@ -442,10 +441,10 @@ bool IsValidExpectation(const SgxIdentityExpectation &expectation,
442441
return IsIdentityCompatibleWithMatchSpec(identity, spec, is_legacy);
443442
}
444443

445-
SgxIdentity ParseSgxIdentityFromHardwareReport(const Report &report) {
444+
SgxIdentity ParseSgxIdentityFromHardwareReport(const ReportBody &report) {
446445
SgxIdentity identity;
447446
identity.mutable_machine_configuration()->mutable_cpu_svn()->set_value(
448-
report.body.cpusvn.data(), report.body.cpusvn.size());
447+
report.cpusvn.data(), report.cpusvn.size());
449448
*identity.mutable_code_identity() =
450449
ParseCodeIdentityFromHardwareReport(report);
451450
return identity;

asylo/identity/sgx/sgx_identity_util_internal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ bool IsValidExpectation(const SgxIdentityExpectation &expectation,
7070
bool is_legacy = false);
7171

7272
// Parses SgxIdentity from |report| and places the result in |identity|.
73-
// Does not verify |report|.
74-
SgxIdentity ParseSgxIdentityFromHardwareReport(const Report &report);
73+
SgxIdentity ParseSgxIdentityFromHardwareReport(const ReportBody &report);
7574

7675
// Sets |spec| to the default local SGX match spec, which requires a match on
7776
// MRSIGNER, all MISCSELECT bits, and all ATTRIBUTES bits that do not fall into

asylo/identity/sgx/sgx_identity_util_internal_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ TEST_F(SgxIdentityUtilInternalTest, ParseSgxIdentityFromHardwareReport) {
911911

912912
Report report;
913913
ASYLO_ASSERT_OK_AND_ASSIGN(report, hardware_->GetReport(*tinfo, *reportdata));
914-
SgxIdentity identity = ParseSgxIdentityFromHardwareReport(report);
914+
SgxIdentity identity = ParseSgxIdentityFromHardwareReport(report.body);
915915
CodeIdentity code_identity = identity.code_identity();
916916
EXPECT_TRUE(std::equal(
917917
report.body.mrenclave.cbegin(), report.body.mrenclave.cend(),

asylo/identity/sgx/sgx_local_assertion_generator_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ TEST_F(SgxLocalAssertionGeneratorTest, GenerateSuccess) {
408408
EXPECT_EQ(report->body.reportdata.data, expected_reportdata);
409409

410410
// Verify that the asserted identity is the self identity.
411-
SgxIdentity sgx_identity = ParseSgxIdentityFromHardwareReport(*report);
411+
SgxIdentity sgx_identity = ParseSgxIdentityFromHardwareReport(report->body);
412412

413413
SgxIdentity expected_identity = sgx::GetSelfIdentity()->sgx_identity;
414414
EXPECT_THAT(sgx_identity, EqualsProto(expected_identity))

asylo/identity/sgx/sgx_local_assertion_verifier.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ Status SgxLocalAssertionVerifier::Verify(const std::string &user_data,
183183

184184
// Serialize the protobuf representation of the peer's SGX identity and save
185185
// it in |peer_identity|.
186-
SgxIdentity sgx_identity = sgx::ParseSgxIdentityFromHardwareReport(report);
186+
SgxIdentity sgx_identity =
187+
sgx::ParseSgxIdentityFromHardwareReport(report.body);
187188
ASYLO_RETURN_IF_ERROR(sgx::SerializeSgxIdentity(sgx_identity, peer_identity));
188189

189190
return Status::OkStatus();

0 commit comments

Comments
 (0)