Crypt::OpenPGP::KeyRing - Key ring object |
find_keyblock_by_keyid($key_id)
find_keyblock_by_uid($uid)
find_keyblock_by_index($index)
Crypt::OpenPGP::KeyRing - Key ring object
use Crypt::OpenPGP::KeyRing;
my $ring = Crypt::OpenPGP::KeyRing->new( Filename => 'foo.ring' );
my $kb = $ring->find_keyblock_by_keyid($key_id);
Crypt::OpenPGP::KeyRing provides keyring management and key lookup for Crypt::OpenPGP. A KeyRing, in this case, does not necessarily have to be a keyring file; a KeyRing object is just a collection of key blocks, where each key block contains exactly one master key, zero or more subkeys, some user ID packets, some signatures, etc.
Constructs a new Crypt::OpenPGP::KeyRing object and returns that object. This has the effect os hooking the object to a particular keyring, so that all subsequent methods called on the KeyRing object will use the data specified in the arguments to new.
%arg can contain:
This argument is optional.
This argument is optional.
find_keyblock_by_keyid($key_id)
Looks up the key ID $key_id in the keyring $ring. $key_id should be either a 4-octet or 8-octet string--it should not be a string of hexadecimal digits. If that is what you have, use pack to convert it to an octet string:
pack 'H*', $hex_key_id
If a keyblock is found where the key ID of either the master key or subkey matches $key_id, that keyblock will be returned. The definition of ``match'' depends on the length of $key_id: if it is a 16-digit hex number, only exact matches will be returned; if it is an 8-digit hex number, any keyblocks containing keys whose last 8 hex digits match $key_id will be returned.
In scalar context, only the first keyblock found in the keyring is returned; in list context, all matching keyblocks are returned. In practice, duplicated key IDs are rare, particularly so if you specify the full 16 hex digits in $key_id.
Returns false on failure (undef
in scalar context, an empty list in
list context).
find_keyblock_by_uid($uid)
Given a string $uid, looks up all keyblocks with User ID packets matching the string $uid, including partial matches.
In scalar context, returns only the first keyblock with a matching user ID; in list context, returns all matching keyblocks.
Returns false on failure.
find_keyblock_by_index($index)
Given an index into a list of keyblocks $index, returns the keyblock
(a Crypt::OpenPGP::KeyBlock object) at that index. Accepts negative
indexes, so -1
will give you the last keyblock in the keyring.
Please see the Crypt::OpenPGP manpage for author, copyright, and license information.
Crypt::OpenPGP::KeyRing - Key ring object |