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) |
Manuel Pégourié-Gonnard | 7143284 | 2015-03-20 16:19:35 +0000 | [diff] [blame] | 5 | * |
| 6 | * \deprecated Use pkcs5.h instead. |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 7 | * |
| 8 | * \author Mathias Olsson <mathias@kompetensum.com> |
| 9 | * |
Manuel Pégourié-Gonnard | a658a40 | 2015-01-23 09:45:19 +0000 | [diff] [blame] | 10 | * Copyright (C) 2006-2012, ARM Limited, All Rights Reserved |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 11 | * |
Manuel Pégourié-Gonnard | fe44643 | 2015-03-06 13:17:10 +0000 | [diff] [blame] | 12 | * This file is part of mbed TLS (https://tls.mbed.org) |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 13 | * |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License along |
| 25 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 26 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 27 | */ |
| 28 | #ifndef POLARSSL_PBKDF2_H |
| 29 | #define POLARSSL_PBKDF2_H |
| 30 | |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 31 | #include "md.h" |
| 32 | |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 33 | #include <stddef.h> |
| 34 | |
Paul Bakker | fa6a620 | 2013-10-28 18:48:30 +0100 | [diff] [blame] | 35 | #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32) |
Paul Bakker | 5c2364c | 2012-10-01 14:41:15 +0000 | [diff] [blame] | 36 | #include <basetsd.h> |
| 37 | typedef UINT32 uint32_t; |
| 38 | #else |
| 39 | #include <inttypes.h> |
| 40 | #endif |
| 41 | |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 42 | #define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA -0x007C /**< Bad input parameters to function. */ |
| 43 | |
| 44 | #ifdef __cplusplus |
| 45 | extern "C" { |
| 46 | #endif |
| 47 | |
Manuel Pégourié-Gonnard | c70581c | 2015-03-23 13:58:27 +0100 | [diff] [blame^] | 48 | #if ! defined(POLARSSL_DEPRECATED_REMOVED) |
| 49 | #if defined(POLARSSL_DEPRECATED_WARNING) |
| 50 | #define DEPRECATED __attribute__((deprecated)) |
| 51 | #else |
| 52 | #define DEPRECATED |
| 53 | #endif |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 54 | /** |
| 55 | * \brief PKCS#5 PBKDF2 using HMAC |
Manuel Pégourié-Gonnard | 7143284 | 2015-03-20 16:19:35 +0000 | [diff] [blame] | 56 | * |
| 57 | * \deprecated Use pkcs5_pbkdf2_hmac() instead |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 58 | * |
| 59 | * \param ctx Generic HMAC context |
| 60 | * \param password Password to use when generating key |
| 61 | * \param plen Length of password |
| 62 | * \param salt Salt to use when generating key |
| 63 | * \param slen Length of salt |
| 64 | * \param iteration_count Iteration count |
| 65 | * \param key_length Length of generated key |
| 66 | * \param output Generated key. Must be at least as big as key_length |
| 67 | * |
Manuel Pégourié-Gonnard | b4fe3cb | 2015-01-22 16:11:05 +0000 | [diff] [blame] | 68 | * \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] | 69 | */ |
| 70 | int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password, |
| 71 | size_t plen, const unsigned char *salt, size_t slen, |
| 72 | unsigned int iteration_count, |
Manuel Pégourié-Gonnard | c70581c | 2015-03-23 13:58:27 +0100 | [diff] [blame^] | 73 | uint32_t key_length, unsigned char *output ) DEPRECATED; |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 74 | |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 75 | /** |
| 76 | * \brief Checkup routine |
Manuel Pégourié-Gonnard | 7143284 | 2015-03-20 16:19:35 +0000 | [diff] [blame] | 77 | * |
| 78 | * \deprecated Use pkcs5_self_test() instead |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 79 | * |
| 80 | * \return 0 if successful, or 1 if the test failed |
| 81 | */ |
Manuel Pégourié-Gonnard | c70581c | 2015-03-23 13:58:27 +0100 | [diff] [blame^] | 82 | int pbkdf2_self_test( int verbose ) DEPRECATED; |
| 83 | #undef DEPRECATED |
| 84 | #endif /* POLARSSL_DEPRECATED_REMOVED */ |
Paul Bakker | f518b16 | 2012-08-23 13:03:18 +0000 | [diff] [blame] | 85 | |
| 86 | #ifdef __cplusplus |
| 87 | } |
| 88 | #endif |
| 89 | |
| 90 | #endif /* pbkdf2.h */ |