1
2 #include "crypto_secretbox.h"
3 #include "randombytes.h"
4
5 size_t
crypto_secretbox_keybytes(void)6 crypto_secretbox_keybytes(void)
7 {
8 return crypto_secretbox_KEYBYTES;
9 }
10
11 size_t
crypto_secretbox_noncebytes(void)12 crypto_secretbox_noncebytes(void)
13 {
14 return crypto_secretbox_NONCEBYTES;
15 }
16
17 size_t
crypto_secretbox_zerobytes(void)18 crypto_secretbox_zerobytes(void)
19 {
20 return crypto_secretbox_ZEROBYTES;
21 }
22
23 size_t
crypto_secretbox_boxzerobytes(void)24 crypto_secretbox_boxzerobytes(void)
25 {
26 return crypto_secretbox_BOXZEROBYTES;
27 }
28
29 size_t
crypto_secretbox_macbytes(void)30 crypto_secretbox_macbytes(void)
31 {
32 return crypto_secretbox_MACBYTES;
33 }
34
35 size_t
crypto_secretbox_messagebytes_max(void)36 crypto_secretbox_messagebytes_max(void)
37 {
38 return crypto_secretbox_MESSAGEBYTES_MAX;
39 }
40
41 const char *
crypto_secretbox_primitive(void)42 crypto_secretbox_primitive(void)
43 {
44 return crypto_secretbox_PRIMITIVE;
45 }
46
47 int
crypto_secretbox(unsigned char * c,const unsigned char * m,unsigned long long mlen,const unsigned char * n,const unsigned char * k)48 crypto_secretbox(unsigned char *c, const unsigned char *m,
49 unsigned long long mlen, const unsigned char *n,
50 const unsigned char *k)
51 {
52 return crypto_secretbox_xsalsa20poly1305(c, m, mlen, n, k);
53 }
54
55 int
crypto_secretbox_open(unsigned char * m,const unsigned char * c,unsigned long long clen,const unsigned char * n,const unsigned char * k)56 crypto_secretbox_open(unsigned char *m, const unsigned char *c,
57 unsigned long long clen, const unsigned char *n,
58 const unsigned char *k)
59 {
60 return crypto_secretbox_xsalsa20poly1305_open(m, c, clen, n, k);
61 }
62
63 void
crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES])64 crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES])
65 {
66 randombytes_buf(k, crypto_secretbox_KEYBYTES);
67 }
68