diff options
author | Christian Pointner <equinox@anytun.org> | 2009-01-04 11:39:22 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-01-04 11:39:22 +0000 |
commit | 602ed60d0b4019377634fb95e922f2dd246c1e2a (patch) | |
tree | 0050e969b3f9823a5d4d9f2e8f41234d38448b12 /src/key_derivation.c | |
parent | some cleanup @ cipher, auth_algo and key derivation (diff) |
added NO_LIBGMP and NO_CRYPT to build a daemon without cryptosupport
NOTE: with NO_LIBGMP the cipher and the keyderivation don't work until now
Diffstat (limited to 'src/key_derivation.c')
-rw-r--r-- | src/key_derivation.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/key_derivation.c b/src/key_derivation.c index dbbd1d2..2911272 100644 --- a/src/key_derivation.c +++ b/src/key_derivation.c @@ -41,8 +41,9 @@ #include <stdlib.h> #include <string.h> +#ifndef NO_LIBGMP #include <gmp.h> - +#endif int key_derivation_init(key_derivation_t* kd, const char* type, int8_t ld_kdr, u_int8_t* key, u_int32_t key_len, u_int8_t* salt, u_int32_t salt_len) { @@ -217,15 +218,17 @@ int key_derivation_aesctr_calc_ctr(key_derivation_t* kd, key_store_t* result, sa } result->r_ = r; - mpz_t ctr, key_id; - mpz_init2(ctr, 128); - mpz_init2(key_id, 128); - int faked_msb = 0; if(!kd->master_salt_.buf_[0]) { kd->master_salt_.buf_[0] = 1; faked_msb = 1; } + +#ifndef NO_LIBGMP + mpz_t ctr, key_id; + mpz_init2(ctr, 128); + mpz_init2(key_id, 128); + mpz_import(ctr, kd->master_salt_.length_, 1, 1, 0, 0, kd->master_salt_.buf_); mpz_set_ui(key_id, label); @@ -242,6 +245,9 @@ int key_derivation_aesctr_calc_ctr(key_derivation_t* kd, key_store_t* result, sa if(result->key_.buf_) free(result->key_.buf_); result->key_.buf_ = mpz_export(NULL, (size_t*)&(result->key_.length_), 1, 1, 0, 0, ctr); + mpz_clear(ctr); + mpz_clear(key_id); +#endif #ifndef ANYTUN_02_COMPAT if(faked_msb) { @@ -250,9 +256,6 @@ int key_derivation_aesctr_calc_ctr(key_derivation_t* kd, key_store_t* result, sa } #endif - mpz_clear(ctr); - mpz_clear(key_id); - return 1; } |