Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions t/bignum.t
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 1 addition & 5 deletions t/check_param.t
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions t/fakelib/Crypt/OpenSSL/Bignum.pm

This file was deleted.

15 changes: 2 additions & 13 deletions t/key_lifecycle.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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) ---
Expand Down
11 changes: 3 additions & 8 deletions t/keygen.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}
Expand All @@ -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");
}
Expand All @@ -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");
}
Expand Down
Loading