From fbe226adc38f241a74c7b03458ae735500d0ea99 Mon Sep 17 00:00:00 2001 From: Toddr Bot Date: Mon, 25 May 2026 23:18:39 +0000 Subject: [PATCH] Remove dead Bignum availability guards from tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Crypt::OpenSSL::Bignum is a hard compile-time dependency via `use Crypt::OpenSSL::Bignum` in RSA.pm. The t/fakelib/ mock and all $HAS_BIGNUM / skip_all checks in tests are dead code — they can never trigger because RSA.pm won't compile without the real Bignum module. - Remove t/fakelib/ (mock Bignum that returns false) - Remove dead skip_all in bignum.t and check_param.t - Remove $HAS_BIGNUM variable and SKIP guards in keygen.t and key_lifecycle.t Co-Authored-By: Claude Opus 4.6 --- MANIFEST | 1 - t/bignum.t | 4 +--- t/check_param.t | 6 +----- t/fakelib/Crypt/OpenSSL/Bignum.pm | 3 --- t/key_lifecycle.t | 15 ++------------- t/keygen.t | 11 +++-------- 6 files changed, 7 insertions(+), 33 deletions(-) delete mode 100644 t/fakelib/Crypt/OpenSSL/Bignum.pm diff --git a/MANIFEST b/MANIFEST index 9617adb..d370a80 100644 --- a/MANIFEST +++ b/MANIFEST @@ -16,7 +16,6 @@ t/crypto.t t/der.t t/error.t t/error_queue.t -t/fakelib/Crypt/OpenSSL/Bignum.pm t/format.t t/get_key_parameters.t t/key_lifecycle.t diff --git a/t/bignum.t b/t/bignum.t index 70aea5c..ea64b29 100644 --- a/t/bignum.t +++ b/t/bignum.t @@ -3,9 +3,7 @@ use Test::More; use Crypt::OpenSSL::RSA; -$INC{'Crypt/OpenSSL/Bignum.pm'} - ? plan( tests => 64 ) - : plan( skip_all => "Crypt::OpenSSL::Bignum required for bignum tests" ); +plan( tests => 64 ); my @PARAM_NAMES = qw(n e d p q dmp1 dmq1 iqmp); diff --git a/t/check_param.t b/t/check_param.t index d58f8fc..5b2f2e7 100644 --- a/t/check_param.t +++ b/t/check_param.t @@ -7,11 +7,7 @@ use Crypt::OpenSSL::RSA; Crypt::OpenSSL::Random::random_seed("OpenSSL needs at least 32 bytes."); Crypt::OpenSSL::RSA->import_random_seed(); -my $HAS_BIGNUM = $INC{'Crypt/OpenSSL/Bignum.pm'} ? 1 : 0; - -$HAS_BIGNUM - ? plan( tests => 9 ) - : plan( skip_all => "Crypt::OpenSSL::Bignum required for check_param tests" ); +plan( tests => 9 ); my $rsa = Crypt::OpenSSL::RSA->generate_key(2048); my ( $n, $e, $d, $p, $q ) = $rsa->get_key_parameters(); diff --git a/t/fakelib/Crypt/OpenSSL/Bignum.pm b/t/fakelib/Crypt/OpenSSL/Bignum.pm deleted file mode 100644 index 97603fc..0000000 --- a/t/fakelib/Crypt/OpenSSL/Bignum.pm +++ /dev/null @@ -1,3 +0,0 @@ -package Crypt::OpenSSL::Bignum; - -0; # make require fail diff --git a/t/key_lifecycle.t b/t/key_lifecycle.t index 5c25b19..a049915 100644 --- a/t/key_lifecycle.t +++ b/t/key_lifecycle.t @@ -7,10 +7,6 @@ use Crypt::OpenSSL::RSA; Crypt::OpenSSL::Random::random_seed("OpenSSL needs at least 32 bytes."); Crypt::OpenSSL::RSA->import_random_seed(); -my $HAS_BIGNUM = eval { require Crypt::OpenSSL::Bignum; 1 } ? 1 : 0; - -# skip() reports skipped tests which count toward total, so plan must -# always include them regardless of whether Bignum is available. plan tests => 9 + 14 + 20 + 2 + 4; # --- Cross-key operations --- @@ -58,12 +54,8 @@ ok( $rsa1->verify($plaintext, $sig_copy), "original key verifies signature from exported key" ); # --- Key parameter round-trip with real-sized keys --- -# Requires Crypt::OpenSSL::Bignum - -SKIP: { - skip "Crypt::OpenSSL::Bignum required for parameter tests", 14 - unless $HAS_BIGNUM; +{ # Extract parameters from a 2048-bit key my ($n, $e, $d, $p, $q, $dmp1, $dmq1, $iqmp) = $rsa1->get_key_parameters(); @@ -116,10 +108,7 @@ SKIP: { # Tests for deriving missing p or q from n, and constructing keys # from n/e/d without CRT params. -SKIP: { - skip "Crypt::OpenSSL::Bignum required for derivation tests", 20 - unless $HAS_BIGNUM; - +{ my ($n, $e, $d, $p, $q) = $rsa1->get_key_parameters(); # --- Derive q from n and p (pass p, omit q) --- diff --git a/t/keygen.t b/t/keygen.t index 2a4f1d3..2e3ff23 100644 --- a/t/keygen.t +++ b/t/keygen.t @@ -12,8 +12,6 @@ use Crypt::OpenSSL::RSA; Crypt::OpenSSL::Random::random_seed("OpenSSL needs at least 32 bytes."); Crypt::OpenSSL::RSA->import_random_seed(); -my $HAS_BIGNUM = eval { require Crypt::OpenSSL::Bignum; 1 } ? 1 : 0; - # Use 2048-bit keys throughout — AlmaLinux 9 and other FIPS-like systems # enforce a minimum RSA key size of 2048 bits. my $BITS = 2048; @@ -29,8 +27,7 @@ plan tests => 29; ok($rsa->is_private(), "generated key is private"); ok($rsa->check_key(), "key passes check_key"); - SKIP: { - skip "Crypt::OpenSSL::Bignum not available", 1 unless $HAS_BIGNUM; + { my (undef, $e) = $rsa->get_key_parameters(); is($e->to_decimal(), "65537", "exponent is 65537"); } @@ -51,8 +48,7 @@ plan tests => 29; ok($sig, "e=3 key can sign"); ok($rsa->verify("test message", $sig), "e=3 key signature verifies"); - SKIP: { - skip "Crypt::OpenSSL::Bignum not available", 1 unless $HAS_BIGNUM; + { my (undef, $e) = $rsa->get_key_parameters(); is($e->to_decimal(), "3", "exponent is 3"); } @@ -73,8 +69,7 @@ plan tests => 29; my $pt = $rsa->decrypt($ct); is($pt, "hello", "e=17 key encrypt/decrypt round-trip"); - SKIP: { - skip "Crypt::OpenSSL::Bignum not available", 1 unless $HAS_BIGNUM; + { my (undef, $e) = $rsa->get_key_parameters(); is($e->to_decimal(), "17", "exponent is 17"); }