Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /**
  2.  * \file pbkdf2.h
  3.  *
  4.  * \brief Password-Based Key Derivation Function 2 (from PKCS#5)
  5.  *
  6.  * \author Mathias Olsson <mathias@kompetensum.com>
  7.  *
  8.  *  Copyright (C) 2006-2012, 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_PBKDF2_H
  30. #define POLARSSL_PBKDF2_H
  31.  
  32. #include <string.h>
  33.  
  34. #include "md.h"
  35.  
  36. #ifdef _MSC_VER
  37. #include <basetsd.h>
  38. typedef UINT32 uint32_t;
  39. #else
  40. #include <inttypes.h>
  41. #endif
  42.  
  43. #define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA                 -0x007C  /**< Bad input parameters to function. */
  44.  
  45. #ifdef __cplusplus
  46. extern "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.  */
  63. int 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. /**
  70.  * \brief          Checkup routine
  71.  *
  72.  * \return         0 if successful, or 1 if the test failed
  73.  */
  74. int pbkdf2_self_test( int verbose );
  75.  
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79.  
  80. #endif /* pbkdf2.h */
  81.