From 385f347b33f2f16a6692e0042e279f65144373b8 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sat, 8 Apr 2017 16:20:58 -0400 Subject: [PATCH] We don't need libscrypt when linking against sodium. --- core/c/mpw-util.c | 8 ++++---- platform-independent/cli-c/CMakeLists.txt | 12 ++++++++++++ platform-independent/cli-c/build | 14 ++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 platform-independent/cli-c/CMakeLists.txt diff --git a/core/c/mpw-util.c b/core/c/mpw-util.c index bede72e5..988ecf49 100644 --- a/core/c/mpw-util.c +++ b/core/c/mpw-util.c @@ -29,7 +29,7 @@ #if HAS_CPERCIVA #include #include -#elif HAS_SCRYPT_SODIUM +#elif HAS_SODIUM #include #include #endif @@ -99,7 +99,7 @@ uint8_t const *mpw_scrypt(const size_t keySize, const char *secret, const uint8_ mpw_free( key, keySize ); return NULL; } -#elif HAS_SCRYPT_SODIUM +#elif HAS_SODIUM if (crypto_pwhash_scryptsalsa208sha256_ll( (const uint8_t *)secret, strlen( secret ), salt, saltSize, N, r, p, key, keySize) != 0 ) { mpw_free( key, keySize ); return NULL; @@ -118,7 +118,7 @@ uint8_t const *mpw_hmac_sha256(const uint8_t *key, const size_t keySize, const u HMAC_SHA256_Buf( key, keySize, salt, saltSize, buffer ); return buffer; -#elif HAS_SCRYPT_SODIUM +#elif HAS_SODIUM uint8_t *const buffer = malloc( crypto_auth_hmacsha256_BYTES ); if (!buffer) return NULL; @@ -144,7 +144,7 @@ const char *mpw_id_buf(const void *buf, size_t length) { SHA256_Buf( buf, length, hash ); return mpw_hex( hash, 32 ); -#elif HAS_SCRYPT_SODIUM +#elif HAS_SODIUM uint8_t hash[crypto_hash_sha256_BYTES]; crypto_hash_sha256( hash, buf, length ); diff --git a/platform-independent/cli-c/CMakeLists.txt b/platform-independent/cli-c/CMakeLists.txt new file mode 100644 index 00000000..156fb654 --- /dev/null +++ b/platform-independent/cli-c/CMakeLists.txt @@ -0,0 +1,12 @@ +project(mpw) +cmake_minimum_required(VERSION 3.0.2) + +set(CMAKE_BUILD_TYPE Release) +set(CMAKE_C_FLAGS "-O3 -DHAS_SODIUM=1") + +include_directories(core cli) +file(GLOB SOURCES "core/*.c" "cli/mpw-cli.c") +add_executable(mpw ${SOURCES}) + +find_library(libsodium REQUIRED) +target_link_libraries(mpw sodium) diff --git a/platform-independent/cli-c/build b/platform-independent/cli-c/build index 667529d6..f2c7d869 100755 --- a/platform-independent/cli-c/build +++ b/platform-independent/cli-c/build @@ -45,7 +45,13 @@ mpw_color=${mpw_color:-1} # Colorized Identicon, requires libncurses-dev export CFLAGS="-O3 $CFLAGS" export LDFLAGS="$LDFLAGS" - +# Distribution specific configuration. +# Homebrew - openssl for scrypt +if hash brew 2>/dev/null; then + opensslPath=$(brew --prefix openssl) + CFLAGS+=" -I$opensslPath/include" + LDFLAGS+=" -L$opensslPath/lib" +fi ### DEPENDENCIES @@ -207,9 +213,9 @@ depend() { popd } depend_scrypt() { - if haslib scrypt && haslib sodium; then - CFLAGS+=" -DHAS_SCRYPT_SODIUM=1" - LDFLAGS+=" -lscrypt -lsodium" + if haslib sodium; then + CFLAGS+=" -DHAS_SODIUM=1" + LDFLAGS+=" -lsodium" return fi