@@ -8,56 +8,47 @@ import (
88
99 "github.com/cenkalti/backoff/v4"
1010
11+ "github.com/oasisprotocol/oasis-core/go/common"
1112 "github.com/oasisprotocol/oasis-core/go/common/cbor"
1213 "github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
1314 "github.com/oasisprotocol/oasis-core/go/common/identity"
1415 "github.com/oasisprotocol/oasis-core/go/common/logging"
1516 "github.com/oasisprotocol/oasis-core/go/common/node"
1617 "github.com/oasisprotocol/oasis-core/go/common/sgx/pcs"
1718 sgxQuote "github.com/oasisprotocol/oasis-core/go/common/sgx/quote"
19+ "github.com/oasisprotocol/oasis-core/go/common/version"
1820 consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
1921 registry "github.com/oasisprotocol/oasis-core/go/registry/api"
20- "github.com/oasisprotocol/oasis-core/go/runtime/bundle/component"
2122 "github.com/oasisprotocol/oasis-core/go/runtime/host"
2223 "github.com/oasisprotocol/oasis-core/go/runtime/host/protocol"
2324 "github.com/oasisprotocol/oasis-core/go/runtime/host/sandbox"
2425)
2526
26- // GetQuotePolicy fetches the quote policy for the given component. In case the policy is
27- // not available, return the fallback policy.
28- func GetQuotePolicy (
27+ // GetRONLQuotePolicy fetches the quote policy for the specified RONL deployment.
28+ //
29+ // Returns nil if the policy is not available.
30+ func GetRONLQuotePolicy (
2931 ctx context.Context ,
30- cfg * host.Config ,
32+ runtimeID common.Namespace ,
33+ version version.Version ,
3134 cs consensus.Service ,
32- fallbackPolicy * sgxQuote.Policy ,
3335) (* sgxQuote.Policy , error ) {
34- switch cfg .Component .Kind {
35- case component .RONL :
36- // Load RONL policy from the consensus layer.
37- rt , err := cs .Registry ().GetRuntime (ctx , & registry.GetRuntimeQuery {
38- Height : consensus .HeightLatest ,
39- ID : cfg .ID ,
40- IncludeSuspended : true ,
41- })
42- if err != nil {
43- return nil , fmt .Errorf ("failed to query runtime descriptor: %w" , err )
44- }
45- if d := rt .DeploymentForVersion (cfg .Component .Version ); d != nil {
46- var sc node.SGXConstraints
47- if err = cbor .Unmarshal (d .TEE , & sc ); err != nil {
48- return nil , fmt .Errorf ("malformed runtime SGX constraints: %w" , err )
49- }
50-
51- return sc .Policy , nil
36+ rt , err := cs .Registry ().GetRuntime (ctx , & registry.GetRuntimeQuery {
37+ Height : consensus .HeightLatest ,
38+ ID : runtimeID ,
39+ IncludeSuspended : true ,
40+ })
41+ if err != nil {
42+ return nil , fmt .Errorf ("failed to query runtime descriptor: %w" , err )
43+ }
44+ if d := rt .DeploymentForVersion (version ); d != nil {
45+ var sc node.SGXConstraints
46+ if err = cbor .Unmarshal (d .TEE , & sc ); err != nil {
47+ return nil , fmt .Errorf ("malformed runtime SGX constraints: %w" , err )
5248 }
53- return fallbackPolicy , nil
54- case component .ROFL :
55- // Always use fallback policy for ROFL components.
56- return fallbackPolicy , nil
57- default :
58- // No policy.
59- return fallbackPolicy , nil
49+ return sc .Policy , nil
6050 }
51+ return nil , nil
6152}
6253
6354// EndorseCapabilityTEE endorses the given CapabilityTEE and submits the signed endorsement to the
0 commit comments