provider

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package provider implements a common interface for token and smartcards which provide secret key material.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSlotType                 = errors.New("invalid slot type")
	ErrParse                    = errors.New("failed to parse")
	ErrUnsupportedCurve         = errors.New("unsupported curve")
	ErrUnsupportedHashAlgorithm = errors.New("unsupported hash algorithm")
	ErrUnsupportedProtocol      = errors.New("unsupported protocol")
)
View Source
var ErrKeyNotFound = errors.New("key not found")

Functions

func Register

func Register(name string, p any)

Types

type CardFilter

type CardFilter = filter.Filter

type KeyID

type KeyID []byte

func (KeyID) String

func (i KeyID) String() string

type MultiProvider

type MultiProvider struct {
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(cfg MultiProviderConfig) (p *MultiProvider, err error)

func (*MultiProvider) Close

func (p *MultiProvider) Close() error

func (*MultiProvider) CreateKey

func (p *MultiProvider) CreateKey(_ string) (KeyID, error)

func (*MultiProvider) DestroyKey

func (p *MultiProvider) DestroyKey(KeyID) error

func (*MultiProvider) Keys

func (p *MultiProvider) Keys() (allKeys []KeyID, err error)

func (*MultiProvider) OpenKey

func (p *MultiProvider) OpenKey(KeyID) (PrivateKey, error)

type MultiProviderConfig

type MultiProviderConfig struct {
	TPMPaths    []string
	FilterCards CardFilter
	FilterTPMs  TPMFilter
}

type NewProviderTPM

type NewProviderTPM func(transport.TPM) (Provider, error)

type PrivateKey

type PrivateKey interface {
	// ID returns the keys unique identifier.
	// For elliptic curve keys its the SHA256 digest of the public key.
	// For HMAC keys its the output of HMAC([]).
	ID() KeyID

	// Details returns a dictionary of the keys auxiliary attributes.
	Details() map[string]any

	// Close closes any internal handles to the key.
	Close() error
}

type PrivateKeyDH

type PrivateKeyDH interface {
	PrivateKey

	ecdh.PrivateKey
}

type PrivateKeyHMAC

type PrivateKeyHMAC interface {
	PrivateKey

	HMAC(challenge []byte) ([]byte, error)
}

type Provider

type Provider interface {
	// Keys enumerates all keys available via this provider.
	Keys() ([]KeyID, error)

	// CreateKey creates a new key with the given human-readable label.
	CreateKey(label string) (KeyID, error)

	// OpenKey opens a key for cryptographic operations.
	OpenKey(KeyID) (PrivateKey, error)

	// DestroyKey removes the cryptographic key material from the provider.
	DestroyKey(KeyID) error
}

type TPMFilter

type TPMFilter func(string) bool

Jump to

Keyboard shortcuts

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