| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 1 | /** | 
|  | 2 | * \file pbkdf2.c | 
|  | 3 | * | 
|  | 4 | * \brief Password-Based Key Derivation Function 2 (from PKCS#5) | 
| Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 5 | *        DEPRECATED: Use pkcs5.c instead | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 6 | * | 
|  | 7 | * \author Mathias Olsson <mathias@kompetensum.com> | 
|  | 8 | * | 
| Paul Bakker | 66d5d07 | 2014-06-17 16:39:18 +0200 | [diff] [blame] | 9 | *  Copyright (C) 2006-2014, Brainspark B.V. | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 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 |  | 
| Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 37 | #if !defined(POLARSSL_CONFIG_FILE) | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 38 | #include "polarssl/config.h" | 
| Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 39 | #else | 
|  | 40 | #include POLARSSL_CONFIG_FILE | 
|  | 41 | #endif | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 42 |  | 
|  | 43 | #if defined(POLARSSL_PBKDF2_C) | 
|  | 44 |  | 
|  | 45 | #include "polarssl/pbkdf2.h" | 
| Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 46 | #include "polarssl/pkcs5.h" | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 47 |  | 
|  | 48 | int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password, size_t plen, | 
|  | 49 | const unsigned char *salt, size_t slen, | 
|  | 50 | unsigned int iteration_count, | 
| Paul Bakker | 5c2364c | 2012-10-01 14:41:15 +0000 | [diff] [blame] | 51 | uint32_t key_length, unsigned char *output ) | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 52 | { | 
| Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 53 | return pkcs5_pbkdf2_hmac( ctx, password, plen, salt, slen, iteration_count, | 
|  | 54 | key_length, output ); | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 55 | } | 
|  | 56 |  | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 57 | #if defined(POLARSSL_SELF_TEST) | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 58 | int pbkdf2_self_test( int verbose ) | 
|  | 59 | { | 
| Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 60 | return pkcs5_self_test( verbose ); | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 61 | } | 
| Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 62 | #endif /* POLARSSL_SELF_TEST */ | 
|  | 63 |  | 
|  | 64 | #endif /* POLARSSL_PBKDF2_C */ |