We have an application that requires cleartext passwords for user authentication because of the authentication mechanism in use (RADIUS/CHAP), which unfortunately we cannot change. Since we don't want to store cleartext passwords, an idea is to use asymmetric encryption to secure them as good as possible. After creating/chaning a password, it will be encrypted with the public key and replicated through more or less unsecured channels to the authentication systems. When a user tries to authenticate, the encrypted password will be decrypted with the private key (which has to be available on the authentication servers, obviously).
So we would have a database with lots of encrypted passwords, but all encrypted with the same key. After some research I see that this not the way asymmetric encryption is commonly used. Usually the payload is encrypted with a block cipher and the symmetric key is encrypted with an asymmetric key. But since passwords are quite short I wonder if this additional encryption layer can safely be avoided or if this would be simplification would be a serious risk.
Related to this: What algorithm would you recommend? I kind of narrowed it down to RSA and Elgamal, mostly because these two seem to be most widely used and are available through well-known libraries (OpenSSL, gcrypt). RSA seems to require longer keys to provide the same security, so Elgamal seem to be the better option there's no other argument against it.
Comments?
Sure, Padding is mandatory, the OpenSSL docs recommend RSA_PKCS1_OAEP_PADDING.
I could not find a good source that Elgamal requires less bits, and for Elgamal we would need gcrypt, which has an even more awkward API than OpenSSL, so we will go with RSA.
I do not see an advantage of hybrid encryption, the length of the output of the RSA encryption is as long as its key, regardless of the input. The weak point of all this is the server with the private key, yes, but this secures intermediate storage, which is a big plus for us – Jakob Apr 12 '13 at 14:56