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_box_curve25519xsalsa20poly1305_H
5 */
6 
7 module deimos.sodium.crypto_box_curve25519xsalsa20poly1305;
8 
9 import deimos.sodium.crypto_stream_xsalsa20 : crypto_stream_xsalsa20_MESSAGEBYTES_MAX;
10 
11 extern(C) @nogc :
12 
13 
14 enum crypto_box_curve25519xsalsa20poly1305_SEEDBYTES = 32U;
15 
16 size_t crypto_box_curve25519xsalsa20poly1305_seedbytes() pure @trusted;
17 
18 enum crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES = 32U;
19 
20 size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes() pure @trusted;
21 
22 enum crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES = 32U;
23 
24 size_t crypto_box_curve25519xsalsa20poly1305_secretkeybytes() pure @trusted;
25 
26 enum crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES = 32U;
27 
28 size_t crypto_box_curve25519xsalsa20poly1305_beforenmbytes() pure @trusted;
29 
30 enum crypto_box_curve25519xsalsa20poly1305_NONCEBYTES = 24U;
31 
32 size_t crypto_box_curve25519xsalsa20poly1305_noncebytes() pure @trusted;
33 
34 enum crypto_box_curve25519xsalsa20poly1305_MACBYTES = 16U;
35 
36 size_t crypto_box_curve25519xsalsa20poly1305_macbytes() pure @trusted;
37 
38 /* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */
39 enum crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX =
40     (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES);
41 
42 size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max() pure @trusted;
43 
44 int crypto_box_curve25519xsalsa20poly1305_seed_keypair(ubyte* pk,
45                                                        ubyte* sk,
46                                                        const(ubyte)* seed) pure; // __attribute__ ((nonnull));
47 
48 int crypto_box_curve25519xsalsa20poly1305_keypair(ubyte* pk,
49                                                   ubyte* sk) nothrow; // __attribute__ ((nonnull));
50 
51 int crypto_box_curve25519xsalsa20poly1305_beforenm(ubyte* k,
52                                                    const(ubyte)* pk,
53                                                    const(ubyte)* sk) pure nothrow; // __attribute__ ((warn_unused_result))  __attribute__ ((nonnull));
54 
55 /* -- NaCl compatibility interface ; Requires padding -- */
56 
57 enum crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES = 16U;
58 
59 size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes() pure @trusted;
60 
61 enum crypto_box_curve25519xsalsa20poly1305_ZEROBYTES =
62     (crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES +
63      crypto_box_curve25519xsalsa20poly1305_MACBYTES);
64 
65 size_t crypto_box_curve25519xsalsa20poly1305_zerobytes() pure @trusted;
66 
67 int crypto_box_curve25519xsalsa20poly1305(ubyte* c,
68                                           const(ubyte)* m,
69                                           ulong mlen,
70                                           const(ubyte)* n,
71                                           const(ubyte)* pk,
72                                           const(ubyte)* sk) pure nothrow; // __attribute__ ((warn_unused_result))  __attribute__ ((nonnull(1, 4, 5, 6)));
73 
74 int crypto_box_curve25519xsalsa20poly1305_open(ubyte* m,
75                                                const(ubyte)* c,
76                                                ulong clen,
77                                                const(ubyte)* n,
78                                                const(ubyte)* pk,
79                                                const(ubyte)* sk) pure nothrow; // __attribute__ ((warn_unused_result))  __attribute__ ((nonnull(2, 4, 5, 6)));
80 
81 int crypto_box_curve25519xsalsa20poly1305_afternm(ubyte* c,
82                                                   const(ubyte)* m,
83                                                   ulong mlen,
84                                                   const(ubyte)* n,
85                                                   const(ubyte)* k) pure; // __attribute__ ((nonnull(1, 4, 5)));
86 
87 int crypto_box_curve25519xsalsa20poly1305_open_afternm(ubyte* m,
88                                                        const(ubyte)* c,
89                                                        ulong clen,
90                                                        const(ubyte)* n,
91                                                        const(ubyte)* k) pure nothrow; // __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));