api

package
v0.2103.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package api defines the EnclaveRPC interface.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ServiceName is the gRPC service name.
	ServiceName = cmnGrpc.NewServiceName("EnclaveRPC")

	// MethodCallEnclave is the CallEnclave method.
	MethodCallEnclave = ServiceName.NewMethod("CallEnclave", CallEnclaveRequest{}).
						WithNamespaceExtractor(func(ctx context.Context, req interface{}) (common.Namespace, error) {
			r, ok := req.(*CallEnclaveRequest)
			if !ok {
				return common.Namespace{}, errInvalidRequestType
			}
			return r.RuntimeID, nil
		}).
		WithAccessControl(func(ctx context.Context, req interface{}) (bool, error) {
			r, ok := req.(*CallEnclaveRequest)
			if !ok {
				return false, errInvalidRequestType
			}

			endpoint, ok := registeredEndpoints.Load(r.Endpoint)
			if !ok {
				return false, fmt.Errorf("enclaverpc: unsupported endpoint: %s", r.Endpoint)
			}

			return endpoint.(Endpoint).AccessControlRequired(ctx, r)
		})
)

Functions

func NewEndpoint

func NewEndpoint(name string, endpoint Endpoint)

NewEndpoint registers a new EnclaveRPC endpoint.

func RegisterService

func RegisterService(server *grpc.Server, service Transport)

RegisterService registers a new EnclaveRPC transport service with the given gRPC server.

Types

type CallEnclaveRequest

type CallEnclaveRequest struct {
	RuntimeID common.Namespace `json:"runtime_id"`
	Endpoint  string           `json:"endpoint"`

	// Payload is a CBOR-serialized Frame.
	Payload []byte `json:"payload"`
}

CallEnclaveRequest is a CallEnclave request.

type Endpoint

type Endpoint interface {
	// AccessControlRequired returns true if access control policy lookup is required for a specific
	// request. In case an error is returned the request is aborted.
	AccessControlRequired(ctx context.Context, request *CallEnclaveRequest) (bool, error)
}

Endpoint is an EnclaveRPC endpoint descriptor.

Endpoints may be registered using the `NewEndpoint` function.

type Frame

type Frame struct {
	Session            []byte `json:"session,omitempty"`
	UntrustedPlaintext string `json:"untrusted_plaintext,omitempty"`
	Payload            []byte `json:"payload,omitempty"`
}

Frame is an EnclaveRPC frame.

It is the Go analog of the Rust RPC frame defined in client/src/rpc/types.rs.

type Transport

type Transport interface {
	// CallEnclave sends the request bytes to the target enclave.
	CallEnclave(ctx context.Context, request *CallEnclaveRequest) ([]byte, error)
}

Transport is the EnclaveRPC transport interface.

func NewTransportClient

func NewTransportClient(c *grpc.ClientConn) Transport

NewTransportClient creates a new EnclaveRPC gRPC transport client service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL