RSA public key encryption/private key decription
I'm using the openssl package for a project I'm working on, and have come across the following in the RSA_public_encrypt man page.
"Raw RSA encryption. This mode should only be used to implement cryptographically sound padding modes in the application code. Encrypting user data directly with RSA is insecure."
What I would like to know is why this is insecure, and how does padding help. I've tried padding using RSA_PKCS1_OAEP_PADDING, but this causes data to encrypt to different "target" values. So say I encrypt the string "this string is to be encrypted" 5 or 6 times, I will end up with 5 or 6 different encrypted versions. For what I'm using it, this is not quite acceptable - the same string should encrypt to the same value each and every time (yes - this is probably slightly insecure - but it is needed). So what I did was pad whatever I get upto a multiple of 128 bytes with 0's (I still want to change this, based upon the input data pad it otherwise). Then encrypt each block of 128 bytes with no padding. Is this ok, or is it as the man pages suggest - REALLY BAD.
Thanks beforehand for all help
|All times are GMT -5. The time now is 11:56 AM.|