xref: /freebsd/crypto/openssl/doc/man3/PKCS5_PBKDF2_HMAC.pod (revision e71b70530d95c4f34d8bdbd78d1242df1ba4a945)
1*e71b7053SJung-uk Kim=pod
2*e71b7053SJung-uk Kim
3*e71b7053SJung-uk Kim=head1 NAME
4*e71b7053SJung-uk Kim
5*e71b7053SJung-uk KimPKCS5_PBKDF2_HMAC, PKCS5_PBKDF2_HMAC_SHA1 - password based derivation routines with salt and iteration count
6*e71b7053SJung-uk Kim
7*e71b7053SJung-uk Kim=head1 SYNOPSIS
8*e71b7053SJung-uk Kim
9*e71b7053SJung-uk Kim #include <openssl/evp.h>
10*e71b7053SJung-uk Kim
11*e71b7053SJung-uk Kim int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
12*e71b7053SJung-uk Kim                       const unsigned char *salt, int saltlen, int iter,
13*e71b7053SJung-uk Kim                       const EVP_MD *digest,
14*e71b7053SJung-uk Kim                       int keylen, unsigned char *out);
15*e71b7053SJung-uk Kim
16*e71b7053SJung-uk Kim int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
17*e71b7053SJung-uk Kim                            const unsigned char *salt, int saltlen, int iter,
18*e71b7053SJung-uk Kim                            int keylen, unsigned char *out);
19*e71b7053SJung-uk Kim
20*e71b7053SJung-uk Kim=head1 DESCRIPTION
21*e71b7053SJung-uk Kim
22*e71b7053SJung-uk KimPKCS5_PBKDF2_HMAC() derives a key from a password using a salt and iteration count
23*e71b7053SJung-uk Kimas specified in RFC 2898.
24*e71b7053SJung-uk Kim
25*e71b7053SJung-uk KimB<pass> is the password used in the derivation of length B<passlen>. B<pass>
26*e71b7053SJung-uk Kimis an optional parameter and can be NULL. If B<passlen> is -1, then the
27*e71b7053SJung-uk Kimfunction will calculate the length of B<pass> using strlen().
28*e71b7053SJung-uk Kim
29*e71b7053SJung-uk KimB<salt> is the salt used in the derivation of length B<saltlen>. If the
30*e71b7053SJung-uk KimB<salt> is NULL, then B<saltlen> must be 0. The function will not
31*e71b7053SJung-uk Kimattempt to calculate the length of the B<salt> because it is not assumed to
32*e71b7053SJung-uk Kimbe NULL terminated.
33*e71b7053SJung-uk Kim
34*e71b7053SJung-uk KimB<iter> is the iteration count and its value should be greater than or
35*e71b7053SJung-uk Kimequal to 1. RFC 2898 suggests an iteration count of at least 1000. Any
36*e71b7053SJung-uk KimB<iter> less than 1 is treated as a single iteration.
37*e71b7053SJung-uk Kim
38*e71b7053SJung-uk KimB<digest> is the message digest function used in the derivation. Values include
39*e71b7053SJung-uk Kimany of the EVP_* message digests. PKCS5_PBKDF2_HMAC_SHA1() calls
40*e71b7053SJung-uk KimPKCS5_PBKDF2_HMAC() with EVP_sha1().
41*e71b7053SJung-uk Kim
42*e71b7053SJung-uk KimThe derived key will be written to B<out>. The size of the B<out> buffer
43*e71b7053SJung-uk Kimis specified via B<keylen>.
44*e71b7053SJung-uk Kim
45*e71b7053SJung-uk Kim=head1 NOTES
46*e71b7053SJung-uk Kim
47*e71b7053SJung-uk KimA typical application of this function is to derive keying material for an
48*e71b7053SJung-uk Kimencryption algorithm from a password in the B<pass>, a salt in B<salt>,
49*e71b7053SJung-uk Kimand an iteration count.
50*e71b7053SJung-uk Kim
51*e71b7053SJung-uk KimIncreasing the B<iter> parameter slows down the algorithm which makes it
52*e71b7053SJung-uk Kimharder for an attacker to perform a brute force attack using a large number
53*e71b7053SJung-uk Kimof candidate passwords.
54*e71b7053SJung-uk Kim
55*e71b7053SJung-uk KimThese functions make no assumption regarding the given password.
56*e71b7053SJung-uk KimIt will simply be treated as a byte sequence.
57*e71b7053SJung-uk Kim
58*e71b7053SJung-uk Kim=head1 RETURN VALUES
59*e71b7053SJung-uk Kim
60*e71b7053SJung-uk KimPKCS5_PBKDF2_HMAC() and PBKCS5_PBKDF2_HMAC_SHA1() return 1 on success or 0 on error.
61*e71b7053SJung-uk Kim
62*e71b7053SJung-uk Kim=head1 SEE ALSO
63*e71b7053SJung-uk Kim
64*e71b7053SJung-uk KimL<evp(7)>, L<RAND_bytes(3)>,
65*e71b7053SJung-uk KimL<EVP_BytesToKey(3)>,
66*e71b7053SJung-uk KimL<passphrase-encoding(7)>
67*e71b7053SJung-uk Kim
68*e71b7053SJung-uk Kim=head1 COPYRIGHT
69*e71b7053SJung-uk Kim
70*e71b7053SJung-uk KimCopyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
71*e71b7053SJung-uk Kim
72*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License").  You may not use
73*e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
74*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
75*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
76*e71b7053SJung-uk Kim
77*e71b7053SJung-uk Kim=cut
78