密码学:使用模数和密码生成 RSA 私钥指数
我是密码世界的新手。我需要根据下面提供的数据生成相应的 RSA 私钥。
Modulus B87BDAB530F8FDED78223D841C5D4E66A6CA86E1D690E829755F244B6FA64D0B8FFBB33AC46FE533568FD6A965EDE7AFFAED8B15476E7B70D637188B8E6B78FDAE17941E7A1304699405F94FD8E596A2BA1CA57D413E96F6E9A3F7585EEF156E8220E7C45DCB48C6CC667AC52E521444225DD6F5611CE8C14DF680C291CFDFE5
Modulus
(Base 64) uHvatTD4/e14Ij2EHF1OZqbKhuHWkOgpdV8kS2+mTQuP+7M6xGlM1aP1qll7eev+u2LFUdue3DWNxiLjmt4a4XlB56EwRplAX5T9jllqK6HKV9QT6W9umj91he7xVugiDnxF3LSMbMZnrFLlIURCJd1vVhHOjBTfaAwpHP3+U=
Private Exponent 84920445868EB73309CC593671879F8A66BB4D18472F54964E50F36CFE2B9C5BFDB8DB4014DF6FEE677AEFC0458E239B338FB60DB18A344C8EB38300EE744EB98B2606AC4781C4C9317B0289F41D7E92C927639E699D0E903B5160D9AEBFD70C1D6EBA539774459B95107E60941B22EECD54F7D0C8DE47DA7719C33FD4DB9155
Private Exponent (Base 64) hJIERYaOtzMJzFk2cYefima7TRhHL1SWTlDzbP4rnFv9uNtAFN9v7md678BFjiObM4+2DbGKNEyOs4MA7nROuYsmBqxHgcTJMXsCifQdfpLJJ2OeaZ0OkDtRYNmuv9cMHW66U5d0RZuVEH5glBsi7s1U99DI3kfadxnDP9TbkVU=
Public Exponent 010001
Public Exponent (Base 64) AQAB
我使用以下方法生成 RSAPrivateKey 但密钥不正确。
char *szModulus = "B87BDAB530F8FDED78223D841C5D4E66A6CA86E1D690E829755F244B6FA64D0B8FFBB33AC46FE533568FD6A965EDE7AFFAED8B15476E7B70D637188B8E6B78FDAE17941E7A1304699405F94FD8E596A2BA1CA57D413E96F6E9A3F7585EEF156E8220E7C45DCB48C6CC667AC52E521444225DD6F5611CE8C14DF680C291CFDFE5" ;
char *szExp = "84920445868EB73309CC593671879F8A66BB4D18472F54964E50F36CFE2B9C5BFDB8DB4014DF6FEE677AEFC0458E239B338FB60DB18A344C8EB38300EE744EB98B2606AC4781C4C9317B0289F41D7E92C927639E699D0E903B5160D9AEBFD70C1D6EBA539774459B95107E60941B22EECD54F7D0C8DE47DA7719C33FD4DB9155" ;
char *szPubExp = "010001" ;
RSA* rsa = RSA_new();
int ret = BN_hex2bn(&rsa->n,szModulus) ;
ret = BN_hex2bn(&rsa->d,szExp) ;
ret = BN_hex2bn(&rsa->e,szPubExp) ;
if (!PEM_write_RSAPrivateKey(fp, rsa, NULL, NULL, 0, 0, NULL))
{
printf("\n PEM_write_PrivateKey failed \n") ;
}
/**/
I am new to cryptographic world. I need to generate a corresponding RSA private key from the data provided below.
Modulus B87BDAB530F8FDED78223D841C5D4E66A6CA86E1D690E829755F244B6FA64D0B8FFBB33AC46FE533568FD6A965EDE7AFFAED8B15476E7B70D637188B8E6B78FDAE17941E7A1304699405F94FD8E596A2BA1CA57D413E96F6E9A3F7585EEF156E8220E7C45DCB48C6CC667AC52E521444225DD6F5611CE8C14DF680C291CFDFE5
Modulus
(Base 64) uHvatTD4/e14Ij2EHF1OZqbKhuHWkOgpdV8kS2+mTQuP+7M6xGlM1aP1qll7eev+u2LFUdue3DWNxiLjmt4a4XlB56EwRplAX5T9jllqK6HKV9QT6W9umj91he7xVugiDnxF3LSMbMZnrFLlIURCJd1vVhHOjBTfaAwpHP3+U=
Private Exponent 84920445868EB73309CC593671879F8A66BB4D18472F54964E50F36CFE2B9C5BFDB8DB4014DF6FEE677AEFC0458E239B338FB60DB18A344C8EB38300EE744EB98B2606AC4781C4C9317B0289F41D7E92C927639E699D0E903B5160D9AEBFD70C1D6EBA539774459B95107E60941B22EECD54F7D0C8DE47DA7719C33FD4DB9155
Private Exponent (Base 64) hJIERYaOtzMJzFk2cYefima7TRhHL1SWTlDzbP4rnFv9uNtAFN9v7md678BFjiObM4+2DbGKNEyOs4MA7nROuYsmBqxHgcTJMXsCifQdfpLJJ2OeaZ0OkDtRYNmuv9cMHW66U5d0RZuVEH5glBsi7s1U99DI3kfadxnDP9TbkVU=
Public Exponent 010001
Public Exponent (Base 64) AQAB
I used following to generate the RSAPrivateKey but the key is not correct.
char *szModulus = "B87BDAB530F8FDED78223D841C5D4E66A6CA86E1D690E829755F244B6FA64D0B8FFBB33AC46FE533568FD6A965EDE7AFFAED8B15476E7B70D637188B8E6B78FDAE17941E7A1304699405F94FD8E596A2BA1CA57D413E96F6E9A3F7585EEF156E8220E7C45DCB48C6CC667AC52E521444225DD6F5611CE8C14DF680C291CFDFE5" ;
char *szExp = "84920445868EB73309CC593671879F8A66BB4D18472F54964E50F36CFE2B9C5BFDB8DB4014DF6FEE677AEFC0458E239B338FB60DB18A344C8EB38300EE744EB98B2606AC4781C4C9317B0289F41D7E92C927639E699D0E903B5160D9AEBFD70C1D6EBA539774459B95107E60941B22EECD54F7D0C8DE47DA7719C33FD4DB9155" ;
char *szPubExp = "010001" ;
RSA* rsa = RSA_new();
int ret = BN_hex2bn(&rsa->n,szModulus) ;
ret = BN_hex2bn(&rsa->d,szExp) ;
ret = BN_hex2bn(&rsa->e,szPubExp) ;
if (!PEM_write_RSAPrivateKey(fp, rsa, NULL, NULL, 0, 0, NULL))
{
printf("\n PEM_write_PrivateKey failed \n") ;
}
/**/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
模数和私有指数是私钥,至少以简化的方式是这样。
对于 RSA,通常会在私钥中包含一些其他参数,例如模数的两个(或多个)质因数。这些额外的参数不会提供更多的能力(模数和私有指数足以计算签名和解密数据),但可以实现更快的实现(3 到 4 倍)。
因此,考虑到上述信息,问题可能是关于恢复模数的素因数。通用方法在应用密码学手册第 8 章第 8.2 节中给出。 2,第 (i) 段(“与保理的关系”),第 287 页。
The modulus and the private exponent are the private key, at least in a simplified way.
With RSA, it is customary to include a few other parameters in the private key, such as the two (or more) prime factors of the modulus. These extra parameters do not offer more power (the modulus and private exponent are enough to compute signatures and decrypt data) but allow for a faster implementation (by a factor of 3x to 4x).
Thus, possibly, the question is about recovering the prime factors of the modulus, given the information above. The generic method is given in the Handbook of Applied Cryptography, chapter 8, section 8.2.2, paragraph (i) ("Relation to factoring"), page 287.