[Botan-devel] Problem with RSA Encryption/decryption

Ruben Quintero Lores rubenql at iti.upv.es
Tue Jul 5 12:02:26 EDT 2005


Hi!!

I have the following code to encrypt/desencrypt the hash of a Diffie
Hellmann session symetric key, I use to encrypt a private RSA key and a
public RSA key to desencrypt

byte* modify(bool encryption, RSA_PrivateKey *aprivatekey, RSA_PublicKey
*apublickey)
{
    initialize_botan();
    if (encryption)  // encryption
    {
     PK_Encryptor* rsa_enc = get_pk_encryptor(*aprivatekey, "EME1
(SHA-1)");
     SecureVector<byte> cipher = rsa_enc->encrypt(sessionkey.bits_of(),
sizeof(sessionkey));
     delete rsa_enc;
     return (byte*)cipher;
    }
  else  //decryption
    {
     PK_Decryptor* rsa_dec = get_pk_decryptor(*apublickey, "EME1
(SHA-1)");
     SecureVector<byte> cipher = rsa_dec->decrypt(sessionkey.bits_of(),
sizeof(sessionkey));
     delete rsa_dec;
     return (byte*)cipher;
    }
}

The encryption process apparently work fine BUT in desencryption process
I get an error like this

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

What happend?? Wich is the meaning of this error?? What I'll doing
wrong??

Help me please because I don't understand.

Thank you,

Rubén
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20050705/8070b007/attachment.html>


More information about the botan-devel mailing list