Jump to content

RSA help


Braclayrab

Recommended Posts

Hi,
I'm trying to implement the RSA library available from Pear(http://pear.php.net/package/Crypt_RSA/).  I'm having trouble getting it working.

I'm passing the public key to my client which then encrypt a password with javascript.  I retrieve it from CryptRSA(the php library) with the following code:

bin2hex($_SESSION['key_pair']->getPublicKey()->getExponent())

Similarly for the modulus.  However, the javascript library is not functional with the keys that are being generated by CryptRSA  If I pass the public key to the javascript library as well I can't even use it to decrypt on the client(javascript) side.

CryptRSA also appears to sometimes generate even numbers for p and q!  Am I misunderstanding something?  do p and q not actually need to be prime?

Has anyone else ever gotten CryptRSA working in this way?  Is there perhaps a better way for me to be doing the encryption on the client side?  Does anyone know of another PHP RSA library that I can try?

TIA!
-Clay
Link to comment
Share on other sites

Update:
I may have figured out the issue, looks like and endianness problem.  The math libraries are possibly spitting out the numbers in the wrong order.  Here's a bunch of p's, The second digit is always odd and the same is true for the moduli:

0bcdd4dce4ecf3fb
9daeb6bec6ced6de
a3a8b0b8c0c8d0d8
a9b8c0c8d0d8e0e7
adccd4dce4ecf4fc
a5adb6bec6ced6dd
8fa0a8b0b8c0c7cf
f9c1cad2d9e2e9f1
c1c5cdd5dee7eff7
a1a1acb4bcc4ccd4
b5cad2dae2eaf2f9
25c9d0d8e0e8f0f8
9bacb5bdc5cdd4dc
c5abb3bbc3cbd3db
cdc9d2dae2e9f1f9
c5cdd5dde5edf4fc
19b6bdc6ced6dee6
bfc9d1d9e1e9f1f9
25c9d0d8e0e8f0f8
13bfc6ced6dee5ed
e9a6afb7bfc7cfdc
bfc9d1d9e1e9f1f9
adc3cbd3dbe2eaf2
d5b2bac2cad2dce4
1dc2cad2dae2e9f1
9fb0b8c0c8d0d8e0
bda7afb7bec6ced6
c5c2cad2dae2e9f1
8ba3acb4bcc5cdd5
b9d0d8e0e8f0f7ff
c1cdd5dde5edf5fd
49525b636a727ae6
9399a1a9b0b8c0c8
e9b0b8c0c8d0d7df
e9c5ced5dde5edf5
adb2bbc3cad2dae2
b3b3bac2cbd3dbe2
d5cbd3dbe3ebf3fa
Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.