blob: 5ccb2fa9f2120b9692723e4dab1916a0912e8937 [file] [log] [blame]
Paul Bakkerf518b162012-08-23 13:03:18 +00001/**
2 * \file pbkdf2.h
3 *
4 * \brief Password-Based Key Derivation Function 2 (from PKCS#5)
Paul Bakkerb0c19a42013-06-24 19:26:38 +02005 * DEPRECATED: use pkcs5.h instead.
Paul Bakkerf518b162012-08-23 13:03:18 +00006 *
7 * \author Mathias Olsson <mathias@kompetensum.com>
8 *
9 * Copyright (C) 2006-2012, Brainspark B.V.
10 *
11 * This file is part of PolarSSL (http://www.polarssl.org)
12 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
13 *
14 * All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 */
30#ifndef POLARSSL_PBKDF2_H
31#define POLARSSL_PBKDF2_H
32
33#include <string.h>
34
35#include "md.h"
36
Paul Bakkerfa6a6202013-10-28 18:48:30 +010037#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
Paul Bakker5c2364c2012-10-01 14:41:15 +000038#include <basetsd.h>
39typedef UINT32 uint32_t;
40#else
41#include <inttypes.h>
42#endif
43
Paul Bakkerf518b162012-08-23 13:03:18 +000044#define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA -0x007C /**< Bad input parameters to function. */
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/**
51 * \brief PKCS#5 PBKDF2 using HMAC
Paul Bakkerb0c19a42013-06-24 19:26:38 +020052 * DEPRECATED: Use pkcs5_pbkdf2_hmac() instead!
Paul Bakkerf518b162012-08-23 13:03:18 +000053 *
54 * \param ctx Generic HMAC context
55 * \param password Password to use when generating key
56 * \param plen Length of password
57 * \param salt Salt to use when generating key
58 * \param slen Length of salt
59 * \param iteration_count Iteration count
60 * \param key_length Length of generated key
61 * \param output Generated key. Must be at least as big as key_length
62 *
63 * \returns 0 on success, or a PolarSSL error code if verification fails.
64 */
65int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
66 size_t plen, const unsigned char *salt, size_t slen,
67 unsigned int iteration_count,
Paul Bakker5c2364c2012-10-01 14:41:15 +000068 uint32_t key_length, unsigned char *output );
Paul Bakkerf518b162012-08-23 13:03:18 +000069
Paul Bakkerf518b162012-08-23 13:03:18 +000070/**
71 * \brief Checkup routine
Paul Bakkerb0c19a42013-06-24 19:26:38 +020072 * DEPRECATED: Use pkcs5_self_test() instead!
Paul Bakkerf518b162012-08-23 13:03:18 +000073 *
74 * \return 0 if successful, or 1 if the test failed
75 */
76int pbkdf2_self_test( int verbose );
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif /* pbkdf2.h */