1 2 #ifndef crypto_box_curve25519xchacha20poly1305_H 3 #define crypto_box_curve25519xchacha20poly1305_H 4 5 #include <stddef.h> 6 #include "crypto_stream_xchacha20.h" 7 #include "export.h" 8 9 #ifdef __cplusplus 10 # ifdef __GNUC__ 11 # pragma GCC diagnostic ignored "-Wlong-long" 12 # endif 13 extern "C" { 14 #endif 15 16 #define crypto_box_curve25519xchacha20poly1305_SEEDBYTES 32U 17 SODIUM_EXPORT 18 size_t crypto_box_curve25519xchacha20poly1305_seedbytes(void); 19 20 #define crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES 32U 21 SODIUM_EXPORT 22 size_t crypto_box_curve25519xchacha20poly1305_publickeybytes(void); 23 24 #define crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES 32U 25 SODIUM_EXPORT 26 size_t crypto_box_curve25519xchacha20poly1305_secretkeybytes(void); 27 28 #define crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES 32U 29 SODIUM_EXPORT 30 size_t crypto_box_curve25519xchacha20poly1305_beforenmbytes(void); 31 32 #define crypto_box_curve25519xchacha20poly1305_NONCEBYTES 24U 33 SODIUM_EXPORT 34 size_t crypto_box_curve25519xchacha20poly1305_noncebytes(void); 35 36 #define crypto_box_curve25519xchacha20poly1305_MACBYTES 16U 37 SODIUM_EXPORT 38 size_t crypto_box_curve25519xchacha20poly1305_macbytes(void); 39 40 #define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \ 41 (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES) 42 SODIUM_EXPORT 43 size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void); 44 45 SODIUM_EXPORT 46 int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk, 47 unsigned char *sk, 48 const unsigned char *seed); 49 50 SODIUM_EXPORT 51 int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk, 52 unsigned char *sk); 53 54 SODIUM_EXPORT 55 int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c, 56 const unsigned char *m, 57 unsigned long long mlen, 58 const unsigned char *n, 59 const unsigned char *pk, 60 const unsigned char *sk) 61 __attribute__ ((warn_unused_result)); 62 63 SODIUM_EXPORT 64 int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m, 65 const unsigned char *c, 66 unsigned long long clen, 67 const unsigned char *n, 68 const unsigned char *pk, 69 const unsigned char *sk) 70 __attribute__ ((warn_unused_result)); 71 72 SODIUM_EXPORT 73 int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c, 74 unsigned char *mac, 75 const unsigned char *m, 76 unsigned long long mlen, 77 const unsigned char *n, 78 const unsigned char *pk, 79 const unsigned char *sk) 80 __attribute__ ((warn_unused_result)); 81 82 SODIUM_EXPORT 83 int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m, 84 const unsigned char *c, 85 const unsigned char *mac, 86 unsigned long long clen, 87 const unsigned char *n, 88 const unsigned char *pk, 89 const unsigned char *sk) 90 __attribute__ ((warn_unused_result)); 91 92 /* -- Precomputation interface -- */ 93 94 SODIUM_EXPORT 95 int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k, 96 const unsigned char *pk, 97 const unsigned char *sk) 98 __attribute__ ((warn_unused_result)); 99 100 SODIUM_EXPORT 101 int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c, 102 const unsigned char *m, 103 unsigned long long mlen, 104 const unsigned char *n, 105 const unsigned char *k); 106 107 SODIUM_EXPORT 108 int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m, 109 const unsigned char *c, 110 unsigned long long clen, 111 const unsigned char *n, 112 const unsigned char *k) 113 __attribute__ ((warn_unused_result)); 114 115 SODIUM_EXPORT 116 int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c, 117 unsigned char *mac, 118 const unsigned char *m, 119 unsigned long long mlen, 120 const unsigned char *n, 121 const unsigned char *k); 122 123 SODIUM_EXPORT 124 int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m, 125 const unsigned char *c, 126 const unsigned char *mac, 127 unsigned long long clen, 128 const unsigned char *n, 129 const unsigned char *k) 130 __attribute__ ((warn_unused_result)); 131 132 /* -- Ephemeral SK interface -- */ 133 134 #define crypto_box_curve25519xchacha20poly1305_SEALBYTES \ 135 (crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + \ 136 crypto_box_curve25519xchacha20poly1305_MACBYTES) 137 138 SODIUM_EXPORT 139 size_t crypto_box_curve25519xchacha20poly1305_sealbytes(void); 140 141 SODIUM_EXPORT 142 int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c, 143 const unsigned char *m, 144 unsigned long long mlen, 145 const unsigned char *pk); 146 147 SODIUM_EXPORT 148 int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m, 149 const unsigned char *c, 150 unsigned long long clen, 151 const unsigned char *pk, 152 const unsigned char *sk) 153 __attribute__ ((warn_unused_result)); 154 155 #ifdef __cplusplus 156 } 157 #endif 158 159 #endif 160