inmemcrypto

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: 19 Imported by: 1 module, 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 inmemcrypto is a software cryptoprov.Provider that keeps RSA, ECDSA and ML-DSA keys in memory and can export them as PEM (PKCS#1, SEC1 and PKCS#8 respectively). It registers itself as manufacturer "inmem" and is selected by cryptoprov.Load when the config location is "" or "inmem". Intended for development, tests and delegated OCSP responder keys; it is not a KeyManager.

Key generation, lookup, and PEM export may run concurrently. Registry locking does not cover key generation, signing, or PEM serialization. Each export returns a caller-owned byte slice. Token configuration passed to Loader must remain unchanged while the provider is in use.

Index

Constants

View Source
const ProviderName = "inmem"

ProviderName specifies a provider name

Variables

This section is empty.

Functions

func Loader

Loader provides loader for Provider

Types

type Provider

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

Provider stores exportable RSA, ECDSA and ML-DSA keys and supports concurrent key generation, lookup, and PEM export. Token configuration must remain unchanged while the provider is in use.

func NewProvider

func NewProvider() *Provider

NewProvider creates new provider for exportable RSA, ECDSA and ML-DSA keys. This provider should be used only when HSM use is not applicable.

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 the PEM encoded plain text key: PKCS#1 for RSA, SEC1 for ECDSA and PKCS#8 (seed form) for ML-DSA.

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; see cryptoprov.MLDSASignerOptions. 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