I am using PHP Crypt_RSA (http://pear.php.net/package/Crypt_RSA) for encrypting and decrypting the contents. Contents are of 1kb size. Following are the results:
- keylength = 1024
- Encryption function takes time: 225 secs
- keylength = 2048
- Encryption function takes time: 115 secs
I need to reduce this execution time as most of the live apache servers have 120 sec limit for execution time. How to reduce this execution time? RSA alorithm docs says the only 1024 – 2048 keys are generated. I ACTUALLY tried to generate larger key, but it always results in execution timeout.
How do i work on reducing encryption – decryption execution time?
Thanks,
Nila
Do not use RSA to encrypt content, use RSA to encrypt a symmetric key that is then used to encrypt the content.
The symmetric cipher AES uses a key length of 256 bits, which is 32 bytes, about 30 times less data to encrypt/decrypt using RSA than the kilobyte of data you encrypt now.
So the 115 seconds will be reduced to 3-4 secs plus the encryption/decryption time used for AES which is much faster than RSA.