Skip to content

Commit 40ba7c7

Browse files
authored
Merge pull request #2582 from babarosaM33/master
ppbloom:remove unnecessay bloom_check
2 parents 6b5025b + 9576dce commit 40ba7c7

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/aead.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,13 +653,13 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
653653

654654
memcpy(cipher_ctx->salt, cipher_ctx->chunk->data, salt_len);
655655

656-
aead_cipher_ctx_set_key(cipher_ctx, 0);
657-
658656
if (ppbloom_check((void *)cipher_ctx->salt, salt_len) == 1) {
659657
LOGE("crypto: AEAD: repeat salt detected");
660658
return CRYPTO_ERROR;
661659
}
662660

661+
aead_cipher_ctx_set_key(cipher_ctx, 0);
662+
663663
memmove(cipher_ctx->chunk->data, cipher_ctx->chunk->data + salt_len,
664664
cipher_ctx->chunk->len - salt_len);
665665
cipher_ctx->chunk->len -= salt_len;
@@ -695,11 +695,10 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
695695

696696
// Add the salt to bloom filter
697697
if (cipher_ctx->init == 1) {
698-
if (ppbloom_check((void *)cipher_ctx->salt, salt_len) == 1) {
698+
if (ppbloom_add((void *)cipher_ctx->salt, salt_len) == 1) {
699699
LOGE("crypto: AEAD: repeat salt detected");
700700
return CRYPTO_ERROR;
701701
}
702-
ppbloom_add((void *)cipher_ctx->salt, salt_len);
703702
cipher_ctx->init = 2;
704703
}
705704

src/ppbloom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ppbloom_add(const void *buffer, int len)
8080
{
8181
int err;
8282
err = bloom_add(ppbloom + current, buffer, len);
83-
if (err == -1)
83+
if (err == -1 || err == 1)
8484
return err;
8585

8686
bloom_count[current]++;

0 commit comments

Comments
 (0)