X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=common%2Fauth.c;fp=common%2Fauth.c;h=a4a40cd001f34f0a0b103d9732fc402a79ba575d;hb=65363bdbdec43b2efd906d8fa848fc4d69c529d2;hp=a048c2f0836397bfb65e93b23017630313c560f2;hpb=c1465d733ef80a19bff0056935dbf15539f122c7;p=blerg.git diff --git a/common/auth.c b/common/auth.c index a048c2f..a4a40cd 100644 --- a/common/auth.c +++ b/common/auth.c @@ -7,9 +7,11 @@ #include #include #include +#include #include #include "config.h" #include "configuration.h" +#include "database.h" #include "auth.h" #include "util.h" #include "md5.h" @@ -17,7 +19,7 @@ int auth_set_password(const char *username, const char *password) { char filename[FILENAME_MAX]; unsigned char pwhash[SCRYPT_OUTPUT_SIZE]; - unsigned char salt[SCRYPT_SALT_SIZE]; + uint8_t salt[SCRYPT_SALT_SIZE]; int fd, n, r; if (!valid_name(username) || !blerg_exists(username)) @@ -36,7 +38,7 @@ int auth_set_password(const char *username, const char *password) { read(fd, salt, SCRYPT_SALT_SIZE); close(fd); - r = crypto_scrypt(password, n, salt, SCRYPT_SALT_SIZE, SCRYPT_N, SCRYPT_r, SCRYPT_p, pwhash, SCRYPT_OUTPUT_SIZE); + r = crypto_scrypt((const uint8_t *)password, n, salt, SCRYPT_SALT_SIZE, SCRYPT_N, SCRYPT_r, SCRYPT_p, pwhash, SCRYPT_OUTPUT_SIZE); if (r != 0) { fprintf(stderr, "Failure in scrypt for %s\n", username); return 0; @@ -109,7 +111,7 @@ int auth_get_password(const char *username, char *password) { return 1; } -int auth_get_salt(const char *username, char *salt) { +int auth_get_salt(const char *username, uint8_t *salt) { char filename[FILENAME_MAX]; int fd, len; @@ -128,7 +130,7 @@ int auth_get_salt(const char *username, char *salt) { int auth_check_password_v0(const char *username, const char *password) { char epw[MD5_DIGEST_SIZE + 1]; - unsigned char givenpw[MD5_DIGEST_SIZE]; + char givenpw[MD5_DIGEST_SIZE]; struct MD5Context ctx; if (auth_get_password(username, epw) == 0) @@ -137,7 +139,7 @@ int auth_check_password_v0(const char *username, const char *password) { MD5Init(&ctx); MD5Update(&ctx, username, strlen(username)); MD5Update(&ctx, password, strlen(password)); - MD5Final(givenpw, &ctx); + MD5Final((unsigned char *)givenpw, &ctx); if (strncmp(givenpw, epw, MD5_DIGEST_SIZE) == 0) return 1; @@ -147,7 +149,7 @@ int auth_check_password_v0(const char *username, const char *password) { int auth_check_password_v1(const char *username, const char *password) { unsigned char epw[SCRYPT_OUTPUT_SIZE]; - unsigned char esalt[SCRYPT_SALT_SIZE]; + uint8_t esalt[SCRYPT_SALT_SIZE]; unsigned char givenpw[SCRYPT_OUTPUT_SIZE]; int r;