Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Problem with module using Crypt::OpenPGP

by DamnDirtyApe (Curate)
on Aug 18, 2003 at 04:56 UTC ( #284483=note: print w/replies, xml ) Need Help??

in reply to Problem with module using Crypt::OpenPGP

I think I've isolated the problem: when I ran the script as myself, the script was using my personal keyring, not the one I'm passing it. For some reason, the keyring I'm trying to create in the program isn't working. I've reduced the problem to this script; if I can get this to work, I believe I can make the larger program run as well.

#! /usr/bin/perl use strict; use Crypt::OpenPGP; my $gpg = Crypt::OpenPGP->new or die "Cannot create Crypt object: $!"; my $ring = Crypt::OpenPGP::KeyRing->new( Data => \*DATA ) or die "Cannot create keyring: $!"; my $plaintext = 'Foobar!'; my $cipher = $gpg->encrypt( Compat => 'GnuPG', PubRing => $ring, Data => $plaintext, Armour => 1, Recipients => '' ) or die "Cannot encrypt text: " . $gpg->errstr; print "$cipher"; __DATA__ -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.2.2 (GNU/Linux) mQGiBDwTwfQRBADH+C+xkm3V3rFywQJw9IwkbNKifRxn47GSZEOOTxNn6IupqqGi lO7BndliHsBQEqqalQchv6Ly8Djxl0aeS5MweCT1qrlrtkMtbqYtDcyp10x2iTcC 4MA5dU1/P/TdhEQQSAgSFbt3qE2ZnK3wsai2CdEFR47xAKG6NKwmMPeUAwCg+61C gaMddxI+5/kzoCGomqGmcI8D/2qculnwGTeNyDH5EKJnb0w2Cjb7jmxe8RtAOKEx 3hApV18Ng5dWiEuId8TmAYoQiHyC09vv9L0lADysTNrzfH8ozXZwXJlcIYFg/Doi jtUleX0mmZVSUkrJJ+rybT8jcfcWso2wa/igLjTyWHwXqPdkLf3zDOM8V1KJO1zj Og3BBAC5j0iM3vKvkU0KXt9A2i+0Pz+xPIrUc3XUVVHntq9nhOPOhbckHF81tfTu UnKFPQhiHmYFSoqhwMuPvMGvq3URs29WsCUGjX1gcoMkinOkAeOLQwwNh3MxMAri d0GFaeQPUK0V4uG5HDRG6Ggs95mfF3TjO3bcjikR+xzEd+cIv7QgRG91ZyBHb3Js ZXkgPGRvdWdnb3JsZXlAc2hhdy5jYT6IWgQTEQIAGgULBwoDBAMVAwIDFgIBAheA AhkBBQI8E8H1AAoJEMWpVBWiIVWb8OcAoPQ+2Rz3aQ6nsVBNFGRbN6XBHhoOAJ4v TWlEp4vz3/seWpJu8Eusd9eH0ohGBBARAgAGBQI+XGA+AAoJEIIiaBYBnUdP6X8A ni7yhBPc37MatJad9tKO1m/FKXv/AKCHC0hIIr0rSPl5oWt265Cit228KrkBDQQ8 E8H6EAQAhSB8LOS83dcRvxpq8k3y9SfzthnQyDtJRi/6qaE7+LCSPzx4SDfxP1Sn r/ScPceqTP54GR51nYLTv9abm75SIbcgkwUQx2U0q5XM3UjZB2ZJxLQ1bOxhFJpn F8PX9PtDm77e3zitCRdoBlXyKcKCnDKSAhp2B9hhD9eOj6i9ah8AAwcD/itF9KhK sUr/SD33ToPJ216aTx9aQ2iyWMcQ4hEaTq0bLN8UOBLvwFYglUdA1wUjrEUKK9QC ptfb5+/CibNvjTuP6M+087OmX/BFKLIhfO9oQlp3RV1u9futp1tzTlRo2F0uI1YV mAIHNuildXCSCuTEkctQlujqMSJ5E1B1dYr3iEYEGBECAAYFAjwTwfoACgkQxalU FaIhVZsCNgCfWHmXo/me0717bsT38c55Uqfrng0AoLTOcDzWdHln4MhLBOQ+RVN6 u0sd =NtKC -----END PGP PUBLIC KEY BLOCK-----

Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

Replies are listed 'Best First'.
Re: Re: Problem with module using Crypt::OpenPGP
by mattr (Curate) on Aug 18, 2003 at 06:37 UTC
    This sounds similar to some things I have wrestled with in the past but I looked over some of my notes and could not find the exact reference due to having way too many notes and also trying both PGP and GPG, it's been several months.. Anyway one thing you may want to try is consider that the bug message may be wrong, it is not having trouble understanding the recipient but rather the sender. I seem to remember something like that..

    Also it may be that if this happens to be on a shared server (if so be real careful with your secrets..) it may be using a different ring.

    In my case I also had trouble with tons of dependencies in other modules, I had an old perl. I ended up rolling my own module using Storable, IO::Handle, and GnuPG::Interface, and Class::MethodMaker. Perl libs were built with a local prefix.

    First I made a keyring on the command line and imported a public key into it. The key has to be trusted, which can be done without any secret keys being installed by editting .gnupg/options (reading the comments is essential). The encrypted text is ascii armored and can be copied or downloaded for decryption with a GPG client like WinPT / GPG.

    Note it is not very secure to encrypt things on a shared server, however since it was not an extremely heavy situation I did a couple things like chmod my own gpg binary -rwsr-xr-x to attempt to secure memory, plus filling strings with zeroes before they went out of scope to try to keep data from remaining in the swap partition.

    Anyway I'm guessing you have a much better environment available to you. It does sound however that PGP is fighting you because it thinks you have a different identity than you really do; this is the main reason I have found PGP/GPG to fight when it works on the command line. If you can figure out who it thinks you are (very hard I think) you are there.

Re: Re: Problem with module using Crypt::OpenPGP
by DamnDirtyApe (Curate) on Aug 27, 2003 at 16:35 UTC

    I've found the problem here; the key ring needs to be provided as an argument to the new() function. This worked for me:

    my $gpg = Crypt::OpenPGP->new( PubRing => './' ) or die "Cannot create Crypt::OpenPGP object: $!";

    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://284483]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-03-24 19:06 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (306 votes). Check out past polls.