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_generichash_H 5 */ 6 7 module deimos.sodium.crypto_generichash; 8 9 import deimos.sodium.crypto_generichash_blake2b : crypto_generichash_blake2b_state, 10 crypto_generichash_blake2b_BYTES_MIN, 11 crypto_generichash_blake2b_BYTES_MAX, 12 crypto_generichash_blake2b_BYTES, 13 crypto_generichash_blake2b_KEYBYTES_MIN, 14 crypto_generichash_blake2b_KEYBYTES_MAX, 15 crypto_generichash_blake2b_KEYBYTES; 16 17 18 extern(C) @nogc : 19 20 21 alias crypto_generichash_BYTES_MIN = crypto_generichash_blake2b_BYTES_MIN; 22 23 size_t crypto_generichash_bytes_min() pure @trusted; 24 25 alias crypto_generichash_BYTES_MAX = crypto_generichash_blake2b_BYTES_MAX; 26 27 size_t crypto_generichash_bytes_max() pure @trusted; 28 29 alias crypto_generichash_BYTES = crypto_generichash_blake2b_BYTES; 30 31 size_t crypto_generichash_bytes() pure @trusted; 32 33 alias crypto_generichash_KEYBYTES_MIN = crypto_generichash_blake2b_KEYBYTES_MIN; 34 35 size_t crypto_generichash_keybytes_min() pure @trusted; 36 37 alias crypto_generichash_KEYBYTES_MAX = crypto_generichash_blake2b_KEYBYTES_MAX; 38 39 size_t crypto_generichash_keybytes_max() pure @trusted; 40 41 alias crypto_generichash_KEYBYTES = crypto_generichash_blake2b_KEYBYTES; 42 43 size_t crypto_generichash_keybytes() pure @trusted; 44 45 enum crypto_generichash_PRIMITIVE = "blake2b"; 46 47 /* Deviating from C header, in D the following function expresses __attribute__ ((warn_unused_result)) as well (if compiler switch -w is thrown) */ 48 const(char)* crypto_generichash_primitive() pure nothrow @trusted; 49 50 /* 51 * Important when writing bindings for other programming languages: 52 * the state address should be 64-bytes aligned. 53 */ 54 alias crypto_generichash_state = crypto_generichash_blake2b_state; 55 56 size_t crypto_generichash_statebytes() pure @trusted; 57 58 int crypto_generichash(ubyte* out_, size_t outlen, 59 const(ubyte)* in_, ulong inlen, 60 const(ubyte)* key, size_t keylen) pure; // __attribute__ ((nonnull(1))); 61 62 int crypto_generichash_init(crypto_generichash_state* state, 63 const(ubyte)* key, 64 const size_t keylen, const size_t outlen) pure; // __attribute__ ((nonnull(1))); 65 66 int crypto_generichash_update(crypto_generichash_state* state, 67 const(ubyte)* in_, 68 ulong inlen) pure; // __attribute__ ((nonnull(1))); 69 70 int crypto_generichash_final(crypto_generichash_state* state, 71 ubyte* out_, const size_t outlen) pure; // __attribute__ ((nonnull)); 72 73 void crypto_generichash_keygen(ref ubyte[crypto_generichash_KEYBYTES] k) nothrow @trusted; // __attribute__ ((nonnull));