blob: 28987b3f7f9488c167bbce86cd1fdfd269d21080 [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)
Manuel Pégourié-Gonnard71432842015-03-20 16:19:35 +00005 *
6 * \deprecated Use pkcs5.h instead.
Paul Bakkerf518b162012-08-23 13:03:18 +00007 *
8 * \author Mathias Olsson <mathias@kompetensum.com>
9 *
Manuel Pégourié-Gonnarda658a402015-01-23 09:45:19 +000010 * Copyright (C) 2006-2012, ARM Limited, All Rights Reserved
Paul Bakkerf518b162012-08-23 13:03:18 +000011 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000012 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakkerf518b162012-08-23 13:03:18 +000013 *
Paul Bakkerf518b162012-08-23 13:03:18 +000014 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 */
28#ifndef POLARSSL_PBKDF2_H
29#define POLARSSL_PBKDF2_H
30
Paul Bakkerf518b162012-08-23 13:03:18 +000031#include "md.h"
32
Rich Evans00ab4702015-02-06 13:43:58 +000033#include <stddef.h>
34
Paul Bakkerfa6a6202013-10-28 18:48:30 +010035#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
Paul Bakker5c2364c2012-10-01 14:41:15 +000036#include <basetsd.h>
37typedef UINT32 uint32_t;
38#else
39#include <inttypes.h>
40#endif
41
Paul Bakkerf518b162012-08-23 13:03:18 +000042#define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA -0x007C /**< Bad input parameters to function. */
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
Manuel Pégourié-Gonnardc70581c2015-03-23 13:58:27 +010048#if ! defined(POLARSSL_DEPRECATED_REMOVED)
49#if defined(POLARSSL_DEPRECATED_WARNING)
50#define DEPRECATED __attribute__((deprecated))
51#else
52#define DEPRECATED
53#endif
Paul Bakkerf518b162012-08-23 13:03:18 +000054/**
55 * \brief PKCS#5 PBKDF2 using HMAC
Manuel Pégourié-Gonnard71432842015-03-20 16:19:35 +000056 *
57 * \deprecated Use pkcs5_pbkdf2_hmac() instead
Paul Bakkerf518b162012-08-23 13:03:18 +000058 *
59 * \param ctx Generic HMAC context
60 * \param password Password to use when generating key
61 * \param plen Length of password
62 * \param salt Salt to use when generating key
63 * \param slen Length of salt
64 * \param iteration_count Iteration count
65 * \param key_length Length of generated key
66 * \param output Generated key. Must be at least as big as key_length
67 *
Manuel Pégourié-Gonnardb4fe3cb2015-01-22 16:11:05 +000068 * \returns 0 on success, or a POLARSSL_ERR_xxx code if verification fails.
Paul Bakkerf518b162012-08-23 13:03:18 +000069 */
70int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
71 size_t plen, const unsigned char *salt, size_t slen,
72 unsigned int iteration_count,
Manuel Pégourié-Gonnardc70581c2015-03-23 13:58:27 +010073 uint32_t key_length, unsigned char *output ) DEPRECATED;
Paul Bakkerf518b162012-08-23 13:03:18 +000074
Paul Bakkerf518b162012-08-23 13:03:18 +000075/**
76 * \brief Checkup routine
Manuel Pégourié-Gonnard71432842015-03-20 16:19:35 +000077 *
78 * \deprecated Use pkcs5_self_test() instead
Paul Bakkerf518b162012-08-23 13:03:18 +000079 *
80 * \return 0 if successful, or 1 if the test failed
81 */
Manuel Pégourié-Gonnardc70581c2015-03-23 13:58:27 +010082int pbkdf2_self_test( int verbose ) DEPRECATED;
83#undef DEPRECATED
84#endif /* POLARSSL_DEPRECATED_REMOVED */
Paul Bakkerf518b162012-08-23 13:03:18 +000085
86#ifdef __cplusplus
87}
88#endif
89
90#endif /* pbkdf2.h */