From 07abec4a2ef8cda2eb0115e6e9f479de90dbe20b Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Wed, 21 Aug 2019 09:44:58 +0000 Subject: [PATCH] go/registry: Add a Version field * Just has the allowed MRSIGNER/MRENCLAVE pairs for now, will have also be where I move the non-SGX versioning when it happens. --- go/grpc/registry/runtime.proto | 6 ++++++ go/registry/api/runtime.go | 33 +++++++++++++++++++++++++++++++++ go/registry/api/runtime_test.go | 3 +++ 3 files changed, 42 insertions(+) diff --git a/go/grpc/registry/runtime.proto b/go/grpc/registry/runtime.proto index 8a24149d366..64d8956a110 100644 --- a/go/grpc/registry/runtime.proto +++ b/go/grpc/registry/runtime.proto @@ -23,6 +23,12 @@ message Runtime { uint32 kind = 8; bytes key_manager = 9; + + VersionInfo version = 10; +} + +message VersionInfo { + bytes tee = 1; } service RuntimeRegistry { diff --git a/go/registry/api/runtime.go b/go/registry/api/runtime.go index 414590c19db..e43b7b3ea18 100644 --- a/go/registry/api/runtime.go +++ b/go/registry/api/runtime.go @@ -8,6 +8,7 @@ import ( "github.com/oasislabs/ekiden/go/common/crypto/hash" "github.com/oasislabs/ekiden/go/common/crypto/signature" "github.com/oasislabs/ekiden/go/common/node" + "github.com/oasislabs/ekiden/go/common/sgx" pbRegistry "github.com/oasislabs/ekiden/go/grpc/registry" storage "github.com/oasislabs/ekiden/go/storage/api" ) @@ -70,6 +71,9 @@ type Runtime struct { // KeyManager is the key manager runtime ID for this runtime. KeyManager signature.PublicKey `codec:"key_manager"` + + // Version is the runtime version information. + Version VersionInfo `codec:"versions"` } // String returns a string representation of itself. @@ -110,6 +114,10 @@ func (c *Runtime) FromProto(pb *pbRegistry.Runtime) error { return err } + if err := c.Version.fromProto(pb.GetVersion()); err != nil { + return err + } + c.ReplicaGroupSize = pb.GetReplicaGroupSize() c.ReplicaGroupBackupSize = pb.GetReplicaGroupBackupSize() c.ReplicaAllowedStragglers = pb.GetReplicaAllowedStragglers() @@ -134,6 +142,7 @@ func (c *Runtime) ToProto() *pbRegistry.Runtime { if pb.KeyManager, err = c.KeyManager.MarshalBinary(); err != nil { panic(err) } + pb.Version = c.Version.toProto() pb.ReplicaGroupSize = c.ReplicaGroupSize pb.ReplicaGroupBackupSize = c.ReplicaGroupBackupSize pb.ReplicaAllowedStragglers = c.ReplicaAllowedStragglers @@ -181,6 +190,30 @@ func SignRuntime(signer signature.Signer, context []byte, runtime *Runtime) (*Si }, nil } +// VersionInfo is the per-runtime version information. +type VersionInfo struct { + // TEE is the enclave version information, in an enclave provider specific + // format if any. + TEE []byte `codec:"tee,omit_empty"` +} + +func (v *VersionInfo) fromProto(pb *pbRegistry.VersionInfo) error { + v.TEE = append([]byte{}, pb.GetTee()...) + return nil +} + +func (v *VersionInfo) toProto() *pbRegistry.VersionInfo { + pb := new(pbRegistry.VersionInfo) + pb.Tee = append([]byte{}, v.TEE...) + return pb +} + +// VersionInfoIntelSGX is the SGX TEE version information. +type VersionInfoIntelSGX struct { + // Enclaves is the allowed MRSIGNER/MRENCLAVE pairs. + Enclaves []sgx.EnclaveIdentity `codec:"enclaves"` +} + // RuntimeGenesis is the runtime genesis information that is used to // initialize runtime state in the first block. type RuntimeGenesis struct { diff --git a/go/registry/api/runtime_test.go b/go/registry/api/runtime_test.go index 0610645e7bc..582f6809f19 100644 --- a/go/registry/api/runtime_test.go +++ b/go/registry/api/runtime_test.go @@ -19,6 +19,9 @@ func TestSerialization(t *testing.T) { ReplicaAllowedStragglers: 81, StorageGroupSize: 90, KeyManager: signature.PublicKey(key), + Version: VersionInfo{ + TEE: []byte{}, + }, } cp := c.ToProto()