It happens when password is missing
#!/usr/bin/perl -- use strict; use warnings; use File::Spec; use Crypt::RSA; Main(@ARGV); exit(0); sub Main { my $thisf = File::Spec->rel2abs(__FILE__); my $fprivate = "$thisf-testkey.private"; my $fpublic = "$thisf-testkey.public"; print "RSA tester ($thisf)\n"; my $infoToSign = "blah"; my $privateKey = 5; my $rsa = new Crypt::RSA; my ( $public, $private ); if ( -e $fpublic and -e $fprivate ) { print "reading $fprivate\n"; $private = new Crypt::RSA::Key::Private( Filename => $fprivate, @_ ? ( Password => 'password' ) : (), # NOTICE ARGV ); } else { print "generating keys\n"; ( $public, $private ) = $rsa->keygen( Identity => 'RBSClient', Size => 1024, Password => 'password', ) or die $rsa->errstr(); $private->write( Filename => $fprivate ); $public->write( Filename => $fpublic ); } print "signing $infoToSign\n"; my $signature = $rsa->sign( Message => $infoToSign, Key => $private, Armour => 1, ) || die $rsa->errstr(); print "$signature \n"; } __END__ $ perl crypt-rsa-sign-test.pl RSA tester (~/tmp/crypt-rsa-sign-test.pl) generating keys signing blah PARI: *** negative exponent in glog. at ~/lib/Crypt/RSA/DataFormat +.pm line 77. $ $ perl crypt-rsa-sign-test.pl RSA tester (~/tmp/crypt-rsa-sign-test.pl) reading ~/tmp/crypt-rsa-sign-test.pl-testkey.private signing blah PARI: *** negative exponent in glog. at ~/lib/MSWin32-x86-multi-th +read/Math/Pari.pm line 994. $ perl crypt-rsa-sign-test.pl asdf RSA tester (~/tmp/crypt-rsa-sign-test.pl) reading ~/tmp/crypt-rsa-sign-test.pl-testkey.private signing blah -----BEGIN RSA SIGNATURE----- Version: 1.99 Scheme: Crypt::RSA::SS::PSS OQAxMjgAU2lnbmF0dXJlU7UxMIX136kFP+o3o7Pf5orq6jeCJWI7qG/uRqCwFgAoUc/LUR +9jsmBM B1Wl6krjm/98qTYUNgNNWgApxsfTFu23jL3LBbrKH50fNql9YuElxYdER0kyFJgX61xmrg +ivfbm1 Vim4LMMoCSJq2qyhCOEcA1q3zg/p+6U5/Zg8Lbg= =ufjanyZlBik+n/N3tWigfw== -----END RSA SIGNATURE----- $

In reply to Re: Math::PARI and Crypt::RSA by Anonymous Monk
in thread Math::PARI and Crypt::RSA 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.