[rs-commit] r47 - in /redwax-tool/trunk: config.h.in configure.ac redwax-tool.c redwax_openssl.c

rs-commit at redwax.eu rs-commit at redwax.eu
Sat Nov 20 12:25:39 CET 2021


Author: minfrin at redwax.eu
Date: Sat Nov 20 12:25:38 2021
New Revision: 47

Log:
Compensate for openssl 1.0.x.

Modified:
    redwax-tool/trunk/config.h.in
    redwax-tool/trunk/configure.ac
    redwax-tool/trunk/redwax-tool.c
    redwax-tool/trunk/redwax_openssl.c

Modified: redwax-tool/trunk/config.h.in
==============================================================================
--- redwax-tool/trunk/config.h.in	(original)
+++ redwax-tool/trunk/config.h.in	Sat Nov 20 12:25:38 2021
@@ -64,6 +64,15 @@
 
 /* Define to 1 if you have the `RSA_get0_q' function. */
 #undef HAVE_RSA_GET0_Q
+
+/* Define to 1 if you have the `RSA_set0_crt_params' function. */
+#undef HAVE_RSA_SET0_CRT_PARAMS
+
+/* Define to 1 if you have the `RSA_set0_factors' function. */
+#undef HAVE_RSA_SET0_FACTORS
+
+/* Define to 1 if you have the `RSA_set0_key' function. */
+#undef HAVE_RSA_SET0_KEY
 
 /* Define to 1 if stdbool.h conforms to C99. */
 #undef HAVE_STDBOOL_H

Modified: redwax-tool/trunk/configure.ac
==============================================================================
--- redwax-tool/trunk/configure.ac	(original)
+++ redwax-tool/trunk/configure.ac	Sat Nov 20 12:25:38 2021
@@ -96,7 +96,7 @@
 
 # Checks for library functions.
 AC_FUNC_MALLOC
-AC_CHECK_FUNCS([OPENSSL_init_crypto ASN1_TIME_diff X509_STORE_get0_param X509_STORE_CTX_set0_trusted_stack X509_STORE_CTX_get_num_untrusted X509_get0_notBefore X509_get0_notAfter X509_get_extension_flags X509_up_ref EVP_PKEY_get0_description EVP_PKEY_get_bn_param RSA_get0_n RSA_get0_e RSA_get0_d RSA_get0_p RSA_get0_q RSA_get0_dmp1 RSA_get0_dmq1 RSA_get0_iqmp NSS_Initialize p11_kit_modules_load_and_initialize apr_crypto_clear])
+AC_CHECK_FUNCS([OPENSSL_init_crypto ASN1_TIME_diff X509_STORE_get0_param X509_STORE_CTX_set0_trusted_stack X509_STORE_CTX_get_num_untrusted X509_get0_notBefore X509_get0_notAfter X509_get_extension_flags X509_up_ref EVP_PKEY_get0_description EVP_PKEY_get_bn_param RSA_get0_n RSA_get0_e RSA_get0_d RSA_get0_p RSA_get0_q RSA_get0_dmp1 RSA_get0_dmq1 RSA_get0_iqmp RSA_set0_key RSA_set0_factors RSA_set0_crt_params NSS_Initialize p11_kit_modules_load_and_initialize apr_crypto_clear])
 
 AC_OUTPUT
 

Modified: redwax-tool/trunk/redwax-tool.c
==============================================================================
--- redwax-tool/trunk/redwax-tool.c	(original)
+++ redwax-tool/trunk/redwax-tool.c	Sat Nov 20 12:25:38 2021
@@ -24,6 +24,7 @@
 #include <string.h>
 
 #include <apr.h>
+#include <apr_crypto.h>
 #include <apr_fnmatch.h>
 #include <apr_getopt.h>
 #include <apr_hooks.h>

Modified: redwax-tool/trunk/redwax_openssl.c
==============================================================================
--- redwax-tool/trunk/redwax_openssl.c	(original)
+++ redwax-tool/trunk/redwax_openssl.c	Sat Nov 20 12:25:38 2021
@@ -2504,6 +2504,7 @@
         X509_PUBKEY *pub = NULL;
         RSA *rsa = RSA_new();
 
+#if HAVE_RSA_SET0_KEY
         RSA_set0_key(rsa,
                 BN_bin2bn(key->rsa->modulus, key->rsa->modulus_len,
                         NULL),
@@ -2511,11 +2512,27 @@
                         key->rsa->public_exponent_len, NULL),
                 BN_bin2bn(key->rsa->private_exponent,
                         key->rsa->private_exponent_len, NULL));
+#else
+        rsa->n = BN_bin2bn(key->rsa->modulus, key->rsa->modulus_len,
+                NULL);
+        rsa->e = BN_bin2bn(key->rsa->public_exponent,
+                key->rsa->public_exponent_len, NULL);
+        rsa->d = BN_bin2bn(key->rsa->private_exponent,
+                key->rsa->private_exponent_len, NULL);
+#endif
+#if HAVE_RSA_SET0_FACTORS
         RSA_set0_factors(rsa,
                 BN_bin2bn(key->rsa->prime_1, key->rsa->prime_1_len,
                         NULL),
                 BN_bin2bn(key->rsa->prime_2, key->rsa->prime_2_len,
                         NULL));
+#else
+        rsa->p = BN_bin2bn(key->rsa->prime_1, key->rsa->prime_1_len,
+                NULL);
+        rsa->q = BN_bin2bn(key->rsa->prime_2, key->rsa->prime_2_len,
+                NULL);
+#endif
+#if HAVE_RSA_SET0_CRT_PARAMS
         RSA_set0_crt_params(rsa,
                 BN_bin2bn(key->rsa->exponent_1, key->rsa->exponent_1_len,
                         NULL),
@@ -2523,6 +2540,14 @@
                         NULL),
                 BN_bin2bn(key->rsa->coefficient, key->rsa->coefficient_len,
                         NULL));
+#else
+        rsa->dmp1 = BN_bin2bn(key->rsa->exponent_1, key->rsa->exponent_1_len,
+                NULL);
+        rsa->dmq1 = BN_bin2bn(key->rsa->exponent_2, key->rsa->exponent_2_len,
+                NULL);
+        rsa->iqmp = BN_bin2bn(key->rsa->coefficient, key->rsa->coefficient_len,
+                NULL);
+#endif
 
         EVP_PKEY_set1_RSA(pkey, rsa);
         p8inf = EVP_PKEY2PKCS8(pkey);



More information about the rs-commit mailing list