3
# enc-dec.t - Crypt::GPG encryption / decryption tests.
4
# Copyright (c) 2005 Ashish Gulhati <crypt-gpg at neomailbox.com>
6
# All rights reserved. This code is free software; you can
7
# redistribute it and/or modify it under the same terms as Perl
10
# $Id: 04-encdec.t,v 1.5 2005/02/23 09:12:56 cvs Exp $
16
BEGIN { plan tests => 15 }
19
my $dir = $0 =~ /^\// ? $0 : $ENV{PWD} . '/' . $0; $dir =~ s/\/[^\/]*$//;
22
# Create new Crypt::GPG object
25
my $gpg = new Crypt::GPG;
26
$ENV{GPGBIN} and $gpg->gpgbin($ENV{GPGBIN});
27
$gpg->gpgopts('--compress-algo 1 --cipher-algo cast5 --force-v3-sigs --no-comment');
30
# Start test loop with different key sizes/types
31
################################################
32
for my $bits qw(1024 2048) {
33
for my $type ('ELG-E') {
35
my ($secretkey) = grep { $_->{Type} =~ /^sec[^\@]?/ } $gpg->keyinfo("A $bits $type");
36
$gpg->secretkey($secretkey);
42
@x = $gpg->encrypt("Test\n", "A $bits $type");
45
for my $nopass (0,1) {
47
# Blank out the Key password and do another round of tests
48
##########################################################
51
$gpg->keypass($secretkey, "$bits Bit $type Test Key", '');
58
$gpg->passphrase("$bits Bit $type Test Key") unless $nopass;
59
my ($clear) = $gpg->decrypt(@x);
64
# Set passphrase back to original
65
#################################
67
$gpg->keypass($secretkey, '', "$bits Bit $type Test Key");