1 /*******************************************************************************
2 
3     D language bindings for libsodium's crypto_aead_xchacha20poly1305.h
4 
5     License: ISC (see LICENSE.txt)
6 
7 *******************************************************************************/
8 
9 module libsodium.crypto_aead_xchacha20poly1305;
10 
11 @nogc nothrow:
12 
13 import libsodium.export_;
14 
15 extern (C):
16 
17 enum crypto_aead_xchacha20poly1305_ietf_KEYBYTES = 32U;
18 size_t crypto_aead_xchacha20poly1305_ietf_keybytes ();
19 
20 enum crypto_aead_xchacha20poly1305_ietf_NSECBYTES = 0U;
21 size_t crypto_aead_xchacha20poly1305_ietf_nsecbytes ();
22 
23 enum crypto_aead_xchacha20poly1305_ietf_NPUBBYTES = 24U;
24 size_t crypto_aead_xchacha20poly1305_ietf_npubbytes ();
25 
26 enum crypto_aead_xchacha20poly1305_ietf_ABYTES = 16U;
27 size_t crypto_aead_xchacha20poly1305_ietf_abytes ();
28 
29 enum crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES;
30 size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max ();
31 
32 int crypto_aead_xchacha20poly1305_ietf_encrypt (
33     ubyte* c,
34     ulong* clen_p,
35     const(ubyte)* m,
36     ulong mlen,
37     const(ubyte)* ad,
38     ulong adlen,
39     const(ubyte)* nsec,
40     const(ubyte)* npub,
41     const(ubyte)* k);
42 
43 int crypto_aead_xchacha20poly1305_ietf_decrypt (
44     ubyte* m,
45     ulong* mlen_p,
46     ubyte* nsec,
47     const(ubyte)* c,
48     ulong clen,
49     const(ubyte)* ad,
50     ulong adlen,
51     const(ubyte)* npub,
52     const(ubyte)* k);
53 
54 int crypto_aead_xchacha20poly1305_ietf_encrypt_detached (
55     ubyte* c,
56     ubyte* mac,
57     ulong* maclen_p,
58     const(ubyte)* m,
59     ulong mlen,
60     const(ubyte)* ad,
61     ulong adlen,
62     const(ubyte)* nsec,
63     const(ubyte)* npub,
64     const(ubyte)* k);
65 
66 int crypto_aead_xchacha20poly1305_ietf_decrypt_detached (
67     ubyte* m,
68     ubyte* nsec,
69     const(ubyte)* c,
70     ulong clen,
71     const(ubyte)* mac,
72     const(ubyte)* ad,
73     ulong adlen,
74     const(ubyte)* npub,
75     const(ubyte)* k);
76 
77 void crypto_aead_xchacha20poly1305_ietf_keygen (
78     ref ubyte[crypto_aead_xchacha20poly1305_ietf_KEYBYTES] k);
79 
80 /* Aliases */
81 
82 enum crypto_aead_xchacha20poly1305_IETF_KEYBYTES = crypto_aead_xchacha20poly1305_ietf_KEYBYTES;
83 enum crypto_aead_xchacha20poly1305_IETF_NSECBYTES = crypto_aead_xchacha20poly1305_ietf_NSECBYTES;
84 enum crypto_aead_xchacha20poly1305_IETF_NPUBBYTES = crypto_aead_xchacha20poly1305_ietf_NPUBBYTES;
85 enum crypto_aead_xchacha20poly1305_IETF_ABYTES = crypto_aead_xchacha20poly1305_ietf_ABYTES;
86 enum crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX = crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX;