Fix build error and set version 2.7.1
[platform/upstream/nettle.git] / pbkdf2.h
1 /* pbkdf2.h
2  *
3  * PKCS #5 password-based key derivation function PBKDF2, see RFC 2898.
4  */
5
6 /* nettle, low-level cryptographics library
7  *
8  * Copyright (C) 2012 Simon Josefsson
9  *
10  * The nettle library is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or (at your
13  * option) any later version.
14  *
15  * The nettle library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with the nettle library; see the file COPYING.LIB.  If not, write to
22  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23  * MA 02111-1301, USA.
24  */
25
26 #ifndef NETTLE_PBKDF2_H_INCLUDED
27 #define NETTLE_PBKDF2_H_INCLUDED
28
29 #include "nettle-meta.h"
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /* Namespace mangling */
37 #define pbkdf2 nettle_pbkdf2
38 #define pbkdf2_hmac_sha1 nettle_pbkdf2_hmac_sha1
39 #define pbkdf2_hmac_sha256 nettle_pbkdf2_hmac_sha256
40
41 void
42 pbkdf2 (void *mac_ctx,
43         nettle_hash_update_func *update,
44         nettle_hash_digest_func *digest,
45         unsigned digest_size, unsigned iterations,
46         unsigned salt_length, const uint8_t *salt,
47         unsigned length, uint8_t *dst);
48
49 #define PBKDF2(ctx, update, digest, digest_size,                        \
50                iterations, salt_length, salt, length, dst)              \
51   (0 ? ((update)((ctx), 0, (uint8_t *) 0),                              \
52         (digest)((ctx), 0, (uint8_t *) 0))                              \
53    : pbkdf2 ((ctx),                                                     \
54              (nettle_hash_update_func *)(update),                       \
55              (nettle_hash_digest_func *)(digest),                       \
56              (digest_size), (iterations),                               \
57              (salt_length), (salt), (length), (dst)))
58
59 /* PBKDF2 with specific PRFs. */
60
61 void
62 pbkdf2_hmac_sha1 (unsigned key_length, const uint8_t *key,
63                   unsigned iterations,
64                   unsigned salt_length, const uint8_t *salt,
65                   unsigned length, uint8_t *dst);
66
67 void
68 pbkdf2_hmac_sha256 (unsigned key_length, const uint8_t *key,
69                     unsigned iterations,
70                     unsigned salt_length, const uint8_t *salt,
71                     unsigned length, uint8_t *dst);
72
73 #ifdef __cplusplus
74 }
75 #endif
76
77 #endif /* NETTLE_PBKDF2_H_INCLUDED */