From b85d2641b20159f25a4416d7c1322ec98c04eb0c Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 25 Sep 2012 11:55:47 +0000 Subject: added clang support --- src/cipher.c | 6 ++---- src/configure | 20 ++++++++++++++++---- src/key_derivation.c | 7 +++---- 3 files changed, 21 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/cipher.c b/src/cipher.c index 8913f64..427ce9a 100644 --- a/src/cipher.c +++ b/src/cipher.c @@ -210,8 +210,6 @@ int cipher_aesctr_init(cipher_t* c) if(!c->params_) return -2; - cipher_aesctr_param_t* params = c->params_; - #ifndef USE_SSL_CRYPTO int algo; switch(c->key_length_) { @@ -224,6 +222,7 @@ int cipher_aesctr_init(cipher_t* c) } } + cipher_aesctr_param_t* params = c->params_; gcry_error_t err = gcry_cipher_open(¶ms->handle_, algo, GCRY_CIPHER_MODE_CTR, 0); if(err) { log_printf(ERROR, "failed to open cipher: %s", gcry_strerror(err)); @@ -240,9 +239,8 @@ void cipher_aesctr_close(cipher_t* c) return; if(c->params_) { - cipher_aesctr_param_t* params = c->params_; - #ifndef USE_SSL_CRYPTO + cipher_aesctr_param_t* params = c->params_; if(params->handle_) gcry_cipher_close(params->handle_); #endif diff --git a/src/configure b/src/configure index d91b396..d2f60a8 100755 --- a/src/configure +++ b/src/configure @@ -35,11 +35,9 @@ # TARGET=`uname -s` - EBUILD_COMPAT=0 -CFLAGS='-g -Wall -O2' -LDFLAGS='-g -Wall -O2' +USE_CLANG=0 CRYPTO_LIB='gcrypt' PASSPHRASE=1 @@ -66,6 +64,7 @@ print_usage() { echo " --no-crypto disable crypto at all (only NULL cipher)" echo " --disable-passphrase disable master key and salt passphrase" echo " --enable-passphrase enable master key and salt passphrase" + echo " --use-clang use clang/llvm as compiler/linker" } for arg @@ -74,6 +73,9 @@ do --target=*) TARGET=${arg#--target=} ;; + --use-clang) + USE_CLANG=1 + ;; --prefix=*) PREFIX=${arg#--prefix=} ;; @@ -129,6 +131,16 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then exit 1 fi +if [ $USE_CLANG -eq 0 ]; then + CFLAGS='-g -Wall -O2' + LDFLAGS='-g -Wall -O2' + COMPILER='gcc' +else + CFLAGS='-g -O2' + LDFLAGS='-g -O2' + COMPILER='clang' +fi + rm -f version.h rm -f include.mk case $TARGET in @@ -194,7 +206,7 @@ cat > include.mk <master_key_.length_ = key_length/8; @@ -213,7 +213,7 @@ int key_derivation_generate_master_salt(key_derivation_t* kd, const char* passph #ifndef USE_SSL_CRYPTO gcry_md_hash_buffer(GCRY_MD_SHA1, digest.buf_, passphrase, strlen(passphrase)); #else - SHA1(passphrase, strlen(passphrase), digest.buf_); + SHA1((const u_int8_t*)passphrase, strlen(passphrase), digest.buf_); #endif kd->master_salt_.length_ = salt_length/8; @@ -385,9 +385,8 @@ void key_derivation_aesctr_close(key_derivation_t* kd) return; if(kd->params_) { - key_derivation_aesctr_param_t* params = kd->params_; - #ifndef USE_SSL_CRYPTO + key_derivation_aesctr_param_t* params = kd->params_; if(params->handle_) gcry_cipher_close(params->handle_); #endif -- cgit v1.2.3