OK, a wierd title, but I couldn't think of anything else.
Here's what I did after I
installed Crypt::RSA.
Had a look at
the author's tutorial at perl's own website.
Followed suit and prepared this code:
#!/usr/bin/perl
use strict;
use Crypt::RSA;
my $message="string";
my $rsa = new Crypt::RSA;
my ($public, $private) = $rsa->keygen( Size => 64 );
print "My Public key is: $public ", $public->serialize();
print "My Private key is: $private", $private->serialize();
my $c = $rsa->encrypt( Message => $message, Key => $public, ) or warn
+"$!\n";
print "My cipher text is: $c\n";
my $nmessage = $rsa->decrypt( Ciphertext => $c, Key => $private, );
print "My plain text is: $nmessage\n";
Modified the RSA.pm to print certain messages in the enrypt subroutine:
....
......
....
sub encrypt {
my ($self, %params) = @_;
my $plaintext = $params{Message} || $params{Plaintext};
my $key = $params{Key};
print "\n$plaintext\n$key\n";
return $self->error ($key->errstr, \%params, $key, \$plaintext)
unless $key->check();
print "\nAfter self error\n";
my $blocksize = blocksize ( $$self{es}->encryptblock (Key => $key)
+,
length($plaintext)
);
print "\nAfter block size\n";
return $self->error("Message too long.", \$key, \%params) if $bloc
+ksize <= 0;
print "\nAfter self error\n";
my $cyphertext;
....
....
Executed the code and got the following message:
My Public key is: Crypt::RSA::Key::Public=HASH(0x8132390) $VAR1 = bles
+s( {
'e' => 65537,
'n' => '10270622025769038677',
'Version' => '1.91'
}, 'Crypt::RSA::Key::Public' );
My Private key is: Crypt::RSA::Key::Private=HASH(0x8132378)$VAR1 = ble
+ss( {
'Version' => '1.91',
'Checked' => 0,
'private' => {
'_phi' => '10270622019208864620',
'_n' => '10270622025769038677',
'_q' => '2581267387',
'_p' => '3978906671',
'_u' => '564982676',
'_dp' => '2208958913',
'_dq' => '2285751125',
'_d' => '4317024349041710693',
'_e' => '65537'
},
'Cipher' => 'Blowfish'
}, 'Crypt::RSA::Key::Private' );
string
Crypt::RSA::Key::Public=HASH(0x8132390)
After self error
Can't call method "encryptblock" on an undefined value at /usr/lib/per
+l5/site_perl/5.8.0/Crypt/RSA.pm line 98.
Haven't been able to figure out why the "blocksize" method is failing.
Your thoughts?
Edited by Arunbear: Changed title from 'The "R", the "S" and the "A"...', as per Monastery guidelines