mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Revert usage of OpenSSL blake2 implementation
This commit is contained in:
1 parent
6963af7614
commit
8c638fcaff
7 files changed
+52
-115
No files matched your search
+28
-22
@@ -1,5 +1,5 @@
|
||||
#include "proxy.h"
|
||||
#include "blake2_compat.h"
|
||||
#include "libs/blake2.h"
|
||||
|
||||
|
||||
static void char_index2hash(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||
@@ -10,9 +10,11 @@ static void char_index2hash(const struct hashtable *ht, void *index, uint8_t *ha
|
||||
memset(hash, 0, ht->hash_size);
|
||||
if(len <= ht->hash_size) memcpy(hash, index, len);
|
||||
else {
|
||||
blake2b_init_3p(&S, ht->hash_size);
|
||||
blake2b_update_3p(&S, index, strlen((const char*)index) + 1);
|
||||
blake2b_final_3p(&S, hash, ht->hash_size);
|
||||
unsigned char _b2tmp[64];
|
||||
blake2b_init(&S, 64);
|
||||
blake2b_update(&S, index, strlen((const char*)index) + 1);
|
||||
blake2b_final(&S, _b2tmp, 64);
|
||||
memcpy(hash, _b2tmp, ht->hash_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,18 +51,20 @@ static void param2hash_add(const struct hashtable *ht, void *index, uint8_t *has
|
||||
if((type & 2048)){ memcpy(hash + offset, SAPORT(¶m->srv->intsa), p2len); offset += 2; }
|
||||
}
|
||||
else {
|
||||
blake2b_init_3p(&S, ht->hash_size);
|
||||
if((type & 2) && param->username)blake2b_update_3p(&S, param->username, ulen);
|
||||
if((type & 4) && param->password)blake2b_update_3p(&S, param->password, plen);
|
||||
if((type & 1) && !(type & 8))blake2b_update_3p(&S, SAADDR(¶m->sincr), a1len);
|
||||
if((type & 16))blake2b_update_3p(&S, ¶m->srv->acl, acllen);
|
||||
if((type & 64))blake2b_update_3p(&S, SAADDR(¶m->req), a2len);
|
||||
if((type & 128))blake2b_update_3p(&S, SAPORT(¶m->req), 2);
|
||||
if((type & 256) && param->hostname)blake2b_update_3p(&S, param->hostname, hlen);
|
||||
if((type & 512))blake2b_update_3p(&S, ¶m->operation, sizeof(param->operation));
|
||||
if((type & 1024))blake2b_update_3p(&S, SAADDR(¶m->srv->intsa), a3len);
|
||||
if((type & 2048))blake2b_update_3p(&S, SAPORT(¶m->srv->intsa), 2);
|
||||
blake2b_final_3p(&S, hash, ht->hash_size);
|
||||
unsigned char _b2tmp[64];
|
||||
blake2b_init(&S, 64);
|
||||
if((type & 2) && param->username)blake2b_update(&S, param->username, ulen);
|
||||
if((type & 4) && param->password)blake2b_update(&S, param->password, plen);
|
||||
if((type & 1) && !(type & 8))blake2b_update(&S, SAADDR(¶m->sincr), a1len);
|
||||
if((type & 16))blake2b_update(&S, ¶m->srv->acl, acllen);
|
||||
if((type & 64))blake2b_update(&S, SAADDR(¶m->req), a2len);
|
||||
if((type & 128))blake2b_update(&S, SAPORT(¶m->req), 2);
|
||||
if((type & 256) && param->hostname)blake2b_update(&S, param->hostname, hlen);
|
||||
if((type & 512))blake2b_update(&S, ¶m->operation, sizeof(param->operation));
|
||||
if((type & 1024))blake2b_update(&S, SAADDR(¶m->srv->intsa), a3len);
|
||||
if((type & 2048))blake2b_update(&S, SAPORT(¶m->srv->intsa), 2);
|
||||
blake2b_final(&S, _b2tmp, 64);
|
||||
memcpy(hash, _b2tmp, ht->hash_size);
|
||||
}
|
||||
memcpy(param->hash, hash, ht->hash_size);
|
||||
}
|
||||
@@ -74,12 +78,14 @@ void param2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||
static void udpparam2hash(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||
struct clientparam *param = (struct clientparam *)index;
|
||||
blake2b_state S;
|
||||
blake2b_init_3p(&S, ht->hash_size);
|
||||
blake2b_update_3p(&S, SAADDR(¶m->srv->intsa), SAADDRLEN(¶m->srv->intsa));
|
||||
blake2b_update_3p(&S, SAPORT(¶m->srv->intsa), 2);
|
||||
blake2b_update_3p(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
||||
blake2b_update_3p(&S, SAPORT(¶m->sincr), 2);
|
||||
blake2b_final_3p(&S, hash, ht->hash_size);
|
||||
unsigned char _b2tmp[64];
|
||||
blake2b_init(&S, 64);
|
||||
blake2b_update(&S, SAADDR(¶m->srv->intsa), SAADDRLEN(¶m->srv->intsa));
|
||||
blake2b_update(&S, SAPORT(¶m->srv->intsa), 2);
|
||||
blake2b_update(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
||||
blake2b_update(&S, SAPORT(¶m->sincr), 2);
|
||||
blake2b_final(&S, _b2tmp, 64);
|
||||
memcpy(hash, _b2tmp, ht->hash_size);
|
||||
}
|
||||
|
||||
struct hashtable dns_table = {char_index2hash, char_index2hash, 4, 32};
|
||||
|
||||
Reference in new issue
Block a user