1 /*******************************************************************************
2 
3     D language bindings for libsodium's crypto_pwhash_scryptsalsa208sha256.h
4 
5     License: ISC (see LICENSE.txt)
6 
7 *******************************************************************************/
8 
9 module libsodium.crypto_pwhash_scryptsalsa208sha256;
10 
11 @nogc nothrow:
12 
13 import libsodium.export_;
14 import core.stdc.stdint;
15 
16 extern (C):
17 
18 enum crypto_pwhash_scryptsalsa208sha256_BYTES_MIN = 16U;
19 size_t crypto_pwhash_scryptsalsa208sha256_bytes_min ();
20 
21 enum crypto_pwhash_scryptsalsa208sha256_BYTES_MAX = SODIUM_MIN(SODIUM_SIZE_MAX, 0x1fffffffe0UL);
22 size_t crypto_pwhash_scryptsalsa208sha256_bytes_max ();
23 
24 enum crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN = 0U;
25 size_t crypto_pwhash_scryptsalsa208sha256_passwd_min ();
26 
27 enum crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX = SODIUM_SIZE_MAX;
28 size_t crypto_pwhash_scryptsalsa208sha256_passwd_max ();
29 
30 enum crypto_pwhash_scryptsalsa208sha256_SALTBYTES = 32U;
31 size_t crypto_pwhash_scryptsalsa208sha256_saltbytes ();
32 
33 enum crypto_pwhash_scryptsalsa208sha256_STRBYTES = 102U;
34 size_t crypto_pwhash_scryptsalsa208sha256_strbytes ();
35 
36 enum crypto_pwhash_scryptsalsa208sha256_STRPREFIX = "$7$";
37 const(char)* crypto_pwhash_scryptsalsa208sha256_strprefix ();
38 
39 enum crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN = 32768U;
40 size_t crypto_pwhash_scryptsalsa208sha256_opslimit_min ();
41 
42 enum crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX = 4294967295U;
43 size_t crypto_pwhash_scryptsalsa208sha256_opslimit_max ();
44 
45 enum crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN = 16777216U;
46 size_t crypto_pwhash_scryptsalsa208sha256_memlimit_min ();
47 
48 enum crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX = SODIUM_MIN(SIZE_MAX, 68719476736UL);
49 size_t crypto_pwhash_scryptsalsa208sha256_memlimit_max ();
50 
51 enum crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE = 524288U;
52 size_t crypto_pwhash_scryptsalsa208sha256_opslimit_interactive ();
53 
54 enum crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE = 16777216U;
55 size_t crypto_pwhash_scryptsalsa208sha256_memlimit_interactive ();
56 
57 enum crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE = 33554432U;
58 size_t crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive ();
59 
60 enum crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE = 1073741824U;
61 size_t crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive ();
62 
63 int crypto_pwhash_scryptsalsa208sha256 (
64     ubyte* out_,
65     ulong outlen,
66     const char* passwd,
67     ulong passwdlen,
68     const ubyte* salt,
69     ulong opslimit,
70     size_t memlimit);
71 
72 int crypto_pwhash_scryptsalsa208sha256_str (
73     ref char[crypto_pwhash_scryptsalsa208sha256_STRBYTES] out_,
74     const char* passwd,
75     ulong passwdlen,
76     ulong opslimit,
77     size_t memlimit);
78 
79 int crypto_pwhash_scryptsalsa208sha256_str_verify (
80     ref const(char)[crypto_pwhash_scryptsalsa208sha256_STRBYTES] str,
81     const char* passwd,
82     ulong passwdlen);
83 
84 int crypto_pwhash_scryptsalsa208sha256_ll (
85     const(ubyte)* passwd,
86     size_t passwdlen,
87     const(ubyte)* salt,
88     size_t saltlen,
89     ulong N,
90     uint r,
91     uint p,
92     ubyte* buf,
93     size_t buflen);
94 
95 int crypto_pwhash_scryptsalsa208sha256_str_needs_rehash (
96     ref const(char)[crypto_pwhash_scryptsalsa208sha256_STRBYTES] str,
97     ulong opslimit,
98     size_t memlimit);