pbkdf2.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * cifra - embedded cryptography library
  3. * Written in 2014 by Joseph Birr-Pixton <jpixton@gmail.com>
  4. *
  5. * To the extent possible under law, the author(s) have dedicated all
  6. * copyright and related and neighboring rights to this software to the
  7. * public domain worldwide. This software is distributed without any
  8. * warranty.
  9. *
  10. * You should have received a copy of the CC0 Public Domain Dedication
  11. * along with this software. If not, see
  12. * <http://creativecommons.org/publicdomain/zero/1.0/>.
  13. */
  14. #ifndef PBKDF2_H
  15. #define PBKDF2_H
  16. #include <stddef.h>
  17. #include <stdint.h>
  18. #include "chash.h"
  19. /**
  20. * PBKDF2-HMAC
  21. * ===========
  22. * This is PBKDF2 as described by PKCS#5/RFC2898 with HMAC as the PRF.
  23. */
  24. /* .. c:function:: $DECL
  25. * This computes PBKDF2-HMAC with the given hash functon.
  26. *
  27. * :param pw: password input buffer.
  28. * :param npw: password length.
  29. * :param salt: salt input buffer.
  30. * :param nsalt: salt length.
  31. * :param iterations: non-zero iteration count. Tune this for performance/security tradeoff.
  32. * :param out: key material output buffer. `nout` bytes are written here.
  33. * :param nout: key material length.
  34. * :param hash: hash function description.
  35. */
  36. void cf_pbkdf2_hmac(const uint8_t *pw, size_t npw,
  37. const uint8_t *salt, size_t nsalt,
  38. uint32_t iterations,
  39. uint8_t *out, size_t nout,
  40. const cf_chash *hash);
  41. #endif