1PKCS5_PBKDF2_HMAC(3ossl) OpenSSL PKCS5_PBKDF2_HMAC(3ossl)
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.
39 PKCS5_PBKDF2_HMAC_SHA1() calls PKCS5_PBKDF2_HMAC() with EVP_sha1().
40
41 The derived key will be written to out. The size of the out buffer is
42 specified via keylen.
43
45 A typical application of this function is to derive keying material for
46 an encryption algorithm from a password in the pass, a salt in salt,
47 and an iteration count.
48
49 Increasing the iter parameter slows down the algorithm which makes it
50 harder for an attacker to perform a brute force attack using a large
51 number of candidate passwords.
52
53 These functions make no assumption regarding the given password. It
54 will simply be treated as a byte sequence.
55
57 PKCS5_PBKDF2_HMAC() and PBKCS5_PBKDF2_HMAC_SHA1() return 1 on success
58 or 0 on error.
59
61 evp(7), RAND_bytes(3), EVP_BytesToKey(3), passphrase-encoding(7)
62
64 Copyright 2014-2021 The OpenSSL Project Authors. All Rights Reserved.
65
66 Licensed under the Apache License 2.0 (the "License"). You may not use
67 this file except in compliance with the License. You can obtain a copy
68 in the file LICENSE in the source distribution or at
69 <https://www.openssl.org/source/license.html>.
70
71
72
733.0.5 2022-11-01 PKCS5_PBKDF2_HMAC(3ossl)