RSA Private Key BER decode error

494 views
Skip to first unread message

gvalenz (sent by Nabble.com)

unread,
Jun 14, 2006, 2:27:08 PM6/14/06
to crypto...@eskimo.com

Hello,

I have a Private Key File as the following example:

-----BEGIN ENCRYPTED PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,0F6D6F770782C99A

6EbssRIDXh8t1lC9xmLvMBlbYoZgCm/ah78JkAjKLdF+zjzftanshMYLWLasp3NM
VvWBs5KJVNbfAIewGcXy+eQQWrRc9yk7KtBK4ziSoWgPmYieKUX+KFi/XRWbVVv4
...
-----END RSA PRIVATE KEY-----

When I try to use the following sample code of Crypto++ I get an exception.
{I get the error on line: RSAES_OAEP_SHA_Decryptor priv(privFile);}

string RSADecryptString(const char *privFilename, const char *ciphertext)
{
string result;

try {
FileSource privFile(privFilename, true, new HexDecoder);

RSAES_OAEP_SHA_Decryptor priv(privFile);

StringSource(ciphertext, true, new HexDecoder(new
PK_DecryptorFilter(GlobalRNG(), priv, new StringSink(result))));
}
catch (CryptoPP::Exception const& e)
{
cout << "CryptoPP::Exception caught:" << endl
<< e.what() << endl;
cout << e.GetErrorType() << endl;
return "1";
}

return result;
}

The exception is:
CryptoPP::Exception caught:
BER decode error
1

Does somebody suggest me something to solve this issue?
I am new on Crypto++ and security concepts?

Thank you in advance.
--
View this message in context: http://www.nabble.com/RSA-Private-Key-BER-decode-error-t1787416.html#a4868885
Sent from the Crypto++ forum at Nabble.com.


Haytham Mohammed

unread,
Jun 23, 2006, 7:23:56 PM6/23/06
to crypto...@eskimo.com
Hi
 
Private Key Should be in BER format
as I see the private key is encrypted with DES-ede
1- so u have to Get the private Key from the body of the file
6EbssRIDXh8t1lC9xmLvMBlbYoZgCm/ah78JkAjKLdF+zjzftanshMYLWLasp3NM
VvWBs5KJVNbfAIewGcXy+eQQWrRc9yk7KtBK4ziSoWgPmYieKUX+KFi/XRWbVVv4
...
2- decode it base 64
3- decrypt it with DES-ede to get the plain RSA private key
4- encode the private key using base64 encoding
 
Regards
Haytham


Ring'em or ping'em. Make PC-to-phone calls as low as 1「/min with Yahoo! Messenger with Voice.

Reply all
Reply to author
Forward
0 new messages