Alt-Crypt-RSA-BigInt
view release on metacpan or search on metacpan
lib/Crypt/RSA.pm view on Meta::CPAN
ASCII_PP => { Module => "Convert::ASCII::Armour" },
);
sub new {
my ($class, %params) = @_;
my %self = (%DEFAULTS, %params);
my $self = bless \%self, $class;
$self->_storemap (%KNOWNMAP);
for (qw(ES SS PP)) {
$$self{$_} = { Name => $$self{$_} . "_$_" } unless ref $$self{$_};
$$self{lc($_)} = $self->_load ( %{$$self{$_}} );
}
$$self{keychain} = new Crypt::RSA::Key;
return bless \%self, $class;
}
sub keygen {
my ($self, %params) = @_;
$params{KF} = $$self{KF} if $$self{KF};
my @keys;
lib/Crypt/RSA/ES/OAEP.pm view on Meta::CPAN
use Crypt::RSA::Primitives;
use Crypt::RSA::Debug qw(debug);
use Digest::SHA qw(sha1);
use Sort::Versions qw(versioncmp);
use Carp;
$Crypt::RSA::ES::OAEP::VERSION = '1.99';
sub new {
my ($class, %params) = @_;
my $self = bless { primitives => new Crypt::RSA::Primitives,
P => "",
hlen => 20,
VERSION => $Crypt::RSA::ES::OAEP::VERSION,
}, $class;
if ($params{Version}) {
if (versioncmp($params{Version}, '1.15') == -1) {
$$self{P} = "Crypt::RSA";
$$self{VERSION} = $params{Version};
} elsif (versioncmp($params{Version}, $$self{VERSION}) == 1) {
croak "Required version ($params{Version}) greater than installed version ($$self{VERSION}) of $class.\n";
lib/Crypt/RSA/ES/PKCS1v15.pm view on Meta::CPAN
use Math::Prime::Util qw/random_bytes/;
use Crypt::RSA::DataFormat qw(bitsize octet_len os2ip i2osp);
use Crypt::RSA::Primitives;
use Crypt::RSA::Debug qw(debug);
use Carp;
$Crypt::RSA::ES::PKCS1v15::VERSION = '1.99';
sub new {
my ($class, %params) = @_;
my $self = bless { primitives => new Crypt::RSA::Primitives,
VERSION => $Crypt::RSA::ES::PKCS1v15::VERSION,
}, $class;
if ($params{Version}) {
# do versioning here.
}
return $self;
}
sub encrypt {
lib/Crypt/RSA/Errorhandler.pm view on Meta::CPAN
use warnings;
## Crypt::RSA::Errorhandler -- Base class that provides error
## handling functionality.
##
## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
## This code is free software; you can redistribute it and/or modify
## it under the same terms as Perl itself.
sub new {
bless {}, shift
}
sub error {
my ($self, $errstr, @towipe) = @_;
$$self{errstr} = "$errstr\n";
for (@towipe) {
my $var = $_;
if (ref($var) =~ /Crypt::RSA/) {
$var->DESTROY();
lib/Crypt/RSA/Key.pm view on Meta::CPAN
Native_PKF => { Module => "Crypt::RSA::Key::Public" },
Native_SKF => { Module => "Crypt::RSA::Key::Private" },
SSH_PKF => { Module => "Crypt::RSA::Key::Public::SSH" },
SSH_SKF => { Module => "Crypt::RSA::Key::Private::SSH" },
);
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
$self->_storemap ( %MODMAP );
return $self;
}
sub generate {
my ($self, %params) = @_;
my $key;
lib/Crypt/RSA/Key/Private.pm view on Meta::CPAN
use Math::Prime::Util qw/is_prime/;
use Carp;
$Crypt::RSA::Key::Private::VERSION = '1.99';
sub new {
my ($class, %params) = @_;
my $self = { Version => $Crypt::RSA::Key::Private::VERSION };
if ($params{Filename}) {
bless $self, $class;
$self = $self->read (%params);
return bless $self, $class;
} else {
bless $self, $class;
$self->Identity ($params{Identity}) if $params{Identity};
$self->Cipher ($params{Cipher}||"Blowfish");
$self->Password ($params{Password}) if $params{Password};
return $self;
}
}
sub AUTOLOAD {
lib/Crypt/RSA/Key/Public.pm view on Meta::CPAN
use base 'Crypt::RSA::Errorhandler';
use Math::BigInt try => 'GMP, Pari';
$Crypt::RSA::Key::Public::VERSION = '1.99';
sub new {
my ($class, %params) = @_;
my $self = { Version => $Crypt::RSA::Key::Public::VERSION };
if ($params{Filename}) {
bless $self, $class;
$self = $self->read (%params);
return bless $self, $class;
} else {
return bless $self, $class;
}
}
sub AUTOLOAD {
my ($self, $value) = @_;
my $key = $AUTOLOAD; $key =~ s/.*:://;
if ($key =~ /^n|e$/) {
if (defined $value) {
lib/Crypt/RSA/Primitives.pm view on Meta::CPAN
## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
## This code is free software; you can redistribute it and/or modify
## it under the same terms as Perl itself.
use base 'Crypt::RSA::Errorhandler';
use Crypt::RSA::Debug qw(debug);
use Math::BigInt try => 'GMP, Pari';
use Carp;
sub new {
return bless {}, shift;
}
sub core_encrypt {
# procedure:
# c = (m ** e) mod n
my ($self, %params) = @_;
my $key = $params{Key};
lib/Crypt/RSA/SS/PKCS1v15.pm view on Meta::CPAN
# See if we have a bug-fixed RIPEMD-160.
my $ripe_hash = undef;
if (eval { require Crypt::RIPEMD160; $Crypt::RIPEMD160::VERSION >= 0.05; }) {
$ripe_hash = sub { my $r=new Crypt::RIPEMD160; $r->add(shift); $r->digest();};
}
sub new {
my ($class, %params) = @_;
my $self = bless {
primitives => new Crypt::RSA::Primitives,
digest => $params{Digest} || 'SHA1',
encoding => {
# See http://rfc-ref.org/RFC-TEXTS/3447/chapter9.html
MD2 =>[\&md2, "30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 02 05 00 04 10"],
MD5 =>[\&md5, "30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 05 05 00 04 10"],
SHA1 =>[\&sha1, "30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14"],
SHA224=>[\&sha224,"30 2d 30 0d 06 09 60 86 48 01 65 03 04 02 04 05 00 04 1c"],
SHA256=>[\&sha256,"30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20"],
SHA384=>[\&sha384,"30 41 30 0d 06 09 60 86 48 01 65 03 04 02 02 05 00 04 30"],
lib/Crypt/RSA/SS/PSS.pm view on Meta::CPAN
use Math::Prime::Util qw/random_bytes/;
use Crypt::RSA::DataFormat qw(octet_len os2ip i2osp octet_xor mgf1);
use Crypt::RSA::Primitives;
use Crypt::RSA::Debug qw(debug);
use Digest::SHA qw(sha1);
$Crypt::RSA::SS::PSS::VERSION = '1.99';
sub new {
my ($class, %params) = @_;
my $self = bless { primitives => new Crypt::RSA::Primitives,
hlen => 20,
VERSION => $Crypt::RSA::SS::PSS::VERSION,
}, $class;
if ($params{Version}) {
# do versioning here
}
return $self;
}
( run in 0.811 second using v1.01-cache-2.11-cpan-de7293f3b23 )