Add support for new and old openssl API

RSA_generate_key is marked as deprecated and as been remplaced by
RSA_generate_key_ex.
Some distributors, like Android, do not support deprecated openssl.
This patch add support for RSA_generate_key_ex. If both are available,
RSA_generate_key_ex (newer) is chosen.