While trying to get Crypt::RSA to work I started getting some weird errors. I am trying to use a private key to sign some data. The error that I get is below (and I am not sure I understand it):
[Thu Oct 22 15:01:36 2009] [error] [client 10.29.12.38] Can't call met +hod "n" without a package or object reference at /usr/lib/perl5/site_ +perl/5.8.8/Crypt/RSA/ SS/PSS.pm line 41, <PRIVATE_KEY_FILE> line 15., referer: http://192.16 +8.15.2/cgi -bin/RBS_MessageParameterCollectionGUI.pl

The code in question is shown below. Line 41 of PSS.pm is the 'my $k = octet_len ($key->n);' line:
sub sign { my ($self, %params) = @_; my $key = $params{Key}; my $M = $params{Message} || $params{Plaint +ext}; return $self->error("No Key parameter", \$M, \%params) unless $key +; return $self->error("No Message or Plaintext parameter", \$key, \% +params) un less $M; my $k = octet_len ($key->n); my $salt = makerandom_octet (Length => $self->{hlen}); my $em = $self->encode ($M, $salt, $k-1); my $m = os2ip ($em); my $sig = $self->{primitives}->core_sign (Key => $key, Message => +$m); my $S = i2osp ($sig, $k); return ($S, $salt) if wantarray; return $S; }

The code in which I actually use the Crypt::RSA stuff is below:
my $rsa = new Crypt::RSA; my $signatureValue = $rsa->sign( Message => $infoToSign, Key => $privateKey);


If anyone has any idea as to why it is not working, or what might be going wrong, please let me know.

Cheers,
Shug

In reply to Perl Crypt::RSA problems by shug94

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.