Interface PasswordHashProvider
- All Known Implementing Classes:
Pbkdf2PasswordHashProvider
public interface PasswordHashProvider
Service-provider contract for a concrete password hashing
implementation.
Providers are discovered through Java's ServiceLoader
or registered explicitly by the bootstrap layer. Phase 1a ships a
single PBKDF2 provider in security-core; the optional
security-crypto-bc module adds Argon2id, bcrypt and scrypt.
Providers must not:
- change the global JCA provider order through
Security.insertProviderAtor equivalent; - log password material, derived key material or secret salts;
- throw on a genuine credential mismatch — return
ProviderVerificationResult.NotMatchedinstead.
Pepper material is threaded through as an Optional byte
array; Phase 1a always supplies Optional.empty() (the
NoOpPepperService).
-
Method Summary
Modifier and TypeMethodDescriptionCanonical algorithm identifier this provider handles by default.hash(char[] password, PasswordHashPolicy policy, Optional<PepperReference> pepper) Derives a fresh hash for the supplied password under the active policy.Logical provider identifier, stable across releases.default ResourceEstimateresourceEstimate(Map<String, String> parameters) Optional resource estimate for the supplied parameter map.default booleanReturns whether this provider can serve the given combination.verify(char[] password, PasswordHashEnvelope envelope, Optional<PepperReference> pepper) Verifies the supplied password against the parsed envelope.
-
Method Details
-
providerId
String providerId()Logical provider identifier, stable across releases. Stored in the envelope so that verification can resolve the same implementation regardless of the active policy. -
algorithm
String algorithm()Canonical algorithm identifier this provider handles by default. -
supports
-
hash
PasswordHashResult hash(char[] password, PasswordHashPolicy policy, Optional<PepperReference> pepper) Derives a fresh hash for the supplied password under the active policy.- Parameters:
password- caller-owned character array; the provider must not zero or modify itpolicy- active policy from which to read parameterspepper- resolved active pepper key, orOptional.empty()when peppering is off; the provider applies the pepper asHMAC-SHA-256(pepper.key, KDF(password,salt))and writes thepepper.keyIdinto the envelope
-
verify
ProviderVerificationResult verify(char[] password, PasswordHashEnvelope envelope, Optional<PepperReference> pepper) Verifies the supplied password against the parsed envelope.Implementations must use a constant-time comparison and must never throw on a genuine mismatch. Provider-level failures (missing JCA service, unsupported parameter combination) collapse onto
ProviderVerificationResult.ProviderErrorso the pipeline can keep public messaging generic.- Parameters:
pepper- resolved pepper key matchingenvelope.pepperKeyId(), orOptional.empty()when the envelope has no pepper field
-
resourceEstimate
Optional resource estimate for the supplied parameter map. Default:ResourceEstimate.UNKNOWN.
-