Skip to content

Commit

Permalink
fixup! fixup! add test/recipes/15-test_pkey.t
Browse files Browse the repository at this point in the history
  • Loading branch information
DDvO committed Sep 27, 2024
1 parent 42c82e4 commit df355f6
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions test/recipes/15-test_pkey.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,27 @@ subtest "=== pkey en-/decryption using AES256-CBC ===" => sub {
subtest "=== pkey handling of identical input and output files, using 3DES and -traditional ===" => sub {
plan tests => 4;

my $encrypted_key2 = 'encrypted_key2.pem';
my $inout = 'inout.pem';
copy($in_key, $inout);
ok(run(app(['openssl', 'pkey', '-des3', '-traditional', '-in', $inout,
'-out', $inout, '-passout', 'pass:password'])),
"identical infile and outfile, encrypt");
copy($inout, $encrypted_key2);
ok(run(app(['openssl', 'pkey', '-in', $inout,
'-out', $inout, '-passin', 'pass:password'])),
"identical infile and outfile, decrypt");
is(compare($in_key, $inout), 0,
"Same file contents after encrypting and decrypting in same file");

sub file_line_contains { grep /$_[0]/, ((open F, $_[1]), <F>, close F) }
ok(file_line_contains("DEK-Info: DES-EDE3-CBC,", $encrypted_key2),
"encrypted traditional file contains \"DEK-Info: DES-EDE3-CBC,\"");
SKIP: {
skip "DES isn't supported in this build", 4
if disabled("des");

my $encrypted_key2 = 'encrypted_key2.pem';
my $inout = 'inout.pem';
copy($in_key, $inout);
ok(run(app(['openssl', 'pkey', '-des3', '-traditional', '-in', $inout,
'-out', $inout, '-passout', 'pass:password'])),
"identical infile and outfile, encrypt");
copy($inout, $encrypted_key2);
ok(run(app(['openssl', 'pkey', '-in', $inout,
'-out', $inout, '-passin', 'pass:password'])),
"identical infile and outfile, decrypt");
is(compare($in_key, $inout), 0,
"Same file contents after encrypting and decrypting in same file");

sub file_line_contains { grep /$_[0]/, ((open F, $_[1]), <F>, close F) }
ok(file_line_contains("DEK-Info: DES-EDE3-CBC,", $encrypted_key2),
"encrypted traditional file contains \"DEK-Info: DES-EDE3-CBC,\"");
}
};

subtest "=== pkey handling of public keys ===" => sub {
Expand Down

0 comments on commit df355f6

Please sign in to comment.