Pregunta

hi to all another problem another question..

I am on a C# project that decrypts encrypted messages. for decrypting i am using openssl. I am able to encrypt a message with private key and decrypt it public key with given below code

CryptoKey key = CryptoKey.FromPrivateKey(prvkey, null);
RSA rsa = key.GetRSA();
byte[] alinan = System.Text.Encoding.UTF8.GetBytes(textBox1.Text);
byte[] sonuc = rsa.PrivateEncrypt(alinan, RSA.Padding.PKCS1);

key = CryptoKey.FromPublicKey(pubkey, null);
rsa = key.GetRSA();
byte[] cozulen = rsa.PublicDecrypt(sonuc, RSA.Padding.None);

but for my project i dont have public key , i have only modulus and exponent. I dont know how to get the public key by using modulus and exponent. I have done many searchings but i couldnt find any proper answer. Does anybody have an idea ?

Thanks..

¿Fue útil?

Solución

At least on the c++ openssl the process is:

1 - Generate two BigNumbers from the byte array (modulus and exponent)

2 - Create a new (empty) RSA object

3 - Set the n (modulus) and e (public exponent) attributes of the RSA object.

You may be able to replicate this process in any technology (java, java card, etc)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top