Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Stumped by Crypt::OpenPGP::Signature->key_id

by mhi (Friar)
on Nov 22, 2011 at 11:06 UTC ( #939426=perlquestion: print w/ replies, xml ) Need Help??
mhi has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks!

In trying to verify a PGP signature and determine the Key ID of the signing key, I have been stumped by the strange format I encountered in reading out that Key ID.

Expecting to find it in the usual hex format, I instead was offered 'key_id' => 'yp▒▒▒▒▒'. To me this is especially confusing as accoring to the docs when creating a signature, you are supposed to enter the Key-ID as an 8- or 16-digit hex number.

Here's a code snippet:

use Crypt::OpenPGP; ... my $pgp = Crypt::OpenPGP->new; my($userid,$sigobj) = $pgp->verify( Signature => $mailbody, Data => $mailbody, ); unless(defined $userid){ done(1,"Could not verify signature."); } printf("KeyID: 0x%x\nUserID:%s\n",$sigobj->key_id, $userid);

Output:

Argument "ypM-&M-^W^]M-^UM-\rM-^W" isn't numeric in printf at ./script.pl line 118.
KeyID: 0x0
UserID:Test Key <testkey@example.com>

How can I get the Key-ID in hex? Am I just not seeing it? I would be delighted to be enlightened. :-)

Update/Correction: Input of course would be an 8- or 16-digit hex no., not 10 as I previously wrote.

Comment on Stumped by Crypt::OpenPGP::Signature->key_id
Download Code
Re: Stumped by Crypt::OpenPGP::Signature->key_id
by Anonymous Monk on Nov 22, 2011 at 11:18 UTC
      Sorry, but I don't see how that helps.
      • The node mentioned has nothing to do with the issue at hand.
      • The Searchlink doesn't work.
      • There is no
        Crypt::OpenPGP::Signature->key_id_hex but only
        Crypt::OpenPGP::Signature->key_id and
        Crypt::OpenPGP::Certificate->key_id_hex

        The node mentioned has nothing to do with the issue at hand.

        Yup, just nostalgia

        The Searchlink doesn't work.

        Sorry if you have to copy/paste, at least I made it tab-key navigable (couldn't have posted the link otherwise )

        There is no Crypt::OpenPGP::Signature->key_id_hex

        Too bad, it was worth a shot

        Anyway, hex of anything is

        $ perl -le " print unpack qw/H*/, $_ for @ARGV; " 1 aSdF82 31 615364463832
        Patches Welcome™ . . .
Reaped: Re: Stumped by Crypt::OpenPGP::Signature->key_id
by NodeReaper (Curate) on Nov 25, 2011 at 12:57 UTC
Reaped: Re: Stumped by Crypt::OpenPGP::Signature->key_id
by NodeReaper (Curate) on Nov 28, 2011 at 12:36 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://939426]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

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

    April first is:







    Results (475 votes), past polls