I'm developing a simple software that do aes256-cbc file encryption. This software is developed on GNU/Linux using libgcrypt-1.5.0.
I want to use the above function with GCRY_KDF_PBKDF2
as algo
and SHA512
as subalgo.
gcry_kdf_derive( const void *passphrase, size_t passphraselen, int algo, int subalgo,
const void *salt, size_t saltlen, unsigned long iterations,
size_t keysize, void *keybuffer )
This function derive a key from a passphrase
. keysize
gives the requested size of the keys in octets. keybuffer
is a caller provided buffer filled on success with the derived key. The input passphrase is taken from passphrase
which is an arbitrary memory buffer of passphraselen octets. algo
specifies the KDF algorithm to use; see below. subalgo
specifies an algorithm used internally by the KDF algorithms; this is usually a hash algorithm but certain KDF algorithms may use it differently. salt
is a salt of length saltlen octets, as needed by most KDF algorithms. iterations
is a positive integer parameter to most KDFs.
I don't have understand three things about how to use this function:
salt
must be generate randomly so it must be put not encrypted into the output file, isn't it? (IV-CIPHERTEXT-SALT-MAC)saltlen
has a correct "crypto" value or can i choose whatever i prefer? Like 10,20,30...- keysize (in this case) must be 512, right?