Skip to content

Commit

Permalink
Add test for Fix for RT #79798 - Symkey decrypt failed: Invalid secre…
Browse files Browse the repository at this point in the history
…t key ID
  • Loading branch information
timlegge committed Oct 14, 2024
1 parent 0bf6750 commit 2d6a21b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions t/19-issue-79798.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use strict;
use warnings;

use Test::More tests => 2;

use Crypt::OpenPGP;

use vars qw( $SAMPLES );
unshift @INC, 't/';
require 'test-common.pl';
use File::Spec;

my $encrypted = <<'ENCRYPTED';
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1
hQIOA5M412pWe59CEAf/eygcKcs9i27HSgewRpg9PSuaPSCXE3/O8+Kn+yaJtc1N
NAftT6S/QbqxuMmeAR1jSil1lZuCq5znldQKbmsBzvNe5B92OK0ruVtPBSnfV87x
Dpfh+lf/IGWBRZOcxGi6mErfVgQYJddeKwSR3M8q8NQaXqeOABK8D/sR3ku8C5u0
y3+quHUterlguJVy8UgrZic2e2ocWX/RK1iHChhOhAGjcSMI/n3qPH8xhCSRuPmi
9uq0tenaktvrd0FpBamUbM4Sqdh9Dn8jByWgYPue+W4HgtJTxweu+2iZ7sRGtYcb
wowmTexuVoZisnY73X1Jzy5zA/z8ANjgY1ObgkX0cAgAjGMOCyCVW/qcBCdI9b6p
D7hYuqWuILMlAfLbj13BBxFYUA9zRLlpVdKbetWe/HEzNDYewt4ORM3sIrh78NPo
1qcS6RXnBv3ipg+oZXCy+ePJkUyoECsEJfiM+YiySwgOLGDyk1MlK1Be8c+LQAa4
/9jWixK7gmRBda+KYOE7xTpKMUdUXuKWxDR0g861hoquizi3fjNVayvrjgSbEvi7
jr4O/EBQvE0Ebniryo9x5S1y9voVqsVaalswZT+G1TVflFLD2YYXvGQPDLXKHfIq
BRsroH1tVmRDj6/qF5RR4Yg6Y1y0kHrUlIW0Qt/koSv8loAhLxYWb7Dt71+i62WQ
6dJTAbMm7W7hI3Ikc/0LMOEUTHneuLMK9VHfVpbRkUzxUthaAphGulPL/m65GK8s
OSP07ZS5UVwk1aghrdVDXBORIYyubECxxcZK86H+wmf6Rp+bkUw=
=XsZR
-----END PGP MESSAGE-----
ENCRYPTED

my $original = << 'ORIGINAL';
Encrypt with RSA SubKey
ORIGINAL
my $secring = File::Spec->catfile( $SAMPLES, 'gpg', 'subkeys-ring.sec' );
my $pubring = File::Spec->catfile( $SAMPLES, 'gpg', 'subkeys-ring.pub' );
my $passphrase = 'foobar';

my $pgp = Crypt::OpenPGP->new(
SecRing => $secring,
PubRing => $pubring,
);
ok($pgp, "Crypt::OpenPGP created");

my $plaintext = $pgp->decrypt(
Data => $encrypted,
Passphrase => $passphrase,
);
like($plaintext, qr/$original/, "Crypt::OpenPGP can verify signature");

done_testing;
Binary file added t/samples/gpg/subkeys-ring.pub
Binary file not shown.
Binary file added t/samples/gpg/subkeys-ring.sec
Binary file not shown.

0 comments on commit 2d6a21b

Please sign in to comment.