blob: 09e56dfa3ce0c22222c8955afaaa5dc94e50ce83 [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 *
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/*
31 * PBKDF2 is part of PKCS#5
32 *
33 * http://tools.ietf.org/html/rfc2898 (Specification)
34 * http://tools.ietf.org/html/rfc6070 (Test vectors)
35 */
36
37#include "polarssl/config.h"
38
39#if defined(POLARSSL_PBKDF2_C)
40
41#include "polarssl/pbkdf2.h"
Paul Bakkerb0c19a42013-06-24 19:26:38 +020042#include "polarssl/pkcs5.h"
Paul Bakkerf518b162012-08-23 13:03:18 +000043
44int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password, size_t plen,
45 const unsigned char *salt, size_t slen,
46 unsigned int iteration_count,
Paul Bakker5c2364c2012-10-01 14:41:15 +000047 uint32_t key_length, unsigned char *output )
Paul Bakkerf518b162012-08-23 13:03:18 +000048{
Paul Bakkerb0c19a42013-06-24 19:26:38 +020049 return pkcs5_pbkdf2_hmac( ctx, password, plen, salt, slen, iteration_count,
50 key_length, output );
Paul Bakkerf518b162012-08-23 13:03:18 +000051}
52
Paul Bakkerf518b162012-08-23 13:03:18 +000053#if defined(POLARSSL_SELF_TEST)
Paul Bakkerf518b162012-08-23 13:03:18 +000054int pbkdf2_self_test( int verbose )
55{
Paul Bakkerb0c19a42013-06-24 19:26:38 +020056 return pkcs5_self_test( verbose );
Paul Bakkerf518b162012-08-23 13:03:18 +000057}
Paul Bakkerf518b162012-08-23 13:03:18 +000058#endif /* POLARSSL_SELF_TEST */
59
60#endif /* POLARSSL_PBKDF2_C */