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