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 perform 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 concatenation, 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(7), RAND_bytes(3), PKCS5_PBKDF2_HMAC(3), EVP_EncryptInit(3)
60
62       Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
63
64       Licensed under the OpenSSL license (the "License").  You may not use
65       this file except in compliance with the License.  You can obtain a copy
66       in the file LICENSE in the source distribution or at
67       <https://www.openssl.org/source/license.html>.
68
69
70
711.1.1q                            2022-07-21                 EVP_BYTESTOKEY(3)
Impressum