mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-17 20:54:01 +00:00
Refine the ppbloom filter
This commit is contained in:
+6
-3
@@ -622,9 +622,6 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
|
||||
cipher_ctx->init = 1;
|
||||
|
||||
} else if (cipher_ctx->init == 1) {
|
||||
ppbloom_add((void *)cipher_ctx->salt, salt_len);
|
||||
cipher_ctx->init = 2;
|
||||
}
|
||||
|
||||
size_t plen = 0;
|
||||
@@ -652,6 +649,12 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
memcpy(ciphertext->data, plaintext->data, plaintext->len);
|
||||
ciphertext->len = plaintext->len;
|
||||
|
||||
// Add the salt to bloom filter
|
||||
if (cipher_ctx->init == 1) {
|
||||
ppbloom_add((void *)cipher_ctx->salt, salt_len);
|
||||
cipher_ctx->init = 2;
|
||||
}
|
||||
|
||||
return CRYPTO_OK;
|
||||
}
|
||||
|
||||
|
||||
+8
-5
@@ -553,11 +553,6 @@ stream_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
return CRYPTO_ERROR;
|
||||
}
|
||||
}
|
||||
} else if (cipher_ctx->init == 1) {
|
||||
if (cipher->method >= RC4_MD5) {
|
||||
ppbloom_add((void *)cipher_ctx->nonce, cipher->nonce_len);
|
||||
cipher_ctx->init = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (ciphertext->len <= 0)
|
||||
@@ -601,6 +596,14 @@ stream_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
memcpy(ciphertext->data, plaintext->data, plaintext->len);
|
||||
ciphertext->len = plaintext->len;
|
||||
|
||||
// Add to bloom filter
|
||||
if (cipher_ctx->init == 1) {
|
||||
if (cipher->method >= RC4_MD5) {
|
||||
ppbloom_add((void *)cipher_ctx->nonce, cipher->nonce_len);
|
||||
cipher_ctx->init = 2;
|
||||
}
|
||||
}
|
||||
|
||||
return CRYPTO_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user