xref: /freebsd/sys/contrib/libsodium/src/libsodium/crypto_box/crypto_box.c (revision 3611ec604864a7d4dcc9a3ea898c80eb35eef8a0)
1 
2 #include "crypto_box.h"
3 
4 size_t
crypto_box_seedbytes(void)5 crypto_box_seedbytes(void)
6 {
7     return crypto_box_SEEDBYTES;
8 }
9 
10 size_t
crypto_box_publickeybytes(void)11 crypto_box_publickeybytes(void)
12 {
13     return crypto_box_PUBLICKEYBYTES;
14 }
15 
16 size_t
crypto_box_secretkeybytes(void)17 crypto_box_secretkeybytes(void)
18 {
19     return crypto_box_SECRETKEYBYTES;
20 }
21 
22 size_t
crypto_box_beforenmbytes(void)23 crypto_box_beforenmbytes(void)
24 {
25     return crypto_box_BEFORENMBYTES;
26 }
27 
28 size_t
crypto_box_noncebytes(void)29 crypto_box_noncebytes(void)
30 {
31     return crypto_box_NONCEBYTES;
32 }
33 
34 size_t
crypto_box_zerobytes(void)35 crypto_box_zerobytes(void)
36 {
37     return crypto_box_ZEROBYTES;
38 }
39 
40 size_t
crypto_box_boxzerobytes(void)41 crypto_box_boxzerobytes(void)
42 {
43     return crypto_box_BOXZEROBYTES;
44 }
45 
46 size_t
crypto_box_macbytes(void)47 crypto_box_macbytes(void)
48 {
49     return crypto_box_MACBYTES;
50 }
51 
52 size_t
crypto_box_messagebytes_max(void)53 crypto_box_messagebytes_max(void)
54 {
55     return crypto_box_MESSAGEBYTES_MAX;
56 }
57 
58 const char *
crypto_box_primitive(void)59 crypto_box_primitive(void)
60 {
61     return crypto_box_PRIMITIVE;
62 }
63 
64 int
crypto_box_seed_keypair(unsigned char * pk,unsigned char * sk,const unsigned char * seed)65 crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk,
66                         const unsigned char *seed)
67 {
68     return crypto_box_curve25519xsalsa20poly1305_seed_keypair(pk, sk, seed);
69 }
70 
71 int
crypto_box_keypair(unsigned char * pk,unsigned char * sk)72 crypto_box_keypair(unsigned char *pk, unsigned char *sk)
73 {
74     return crypto_box_curve25519xsalsa20poly1305_keypair(pk, sk);
75 }
76 
77 int
crypto_box_beforenm(unsigned char * k,const unsigned char * pk,const unsigned char * sk)78 crypto_box_beforenm(unsigned char *k, const unsigned char *pk,
79                     const unsigned char *sk)
80 {
81     return crypto_box_curve25519xsalsa20poly1305_beforenm(k, pk, sk);
82 }
83 
84 int
crypto_box_afternm(unsigned char * c,const unsigned char * m,unsigned long long mlen,const unsigned char * n,const unsigned char * k)85 crypto_box_afternm(unsigned char *c, const unsigned char *m,
86                    unsigned long long mlen, const unsigned char *n,
87                    const unsigned char *k)
88 {
89     return crypto_box_curve25519xsalsa20poly1305_afternm(c, m, mlen, n, k);
90 }
91 
92 int
crypto_box_open_afternm(unsigned char * m,const unsigned char * c,unsigned long long clen,const unsigned char * n,const unsigned char * k)93 crypto_box_open_afternm(unsigned char *m, const unsigned char *c,
94                         unsigned long long clen, const unsigned char *n,
95                         const unsigned char *k)
96 {
97     return crypto_box_curve25519xsalsa20poly1305_open_afternm(m, c, clen, n, k);
98 }
99 
100 int
crypto_box(unsigned char * c,const unsigned char * m,unsigned long long mlen,const unsigned char * n,const unsigned char * pk,const unsigned char * sk)101 crypto_box(unsigned char *c, const unsigned char *m,
102            unsigned long long mlen, const unsigned char *n,
103            const unsigned char *pk, const unsigned char *sk)
104 {
105     return crypto_box_curve25519xsalsa20poly1305(c, m, mlen, n, pk, sk);
106 }
107 
108 int
crypto_box_open(unsigned char * m,const unsigned char * c,unsigned long long clen,const unsigned char * n,const unsigned char * pk,const unsigned char * sk)109 crypto_box_open(unsigned char *m, const unsigned char *c,
110                 unsigned long long clen, const unsigned char *n,
111                 const unsigned char *pk, const unsigned char *sk)
112 {
113     return crypto_box_curve25519xsalsa20poly1305_open(m, c, clen, n, pk, sk);
114 }
115