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 ¶
- func Loader(tc cryptoprov.TokenConfig) (cryptoprov.Provider, error)
- type Provider
- func (p *Provider) DestroyKey(ctx context.Context, keyID string) error
- func (p *Provider) ExportKey(_ context.Context, keyID string) (string, []byte, error)
- func (p *Provider) GenerateKey(ctx context.Context, req *cryptoprov.GenerateKeyRequest) (crypto.PrivateKey, error)
- func (p *Provider) GetKey(ctx context.Context, keyID string) (crypto.PrivateKey, error)
- func (p *Provider) IdentifyKey(_ context.Context, priv crypto.PrivateKey) (keyID, label string, err error)
- func (p *Provider) KeyInfo(ctx context.Context, keyID string, fields cryptoprov.KeyFields) (*cryptoprov.KeyInfo, error)
- func (p *Provider) ListKeys(ctx context.Context, req *cryptoprov.ListKeysRequest) (*cryptoprov.ListKeysResponse, error)
- func (p *Provider) Manufacturer() string
- func (p *Provider) Model() string
- func (p *Provider) Serial() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Loader ¶
func Loader(tc cryptoprov.TokenConfig) (cryptoprov.Provider, error)
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 (*Provider) DestroyKey ¶
DestroyKey forgets the key keyID. Handles returned earlier keep working. A key the provider does not have is a wrapped cryptoprov.ErrKeyNotFound.
func (*Provider) GenerateKey ¶
func (p *Provider) GenerateKey(ctx context.Context, req *cryptoprov.GenerateKeyRequest) (crypto.PrivateKey, error)
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 ¶
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 ¶
func (p *Provider) ListKeys(ctx context.Context, req *cryptoprov.ListKeysRequest) (*cryptoprov.ListKeysResponse, error)
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 ¶
Manufacturer return manufacturer for the provider