From 6286bfcd6ebab8bafad222550b8a97201f3687f2 Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Fri, 8 May 2026 19:00:14 +0300 Subject: [PATCH] Fix crypt passwords --- src/3proxy_crypt.c | 6 ++---- src/auth.c | 4 ++-- src/conf.c | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/3proxy_crypt.c b/src/3proxy_crypt.c index e421cd1..b936ee7 100644 --- a/src/3proxy_crypt.c +++ b/src/3proxy_crypt.c @@ -202,15 +202,13 @@ unsigned char * mycrypt(const unsigned char *pw, const unsigned char *salt, unsi magic = (unsigned char *)"$3$"; { blake2b_state S; - unsigned char _b2tmp[64]; - if(blake2b_init(&S, 64) != 0 || + if(blake2b_init(&S, MD5_SIZE) != 0 || blake2b_update(&S, pw, strlen((char *)pw) + 1) != 0 || blake2b_update(&S, sp, sl) != 0 || - blake2b_final(&S, _b2tmp, 64) != 0) { + blake2b_final(&S, final, MD5_SIZE) != 0) { *passwd = 0; return NULL; } - memcpy(final, _b2tmp, MD5_SIZE); } } else { diff --git a/src/auth.c b/src/auth.c index 5d7ea2c..d6f1eb0 100644 --- a/src/auth.c +++ b/src/auth.c @@ -244,9 +244,9 @@ int strongauth(struct clientparam * param){ return 6; } case CR: - if (mycrypt(param->password, (unsigned char *)pass, buf) && + if (mycrypt(param->password, (unsigned char *)pass + 1, buf) && !strcmp(pass + 1, (char *)buf)) - return 0; + return 0; else return 7; #ifdef WITH_SSL case NT: diff --git a/src/conf.c b/src/conf.c index 7e9502e..7a8359d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -559,13 +559,11 @@ static int h_users(int argc, unsigned char **argv){ if((unsigned)l >= pwl_table.recsize) { if(*pass != CL) continue; blake2b_state S; - unsigned char _b2tmp[64]; unsigned hashsz; 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_final(&S, _b2tmp, 64); - memcpy((uint8_t *)(pass + 1), _b2tmp, hashsz); + blake2b_final(&S, pass+1, hashsz); } else { memcpy(pass + 1, pw[1], l); }