blob: a07c70cc26d47f7d61d2ffd4910902eb4f8da988 [file] [log] [blame]
Paul Bakkerf518b162012-08-23 13:03:18 +00001/**
2 * \file pbkdf2.c
3 *
4 * \brief Password-Based Key Derivation Function 2 (from PKCS#5)
Paul Bakkerb0c19a42013-06-24 19:26:38 +02005 * DEPRECATED: Use pkcs5.c 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-2014, ARM Limited, All Rights Reserved
Paul Bakkerf518b162012-08-23 13:03:18 +000010 *
Manuel Pégourié-Gonnard860b5162015-01-28 17:12:07 +000011 * This file is part of mbed TLS (https://polarssl.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/*
28 * PBKDF2 is part of PKCS#5
29 *
30 * http://tools.ietf.org/html/rfc2898 (Specification)
31 * http://tools.ietf.org/html/rfc6070 (Test vectors)
32 */
33
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020034#if !defined(POLARSSL_CONFIG_FILE)
Paul Bakkerf518b162012-08-23 13:03:18 +000035#include "polarssl/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020036#else
37#include POLARSSL_CONFIG_FILE
38#endif
Paul Bakkerf518b162012-08-23 13:03:18 +000039
40#if defined(POLARSSL_PBKDF2_C)
41
42#include "polarssl/pbkdf2.h"
Paul Bakkerb0c19a42013-06-24 19:26:38 +020043#include "polarssl/pkcs5.h"
Paul Bakkerf518b162012-08-23 13:03:18 +000044
45int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password, size_t plen,
46 const unsigned char *salt, size_t slen,
47 unsigned int iteration_count,
Paul Bakker5c2364c2012-10-01 14:41:15 +000048 uint32_t key_length, unsigned char *output )
Paul Bakkerf518b162012-08-23 13:03:18 +000049{
Paul Bakkerb0c19a42013-06-24 19:26:38 +020050 return pkcs5_pbkdf2_hmac( ctx, password, plen, salt, slen, iteration_count,
51 key_length, output );
Paul Bakkerf518b162012-08-23 13:03:18 +000052}
53
Paul Bakkerf518b162012-08-23 13:03:18 +000054#if defined(POLARSSL_SELF_TEST)
Paul Bakkerf518b162012-08-23 13:03:18 +000055int pbkdf2_self_test( int verbose )
56{
Paul Bakkerb0c19a42013-06-24 19:26:38 +020057 return pkcs5_self_test( verbose );
Paul Bakkerf518b162012-08-23 13:03:18 +000058}
Paul Bakkerf518b162012-08-23 13:03:18 +000059#endif /* POLARSSL_SELF_TEST */
60
61#endif /* POLARSSL_PBKDF2_C */