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