mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Use blake2 hashsize
This commit is contained in:
1 parent
6286bfcd6e
commit
95029e9e41
2 files changed
+8
-17
No files matched your search
+6
-13
@@ -10,11 +10,9 @@ 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 {
|
||||
unsigned char _b2tmp[64];
|
||||
blake2b_init(&S, 64);
|
||||
blake2b_init(&S, ht->hash_size);
|
||||
blake2b_update(&S, index, strlen((const char*)index) + 1);
|
||||
blake2b_final(&S, _b2tmp, 64);
|
||||
memcpy(hash, _b2tmp, ht->hash_size);
|
||||
blake2b_final(&S, hash, ht->hash_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +49,7 @@ 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 {
|
||||
unsigned char _b2tmp[64];
|
||||
blake2b_init(&S, 64);
|
||||
blake2b_init(&S, ht->hash_size);
|
||||
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);
|
||||
@@ -63,10 +60,8 @@ static void param2hash_add(const struct hashtable *ht, void *index, uint8_t *has
|
||||
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);
|
||||
blake2b_final(&S, hash, ht->hash_size);
|
||||
}
|
||||
memcpy(param->hash, hash, ht->hash_size);
|
||||
}
|
||||
|
||||
void param2hash_search(const struct hashtable *ht, void *index, uint8_t *hash){
|
||||
@@ -78,14 +73,12 @@ 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;
|
||||
unsigned char _b2tmp[64];
|
||||
blake2b_init(&S, 64);
|
||||
blake2b_init(&S, ht->hash_size);
|
||||
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);
|
||||
blake2b_final(&S, hash, ht->hash_size);
|
||||
}
|
||||
|
||||
struct hashtable dns_table = {char_index2hash, char_index2hash, 4, 32};
|
||||
|
||||
Reference in new issue
Block a user