package keys

import "github.com/google/trillian/crypto/keys"

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

Index

Constants

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
)

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.

Source Files

doc.go generate.go handlers.go

Directories

PathSynopsis
crypto/keys/der
crypto/keys/der/protoPackage proto registers a DER keys.ProtoHandler using keys.RegisterHandler.
crypto/keys/pem
crypto/keys/pem/protoPackage proto registers a PEM keys.ProtoHandler using keys.RegisterHandler.
crypto/keys/pkcs11Package pkcs11 provides access to private keys using a PKCS#11 interface.
crypto/keys/pkcs11/protoPackage proto registers a PKCS#11 keys.ProtoHandler using keys.RegisterHandler.
crypto/keys/testonlyPackage testonly contains code and data that should only be used by tests.
Version
v1.3.0
Published
Jul 11, 2019
Platform
js/wasm
Imports
11 packages
Last checked
6 hours ago

Tools for package owners.