Class Pbkdf2PasswordHashProvider

java.lang.Object
com.svenruppert.jsentinel.credential.password.pbkdf2.Pbkdf2PasswordHashProvider
All Implemented Interfaces:
PasswordHashProvider

public final class Pbkdf2PasswordHashProvider extends Object implements PasswordHashProvider
JDK/JCA-only PBKDF2 password hash provider.

This is the secure core default and must remain JDK-only so that security-core introduces no runtime dependencies. Modern memory-hard algorithms (Argon2id, scrypt) live in the optional security-crypto-bc module that ships in Phase 1b.

Implementation notes:

  • The provider never modifies the global JCA provider order. A specific JCA provider can be pinned through the jcaProviderName constructor argument; the lookup is performed via SecretKeyFactory.getInstance(String, String) on every call.
  • Salt is drawn fresh from a caller-supplied SecureRandom for every hash(...) so that two identical passwords never yield identical envelopes (CWE-759 / CWE-760).
  • The constant-time comparison uses MessageDigest.isEqual(byte[], byte[]).
  • Temporary byte[] arrays holding salt and derived key material are zeroed before the method returns. The PBEKeySpec.clearPassword() hook is invoked even on failure paths.
  • The provider returns ProviderVerificationResult.ProviderError on JCA-level failures (missing algorithm or provider, invalid key spec) so the surrounding pipeline can keep public messaging generic (CWE-209).
  • Constructor Details

    • Pbkdf2PasswordHashProvider

      public Pbkdf2PasswordHashProvider()
    • Pbkdf2PasswordHashProvider

      public Pbkdf2PasswordHashProvider(String jcaProviderName)
    • Pbkdf2PasswordHashProvider

      public Pbkdf2PasswordHashProvider(PasswordHashCodec codec, SecureRandom random, Optional<String> jcaProviderName)
      Test/SPI constructor that lets callers inject a deterministic SecureRandom (for known-answer assertions) or pin the JCA provider (for FIPS-mode deployments).
  • Method Details