const char *salt = strchr(pw, '\0')+1;
char *hash = password_crypt(pw, salt);
int rv = !hash || strcmp(hash, salt) != 0;
- // TODO: remove cipher migration
- if (!rv && salt[1] == '6') {
- const char *getdatafile(const char *fn);
- FILE *f = fopen(getdatafile("newhash.txt"), "ab" FOPEN_CLOEXEC);
- if (f) {
- fprintf(f, "%s:", hash);
- memset(hash, 0, strlen(hash));
- hash = password_hash(pw);
- fprintf(f, "%s\n", hash ? hash : "*");
- fclose(f);
- }
- }
if (hash)
memset(hash, 0, strlen(hash));
return rv;
#include <string.h>
#ifndef _WIN32
#include <unistd.h>
-#include <crypt.h>
#else
#include <bcrypt.h>
#endif
static char output[128];
if (setting[0] == '$' && setting[1] == '2' && setting[3] == '$')
return crypt_blowfish(key, setting, output);
-#ifndef _WIN32
- else if (setting[0] == '$' && setting[1] == '6' && setting[2] == '$')
- return crypt(key, setting);
-#endif
else
return strcpy(output, "*");
}
salt[ 8+4*5] = b64[ubytes[0+3*5]<<4 & 63];
salt[ 9+4*5] = 0;
} else {
- salt[0] = '$';
- salt[1] = '6';
- salt[2] = '$';
- for (int i = 0; i < 16; i++)
- salt[3+i] = b64[ubytes[i]&63];
- salt[19] = '\0';
+ salt[0] = '\0';
}
memset(ubytes, 0, 16);