crypto_pwhash_scryptsalsa208sha256.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef crypto_pwhash_scryptsalsa208sha256_H
  2. #define crypto_pwhash_scryptsalsa208sha256_H
  3. #include <limits.h>
  4. #include <stddef.h>
  5. #include <stdint.h>
  6. #include "export.h"
  7. #ifdef __cplusplus
  8. # ifdef __GNUC__
  9. # pragma GCC diagnostic ignored "-Wlong-long"
  10. # endif
  11. extern "C" {
  12. #endif
  13. #define crypto_pwhash_scryptsalsa208sha256_BYTES_MIN 16U
  14. SODIUM_EXPORT
  15. size_t crypto_pwhash_scryptsalsa208sha256_bytes_min(void);
  16. #define crypto_pwhash_scryptsalsa208sha256_BYTES_MAX \
  17. SODIUM_MIN(SODIUM_SIZE_MAX, 0x1fffffffe0ULL)
  18. SODIUM_EXPORT
  19. size_t crypto_pwhash_scryptsalsa208sha256_bytes_max(void);
  20. #define crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN 0U
  21. SODIUM_EXPORT
  22. size_t crypto_pwhash_scryptsalsa208sha256_passwd_min(void);
  23. #define crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX SODIUM_SIZE_MAX
  24. SODIUM_EXPORT
  25. size_t crypto_pwhash_scryptsalsa208sha256_passwd_max(void);
  26. #define crypto_pwhash_scryptsalsa208sha256_SALTBYTES 32U
  27. SODIUM_EXPORT
  28. size_t crypto_pwhash_scryptsalsa208sha256_saltbytes(void);
  29. #define crypto_pwhash_scryptsalsa208sha256_STRBYTES 102U
  30. SODIUM_EXPORT
  31. size_t crypto_pwhash_scryptsalsa208sha256_strbytes(void);
  32. #define crypto_pwhash_scryptsalsa208sha256_STRPREFIX "$7$"
  33. SODIUM_EXPORT
  34. const char *crypto_pwhash_scryptsalsa208sha256_strprefix(void);
  35. #define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN 32768U
  36. SODIUM_EXPORT
  37. size_t crypto_pwhash_scryptsalsa208sha256_opslimit_min(void);
  38. #define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX 4294967295U
  39. SODIUM_EXPORT
  40. size_t crypto_pwhash_scryptsalsa208sha256_opslimit_max(void);
  41. #define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN 16777216U
  42. SODIUM_EXPORT
  43. size_t crypto_pwhash_scryptsalsa208sha256_memlimit_min(void);
  44. #define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX \
  45. SODIUM_MIN(SIZE_MAX, 68719476736ULL)
  46. SODIUM_EXPORT
  47. size_t crypto_pwhash_scryptsalsa208sha256_memlimit_max(void);
  48. #define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE 524288U
  49. SODIUM_EXPORT
  50. size_t crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(void);
  51. #define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE 16777216U
  52. SODIUM_EXPORT
  53. size_t crypto_pwhash_scryptsalsa208sha256_memlimit_interactive(void);
  54. #define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE 33554432U
  55. SODIUM_EXPORT
  56. size_t crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(void);
  57. #define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE 1073741824U
  58. SODIUM_EXPORT
  59. size_t crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive(void);
  60. SODIUM_EXPORT
  61. int crypto_pwhash_scryptsalsa208sha256(unsigned char * const out,
  62. unsigned long long outlen,
  63. const char * const passwd,
  64. unsigned long long passwdlen,
  65. const unsigned char * const salt,
  66. unsigned long long opslimit,
  67. size_t memlimit)
  68. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  69. SODIUM_EXPORT
  70. int crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
  71. const char * const passwd,
  72. unsigned long long passwdlen,
  73. unsigned long long opslimit,
  74. size_t memlimit)
  75. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  76. SODIUM_EXPORT
  77. int crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
  78. const char * const passwd,
  79. unsigned long long passwdlen)
  80. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  81. SODIUM_EXPORT
  82. int crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen,
  83. const uint8_t * salt, size_t saltlen,
  84. uint64_t N, uint32_t r, uint32_t p,
  85. uint8_t * buf, size_t buflen)
  86. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  87. SODIUM_EXPORT
  88. int crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
  89. unsigned long long opslimit,
  90. size_t memlimit)
  91. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif