/src/nettle-with-mini-gmp/pbkdf2-hmac-sha512.c
Line | Count | Source |
1 | | /* pbkdf2-hmac-sha512.c |
2 | | |
3 | | Copyright (C) 2012 Simon Josefsson |
4 | | Copyright (C) 2021 Nicolas Mora |
5 | | |
6 | | This file is part of GNU Nettle. |
7 | | |
8 | | GNU Nettle is free software: you can redistribute it and/or |
9 | | modify it under the terms of either: |
10 | | |
11 | | * the GNU Lesser General Public License as published by the Free |
12 | | Software Foundation; either version 3 of the License, or (at your |
13 | | option) any later version. |
14 | | |
15 | | or |
16 | | |
17 | | * the GNU General Public License as published by the Free |
18 | | Software Foundation; either version 2 of the License, or (at your |
19 | | option) any later version. |
20 | | |
21 | | or both in parallel, as here. |
22 | | |
23 | | GNU Nettle is distributed in the hope that it will be useful, |
24 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
26 | | General Public License for more details. |
27 | | |
28 | | You should have received copies of the GNU General Public License and |
29 | | the GNU Lesser General Public License along with this program. If |
30 | | not, see http://www.gnu.org/licenses/. |
31 | | */ |
32 | | |
33 | | #if HAVE_CONFIG_H |
34 | | # include "config.h" |
35 | | #endif |
36 | | |
37 | | #include "pbkdf2.h" |
38 | | |
39 | | #include "hmac.h" |
40 | | |
41 | | void |
42 | | pbkdf2_hmac_sha512 (size_t key_length, const uint8_t *key, |
43 | | unsigned iterations, |
44 | | size_t salt_length, const uint8_t *salt, |
45 | | size_t length, uint8_t *dst) |
46 | 19 | { |
47 | 19 | struct hmac_sha512_ctx sha512ctx; |
48 | | |
49 | 19 | hmac_sha512_set_key (&sha512ctx, key_length, key); |
50 | 19 | PBKDF2 (&sha512ctx, hmac_sha512_update, hmac_sha512_digest, |
51 | 19 | SHA512_DIGEST_SIZE, iterations, salt_length, salt, length, dst); |
52 | 19 | } |