Alt-Crypt-RSA-BigInt
view release on metacpan or search on metacpan
t/14-ss-pkcs1v15.t view on Meta::CPAN
Accounted dangerous folly. ";
# my ($pub, $priv) = readkeys();
# SHA384 and SHA512 require a key length of at least 768.
# SHA224 amd SJA256 require a key length of at least 512.
# SHA1, MD5, and MD2 require at least 384.
my ($pub, $priv) = Crypt::RSA::Key->new->generate (
Size => 768,
Identity => 'i am i',
Password => 'guess me',
);
foreach my $hash (qw(MD2 MD5 SHA1 SHA224 SHA256 SHA384 SHA512)) {
my $pkcs = new Crypt::RSA::SS::PKCS1v15 ( Digest => $hash );
my $sig = $pkcs->sign (
Message => $message,
Key => $priv,
) || die $pkcs->errstr();
t/17-public-ssh.t view on Meta::CPAN
plan tests => 3;
# Danaj: This is definitely not the interface I would have chosen. It would
# seem like you'd like to be able to hand the string to generate.
# Why do I have to make a full new object to deserialize?
my $obj = new Crypt::RSA::Key;
my ($pub, $pri) = $obj->generate(
Identity => 'Some User <someuser@example.com>',
Password => 'guess',
Size => 512,
KF => 'SSH',
);
die $obj->errstr if $obj->errstr();
my $n1 = $pub->n;
my $s = $pub->serialize();
my ($newpub, $newpri) = $obj->generate( Size => 128, KF => 'SSH', );
my $n2 = $newpub->n;
t/18-private-ssh.t view on Meta::CPAN
plan tests => 1*2;
# Danaj: This is definitely not the interface I would have chosen. It would
# seem like you'd like to be able to hand the string to generate.
# Why do I have to make a full new object to deserialize?
my $obj = new Crypt::RSA::Key;
my ($pub, $pri) = $obj->generate(
Identity => 'Some User <someuser@example.com>',
Password => 'guess',
Size => 512,
KF => 'SSH',
);
my $n1 = $pri->n;
# You can also use IDEA, DES, DES3, Twofish2, CAST5, Rijndael, RC6, Camellia.
# Only Blowfish is required to be present based on the dependencies we list.
foreach my $cipher (qw/Blowfish/) {
my $s = $pri->serialize( Cipher => $cipher, Password => 'serpent' );
my ($newpub, $newpri) = $obj->generate( Size => 128, KF => 'SSH', );
# Do it incorrectly first. Should croak.
eval { $newpri->deserialize( String => $s, Password => "mst" ); };
like($@, qr/passphrase/i, "Bad passphrase will croak");
$newpri->deserialize( String => $s, Password => "serpent" );
# newpri should have no password assigned
$newpri->{Password} = 'guess';
is_deeply( $newpri, $pri, "private key fully deserialized using $cipher");
}
( run in 0.587 second using v1.01-cache-2.11-cpan-74e6d1fb12f )