Documentation ¶
Overview ¶
Package signing provides all functionality within arrebato regarding message signing. This includes both gRPC, raft and data store interactions.
Index ¶
- Variables
- func NewKeyPair() (public []byte, private []byte, err error)
- func SignProto(m proto.Message, privateKey []byte) ([]byte, error)
- func Verify(signature []byte, publicKey []byte) bool
- type BoltStore
- type Executor
- type GRPC
- func (svr *GRPC) CreateKeyPair(ctx context.Context, _ *signingsvc.CreateKeyPairRequest) (*signingsvc.CreateKeyPairResponse, error)
- func (svr *GRPC) GetPublicKey(ctx context.Context, request *signingsvc.GetPublicKeyRequest) (*signingsvc.GetPublicKeyResponse, error)
- func (svr *GRPC) ListPublicKeys(ctx context.Context, _ *signingsvc.ListPublicKeysRequest) (*signingsvc.ListPublicKeysResponse, error)
- func (svr *GRPC) Register(registrar grpc.ServiceRegistrar, healthServer *health.Server)
- type Handler
- type PublicKeyCreator
- type PublicKeyGetter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoPublicKey is the error given when requesting a public key that does not exist. ErrNoPublicKey = errors.New("no public key") // ErrPublicKeyExists is the error given when performing an operation that would overwrite an existing // public key. ErrPublicKeyExists = errors.New("public key exists") )
Functions ¶
func NewKeyPair ¶
NewKeyPair generates a new public/private key pair for message signing.
Types ¶
type BoltStore ¶
type BoltStore struct {
// contains filtered or unexported fields
}
The BoltStore type is responsible for storing client public key data within a bolt database.
func NewBoltStore ¶
NewBoltStore returns a new instance of the BoltStore type that stores signing key data within the provided bbolt.DB instance.
func (*BoltStore) Create ¶
Create a public key record for a client. Returns ErrPublicKeyExists if the client already has a public key.
type Executor ¶
The Executor interface describes types that execute commands related to signing key data.
type GRPC ¶
type GRPC struct {
// contains filtered or unexported fields
}
The GRPC type is a signingsvc.SigningServiceServer implementation that handles inbound gRPC requests to manage client signing keys.
func NewGRPC ¶
func NewGRPC(executor Executor, publicKeys PublicKeyGetter) *GRPC
NewGRPC returns a new instance of the GRPC type that will handle inbound gRPC requests for signing key data. Commands will be executed via the Executor implementation and public keys will be queried via the PublicKeyGetter implementation.
func (*GRPC) CreateKeyPair ¶
func (svr *GRPC) CreateKeyPair(ctx context.Context, _ *signingsvc.CreateKeyPairRequest) (*signingsvc.CreateKeyPairResponse, error)
CreateKeyPair attmpts to create a new signing key pair for the client. It returns a codes.FailedPrecondition error code if this node is not the leader, or a codes.AlreadyExists error code if the client already has a key pair. The private key is not stored by the server and should be kept securely by the client.
func (*GRPC) GetPublicKey ¶
func (svr *GRPC) GetPublicKey(ctx context.Context, request *signingsvc.GetPublicKeyRequest) (*signingsvc.GetPublicKeyResponse, error)
GetPublicKey returns the public key for a client. It returns a codes.NotFound error code if there is no public key for a client.
func (*GRPC) ListPublicKeys ¶
func (svr *GRPC) ListPublicKeys(ctx context.Context, _ *signingsvc.ListPublicKeysRequest) (*signingsvc.ListPublicKeysResponse, error)
ListPublicKeys returns all public keys stored within the server.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
The Handler type is responsible for handling commands sent to the server regarding signing keys.
func NewHandler ¶
func NewHandler(publicKeys PublicKeyCreator, logger hclog.Logger) *Handler
NewHandler returns a new instance of the Handler type that will store public key data via the PublicKeyCreator implementation.
func (*Handler) Create ¶
func (h *Handler) Create(ctx context.Context, payload *signingcmd.CreatePublicKey) error
Create a new public key for the client.
type PublicKeyCreator ¶
type PublicKeyCreator interface { // Create a public key for a client, should return ErrPublicKeyExists if the client already has a public // key. Create(ctx context.Context, clientID string, publicKey []byte) error }
The PublicKeyCreator interface describes types that can create public key records for a client.