0

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.php Commented Sep 27, 2010 at 7:13
  • How did you retrieve the keys from .NET? What format are they in? Commented Sep 27, 2010 at 22:27
  • Thanks for the link. I have tried but have failed to get anything to work with openssl. Commented 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> Commented 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> Commented Sep 28, 2010 at 3:10

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
-1

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.