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