Skip to content

test: PKCS#1 v1.5 signing regression tests (#146)#148

Merged
timlegge merged 2 commits intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/test-pkcs1-v15-signing
Apr 7, 2026
Merged

test: PKCS#1 v1.5 signing regression tests (#146)#148
timlegge merged 2 commits intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/test-pkcs1-v15-signing

Conversation

@toddr-bot
Copy link
Copy Markdown
Contributor

@toddr-bot toddr-bot commented Mar 30, 2026

Summary

  • Add t/pkcs1_sign.t with 10 tests covering RSASSA-PKCS1-v1_5 signing
  • Add test file to MANIFEST

Why

Issue #146 reports that ACME/Let's Encrypt clients break because PKCS#1 v1.5 signing was disabled. The code fix exists but there was no dedicated test coverage for the PKCS#1 v1.5 sign/verify workflow. This ensures the fix stays working.

Testing

Covers: sign/verify with SHA-256 (RS256) and SHA-1, cross-padding rejection (PKCS1 sig must not verify with PSS), Marvin guard for encryption, and key PEM round-trip verification.

All 518 tests pass locally (OpenSSL 3.x).

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 99 insertions(+)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Covers the RSASSA-PKCS1-v1_5 signing workflow used by ACME/Let's
Encrypt clients (RS256). Verifies that use_pkcs1_padding() works for
sign/verify while remaining blocked for encrypt (Marvin protection).

Tests: sign/verify with SHA-256 and SHA-1, cross-padding rejection,
Marvin guard for encryption, key PEM round-trip.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@timlegge
Copy link
Copy Markdown
Member

timlegge commented Apr 6, 2026

@toddr-bot review and fix the debian bullseye test issue

@toddr-bot
Copy link
Copy Markdown
Contributor Author

PR Review — test: PKCS#1 v1.5 signing regression tests (#146)

Good regression test coverage for the PKCS#1 v1.5 signing fix. The one blocking issue is the cross-padding rejection test (lines 63-71): on OpenSSL 1.1.1 (Debian bullseye), RSA_verify() ignores the padding mode and always does PKCS#1 v1.5 verification, so a PKCS1 signature will verify even when PSS is requested. This will cause a test failure on bullseye CI. Wrap that test in a SKIP block conditioned on OpenSSL 3.x. The remaining tests are well-structured with appropriate SKIP handling for SHA-1 availability.


🔴 Blocking

1. Cross-padding test fails on OpenSSL < 3.x (bullseye) (`t/pkcs1_sign.t`, L63-71)

On OpenSSL 1.1.1 (Debian bullseye), both RSA_sign() and RSA_verify() in the pre-3.x code path (RSA.xs:1455) ignore the stored padding mode entirely — they always perform PKCS#1 v1.5 operations. This means setting use_pkcs1_pss_padding() on $rsa_pub before verify() has no effect, and the PKCS#1 signature will verify successfully even though PSS was requested. The test expects !$result but will get a truthy result on bullseye, causing a test failure.

Wrap this block in a SKIP that checks the OpenSSL version, e.g.:

SKIP: {
    skip "Pre-3.x RSA_verify() ignores padding mode", 1
        unless Crypt::OpenSSL::RSA->version() >= 0x30000000;
    # ... existing test ...
}

Alternatively, if there's no version() accessor, you could probe the behavior: attempt PSS verify of a known-good PSS signature and skip if it fails/succeeds unexpectedly. Check how other tests handle this (e.g., t/padding.t).

    $rsa_pub->use_pkcs1_pss_padding();
    $rsa_pub->use_sha256_hash();
    my $result = eval { $rsa_pub->verify("cross-padding test", $sig) };
    ok(!$result, "PKCS1 signature does not verify with PSS padding");

🟢 Suggestions

1. Missing 'use warnings' (`t/pkcs1_sign.t`, L3)

Most existing test files in this project include use warnings;. Adding it here would be consistent and catch potential issues during development.

use strict;
2. Marvin regex could be more precise (`t/pkcs1_sign.t`, L77)

The actual croak message is: "PKCS#1 v1.5 padding for encryption is vulnerable to the Marvin attack." (RSA.xs:450). The regex qr/Marvin|vulnerable/i is loose — vulnerable alone could match unrelated OpenSSL error strings. Consider qr/Marvin attack/ for a tighter match.

like($@, qr/Marvin|vulnerable/i,
         "PKCS#1 v1.5 encryption still blocked (Marvin)");

Checklist


Summary

Good regression test coverage for the PKCS#1 v1.5 signing fix. The one blocking issue is the cross-padding rejection test (lines 63-71): on OpenSSL 1.1.1 (Debian bullseye), RSA_verify() ignores the padding mode and always does PKCS#1 v1.5 verification, so a PKCS1 signature will verify even when PSS is requested. This will cause a test failure on bullseye CI. Wrap that test in a SKIP block conditioned on OpenSSL 3.x. The remaining tests are well-structured with appropriate SKIP handling for SHA-1 availability.


Automated review by Kōan

@toddr-bot
Copy link
Copy Markdown
Contributor Author

@timlegge: @toddr-bot review and fix the debian bullseye test issue

The bullseye test failure is in the cross-padding rejection test (t/pkcs1_sign.t lines 63-71). On OpenSSL 1.1.1 (bullseye), the pre-3.x code path in RSA.xs:1455 calls RSA_verify() directly, which ignores the padding mode — it always performs PKCS#1 v1.5 verification regardless of what use_pkcs1_pss_padding() set. So the test that signs with PKCS1 and expects PSS verify to reject the signature will fail on bullseye because RSA_verify() successfully verifies it as PKCS#1 v1.5 anyway.

Fix: wrap the cross-padding block in a SKIP conditioned on OpenSSL >= 3.x, and adjust plan tests from 10 to account for the skip. Something like:

SKIP: {
    skip "Pre-3.x RSA_verify ignores padding mode", 1
        unless eval { Crypt::OpenSSL::RSA->can('_openssl_version') && ... };
    # existing cross-padding test
}

Or probe it dynamically — attempt to detect whether padding differentiation is honored.

Add version check for OpenSSL to adjust PKCS1 padding usage in tests.
In OpenSSL < 3.0 the padding defaults to PKCS1 for RSA_sign
@timlegge timlegge marked this pull request as ready for review April 7, 2026 01:36
@timlegge timlegge merged commit 51967f9 into cpan-authors:main Apr 7, 2026
28 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.

2 participants