Skip to content

test(coverage): exercise the encryption path (sec001+sec002) in the subset - #84

Merged
gburd merged 1 commit into
masterfrom
agent/crypto-cov
Jul 29, 2026
Merged

test(coverage): exercise the encryption path (sec001+sec002) in the subset#84
gburd merged 1 commit into
masterfrom
agent/crypto-cov

Conversation

@gburd

@gburd gburd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Raises coverage of the cold crypto/hmac surface by running an encrypted workload in the bounded coverage subset.

Why it was cold

crypto/ + hmac/ sat cold in run_coverage.sh's subset because no subset test opened an encrypted env or db. AES page/log encryption, the HMAC-SHA1 password/checksum path, and the mt19937 IV generator (__db_generate_iv) only run under DB_ENV->set_encrypt(passwd, DB_ENCRYPT_AES) + DB->set_flags(DB_ENCRYPT).

What changed

Added the two already-registered encryption Tcl tests to the default COV_TESTS (sec001: sec002:). No new Tcl written.

  • sec001 — encryption interface: create/open/join encrypted env+db, DB_ENCRYPT_ANY, and every failure branch (empty password, algorithm-not-supplied, join-mismatch, wrong-length password, wrong password, open-encrypted-with-no-key). Drives cipher setup + auth-failure branches in crypto.c and key derivation in aes_method.c.
  • sec002 — page-encryption round-trip (AES CBC block encrypt/decrypt + IV generation) and tamper paths (meta-page scribble / root-page swap → HMAC-SHA1 metadata page checksum errorDB_RUNRECOVERY).

run_secmethod/run_secenv (full access-method test twice under encryption) add only ~1–2 pp over sec001+sec002 for ~double the runtime, so they are deliberately left out.

Coverage before → after (bounded subset)

file before after (line% / br%)
crypto/mersenne/mt19937db.c 0.0 95.6 / 56.2
hmac/hmac.c 10.4 91.0 / 80.0
crypto/rijndael/rijndael-alg-fst.c 18.8 83.5 / 55.0
crypto/crypto.c 50.7 77.9 / 60.5
crypto/aes_method.c 27.8 44.3 / 36.6
crypto/rijndael/rijndael-api-fst.c 6.3 29.8 / 21.9
hmac/sha1.c 97.4 98.7 / 72.7

Ceilings (not bugs)

  • rijndael-api-fst.c caps at ~30% by design: aes_method.c only ever calls __db_blockEncrypt/__db_blockDecrypt with MODE_CBC, so the ECB/CFB1 branches and the entire __db_padEncrypt/__db_padDecrypt/__db_cipherUpdateRounds halves are dead code from BDB's point of view — unreachable by any Tcl workload.
  • aes_method.c's remaining cold lines are the HAVE_CRYPTO_IPP alternate-backend blocks (this build is not IPP) and the __aes_err message table + EAGAIN branches, which fire only on an internal cipher error (bad key length / bad state) not reachable through the public API without fault injection.

Validation

Built + ran in the nix dev shell (--enable-debug --enable-test, HAVE_CRYPTO 1, non-IPP). has_crypto=1 in the harness. Both tests PASS through the exact test:arg loop mechanism run_coverage.sh uses. No real encryption/decryption or wrong-password bug surfaced — every error branch behaved as the tests assert.

No engine code touched; docs + coverage wiring only.

crypto/ and hmac/ were the coldest reachable surface in the bounded
coverage subset because no other subset test opens an encrypted env or
db -- AES page/log encryption, the HMAC-SHA1 password/checksum path, and
the mt19937 IV generator only run under
DB_ENV->set_encrypt(DB_ENCRYPT_AES) + DB->set_flags(DB_ENCRYPT).

Add the already-registered sec001 (encryption interface + wrong/empty
password + algorithm-mismatch error branches) and sec002 (page-encryption
round-trip + meta/root-page checksum-error -> DB_RUNRECOVERY paths) to the
default COV_TESTS. No new Tcl written.

Measured lift (subset baseline -> with sec001+sec002):
  crypto/mersenne/mt19937db.c        0.0  -> 95.6 line / 56.2 br
  hmac/hmac.c                       10.4  -> 91.0 line / 80.0 br
  crypto/rijndael/rijndael-alg-fst.c 18.8 -> 83.5 line / 55.0 br
  crypto/crypto.c                   50.7  -> 77.9 line / 60.5 br
  crypto/aes_method.c               27.8  -> 44.3 line / 36.6 br
  crypto/rijndael/rijndael-api-fst.c 6.3  -> 29.8 line / 21.9 br
  hmac/sha1.c                       97.4  -> 98.7 line / 72.7 br

rijndael-api-fst.c caps at ~30% by design: aes_method.c only ever uses AES
MODE_CBC, so the ECB/CFB1 branches and the entire padEncrypt/padDecrypt/
cipherUpdateRounds halves are dead code from BDB's point of view.
aes_method.c's remaining cold lines are the HAVE_CRYPTO_IPP alternate
backend (not this build) and the __aes_err table / EAGAIN branches, which
need an internal cipher error (bad key length / bad state) not reachable
through the public API without fault injection.
@github-actions

Copy link
Copy Markdown

Coccinelle convention checks

No new violations. ✅

Resolved since baseline (2) -- update dist/cocci/baseline.txt to lock these in.
rule_mutex_unbalanced|MUTEX_UNBALANCED|src/crypto/mersenne/mt19937db.c|return (ret);
rule_mutex_unbalanced|MUTEX_UNBALANCED|src/mp/mp_register.c|return (ret);

@github-actions

Copy link
Copy Markdown

ABI diff vs v5.3.31 (libabigail — authoritative)

Removed exported symbols (nm -D, _NNNN version suffix normalized)

None.


Advisory: libabigail/nm is the authoritative binary-ABI check; Coccinelle is complementary source-level early warning. See dist/cocci/README.md.

@gburd
gburd merged commit 845bf32 into master Jul 29, 2026
45 of 47 checks passed
@gburd
gburd deleted the agent/crypto-cov branch July 29, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant