Skip to content

Commit

Permalink
Merge pull request #2582 from babarosaM33/master
Browse files Browse the repository at this point in the history
ppbloom:remove unnecessay bloom_check
  • Loading branch information
madeye authored Jan 13, 2020
2 parents 6b5025b + 9576dce commit 40ba7c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,13 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)

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

aead_cipher_ctx_set_key(cipher_ctx, 0);

if (ppbloom_check((void *)cipher_ctx->salt, salt_len) == 1) {
LOGE("crypto: AEAD: repeat salt detected");
return CRYPTO_ERROR;
}

aead_cipher_ctx_set_key(cipher_ctx, 0);

memmove(cipher_ctx->chunk->data, cipher_ctx->chunk->data + salt_len,
cipher_ctx->chunk->len - salt_len);
cipher_ctx->chunk->len -= salt_len;
Expand Down Expand Up @@ -695,11 +695,10 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)

// Add the salt to bloom filter
if (cipher_ctx->init == 1) {
if (ppbloom_check((void *)cipher_ctx->salt, salt_len) == 1) {
if (ppbloom_add((void *)cipher_ctx->salt, salt_len) == 1) {
LOGE("crypto: AEAD: repeat salt detected");
return CRYPTO_ERROR;
}
ppbloom_add((void *)cipher_ctx->salt, salt_len);
cipher_ctx->init = 2;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ppbloom.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ppbloom_add(const void *buffer, int len)
{
int err;
err = bloom_add(ppbloom + current, buffer, len);
if (err == -1)
if (err == -1 || err == 1)
return err;

bloom_count[current]++;
Expand Down

0 comments on commit 40ba7c7

Please sign in to comment.