PGP-Mail
view release on metacpan or search on metacpan
use GnuPG::Interface;
use MIME::Parser;
=head1 NAME
PGP::Mail - Signature checking for PGP-signed mail messages
=head1 SYNOPSIS
use PGP::Mail;
my $pgpmail=new PGP::Mail($mail, {default-keyring=>"kr.gpg"});
$status=$pgpmail->status();
$keyid=$pgpmail->keyid();
$data=$pgpmail->data();
=head1 DESCRIPTION
This module operates on PGP-signed mail messages. It checks the signature of
either a standard clearsigned, a signed message or a PGP/MIME style message.
It returns an object which can be used to check what the signed data was,
}
$self->{status}="unverified";
$self->{keyid}="0x0000000000000000";
$self->{data}=join("",@lines);
if(!$self->{PGPTEXT} && !$self->{PGPMIME}) {
return 0;
}
$self->{gpg}=new GnuPG::Interface;
$self->{gpg}->options->hash_init( %$args );
$self->{gpg}->options->meta_interactive( 0 );
if($self->{PGPTEXT}) {
$self->textpgp(\@lines);
}
else {
$self->mimepgp(\@lines, $self->{PGPMIMEBOUND});
}
return 1;
}
my $error=new IO::Handle;
my $status=new IO::Handle;
my $pp=new IO::Handle;
my $handles=GnuPG::Handles->new(
stdin=>$input,
stdout=>$output,
stderr=>$error,
status=>$status,
passphrase=>$pp
);
my $pid=$self->{gpg}->decrypt(handles=>$handles);
close $pp;
print $input join "",@$data;
close $input;
$self->{data}=join "",<$output>;
close $output;
$self->get_status($status);
waitpid $pid, 0;
my $input=new IO::Handle;
my $output=new IO::Handle;
my $error=new IO::Handle;
my $status=new IO::Handle;
my $handles=GnuPG::Handles->new(
stdin=>$input,
stdout=>$output,
stderr=>$error,
status=>$status
);
my $pid=$self->{gpg}->verify(handles=>$handles, command_args=>["-",$fn]);
print $input $signature;
close $input;
$parser=new MIME::Parser;
$parser->output_to_core(1);
$self->{data}=$parser->parse_data($sigdata)->bodyhandle->as_string;
$self->get_status($status);
( run in 0.996 second using v1.01-cache-2.11-cpan-df04353d9ac )