Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-16 16:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found