keys

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package keys provides access to public and private keys for signing and verification of signatures.

Index

Constants

View Source
const (
	// DefaultRsaKeySizeInBits is the size of an RSA key generated by this package, in bits, if not overridden.
	DefaultRsaKeySizeInBits = 2048

	// MinRsaKeySizeInBits is the smallest RSA key that this package will generate.
	MinRsaKeySizeInBits = 2048
)

Variables

This section is empty.

Functions

func ECDSACurveFromParams

func ECDSACurveFromParams(params *keyspb.Specification_ECDSA) elliptic.Curve

ECDSACurveFromParams returns the curve specified by the given parameters. Returns nil if the curve is not supported.

func NewFromSpec

func NewFromSpec(spec *keyspb.Specification) (crypto.Signer, error)

NewFromSpec generates a new private key based on a key specification. If an RSA key is specified, the key size must be at least MinRsaKeySizeInBits.

func NewSigner

func NewSigner(ctx context.Context, keyProto proto.Message) (crypto.Signer, error)

NewSigner uses a registered ProtoHandler (see RegisterHandler()) to convert a protobuf message into a crypto.Signer. If there is no ProtoHandler registered for this type of protobuf message, an error will be returned.

func RegisterHandler

func RegisterHandler(keyProto proto.Message, handler ProtoHandler)

RegisterHandler enables transformation of protobuf messages of the same type as keyProto into crypto.Signer by invoking the provided handler. The keyProto need only be an empty example of the type of protobuf message that the handler can process - only its type is examined. If a handler for this type of protobuf message has already been added, it will be replaced.

func UnregisterHandler

func UnregisterHandler(keyProto proto.Message)

UnregisterHandler removes a previously-added protobuf message handler. See RegisterHandler().

Types

type ProtoGenerator

type ProtoGenerator func(context.Context, *keyspb.Specification) (proto.Message, error)

ProtoGenerator creates a new private key based on a key specification. It returns a proto that can be passed to a ProtoHandler to get a crypto.Signer.

type ProtoHandler

type ProtoHandler func(context.Context, proto.Message) (crypto.Signer, error)

ProtoHandler uses the information in a protobuf message to obtain a crypto.Signer. For example, the protobuf message may contain a key or identify where a key can be found.

Directories

Path Synopsis
der
proto
Package proto registers a DER keys.ProtoHandler using keys.RegisterHandler.
Package proto registers a DER keys.ProtoHandler using keys.RegisterHandler.
pem
proto
Package proto registers a PEM keys.ProtoHandler using keys.RegisterHandler.
Package proto registers a PEM keys.ProtoHandler using keys.RegisterHandler.
Package pkcs11 provides access to private keys using a PKCS#11 interface.
Package pkcs11 provides access to private keys using a PKCS#11 interface.
proto
Package proto registers a PKCS#11 keys.ProtoHandler using keys.RegisterHandler.
Package proto registers a PKCS#11 keys.ProtoHandler using keys.RegisterHandler.
Package testonly contains code and data that should only be used by tests.
Package testonly contains code and data that should only be used by tests.

Jump to

Keyboard shortcuts

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