Class Pkcs11SigningProviderFactory
java.lang.Object
zeroecho.pki.impl.crypto.pkcs11.Pkcs11SigningProviderFactory
- All Implemented Interfaces:
ConfigurableProvider<SigningProvider>, SigningProviderFactory
ServiceLoader factory for the PKCS#11 / HSM signing provider.
Keys are generated on the HSM and never exported. Cryptographic operations
execute on the HSM token via the JDK's built-in SunPKCS11 provider.
This satisfies FIPS 140-3 Level 3 requirements for key non-exportability.
Configuration keys
pkcs11ConfigFile(required): path to the SunPKCS11 library config filepinVariable(required): name of the environment variable holding the HSM PINslot(optional, default0): PKCS#11 slot indexkeyLabelPattern(optional, defaultzeroecho-{authorityId}): key label templatekeyRefPrefix(optional): prefix applied to key referencesoperationHorizon(optional, ISO-8601 duration, defaultP90D)sessionPoolSize(optional, default2): number of PKCS#11 sessionssupportedAlgorithms(optional, comma-separated JCA names)
Security
The PIN is read from the environment variable named by pinVariable,
never from the config file itself. Configuration values must not be logged.
- Since:
- 1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a provider factory without opening an HSM session. -
Method Summary
Modifier and TypeMethodDescriptionallocate(ProviderConfig config) Allocates a new instance using the provided configuration.allocate(ProviderConfig config, SigningProviderRuntimeDependencies dependencies) Allocates a provider with explicit process-local runtime dependencies.id()Returns a stable backend identifier (e.g.Returns the configuration keys understood by this backend.voidvalidateConfig(ProviderConfig config) Validates configuration for the PKCS#11 signing provider.
-
Field Details
-
DC_PIN_ENV_NOT_SET
Stable failure code when the HSM PIN environment variable is absent or empty.- See Also:
-
DC_PKCS11_PROVIDER_LOAD_FAILED
Stable failure code when the PKCS#11 provider cannot be loaded.- See Also:
-
DC_HSM_KEYSTORE_OPEN_FAILED
Stable failure code when the HSM KeyStore cannot be opened.- See Also:
-
-
Constructor Details
-
Pkcs11SigningProviderFactory
public Pkcs11SigningProviderFactory()Creates a provider factory without opening an HSM session.
-
-
Method Details
-
id
Description copied from interface:ConfigurableProviderReturns a stable backend identifier (e.g."fs","jdbc").- Specified by:
idin interfaceConfigurableProvider<SigningProvider>- Returns:
- backend identifier (never
null, never blank)
-
supportedKeys
Description copied from interface:ConfigurableProviderReturns the configuration keys understood by this backend.Keys are informational (diagnostics/validation/help). Unknown keys must be ignored by implementations for forward compatibility.
- Specified by:
supportedKeysin interfaceConfigurableProvider<SigningProvider>- Returns:
- supported configuration keys (never
null)
-
validateConfig
Validates configuration for the PKCS#11 signing provider.- Specified by:
validateConfigin interfaceConfigurableProvider<SigningProvider>- Parameters:
config- provider configuration (nevernull)- Throws:
IllegalArgumentException- if the configuration is incomplete or invalid
-
allocate
Description copied from interface:ConfigurableProviderAllocates a new instance using the provided configuration.Implementations must validate required keys and throw
IllegalArgumentExceptionif configuration is incomplete or invalid.- Specified by:
allocatein interfaceConfigurableProvider<SigningProvider>- Parameters:
config- configuration (nevernull)- Returns:
- new instance (never
null)
-
allocate
public SigningProvider allocate(ProviderConfig config, SigningProviderRuntimeDependencies dependencies) Description copied from interface:SigningProviderFactoryAllocates a provider with explicit process-local runtime dependencies.- Specified by:
allocatein interfaceSigningProviderFactory- Parameters:
config- validated persistent provider configurationdependencies- process-local security capabilities- Returns:
- opened signing provider owned by the caller
-