Skip to content

Commit

Permalink
go/keymanager: Move Frame structure to enclaverpc package
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Jan 29, 2020
1 parent d24fe99 commit 1e38ba9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 0 additions & 8 deletions go/keymanager/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go/keymanager/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 12 additions & 1 deletion go/runtime/enclaverpc/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"`
}

0 comments on commit 1e38ba9

Please sign in to comment.