pbkdf2.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef GMSSL_PBKDF2_H
  10. #define GMSSL_PBKDF2_H
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <stdint.h>
  15. #include <limits.h>
  16. #include <gmssl/hmac.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /*
  21. PBKDF2 Public API
  22. PBKDF2_MIN_ITER
  23. PBKDF2_DEFAULT_SALT_SIZE
  24. PBKDF2_MAX_SALT_SIZE
  25. pbkdf2_hmac_sm3_genkey
  26. */
  27. #define PBKDF2_MIN_ITER 10000
  28. #define PBKDF2_MAX_ITER (INT_MAX)
  29. #define PBKDF2_MAX_SALT_SIZE 64
  30. #define PBKDF2_DEFAULT_SALT_SIZE 8
  31. int pbkdf2_genkey(const DIGEST *digest,
  32. const char *pass, size_t passlen, const uint8_t *salt, size_t saltlen, size_t iter,
  33. size_t outlen, uint8_t *out);
  34. int pbkdf2_hmac_sm3_genkey(
  35. const char *pass, size_t passlen, const uint8_t *salt, size_t saltlen, size_t iter,
  36. size_t outlen, uint8_t *out);
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. #endif