AnyEvent-GnuPG
view release on metacpan or search on metacpan
This file contains message digests of all files listed in MANIFEST,
signed via the Module::Signature module, version 0.73.
To verify the content in this distribution, first make sure you have
Module::Signature installed, then type:
% cpansign -v
It will check each file's integrity, as well as the signature's
validity. If "==> Signature verified OK! <==" is not displayed,
the distribution may already have been compromised, and you should
not run its Makefile.PL or Build.PL.
-----BEGIN PGP SIGNED MESSAGE-----
lib/AnyEvent/GnuPG.pm view on Meta::CPAN
sub clearsign {
my $self = shift;
$self->sign( @_, clearsign => 1 );
}
sub clearsign_cb {
my $self = shift;
$self->sign_cb( @_, clearsign => 1 );
}
sub verify {
shift->verify_cb(@_)->recv;
}
sub verify_cb {
my ( $self, %args ) = @_;
my $cv = _condvar( delete $args{cb} );
return _croak( $cv, "missing signature argument" ) unless $args{signature};
my $files = [];
if ( $args{file} ) {
$args{file} = [ $args{file} ] unless ref $args{file};
@$files = ( $args{signature}, @{ $args{file} } );
}
else {
lib/AnyEvent/GnuPG.pm view on Meta::CPAN
}
my $options = [];
push @$options, "--auto-key-locate", $args{"auto-key-locate"}
if defined $args{"auto-key-locate"};
push @$options, "--keyserver", $args{"keyserver"}
if defined $args{"keyserver"};
my @verify_options = ();
push @verify_options => 'pka-lookups' if $args{'pka-loopups'};
push @verify_options => 'pka-trust-increase' if $args{'pka-trust-increase'};
push @$options => ( '--verify-options' => join( ',' => @verify_options ) )
if @verify_options;
$self->_command("verify");
$self->_options($options);
$self->_args($files);
my $proc = $self->_run_gnupg($cv);
$proc->finish unless $self->{input};
my $sig = { trust => TRUST_UNDEFINED, };
$self->_parse_status(
$cv,
lib/AnyEvent/GnuPG.pm view on Meta::CPAN
output => "file.txt"
);
$gpg->clearsign(
plaintext => "file.txt",
output => "file.txt.asc",
passphrase => $secret,
armor => 1,
);
$gpg->verify(
signature => "file.txt.asc",
file => "file.txt"
);
$gpg->gen_key(
name => "Joe Blow",
comment => "My GnuPG key",
passphrase => $secret,
);
lib/AnyEvent/GnuPG.pm view on Meta::CPAN
Asynchronous variant of L</sign>.
=head2 clearsign(%params)
This methods clearsign a message. The output will contains the original message with a signature appended. It takes the same parameters as the L</sign> method.
=head2 clearsign_cb(%params[, cb => $callback|$condvar])
Asynchronous variant of L</clearsign>.
=head2 verify(%params)
This method verifies a signature against the signed message. The methods croaks if the signature is invalid or an error is encountered. If the signature is valid, it returns an hash with the signature parameters. Here are the method's parameters:
=over 4
=item * signature
If the message and the signature are in the same file (i.e. a clearsigned message), this parameter can be either a file name or anything else that L<AnyEvent::Proc/pull> accepts.
If the signature doesn't follows the message, than it must be the name of the file that contains the signature and the parameter I<file> must be used to name the signed data.
lib/AnyEvent/GnuPG.pm view on Meta::CPAN
The fingerprint of the signature.
=item * trust
The trust value of the public key of the signer. Those are values that can be imported in your namespace with the :trust tag. They are (TRUST_UNDEFINED, TRUST_NEVER, TRUST_MARGINAL, TRUST_FULLY, TRUST_ULTIMATE).
=back
Example:
my $sig = $gpg->verify(
signature => "file.txt.asc",
file => "file.txt"
);
=head2 verify_cb(%params[, cb => $callback|$condvar])
Asynchronous variant of L</verify>.
=head2 decrypt(%params)
This method decrypts an encrypted message. It croaks, if there is an error while decrypting the message. If the message was signed, this method also verifies the signature. If decryption is sucessful, the method either returns the valid signature par...
=over 4
=item * ciphertext
This optional parameter contains either the name of the file containing the ciphertext or a reference to a file handle containing the ciphertext.
pipe_decrypt_test
encrypt_sign_test
encrypt_sym_test
encrypt_notrust_test
decrypt_test
decrypt_sign_test
decrypt_sym_test
sign_test
detachsign_test
clearsign_test
verify_sign_test
verify_detachsign_test
verify_clearsign_test
multiple_recipients
)
);
if ( defined $ENV{TESTS} ) {
@tests = split /\s+/, $ENV{TESTS};
}
unless ( Env::Path->PATH->Whence('gpg') ) {
plan skip_all => 'gpg needed for this module';
die unless -s "test/file.txt.cipher";
$gpg->decrypt(
output => "test/file.txt.plain3",
ciphertext => "test/file.txt.cipher",
symmetric => 1,
passphrase => PASSWD,
);
ok -s "test/file.txt.plain3";
}
sub verify_sign_test {
die unless -s "test/file.txt.sig";
$gpg->verify( signature => "test/file.txt.sig" );
}
sub verify_detachsign_test {
die unless -s "test/file.txt.asc";
die unless -s "test/file.txt";
$gpg->verify(
signature => "test/file.txt.asc",
file => "test/file.txt",
);
}
sub verify_clearsign_test {
die unless -s "test/file.txt.clear";
$gpg->verify( signature => "test/file.txt.clear" );
}
sub encrypt_from_fh_test {
die unless -s "test/file.txt";
open( FH, "test/file.txt" ) or die "error opening file: $!\n";
$gpg->encrypt(
recipient => UNTRUSTED,
output => "test/file-fh.txt.gpg",
armor => 1,
plaintext => \*FH,
( run in 0.486 second using v1.01-cache-2.11-cpan-5467b0d2c73 )