Skip to content

Commit

Permalink
Ignore rarely-hit ElGamal code chunk in coverage report.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 authored and ronaldtse committed Mar 18, 2024
1 parent 6a8c9a5 commit ed0c871
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/crypto/elgamal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@ elgamal_generate(rnp::RNG *rng, pgp_eg_key_t *key, size_t keybits)
goto end;
}
if (bn_num_bytes(*y) < BITS_TO_BYTES(keybits)) {
/* This code chunk is rarely hit, so ignoring it for the coverage report:
* LCOV_EXCL_START */
botan_privkey_destroy(key_priv);
goto start;
/* LCOV_EXCL_END */
}

if (botan_privkey_get_field(BN_HANDLE_PTR(p), key_priv, "p") ||
Expand Down
6 changes: 6 additions & 0 deletions src/lib/crypto/elgamal_ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,14 @@ elgamal_generate(rnp::RNG *rng, pgp_eg_key_t *key, size_t keybits)
goto done;
}
if (y.bytes() != BITS_TO_BYTES(keybits)) {
/* This code chunk is rarely hit, so ignoring it for the coverage report:
* LCOV_EXCL_START */
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
EVP_PKEY_free(pkey);
pkey = NULL;
goto start;
/* LCOV_EXCL_END */
}

rnp::bn p;
Expand All @@ -418,11 +421,14 @@ elgamal_generate(rnp::RNG *rng, pgp_eg_key_t *key, size_t keybits)
goto done;
}
if (BITS_TO_BYTES(BN_num_bits(DH_get0_pub_key(dh))) != BITS_TO_BYTES(keybits)) {
/* This code chunk is rarely hit, so ignoring it for the coverage report:
* LCOV_EXCL_START */
EVP_PKEY_CTX_free(ctx);
ctx = NULL;
EVP_PKEY_free(pkey);
pkey = NULL;
goto start;
/* LCOV_EXCL_END */
}

const bignum_t *p;
Expand Down

0 comments on commit ed0c871

Please sign in to comment.