• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the License); you may
5  *  not use this file except in compliance with the License.
6  *
7  *  http://www.apache.org/licenses/LICENSE-2.0
8  */
9 
10 
11 #ifndef GMSSL_PBKDF2_H
12 #define GMSSL_PBKDF2_H
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <stdint.h>
18 #include <limits.h>
19 #include <gmssl/hmac.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /*
26 PBKDF2 Public API
27 
28 	PBKDF2_MIN_ITER
29 	PBKDF2_DEFAULT_SALT_SIZE
30 	PBKDF2_MAX_SALT_SIZE
31 
32 	pbkdf2_hmac_sm3_genkey
33 */
34 
35 
36 #define PBKDF2_MIN_ITER			10000
37 #define PBKDF2_MAX_ITER			(INT_MAX)
38 #define PBKDF2_MAX_SALT_SIZE		64
39 #define PBKDF2_DEFAULT_SALT_SIZE	8
40 
41 
42 int pbkdf2_genkey(const DIGEST *digest,
43 	const char *pass, size_t passlen, const uint8_t *salt, size_t saltlen, size_t iter,
44 	size_t outlen, uint8_t *out);
45 
46 int pbkdf2_hmac_sm3_genkey(
47 	const char *pass, size_t passlen, const uint8_t *salt, size_t saltlen, size_t iter,
48 	size_t outlen, uint8_t *out);
49 
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 #endif
55