diff options
| author | Eli Zaretskii | 2017-07-14 22:00:55 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-07-14 22:00:55 +0300 |
| commit | 389fb2aebf01fb786e5b18ab87953c90c15279ff (patch) | |
| tree | 174b3b1878e0ad4f04188dd92d1cd73eae5c3a4f /src | |
| parent | 548941bbd8a0a02fe58ba34875468e208c08c891 (diff) | |
| download | emacs-389fb2aebf01fb786e5b18ab87953c90c15279ff.tar.gz emacs-389fb2aebf01fb786e5b18ab87953c90c15279ff.zip | |
Fix the MS-Windows build due to added GnuTLS functions
* src/gnutls.c [WINDOWSNT]: Add DEF_DLL_FN for new functions.
(init_gnutls_functions) [WINDOWSNT]: Add LOAD_DLL_FN for new
functions. Add #define redirections for new functions.
(gnutls_symmetric_aead): Fix format specs to be more portable when
printing ptrdiff_t arguments.
* src/fns.c (gnutls_rnd) [WINDOWSNT]: Redirect to w32_gnutls_rnd
wrapper.
* src/gnutls.h [WINDOWSNT]: Add prototype for w32_gnutls_rnd.
* test/lisp/net/gnutls-tests.el (gnutls-tests-tested-macs)
(gnutls-tests-tested-digests, gnutls-tests-tested-ciphers): Call
gnutls-available-p, otherwise GnuTLS functions might not be loaded
from the DLL on MS-Windows.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 4 | ||||
| -rw-r--r-- | src/gnutls.c | 121 | ||||
| -rw-r--r-- | src/gnutls.h | 1 |
3 files changed, 123 insertions, 3 deletions
| @@ -37,6 +37,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 37 | #include "puresize.h" | 37 | #include "puresize.h" |
| 38 | #include "gnutls.h" | 38 | #include "gnutls.h" |
| 39 | 39 | ||
| 40 | #ifdef WINDOWSNT | ||
| 41 | # define gnutls_rnd w32_gnutls_rnd | ||
| 42 | #endif | ||
| 43 | |||
| 40 | static void sort_vector_copy (Lisp_Object, ptrdiff_t, | 44 | static void sort_vector_copy (Lisp_Object, ptrdiff_t, |
| 41 | Lisp_Object *restrict, Lisp_Object *restrict); | 45 | Lisp_Object *restrict, Lisp_Object *restrict); |
| 42 | enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES }; | 46 | enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES }; |
diff --git a/src/gnutls.c b/src/gnutls.c index 7a4e92f0d3f..761fe7df3ac 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -172,6 +172,51 @@ DEF_DLL_FN (const char *, gnutls_cipher_get_name, | |||
| 172 | DEF_DLL_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t)); | 172 | DEF_DLL_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t)); |
| 173 | DEF_DLL_FN (const char *, gnutls_mac_get_name, (gnutls_mac_algorithm_t)); | 173 | DEF_DLL_FN (const char *, gnutls_mac_get_name, (gnutls_mac_algorithm_t)); |
| 174 | 174 | ||
| 175 | # if (GNUTLS_VERSION_MAJOR + (GNUTLS_VERSION_MINOR >= 4) > 3) | ||
| 176 | DEF_DLL_FN (int, gnutls_rnd, (gnutls_rnd_level_t, void *, size_t)); | ||
| 177 | DEF_DLL_FN (gnutls_cipher_algorithm_t *, gnutls_cipher_list, (void)); | ||
| 178 | DEF_DLL_FN (int, gnutls_cipher_get_iv_size, (gnutls_cipher_algorithm_t)); | ||
| 179 | DEF_DLL_FN (size_t, gnutls_cipher_get_key_size, (gnutls_cipher_algorithm_t)); | ||
| 180 | DEF_DLL_FN (int, gnutls_cipher_get_block_size, (gnutls_cipher_algorithm_t)); | ||
| 181 | DEF_DLL_FN (int, gnutls_cipher_get_tag_size, (gnutls_cipher_algorithm_t)); | ||
| 182 | DEF_DLL_FN (int, gnutls_cipher_init, | ||
| 183 | (gnutls_cipher_hd_t *, gnutls_cipher_algorithm_t, | ||
| 184 | const gnutls_datum_t *, const gnutls_datum_t *)); | ||
| 185 | DEF_DLL_FN (int, gnutls_aead_cipher_init, | ||
| 186 | (gnutls_aead_cipher_hd_t *, gnutls_cipher_algorithm_t, | ||
| 187 | const gnutls_datum_t *)); | ||
| 188 | DEF_DLL_FN (void, gnutls_aead_cipher_deinit, (gnutls_aead_cipher_hd_t)); | ||
| 189 | DEF_DLL_FN (int, gnutls_aead_cipher_encrypt, | ||
| 190 | (gnutls_aead_cipher_hd_t, const void *, size_t, const void *, | ||
| 191 | size_t, size_t, const void *, size_t, void *, size_t *)); | ||
| 192 | DEF_DLL_FN (int, gnutls_aead_cipher_decrypt, | ||
| 193 | (gnutls_aead_cipher_hd_t, const void *, size_t, const void *, | ||
| 194 | size_t, size_t, const void *, size_t, void *, size_t *)); | ||
| 195 | DEF_DLL_FN (void, gnutls_cipher_set_iv, (gnutls_cipher_hd_t, void *, size_t)); | ||
| 196 | DEF_DLL_FN (int, gnutls_cipher_encrypt2, | ||
| 197 | (gnutls_cipher_hd_t, const void *, size_t, void *, size_t)); | ||
| 198 | DEF_DLL_FN (void, gnutls_cipher_deinit, (gnutls_cipher_hd_t)); | ||
| 199 | DEF_DLL_FN (int, gnutls_cipher_decrypt2, | ||
| 200 | (gnutls_cipher_hd_t, const void *, size_t, void *, size_t)); | ||
| 201 | DEF_DLL_FN (const gnutls_mac_algorithm_t *, gnutls_mac_list, (void)); | ||
| 202 | DEF_DLL_FN (size_t, gnutls_mac_get_nonce_size, (gnutls_mac_algorithm_t)); | ||
| 203 | DEF_DLL_FN (size_t, gnutls_mac_get_key_size, (gnutls_mac_algorithm_t)); | ||
| 204 | DEF_DLL_FN (const gnutls_digest_algorithm_t *, gnutls_digest_list, (void)); | ||
| 205 | DEF_DLL_FN (const char *, gnutls_digest_get_name, (gnutls_digest_algorithm_t)); | ||
| 206 | DEF_DLL_FN (int, gnutls_hmac_init, | ||
| 207 | (gnutls_hmac_hd_t *, gnutls_mac_algorithm_t, const void *, size_t)); | ||
| 208 | DEF_DLL_FN (int, gnutls_hmac_get_len, (gnutls_mac_algorithm_t)); | ||
| 209 | DEF_DLL_FN (int, gnutls_hmac, (gnutls_hmac_hd_t, const void *, size_t)); | ||
| 210 | DEF_DLL_FN (void, gnutls_hmac_deinit, (gnutls_hmac_hd_t, void *)); | ||
| 211 | DEF_DLL_FN (int, gnutls_hash_init, | ||
| 212 | (gnutls_hash_hd_t *, gnutls_digest_algorithm_t)); | ||
| 213 | DEF_DLL_FN (void, gnutls_hmac_output, (gnutls_hmac_hd_t, void *)); | ||
| 214 | DEF_DLL_FN (int, gnutls_hash_get_len, (gnutls_digest_algorithm_t)); | ||
| 215 | DEF_DLL_FN (int, gnutls_hash, (gnutls_hash_hd_t, const void *, size_t)); | ||
| 216 | DEF_DLL_FN (void, gnutls_hash_deinit, (gnutls_hash_hd_t, void *)); | ||
| 217 | DEF_DLL_FN (void, gnutls_hash_output, (gnutls_hash_hd_t, void *)); | ||
| 218 | # endif | ||
| 219 | |||
| 175 | 220 | ||
| 176 | static bool | 221 | static bool |
| 177 | init_gnutls_functions (void) | 222 | init_gnutls_functions (void) |
| @@ -256,6 +301,38 @@ init_gnutls_functions (void) | |||
| 256 | LOAD_DLL_FN (library, gnutls_cipher_get_name); | 301 | LOAD_DLL_FN (library, gnutls_cipher_get_name); |
| 257 | LOAD_DLL_FN (library, gnutls_mac_get); | 302 | LOAD_DLL_FN (library, gnutls_mac_get); |
| 258 | LOAD_DLL_FN (library, gnutls_mac_get_name); | 303 | LOAD_DLL_FN (library, gnutls_mac_get_name); |
| 304 | # if GNUTLS_VERSION_MAJOR + (GNUTLS_VERSION_MINOR >= 4) > 3 | ||
| 305 | LOAD_DLL_FN (library, gnutls_rnd); | ||
| 306 | LOAD_DLL_FN (library, gnutls_cipher_list); | ||
| 307 | LOAD_DLL_FN (library, gnutls_cipher_get_iv_size); | ||
| 308 | LOAD_DLL_FN (library, gnutls_cipher_get_key_size); | ||
| 309 | LOAD_DLL_FN (library, gnutls_cipher_get_block_size); | ||
| 310 | LOAD_DLL_FN (library, gnutls_cipher_get_tag_size); | ||
| 311 | LOAD_DLL_FN (library, gnutls_cipher_init); | ||
| 312 | LOAD_DLL_FN (library, gnutls_aead_cipher_encrypt); | ||
| 313 | LOAD_DLL_FN (library, gnutls_aead_cipher_decrypt); | ||
| 314 | LOAD_DLL_FN (library, gnutls_aead_cipher_init); | ||
| 315 | LOAD_DLL_FN (library, gnutls_aead_cipher_deinit); | ||
| 316 | LOAD_DLL_FN (library, gnutls_cipher_set_iv); | ||
| 317 | LOAD_DLL_FN (library, gnutls_cipher_encrypt2); | ||
| 318 | LOAD_DLL_FN (library, gnutls_cipher_decrypt2); | ||
| 319 | LOAD_DLL_FN (library, gnutls_cipher_deinit); | ||
| 320 | LOAD_DLL_FN (library, gnutls_mac_list); | ||
| 321 | LOAD_DLL_FN (library, gnutls_mac_get_nonce_size); | ||
| 322 | LOAD_DLL_FN (library, gnutls_mac_get_key_size); | ||
| 323 | LOAD_DLL_FN (library, gnutls_digest_list); | ||
| 324 | LOAD_DLL_FN (library, gnutls_digest_get_name); | ||
| 325 | LOAD_DLL_FN (library, gnutls_hmac_init); | ||
| 326 | LOAD_DLL_FN (library, gnutls_hmac_get_len); | ||
| 327 | LOAD_DLL_FN (library, gnutls_hmac); | ||
| 328 | LOAD_DLL_FN (library, gnutls_hmac_deinit); | ||
| 329 | LOAD_DLL_FN (library, gnutls_hmac_output); | ||
| 330 | LOAD_DLL_FN (library, gnutls_hash_init); | ||
| 331 | LOAD_DLL_FN (library, gnutls_hash_get_len); | ||
| 332 | LOAD_DLL_FN (library, gnutls_hash); | ||
| 333 | LOAD_DLL_FN (library, gnutls_hash_deinit); | ||
| 334 | LOAD_DLL_FN (library, gnutls_hash_output); | ||
| 335 | # endif | ||
| 259 | 336 | ||
| 260 | max_log_level = global_gnutls_log_level; | 337 | max_log_level = global_gnutls_log_level; |
| 261 | 338 | ||
| @@ -333,6 +410,44 @@ init_gnutls_functions (void) | |||
| 333 | # define gnutls_x509_crt_get_version fn_gnutls_x509_crt_get_version | 410 | # define gnutls_x509_crt_get_version fn_gnutls_x509_crt_get_version |
| 334 | # define gnutls_x509_crt_import fn_gnutls_x509_crt_import | 411 | # define gnutls_x509_crt_import fn_gnutls_x509_crt_import |
| 335 | # define gnutls_x509_crt_init fn_gnutls_x509_crt_init | 412 | # define gnutls_x509_crt_init fn_gnutls_x509_crt_init |
| 413 | # define gnutls_rnd fn_gnutls_rnd | ||
| 414 | # define gnutls_cipher_list fn_gnutls_cipher_list | ||
| 415 | # define gnutls_cipher_get_iv_size fn_gnutls_cipher_get_iv_size | ||
| 416 | # define gnutls_cipher_get_key_size fn_gnutls_cipher_get_key_size | ||
| 417 | # define gnutls_cipher_get_block_size fn_gnutls_cipher_get_block_size | ||
| 418 | # define gnutls_cipher_get_tag_size fn_gnutls_cipher_get_tag_size | ||
| 419 | # define gnutls_cipher_init fn_gnutls_cipher_init | ||
| 420 | # define gnutls_aead_cipher_encrypt fn_gnutls_aead_cipher_encrypt | ||
| 421 | # define gnutls_aead_cipher_decrypt fn_gnutls_aead_cipher_decrypt | ||
| 422 | # define gnutls_aead_cipher_init fn_gnutls_aead_cipher_init | ||
| 423 | # define gnutls_aead_cipher_deinit fn_gnutls_aead_cipher_deinit | ||
| 424 | # define gnutls_cipher_set_iv fn_gnutls_cipher_set_iv | ||
| 425 | # define gnutls_cipher_encrypt2 fn_gnutls_cipher_encrypt2 | ||
| 426 | # define gnutls_cipher_decrypt2 fn_gnutls_cipher_decrypt2 | ||
| 427 | # define gnutls_cipher_deinit fn_gnutls_cipher_deinit | ||
| 428 | # define gnutls_mac_list fn_gnutls_mac_list | ||
| 429 | # define gnutls_mac_get_nonce_size fn_gnutls_mac_get_nonce_size | ||
| 430 | # define gnutls_mac_get_key_size fn_gnutls_mac_get_key_size | ||
| 431 | # define gnutls_digest_list fn_gnutls_digest_list | ||
| 432 | # define gnutls_digest_get_name fn_gnutls_digest_get_name | ||
| 433 | # define gnutls_hmac_init fn_gnutls_hmac_init | ||
| 434 | # define gnutls_hmac_get_len fn_gnutls_hmac_get_len | ||
| 435 | # define gnutls_hmac fn_gnutls_hmac | ||
| 436 | # define gnutls_hmac_deinit fn_gnutls_hmac_deinit | ||
| 437 | # define gnutls_hmac_output fn_gnutls_hmac_output | ||
| 438 | # define gnutls_hash_init fn_gnutls_hash_init | ||
| 439 | # define gnutls_hash_get_len fn_gnutls_hash_get_len | ||
| 440 | # define gnutls_hash fn_gnutls_hash | ||
| 441 | # define gnutls_hash_deinit fn_gnutls_hash_deinit | ||
| 442 | # define gnutls_hash_output fn_gnutls_hash_output | ||
| 443 | |||
| 444 | /* This wrapper is called from fns.c, which doesn't know about the | ||
| 445 | LOAD_DLL_FN stuff above. */ | ||
| 446 | int | ||
| 447 | w32_gnutls_rnd (gnutls_rnd_level_t level, void *data, size_t len) | ||
| 448 | { | ||
| 449 | return gnutls_rnd (level, data, len); | ||
| 450 | } | ||
| 336 | 451 | ||
| 337 | #endif | 452 | #endif |
| 338 | 453 | ||
| @@ -1899,7 +2014,7 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher, | |||
| 1899 | error ("GnuTLS cipher key extraction failed"); | 2014 | error ("GnuTLS cipher key extraction failed"); |
| 1900 | 2015 | ||
| 1901 | if ((kend_byte - kstart_byte) != gnutls_cipher_get_key_size (gca)) | 2016 | if ((kend_byte - kstart_byte) != gnutls_cipher_get_key_size (gca)) |
| 1902 | error ("GnuTLS cipher %s/%s key length %ld was not equal to " | 2017 | error ("GnuTLS cipher %s/%s key length %" pD "d was not equal to " |
| 1903 | "the required %ld", | 2018 | "the required %ld", |
| 1904 | gnutls_cipher_get_name (gca), desc, | 2019 | gnutls_cipher_get_name (gca), desc, |
| 1905 | kend_byte - kstart_byte, (long) gnutls_cipher_get_key_size (gca)); | 2020 | kend_byte - kstart_byte, (long) gnutls_cipher_get_key_size (gca)); |
| @@ -1911,7 +2026,7 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher, | |||
| 1911 | error ("GnuTLS cipher IV extraction failed"); | 2026 | error ("GnuTLS cipher IV extraction failed"); |
| 1912 | 2027 | ||
| 1913 | if ((vend_byte - vstart_byte) != gnutls_cipher_get_iv_size (gca)) | 2028 | if ((vend_byte - vstart_byte) != gnutls_cipher_get_iv_size (gca)) |
| 1914 | error ("GnuTLS cipher %s/%s IV length %ld was not equal to " | 2029 | error ("GnuTLS cipher %s/%s IV length %" pD "d was not equal to " |
| 1915 | "the required %ld", | 2030 | "the required %ld", |
| 1916 | gnutls_cipher_get_name (gca), desc, | 2031 | gnutls_cipher_get_name (gca), desc, |
| 1917 | vend_byte - vstart_byte, (long) gnutls_cipher_get_iv_size (gca)); | 2032 | vend_byte - vstart_byte, (long) gnutls_cipher_get_iv_size (gca)); |
| @@ -1939,7 +2054,7 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher, | |||
| 1939 | } | 2054 | } |
| 1940 | 2055 | ||
| 1941 | if ((iend_byte - istart_byte) % gnutls_cipher_get_block_size (gca) != 0) | 2056 | if ((iend_byte - istart_byte) % gnutls_cipher_get_block_size (gca) != 0) |
| 1942 | error ("GnuTLS cipher %s/%s input block length %ld was not a multiple " | 2057 | error ("GnuTLS cipher %s/%s input block length %" pD "d was not a multiple " |
| 1943 | "of the required %ld", | 2058 | "of the required %ld", |
| 1944 | gnutls_cipher_get_name (gca), desc, | 2059 | gnutls_cipher_get_name (gca), desc, |
| 1945 | iend_byte - istart_byte, (long) gnutls_cipher_get_block_size (gca)); | 2060 | iend_byte - istart_byte, (long) gnutls_cipher_get_block_size (gca)); |
diff --git a/src/gnutls.h b/src/gnutls.h index 981d59410bb..3ec86a8892d 100644 --- a/src/gnutls.h +++ b/src/gnutls.h | |||
| @@ -86,6 +86,7 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte); | |||
| 86 | extern ptrdiff_t emacs_gnutls_record_check_pending (gnutls_session_t state); | 86 | extern ptrdiff_t emacs_gnutls_record_check_pending (gnutls_session_t state); |
| 87 | #ifdef WINDOWSNT | 87 | #ifdef WINDOWSNT |
| 88 | extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err); | 88 | extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err); |
| 89 | extern int w32_gnutls_rnd (gnutls_rnd_level_t, void *, size_t); | ||
| 89 | #endif | 90 | #endif |
| 90 | extern Lisp_Object emacs_gnutls_deinit (Lisp_Object); | 91 | extern Lisp_Object emacs_gnutls_deinit (Lisp_Object); |
| 91 | extern Lisp_Object emacs_gnutls_global_init (void); | 92 | extern Lisp_Object emacs_gnutls_global_init (void); |