From 1e38ba908931e110c1ed1b61dcedab9cb86500e1 Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Wed, 29 Jan 2020 11:22:03 +0100 Subject: [PATCH] go/keymanager: Move Frame structure to enclaverpc package --- go/keymanager/api/api.go | 8 -------- go/keymanager/api/grpc.go | 4 ++-- go/runtime/enclaverpc/api/api.go | 13 ++++++++++++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/go/keymanager/api/api.go b/go/keymanager/api/api.go index 2d556958cdd..2c16f51930a 100644 --- a/go/keymanager/api/api.go +++ b/go/keymanager/api/api.go @@ -180,14 +180,6 @@ func (g *Genesis) SanityCheck() error { return nil } -// Frame is the Go analog of the Rust RPC Frame defined in -// client/src/rpc/client.rs. -type Frame struct { - Session []byte `json:"session,omitempty"` - UntrustedPlaintext string `json:"untrusted_plaintext,omitempty"` - Payload []byte `json:"payload,omitempty"` -} - func init() { // Old `INSECURE_SIGNING_KEY_PKCS8`. var oldTestKey signature.PublicKey diff --git a/go/keymanager/api/grpc.go b/go/keymanager/api/grpc.go index 54c7b7b4d56..4e9c2cb38e9 100644 --- a/go/keymanager/api/grpc.go +++ b/go/keymanager/api/grpc.go @@ -32,9 +32,9 @@ var ( Service = enclaverpc.NewService(ModuleName, requestSkipPolicyCheck) ) -func payloadSkipPolicyCheck(data []byte) (bool, error) { +func payloadSkipPolicyCheck(data cbor.RawMessage) (bool, error) { // Unpack the payload, get method from Frame. - var f Frame + var f enclaverpc.Frame if err := cbor.Unmarshal(data, &f); err != nil { return false, fmt.Errorf("unable to unpack Frame: %w", err) } diff --git a/go/runtime/enclaverpc/api/api.go b/go/runtime/enclaverpc/api/api.go index bce034b119c..4a6ca3d737a 100644 --- a/go/runtime/enclaverpc/api/api.go +++ b/go/runtime/enclaverpc/api/api.go @@ -5,6 +5,7 @@ import ( "context" "github.com/oasislabs/oasis-core/go/common" + "github.com/oasislabs/oasis-core/go/common/cbor" ) // Transport is the EnclaveRPC transport interface. @@ -18,5 +19,15 @@ type CallEnclaveRequest struct { RuntimeID common.Namespace `json:"runtime_id"` Endpoint string `json:"endpoint"` - Payload []byte `json:"payload"` + // Payload is a CBOR-serialized Frame. + Payload cbor.RawMessage `json:"payload"` +} + +// Frame is an EnclaveRPC frame. +// +// It is the Go analog of the Rust RPC frame defined in client/src/rpc/client.rs. +type Frame struct { + Session []byte `json:"session,omitempty"` + UntrustedPlaintext string `json:"untrusted_plaintext,omitempty"` + Payload []byte `json:"payload,omitempty"` }