Files
pki/Documentation/api/cryptoprov_testprov.md
2026-09-21 09:12:53 +01:00

4.9 KiB

testprov

import "github.com/effective-security/xpki/cryptoprov/testprov"

Package testprov is a test-only in-memory cryptoprov.Provider 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

func Loader

func Loader(tc cryptoprov.TokenConfig) (cryptoprov.Provider, error)

Loader for Provider

type Provider

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.

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

func Init

func Init() (*Provider, error)

Init creates new provider for in memory based HSM

func (*Provider) ExportKey

func (p *Provider) ExportKey(keyID string) (string, []byte, error)

ExportKey returns pkcs11 uri for the given key id

func (*Provider) GenerateECDSAKey

func (p *Provider) GenerateECDSAKey(label string, curve elliptic.Curve) (crypto.PrivateKey, error)

GenerateECDSAKey creates signer using randomly generated ECDSA key

func (*Provider) GenerateRSAKey

func (p *Provider) GenerateRSAKey(label string, bits int, purpose int) (crypto.PrivateKey, error)

GenerateRSAKey creates signer using randomly generated RSA key

func (*Provider) GetKey

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

GetKey returns key for the given id

func (*Provider) IdentifyKey

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

IdentifyKey returns key id and label for the given private key

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

Generated by gomarkdoc