Interface KeyDerivationFunction


  • public interface KeyDerivationFunction
    Key derivation function from password interface.
    Since:
    5.4M1
    Version:
    $Id: 21052e0bf378847b87a8df3abfd3465164685c67 $
    • Method Detail

      • getKeySize

        int getKeySize()
        Returns:
        the current requested key size in bytes.
      • overrideKeySize

        void overrideKeySize​(int keySize)
        Override the key size receive from the factory. This is mainly useful internally when the key size from parameter is negative (see KeyDerivationFunctionParameters) to set the effective key size that should be produced by the derivation function. This value will not be encoded with the function, which means that the recipient of the encoded form will also have to overwrite the key size to be able to use this function.
        Parameters:
        keySize - the length of the key to generate. A negative or null value means use the one from parameters.
      • isKeySizeOverwritten

        boolean isKeySizeOverwritten()
        Returns:
        true if the key size has been overwritten.
      • derive

        KeyParameter derive​(byte[] password)
        Derive a key from the provided password.
        Parameters:
        password - the password already converted properly to a byte array. See (PasswordToByteConverter) for converting password properly.
        Returns:
        a key parameters with the generated key.
      • derive

        KeyWithIVParameters derive​(byte[] password,
                                   int ivSize)
        Derive a key and an initialization vector of the requested size from the provided password. Security note: Deriving the initialization vector and the key from the same password is not recommended since it partially defeat the purpose of the initialization vector which is to salt the resulting encrypted data.
        Parameters:
        password - the password already converted properly to a byte array. See (PasswordToByteConverter) for converting password properly.
        ivSize - the initialization vector size in byte.
        Returns:
        a key with iv parameters.
      • getEncoded

        byte[] getEncoded()
                   throws IOException
        Serialize the definition of this key derivation function. This serialization could be provided to an appropriate factory (like the one that have been used to create this function) to produce an equivalent function. The serialization contains the key algorithm and the key parameters. For best interoperability, the recommended encoding is ASN.1 in DER format.
        Returns:
        an encoded definition of this derivation function.
        Throws:
        IOException - on error