Hy
I hope somebody can help me.
I'm new with crypto++.
I try to encrypt an Message with the private Key of RSA.

My example Code:

to generate Key files:
{
string PrivateKeyFile = "key.pv";
string PublicKeyFile = "key.pb";
AutoSeededRandomPool rng;
int e = 65537;
RSAES_OAEP_SHA_Decryptor Decryptor( rng, 1024 , e );
HexEncoder privFile(new FileSink( PrivateKeyFile.c_str() ));

Decryptor.DEREncode(privFile);
privFile.MessageEnd();
RSAES_OAEP_SHA_Encryptor Encryptor(Decryptor);
HexEncoder pubFile(new  FileSink( PublicKeyFile.c_str() )       );
Encryptor.DEREncode(pubFile);
pubFile.MessageEnd();
}

after that ich try to encrypt a message :
{
const char * pubFilename = "key.pv";


       FileSource pubFile(pubFilename, true, new HexDecoder);

       RSAES_OAEP_SHA_Encryptor pub(pubFile);
       AutoSeededRandomPool randPool;
       string * result = new string();

       StringSource(
                       message,
                       true,
                       new PK_EncryptorFilter(randPool, pub, new
HexEncoder(new
StringSink(*result))));

       cout << *result << endl;

}
to decrypt the cipher
{
const char * privFilename = "key.pb";
       AutoSeededRandomPool randPool;

       FileSource privFile(privFilename, true, new HexDecoder);
       RSAES_OAEP_SHA_Decryptor priv(privFile);

       string *result2 = new string();
       StringSource(
                       cipher,
                       true,
                       new HexDecoder(new PK_DecryptorFilter(randPool, priv,
new
StringSink(*result2))));
       cout << *result2 << endl;

}
the error:
terminate called after throwing an instance of 'CryptoPP::BERDecodeErr'
  what():  BER decode error


I need this for my bachelor thesis!
Thank a lot

ps.: I post also here : 
http://groups.google.com/group/cryptopp-users/browse_thread/thread/3c051aae6f11fbaf
-- 
View this message in context: 
http://www.nabble.com/RSA-encrypt-with-private-and-decrypt-with-public-key-tp19141140p19141140.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
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