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 | 19bd297 | 2013-06-14 12:06:45 +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 | 530927b | 2015-02-13 14:24:10 +0100 | [diff] [blame] | 9 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 10 | * |
Manuel Pégourié-Gonnard | e12abf9 | 2015-01-28 17:13:45 +0000 | [diff] [blame] | 11 | * This file is part of mbed TLS (https://polarssl.org) |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 12 | * |
| 13 | * 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 | |
| 34 | #include "polarssl/config.h" |
| 35 | |
| 36 | #if defined(POLARSSL_PBKDF2_C) |
| 37 | |
| 38 | #include "polarssl/pbkdf2.h" |
Paul Bakker | 19bd297 | 2013-06-14 12:06:45 +0200 | [diff] [blame] | 39 | #include "polarssl/pkcs5.h" |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 40 | |
| 41 | int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password, size_t plen, |
| 42 | const unsigned char *salt, size_t slen, |
| 43 | unsigned int iteration_count, |
Paul Bakker | 5c2364c | 2012-10-01 14:41:15 +0000 | [diff] [blame] | 44 | uint32_t key_length, unsigned char *output ) |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 45 | { |
Paul Bakker | 19bd297 | 2013-06-14 12:06:45 +0200 | [diff] [blame] | 46 | return pkcs5_pbkdf2_hmac( ctx, password, plen, salt, slen, iteration_count, |
| 47 | key_length, output ); |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 50 | #if defined(POLARSSL_SELF_TEST) |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 51 | int pbkdf2_self_test( int verbose ) |
| 52 | { |
Paul Bakker | 19bd297 | 2013-06-14 12:06:45 +0200 | [diff] [blame] | 53 | return pkcs5_self_test( verbose ); |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 54 | } |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 55 | #endif /* POLARSSL_SELF_TEST */ |
| 56 | |
| 57 | #endif /* POLARSSL_PBKDF2_C */ |