Use RSA_generate_key_ex for OpenSSL >=

Older versions of OpenSSL used RSA_generate_key and newer versions use RSA_generate_key_ex .
A change in 1a3a279 caused only versions of OpenSSL >= 1.1 to use the _ex form.
This fails on, at least, openssl-1.0.2k-8, currently shipping on CentOS/RHEL during
"make test" with a failure to create an RSA key.

This commit adds a test for OpenSSL >= (release) and uses the _ex form there.
"make test" works with this change on openssl-1.0.2k-8 on EL7 and openssl-1.1.0f-7
on Fedora 26.

Resolves: #16
This commit is contained in:
Bill McGonigle 2017-09-17 12:11:20 -04:00
parent 15fb7e0b5f
commit 2f566af775
1 changed files with 2 additions and 1 deletions

View File

@ -68,6 +68,7 @@
#include <openssl/rsa.h>
#include <openssl/sha.h>
#define OPENSSL_VERSION_1_1 0x10100000L
#define OPENSSL_VERSION_0_9_0_8 0x0090800FL
/* Define NEED_HTOBE32 if htobe32() is not available on your platform. */
/* #define NEED_HTOBE32 */
@ -263,7 +264,7 @@ worker(void *arg)
while (!done) {
/* Generate a new RSA key every time e reaches RSA_E_LIMIT */
rsa = RSA_new();
if (!RSA_generate_key_ex(rsa, RSA_KEYS_BITLEN, big_e, NULL))
error("RSA Key Generation failed!\n");