使用模数和指数获取公钥 [英] Getting public key using modulus and exponent
问题描述
大家好,另一个问题,另一个问题..
hi to all another problem another question..
我参与了一个解密加密消息的 C# 项目.解密我使用openssl.我能够使用私钥加密消息并使用下面给出的代码解密它的公钥
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 ?
谢谢..
推荐答案
至少在c++ openssl上的流程是:
At least on the c++ openssl the process is:
1 - 从字节数组(模数和指数)生成两个 BigNumbers
1 - Generate two BigNumbers from the byte array (modulus and exponent)
2 - 创建一个新的(空的)RSA 对象
2 - Create a new (empty) RSA object
3 - 设置 RSA 对象的 n(模数)和 e(公共指数)属性.
3 - Set the n (modulus) and e (public exponent) attributes of the RSA object.
你可以用任何技术(java、java卡等)复制这个过程
You may be able to replicate this process in any technology (java, java card, etc)
这篇关于使用模数和指数获取公钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!