[Botan-devel] Problem with RSA Encryption/decryption

Ruben Quintero Lores rubenql at iti.upv.es
Tue Jul 5 13:11:42 EDT 2005

> No - for public key encryption you want to encrypt with the public key, decrypt
> with the private key. 'Encrypting with the private key' is how you do RSA
> signatures (and really they are not the same operation, but people do describe
> RSA signatures like that a lot).
> Other than swapping your public and private key variables in the code you sent,
> it looks fine to me. Just make sure you're actually trying to decrypt the same
> value that is returned by the encryption function.

I tried to swap my public and private key variables I get the same
problem, when I try to decrypt I get the error

terminate called after throwing an instance of 'Botan::Exception'
  what():  Botan: PK_Decryptor_MR_with_EME: Input is invalid

No problem, I can do a thing, when a destination node receive the public
key of source node, calulate the corresponding session key and encrypt
it, and then compare it with the received encrypted sesion key, both
will be the same value

More information about the botan-devel mailing list