Crypt::OpenPGP::Signature - Signature packet


Crypt::OpenPGP::Signature - Signature packet


    use Crypt::OpenPGP::Signature;
    my $sig = Crypt::OpenPGP::Signature->new(
                               Key  => $secret_key,
                               Data => $plaintext,
                               Type => 0x00,
    my $serialized = $sig->save;
    my $sig = Crypt::OpenPGP::Signature->parse($buffer);
    my $hashed_data = $sig->hash_data($plaintext);
    ## Look up public key by $sig->key_id to get $cert, then...
    my $is_valid_sig = $cert->key->verify($sig, $hashed_data);


Crypt::OpenPGP::Signature implements PGP signature packets and provides functionality for hashing PGP packets to obtain message digests; these digests are then signed by the secret key to form a signature.

Crypt::OpenPGP::Signature reads and writes both version 3 and version 4 signatures, along with the signature subpackets found in version 4 (see Crypt::OpenPGP::Signature::SubPacket).


Crypt::OpenPGP::Signature->new( %arg )

Creates a new signature packet object and returns that object. If there are no arguments in %arg, the object is created empty; this is used, for example, in parse (below), to create an empty packet which is then filled from the data in the buffer.

If you wish to initialize a non-empty object, %arg can contain:


Serializes the signature packet and returns a string of octets.


Given $buffer, a Crypt::OpenPGP::Buffer object holding (or with offset pointing to) a signature packet, returns a new Crypt::OpenPGP::Signature object, initialized with the signature data in the buffer.


Prepares a digital hash of the packets in @data; the hashing method depends on the type of packets in @data, and the hashing algorithm used depends on the algorithm associated with the Crypt::OpenPGP::Signature object $sig. This digital hash is then signed to produce the signature itself.

You generally do not need to use this method unless you have not passed in the Data parameter to new (above).

There are two possible packet types that can be included in @data:


Returns the ID of the key that created the signature.


Returns the time that the signature was created in Unix epoch time (seconds since 1970).


Returns a Crypt::OpenPGP::Digest object representing the digest algorithm used by the signature.


Please see the Crypt::OpenPGP manpage for author, copyright, and license information.

 Crypt::OpenPGP::Signature - Signature packet