1PKCS5_PBKDF2_HMAC(3) OpenSSL PKCS5_PBKDF2_HMAC(3)
2
3
4
6 PKCS5_PBKDF2_HMAC, PKCS5_PBKDF2_HMAC_SHA1 - password based derivation
7 routines with salt and iteration count
8
10 #include <openssl/evp.h>
11
12 int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
13 const unsigned char *salt, int saltlen, int iter,
14 const EVP_MD *digest,
15 int keylen, unsigned char *out);
16
17 int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
18 const unsigned char *salt, int saltlen, int iter,
19 int keylen, unsigned char *out);
20
22 PKCS5_PBKDF2_HMAC() derives a key from a password using a salt and
23 iteration count as specified in RFC 2898.
24
25 pass is the password used in the derivation of length passlen. pass is
26 an optional parameter and can be NULL. If passlen is -1, then the
27 function will calculate the length of pass using strlen().
28
29 salt is the salt used in the derivation of length saltlen. If the salt
30 is NULL, then saltlen must be 0. The function will not attempt to
31 calculate the length of the salt because it is not assumed to be NULL
32 terminated.
33
34 iter is the iteration count and its value should be greater than or
35 equal to 1. RFC 2898 suggests an iteration count of at least 1000. Any
36 iter less than 1 is treated as a single iteration.
37
38 digest is the message digest function used in the derivation. Values
39 include any of the EVP_* message digests. PKCS5_PBKDF2_HMAC_SHA1()
40 calls PKCS5_PBKDF2_HMAC() with EVP_sha1().
41
42 The derived key will be written to out. The size of the out buffer is
43 specified via keylen.
44
46 A typical application of this function is to derive keying material for
47 an encryption algorithm from a password in the pass, a salt in salt,
48 and an iteration count.
49
50 Increasing the iter parameter slows down the algorithm which makes it
51 harder for an attacker to perform a brute force attack using a large
52 number of candidate passwords.
53
54 These functions make no assumption regarding the given password. It
55 will simply be treated as a byte sequence.
56
58 PKCS5_PBKDF2_HMAC() and PBKCS5_PBKDF2_HMAC_SHA1() return 1 on success
59 or 0 on error.
60
62 evp(7), RAND_bytes(3), EVP_BytesToKey(3), passphrase-encoding(7)
63
65 Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
66
67 Licensed under the OpenSSL license (the "License"). You may not use
68 this file except in compliance with the License. You can obtain a copy
69 in the file LICENSE in the source distribution or at
70 <https://www.openssl.org/source/license.html>.
71
72
73
741.1.1i 2021-07-22 PKCS5_PBKDF2_HMAC(3)