diff options
-rw-r--r-- | crypto.h | 19 | ||||
-rw-r--r-- | ct_servmgmt.c | 7 | ||||
-rw-r--r-- | ct_usermgmt.c | 9 | ||||
-rw-r--r-- | curve.c | 12 | ||||
-rw-r--r-- | curve.h | 8 | ||||
-rw-r--r-- | curvetun.c | 5 |
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]; @@ -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) { @@ -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; @@ -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, |