summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Raad <Marcel.Raad@teamviewer.com>2021-10-11 21:29:51 +0200
committerMarcel Raad <Marcel.Raad@teamviewer.com>2021-11-20 12:04:56 +0100
commit9b923eaf3e90850dc9cccaf7773eadd245bebc37 (patch)
tree6e3fdbe27553cef9cc64e746ac19455b6b83b65c
parent6147dfab93b434f49cc927babc4e9135071f7f13 (diff)
downloadcurl-9b923eaf3e90850dc9cccaf7773eadd245bebc37.tar.gz
openssl: reduce code duplication
`BN_print`'s `BIGNUM` parameter has been `const` since OpenSSL 0.9.4. Closes https://github.com/curl/curl/pull/7893
-rw-r--r--lib/vtls/openssl.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index cba6491ab..001d6868d 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -3471,10 +3471,7 @@ static void pubkey_show(struct Curl_easy *data,
int num,
const char *type,
const char *name,
-#ifdef HAVE_OPAQUE_RSA_DSA_DH
- const
-#endif
- BIGNUM *bn)
+ const BIGNUM *bn)
{
char *ptr;
char namebuf[32];
@@ -3659,23 +3656,20 @@ static CURLcode get_cert_chain(struct Curl_easy *data,
rsa = pubkey->pkey.rsa;
#endif
-#ifdef HAVE_OPAQUE_RSA_DSA_DH
{
+#ifdef HAVE_OPAQUE_RSA_DSA_DH
const BIGNUM *n;
const BIGNUM *e;
RSA_get0_key(rsa, &n, &e, NULL);
BIO_printf(mem, "%d", BN_num_bits(n));
+#else
+ BIO_printf(mem, "%d", BN_num_bits(rsa->n));
+#endif
push_certinfo("RSA Public Key", i);
print_pubkey_BN(rsa, n, i);
print_pubkey_BN(rsa, e, i);
}
-#else
- BIO_printf(mem, "%d", BN_num_bits(rsa->n));
- push_certinfo("RSA Public Key", i);
- print_pubkey_BN(rsa, n, i);
- print_pubkey_BN(rsa, e, i);
-#endif
break;
}
@@ -3688,8 +3682,8 @@ static CURLcode get_cert_chain(struct Curl_easy *data,
#else
dsa = pubkey->pkey.dsa;
#endif
-#ifdef HAVE_OPAQUE_RSA_DSA_DH
{
+#ifdef HAVE_OPAQUE_RSA_DSA_DH
const BIGNUM *p;
const BIGNUM *q;
const BIGNUM *g;
@@ -3697,18 +3691,12 @@ static CURLcode get_cert_chain(struct Curl_easy *data,
DSA_get0_pqg(dsa, &p, &q, &g);
DSA_get0_key(dsa, &pub_key, NULL);
-
+#endif
print_pubkey_BN(dsa, p, i);
print_pubkey_BN(dsa, q, i);
print_pubkey_BN(dsa, g, i);
print_pubkey_BN(dsa, pub_key, i);
}
-#else
- print_pubkey_BN(dsa, p, i);
- print_pubkey_BN(dsa, q, i);
- print_pubkey_BN(dsa, g, i);
- print_pubkey_BN(dsa, pub_key, i);
-#endif
#endif /* !OPENSSL_NO_DSA */
break;
}
@@ -3720,8 +3708,8 @@ static CURLcode get_cert_chain(struct Curl_easy *data,
#else
dh = pubkey->pkey.dh;
#endif
-#ifdef HAVE_OPAQUE_RSA_DSA_DH
{
+#ifdef HAVE_OPAQUE_RSA_DSA_DH
const BIGNUM *p;
const BIGNUM *q;
const BIGNUM *g;
@@ -3731,13 +3719,12 @@ static CURLcode get_cert_chain(struct Curl_easy *data,
print_pubkey_BN(dh, p, i);
print_pubkey_BN(dh, q, i);
print_pubkey_BN(dh, g, i);
- print_pubkey_BN(dh, pub_key, i);
- }
#else
- print_pubkey_BN(dh, p, i);
- print_pubkey_BN(dh, g, i);
- print_pubkey_BN(dh, pub_key, i);
+ print_pubkey_BN(dh, p, i);
+ print_pubkey_BN(dh, g, i);
#endif
+ print_pubkey_BN(dh, pub_key, i);
+ }
break;
}
}