tags:

views:

58

answers:

1

Hello all, I am not sure where to post this so I am starting here and hoping for the best. I have a public and private key generated for .NET. The keys have (Modulus, Exponent, etc...). I sent the public key to a third party and they used it to encrypt passwords in a database. I downloaded the encrypted passwords and now I need to decrypt them on my end. The issue comes in when it has to be decrypted on a unix server. I do not care if I use php, java or any other language as long as it works on the unix box. I am a complete rookie to RSA keys and would appreciate any help or even a direction on where I "should" post this. Thanks in advance....

A: 

The values appear to be base64 encoded. You could use phpseclib's pure PHP RSA implementation and do something like this to load the public key:

$rsa->loadKey(array('modulus' => $modulus, 'exponent' => $exponent), CRYPT_RSA_PUBLIC_FORMAT_RAW);

For the private key... maybe you could do something like..

$rsa = new Crypt_RSA();
$rsa->modulus = $modulus;
$rsa->publicExponent = $exponent;
$rsa->exponents = array(1=> $dp, $dq)
$rsa->coefficients = array(2 => $inverseq);
$rsa->primes = array(1 => $p, $q);

Or something like that - I haven't tested the code, but a cursory glance of phpseclib's code suggests that'll work.

notedshow
I really appreciate the help notedshow. I have read the documentation and must confess that I am well versed in php, I am lost when it comes to RSA and the implementation. I have the Private key, Public Key and the encrypted password, but How do I use what you are showing me against the encrypted password? Sorry in advance for my ignorance.
Thanks for the help, it is working now.