2

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 $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

  1. Encrypt with gpg and decrypt with gpg.
    • Works fine, as expected
  2. Encrypt with perl using Crypt::OpenPGP and decrypt with gpg.
    • Works fine.
  3. Encrypt with perl using Crypt::OpenPGP and decrypt with perl using Crypt::OpenPGP
    • Works fine.
  4. 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?

xenoterracide
  • 16,274
  • 24
  • 118
  • 243
  • Is #1 using the same key as #2?. I bet your openpgp's key store is different from gpg – J-16 SDiZ Sep 22 '12 at 03:04
  • when it prompts it asks for a key that is in my gpg store, I do not have any other store's. Apparently openpgp searches the usual suspects. – xenoterracide Sep 22 '12 at 03:16
  • Can you encrypt (`$pgp->encrypt`) a text using perl script (that uses `Crypt::OpenPGP`) and then try to decrypt it? If this works then it means the `Crypt::OpenPGP` can only handle encryption done by `Crypt::OpenPGP`. PGP Encryption done by other apps (like [Kleopatra](http://www.kde.org/applications/utilities/kleopatra/)) or programs would probably fail in most of the cases. – Anjan Biswas Oct 05 '12 at 22:17
  • yes, and that seems to be the case – xenoterracide Oct 06 '12 at 02:34

0 Answers0