Greetings, Perl Monks!
I am working on a small perl program that gives me an interface to Crypt::OpenPGP. It successfully generates encrypted text in Compat=PGP5 mode, which I can decrypt using the PGP Freeware client. However, my program cannot decrypt the very same cipher text using the Crypt::OpenPGP module.
The error I get on decryption is:
encrypt: datasize not multiple of blocksize (16 bytes) at /usr/local/l
+ib/perl5/site_perl/5.8.3/Crypt/OpenPGP/CFB.pm line 59.
Here is a small test case that attempts to do the decrypt and produces the error:
#!/usr/local/bin/perl -w
use Crypt::OpenPGP;
# slurp in file of ciphertext:
open( my $fh, "/home/nobody/tools/crypt/cipher.txt") or die "flaming
+ death\n";
my $Data = do { local( $/ ) ; <$fh> } ;
my $pgp = Crypt::OpenPGP->new (
"SecRing" => "/home/nobody/.keys/secring.skr"
);
my $plaintext = $pgp->decrypt (
"Compat" => "PGP5",
"Data" => $Data,
"Passphrase" => "no, you cant have it"
);
die "Decryption Failed: ", $pgp->errstr unless $plaintext;
print "plain text:\n" . $plaintext . "\n";
The code that did the crypting looks like this:
my $pgp = Crypt::OpenPGP->new (
"PubRing" => $PubRing
);
my $ciphertext = $pgp->encrypt (
"Compat" => $Compat,
"Data" => $Data,
"Recipients" => @recipients_list,
"Armour" => $Armour,
);
die "Encryption failed: ", $pgp->errstr unless $ciphertext;
return $ciphertext;
Stuff I've Tried So Far:
- Setting the Compat mode to PGP2 or GnuPG doesn't help.
- Tried setting the cipher attribute to DES3 and Rjindael, no help
system/perl info:
- Solaris 9 sparc
- Perl 5.8.3
Any insight is greatly appreciated ^_~
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.