1 /*******************************************************************************
2 
3     D language bindings for libsodium's crypto_generichash.h
4 
5     License: ISC (see LICENSE.txt)
6 
7 *******************************************************************************/
8 
9 module libsodium.crypto_generichash;
10 
11 @nogc nothrow:
12 
13 import libsodium.export_;
14 import libsodium.crypto_generichash_blake2b;
15 
16 extern (C):
17 
18 enum crypto_generichash_BYTES_MIN = crypto_generichash_blake2b_BYTES_MIN;
19 size_t crypto_generichash_bytes_min ();
20 
21 enum crypto_generichash_BYTES_MAX = crypto_generichash_blake2b_BYTES_MAX;
22 size_t crypto_generichash_bytes_max ();
23 
24 enum crypto_generichash_BYTES = crypto_generichash_blake2b_BYTES;
25 size_t crypto_generichash_bytes ();
26 
27 enum crypto_generichash_KEYBYTES_MIN = crypto_generichash_blake2b_KEYBYTES_MIN;
28 size_t crypto_generichash_keybytes_min ();
29 
30 enum crypto_generichash_KEYBYTES_MAX = crypto_generichash_blake2b_KEYBYTES_MAX;
31 size_t crypto_generichash_keybytes_max ();
32 
33 enum crypto_generichash_KEYBYTES = crypto_generichash_blake2b_KEYBYTES;
34 size_t crypto_generichash_keybytes ();
35 
36 enum crypto_generichash_PRIMITIVE = "blake2b";
37 const(char)* crypto_generichash_primitive ();
38 
39 /*
40  * Important when writing bindings for other programming languages:
41  * the state address should be 64-bytes aligned.
42  */
43 alias crypto_generichash_state = crypto_generichash_blake2b_state;
44 
45 size_t crypto_generichash_statebytes ();
46 
47 int crypto_generichash (
48     ubyte* out_,
49     size_t outlen,
50     const(ubyte)* in_,
51     ulong inlen,
52     const(ubyte)* key,
53     size_t keylen);
54 
55 int crypto_generichash_init (
56     crypto_generichash_state* state,
57     const(ubyte)* key,
58     const size_t keylen,
59     const size_t outlen);
60 
61 int crypto_generichash_update (
62     crypto_generichash_state* state,
63     const(ubyte)* in_,
64     ulong inlen);
65 
66 int crypto_generichash_final (
67     crypto_generichash_state* state,
68     ubyte* out_,
69     const size_t outlen);
70 
71 void crypto_generichash_keygen (ref ubyte[crypto_generichash_KEYBYTES] k);