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.

Reply via email to