2

For example if I have a 1024-bit key, and wish to encrypt precisely 128 bytes of data, then padding is not required.

This is a usual method of encrypting:

RSA rsa = RSA.Create();
byte[] encrypted = rsa.Encrypt(plaintext, RSAEncryptionPadding.Pkcs1);

But there appears to be no RSAEncryptionPadding.None. Is there another way to do this?

Elaine Li
  • 21
  • 1
  • If you have a 1024-bit key then 128 bytes of data is too much to encrypt. – President James K. Polk Feb 26 '17 at 13:11
  • Why is it too much data to encrypt? – Elaine Li Feb 26 '17 at 13:31
  • Even with raw/unpadded RSA, you can only recover data where the message `m` as a big number is less than the modulus `n` as a big number. So if the modulus has a true 1024-bit spread it can do all 1023-bit numbers safely, but not all 1024-bit. (0xFFFFFFFF...FFFF will not round-trip successfully). So raw 1024 can safely do 127 bytes, but not all 128 byte messages. – bartonjs Feb 27 '17 at 18:16

0 Answers0