2
0

We don't need libscrypt when linking against sodium.

This commit is contained in:
Maarten Billemont 2017-04-08 16:20:58 -04:00
parent 4058d33202
commit 385f347b33
3 changed files with 26 additions and 8 deletions

View File

@ -29,7 +29,7 @@
#if HAS_CPERCIVA
#include <scrypt/crypto_scrypt.h>
#include <scrypt/sha256.h>
#elif HAS_SCRYPT_SODIUM
#elif HAS_SODIUM
#include <libscrypt.h>
#include <sodium.h>
#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 );

View File

@ -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)

View File

@ -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