Crypt-Keys
view release on metacpan or search on metacpan
t/10-private.t view on Meta::CPAN
# $Id: 10-private.t,v 1.5 2002/02/16 18:26:44 btrott Exp $
use Test;
use Crypt::Keys;
my($no_pem, $no_ssh1);
BEGIN {
eval "use Convert::PEM;";
$no_pem = $@;
eval "use Crypt::CBC; use Crypt::DES;";
$no_ssh1 = $@;
}
use File::Spec::Functions qw( catfile );
use vars qw( $SAMPLES );
my %ALG;
BEGIN {
unshift @INC, 't/';
require 'test-common.pl';
%ALG = (
DSA_PEM => {
keyfile => catfile($SAMPLES, 'dsa-priv.pem'),
datafields => [ qw( p q g pub_key priv_key ) ],
format => 'Private::DSA::PEM',
desc => 'DSA Private Key, PEM-encoded',
skip => $no_pem,
},
RSA_PEM => {
keyfile => catfile($SAMPLES, 'rsa-priv.pem'),
datafields => [ qw( e n p q d dp dq iqmp ) ],
format => 'Private::RSA::PEM',
desc => 'RSA Private Key, PEM-encoded',
skip => $no_pem,
},
DSA_SSH2 => {
keyfile => catfile($SAMPLES, 'dsa-priv.ssh2'),
datafields => [ qw( p q g pub_key priv_key ) ],
format => 'Private::DSA::SSH2',
desc => 'DSA Private Key, SSH2-encoded',
skip => 0,
},
RSA_SSH1 => {
keyfile => catfile($SAMPLES, 'rsa-priv.ssh1'),
datafields => [ qw( e n p q d dp dq iqmp ) ],
format => 'Private::RSA::SSH1',
desc => 'RSA Private Key, SSH1-encoded',
skip => $no_ssh1,
},
);
my $num_tests = 0;
for my $alg (keys %ALG) {
next if $ALG{$alg}{skip};
$num_tests += 15; ## static tests
$num_tests += @{ $ALG{$alg}{datafields} } * 3;
}
plan tests => $num_tests;
}
for my $alg (keys %ALG) {
my $rec = $ALG{$alg};
next if $rec->{skip};
my $type_data = Crypt::Keys->detect( Filename => $rec->{keyfile} );
ok($type_data && ref($type_data) eq "HASH");
ok($type_data->{Format} & $type_data->{Description});
ok($type_data->{Format}, $rec->{format});
( run in 2.776 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )