Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSA Encryption Problem [Size of payload data]

Tags:

is it true that RSA encryption only can handle limited payload of data ? ... im confused with the theory ... theoretically there is no note regarding this ...

like image 229
Sudantha Avatar asked May 03 '11 06:05

Sudantha


People also ask

Does RSA encryption increase data size?

Symmetric encryption does not increase the size of the data. The maximum asymmetric data size is 11 bytes less than the size of the key.

Why is RSA not suitable to encrypt large amounts of data?

Simply, RSA is very resource expensive algorithm, it takes time to generate RSA keys and to perform operations on these enormous prime numbers. As the size of data increases, the process load increases and the whole thing ends up taking too much time to complete.

How much data can you encrypt with RSA?

The modulus size is the key size in bits / 8. Thus a 1024-bit RSA key using OAEP padding can encrypt up to (1024/8) – 42 = 128 – 42 = 86 bytes. A 2048-bit key can encrypt up to (2048/8) – 42 = 256 – 42 = 214 bytes.


2 Answers

RSA encrypts a single message which has a length which is somewhat smaller than the modulus. Specifically, the message is first "padded", resulting in a sequence of bytes which is then interpreted as a big integer between 0 and n-1, where n is the modulus (a part of the public key) -- so the padded message cannot be longer than the modulus, which implies a strict maximum length on the raw message.

Specifically, with the most common padding scheme (PKCS#1 "old-style", aka "v1.5"), the padding adds at least 11 bytes to the message, and the total padded message length must be equal to the modulus length, e.g. 128 bytes for a 1024-bit RSA key. Thus, the maximum message length is 117 bytes. Note that the resulting encrypted message length has the same size than the modulus, so the encryption necessarily expands the message size by at least 11 bytes.

The normal way of using RSA for encrypted a big message (say, an e-mail) is to use an hybrid scheme:

  • A random symmetric key K is chosen (a raw sequence of, e.g., 128 to 256 random bits).
  • The big message is symmetrically encrypted with K, using a proper and efficient symmetric encryption scheme such as AES.
  • K is asymmetrically encrypted with RSA.

"Splitting" a big message into so many 117-byte blocks, each to be encrypted with RSA, is not normally done, for a variety of reasons: it is difficult to do it right without adding extra weaknesses; each block would be expanded by 11 bytes, implying a non-negligible total message size increase (network bandwidth can be a scarce resource); symmetric encryption is much faster.

like image 194
Thomas Pornin Avatar answered Oct 19 '22 02:10

Thomas Pornin


In the basic RSA algorithm (without padding) which is not very secure the size of the message is limited to be smaller than the modulus.

To enhance the security of RSA you should use padding schemes as defined in PKCS1. Depending on the scheme you choose the size of the message can be significantly smaller than the modulus. http://en.wikipedia.org/wiki/PKCS1

like image 39
mrks Avatar answered Oct 19 '22 01:10

mrks