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