1EVP_BytesToKey(3) OpenSSL EVP_BytesToKey(3)
2
3
4
6 EVP_BytesToKey - password based encryption routine
7
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
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 paramter 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
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 more standard algorithms such as PKCS#5
38 v2.0 for key derivation.
39
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
54 EVP_BytesToKey() returns the size of the derived key in bytes.
55
57 evp(3), rand(3), EVP_EncryptInit(3)
58
601.0.1e 2013-02-11 EVP_BytesToKey(3)