Skip Menu |

This queue is for tickets about the Crypt-OpenPGP CPAN distribution.

Report information
The Basics
Id: 79798
Status: open
Priority: 0/
Queue: Crypt-OpenPGP

People
Owner: Nobody in particular
Requestors: xenoterracide [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: cpan [...] stupidfool.org
Subject: Symkey decrypt failed: Invalid secret key ID (when using GPG encrypted data )
Date: Sat, 22 Sep 2012 17:58:29 -0500
To: bugs-crypt-openpgp [...] rt.cpan.org
From: Caleb Cushing <xenoterracide [...] gmail.com>
I'm not actually sure this is a bug, but if not perhaps you can explain why and how to fix it. http://stackoverflow.com/questions/12540226/cryptopenpgp-symkey-decrypt-failed-invalid-secret-key-id For duplication purposes here's the text. I am having a problem where Crypt::OpenPGP is unable to decrypt a message encoded by GPG. It seems that I am not the first to have this problem. But no solution was found on that thread. my $pgp = load_class('Crypt::OpenPGP')->new; $pgp->handle( Data => $encrypted, ) or confess $self->_pgp->errstr; Crypt::OpenPGP prompts correctly for the key passphrase, finding the key successfully, and I'v tested to make sure the passphrase works with GPG. But when attempting to decrypt the message with Crypt::OpenPGP I get the error. Symkey decrypt failed: Invalid secret key ID according to the thread the following have been tested Encrypt with gpg and decrypt with gpg. Works fine, as expected Encrypt with perl using Crypt::OpenPGP and decrypt with gpg. Works fine. Encrypt with perl using Crypt::OpenPGP and decrypt with perl using Crypt::OpenPGP Works fine. Encrypt with gpg and decrypt with perl using Crypt::OpenPGP Failure with "Symkey decrypt failed: Invalid secret key ID" message. This is the situation described above which seems to reflect my own observation though I've not tested a few of these. Does anyone know the cause or even better a fix? -- Caleb Cushing http://xenoterracide.com
Greetings, So I actually faced this same issue and I have a fix for it in the form of a diff. I must admit I'm not 100% familiar with how every aspect of this module and GPG/PGP encryption works but I wanted to share this and hopefully it'll do the trick and can be merged in. This is the diff: [rstone@rstone ~]$ diff perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Crypt/OpenPGP.pm repos/Crypt-OpenPGP-1.03/lib/Crypt/OpenPGP.pm 602,607c602 < for my $potential_cert (@{ $kb->get('Crypt::OpenPGP::Certificate') }) { < if( $potential_cert->key_id eq $sym_key->key_id ) { < $cert = $potential_cert; < last; < } < } --- Show quoted text
> $cert = $kb->encrypting_key;
I am working against the 1.03 version due to other unrelated issues but I've also applied the patch to 1.11 and it seems to work there. It seems that the wrong key was being returned by the call to ->encrypting_key due to this logic in Crypt::OpenPGP::KeyBlock: sub encrypting_key { my $kb = shift; my $keys = $kb->get('Crypt::OpenPGP::Certificate'); return unless $keys && @$keys; for my $key (@$keys) { return $key if $key->can_encrypt; } } In my case at least, this loop was existing out too early and it was the second key and not the first one that matched that did the decryption I needed. Hopefully this is helpful to the maintainer and anyone else who stumbles across this issue. Again, I'm not 100% sure of any other consequences of this change other than to say it "Worked for me." Thanks!