Skip to content

Commit

Permalink
Merge pull request #5704 from oasisprotocol/jberci/feat/tcb-reorder
Browse files Browse the repository at this point in the history
Reverse TCB fetch order
  • Loading branch information
jberci authored May 27, 2024
2 parents 7f4cb9a + 09a2c65 commit be002a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changelog/5704.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go: Reverse order of TCB update fetching

Early TCB updates are now tried first when updating TCB info. If
validation for an early update fails, the mechanism falls back to the
standard update.
2 changes: 1 addition & 1 deletion go/runtime/host/sgx/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (ec *teeStateECDSA) Update(ctx context.Context, sp *sgxProvisioner, conn pr
return fresh, nil
}
var tcbBundle *pcs.TCBBundle
for _, update := range []pcs.UpdateType{pcs.UpdateStandard, pcs.UpdateEarly} {
for _, update := range []pcs.UpdateType{pcs.UpdateEarly, pcs.UpdateStandard} {
if tcbBundle, err = getTcbBundle(update); err == nil {
break
}
Expand Down
12 changes: 7 additions & 5 deletions go/runtime/host/sgx/epid.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,24 @@ func (ep *teeStateEPID) update(
RuntimeID: ep.runtimeID,
Quote: quote,
Nonce: nonce,
EarlyTCBUpdate: true,
MinTCBEvaluationDataNumber: quotePolicy.MinTCBEvaluationDataNumber,
}

// First try with early updating. If that fails, fall back to normal.
avrBundle, err := iasClient.VerifyEvidence(ctx, &evidence)
if err != nil {
return nil, fmt.Errorf("error while verifying attestation evidence: %w", err)
return nil, fmt.Errorf("error while verifying attestation evidence with early update: %w", err)
}

// Decode the AVR so we can do further checks.
avr, decErr := cmnIAS.UnsafeDecodeAVR(avrBundle.Body)
if decErr == nil && avr.TCBEvaluationDataNumber < quotePolicy.MinTCBEvaluationDataNumber {
// Retry again with early updating.
evidence.EarlyTCBUpdate = true
if decErr == nil && avr.ISVEnclaveQuoteStatus != cmnIAS.QuoteOK && avr.ISVEnclaveQuoteStatus != cmnIAS.QuoteSwHardeningNeeded {
// Retry again without early updating.
evidence.EarlyTCBUpdate = false
avrBundle, err = iasClient.VerifyEvidence(ctx, &evidence)
if err != nil {
return nil, fmt.Errorf("error while verifying attestation evidence with early update: %w", err)
return nil, fmt.Errorf("error while verifying attestation evidence with normal update: %w", err)
}
avr, decErr = cmnIAS.UnsafeDecodeAVR(avrBundle.Body)
}
Expand Down

0 comments on commit be002a0

Please sign in to comment.