The KDF
abstract class represent base class for all Key Derivation Functions.
It is a parent of PBKDF2
.
Description: Creates a new KDF
class.
The KDF
class is an abstract class which means that it can't be instantiated.
This constructor defines just logic for its subclasses. It sets a supplied
length and salt if supplied. It can throw KDFException
if the salt size
or length is over the max limits.
length : int
- the key length
salt : string
- the salt
KDF
: New instances of the KDF
subclass.
It can throw KDFException
with code
KDFException::KEY_LENGTH_LOW
- the supplied key length is too lowKDFException::KEY_LENGTH_HIGH
- the supplied key length is too highKDFException::SALT_LENGTH_HIGH
- if the data length exceeds C INT_MAX
Description: An abstract method to derive the key from the password.
The derive
abstract method has to be used in all subclasses to derive
the key from the supplied password. If the derivation fails, it must
throw KDFException
.
password : string
- the password
string
: Derived key.
The implementing method can throw KDFException
with code
KDFException::DERIVATION_FAILED
- the derivation failedKDFException::PASSWORD_LENGTH_INVALID
- if the password length exceeds C INT_MAX
Description: Returns a length of the derived key.
This method returns a lenght of the key that will be or was derived
by the KDF::derive
.
This method has no parameters.
This method does not throw any exception.
int
: The lenght of the derived key.
Description: Returns salt for the key derivation.
This method returns salt string that will be used when deriving a key
using KDF::derive
.
This method has no parameters.
This method does not throw any exception.
string
: The salt.
Description: Sets a length for the derived key.
This method sets a length that will be the string length of the derived key.
length : int
- key length
It can throw KDFException
with code
KDFException::KEY_LENGTH_LOW
- if key length is less than 0KDFException::KEY_LENGTH_HIGH
- if key length is more than C INT_MAX value
bool
: true if the key length was set succesfully
Description: Sets salt for the key derivation.
This method sets salt that will be used when deriving key using KDF::derive
.
salt : string
- salt for the key derivation
It can throw KDFException
with code
KDFException::SALT_LENGTH_HIGH
- if the salt length is more than C INT_MAX
bool
: true if the salt was set succesfully