Fix crypt passwords

This commit is contained in:
Vladimir Dubrovin 2026-05-08 19:00:14 +03:00
parent b1d21cbdca
commit 6286bfcd6e
3 changed files with 6 additions and 10 deletions

View File

@ -202,15 +202,13 @@ unsigned char * mycrypt(const unsigned char *pw, const unsigned char *salt, unsi
magic = (unsigned char *)"$3$"; magic = (unsigned char *)"$3$";
{ {
blake2b_state S; blake2b_state S;
unsigned char _b2tmp[64]; if(blake2b_init(&S, MD5_SIZE) != 0 ||
if(blake2b_init(&S, 64) != 0 ||
blake2b_update(&S, pw, strlen((char *)pw) + 1) != 0 || blake2b_update(&S, pw, strlen((char *)pw) + 1) != 0 ||
blake2b_update(&S, sp, sl) != 0 || blake2b_update(&S, sp, sl) != 0 ||
blake2b_final(&S, _b2tmp, 64) != 0) { blake2b_final(&S, final, MD5_SIZE) != 0) {
*passwd = 0; *passwd = 0;
return NULL; return NULL;
} }
memcpy(final, _b2tmp, MD5_SIZE);
} }
} }
else { else {

View File

@ -244,7 +244,7 @@ int strongauth(struct clientparam * param){
return 6; return 6;
} }
case CR: case CR:
if (mycrypt(param->password, (unsigned char *)pass, buf) && if (mycrypt(param->password, (unsigned char *)pass + 1, buf) &&
!strcmp(pass + 1, (char *)buf)) !strcmp(pass + 1, (char *)buf))
return 0; return 0;
else return 7; else return 7;

View File

@ -559,13 +559,11 @@ static int h_users(int argc, unsigned char **argv){
if((unsigned)l >= pwl_table.recsize) { if((unsigned)l >= pwl_table.recsize) {
if(*pass != CL) continue; if(*pass != CL) continue;
blake2b_state S; blake2b_state S;
unsigned char _b2tmp[64];
unsigned hashsz; unsigned hashsz;
hashsz = pwl_table.recsize - 1 < 64 ? pwl_table.recsize - 1 : 64; hashsz = pwl_table.recsize - 1 < 64 ? pwl_table.recsize - 1 : 64;
blake2b_init(&S, 64); blake2b_init(&S, hashsz);
blake2b_update(&S, pw[1], l + 1); blake2b_update(&S, pw[1], l + 1);
blake2b_final(&S, _b2tmp, 64); blake2b_final(&S, pass+1, hashsz);
memcpy((uint8_t *)(pass + 1), _b2tmp, hashsz);
} else { } else {
memcpy(pass + 1, pw[1], l); memcpy(pass + 1, pw[1], l);
} }