[Botan-devel] Problem with RSA Encryption/decryption

Jack Lloyd lloyd at randombit.net
Tue Jul 5 13:27:48 EDT 2005


On Tue, Jul 05, 2005 at 06:02:26PM +0200, Ruben Quintero Lores wrote:

I just saw the problem here:

>      SecureVector<byte> cipher =
> rsa_enc->encrypt(sessionkey.bits_of(), sizeof(sessionkey));

[...]
>      SecureVector<byte> cipher =
> rsa_dec->decrypt(sessionkey.bits_of(), sizeof(sessionkey));

These are not passing the right things in. sizeof(sessionkey) is not likely to
be the same as sessionkey.length() -- if you remove those second parameters,
then the objects will figure out the right size themselves. These versions of
the calls trust you to get the size correct, which is probably why they are not
working. On my system, sizeof(SymmetricKey) will return 16, which would mean,
if you were using 128 bit session keys it would coincidentally work for
encryption (as long as you don't change the size), but it will never work for
decryption.

-Jack



More information about the botan-devel mailing list