I have been working for some time on some encryption stuff, and have
come across a road block. I follow the instructions in Crypt::RSA's pod docs,
but I keep getting the same error - cannot call method n on an undefined value.
Here is the decode sub from RSA.pm:
sub decrypt {
my ($self, %params) = @_;
my $key = $params{Key};
my $cyphertext = $params{Cyphertext};
$cyphertext = unpack "u*", $cyphertext if $params{Armour};
my $plaintext;
my $blocksize = ((bitsize ($key->n)) / 8);
my @segments = steak ($cyphertext, $blocksize);
for (@segments) {
$plaintext .= $self->{eme}->decrypt (Cyphertext=> $_, Key => $
+key)
|| return $self->error ($self->{eme}->errstr, \$key, \%par
+ams);
}
return $plaintext;
}
The killer is that
bitsize ($key->n). I have turned on Armour (Armour => 1) and
base64 encoded the key I am sending, but still the system is unable to call method n
on they $key value.
Here is the way I am calling, in case that helps:
# $decoded is the base64 decoded cookie
my @fields = get_fields($decoded);
my $public_key = get_pubkey($fields[2]); # Verified to work
my $rsa = new Crypt::RSA;
my $checksum = $rsa->decrypt(
Cyphertext => $encrypted,
Key => $public_key,
Armour => 1,) || die $rsa->errstr();
No matter what I feed in as $public_key, in whatever form, RSA.pm always says it can't call method n on it.
Any help would be appreciated.
What does this little button do . .<Click>;
"USER HAS SIGNED OFF FOR THE DAY"
In reply to Crypt fun
by tame1
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.