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