blob: 5c06bfb0d9b40ed976ebafcecede04aab769adf5 [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 *
Manuel Pégourié-Gonnarda658a402015-01-23 09:45:19 +00009 * Copyright (C) 2006-2012, ARM Limited, All Rights Reserved
Paul Bakkerf518b162012-08-23 13:03:18 +000010 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000011 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakkerf518b162012-08-23 13:03:18 +000012 *
Paul Bakkerf518b162012-08-23 13:03:18 +000013 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27#ifndef POLARSSL_PBKDF2_H
28#define POLARSSL_PBKDF2_H
29
Paul Bakkerf518b162012-08-23 13:03:18 +000030#include "md.h"
31
Rich Evans00ab4702015-02-06 13:43:58 +000032#include <stddef.h>
33
Paul Bakkerfa6a6202013-10-28 18:48:30 +010034#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
Paul Bakker5c2364c2012-10-01 14:41:15 +000035#include <basetsd.h>
36typedef UINT32 uint32_t;
37#else
38#include <inttypes.h>
39#endif
40
Paul Bakkerf518b162012-08-23 13:03:18 +000041#define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA -0x007C /**< Bad input parameters to function. */
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47/**
48 * \brief PKCS#5 PBKDF2 using HMAC
Paul Bakkerb0c19a42013-06-24 19:26:38 +020049 * DEPRECATED: Use pkcs5_pbkdf2_hmac() instead!
Paul Bakkerf518b162012-08-23 13:03:18 +000050 *
51 * \param ctx Generic HMAC context
52 * \param password Password to use when generating key
53 * \param plen Length of password
54 * \param salt Salt to use when generating key
55 * \param slen Length of salt
56 * \param iteration_count Iteration count
57 * \param key_length Length of generated key
58 * \param output Generated key. Must be at least as big as key_length
59 *
Manuel Pégourié-Gonnardb4fe3cb2015-01-22 16:11:05 +000060 * \returns 0 on success, or a POLARSSL_ERR_xxx code if verification fails.
Paul Bakkerf518b162012-08-23 13:03:18 +000061 */
62int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
63 size_t plen, const unsigned char *salt, size_t slen,
64 unsigned int iteration_count,
Paul Bakker5c2364c2012-10-01 14:41:15 +000065 uint32_t key_length, unsigned char *output );
Paul Bakkerf518b162012-08-23 13:03:18 +000066
Paul Bakkerf518b162012-08-23 13:03:18 +000067/**
68 * \brief Checkup routine
Paul Bakkerb0c19a42013-06-24 19:26:38 +020069 * DEPRECATED: Use pkcs5_self_test() instead!
Paul Bakkerf518b162012-08-23 13:03:18 +000070 *
71 * \return 0 if successful, or 1 if the test failed
72 */
73int pbkdf2_self_test( int verbose );
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif /* pbkdf2.h */