Class PBKDF2

    • Field Detail

      • DEFAULT_ITERATION_COUNT

        public static final Integer DEFAULT_ITERATION_COUNT
        Default iteration count.
      • DEFAULT_GENERATED_SALT_LENGTH

        public static final Integer DEFAULT_GENERATED_SALT_LENGTH
        Default length for generated salt, in bytes.
      • PBKDF2_JCA_ALGORITHM_BASE

        private static final String PBKDF2_JCA_ALGORITHM_BASE
        Base algorithm ID for PBKDF2 SecretKeyFactory.
        See Also:
        Constant Field Values
      • salt

        @Nullable
        private String salt
        Base64-encoded salt value.
      • keyLength

        @Nullable
        private Integer keyLength
        Key length, in bits.
    • Constructor Detail

      • PBKDF2

        public PBKDF2()
    • Method Detail

      • getSalt

        @Nullable
        public String getSalt()
        Get the Base64-encoded salt value.
        Returns:
        the salt value
      • setSalt

        public void setSalt​(@Nullable
                            String value)
        Set the Base64-encoded salt value.
        Parameters:
        value - the salt
      • getGeneratedSaltLength

        @NonnullAfterInit
        public Integer getGeneratedSaltLength()
        Get the generated salt length, in bytes.
        Returns:
        the generated salt length, in bytes
      • setGeneratedSaltLength

        public void setGeneratedSaltLength​(@Nullable
                                           Integer length)
        Set the generated salt length, in bytes.
        Parameters:
        length - the generated salt length
      • getRandom

        @NonnullAfterInit
        public SecureRandom getRandom()
        Get the secure random generator.

        Defaults to the platform default via new SecureRandom()

        Returns:
        the secure random instance
      • setRandom

        public void setRandom​(@Nullable
                              SecureRandom sr)
        Set the secure random generator.

        Defaults to the platform default via new SecureRandom()

        Parameters:
        sr - the secure random generator to set
      • getIterationCount

        @NonnullAfterInit
        public Integer getIterationCount()
        Get the iteration count.
        Returns:
        the iteration count
      • setIterationCount

        public void setIterationCount​(@Nullable
                                      Integer count)
        Set the iteration count.
        Parameters:
        count - the iteration count
      • getKeyLength

        @Nullable
        public Integer getKeyLength()
        Get the key length, in number of bits.

        Note: KeyLength in expressed XML will be in bytes

        Returns:
        the key length
      • setKeyLength

        public void setKeyLength​(@Nullable
                                 Integer length)
        Set the key length, in number of bits.

        Note: KeyLength in expressed XML will be in bytes

        Parameters:
        length - the key length
      • getPRF

        @NonnullAfterInit
        public String getPRF()
        Get the pseudo-random function algorithm URI.
        Returns:
        the algorithm URI
      • setPRF

        public void setPRF​(@Nullable
                           String uri)
        Set the pseudo-random function algorithm URI.
        Parameters:
        uri - the PRF URI
      • getEffectiveSalt

        protected byte[] getEffectiveSalt()
                                   throws KeyDerivationException
        Get the effective salt bytes to use.
        Returns:
        the salt bytes
        Throws:
        KeyDerivationException - if the salt value can not be successfully resolved
      • getEffectiveKeyLength

        protected Integer getEffectiveKeyLength​(@Nonnull
                                                String keyAlgorithm,
                                                @Nullable
                                                Integer specifiedKeyLength)
                                         throws KeyDerivationException
        Get the effective key length, in bits.
        Parameters:
        keyAlgorithm - the algorithm for which the derived key will be used
        specifiedKeyLength - the explicitly specified key length
        Returns:
        the effective key length, in bits
        Throws:
        KeyDerivationException - if the key length can not be successfully resolved