Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Crypt::RSA without Pari

by danaj (Friar)
on Oct 30, 2017 at 19:04 UTC ( #1202364=note: print w/replies, xml ) Need Help??


in reply to Crypt::RSA without Pari

You have Alt::Crypt::RSA::BigInt installed (not Alt::Crypt::RSA)? Also install Math::BigInt::GMP.

One rather crude way to check is to do man Crypt::RSA and check the REPORTING BUGS section. If it has a third paragraph talking about segmentation faults and Math::Pari, then you've got the original Math::Pari version. Here's a more complicated but better one command line method:

perl -E 'use Crypt::RSA::Key; my($pari,$big) = ($Math::Pari::VERSION, +$Math::BigInt::VERSION); my $lib = Math::BigInt->config()->{lib} if $ +big; printf "Using %s\n", $pari ? "Pari $pari" : $big ? "BigInt with +$lib" : "???";'

With Crypt::RSA installed it shows Using Pari 2.01080900 where with Alt::Crypt::RSA::BigInt it shows Using BigInt with Math::BigInt::GMP

/dev/urandom shouldn't be hanging. Crypt::Random reads from /dev/random which can block waiting for more entropy. Alt::Crypt::RSA::BigInt version 0.06 (April 2017) should just read about 256 bytes at the start, as it uses an ISAAC CSPRNG after that.

Replies are listed 'Best First'.
Re^2: Crypt::RSA without Pari
by roperl (Beadle) on Oct 30, 2017 at 19:23 UTC
    My perl instances seems to be using Math::BigInt::GMP
    #/opt/perl/bin/perl -E 'use Crypt::RSA::Key; my($pari,$big) = ($Math:: +Pari::VERSION, $Math::BigInt::VERSION); my $lib = Math::BigInt->confi +g()->{lib} if $big; printf "Using %s\n", $pari ? "Pari $pari" : $big +? "BigInt with $lib" : "???";' Using BigInt with Math::BigInt::GMP
    However, when run the following using an RSA public key
    my $ct = $pgp->encrypt( Filename => 'plain.txt', Recipients => $key, C +ipher => 'DES3' ) or die "Encryption failed: ", $pgp->errstr;
    I see Pari library being opened.
    #truss ./encrypt_openpgp.pl 2>&1 | grep open | grep Pari open64("/opt/perl-5.26.0/lib/site_perl/5.26.0/sun4-solaris-thread-mult +i/Math/Pari.pm", O_RDONLY) = 4 open("/opt/perl-5.26.0/lib/site_perl/5.26.0/sun4-solaris-thread-multi/ +auto/Math/Pari/Pari.so", O_RDONLY) = 4
    And when I see my code hanging it always has this file open: /opt/perl-5.26.0/lib/site_perl/5.26.0/Crypt/Random.pm

    If I remove Math::Pari he program fails with
    ./encrypt_openpgp.pl No random source available! at /opt/perl-5.26.0/lib/site_perl/5.26.0/C +rypt/OpenPGP/Util.pm line 111.
    sub get_random_bytes { 103 my $length = shift; 104 if (eval 'require Crypt::Random; 1;') { 105 return Crypt::Random::makerandom_octet( Length => +$length); 106 } 107 elsif (eval 'require Bytes::Random::Secure; 1;') { 108 return Bytes::Random::Secure::random_bytes($length +); 109 } 110 else { 111 die "No random source available!"; 112 } 113 }
      I think i figured out what was happening. I didn't have Bytes::Random::Secure, so OpenPGP was still calling Crypt::Random which still uses Pari I removed and rebuilt OpenPGP. Now I don't see any references to the Pari library I'll see if this fixes my hanging issue

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202364]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2022-01-27 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?