diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-04-10 23:32:45 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-04-10 23:32:45 +0200 |
commit | 10fd2098416c78958a199f31480bd363eaa76212 (patch) | |
tree | a1dafd44090d2aea4180f6fc5d4205dc698a8063 /common | |
parent | 8f747e26fb8629ea290f88cf70112770e90a168a (diff) | |
download | eurephia-10fd2098416c78958a199f31480bd363eaa76212.tar.gz eurephia-10fd2098416c78958a199f31480bd363eaa76212.tar.xz eurephia-10fd2098416c78958a199f31480bd363eaa76212.zip |
Rewritten common/passwd.c and utils/benchmark.c
Make them work without the need of defining BENCHMARK during compilation
Diffstat (limited to 'common')
-rw-r--r-- | common/passwd.c | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/common/passwd.c b/common/passwd.c index 276a4a3..7887efb 100644 --- a/common/passwd.c +++ b/common/passwd.c @@ -126,7 +126,7 @@ int gen_randsaltstr(eurephiaCTX *ctx, char *saltstr, int len) { return 1; } -static char *sha512_crypt_r(const char *key, const char *salt, size_t maxrounds_cfg, char *buffer, int buflen) +inline char *sha512_crypt_r(const char *key, const char *salt, size_t maxrounds_cfg, char *buffer, int buflen) { unsigned char alt_result[64] __attribute__ ((__aligned__ (__alignof__ (uint64_t)))); @@ -497,44 +497,3 @@ char *eurephia_quick_hash(const char *salt, const char *pwd) { return ret; } - - -#ifdef BENCHMARK -// This function is only used by the eurephia_init program to benchmark -// the SHA512 performance, to suggest recommended minimum and maximum -// hashing rounds. -void benchmark_hashing(int rounds) { - - char *buffer = NULL; - char *pwdhash = NULL; - static char randstr[34]; - static int rand_set = 0; - char pwdsalt[64], saltstr[32]; - - // Get random data for our salt - if( rand_set == 0 ) { - memset(&randstr, 0, 34); - if( gen_randsaltstr(NULL, randstr, 32) == 0 ) { - fprintf(stderr, "Could not retrieve enough random data for hashing"); - exit(19); - }; - rand_set = 1; - } - - // Prepare a salt package - memset(&pwdsalt, 0, 64); - memset(&saltstr, 0, 32); - pack_saltinfo(saltstr, 30, rounds, 32, "benchmarkpassword"); - strncpy(pwdsalt, saltstr, strlen(saltstr)); - strncat(pwdsalt, randstr, 62 - strlen(saltstr)); - memset(&randstr, 0, 32); - - buffer = (char *) malloc(1024); - assert( buffer != NULL ); - memset(buffer, 0, 1024); - - pwdhash = sha512_crypt_r("benchmarkpassword", pwdsalt, ROUNDS_MAX, buffer, 1024); - - free_nullsafe(buffer); -} -#endif |