Posted on 2007-11-23 18:27:38-08 by ericpode
Extracting N and E

I've been experimenting with an RSA library in C++ and have encryption and decryption working OK.

Ultimately I wanted to run some of this on a web server, but it seems that I'll have to do this in Perl due to restrictions on running compiled code.

The private and public key generation, and encryption of data using the private key will have to be done on the server in Perl. But the ciphertext will have to be decrypted in a compiled standalone C++ program using the aforementioned C++ RSA library.

In order to construct the 1024 bit public key, the RSA library needs the N and E elements of the RSA context (N is an array of 128 bytes and E is an array of 3 bytes).

Is it possible to extract the N and E elements from a keypair created by Crypt-RSA?

Or is there a better way of doing all this?

Direct Responses: 6521 | Write a response
Posted on 2007-11-25 19:36:54-08 by tlinden in response to 6509
Re: Extracting N and E
$keychain = new Crypt::RSA::Key; ($public, $private) = $keychain->generate ( Identity => "xxx", Size => 1024 ); print "E: " . $public->n() . "\n"; print "N: " . $public->e() . "\n";
prints:
E: 95384534841883872179393371467558510147 52282220320151539540632268288419338725205 62005624249917138301505360131600140241395 35839126416119541325808665949143133698094 31573079437765373059007303321604833386525 89869793341403961172440770412743906707186 05460672508254549790597262757048828845077 233266379528784253528873 N: 65537
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.