1EVP_BytesToKey(3)                   OpenSSL                  EVP_BytesToKey(3)
2
3
4

NAME

6       EVP_BytesToKey - password based encryption routine
7

SYNOPSIS

9        #include <openssl/evp.h>
10
11        int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
12                              const unsigned char *salt,
13                              const unsigned char *data, int datal, int count,
14                              unsigned char *key,unsigned char *iv);
15

DESCRIPTION

17       EVP_BytesToKey() derives a key and IV from various parameters. type is
18       the cipher to derive the key and IV for. md is the message digest to
19       use.  The salt parameter is used as a salt in the derivation: it should
20       point to an 8 byte buffer or NULL if no salt is used. data is a buffer
21       containing datal bytes which is used to derive the keying data. count
22       is the iteration count to use. The derived key and IV will be written
23       to key and iv respectively.
24

NOTES

26       A typical application of this function is to derive keying material for
27       an encryption algorithm from a password in the data parameter.
28
29       Increasing the count parameter slows down the algorithm which makes it
30       harder for an attacker to peform a brute force attack using a large
31       number of candidate passwords.
32
33       If the total key and IV length is less than the digest length and MD5
34       is used then the derivation algorithm is compatible with PKCS#5 v1.5
35       otherwise a non standard extension is used to derive the extra data.
36
37       Newer applications should use a more modern algorithm such as PBKDF2 as
38       defined in PKCS#5v2.1 and provided by PKCS5_PBKDF2_HMAC.
39

KEY DERIVATION ALGORITHM

41       The key and IV is derived by concatenating D_1, D_2, etc until enough
42       data is available for the key and IV. D_i is defined as:
43
44               D_i = HASH^count(D_(i-1) || data || salt)
45
46       where || denotes concatentaion, D_0 is empty, HASH is the digest
47       algorithm in use, HASH^1(data) is simply HASH(data), HASH^2(data) is
48       HASH(HASH(data)) and so on.
49
50       The initial bytes are used for the key and the subsequent bytes for the
51       IV.
52

RETURN VALUES

54       If data is NULL, then EVP_BytesToKey() returns the number of bytes
55       needed to store the derived key.  Otherwise, EVP_BytesToKey() returns
56       the size of the derived key in bytes, or 0 on error.
57

SEE ALSO

59       evp(3), rand(3), EVP_EncryptInit(3)
60

HISTORY

621.0.2o                            2020-08-01                 EVP_BytesToKey(3)
Impressum