Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

GPG signing Issue

by roperl (Beadle)
on Sep 12, 2018 at 20:22 UTC ( #1222254=perlquestion: print w/replies, xml ) Need Help??
roperl has asked for the wisdom of the Perl Monks concerning the following question:

Having an issue with trying to encrypt and sign a message using Crypt::OpenPGP Here is my code
my $ct = $pgp->encrypt( Filename => 'plain.txt', Recipients => $key, C +ipher => 'DES3', SignKeyID => $signkey, SignPassphrase => $GPG_PP ) o +r die "Encryption failed: ", $pgp->errstr; if ($ct) { open( my $fh, '>', 'encrypted.gpg' ); print $fh $ct; close $fh; } else { #print "gpg failed: $pgp->errstr\n"; $err = Crypt::OpenPGP->errstr; print "gpg failed: $err\n"; }
Here is the error message I get:
Data too large for key size at /opt/perl-5.26.0/lib/site_perl/5.26.0/C +rypt/OpenPGP/Key/Secret/DSA.pm line 33.
If I look at Crypt/DSA.pm I can see the error message here
my $dlen = length $dgst; my $i = bitsize($key->q) / 8; croak "Data too large for key size" if $dlen > $i || $dlen > 50;
If I comment out the croak and following if line I can execute the code with no issues. Is there a better workaround then this?

Replies are listed 'Best First'.
Re: GPG signing Issue
by hippo (Canon) on Sep 19, 2018 at 12:59 UTC

    I am having slightly different problems with Crypt::OpenPGP. Can't get it to read my GPGv1 private key from the keyring. It dies with:

    encrypt: datasize not multiple of blocksize (16 bytes) at /usr/local/s +hare/perl5/Crypt/OpenPGP/CFB.pm line 57.

    which Carp::Always tells me is called from Crypt::OpenPGP::Cipher::decrypt on a Crypt::OpenPGP::Cipher::Rijndael object. How are you reading/creating your key in the code in the OP?

    It's a shame because it could be a really good alternative to either GPGme or the CLI wrappers.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1222254]
Approved by Paladin
Front-paged by pryrt
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2018-09-23 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (191 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!