AnyEvent-GnuPG

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for GnuPG

1.001 2014-12-10
 - improve test
 - satisfy perlcritic
 - more documentation
 - add method for getting gpg version
 - abort when ttl exceeded
 - increase ttl to 10min
 - tidy up code

1.000 2014-12-06
 - merge ChangeLog with NEWS to Changes
 - tidy up code (Perl::Tidy)
 - remove spec file

 [API CHANGES]

Changes  view on Meta::CPAN

0.09_02 2009-05-06 Robbie Bow
 - Dev release - update $VERSION in GnuPG.pm to see cpantesters reports

0.09_01 2009-05-06 Robbie Bow
 - Dev release that cargo cults the numerous fixes Debian maintainers have
   added since the last release. See debian/chnagelog for more details

0.08 2001-05-21 Francis J. Lacoste  <francis.lacoste@Contre.COM>
 - Fix POSIX::_SC_OPEN_MAX problem under use strict.
 - Updated for gnupg 1.0.5
 - Tie implementation doesn't add an extra fork. Only one fork for the gpg
   process is done.
 - Added ClearSign and Sign tie interface.
 - GnuPG.pm (sign): Check for invalid passphrase. (Thanks to Park Hays for
   reporting this).
 - GnuPG/Tie/Sign.pm (run_gnupg): Updates for new tie implementation.
 - GnuPG/Tie/Encrypt.pm (run_gnupg): Updates for new tie implementation.
 - GnuPG/Tie/Decrypt.pm (run_gnupg,postread_hook,postwrite_hook): Updates
   for new tie implementation. (signature) Returns the signature info of
   the decryption.
 - GnuPG/Tie/ClearSign.pm (run_gnupg): Updates for new tie implementation.

Changes  view on Meta::CPAN

 - NEWS: Updated for version 0.07.
 - README: Updated for version 0.07.
 - GnuPG.pm (VERSION): Updated version number to 0.07. (run_gnupg): Close
   the fh ref not its file descriptor.
 - test.pl: Added tests for encryption and decryption to a file reference /
   pipe.

0.06 2000-08-07 Francis J. Lacoste  <francis.lacoste@iNsu.COM>
 - Local-user wasn't working. Thanks to Chris Andrews for reporting and
   fixing this.
 - Compatible with gpg 1.02.
 - Ignore warning about RSA or IDEA algorithms.
 - Tag: GNUPG_0_06
 - GnuPG.spec: Updated spec file to use new macros.
 - GnuPG.pm (encrypt): Local user option wasn't working. (Thanks to Chris
   Andrews for the fix) (sign): Local user option wasn't working.
   (version):  Version number is now 0.06

0.05 2000-06-21 Francis J. Lacoste  <francis.lacoste@iNsu.COM>
 - Support for paragraph mode in tied interface. 
 - Removed file descriptor leaks.

Changes  view on Meta::CPAN

   Make sure that we are using newlin as INPUT_RECORD_SEPARATOR.

0.04 1999-12-06 Francis J. Lacoste  <francis.lacoste@iNsu.COM>
 - Small bugfixes related to running under mod_perl.
 - Tag: GNUPG_0_04
 - NEWS: Added a news file.
 - GnuPG/Tie.pm(new): Make sure that pipes aren't closed after an exec and
   that they are unbuffered. Also use CORE::Exit(0) instead of exit(0) so
   that the things works under mod_perl. (version): Upgraded to version
   0.04.
 - GnuPG.pm (new): Specifying gnupg_path wasn't working properly. When gpg
   isn't found in PATH print the content of PATH in the error message.
   (run_gnupg): /dev/null wasn't open for writing. Use CORE::exit(1) so
   that the function still works under mod_perl.

0.03 1999-11-30 Francis J. Lacoste  <francis.lacoste@iNsu.COM>
 - New tied file handle interface for encryption and decryption. 
 - Small bugfixes.
 - GnuPG.pm (pod): Inserted a line before a =over line. Added reference to
   documentation on tied file handle operations. (send_cpr): Removed
   undefined warning when expecting an optional command and receiving an

Changes  view on Meta::CPAN

 - GnuPG/Tie/Encrypt.pm: Added decryption on a tied filehandle.
 - GnuPG/Tie.pm:       Added abstract implementation for tied filehandle
   operations on GnuPG.

0.02 1999-09-08 Francis J. Lacoste  <francis.lacoste@iNsu.COM>
 - TAG: GNUPG_0_02
 - GnuPG.pm: Removed colons from tag names.
 - GnuPG.pm(run_gnupg): Handled input and output from file handle
   correctly.
 - GnuPG.pm(abort_gnupg): Aborting now correctly throws the error message.
 - gpgmailtunl: Added as sample program.

0.01 1999-09-05 Francis J. Lacoste  <francis.lacoste@iNsu.COM>
 - GnuPG.pm: Release 0.01.

MANIFEST  view on Meta::CPAN

lib/AnyEvent/GnuPG.pm
t/00-all.t
t/author-critic.t
t/release-cpan-changes.t
t/release-kwalitee.t
t/release-pod-coverage.t
t/release-pod-syntax.t
test/file.txt
test/key1.pub
test/key2.pub
test/pubring.gpg
test/secring.gpg
test/trustdb.gpg

SIGNATURE  view on Meta::CPAN

SHA1 3d31b7328ffc0cf9a8891992dba95d81c4042f21 lib/AnyEvent/GnuPG.pm
SHA1 1df65007fe3a6e5c6a199eb51e33d57a6e7757f0 t/00-all.t
SHA1 f214de96cfe8b70da71201ab8859bb32cbdafe1d t/author-critic.t
SHA1 1bf69b71b924777ef46b198af9435e8381149fc7 t/release-cpan-changes.t
SHA1 bdd52baa1a968cc0e1a577a7b073f046d563a317 t/release-kwalitee.t
SHA1 ca37d7b91c2299a98877a6f36d3fab51e8dd906f t/release-pod-coverage.t
SHA1 e7fc4d8f3f29ee522cb53914648393524fc7a6d4 t/release-pod-syntax.t
SHA1 3c1bb0cd5d67dddc02fae50bf56d3a3a4cbc7204 test/file.txt
SHA1 225351eaed33e148482bc8ae65d55c9a3da34d70 test/key1.pub
SHA1 84cdd20da0e0ad49b80cc5080d3ff5707a7eb646 test/key2.pub
SHA1 56b646d641cf5f6bfe3986fa08bdd789fa186910 test/pubring.gpg
SHA1 4e36aec8e52412f8f388b3db5c891bb4e2742af9 test/secring.gpg
SHA1 7110a2f778af29f4a62ec593958ad656777d68fc test/trustdb.gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBAgAGBQJUiE51AAoJEHwWRyBU62lqHncP/2o6HERM3R41vmYH/Bh5Kg93
rsT+rglYUoMBLjN5F8QjctjM+EkR6mVdv9/WZ7mIBcBEh1YDnqZUkz3bOTgR9VXA
eabHsJt1RxkBtq0ugkQ9HukB48uPwzcXJvKGfOPHaPT3tc7tlWTusZdqJTHt8LsH
uHp+9oUEsCCN3AS1+vheS49u/FPLzSKZydK02w+nGLGxFkhv0vIPS0GlonWt6vtF
35Bs91kcx8vuTIH+kWgL9+hc0wYWYapP9AFmLI+qMvioFcbn96RSotPco1gjhHNi
pOhhMlsNdvL+iAmkr1TJYT0nclsX6+0o7VnLBSvESgxfoigYzv8nFnMjBga5oGA8
97wGr2MaxSC5PS6pBwu9uumm26jt45Zf3P83W0sE2wdZA1t27NNujINHbKE6Hxav
CSrzJL132Q2m7aAM5HLswNO2prQktadubIsc2ErkqGvxLtXiwxnkScuPraDasiJW
nrmTuJpv7Vj1roAkFPAAYzj0kIB74XImUBHsSdf/LLBmAr45uajPFVZiWK9XC0NK

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN


    if ( defined $self->{output} and not ref $self->{output} ) {
        my $file = $self->{output};
        open( my $fh, '>', $file ) or die "cannot open file $file: $!";
        AE::log info => "output file $file opened at $fh";
        $self->{output} = $fh;
    }

    my $cmdline = $self->_cmdline;

    my $gpg = shift @$cmdline;

    my $status  = AnyEvent::Proc::reader();
    my $command = AnyEvent::Proc::writer();

    unshift @$cmdline, '--status-fd'  => $status;
    unshift @$cmdline, '--command-fd' => $command;

    my $err;

    AE::log debug => "running $gpg " . join( ' ' => @$cmdline );
    my $proc = AnyEvent::Proc->new(
        bin           => $gpg,
        args          => $cmdline,
        extras        => [ $status, $command ],
        ttl           => 600,
        on_ttl_exceed => sub { $self->_abort_gnupg( 'ttl exceeded', $cv ) },
        errstr        => \$err,
    );

    if ( defined $self->{input} ) {
        $proc->pull( $self->{input} );
    }

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

        confess("Invalid home directory: $args{homedir}")
          unless -d $args{homedir} && -x _;
        $self->{homedir} = $args{homedir};
    }
    if ( $args{options} ) {
        confess("Invalid options file: $args{options}")
          unless -r $args{options};
        $self->{options} = $args{options};
    }
    if ( $args{gnupg_path} ) {
        confess("Invalid gpg path: $args{gnupg_path}")
          unless -x $args{gnupg_path};
        $self->{gnupg_path} = $args{gnupg_path};
    }
    else {
        my ($path) = grep { -x "$_/gpg" } split /:/, $ENV{PATH};
        confess("Couldn't find gpg in PATH ($ENV{PATH})") unless $path;
        $self->{gnupg_path} = "$path/gpg";
    }

    bless $self, $class;
}

sub version {
    shift->version_cb(@_)->recv;
}

sub version_cb {

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

AnyEvent::GnuPG - AnyEvent-based interface to the GNU Privacy Guard

=head1 VERSION

version 1.001

=head1 SYNOPSIS

    use AnyEvent::GnuPG qw( :algo );

    my $gpg = AnyEvent::GnuPG->new();

    $gpg->encrypt(
        plaintext   => "file.txt",
        output      => "file.gpg",
        armor       => 1,
        sign        => 1,
        passphrase  => $secret
    );
    
    $gpg->decrypt(
        ciphertext    => "file.gpg",
        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,
    );

=head1 DESCRIPTION

AnyEvent::GnuPG is a perl interface to the GNU Privacy Guard. It uses the shared memory coprocess interface that gpg provides for its wrappers. It tries its best to map the interactive interface of the gpg to a more programmatic model.

=head1 METHODS

=head2 new(%params)

You create a new AnyEvent::GnuPG wrapper object by invoking its new method. (How original!). The module will try to finds the B<gpg> program in your path and will croak if it can't find it. Here are the parameters that it accepts:

=over 4

=item * gnupg_path

Path to the B<gpg> program.

=item * options

Path to the options file for B<gpg>. If not specified, it will use the default one (usually F<~/.gnupg/options>).

=item * homedir

Path to the B<gpg> home directory. This is the directory that contains the default F<options> file, the public and private key rings as well as the trust database.

=back

Example:

    my $gpg = AnyEvent::GnuPG->new();

=head2 version

This method returns the current gpg version as list.

    my @version = $gpg->version;
    # returns ( 1, 4, 18 ) for example

=head2 version_cb

Asynchronous variant of L</version>.

=head2 gen_key(%params)

This methods is used to create a new gpg key pair. The methods croaks if there is an error. It is a good idea to press random keys on the keyboard while running this methods because it consumes a lot of entropy from the computer. Here are the paramet...

=over 4

=item * algo

This is the algorithm use to create the key. Can be I<DSA_ELGAMAL>, I<DSA>, I<RSA_RSA> or I<RSA>. It defaults to I<DSA_ELGAMAL>. To import those constant in your name space, use the I<:algo> tag.

=item * size

The size of the public key. Defaults to 1024. Cannot be less than 768 bits, and keys longer than 2048 are also discouraged. (You *DO* know that your monitor may be leaking sensitive information ;-).

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

Optional comment portion of the user id.

=item * passphrase

The passphrase that will be used to encrypt the private key. Optional but strongly recommended.

=back

Example:

    $gpg->gen_key(
        algo => DSA_ELGAMAL,
        size => 1024,
        name => "My name"
    );

=head2 gen_key_cb(%params[, cb => $callback|$condvar])

Asynchronous variant of L</gen_key>.

=head2 import_keys(%params)

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

=over 4

=item * keys

Only parameter and mandatory. It can either be an ArrayRef containing a list of files that will be imported or a single file name or anything else that L<AnyEvent::Proc/pull> accepts.

=back

Example:

    $gpg->import_keys(
        keys => [qw[ key.pub key.sec ]]
    );

=head2 import_keys_cb(%args[, cb => $callback|$condvar])

Asynchronous variant of L</import_keys>. It returns the number of keys imported.

=head2 import_key($string)

Import one single key into the GnuPG private or public keyring. The method croaks if it encounters an error.

Example:

    $gpg->import_keys($string);

=head2 import_key_cb($string[, $callback|$condvar])

Asynchronous variant of L</import_key>.

=head2 export_keys(%params)

Exports keys from the GnuPG keyrings. The method croaks if it encounters an error. Parameters:

=over 4

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

This argument specifies where the keys will be exported. Can be either a file name or anything else that L<AnyEvent::Proc/pipe> accepts.

=item * armor

Set this parameter to true, if you want the exported keys to be ASCII armored.

=back

Example:

    $gpg->export_keys(
        armor => 1,
        output => "keyring.pub"
    );

=head2 export_keys_cb(%params[, cb => $callback|$condvar])

Asynchronous variant of L</export_keys>.

=head2 encrypt(%params)

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

This parameter is used to specified the private key that will be used to sign the message. If left unspecified, the default user will be used. This option only makes sense when using the I<sign> option.

=item * passphrase

This parameter contains either the secret passphrase for the symmetric algorithm or the passphrase that should be used to decrypt the private key.

=back

Example:

    $gpg->encrypt(
        plaintext => file.txt,
        output => "file.gpg",
        sign => 1,
        passphrase => $secret
    );

=head2 encrypt_cb(%params[, cb => $callback|$condvar])

Asynchronous variant of L</encrypt>.

=head2 sign(%params)

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

This parameter is used to specified the private key that will be used to make the signature. If left unspecified, the default user will be used.

=item * detach-sign

If set to true, a digest of the data will be signed rather than the whole file.

=back

Example:

    $gpg->sign(
        plaintext => "file.txt",
        output => "file.txt.asc",
        armor => 1
    );

=head2 sign_cb(%params[, cb => $callback|$condvar])

Asynchronous variant of L</sign>.

=head2 clearsign(%params)

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)

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

This should be set to true, if the message is encrypted using symmetric cryptography.

=item * passphrase

The passphrase that should be used to decrypt the message (in the case of a message encrypted using a symmetric cipher) or the secret that will unlock the private key that should be used to decrypt the message.

=back

Example:

    $gpg->decrypt(
        ciphertext => "file.gpg",
        output => "file.txt",
        passphrase => $secret
    );

=head2 decrypt_cb(%params[, cb => $callback|$condvar])

Asynchronous variant of L</decrypt>.

=head1 API OVERVIEW

The API is accessed through methods on a AnyEvent::GnuPG object which is a wrapper around the B<gpg> program. All methods takes their argument using named parameters, and errors are returned by throwing an exception (using croak). If you wan't to cat...

This modules uses L<AnyEvent::Proc>. For input data, all of L<AnyEvent::Proc/pull> and for output data, all of L<AnyEvent::Proc/pipe> possible handle types are allowed.

The code is based on L<GnuPG> with API compatibility except that L<GnuPG::Tie> is B<not> ported.

=head2 CALLBACKS AND CONDITION VARIABLES

Every method has a callback variant, suffixed with I<_cb>. These methods accept an optional parameter called I<cb>, which can be a CodeRef or an L<AnyEvent>::CondVar and returns a condvar.

    $gpg->method_cb(%params, cb => sub {
        my $result = shift->recv; # croaks on error
        ...
    });

    my $cv = $gpg->method_cb(%params);
    my $result = $cv->recv; # croaks on error
    ...

The non-callback variants are all wrapper methods, looking something like this:

    sub method {
        shift->method_cb(@_)->recv
    }

=head1 EXPORTS

lib/AnyEvent/GnuPG.pm  view on Meta::CPAN

=head1 BUGS AND LIMITATIONS

This module doesn't work (yet) with the v2 branch of GnuPG.

=head1 SEE ALSO

=over 4

=item * L<GnuPG>

=item * L<gpg(1)>

=back

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website
https://github.com/zurborg/libanyevent-gnupg-perl/issues

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired

t/00-all.t  view on Meta::CPAN

      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';
}
else {
    plan tests => scalar @tests;
}

my $gpg = AnyEvent::GnuPG->new( homedir => "test" );

for (@tests) {
    subtest $_ => sub {
        try {
            no strict 'refs';    ## no critic
            &$_();
            pass;
        }
        catch {
            fail;
            diag $_;
        }
      }

}

sub version {
    my @version = $gpg->version;
    ok @version;
    is shift(@version) => 1,
      'gpg v1 ok'
      or BAIL_OUT "this module works only with gpg v1";
}

sub multiple_recipients {
    die unless -s "test/file.txt";
    $gpg->encrypt(
        recipient => [ USERID, UNTRUSTED ],
        output    => "test/file.txt.gpg",
        armor     => 1,
        plaintext => "test/file.txt",
    );
    ok -s "test/file.txt.gpg";
}

sub gen_key_test {
    if ( $ENV{AUTOMATED_TESTING} ) {
        return;
    }
    diag "Generating a key - can take some time";
    $gpg->gen_key(
        passphrase => PASSWD,
        name       => USERID,
        progress   => sub {
            local $, = ', ';
            diag "progress @_" if $ENV{AUTOMATED_TESTING};
        }
    );
}

sub import_test {
    $gpg->import_keys( keys => "test/key1.pub" );
}

sub import2_test {
    $gpg->import_keys( keys => "test/key1.pub" );
}

sub import3_test {
    $gpg->import_keys( keys => [qw( test/key1.pub test/key2.pub )] );
}

sub export_test {
    $gpg->export_keys(
        keys   => USERID,
        armor  => 1,
        output => "test/key.pub",
    );
    ok -s "test/key.pub";
}

sub export2_test {
    $gpg->export_keys(
        armor  => 1,
        output => "test/keyring.pub",
    );
    ok -s "test/keyring.pub";
}

sub export_secret_test {
    $gpg->export_keys(
        secret => 1,
        armor  => 1,
        output => "test/key.sec",
    );
    ok -s "test/key.sec";
}

sub encrypt_test {
    die unless -s "test/file.txt";
    $gpg->encrypt(
        recipient => USERID,
        output    => "test/file.txt.gpg",
        armor     => 1,
        plaintext => "test/file.txt",
    );
    ok -s "test/file.txt.gpg";
}

sub pipe_encrypt_test {
    die unless -s "test/file.txt";
    open CAT, "| cat > test/pipe-file.txt.gpg" or die "can't fork: $!\n";
    $gpg->encrypt(
        recipient => USERID,
        output    => \*CAT,
        armor     => 1,
        plaintext => "test/file.txt",
    );
    close CAT;
    ok -s "test/pipe-file.txt.gpg";
}

sub encrypt_sign_test {
    die unless -s "test/file.txt";
    $gpg->encrypt(
        recipient  => USERID,
        output     => "test/file.txt.sgpg",
        armor      => 1,
        sign       => 1,
        plaintext  => "test/file.txt",
        passphrase => PASSWD,
    );
    ok -s "test/file.txt.sgpg";
}

sub encrypt_sym_test {
    die unless -s "test/file.txt";
    $gpg->encrypt(
        output     => "test/file.txt.cipher",
        armor      => 1,
        plaintext  => "test/file.txt",
        symmetric  => 1,
        passphrase => PASSWD,
    );
    ok -s "test/file.txt.cipher";
}

sub encrypt_notrust_test {
    die unless -s "test/file.txt";
    $gpg->encrypt(
        recipient  => UNTRUSTED,
        output     => "test/file.txt.dist.gpg",
        armor      => 1,
        sign       => 1,
        plaintext  => "test/file.txt",
        passphrase => PASSWD,
    );
    ok -s "test/file.txt.dist.gpg";
}

sub sign_test {
    die unless -s "test/file.txt";
    $gpg->sign(
        recipient  => USERID,
        output     => "test/file.txt.sig",
        armor      => 1,
        plaintext  => "test/file.txt",
        passphrase => PASSWD,
    );
    ok -s "test/file.txt.sig";
}

sub detachsign_test {
    die unless -s "test/file.txt";
    $gpg->sign(
        recipient     => USERID,
        output        => "test/file.txt.asc",
        "detach-sign" => 1,
        armor         => 1,
        plaintext     => "test/file.txt",
        passphrase    => PASSWD,
    );
    ok -s "test/file.txt.asc";
}

sub clearsign_test {
    die unless -s "test/file.txt";
    $gpg->clearsign(
        output     => "test/file.txt.clear",
        armor      => 1,
        plaintext  => "test/file.txt",
        passphrase => PASSWD,
    );
    ok -s "test/file.txt.clear";
}

sub decrypt_test {
    die unless -s "test/file.txt.gpg";
    $gpg->decrypt(
        output     => "test/file.txt.plain",
        ciphertext => "test/file.txt.gpg",
        passphrase => PASSWD,
    );
    ok -s "test/file.txt.plain";
}

sub pipe_decrypt_test {
    die unless -s "test/file.txt.gpg";
    open CAT, "cat test/file.txt.gpg|" or die "can't fork: $!\n";
    $gpg->decrypt(
        output     => "test/file.txt.plain",
        ciphertext => \*CAT,
        passphrase => PASSWD,
    );
    close CAT;
    ok -s "test/file.txt.plain";
}

sub decrypt_sign_test {
    die unless -s "test/file.txt.sgpg";
    $gpg->decrypt(
        output     => "test/file.txt.plain2",
        ciphertext => "test/file.txt.sgpg",
        passphrase => PASSWD,
    );
    ok -s "test/file.txt.plain2";
}

sub decrypt_sym_test {
    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,
    );
    close FH;
    ok -s "test/file-fh.txt.gpg";
}

sub encrypt_to_fh_test {
    die unless -s "test/file.txt";
    open( FH, ">test/file-fho.txt.gpg" ) or die "error opening file: $!\n";
    $gpg->encrypt(
        recipient => UNTRUSTED,
        output    => \*FH,
        armor     => 1,
        plaintext => "test/file.txt",
    );
    close FH;
    ok -s "test/file-fho.txt.gpg";
}



( run in 1.393 second using v1.01-cache-2.11-cpan-e1769b4cff6 )