The maximum amount of data you can encrypt with a 1024 bit RSA key is 1024 bits of data = 128 bytes. I think PKCS1 padding adds at least 10 bytes before encoding (I might be off on this number?). You want to use padding if you're concerned about the security of your data (pretty much you want to use padding or you wouldn't use RSA anyway). Though you might be able to get away without padding if you're essentially sending random data anyway, since I think the purpose of the padding is to protect against formatted data that can either be guessed at or give clues to a would be attacker?
Generally, you can either encode your data in a more compact form and if you need hex translate it out on the other side, or you can break it into multiple blocks, encrypt and send each block.


Andrew Mann


[EMAIL PROTECTED] wrote:
Hi..
I am using Crypto library of openSSL for RSA encryption and decryption. I am
generating RSA parameters for public modulus size of 1024. if I use
RSA_public_encrypt() using PKCS1 padding and give an input string to encrypt of
lenght 128, I get the following error:
"5977:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large
for key size:rsa_pk1.c:151:"

Is there any way I can encrypt a string of length 128 with the same key size ? I
want this because, I need to encrypt a random number of 512 bits which when
represented in Hex gives me a string of 128 bytes. Please let me know if there
is any work around.

Thanks in Advance,
Aneel.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]

Reply via email to