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....
6
-
Have a look at the PHP OpenSSL extension for starters: php.net/manual/en/book.openssl.phpdeceze– deceze ♦2010-09-27 07:13:54 +00:00Commented Sep 27, 2010 at 7:13
-
How did you retrieve the keys from .NET? What format are they in?President James K. Polk– President James K. Polk2010-09-27 22:27:48 +00:00Commented Sep 27, 2010 at 22:27
-
Thanks for the link. I have tried but have failed to get anything to work with openssl.user1796752– user17967522010-09-28 03:07:17 +00:00Commented Sep 28, 2010 at 3:07
-
Gregs - Here is a sample of the format for the keys I am working with: Below are the Public and Private key values that were generated. Public key: <RSAKeyValue><Modulus>oRykN+m+Znvoy/CSiXcK7024ljy/pFQHikH/eHYhuzzumUXDoxKBrKUd7+ 5NiyFF480SiCgRP/VDk9mrGCEAmJgklUmbs/Bo9sTOYdTqWDkqt2FkH5e5wOk3qQ7f0WWcPq53fLZeCx XTWzFhmib6BJBEChs2N7gfIfXsp+Yi6Xc=</Modulus><Exponent>AQAB</Exponent></RSAKeyVal ue>user1796752– user17967522010-09-28 03:08:01 +00:00Commented Sep 28, 2010 at 3:08
-
Private Key: <RSAKeyValue><D>Fs+WVLBMm/gJQu7B4KKxMqafbu4U+DBJjQLBKA4ZwofjBGKDS5BwOcB7F6B27C7+ 1T0Q1aROpO6V7dYQym7JxZeT9q2DF4OQu62BRwz6cG4xfQ4oQZWjbxWQNj2IyzGG9/JPHk2LQc2BGEat JyLXkmdKSuPz1i5H85Pg7WGR15E=</D><DP>tY60JQ26IojR6sFZ9DCXJKYENFa1jPAru+08n+cX7u0+ CxfVcr/XcevZ2QvbR5dYKUJrmfcB4dK/1MLoaqiMRw==</DP><DQ>RInts3Wwxi9KdBo+IOq6Jq+g0iq vSANPOX2ZWRdKZyqdqm70ftnDmW35dYlvDdKaAGpl6u+xbGXY2m5gy3hPMQ==</DQ><InverseQ>r9EL 6x7mDf28qLMjn2Qwva/PKoId1EDJR/gP5pHsyOxtXxomedebFIqTlZ+0Ry8jn/+kr47w3dZZ5oxGftti fg==</InverseQ>user1796752– user17967522010-09-28 03:10:55 +00:00Commented Sep 28, 2010 at 3:10
|
Show 1 more comment
2 Answers
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.
1 Comment
user1796752
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.
There is a nice article about using .NET's key format with PHP: Using PHP to encrypt/decryp/sign/verify data with .NET XML RSA key
1 Comment
Radim Köhler
Please, try to read this stackoverflow.com/help/deleted-answers, to get more understanding how to not answer. Namely: "Answers that do not fundamentally answer the question": barely more than a link to an external site