1 --- a/lib/rsa/rsa-sign.c
2 +++ b/lib/rsa/rsa-sign.c
4 #include <openssl/ssl.h>
5 #include <openssl/evp.h>
7 -#if OPENSSL_VERSION_NUMBER >= 0x10000000L
8 +#if OPENSSL_VERSION_NUMBER < 0x10000000L
9 +#define HAVE_ERR_REMOVE_STATE
10 +#elif OPENSSL_VERSION_NUMBER < 0x10100000L
11 #define HAVE_ERR_REMOVE_THREAD_STATE
14 +#if OPENSSL_VERSION_NUMBER < 0x10100005L
15 +static void RSA_get0_key(const RSA *r,
16 + const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
27 static int rsa_err(const char *msg)
29 unsigned long sslErr = ERR_get_error();
30 @@ -154,7 +169,8 @@ static void rsa_remove(void)
32 #ifdef HAVE_ERR_REMOVE_THREAD_STATE
33 ERR_remove_thread_state(NULL);
36 +#ifdef HAVE_ERR_REMOVE_STATE
40 @@ -210,7 +226,6 @@ static int rsa_sign_with_key(RSA *rsa, s
41 ret = rsa_err("Could not obtain signature");
44 - EVP_MD_CTX_cleanup(context);
45 EVP_MD_CTX_destroy(context);
48 @@ -270,23 +285,26 @@ static int rsa_get_exponent(RSA *key, ui
53 + RSA_get0_key(key, NULL, &bn_e, NULL);
61 - if (BN_num_bits(key->e) > 64)
62 + if (BN_num_bits(bn_e) > 64)
65 - *e = BN_get_word(key->e);
66 + *e = BN_get_word(bn_e);
68 - if (BN_num_bits(key->e) < 33) {
69 + if (BN_num_bits(bn_e) < 33) {
74 - bn_te = BN_dup(key->e);
75 + bn_te = BN_dup(bn_e);
79 @@ -319,6 +337,9 @@ int rsa_get_params(RSA *key, uint64_t *e
80 BN_CTX *bn_ctx = BN_CTX_new();
84 + RSA_get0_key(key, &bn_n, NULL, NULL);
86 /* Initialize BIGNUMs */
89 @@ -337,7 +358,7 @@ int rsa_get_params(RSA *key, uint64_t *e
90 if (0 != rsa_get_exponent(key, exponent))
93 - if (!BN_copy(n, key->n) || !BN_set_word(big1, 1L) ||
94 + if (!BN_copy(n, bn_n) || !BN_set_word(big1, 1L) ||
95 !BN_set_word(big2, 2L) || !BN_set_word(big32, 32L))