summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2012-09-25 11:55:47 +0000
committerChristian Pointner <equinox@anytun.org>2012-09-25 11:55:47 +0000
commitb85d2641b20159f25a4416d7c1322ec98c04eb0c (patch)
tree42779543116fee6f8963e1b172e767871bd1aed8 /src
parent-Wall cleanup (diff)
added clang support
Diffstat (limited to 'src')
-rw-r--r--src/cipher.c6
-rwxr-xr-xsrc/configure20
-rw-r--r--src/key_derivation.c7
3 files changed, 21 insertions, 12 deletions
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(&params->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 <<EOF
# use ./configure instead
TARGET := $TARGET
-CC := gcc
+CC := $COMPILER
CFLAGS := $CFLAGS
LDFLAGS := $LDFLAGS
STRIP := strip
diff --git a/src/key_derivation.c b/src/key_derivation.c
index a01695b..8e6e95a 100644
--- a/src/key_derivation.c
+++ b/src/key_derivation.c
@@ -158,7 +158,7 @@ int key_derivation_generate_master_key(key_derivation_t* kd, const char* passphr
#ifndef USE_SSL_CRYPTO
gcry_md_hash_buffer(GCRY_MD_SHA256, digest.buf_, passphrase, strlen(passphrase));
#else
- SHA256(passphrase, strlen(passphrase), digest.buf_);
+ SHA256((const u_int8_t*)passphrase, strlen(passphrase), digest.buf_);
#endif
kd->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