EVP_BytesToKey

Derive a cipher key and IV from a password using the legacy EVP_BytesToKey KDF.

Synopsis

Declared in <openssl/evp.h>

int
EVP_BytesToKey(
    EVP_CIPHER const* type,
    EVP_MD const* md,
    unsigned char const* salt,
    unsigned char const* data,
    int datal,
    int count,
    unsigned char* key,
    unsigned char* iv);

Return Value

Length of the derived key in bytes, or 0 on error.

Parameters

NameDescription
typeCipher whose key and IV lengths determine the output sizes.
mdDigest used in the iterative key derivation (commonly EVP_md5()).
saltOptional 8-byte salt, or NULL.
dataPassword / passphrase bytes.
datalLength of data in bytes.
countIteration count (higher slows brute-force attacks).
keyOutput buffer for the derived key, or NULL to skip.
ivOutput buffer for the derived IV, or NULL to skip.