gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnurl] 85/256: vtls: refactor out essential information ab


From: gnunet
Subject: [GNUnet-SVN] [gnurl] 85/256: vtls: refactor out essential information about the SSL backends
Date: Fri, 06 Oct 2017 19:42:56 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnurl.

commit b59288f88146b64ac5fda296675c523df11658b8
Author: Johannes Schindelin <address@hidden>
AuthorDate: Sat Jul 15 13:49:30 2017 +0200

    vtls: refactor out essential information about the SSL backends
    
    There is information about the compiled-in SSL backends that is really
    no concern of any code other than the SSL backend itself, such as which
    function (if any) implements SHA-256 summing.
    
    And there is information that is really interesting to the user, such as
    the name, or the curl_sslbackend value.
    
    Let's factor out the latter into a publicly visible struct. This
    information will be used in the upcoming API to set the SSL backend
    globally.
    
    Signed-off-by: Johannes Schindelin <address@hidden>
---
 include/curl/curl.h  | 5 +++++
 lib/vtls/axtls.c     | 3 +--
 lib/vtls/cyassl.c    | 3 +--
 lib/vtls/darwinssl.c | 3 +--
 lib/vtls/gskit.c     | 3 +--
 lib/vtls/gtls.c      | 3 +--
 lib/vtls/mbedtls.c   | 3 +--
 lib/vtls/nss.c       | 3 +--
 lib/vtls/openssl.c   | 3 +--
 lib/vtls/polarssl.c  | 3 +--
 lib/vtls/schannel.c  | 3 +--
 lib/vtls/vtls.c      | 7 +++----
 lib/vtls/vtls.h      | 7 +++++--
 13 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/include/curl/curl.h b/include/curl/curl.h
index 3936d1e43..146044398 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -2540,6 +2540,11 @@ CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int 
bitmask);
 #define CURLPAUSE_ALL       (CURLPAUSE_RECV|CURLPAUSE_SEND)
 #define CURLPAUSE_CONT      (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT)
 
+typedef struct {
+  curl_sslbackend id;
+  const char *name;
+} curl_ssl_backend;
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/lib/vtls/axtls.c b/lib/vtls/axtls.c
index cfdb1b70f..3531296bb 100644
--- a/lib/vtls/axtls.c
+++ b/lib/vtls/axtls.c
@@ -702,8 +702,7 @@ static void *Curl_axtls_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_axtls = {
-  "axtls",                        /* name */
-  CURLSSLBACKEND_AXTLS,
+  { CURLSSLBACKEND_AXTLS, "axtls" }, /* info */
 
   0, /* have_ca_path */
   0, /* have_certinfo */
diff --git a/lib/vtls/cyassl.c b/lib/vtls/cyassl.c
index d679752fb..122cfda57 100644
--- a/lib/vtls/cyassl.c
+++ b/lib/vtls/cyassl.c
@@ -978,8 +978,7 @@ static void *Curl_cyassl_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_cyassl = {
-  "cyassl",                        /* name */
-  CURLSSLBACKEND_CYASSL,
+  { CURLSSLBACKEND_CYASSL, "cyassl" }, /* info */
 
   0, /* have_ca_path */
   0, /* have_certinfo */
diff --git a/lib/vtls/darwinssl.c b/lib/vtls/darwinssl.c
index b2ca52cb7..d6503216a 100644
--- a/lib/vtls/darwinssl.c
+++ b/lib/vtls/darwinssl.c
@@ -2890,8 +2890,7 @@ static void *Curl_darwinssl_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_darwinssl = {
-  "darwinssl",                        /* name */
-  CURLSSLBACKEND_DARWINSSL,
+  { CURLSSLBACKEND_DARWINSSL, "darwinssl" }, /* info */
 
   0, /* have_ca_path */
   0, /* have_certinfo */
diff --git a/lib/vtls/gskit.c b/lib/vtls/gskit.c
index a1599dd5f..ba5faeff8 100644
--- a/lib/vtls/gskit.c
+++ b/lib/vtls/gskit.c
@@ -1353,8 +1353,7 @@ static void *Curl_gskit_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_gskit = {
-  "gskit",                        /* name */
-  CURLSSLBACKEND_GSKIT,
+  { CURLSSLBACKEND_GSKIT, "gskit" }, /* info */
 
   0, /* have_ca_path */
   1, /* have_certinfo */
diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
index 498634b29..07de85d8f 100644
--- a/lib/vtls/gtls.c
+++ b/lib/vtls/gtls.c
@@ -1806,8 +1806,7 @@ static void *Curl_gtls_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_gnutls = {
-  "gnutls",                      /* name */
-  CURLSSLBACKEND_GNUTLS,
+  { CURLSSLBACKEND_GNUTLS, "gnutls" }, /* info */
 
   1, /* have_ca_path */
   1, /* have_certinfo */
diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c
index d7e16177b..8a0f05b62 100644
--- a/lib/vtls/mbedtls.c
+++ b/lib/vtls/mbedtls.c
@@ -1039,8 +1039,7 @@ static void *Curl_mbedtls_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_mbedtls = {
-  "mbedtls",                        /* name */
-  CURLSSLBACKEND_MBEDTLS,
+  { CURLSSLBACKEND_MBEDTLS, "mbedtls" }, /* info */
 
   0, /* have_ca_path */
   0, /* have_certinfo */
diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c
index 91f6530af..d06b8c8ae 100644
--- a/lib/vtls/nss.c
+++ b/lib/vtls/nss.c
@@ -2343,8 +2343,7 @@ static void *Curl_nss_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_nss = {
-  "nss",                        /* name */
-  CURLSSLBACKEND_NSS,
+  { CURLSSLBACKEND_NSS, "nss" }, /* info */
 
   1, /* have_ca_path */
   1, /* have_certinfo */
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index 136d8e475..394ce2e3d 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -3416,8 +3416,7 @@ static void *Curl_ossl_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_openssl = {
-  "openssl",                     /* name */
-  CURLSSLBACKEND_OPENSSL,
+  { CURLSSLBACKEND_OPENSSL, "openssl" }, /* info */
 
   1, /* have_ca_path */
   1, /* have_certinfo */
diff --git a/lib/vtls/polarssl.c b/lib/vtls/polarssl.c
index 9d4aeacfb..fdfd12ce5 100644
--- a/lib/vtls/polarssl.c
+++ b/lib/vtls/polarssl.c
@@ -901,8 +901,7 @@ static void *Curl_polarssl_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_polarssl = {
-  "polarssl",                        /* name */
-  CURLSSLBACKEND_POLARSSL,
+  { CURLSSLBACKEND_POLARSSL, "polarssl" }, /* info */
 
   1, /* have_ca_path */
   0, /* have_certinfo */
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
index bd7a85bae..473bebe21 100644
--- a/lib/vtls/schannel.c
+++ b/lib/vtls/schannel.c
@@ -1816,8 +1816,7 @@ static void *Curl_schannel_get_internals(struct 
ssl_connect_data *connssl,
 }
 
 const struct Curl_ssl Curl_ssl_schannel = {
-  "schannel",                        /* name */
-  CURLSSLBACKEND_SCHANNEL,
+  { CURLSSLBACKEND_SCHANNEL, "schannel" }, /* info */
 
   0, /* have_ca_path */
   1, /* have_certinfo */
diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
index ed43e1d46..b149d40cf 100644
--- a/lib/vtls/vtls.c
+++ b/lib/vtls/vtls.c
@@ -138,7 +138,7 @@ int Curl_ssl_backend(void)
 {
 #ifdef USE_SSL
   multissl_init();
-  return Curl_ssl->id;
+  return Curl_ssl->info.id;
 #else
   return (int)CURLSSLBACKEND_NONE;
 #endif
@@ -1099,8 +1099,7 @@ static void Curl_multissl_close(struct connectdata *conn, 
int sockindex)
 }
 
 static const struct Curl_ssl Curl_ssl_multi = {
-  "multi",                           /* name */
-  CURLSSLBACKEND_NONE,
+  { CURLSSLBACKEND_NONE, "multi" },  /* info */
 
   0, /* have_ca_path */
   0, /* have_certinfo */
@@ -1182,7 +1181,7 @@ static int multissl_init(void)
   env = getenv("CURL_SSL_BACKEND");
   if(env)
     for(i = 0; available_backends[i]; i++)
-      if(!strcmp(env, available_backends[i]->name)) {
+      if(!strcmp(env, available_backends[i]->info.name)) {
         Curl_ssl = available_backends[i];
         return 0;
       }
diff --git a/lib/vtls/vtls.h b/lib/vtls/vtls.h
index 7d2296952..3c8e32104 100644
--- a/lib/vtls/vtls.h
+++ b/lib/vtls/vtls.h
@@ -27,8 +27,11 @@ struct connectdata;
 struct ssl_connect_data;
 
 struct Curl_ssl {
-  const char *name;
-  int id; /* one of the CURLSSLBACKEND_* constants */
+  /*
+   * This *must* be the first entry to allow returning the list of available
+   * backends in curl_global_sslset().
+   */
+  curl_ssl_backend info;
 
   unsigned have_ca_path:1;      /* supports CAPATH */
   unsigned have_certinfo:1;     /* supports CURLOPT_CERTINFO */

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]