Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:15

0001 /* pbkdf2.h
0002 
0003    PKCS #5 password-based key derivation function PBKDF2, see RFC 2898.
0004 
0005    Copyright (C) 2012 Simon Josefsson
0006 
0007    This file is part of GNU Nettle.
0008 
0009    GNU Nettle is free software: you can redistribute it and/or
0010    modify it under the terms of either:
0011 
0012      * the GNU Lesser General Public License as published by the Free
0013        Software Foundation; either version 3 of the License, or (at your
0014        option) any later version.
0015 
0016    or
0017 
0018      * the GNU General Public License as published by the Free
0019        Software Foundation; either version 2 of the License, or (at your
0020        option) any later version.
0021 
0022    or both in parallel, as here.
0023 
0024    GNU Nettle is distributed in the hope that it will be useful,
0025    but WITHOUT ANY WARRANTY; without even the implied warranty of
0026    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0027    General Public License for more details.
0028 
0029    You should have received copies of the GNU General Public License and
0030    the GNU Lesser General Public License along with this program.  If
0031    not, see http://www.gnu.org/licenses/.
0032 */
0033 
0034 #ifndef NETTLE_PBKDF2_H_INCLUDED
0035 #define NETTLE_PBKDF2_H_INCLUDED
0036 
0037 #include "nettle-meta.h"
0038 
0039 #ifdef __cplusplus
0040 extern "C"
0041 {
0042 #endif
0043 
0044 /* Namespace mangling */
0045 #define pbkdf2 nettle_pbkdf2
0046 #define pbkdf2_hmac_sha1 nettle_pbkdf2_hmac_sha1
0047 #define pbkdf2_hmac_sha256 nettle_pbkdf2_hmac_sha256
0048 #define pbkdf2_hmac_sha384 nettle_pbkdf2_hmac_sha384
0049 #define pbkdf2_hmac_sha512 nettle_pbkdf2_hmac_sha512
0050 #define pbkdf2_hmac_gosthash94cp nettle_pbkdf2_hmac_gosthash94cp
0051 
0052 void
0053 pbkdf2 (void *mac_ctx,
0054     nettle_hash_update_func *update,
0055     nettle_hash_digest_func *digest,
0056     size_t digest_size, unsigned iterations,
0057     size_t salt_length, const uint8_t *salt,
0058     size_t length, uint8_t *dst);
0059 
0060 #define PBKDF2(ctx, update, digest, digest_size,            \
0061            iterations, salt_length, salt, length, dst)      \
0062   (0 ? ((update)((ctx), 0, (uint8_t *) 0),              \
0063     (digest)((ctx), 0, (uint8_t *) 0))              \
0064    : pbkdf2 ((ctx),                         \
0065          (nettle_hash_update_func *)(update),           \
0066          (nettle_hash_digest_func *)(digest),           \
0067          (digest_size), (iterations),               \
0068          (salt_length), (salt), (length), (dst)))
0069 
0070 /* PBKDF2 with specific PRFs. */
0071 
0072 void
0073 pbkdf2_hmac_sha1 (size_t key_length, const uint8_t *key,
0074           unsigned iterations,
0075           size_t salt_length, const uint8_t *salt,
0076           size_t length, uint8_t *dst);
0077 
0078 void
0079 pbkdf2_hmac_sha256 (size_t key_length, const uint8_t *key,
0080             unsigned iterations,
0081             size_t salt_length, const uint8_t *salt,
0082             size_t length, uint8_t *dst);
0083 
0084 void
0085 pbkdf2_hmac_sha384 (size_t key_length, const uint8_t *key,
0086             unsigned iterations,
0087             size_t salt_length, const uint8_t *salt,
0088             size_t length, uint8_t *dst);
0089 
0090 void
0091 pbkdf2_hmac_sha512 (size_t key_length, const uint8_t *key,
0092             unsigned iterations,
0093             size_t salt_length, const uint8_t *salt,
0094             size_t length, uint8_t *dst);
0095 
0096 void
0097 pbkdf2_hmac_gosthash94cp (size_t key_length, const uint8_t *key,
0098               unsigned iterations,
0099               size_t salt_length, const uint8_t *salt,
0100               size_t length, uint8_t *dst);
0101 
0102 #ifdef __cplusplus
0103 }
0104 #endif
0105 
0106 #endif /* NETTLE_PBKDF2_H_INCLUDED */