[#EVP_BytesToKey]
= EVP&lowbar;BytesToKey
:mrdocs:

Derive a cipher key and IV from a password using the legacy EVP&lowbar;BytesToKey KDF&period;

== Synopsis

Declared in `&lt;openssl&sol;evp&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
EVP&lowbar;BytesToKey(
    xref:EVP_CIPHER-07.adoc[EVP&lowbar;CIPHER] const* type,
    xref:EVP_MD.adoc[EVP&lowbar;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&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *type*
| Cipher whose key and IV lengths determine the output sizes&period;
| *md*
| Digest used in the iterative key derivation (commonly EVP&lowbar;md5())&period;
| *salt*
| Optional 8&hyphen;byte salt, or NULL&period;
| *data*
| Password &sol; passphrase bytes&period;
| *datal*
| Length of `data` in bytes&period;
| *count*
| Iteration count (higher slows brute&hyphen;force attacks)&period;
| *key*
| Output buffer for the derived key, or NULL to skip&period;
| *iv*
| Output buffer for the derived IV, or NULL to skip&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
