blob: 5530b586e23f46f619fce299a54f7698ea57bdb4 [file] [log] [blame]
Paul Bakkerb0c19a42013-06-24 19:26:38 +02001/**
2 * \file pkcs#5.h
3 *
4 * \brief PKCS#5 functions
5 *
6 * \author Mathias Olsson <mathias@kompetensum.com>
7 *
8 * Copyright (C) 2006-2013, Brainspark B.V.
9 *
10 * This file is part of PolarSSL (http://www.polarssl.org)
11 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
12 *
13 * All rights reserved.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 */
29#ifndef POLARSSL_PKCS5_H
30#define POLARSSL_PKCS5_H
31
32#include <string.h>
33
34#include "md.h"
35
36#ifdef _MSC_VER
37#include <basetsd.h>
38typedef UINT32 uint32_t;
39#else
40#include <inttypes.h>
41#endif
42
43#define POLARSSL_ERR_PKCS5_BAD_INPUT_DATA -0x007C /**< Bad input parameters to function. */
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/**
50 * \brief PKCS#5 PBKDF2 using HMAC
51 *
52 * \param ctx Generic HMAC context
53 * \param password Password to use when generating key
54 * \param plen Length of password
55 * \param salt Salt to use when generating key
56 * \param slen Length of salt
57 * \param iteration_count Iteration count
58 * \param key_length Length of generated key
59 * \param output Generated key. Must be at least as big as key_length
60 *
61 * \returns 0 on success, or a PolarSSL error code if verification fails.
62 */
63int pkcs5_pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
64 size_t plen, const unsigned char *salt, size_t slen,
65 unsigned int iteration_count,
66 uint32_t key_length, unsigned char *output );
67
68/**
69 * \brief Checkup routine
70 *
71 * \return 0 if successful, or 1 if the test failed
72 */
73int pkcs5_self_test( int verbose );
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif /* pkcs5.h */