On 2/8/06, Elbarto <[EMAIL PROTECTED]> wrote:

[...]
> string RSADecryptString(const char *privFilename, const char
> *ciphertext)
> {
> FileSource privFile(privFilename, true, new HexDecoder);
> RSAES_OAEP_SHA_Decryptor priv(privFile);
>
> string result;
> StringSource(ciphertext, true, new HexDecoder(new
> PK_DecryptorFilter(GlobalRNG(), priv, new StringSink(result))));
> return result;
> }
>
> but this code doesn't work with my private key and ciphertext ,
[...]
> you can help me by this way: I send you with this mail 2 files that
> represent
> the privateKey and the ciphertext in binary format ( pure format, not text
> format )

If they are raw, binary data, you should not use HexDecoder.  But if I do

int main() {
        FileSource privFile( "privatekey.bin", true, 0 );
        RSAES_OAEP_SHA_Decryptor priv( privFile );
        std::string result;
        RandomPool randPool;
        FileSource ciphertext(
                "ciphertext.bin",
                true,
                new PK_DecryptorFilter( randPool, priv, new StringSink( result 
) )
        );
        std::cout << '[' << result << ']';
        return 0;
}

I also get 'invalid ciphertext', so it seems one of the files are
corrupted, maybe CR/LF problems?  Try using standard hex encodings to
make sure there are no such problems.

Cheers,
--
                                                    Jens Peter Secher
_DD6A 05B0 174E BFB2 D4D9 B52E 0EE5 978A FE63 E8A1 jpsecher gmail com_

Reply via email to