AutoSeededRandomPool rng;
char *message = "Hello World";
unsigned int length = pub.CiphertextLength (strlen
(message));
char *outstr = new char [length];
pub.Encrypt (rng, (byte *)message, strlen (message),
(byte *)outstr);
int length2 = priv.MaxPlaintextLength (length);
char *plaintext = new char [length2];
priv.Decrypt (rng, (byte *)outstr, length2, (byte *)plaintext);
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
=====
Olga Sayenko
http://www.cs.uic.edu/~osayenko
Department of Computer Science
University of Illinois at Chicago
You're right that Crypto++ won't let you encrypt with the private key, but
that's not what liang is trying to do. The actual problem is something
else.
> > priv.Decrypt (rng, (byte *)outstr, length2, (byte *)plaintext);
The second parameter here needs to be ciphertextLength, i.e., "length"
rather than "length2".
After checking the code again, I notice that silly
mistake.
Just curius, is there any reason why crypto++ don't
support private key encryption ? If i am not wrong, a
message encrypted with a private key could only be
decrypted with the public key. Since only the owner
has the private key, this can be used to prove that
the message originated from the owner of this keypair.
It kind of serve the same purpose as signature.