-2

I got a 15KB encrypted file (containing a long base64 string) , and a rsa private key file. I have to decrypt this file using the private key, but I am receiving an error while trying to do so with openssl.

This is the command I tried:

openssl rsautl -decrypt -inkey ./id_rsa -in encrypted_file.enc -out output.bin

The error I'm receiving is as follows:

RSA operation error 140360486789312:error:0406506C:rsa routines:rsa_ossl_private_decrypt:data greater than mod len:../crypto/rsa/rsa_ossl.c:391:

I would appreciate to get help how to do it right.

Thanks in advance.

gold foil
  • 1
  • 1
  • 1

1 Answers1

1

RSA is not designed to encrypt (large) data, use symmetric encryption such as AES to encrypt data.

If you really need asymmetric encryption, that is separate encryption and decryption keys, use hybrid encryption. Hybrid encryption creates a Ranson symmetric key, encrypts the data with symmetric encryption, encrypts that symmetric key with asymmetric encryption and packaged the two together.

The size of the data that can be encrypted is less than the key size minus padding. To RSA encrypt a 15KB file would require an RSA key > 17,000 bits and that is currently unreasonable. Also asymmetric encryption (RSA) is orders of magnitude slower than symmetric encryption (AES).

But one question: do you really need asymmetric encryption, would symmetric encryption suffice for your needs?

zaph
  • 111,848
  • 21
  • 189
  • 228