Cryptography : Generation of RSA Private Key Using Modulus & Exponent
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) hJIERYaOtzMJzFk2cY开发者_JAVA技巧efima7TRhHL1SWTlDzbP4rnFv9uNtAFN9v7md678BFjiObM4+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") ;
}
/**/
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.
精彩评论