Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I'm new to pgp and don't know where I'm going wrong. I have a script that transfers pgp files back & forth using ftp and encrypts and decrypts as needed using existing key files.

The current problem I have is signing while encrypting. I can encrypt just fine, but if I try to sign it during the encryption, I get the following error:

Could not find secret key with KeyID ....

Here's the code:

my $mysecring = Crypt::OpenPGP::KeyRing->new(Filename => $CONFIG{priva +tekey}) or handleError( "Error: ".Crypt::OpenPGP::KeyRing->errstr,1); my $mypubring = Crypt::OpenPGP::KeyRing->new(Filename => $CONFIG{publi +ckey}) or handleError( "Error: ".Crypt::OpenPGP::KeyRing->errstr,1); my $theirpubring = Crypt::OpenPGP::KeyRing->new(Filename => $CONFIG{ic +skey}) or handleError( "Error: ".Crypt::OpenPGP::KeyRing->errstr,1); my $pgp = Crypt::OpenPGP->new( SecRing=>$mysecring, PubRing=>$theirpubring, ) or handleError( "there was a problem creating constructor\n\n".C +rypt::OpenPGP->errstr,1); opendir(DIR, $CONFIG{ToDir}) or handleError( "Unable to open directory + $CONFIG{ToDir}: $!",1); my @directory = grep { !(/pgp/) && -f "$CONFIG{ToDir}/$_"} readdir(DIR +); closedir(DIR) or handleError( "Unable to close directory $CONFIG{ToDir +}: $!",1); print "found ".(scalar @directory)." items\n"; foreach (@directory){ print "encrypting $_\n"; my $encryption=$pgp->encrypt( Filename=>$CONFIG{ToDir}.'/'.$_, SignKeyID=>$keyid, SignPassphrase=>$pass, ) or handleError( "there was a problem encrypting the file\n\n +".$pgp->errstr); open FILE,'>'.$CONFIG{ToDir}.'/'.$_.'.pgp'; print FILE $encryption; close FILE; } }

Part (or rather most) of the problem is that I'm not sure what value I need to pass to SignKeyID: is it supposed to be a Crypt::OpenPGP::KeyBlock? a Crypt::OpenPGP::Signature? a string? I've tried setting it to $mysecring, a string of the file location, the secring's 8 char hex keyid, Fingerprint, userid, the 16 char hex subkeyid (all taken from the secring certificate details).

Delving into both the Crypt::OpenPGP documentation and code hasn't given me the answer...at least not one I can wrap my brain around.

Can someone enlighten me with what I'm doing wrong?

update: $mysecring and $mypubring make up the key pairs for my certificate -- $theirpubring is the public key for the party I'm sending the encrypted file to.


In reply to Crypt::OpenPGP encryption signature by ksublondie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2014-08-31 04:01 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (294 votes), past polls