1 /*******************************************************************************
2 
3     D language bindings for libsodium's crypto_box_curve25519xchacha20poly1305.h
4 
5     License: ISC (see LICENSE.txt)
6 
7 *******************************************************************************/
8 
9 module libsodium.crypto_box_curve25519xchacha20poly1305;
10 
11 @nogc nothrow:
12 
13 import libsodium.export_;
14 import libsodium.crypto_stream_xchacha20;
15 
16 extern (C):
17 
18 enum crypto_box_curve25519xchacha20poly1305_SEEDBYTES = 32U;
19 size_t crypto_box_curve25519xchacha20poly1305_seedbytes ();
20 
21 enum crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES = 32U;
22 size_t crypto_box_curve25519xchacha20poly1305_publickeybytes ();
23 
24 enum crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES = 32U;
25 size_t crypto_box_curve25519xchacha20poly1305_secretkeybytes ();
26 
27 enum crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES = 32U;
28 size_t crypto_box_curve25519xchacha20poly1305_beforenmbytes ();
29 
30 enum crypto_box_curve25519xchacha20poly1305_NONCEBYTES = 24U;
31 size_t crypto_box_curve25519xchacha20poly1305_noncebytes ();
32 
33 enum crypto_box_curve25519xchacha20poly1305_MACBYTES = 16U;
34 size_t crypto_box_curve25519xchacha20poly1305_macbytes ();
35 
36 enum crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX = crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES;
37 size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max ();
38 
39 int crypto_box_curve25519xchacha20poly1305_seed_keypair (
40     ubyte* pk,
41     ubyte* sk,
42     const(ubyte)* seed);
43 
44 int crypto_box_curve25519xchacha20poly1305_keypair (ubyte* pk, ubyte* sk);
45 
46 int crypto_box_curve25519xchacha20poly1305_easy (
47     ubyte* c,
48     const(ubyte)* m,
49     ulong mlen,
50     const(ubyte)* n,
51     const(ubyte)* pk,
52     const(ubyte)* sk);
53 
54 int crypto_box_curve25519xchacha20poly1305_open_easy (
55     ubyte* m,
56     const(ubyte)* c,
57     ulong clen,
58     const(ubyte)* n,
59     const(ubyte)* pk,
60     const(ubyte)* sk);
61 
62 int crypto_box_curve25519xchacha20poly1305_detached (
63     ubyte* c,
64     ubyte* mac,
65     const(ubyte)* m,
66     ulong mlen,
67     const(ubyte)* n,
68     const(ubyte)* pk,
69     const(ubyte)* sk);
70 
71 int crypto_box_curve25519xchacha20poly1305_open_detached (
72     ubyte* m,
73     const(ubyte)* c,
74     const(ubyte)* mac,
75     ulong clen,
76     const(ubyte)* n,
77     const(ubyte)* pk,
78     const(ubyte)* sk);
79 
80 /* -- Precomputation interface -- */
81 
82 int crypto_box_curve25519xchacha20poly1305_beforenm (
83     ubyte* k,
84     const(ubyte)* pk,
85     const(ubyte)* sk);
86 
87 int crypto_box_curve25519xchacha20poly1305_easy_afternm (
88     ubyte* c,
89     const(ubyte)* m,
90     ulong mlen,
91     const(ubyte)* n,
92     const(ubyte)* k);
93 
94 int crypto_box_curve25519xchacha20poly1305_open_easy_afternm (
95     ubyte* m,
96     const(ubyte)* c,
97     ulong clen,
98     const(ubyte)* n,
99     const(ubyte)* k);
100 
101 int crypto_box_curve25519xchacha20poly1305_detached_afternm (
102     ubyte* c,
103     ubyte* mac,
104     const(ubyte)* m,
105     ulong mlen,
106     const(ubyte)* n,
107     const(ubyte)* k);
108 
109 int crypto_box_curve25519xchacha20poly1305_open_detached_afternm (
110     ubyte* m,
111     const(ubyte)* c,
112     const(ubyte)* mac,
113     ulong clen,
114     const(ubyte)* n,
115     const(ubyte)* k);
116 
117 /* -- Ephemeral SK interface -- */
118 
119 enum crypto_box_curve25519xchacha20poly1305_SEALBYTES = crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + crypto_box_curve25519xchacha20poly1305_MACBYTES;
120 
121 size_t crypto_box_curve25519xchacha20poly1305_sealbytes ();
122 
123 int crypto_box_curve25519xchacha20poly1305_seal (
124     ubyte* c,
125     const(ubyte)* m,
126     ulong mlen,
127     const(ubyte)* pk);
128 
129 int crypto_box_curve25519xchacha20poly1305_seal_open (
130     ubyte* m,
131     const(ubyte)* c,
132     ulong clen,
133     const(ubyte)* pk,
134     const(ubyte)* sk);