1 #ifndef crypto_box_curve25519xsalsa20poly1305_H 2 #define crypto_box_curve25519xsalsa20poly1305_H 3 4 #include <stddef.h> 5 #include "crypto_stream_xsalsa20.h" 6 #include "export.h" 7 8 #ifdef __cplusplus 9 # ifdef __GNUC__ 10 # pragma GCC diagnostic ignored "-Wlong-long" 11 # endif 12 extern "C" { 13 #endif 14 15 #define crypto_box_curve25519xsalsa20poly1305_SEEDBYTES 32U 16 SODIUM_EXPORT 17 size_t crypto_box_curve25519xsalsa20poly1305_seedbytes(void); 18 19 #define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 32U 20 SODIUM_EXPORT 21 size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes(void); 22 23 #define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES 32U 24 SODIUM_EXPORT 25 size_t crypto_box_curve25519xsalsa20poly1305_secretkeybytes(void); 26 27 #define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES 32U 28 SODIUM_EXPORT 29 size_t crypto_box_curve25519xsalsa20poly1305_beforenmbytes(void); 30 31 #define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES 24U 32 SODIUM_EXPORT 33 size_t crypto_box_curve25519xsalsa20poly1305_noncebytes(void); 34 35 #define crypto_box_curve25519xsalsa20poly1305_MACBYTES 16U 36 SODIUM_EXPORT 37 size_t crypto_box_curve25519xsalsa20poly1305_macbytes(void); 38 39 /* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */ 40 #define crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX \ 41 (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES) 42 SODIUM_EXPORT 43 size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void); 44 45 SODIUM_EXPORT 46 int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk, 47 unsigned char *sk, 48 const unsigned char *seed); 49 50 SODIUM_EXPORT 51 int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk, 52 unsigned char *sk); 53 54 SODIUM_EXPORT 55 int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k, 56 const unsigned char *pk, 57 const unsigned char *sk) 58 __attribute__ ((warn_unused_result)); 59 60 /* -- NaCl compatibility interface ; Requires padding -- */ 61 62 #define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 16U 63 SODIUM_EXPORT 64 size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void); 65 66 #define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES \ 67 (crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + \ 68 crypto_box_curve25519xsalsa20poly1305_MACBYTES) 69 SODIUM_EXPORT 70 size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void); 71 72 SODIUM_EXPORT 73 int crypto_box_curve25519xsalsa20poly1305(unsigned char *c, 74 const unsigned char *m, 75 unsigned long long mlen, 76 const unsigned char *n, 77 const unsigned char *pk, 78 const unsigned char *sk) 79 __attribute__ ((warn_unused_result)); 80 81 SODIUM_EXPORT 82 int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m, 83 const unsigned char *c, 84 unsigned long long clen, 85 const unsigned char *n, 86 const unsigned char *pk, 87 const unsigned char *sk) 88 __attribute__ ((warn_unused_result)); 89 90 SODIUM_EXPORT 91 int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c, 92 const unsigned char *m, 93 unsigned long long mlen, 94 const unsigned char *n, 95 const unsigned char *k); 96 97 SODIUM_EXPORT 98 int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m, 99 const unsigned char *c, 100 unsigned long long clen, 101 const unsigned char *n, 102 const unsigned char *k) 103 __attribute__ ((warn_unused_result)); 104 105 #ifdef __cplusplus 106 } 107 #endif 108 109 #endif 110