Skip to content

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

Merged
aidangarske merged 3 commits into
wolfSSL:masterfrom
ColtonWilley:fix/rsa-verify-short-sig
Dec 2, 2026
Merged

aidangarske merged 3 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).

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

@ColtonWilley
ColtonWilley force-pushed the fix/rsa-verify-short-sig branch from 0e4e5ff to 93e9295 Compare December 1, 2026 19:28

@aidangarske aidangarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Skoll Code Review

Scan type: review

Overall recommendation: REQUEST_CHANGES
Findings: 1 total — 1 posted, 0 skipped
1 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [High] Short signatures remain rejected when the NONE enum is nonzero — src/wp_rsa_sig.c:1485-1489

Review generated by Skoll

Comment thread src/wp_rsa_sig.c Resolved
@aidangarske aidangarske self-assigned this Dec 2, 2026
Comment thread src/wp_rsa_sig.c Resolved
aidangarske
aidangarske previously approved these changes Dec 2, 2026
@ColtonWilley
ColtonWilley dismissed aidangarske’s stale review December 2, 2026 22:04

The merge-base changed after approval.

aidangarske
aidangarske previously approved these changes Dec 2, 2026
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.
@ColtonWilley
ColtonWilley dismissed aidangarske’s stale review December 2, 2026 22:07

The merge-base changed after approval.

@ColtonWilley
ColtonWilley force-pushed the fix/rsa-verify-short-sig branch from 251b68e to 3e6d877 Compare December 2, 2026 22:07
@aidangarske
aidangarske self-requested a review December 2, 2026 22:09
@aidangarske
aidangarske merged commit fe716c9 into wolfSSL:master Dec 2, 2026
83 checks passed
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.

3 participants