Define VERSION_MAJOR and use it in handshake
This commit is contained in:
@@ -4,6 +4,7 @@ AC_INIT([glorytun],
|
|||||||
[https://github.com/angt/glorytun/issues],
|
[https://github.com/angt/glorytun/issues],
|
||||||
[glorytun],
|
[glorytun],
|
||||||
[https://github.com/angt/glorytun])
|
[https://github.com/angt/glorytun])
|
||||||
|
AC_DEFINE_UNQUOTED([VERSION_MAJOR], [m4_esyscmd([./version.sh major])])
|
||||||
AC_CONFIG_SRCDIR([src/common.h])
|
AC_CONFIG_SRCDIR([src/common.h])
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|||||||
@@ -651,6 +651,8 @@ static int gt_setup_secretkey (struct crypto_ctx *ctx, char *keyfile)
|
|||||||
|
|
||||||
static int gt_setup_crypto (struct crypto_ctx *ctx, int fd, int listener)
|
static int gt_setup_crypto (struct crypto_ctx *ctx, int fd, int listener)
|
||||||
{
|
{
|
||||||
|
const uint8_t gt[] = {'G', 'T', VERSION_MAJOR, 0 };
|
||||||
|
|
||||||
const size_t size = 96;
|
const size_t size = 96;
|
||||||
const size_t hash_size = 32;
|
const size_t hash_size = 32;
|
||||||
|
|
||||||
@@ -673,7 +675,7 @@ static int gt_setup_crypto (struct crypto_ctx *ctx, int fd, int listener)
|
|||||||
randombytes_buf(secret, sizeof(secret));
|
randombytes_buf(secret, sizeof(secret));
|
||||||
crypto_scalarmult_base(&data_w[nonce_size], secret);
|
crypto_scalarmult_base(&data_w[nonce_size], secret);
|
||||||
|
|
||||||
byte_cpy(&data_w[size-hash_size-4], "GT\0\0", 4);
|
byte_cpy(&data_w[size-hash_size-sizeof(gt)], gt, sizeof(gt));
|
||||||
|
|
||||||
crypto_generichash(&data_w[size-hash_size], hash_size,
|
crypto_generichash(&data_w[size-hash_size], hash_size,
|
||||||
data_w, size-hash_size, ctx->skey, sizeof(ctx->skey));
|
data_w, size-hash_size, ctx->skey, sizeof(ctx->skey));
|
||||||
@@ -684,7 +686,7 @@ static int gt_setup_crypto (struct crypto_ctx *ctx, int fd, int listener)
|
|||||||
if (fd_read_all(fd, data_r, size)!=size)
|
if (fd_read_all(fd, data_r, size)!=size)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (memcmp(&data_r[size-hash_size-4], &data_w[size-hash_size-4], 4))
|
if (memcmp(&data_r[size-hash_size-sizeof(gt)], gt, sizeof(gt)))
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
crypto_generichash(hash, hash_size,
|
crypto_generichash(hash, hash_size,
|
||||||
|
|||||||
@@ -6,4 +6,6 @@
|
|||||||
[ -z "${VERSION}" ] && VERSION=`basename \`pwd\`` \
|
[ -z "${VERSION}" ] && VERSION=`basename \`pwd\`` \
|
||||||
&& VERSION=${VERSION#*-}
|
&& VERSION=${VERSION#*-}
|
||||||
|
|
||||||
|
[ "$1" = "major" ] && VERSION=${VERSION%%.*}
|
||||||
|
|
||||||
printf ${VERSION}
|
printf ${VERSION}
|
||||||
|
|||||||
Reference in New Issue
Block a user