plugin

package
v0.2200.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package plugin implements the Go plugin signature signer.

Index

Constants

View Source
const (
	// SignerName is the name used to identify the plugin backed signer.
	SignerName = "plugin"
)

Variables

This section is empty.

Functions

func NewFactory

func NewFactory(config interface{}, roles ...signature.SignerRole) (signature.SignerFactory, error)

NewFactory creates a new factory backed by the specified plugin and plugin configuration.

func Serve

func Serve(name string, impl Signer)

Serve instantiates and serves a concrete Signer instance as a plugin. This is intended to be called from the plugin's `main()`.

Types

type FactoryConfig

type FactoryConfig struct {
	// Name is the expected human readable name of the plugin (eg: "ledger", "memory")
	Name string

	// Path is the path to the plugin dynamic shared object.
	Path string

	// Config is the plugin configuration.
	Config string
}

FactoryConfig is the plugin factory configuration.

type RPCContextSignArgs

type RPCContextSignArgs struct {
	Role       signature.SignerRole
	RawContext signature.Context
	Message    []byte
}

RPCContextSignArgs is exposed entirely to placate `net/rpc`.

type RPCInitArgs

type RPCInitArgs struct {
	Config string
	Roles  []signature.SignerRole
}

RPCInitArgs is exposed entirely to placate `net/rpc`.

type RPCLoadArgs

type RPCLoadArgs struct {
	Role         signature.SignerRole
	MustGenerate bool
}

RPCLoadArgs is exposed entirely to placate `net/rpc`.

type Signer

type Signer interface {
	// Initialize initializes the plugin with the provided configuration
	// and roles.
	Initialize(config string, roles ...signature.SignerRole) error

	// Load will load the private key corresponding to the provided role,
	// optionally generating a new keypair if requested.
	Load(role signature.SignerRole, mustGenerate bool) error

	// Public returns the public key corresponding to a given role.
	Public(role signature.SignerRole) (signature.PublicKey, error)

	// ContextSign generates a signature with the given role's private
	// key over the context and message.
	//
	// Note: Unlike the real signature.Signer interface, it is assumed
	// that the caller handles context registration and domain
	// separation.
	ContextSign(role signature.SignerRole, rawContext signature.Context, message []byte) ([]byte, error)
}

Signer is the interface that must be implemented by all signer plugins.

Jump to

Keyboard shortcuts

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