summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crypto.h19
-rw-r--r--ct_servmgmt.c7
-rw-r--r--ct_usermgmt.c9
-rw-r--r--curve.c12
-rw-r--r--curve.h8
-rw-r--r--curvetun.c5
6 files changed, 26 insertions, 34 deletions
diff --git a/crypto.h b/crypto.h
new file mode 100644
index 0000000..2c3fac3
--- /dev/null
+++ b/crypto.h
@@ -0,0 +1,19 @@
+#ifndef CRYPTO_H
+#define CRYPTO_H
+
+#include "crypto_verify_32.h"
+#include "crypto_hash_sha512.h"
+#include "crypto_box_curve25519xsalsa20poly1305.h"
+#include "crypto_scalarmult_curve25519.h"
+#include "crypto_auth_hmacsha512256.h"
+
+#define crypto_box_zerobytes crypto_box_curve25519xsalsa20poly1305_ZEROBYTES
+#define crypto_box_boxzerobytes crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES
+#define crypto_box_noncebytes crypto_box_curve25519xsalsa20poly1305_NONCEBYTES
+#define crypto_box_beforenmbytes crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES
+#define crypto_box_beforenm crypto_box_curve25519xsalsa20poly1305_beforenm
+#define crypto_box_afternm crypto_box_curve25519xsalsa20poly1305_afternm
+#define crypto_box_open_afternm crypto_box_curve25519xsalsa20poly1305_open_afternm
+#define crypto_box_pub_key_size crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES
+
+#endif /* CRYPTO_H */
diff --git a/ct_servmgmt.c b/ct_servmgmt.c
index 143b03a..38eb9c5 100644
--- a/ct_servmgmt.c
+++ b/ct_servmgmt.c
@@ -18,13 +18,8 @@
#include "xmalloc.h"
#include "curvetun.h"
#include "curve.h"
+#include "crypto.h"
#include "ct_servmgmt.h"
-#include "crypto_box_curve25519xsalsa20poly1305.h"
-#include "crypto_auth_hmacsha512256.h"
-
-#define crypto_box_pub_key_size crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES
-
-/* Config line format: alias;serverip|servername;port;udp|tcp;pubkey\n */
struct server_store {
int udp;
diff --git a/ct_usermgmt.c b/ct_usermgmt.c
index a4978fc..201c0c7 100644
--- a/ct_usermgmt.c
+++ b/ct_usermgmt.c
@@ -23,15 +23,8 @@
#include "str.h"
#include "curvetun.h"
#include "curve.h"
+#include "crypto.h"
#include "hash.h"
-#include "crypto_verify_32.h"
-#include "crypto_hash_sha512.h"
-#include "crypto_box_curve25519xsalsa20poly1305.h"
-#include "crypto_auth_hmacsha512256.h"
-
-#define crypto_box_pub_key_size crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES
-
-/* Config line format: username;pubkey\n */
struct user_store {
char username[256];
diff --git a/curve.c b/curve.c
index 9b32c03..b7d5b4f 100644
--- a/curve.c
+++ b/curve.c
@@ -25,16 +25,10 @@
#include "str.h"
#include "curvetun.h"
#include "locking.h"
-#include "crypto_verify_32.h"
-#include "crypto_box_curve25519xsalsa20poly1305.h"
-#include "crypto_scalarmult_curve25519.h"
+#include "crypto.h"
-#define crypto_box_beforenm crypto_box_curve25519xsalsa20poly1305_beforenm
-#define crypto_box_afternm crypto_box_curve25519xsalsa20poly1305_afternm
-#define crypto_box_open_afternm crypto_box_curve25519xsalsa20poly1305_open_afternm
-
-#define NONCE_LENGTH (sizeof(struct taia))
-#define NONCE_OFFSET (crypto_box_curve25519xsalsa20poly1305_NONCEBYTES - NONCE_LENGTH)
+#define NONCE_LENGTH (sizeof(struct taia))
+#define NONCE_OFFSET (crypto_box_noncebytes - NONCE_LENGTH)
void curve25519_selftest(void)
{
diff --git a/curve.h b/curve.h
index b7aebcb..ee4a322 100644
--- a/curve.h
+++ b/curve.h
@@ -14,7 +14,7 @@
#include "built_in.h"
#include "ioops.h"
#include "rnd.h"
-#include "crypto_box_curve25519xsalsa20poly1305.h"
+#include "crypto.h"
struct tai {
uint64_t x;
@@ -32,12 +32,6 @@ static struct taia tolerance_taia = {
.atto = 0,
};
-#define crypto_box_zerobytes crypto_box_curve25519xsalsa20poly1305_ZEROBYTES
-#define crypto_box_boxzerobytes crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES
-
-#define crypto_box_noncebytes crypto_box_curve25519xsalsa20poly1305_NONCEBYTES
-#define crypto_box_beforenmbytes crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES
-
struct curve25519_proto {
unsigned char enonce[crypto_box_noncebytes] __aligned_16;
unsigned char dnonce[crypto_box_noncebytes] __aligned_16;
diff --git a/curvetun.c b/curvetun.c
index 458bd0c..1b69b2d 100644
--- a/curvetun.c
+++ b/curvetun.c
@@ -38,10 +38,7 @@
#include "ct_servmgmt.h"
#include "ioops.h"
#include "tprintf.h"
-#include "crypto_verify_32.h"
-#include "crypto_box_curve25519xsalsa20poly1305.h"
-#include "crypto_scalarmult_curve25519.h"
-#include "crypto_auth_hmacsha512256.h"
+#include "crypto.h"
enum working_mode {
MODE_UNKNOW,