Skip to content

Commit

Permalink
go/registry: Require SGX for non-test compute runtimes using km
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Jul 31, 2020
1 parent 35b95b8 commit c8bb436
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changelog/3159.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/registry: Require SGX for non-test compute runtimes using a key manager

Note: Existing deployments might need to alter the state dump to fix any
existing compute runtimes that registered without SGX hardware and have
keymanager runtime configured.
6 changes: 6 additions & 0 deletions go/genesis/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ func TestGenesisSanityCheck(t *testing.T) {
AdmissionPolicy: registry.RuntimeAdmissionPolicy{
AnyNode: &registry.AnyNodeRuntimeAdmissionPolicy{},
},
TEEHardware: node.TEEHardwareIntelSGX,
Version: registry.VersionInfo{
TEE: cbor.Marshal(registry.VersionInfoIntelSGX{
Enclaves: []sgx.EnclaveIdentity{{}},
}),
},
}
signedTestRuntime := signRuntimeOrDie(signer, testRuntime)

Expand Down
9 changes: 9 additions & 0 deletions go/registry/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,15 @@ func VerifyRegisterComputeRuntimeArgs(ctx context.Context, logger *logging.Logge
)
return ErrInvalidArgument
}

// Currently the keymanager implementation assumes SGX. Unless this is a
// test runtime, a keymanager without SGX is disallowed.
if !rt.ID.IsTest() && rt.TEEHardware != node.TEEHardwareIntelSGX {
logger.Error("RegisterRuntime: runtime without SGX using key manager",
"id", rt.ID,
)
return fmt.Errorf("%w: compute runtime without SGX using key manager", ErrInvalidArgument)
}
}

return nil
Expand Down
30 changes: 29 additions & 1 deletion go/registry/tests/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,35 @@ func testRegistryRuntime(t *testing.T, backend api.Backend, consensus consensusA
true,
true,
},
// Runtime with key manager set.
// Runtime with key manager set, without SGX.
{
"NoSGXWithKM",
func(rt *api.Runtime) {
rt.KeyManager = &rtMapByName["KeyManager"].ID
// Set non-test runtime.
rt.ID = newNamespaceFromSeed([]byte("NoSGXWithKM"), 0)
},
false,
false,
},
// SGX Runtime with key manager set.
{
"SGXWithKM",
func(rt *api.Runtime) {
rt.KeyManager = &rtMapByName["KeyManager"].ID
rt.TEEHardware = node.TEEHardwareIntelSGX

vi := api.VersionInfoIntelSGX{
Enclaves: []sgx.EnclaveIdentity{{}},
}
rt.Version.TEE = cbor.Marshal(vi)
// Set non-test runtime.
rt.ID = newNamespaceFromSeed([]byte("SGXWithKM"), 0)
},
false,
true,
},
// Test Runtime with key manager set.
{
"WithKM",
func(rt *api.Runtime) {
Expand Down

0 comments on commit c8bb436

Please sign in to comment.