Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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/ line 33.
If I look at Crypt/ 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/ 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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2019-01-20 06:42 GMT
Find Nodes?
    Voting Booth?
    After Perl5, I'm mostly interested in:

    Results (345 votes). Check out past polls.

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