1/* pbkdf2.h
2
3 PKCS #5 password-based key derivation function PBKDF2, see RFC 2898.
4
5 Copyright (C) 2012 Simon Josefsson
6
7 This file is part of GNU Nettle.
8
9 GNU Nettle is free software: you can redistribute it and/or
10 modify it under the terms of either:
11
12 * the GNU Lesser General Public License as published by the Free
13 Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
15
16 or
17
18 * the GNU General Public License as published by the Free
19 Software Foundation; either version 2 of the License, or (at your
20 option) any later version.
21
22 or both in parallel, as here.
23
24 GNU Nettle is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 General Public License for more details.
28
29 You should have received copies of the GNU General Public License and
30 the GNU Lesser General Public License along with this program. If
31 not, see http://www.gnu.org/licenses/.
32*/
33
34#ifndef NETTLE_PBKDF2_H_INCLUDED
35#define NETTLE_PBKDF2_H_INCLUDED
36
37#include "nettle-meta.h"
38
39#ifdef __cplusplus
40extern "C"
41{
42#endif
43
44/* Namespace mangling */
45#define pbkdf2 nettle_pbkdf2
46#define pbkdf2_hmac_sha1 nettle_pbkdf2_hmac_sha1
47#define pbkdf2_hmac_sha256 nettle_pbkdf2_hmac_sha256
48
49void
50pbkdf2 (void *mac_ctx,
51 nettle_hash_update_func *update,
52 nettle_hash_digest_func *digest,
53 size_t digest_size, unsigned iterations,
54 size_t salt_length, const uint8_t *salt,
55 size_t length, uint8_t *dst);
56
57#define PBKDF2(ctx, update, digest, digest_size, \
58 iterations, salt_length, salt, length, dst) \
59 (0 ? ((update)((ctx), 0, (uint8_t *) 0), \
60 (digest)((ctx), 0, (uint8_t *) 0)) \
61 : pbkdf2 ((ctx), \
62 (nettle_hash_update_func *)(update), \
63 (nettle_hash_digest_func *)(digest), \
64 (digest_size), (iterations), \
65 (salt_length), (salt), (length), (dst)))
66
67/* PBKDF2 with specific PRFs. */
68
69void
70pbkdf2_hmac_sha1 (size_t key_length, const uint8_t *key,
71 unsigned iterations,
72 size_t salt_length, const uint8_t *salt,
73 size_t length, uint8_t *dst);
74
75void
76pbkdf2_hmac_sha256 (size_t key_length, const uint8_t *key,
77 unsigned iterations,
78 size_t salt_length, const uint8_t *salt,
79 size_t length, uint8_t *dst);
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif /* NETTLE_PBKDF2_H_INCLUDED */
86