diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-04 15:24:05 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-04 15:24:05 +0200 |
commit | dea39103b369f0903be326c505d36a9d489a0c1e (patch) | |
tree | 97a114b3fe7667c07678abdf528530efae8bfea8 /common/passwd.c | |
parent | 856ecfcec0956d3269f2b119836ec31908d02836 (diff) | |
download | eurephia-dea39103b369f0903be326c505d36a9d489a0c1e.tar.gz eurephia-dea39103b369f0903be326c505d36a9d489a0c1e.tar.xz eurephia-dea39103b369f0903be326c505d36a9d489a0c1e.zip |
More comments in common/
Diffstat (limited to 'common/passwd.c')
-rw-r--r-- | common/passwd.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/common/passwd.c b/common/passwd.c index 70fc3d3..3a887c7 100644 --- a/common/passwd.c +++ b/common/passwd.c @@ -63,18 +63,17 @@ #include "passwd.h" #include "sha512.h" +#define DEFAULT_SALT_LEN 32 /**< Default hash salt length */ +#define MAX_SALT_LEN 255 /**< Maximum hash salt length */ -// default and maximum allowed salt length -#define DEFAULT_SALT_LEN 32 -#define MAX_SALT_LEN 255 -// When randomising rounds, this is the default scope -#define ROUNDS_DEFAULT_MIN 5000 -#define ROUNDS_DEFAULT_MAX 7500 -// Min/Max rounds boundaries -#define ROUNDS_MIN 1000 -#define ROUNDS_MAX 999999999 - -/* Table with characters for base64 transformation. */ +#define ROUNDS_DEFAULT_MIN 5000 /**< Default minimum hashing rounds (may be changed in runtime config)*/ +#define ROUNDS_DEFAULT_MAX 7500 /**< Default maximum hashing rounds (may be changed in runtime config)*/ +#define ROUNDS_MIN 1000 /**< Absolutely minimum hashing rounds */ +#define ROUNDS_MAX 999999999 /**< Absolutely maximum hashing rounds */ + +/** + *Table with characters for base64 transformation. +*/ static const char b64t[64] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -179,6 +178,26 @@ int gen_randsaltstr(eurephiaCTX *ctx, char *saltstr, int len) { /** + * Internal function used by sha512_crytp_r(). Converts 24 bits of data into base64 format. + * + * @param B2 + * @param B1 + * @param B0 + * @param N + */ +#define b64_from_24bit(B2, B1, B0, N) \ + do { \ + unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0); \ + int n = (N); \ + while (n-- > 0 && buflen > 0) { \ + *cp++ = b64t[w & 0x3f]; \ + --buflen; \ + w >>= 6; \ + } \ + } while (0) + + +/** * Internal SHA512 hashing function. Does the real hashing job * * @param key The password of the user @@ -370,17 +389,6 @@ inline char *sha512_crypt_r(const char *key, const char *salt, size_t maxrounds_ cp = __stpncpy (buffer, salt, MIN ((size_t) MAX (0, buflen), salt_len)); buflen -= MIN ((size_t) MAX (0, buflen), salt_len); -#define b64_from_24bit(B2, B1, B0, N) \ - do { \ - unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0); \ - int n = (N); \ - while (n-- > 0 && buflen > 0) { \ - *cp++ = b64t[w & 0x3f]; \ - --buflen; \ - w >>= 6; \ - } \ - } while (0) - b64_from_24bit (alt_result[0], alt_result[21], alt_result[42], 4); b64_from_24bit (alt_result[22], alt_result[43], alt_result[1], 4); b64_from_24bit (alt_result[44], alt_result[2], alt_result[23], 4); |