curl/lib/vtls
Johannes Schindelin 70f1db321a
vtls: encapsulate SSL backend-specific data
So far, all of the SSL backends' private data has been declared as
part of the ssl_connect_data struct, in one big #if .. #elif .. #endif
block.

This can only work as long as the SSL backend is a compile-time option,
something we want to change in the next commits.

Therefore, let's encapsulate the exact data needed by each SSL backend
into a private struct, and let's avoid bleeding any SSL backend-specific
information into urldata.h. This is also necessary to allow multiple SSL
backends to be compiled in at the same time, as e.g. OpenSSL's and
CyaSSL's headers cannot be included in the same .c file.

To avoid too many malloc() calls, we simply append the private structs
to the connectdata struct in allocate_conn().

This requires us to take extra care of alignment issues: struct fields
often need to be aligned on certain boundaries e.g. 32-bit values need to
be stored at addresses that divide evenly by 4 (= 32 bit / 8
bit-per-byte).

We do that by assuming that no SSL backend's private data contains any
fields that need to be aligned on boundaries larger than `long long`
(typically 64-bit) would need. Under this assumption, we simply add a
dummy field of type `long long` to the `struct connectdata` struct. This
field will never be accessed but acts as a placeholder for the four
instances of ssl_backend_data instead. the size of each ssl_backend_data
struct is stored in the SSL backend-specific metadata, to allow
allocate_conn() to know how much extra space to allocate, and how to
initialize the ssl[sockindex]->backend and proxy_ssl[sockindex]->backend
pointers.

This would appear to be a little complicated at first, but is really
necessary to encapsulate the private data of each SSL backend correctly.
And we need to encapsulate thusly if we ever want to allow selecting
CyaSSL and OpenSSL at runtime, as their headers cannot be included within
the same .c file (there are just too many conflicting definitions and
declarations for that).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-08-28 14:56:58 +02:00
..
axtls.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
axtls.h vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
cyassl.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
cyassl.h vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
darwinssl.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
darwinssl.h vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
gskit.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
gskit.h vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
gtls.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
gtls.h vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
mbedtls.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
mbedtls.h vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
nss.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
nssg.h vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
openssl.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
openssl.h vtls: move SSL backends' private constants out of their header files 2017-08-28 14:56:57 +02:00
polarssl.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
polarssl.h vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
polarssl_threadlock.c Curl_polarsslthreadlock_thread_setup: clear array at init 2016-10-18 13:05:43 +02:00
polarssl_threadlock.h URLs: change all http:// URLs to https:// 2016-02-03 00:19:02 +01:00
schannel.c vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00
schannel.h vtls: move SSL backends' private constants out of their header files 2017-08-28 14:56:57 +02:00
vtls.c vtls: remove obsolete declarations of SSL backend functionality 2017-08-28 14:56:57 +02:00
vtls.h vtls: encapsulate SSL backend-specific data 2017-08-28 14:56:58 +02:00