testprov

package
v2.0.331 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testprov is a test-only in-memory cryptoprov.Provider (RSA, ECDSA and ML-DSA keys) whose keys are not exportable: ExportKey returns a pkcs11: URI like the HSM and KMS providers do, and the key wrapper implements crypto.Decrypter. Unlike the other providers it is not registered in init(); tests call Register or Loader explicitly.

Key generation, lookup, and URI export may run concurrently. Registry locking does not cover key generation, signing, or decryption. Token configuration passed to Loader must remain unchanged while the provider is in use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loader

Loader for Provider

Types

type Provider

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

Provider stores non-exportable keys for tests and supports concurrent key generation, lookup, and URI export. Token configuration must remain unchanged while the provider is in use.

func Init

func Init() (*Provider, error)

Init creates new provider for in memory based HSM

func (*Provider) DestroyKey

func (p *Provider) DestroyKey(ctx context.Context, keyID string) error

DestroyKey forgets the key keyID. Handles returned earlier keep working. A key the provider does not have is a wrapped cryptoprov.ErrKeyNotFound.

func (*Provider) ExportKey

func (p *Provider) ExportKey(_ context.Context, keyID string) (string, []byte, error)

ExportKey returns pkcs11 uri for the given key id

func (*Provider) GenerateKey

GenerateKey creates a signer using a randomly generated RSA, ECDSA or ML-DSA key as req describes it (cryptoprov.GenerateKeyRequest.Validate); an ML-DSA signer signs messages, not digests. The usage and the tags are recorded for KeyInfo and ListKeys and are not enforced. An empty label gets a random one.

func (*Provider) GetKey

func (p *Provider) GetKey(ctx context.Context, keyID string) (crypto.PrivateKey, error)

GetKey returns key for the given id, or a wrapped cryptoprov.ErrKeyNotFound.

func (*Provider) IdentifyKey

func (p *Provider) IdentifyKey(_ context.Context, priv crypto.PrivateKey) (keyID, label string, err error)

IdentifyKey returns key id and label for the given private key

func (*Provider) KeyInfo

func (p *Provider) KeyInfo(ctx context.Context, keyID string, fields cryptoprov.KeyFields) (*cryptoprov.KeyInfo, error)

KeyInfo describes the key keyID, with its PEM public key when fields has cryptoprov.KeyFieldPublicKey. A key the provider does not have is a wrapped cryptoprov.ErrKeyNotFound.

func (*Provider) ListKeys

ListKeys returns a page of the keys in the order they were generated; the page token is an offset in that order (cryptoprov.PageKeys). Every field group is filled whatever req.Fields selects, since none costs a request.

func (*Provider) Manufacturer

func (p *Provider) Manufacturer() string

Manufacturer return manufacturer for the provider

func (*Provider) Model

func (p *Provider) Model() string

Model return model for the provider

func (*Provider) Serial

func (p *Provider) Serial() string

Serial return serial number for the provider

Jump to

Keyboard shortcuts

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