@@ -3,7 +3,6 @@ package common
33import (
44 "fmt"
55
6- "github.com/oasisprotocol/oasis-core/go/common/sgx"
76 "github.com/oasisprotocol/oasis-core/go/runtime/bundle"
87 "github.com/oasisprotocol/oasis-core/go/runtime/bundle/component"
98
@@ -12,7 +11,7 @@ import (
1211
1312// ComputeEnclaveIdentity computes the enclave identity of the given ROFL components. If no specific
1413// component ID is passed, it uses the first ROFL component.
15- func ComputeEnclaveIdentity (bnd * bundle.Bundle , compID string ) ([]sgx. EnclaveIdentity , error ) {
14+ func ComputeEnclaveIdentity (bnd * bundle.Bundle , compID string ) ([]bundle. Identity , error ) {
1615 var cid component.ID
1716 if compID != "" {
1817 if err := cid .UnmarshalText ([]byte (compID )); err != nil {
@@ -33,14 +32,7 @@ func ComputeEnclaveIdentity(bnd *bundle.Bundle, compID string) ([]sgx.EnclaveIde
3332 }
3433 }
3534
36- switch teeKind := comp .TEEKind (); teeKind {
37- case component .TEEKindSGX :
38- return bnd .EnclaveIdentities (comp .ID ())
39- case component .TEEKindTDX :
40- return measurement .MeasureTdxQemu (bnd , comp )
41- default :
42- return nil , fmt .Errorf ("identity computation for TEE kind '%s' not supported" , teeKind )
43- }
35+ return ComputeComponentIdentity (bnd , comp )
4436 }
4537
4638 switch compID {
@@ -50,3 +42,25 @@ func ComputeEnclaveIdentity(bnd *bundle.Bundle, compID string) ([]sgx.EnclaveIde
5042 return nil , fmt .Errorf ("ROFL app '%s' not found in bundle" , compID )
5143 }
5244}
45+
46+ // ComputeComponentIdentity computes the enclave identity of the given component.
47+ func ComputeComponentIdentity (bnd * bundle.Bundle , comp * bundle.Component ) ([]bundle.Identity , error ) {
48+ switch teeKind := comp .TEEKind (); teeKind {
49+ case component .TEEKindSGX :
50+ eids , err := bnd .EnclaveIdentities (comp .ID ())
51+ if err != nil {
52+ return nil , err
53+ }
54+
55+ ids := make ([]bundle.Identity , len (eids ))
56+ for _ , eid := range eids {
57+ // For SGX enclaves, there is no additional metadata (e.g. hypervisor).
58+ ids = append (ids , bundle.Identity {Enclave : eid })
59+ }
60+ return ids , nil
61+ case component .TEEKindTDX :
62+ return measurement .MeasureTdxQemu (bnd , comp )
63+ default :
64+ return nil , fmt .Errorf ("identity computation for TEE kind '%s' not supported" , teeKind )
65+ }
66+ }
0 commit comments