1 #ifndef crypto_pwhash_H 2 #define crypto_pwhash_H 3 4 #include <stddef.h> 5 6 #include "crypto_pwhash_argon2i.h" 7 #include "crypto_pwhash_argon2id.h" 8 #include "export.h" 9 10 #ifdef __cplusplus 11 # ifdef __GNUC__ 12 # pragma GCC diagnostic ignored "-Wlong-long" 13 # endif 14 extern "C" { 15 #endif 16 17 #define crypto_pwhash_ALG_ARGON2I13 crypto_pwhash_argon2i_ALG_ARGON2I13 18 SODIUM_EXPORT 19 int crypto_pwhash_alg_argon2i13(void); 20 21 #define crypto_pwhash_ALG_ARGON2ID13 crypto_pwhash_argon2id_ALG_ARGON2ID13 22 SODIUM_EXPORT 23 int crypto_pwhash_alg_argon2id13(void); 24 25 #define crypto_pwhash_ALG_DEFAULT crypto_pwhash_ALG_ARGON2ID13 26 SODIUM_EXPORT 27 int crypto_pwhash_alg_default(void); 28 29 #define crypto_pwhash_BYTES_MIN crypto_pwhash_argon2id_BYTES_MIN 30 SODIUM_EXPORT 31 size_t crypto_pwhash_bytes_min(void); 32 33 #define crypto_pwhash_BYTES_MAX crypto_pwhash_argon2id_BYTES_MAX 34 SODIUM_EXPORT 35 size_t crypto_pwhash_bytes_max(void); 36 37 #define crypto_pwhash_PASSWD_MIN crypto_pwhash_argon2id_PASSWD_MIN 38 SODIUM_EXPORT 39 size_t crypto_pwhash_passwd_min(void); 40 41 #define crypto_pwhash_PASSWD_MAX crypto_pwhash_argon2id_PASSWD_MAX 42 SODIUM_EXPORT 43 size_t crypto_pwhash_passwd_max(void); 44 45 #define crypto_pwhash_SALTBYTES crypto_pwhash_argon2id_SALTBYTES 46 SODIUM_EXPORT 47 size_t crypto_pwhash_saltbytes(void); 48 49 #define crypto_pwhash_STRBYTES crypto_pwhash_argon2id_STRBYTES 50 SODIUM_EXPORT 51 size_t crypto_pwhash_strbytes(void); 52 53 #define crypto_pwhash_STRPREFIX crypto_pwhash_argon2id_STRPREFIX 54 SODIUM_EXPORT 55 const char *crypto_pwhash_strprefix(void); 56 57 #define crypto_pwhash_OPSLIMIT_MIN crypto_pwhash_argon2id_OPSLIMIT_MIN 58 SODIUM_EXPORT 59 size_t crypto_pwhash_opslimit_min(void); 60 61 #define crypto_pwhash_OPSLIMIT_MAX crypto_pwhash_argon2id_OPSLIMIT_MAX 62 SODIUM_EXPORT 63 size_t crypto_pwhash_opslimit_max(void); 64 65 #define crypto_pwhash_MEMLIMIT_MIN crypto_pwhash_argon2id_MEMLIMIT_MIN 66 SODIUM_EXPORT 67 size_t crypto_pwhash_memlimit_min(void); 68 69 #define crypto_pwhash_MEMLIMIT_MAX crypto_pwhash_argon2id_MEMLIMIT_MAX 70 SODIUM_EXPORT 71 size_t crypto_pwhash_memlimit_max(void); 72 73 #define crypto_pwhash_OPSLIMIT_INTERACTIVE crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE 74 SODIUM_EXPORT 75 size_t crypto_pwhash_opslimit_interactive(void); 76 77 #define crypto_pwhash_MEMLIMIT_INTERACTIVE crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE 78 SODIUM_EXPORT 79 size_t crypto_pwhash_memlimit_interactive(void); 80 81 #define crypto_pwhash_OPSLIMIT_MODERATE crypto_pwhash_argon2id_OPSLIMIT_MODERATE 82 SODIUM_EXPORT 83 size_t crypto_pwhash_opslimit_moderate(void); 84 85 #define crypto_pwhash_MEMLIMIT_MODERATE crypto_pwhash_argon2id_MEMLIMIT_MODERATE 86 SODIUM_EXPORT 87 size_t crypto_pwhash_memlimit_moderate(void); 88 89 #define crypto_pwhash_OPSLIMIT_SENSITIVE crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE 90 SODIUM_EXPORT 91 size_t crypto_pwhash_opslimit_sensitive(void); 92 93 #define crypto_pwhash_MEMLIMIT_SENSITIVE crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE 94 SODIUM_EXPORT 95 size_t crypto_pwhash_memlimit_sensitive(void); 96 97 /* 98 * With this function, do not forget to store all parameters, including the 99 * algorithm identifier in order to produce deterministic output. 100 * The crypto_pwhash_* definitions, including crypto_pwhash_ALG_DEFAULT, 101 * may change. 102 */ 103 SODIUM_EXPORT 104 int crypto_pwhash(unsigned char * const out, unsigned long long outlen, 105 const char * const passwd, unsigned long long passwdlen, 106 const unsigned char * const salt, 107 unsigned long long opslimit, size_t memlimit, int alg) 108 __attribute__ ((warn_unused_result)); 109 110 /* 111 * The output string already includes all the required parameters, including 112 * the algorithm identifier. The string is all that has to be stored in 113 * order to verify a password. 114 */ 115 SODIUM_EXPORT 116 int crypto_pwhash_str(char out[crypto_pwhash_STRBYTES], 117 const char * const passwd, unsigned long long passwdlen, 118 unsigned long long opslimit, size_t memlimit) 119 __attribute__ ((warn_unused_result)); 120 121 SODIUM_EXPORT 122 int crypto_pwhash_str_alg(char out[crypto_pwhash_STRBYTES], 123 const char * const passwd, unsigned long long passwdlen, 124 unsigned long long opslimit, size_t memlimit, int alg) 125 __attribute__ ((warn_unused_result)); 126 127 SODIUM_EXPORT 128 int crypto_pwhash_str_verify(const char str[crypto_pwhash_STRBYTES], 129 const char * const passwd, 130 unsigned long long passwdlen) 131 __attribute__ ((warn_unused_result)); 132 133 SODIUM_EXPORT 134 int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES], 135 unsigned long long opslimit, size_t memlimit) 136 __attribute__ ((warn_unused_result)); 137 138 #define crypto_pwhash_PRIMITIVE "argon2i" 139 SODIUM_EXPORT 140 const char *crypto_pwhash_primitive(void) 141 __attribute__ ((warn_unused_result)); 142 143 #ifdef __cplusplus 144 } 145 #endif 146 147 #endif 148