Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file pbkdf2.h |
| 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.h instead. |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 6 | * |
| 7 | * \author Mathias Olsson <mathias@kompetensum.com> |
| 8 | * |
Manuel Pégourié-Gonnard | a658a40 | 2015-01-23 09:45:19 +0000 | [diff] [blame] | 9 | * Copyright (C) 2006-2012, ARM Limited, All Rights Reserved |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 10 | * |
Manuel Pégourié-Gonnard | fe44643 | 2015-03-06 13:17:10 +0000 | [diff] [blame^] | 11 | * This file is part of mbed TLS (https://tls.mbed.org) |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 12 | * |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 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 | #ifndef POLARSSL_PBKDF2_H |
| 28 | #define POLARSSL_PBKDF2_H |
| 29 | |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 30 | #include "md.h" |
| 31 | |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 32 | #include <stddef.h> |
| 33 | |
Paul Bakker | fa6a620 | 2013-10-28 18:48:30 +0100 | [diff] [blame] | 34 | #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32) |
Paul Bakker | 5c2364c | 2012-10-01 14:41:15 +0000 | [diff] [blame] | 35 | #include <basetsd.h> |
| 36 | typedef UINT32 uint32_t; |
| 37 | #else |
| 38 | #include <inttypes.h> |
| 39 | #endif |
| 40 | |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 41 | #define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA -0x007C /**< Bad input parameters to function. */ |
| 42 | |
| 43 | #ifdef __cplusplus |
| 44 | extern "C" { |
| 45 | #endif |
| 46 | |
| 47 | /** |
| 48 | * \brief PKCS#5 PBKDF2 using HMAC |
Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 49 | * DEPRECATED: Use pkcs5_pbkdf2_hmac() instead! |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 50 | * |
| 51 | * \param ctx Generic HMAC context |
| 52 | * \param password Password to use when generating key |
| 53 | * \param plen Length of password |
| 54 | * \param salt Salt to use when generating key |
| 55 | * \param slen Length of salt |
| 56 | * \param iteration_count Iteration count |
| 57 | * \param key_length Length of generated key |
| 58 | * \param output Generated key. Must be at least as big as key_length |
| 59 | * |
Manuel Pégourié-Gonnard | b4fe3cb | 2015-01-22 16:11:05 +0000 | [diff] [blame] | 60 | * \returns 0 on success, or a POLARSSL_ERR_xxx code if verification fails. |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 61 | */ |
| 62 | int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password, |
| 63 | size_t plen, const unsigned char *salt, size_t slen, |
| 64 | unsigned int iteration_count, |
Paul Bakker | 5c2364c | 2012-10-01 14:41:15 +0000 | [diff] [blame] | 65 | uint32_t key_length, unsigned char *output ); |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 66 | |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 67 | /** |
| 68 | * \brief Checkup routine |
Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 69 | * DEPRECATED: Use pkcs5_self_test() instead! |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 70 | * |
| 71 | * \return 0 if successful, or 1 if the test failed |
| 72 | */ |
| 73 | int pbkdf2_self_test( int verbose ); |
| 74 | |
| 75 | #ifdef __cplusplus |
| 76 | } |
| 77 | #endif |
| 78 | |
| 79 | #endif /* pbkdf2.h */ |