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_secretbox_xsalsa20poly1305_H
5 */
6 
7 module deimos.sodium.crypto_secretbox_xsalsa20poly1305;
8 
9 import deimos.sodium.crypto_stream_xsalsa20 : crypto_stream_xsalsa20_MESSAGEBYTES_MAX;
10 
11 extern(C) @nogc :
12 
13 
14 enum crypto_secretbox_xsalsa20poly1305_KEYBYTES = 32U;
15 
16 size_t crypto_secretbox_xsalsa20poly1305_keybytes() pure @trusted;
17 
18 enum crypto_secretbox_xsalsa20poly1305_NONCEBYTES = 24U;
19 
20 size_t crypto_secretbox_xsalsa20poly1305_noncebytes() pure @trusted;
21 
22 enum crypto_secretbox_xsalsa20poly1305_MACBYTES = 16U;
23 
24 size_t crypto_secretbox_xsalsa20poly1305_macbytes() pure @trusted;
25 
26 /* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */
27 enum crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX =
28     (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_secretbox_xsalsa20poly1305_MACBYTES);
29 
30 size_t crypto_secretbox_xsalsa20poly1305_messagebytes_max() pure @trusted;
31 
32 int crypto_secretbox_xsalsa20poly1305(ubyte* c,
33                                       const(ubyte)* m,
34                                       ulong mlen,
35                                       const(ubyte)* n,
36                                       const(ubyte)* k) pure; // __attribute__ ((nonnull(1, 4, 5)));
37 
38 int crypto_secretbox_xsalsa20poly1305_open(ubyte* m,
39                                            const(ubyte)* c,
40                                            ulong clen,
41                                            const(ubyte)* n,
42                                            const(ubyte)* k) pure nothrow; //  __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
43 
44 void crypto_secretbox_xsalsa20poly1305_keygen(ref ubyte[crypto_secretbox_xsalsa20poly1305_KEYBYTES] k) nothrow @trusted; // __attribute__ ((nonnull));
45 
46 /* -- NaCl compatibility interface ; Requires padding -- */
47 
48 enum crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES = 16U;
49 
50 size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes() pure @trusted;
51 
52 enum crypto_secretbox_xsalsa20poly1305_ZEROBYTES =
53     (crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES +
54      crypto_secretbox_xsalsa20poly1305_MACBYTES);
55 
56 size_t crypto_secretbox_xsalsa20poly1305_zerobytes() pure @trusted;