Hello all,

my problem:
1. I have been given a certificate in a pfx form that contains the
private key I must use to decode a message.
2. I opened up the certificate and saved the private key data to
a .pem file.
3. The certificate is in the form:

-----BEGIN CERTIFICATE-----
MIICuzCCAiSgAwIBAgIJAMLZ1aXsvPdqMA0GCSqGSIb3DQEBBQUAMGkxCzAJBgNV
(...)
/9kfj2B6h78n9yXo339Xa8i/+3xJQMApR5yXW0IkEg==
-----END CERTIFICATE-----

I went through the examples and found the cool function
string RSADecryptString(const char *privFilename, const char
*ciphertext)
I tried to use it, but I am getting a "BER decode error".

{
string b64decoded;

        //decode file from bsae 64
        StringSource( privFilename, true,
                        new CryptoPP::Base64Decoder(
                            new CryptoPP::StringSink( b64decoded )
                        ) // Base64Encoder
                    ); // StringSource

        //Set up the decryptor
        StringSource priv_key(b64decoded, true, new HexDecoder);
        RSAES_OAEP_SHA_Decryptor priv(priv_key);

        //to replace GlobalRNG that I haver no idea where it is!
        AutoSeededRandomPool rng;

        string result;
        StringSource(ciphertext, true, new HexDecoder(new
PK_DecryptorFilter(rng, priv, new StringSink(result))));

        return result;
}

Sorry for the dumb question, but I'm learning about cryptography as I
go and my time is running short for going through the cryptoPP API's
thoroughly.

I hope that someone can help me out.

Thanks in advance!

Cheers

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to