Skip to content

rsa: accept short PKCS#1 v1.5 signatures without a digest - #514

Open
ColtonWilley wants to merge 2 commits into
wolfSSL:masterfrom
ColtonWilley:fix/rsa-verify-short-sig
Open

ColtonWilley wants to merge 2 commits into
wolfSSL:masterfrom
ColtonWilley:fix/rsa-verify-short-sig

Conversation

@ColtonWilley

Copy link
Copy Markdown
Contributor

In replace-default mode, rpm on RHEL 10 rejects ~1 in 256 validly signed RSA packages (Header V4 RSA/SHA256 Signature: BAD). rpm-sequoia verifies via EVP_PKEY_verify with no digest set and the signature's leading zero bytes stripped, which the default provider accepts. Such short PKCS#1 v1.5 signatures are now left-padded; PSS, X9.31 and PKCS#1 with a digest still require full length (RFC 8017).

rpm-sequoia verifies OpenPGP RSA signatures via EVP_PKEY_verify with no
digest set and leading zeros stripped from the signature MPI, so ~1 in 256
fail. Left-pad them as the default provider's RSA_public_decrypt does.
PSS, X9.31 and PKCS#1 with a digest still require full length (RFC 8017).
Accepted without a digest, rejected with one, as the default provider does.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The padding change is narrowly scoped, buffer cleanup is sound, and regression coverage checks acceptance and rejection behavior with no unresolved findings.

No open issues 🎉

What changed in this PR

This PR fixes RSA verification compatibility with rpm-sequoia in replace-default mode by accepting short PKCS#1 v1.5 signatures when no digest is configured.

Changes:

  • Left-pads short signatures with zeros only for digest-free PKCS#1 v1.5 verification.
  • Preserves existing signature-length behavior for other verification modes.
  • Adds regression coverage for valid short signatures, corrupted signatures, and digest-based length checks.
File Description
test/​unit.h Declares the short-signature regression test.
test/​unit.c Registers the regression test.
test/​test_rsa.c Tests short-signature behavior against both providers.
src/​wp_rsa_sig.c Adds conditional left-padding and frees the temporary buffer.

Review effort: Balanced

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.

2 participants