From 2594a5aa43ac412df69746786f0414797e9f1623 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Sun, 17 Aug 2014 18:25:11 +0200 Subject: [PATCH] Use the new interface to RSA_generate_key if available Some libssls, namely the one you can get precompiled for Android, comes without any deprecated interfaces, and thhose include RSA_generate_key; this stops the module from working. This commit makes the module use the new interface if on a recent version of libssl. --- RSA.xs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/RSA.xs b/RSA.xs index de512e7..d68a50f 100644 --- a/RSA.xs +++ b/RSA.xs @@ -298,7 +298,20 @@ generate_key(proto, bitsSV, exponent = 65537) PREINIT: RSA* rsa; CODE: - CHECK_OPEN_SSL(rsa = RSA_generate_key(SvIV(bitsSV), exponent, NULL, NULL)); +#if OPENSSL_VERSION_NUMBER >= 0x00908000L + BIGNUM *e; + int rc; + e = BN_new(); + BN_set_word(e, exponent); + rsa = RSA_new(); + rc = RSA_generate_key_ex(rsa, SvIV(bitsSV), e, NULL); + BN_free(e); + e = NULL; + CHECK_OPEN_SSL(rc != -1); +#else + rsa = RSA_generate_key(SvIV(bitsSV), exponent, NULL, NULL); +#endif + CHECK_OPEN_SSL(rsa); RETVAL = make_rsa_obj(proto, rsa); OUTPUT: RETVAL