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
- 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 ¶
const ProviderName = "inmem"
ProviderName specifies a provider name
Variables ¶
This section is empty.
Functions ¶
func Loader ¶
func Loader(tc cryptoprov.TokenConfig) (cryptoprov.Provider, error)
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 ¶
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 ¶
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 ¶
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; 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 ¶
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