aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/tls
diff options
context:
space:
mode:
authorlv-426 <oxcafebaby@yahoo.com>2008-08-11 03:40:22 +0000
committerlv-426 <oxcafebaby@yahoo.com>2008-08-11 03:40:22 +0000
commit1c893a971fa8d04ada6c66aa9ebf525b03ed4426 (patch)
tree7a4b22d2bd11a55aa2bd2bc01495572dd260e7d6 /src/daemon/https/tls
parent41886bcf92e8e6b943c9f0697a75f4a380952f52 (diff)
downloadlibmicrohttpd-1c893a971fa8d04ada6c66aa9ebf525b03ed4426.tar.gz
libmicrohttpd-1c893a971fa8d04ada6c66aa9ebf525b03ed4426.zip
gnutls code cleanup
symbol refactoring
Diffstat (limited to 'src/daemon/https/tls')
-rw-r--r--src/daemon/https/tls/auth_anon.c56
-rw-r--r--src/daemon/https/tls/auth_anon.h16
-rw-r--r--src/daemon/https/tls/auth_cert.c192
-rw-r--r--src/daemon/https/tls/auth_cert.h42
-rw-r--r--src/daemon/https/tls/auth_dh_common.c104
-rw-r--r--src/daemon/https/tls/auth_dh_common.h10
-rw-r--r--src/daemon/https/tls/auth_dhe.c102
-rw-r--r--src/daemon/https/tls/auth_rsa.c70
-rw-r--r--src/daemon/https/tls/auth_rsa_export.c96
-rw-r--r--src/daemon/https/tls/debug.c2
-rw-r--r--src/daemon/https/tls/debug.h2
-rw-r--r--src/daemon/https/tls/ext_cert_type.c10
-rw-r--r--src/daemon/https/tls/ext_cert_type.h4
-rw-r--r--src/daemon/https/tls/ext_inner_application.c12
-rw-r--r--src/daemon/https/tls/ext_inner_application.h4
-rw-r--r--src/daemon/https/tls/ext_max_record.c16
-rw-r--r--src/daemon/https/tls/ext_max_record.h8
-rw-r--r--src/daemon/https/tls/ext_oprfi.c34
-rw-r--r--src/daemon/https/tls/ext_oprfi.h4
-rw-r--r--src/daemon/https/tls/ext_server_name.c26
-rw-r--r--src/daemon/https/tls/ext_server_name.h4
-rw-r--r--src/daemon/https/tls/gnutls_alert.c36
-rw-r--r--src/daemon/https/tls/gnutls_algorithms.c379
-rw-r--r--src/daemon/https/tls/gnutls_algorithms.h110
-rw-r--r--src/daemon/https/tls/gnutls_anon_cred.c40
-rw-r--r--src/daemon/https/tls/gnutls_auth.c84
-rw-r--r--src/daemon/https/tls/gnutls_auth.h30
-rw-r--r--src/daemon/https/tls/gnutls_auth_int.h8
-rw-r--r--src/daemon/https/tls/gnutls_buffer.h31
-rw-r--r--src/daemon/https/tls/gnutls_buffers.c204
-rw-r--r--src/daemon/https/tls/gnutls_buffers.h48
-rw-r--r--src/daemon/https/tls/gnutls_cert.c152
-rw-r--r--src/daemon/https/tls/gnutls_cert.h16
-rw-r--r--src/daemon/https/tls/gnutls_cipher.c86
-rw-r--r--src/daemon/https/tls/gnutls_cipher.h8
-rw-r--r--src/daemon/https/tls/gnutls_cipher_int.c8
-rw-r--r--src/daemon/https/tls/gnutls_cipher_int.h8
-rw-r--r--src/daemon/https/tls/gnutls_compress.c8
-rw-r--r--src/daemon/https/tls/gnutls_compress.h4
-rw-r--r--src/daemon/https/tls/gnutls_compress_int.c16
-rw-r--r--src/daemon/https/tls/gnutls_compress_int.h8
-rw-r--r--src/daemon/https/tls/gnutls_constate.c166
-rw-r--r--src/daemon/https/tls/gnutls_constate.h20
-rw-r--r--src/daemon/https/tls/gnutls_datum.c20
-rw-r--r--src/daemon/https/tls/gnutls_datum.h22
-rw-r--r--src/daemon/https/tls/gnutls_dh.c24
-rw-r--r--src/daemon/https/tls/gnutls_dh.h14
-rw-r--r--src/daemon/https/tls/gnutls_dh_primes.c453
-rw-r--r--src/daemon/https/tls/gnutls_errors.c12
-rw-r--r--src/daemon/https/tls/gnutls_extensions.c82
-rw-r--r--src/daemon/https/tls/gnutls_extensions.h22
-rw-r--r--src/daemon/https/tls/gnutls_extra_hooks.h6
-rw-r--r--src/daemon/https/tls/gnutls_global.c69
-rw-r--r--src/daemon/https/tls/gnutls_global.h2
-rw-r--r--src/daemon/https/tls/gnutls_handshake.c494
-rw-r--r--src/daemon/https/tls/gnutls_handshake.h34
-rw-r--r--src/daemon/https/tls/gnutls_hash_int.c98
-rw-r--r--src/daemon/https/tls/gnutls_hash_int.h27
-rw-r--r--src/daemon/https/tls/gnutls_int.h128
-rw-r--r--src/daemon/https/tls/gnutls_kx.c134
-rw-r--r--src/daemon/https/tls/gnutls_kx.h26
-rw-r--r--src/daemon/https/tls/gnutls_mem.c14
-rw-r--r--src/daemon/https/tls/gnutls_mem.h8
-rw-r--r--src/daemon/https/tls/gnutls_mpi.c30
-rw-r--r--src/daemon/https/tls/gnutls_mpi.h16
-rw-r--r--src/daemon/https/tls/gnutls_num.c28
-rw-r--r--src/daemon/https/tls/gnutls_num.h24
-rw-r--r--src/daemon/https/tls/gnutls_pk.c60
-rw-r--r--src/daemon/https/tls/gnutls_pk.h10
-rw-r--r--src/daemon/https/tls/gnutls_priority.c124
-rw-r--r--src/daemon/https/tls/gnutls_record.c224
-rw-r--r--src/daemon/https/tls/gnutls_record.h8
-rw-r--r--src/daemon/https/tls/gnutls_rsa_export.c157
-rw-r--r--src/daemon/https/tls/gnutls_rsa_export.h4
-rw-r--r--src/daemon/https/tls/gnutls_session.c182
-rw-r--r--src/daemon/https/tls/gnutls_session_pack.c180
-rw-r--r--src/daemon/https/tls/gnutls_session_pack.h4
-rw-r--r--src/daemon/https/tls/gnutls_sig.c110
-rw-r--r--src/daemon/https/tls/gnutls_sig.h10
-rw-r--r--src/daemon/https/tls/gnutls_state.c340
-rw-r--r--src/daemon/https/tls/gnutls_state.h34
-rw-r--r--src/daemon/https/tls/gnutls_str.c26
-rw-r--r--src/daemon/https/tls/gnutls_str.h26
-rw-r--r--src/daemon/https/tls/gnutls_supplemental.c22
-rw-r--r--src/daemon/https/tls/gnutls_supplemental.h6
-rw-r--r--src/daemon/https/tls/gnutls_ui.c150
-rw-r--r--src/daemon/https/tls/gnutls_x509.c509
-rw-r--r--src/daemon/https/tls/gnutls_x509.h2
-rw-r--r--src/daemon/https/tls/x509_b64.c20
89 files changed, 2639 insertions, 3640 deletions
diff --git a/src/daemon/https/tls/auth_anon.c b/src/daemon/https/tls/auth_anon.c
index d32ef344..ae6346c3 100644
--- a/src/daemon/https/tls/auth_anon.c
+++ b/src/daemon/https/tls/auth_anon.c
@@ -40,38 +40,38 @@
40#include <gnutls_state.h> 40#include <gnutls_state.h>
41#include <auth_dh_common.h> 41#include <auth_dh_common.h>
42 42
43static int gen_anon_server_kx (gnutls_session_t, opaque **); 43static int gen_anon_server_kx (mhd_gtls_session_t, opaque **);
44static int proc_anon_client_kx (gnutls_session_t, opaque *, size_t); 44static int proc_anon_client_kx (mhd_gtls_session_t, opaque *, size_t);
45static int proc_anon_server_kx (gnutls_session_t, opaque *, size_t); 45static int mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t, opaque *, size_t);
46 46
47const mod_auth_st anon_auth_struct = { 47const mhd_gtls_mod_auth_st anon_auth_struct = {
48 "ANON", 48 "ANON",
49 NULL, 49 NULL,
50 NULL, 50 NULL,
51 gen_anon_server_kx, 51 gen_anon_server_kx,
52 _gnutls_gen_dh_common_client_kx, /* this can be shared */ 52 mhd_gtls_gen_dh_common_client_kx, /* this can be shared */
53 NULL, 53 NULL,
54 NULL, 54 NULL,
55 55
56 NULL, 56 NULL,
57 NULL, /* certificate */ 57 NULL, /* certificate */
58 proc_anon_server_kx, 58 mhd_gtls_proc_anon_server_kx,
59 proc_anon_client_kx, 59 proc_anon_client_kx,
60 NULL, 60 NULL,
61 NULL 61 NULL
62}; 62};
63 63
64static int 64static int
65gen_anon_server_kx (gnutls_session_t session, opaque ** data) 65gen_anon_server_kx (mhd_gtls_session_t session, opaque ** data)
66{ 66{
67 mpi_t g, p; 67 mpi_t g, p;
68 const mpi_t *mpis; 68 const mpi_t *mpis;
69 int ret; 69 int ret;
70 gnutls_dh_params_t dh_params; 70 mhd_gtls_dh_params_t dh_params;
71 gnutls_anon_server_credentials_t cred; 71 mhd_gtls_anon_server_credentials_t cred;
72 72
73 cred = (gnutls_anon_server_credentials_t) 73 cred = (mhd_gtls_anon_server_credentials_t)
74 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL); 74 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
75 if (cred == NULL) 75 if (cred == NULL)
76 { 76 {
77 gnutls_assert (); 77 gnutls_assert ();
@@ -79,8 +79,8 @@ gen_anon_server_kx (gnutls_session_t session, opaque ** data)
79 } 79 }
80 80
81 dh_params = 81 dh_params =
82 _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); 82 mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
83 mpis = _gnutls_dh_params_to_mpi (dh_params); 83 mpis = mhd_gtls_dh_params_to_mpi (dh_params);
84 if (mpis == NULL) 84 if (mpis == NULL)
85 { 85 {
86 gnutls_assert (); 86 gnutls_assert ();
@@ -91,16 +91,16 @@ gen_anon_server_kx (gnutls_session_t session, opaque ** data)
91 g = mpis[1]; 91 g = mpis[1];
92 92
93 if ((ret = 93 if ((ret =
94 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_ANON, 94 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
95 sizeof (anon_auth_info_st), 1)) < 0) 95 sizeof (anon_auth_info_st), 1)) < 0)
96 { 96 {
97 gnutls_assert (); 97 gnutls_assert ();
98 return ret; 98 return ret;
99 } 99 }
100 100
101 _gnutls_dh_set_group (session, g, p); 101 mhd_gtls_dh_set_group (session, g, p);
102 102
103 ret = _gnutls_dh_common_print_server_kx (session, g, p, data, 0); 103 ret = mhd_gtls_dh_common_print_server_kx (session, g, p, data, 0);
104 if (ret < 0) 104 if (ret < 0)
105 { 105 {
106 gnutls_assert (); 106 gnutls_assert ();
@@ -111,20 +111,20 @@ gen_anon_server_kx (gnutls_session_t session, opaque ** data)
111 111
112 112
113static int 113static int
114proc_anon_client_kx (gnutls_session_t session, opaque * data, 114proc_anon_client_kx (mhd_gtls_session_t session, opaque * data,
115 size_t _data_size) 115 size_t _data_size)
116{ 116{
117 gnutls_anon_server_credentials_t cred; 117 mhd_gtls_anon_server_credentials_t cred;
118 int bits; 118 int bits;
119 int ret; 119 int ret;
120 mpi_t p, g; 120 mpi_t p, g;
121 gnutls_dh_params_t dh_params; 121 mhd_gtls_dh_params_t dh_params;
122 const mpi_t *mpis; 122 const mpi_t *mpis;
123 123
124 bits = _gnutls_dh_get_allowed_prime_bits (session); 124 bits = mhd_gtls_dh_get_allowed_prime_bits (session);
125 125
126 cred = (gnutls_anon_server_credentials_t) 126 cred = (mhd_gtls_anon_server_credentials_t)
127 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL); 127 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
128 if (cred == NULL) 128 if (cred == NULL)
129 { 129 {
130 gnutls_assert (); 130 gnutls_assert ();
@@ -132,8 +132,8 @@ proc_anon_client_kx (gnutls_session_t session, opaque * data,
132 } 132 }
133 133
134 dh_params = 134 dh_params =
135 _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); 135 mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
136 mpis = _gnutls_dh_params_to_mpi (dh_params); 136 mpis = mhd_gtls_dh_params_to_mpi (dh_params);
137 if (mpis == NULL) 137 if (mpis == NULL)
138 { 138 {
139 gnutls_assert (); 139 gnutls_assert ();
@@ -143,14 +143,14 @@ proc_anon_client_kx (gnutls_session_t session, opaque * data,
143 p = mpis[0]; 143 p = mpis[0];
144 g = mpis[1]; 144 g = mpis[1];
145 145
146 ret = _gnutls_proc_dh_common_client_kx (session, data, _data_size, g, p); 146 ret = mhd_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
147 147
148 return ret; 148 return ret;
149 149
150} 150}
151 151
152int 152int
153proc_anon_server_kx (gnutls_session_t session, opaque * data, 153mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t session, opaque * data,
154 size_t _data_size) 154 size_t _data_size)
155{ 155{
156 156
@@ -158,14 +158,14 @@ proc_anon_server_kx (gnutls_session_t session, opaque * data,
158 158
159 /* set auth_info */ 159 /* set auth_info */
160 if ((ret = 160 if ((ret =
161 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_ANON, 161 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
162 sizeof (anon_auth_info_st), 1)) < 0) 162 sizeof (anon_auth_info_st), 1)) < 0)
163 { 163 {
164 gnutls_assert (); 164 gnutls_assert ();
165 return ret; 165 return ret;
166 } 166 }
167 167
168 ret = _gnutls_proc_dh_common_server_kx (session, data, _data_size, 0); 168 ret = mhd_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
169 if (ret < 0) 169 if (ret < 0)
170 { 170 {
171 gnutls_assert (); 171 gnutls_assert ();
diff --git a/src/daemon/https/tls/auth_anon.h b/src/daemon/https/tls/auth_anon.h
index b1705f85..631dd595 100644
--- a/src/daemon/https/tls/auth_anon.h
+++ b/src/daemon/https/tls/auth_anon.h
@@ -26,23 +26,23 @@
26#include <gnutls_auth.h> 26#include <gnutls_auth.h>
27#include <auth_dh_common.h> 27#include <auth_dh_common.h>
28 28
29typedef struct gnutls_anon_server_credentials_st 29typedef struct mhd_gtls_anon_server_credentials_st
30{ 30{
31 gnutls_dh_params_t dh_params; 31 mhd_gtls_dh_params_t dh_params;
32 /* this callback is used to retrieve the DH or RSA 32 /* this callback is used to retrieve the DH or RSA
33 * parameters. 33 * parameters.
34 */ 34 */
35 gnutls_params_function *params_func; 35 gnutls_params_function *params_func;
36} anon_server_credentials_st; 36} mhd_anon_server_credentials_st;
37 37
38typedef struct gnutls_anon_client_credentials_st 38typedef struct mhd_gtls_anon_client_credentials_st
39{ 39{
40 int dummy; 40 int dummy;
41} anon_client_credentials_st; 41} mhd_anon_client_credentials_st;
42 42
43typedef struct anon_auth_info_st 43typedef struct mhd_gtls_anon_auth_info_st
44{ 44{
45 dh_info_st dh; 45 dh_info_st dh;
46} *anon_auth_info_t; 46} * mhd_anon_auth_info_t;
47 47
48typedef struct anon_auth_info_st anon_auth_info_st; 48typedef struct mhd_gtls_anon_auth_info_st anon_auth_info_st;
diff --git a/src/daemon/https/tls/auth_cert.c b/src/daemon/https/tls/auth_cert.c
index c5c5d9f5..7fea2569 100644
--- a/src/daemon/https/tls/auth_cert.c
+++ b/src/daemon/https/tls/auth_cert.c
@@ -187,7 +187,7 @@ _gnutls_cert_get_issuer_dn (gnutls_cert * cert, gnutls_datum_t * odn)
187 * CAs and sign algorithms supported by the peer server. 187 * CAs and sign algorithms supported by the peer server.
188 */ 188 */
189static int 189static int
190_find_x509_cert (const gnutls_certificate_credentials_t cred, 190_find_x509_cert (const mhd_gtls_cert_credentials_t cred,
191 opaque * _data, size_t _data_size, 191 opaque * _data, size_t _data_size,
192 const gnutls_pk_algorithm_t * pk_algos, 192 const gnutls_pk_algorithm_t * pk_algos,
193 int pk_algos_length, int *indx) 193 int pk_algos_length, int *indx)
@@ -205,7 +205,7 @@ _find_x509_cert (const gnutls_certificate_credentials_t cred,
205 { 205 {
206 206
207 DECR_LENGTH_RET (data_size, 2, 0); 207 DECR_LENGTH_RET (data_size, 2, 0);
208 size = _gnutls_read_uint16 (data); 208 size = mhd_gtls_read_uint16 (data);
209 DECR_LENGTH_RET (data_size, size, 0); 209 DECR_LENGTH_RET (data_size, size, 0);
210 data += 2; 210 data += 2;
211 211
@@ -258,7 +258,7 @@ _find_x509_cert (const gnutls_certificate_credentials_t cred,
258/* Locates the most appropriate openpgp cert 258/* Locates the most appropriate openpgp cert
259 */ 259 */
260static int 260static int
261_find_openpgp_cert (const gnutls_certificate_credentials_t cred, 261_find_openpgp_cert (const mhd_gtls_cert_credentials_t cred,
262 gnutls_pk_algorithm_t * pk_algos, 262 gnutls_pk_algorithm_t * pk_algos,
263 int pk_algos_length, int *indx) 263 int pk_algos_length, int *indx)
264{ 264{
@@ -294,7 +294,7 @@ _find_openpgp_cert (const gnutls_certificate_credentials_t cred,
294 * certificate request packet. 294 * certificate request packet.
295 */ 295 */
296static int 296static int
297get_issuers_num (gnutls_session_t session, opaque * data, ssize_t data_size) 297get_issuers_num (mhd_gtls_session_t session, opaque * data, ssize_t data_size)
298{ 298{
299 int issuers_dn_len = 0, result; 299 int issuers_dn_len = 0, result;
300 unsigned size; 300 unsigned size;
@@ -314,7 +314,7 @@ get_issuers_num (gnutls_session_t session, opaque * data, ssize_t data_size)
314 */ 314 */
315 result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 315 result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
316 DECR_LENGTH_COM (data_size, 2, goto error); 316 DECR_LENGTH_COM (data_size, 2, goto error);
317 size = _gnutls_read_uint16 (data); 317 size = mhd_gtls_read_uint16 (data);
318 318
319 result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 319 result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
320 DECR_LENGTH_COM (data_size, size, goto error); 320 DECR_LENGTH_COM (data_size, size, goto error);
@@ -343,7 +343,7 @@ error:
343 * packet. 343 * packet.
344 */ 344 */
345static int 345static int
346get_issuers (gnutls_session_t session, 346get_issuers (mhd_gtls_session_t session,
347 gnutls_datum_t * issuers_dn, int issuers_len, 347 gnutls_datum_t * issuers_dn, int issuers_len,
348 opaque * data, size_t data_size) 348 opaque * data, size_t data_size)
349{ 349{
@@ -367,7 +367,7 @@ get_issuers (gnutls_session_t session,
367 */ 367 */
368 data_size -= 2; 368 data_size -= 2;
369 369
370 size = _gnutls_read_uint16 (data); 370 size = mhd_gtls_read_uint16 (data);
371 371
372 data += 2; 372 data += 2;
373 373
@@ -384,7 +384,7 @@ get_issuers (gnutls_session_t session,
384/* Calls the client get callback. 384/* Calls the client get callback.
385 */ 385 */
386static int 386static int
387call_get_cert_callback (gnutls_session_t session, 387call_get_cert_callback (mhd_gtls_session_t session,
388 gnutls_datum_t * issuers_dn, 388 gnutls_datum_t * issuers_dn,
389 int issuers_dn_length, 389 int issuers_dn_length,
390 gnutls_pk_algorithm_t * pk_algos, int pk_algos_length) 390 gnutls_pk_algorithm_t * pk_algos, int pk_algos_length)
@@ -395,10 +395,10 @@ call_get_cert_callback (gnutls_session_t session,
395 gnutls_retr_st st; 395 gnutls_retr_st st;
396 int ret; 396 int ret;
397 gnutls_certificate_type_t type = gnutls_certificate_type_get (session); 397 gnutls_certificate_type_t type = gnutls_certificate_type_get (session);
398 gnutls_certificate_credentials_t cred; 398 mhd_gtls_cert_credentials_t cred;
399 399
400 cred = (gnutls_certificate_credentials_t) 400 cred = (mhd_gtls_cert_credentials_t)
401 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 401 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
402 if (cred == NULL) 402 if (cred == NULL)
403 { 403 {
404 gnutls_assert (); 404 gnutls_assert ();
@@ -457,7 +457,7 @@ call_get_cert_callback (gnutls_session_t session,
457 457
458 } 458 }
459 459
460 _gnutls_selected_certs_set (session, local_certs, 460 mhd_gtls_selected_certs_set (session, local_certs,
461 (local_certs != NULL) ? st.ncerts : 0, 461 (local_certs != NULL) ? st.ncerts : 0,
462 local_key, 1); 462 local_key, 1);
463 463
@@ -504,20 +504,20 @@ cleanup:
504 * algorithm (only in automatic mode). 504 * algorithm (only in automatic mode).
505 */ 505 */
506static int 506static int
507_select_client_cert (gnutls_session_t session, 507_select_client_cert (mhd_gtls_session_t session,
508 opaque * _data, size_t _data_size, 508 opaque * _data, size_t _data_size,
509 gnutls_pk_algorithm_t * pk_algos, int pk_algos_length) 509 gnutls_pk_algorithm_t * pk_algos, int pk_algos_length)
510{ 510{
511 int result; 511 int result;
512 int indx = -1; 512 int indx = -1;
513 gnutls_certificate_credentials_t cred; 513 mhd_gtls_cert_credentials_t cred;
514 opaque *data = _data; 514 opaque *data = _data;
515 ssize_t data_size = _data_size; 515 ssize_t data_size = _data_size;
516 int issuers_dn_length; 516 int issuers_dn_length;
517 gnutls_datum_t *issuers_dn = NULL; 517 gnutls_datum_t *issuers_dn = NULL;
518 518
519 cred = (gnutls_certificate_credentials_t) 519 cred = (mhd_gtls_cert_credentials_t)
520 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 520 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
521 if (cred == NULL) 521 if (cred == NULL)
522 { 522 {
523 gnutls_assert (); 523 gnutls_assert ();
@@ -590,14 +590,14 @@ _select_client_cert (gnutls_session_t session,
590 590
591 if (indx >= 0) 591 if (indx >= 0)
592 { 592 {
593 _gnutls_selected_certs_set (session, 593 mhd_gtls_selected_certs_set (session,
594 &cred->cert_list[indx][0], 594 &cred->cert_list[indx][0],
595 cred->cert_list_length[indx], 595 cred->cert_list_length[indx],
596 &cred->pkey[indx], 0); 596 &cred->pkey[indx], 0);
597 } 597 }
598 else 598 else
599 { 599 {
600 _gnutls_selected_certs_set (session, NULL, 0, NULL, 0); 600 mhd_gtls_selected_certs_set (session, NULL, 0, NULL, 0);
601 } 601 }
602 602
603 result = 0; 603 result = 0;
@@ -613,7 +613,7 @@ cleanup:
613 */ 613 */
614 614
615int 615int
616_gnutls_gen_x509_crt (gnutls_session_t session, opaque ** data) 616_gnutls_gen_x509_crt (mhd_gtls_session_t session, opaque ** data)
617{ 617{
618 int ret, i; 618 int ret, i;
619 opaque *pdata; 619 opaque *pdata;
@@ -624,7 +624,7 @@ _gnutls_gen_x509_crt (gnutls_session_t session, opaque ** data)
624 /* find the appropriate certificate 624 /* find the appropriate certificate
625 */ 625 */
626 if ((ret = 626 if ((ret =
627 _gnutls_get_selected_cert (session, &apr_cert_list, 627 mhd_gtls_get_selected_cert (session, &apr_cert_list,
628 &apr_cert_list_length, &apr_pkey)) < 0) 628 &apr_cert_list_length, &apr_pkey)) < 0)
629 { 629 {
630 gnutls_assert (); 630 gnutls_assert ();
@@ -656,11 +656,11 @@ _gnutls_gen_x509_crt (gnutls_session_t session, opaque ** data)
656 gnutls_assert (); 656 gnutls_assert ();
657 return GNUTLS_E_MEMORY_ERROR; 657 return GNUTLS_E_MEMORY_ERROR;
658 } 658 }
659 _gnutls_write_uint24 (ret - 3, pdata); 659 mhd_gtls_write_uint24 (ret - 3, pdata);
660 pdata += 3; 660 pdata += 3;
661 for (i = 0; i < apr_cert_list_length; i++) 661 for (i = 0; i < apr_cert_list_length; i++)
662 { 662 {
663 _gnutls_write_datum24 (pdata, apr_cert_list[i].raw); 663 mhd_gtls_write_datum24 (pdata, apr_cert_list[i].raw);
664 pdata += (3 + apr_cert_list[i].raw.size); 664 pdata += (3 + apr_cert_list[i].raw.size);
665 } 665 }
666 666
@@ -671,7 +671,7 @@ enum PGPKeyDescriptorType
671{ PGP_KEY_FINGERPRINT, PGP_KEY }; 671{ PGP_KEY_FINGERPRINT, PGP_KEY };
672 672
673int 673int
674_gnutls_gen_openpgp_certificate (gnutls_session_t session, opaque ** data) 674_gnutls_gen_openpgp_certificate (mhd_gtls_session_t session, opaque ** data)
675{ 675{
676 int ret; 676 int ret;
677 opaque *pdata; 677 opaque *pdata;
@@ -681,7 +681,7 @@ _gnutls_gen_openpgp_certificate (gnutls_session_t session, opaque ** data)
681 681
682 /* find the appropriate certificate */ 682 /* find the appropriate certificate */
683 if ((ret = 683 if ((ret =
684 _gnutls_get_selected_cert (session, &apr_cert_list, 684 mhd_gtls_get_selected_cert (session, &apr_cert_list,
685 &apr_cert_list_length, &apr_pkey)) < 0) 685 &apr_cert_list_length, &apr_pkey)) < 0)
686 { 686 {
687 gnutls_assert (); 687 gnutls_assert ();
@@ -702,7 +702,7 @@ _gnutls_gen_openpgp_certificate (gnutls_session_t session, opaque ** data)
702 return GNUTLS_E_MEMORY_ERROR; 702 return GNUTLS_E_MEMORY_ERROR;
703 } 703 }
704 704
705 _gnutls_write_uint24 (ret - 3, pdata); 705 mhd_gtls_write_uint24 (ret - 3, pdata);
706 pdata += 3; 706 pdata += 3;
707 707
708 *pdata = PGP_KEY; /* whole key */ 708 *pdata = PGP_KEY; /* whole key */
@@ -710,17 +710,17 @@ _gnutls_gen_openpgp_certificate (gnutls_session_t session, opaque ** data)
710 710
711 if (apr_cert_list_length > 0) 711 if (apr_cert_list_length > 0)
712 { 712 {
713 _gnutls_write_datum24 (pdata, apr_cert_list[0].raw); 713 mhd_gtls_write_datum24 (pdata, apr_cert_list[0].raw);
714 pdata += (3 + apr_cert_list[0].raw.size); 714 pdata += (3 + apr_cert_list[0].raw.size);
715 } 715 }
716 else /* empty - no certificate */ 716 else /* empty - no certificate */
717 _gnutls_write_uint24 (0, pdata); 717 mhd_gtls_write_uint24 (0, pdata);
718 718
719 return ret; 719 return ret;
720} 720}
721 721
722int 722int
723_gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session, opaque ** data) 723_gnutls_gen_openpgp_certificate_fpr (mhd_gtls_session_t session, opaque ** data)
724{ 724{
725 int ret, packet_size; 725 int ret, packet_size;
726 size_t fpr_size; 726 size_t fpr_size;
@@ -731,7 +731,7 @@ _gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session, opaque ** data)
731 731
732 /* find the appropriate certificate */ 732 /* find the appropriate certificate */
733 if ((ret = 733 if ((ret =
734 _gnutls_get_selected_cert (session, &apr_cert_list, 734 mhd_gtls_get_selected_cert (session, &apr_cert_list,
735 &apr_cert_list_length, &apr_pkey)) < 0) 735 &apr_cert_list_length, &apr_pkey)) < 0)
736 { 736 {
737 gnutls_assert (); 737 gnutls_assert ();
@@ -756,7 +756,7 @@ _gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session, opaque ** data)
756 return GNUTLS_E_MEMORY_ERROR; 756 return GNUTLS_E_MEMORY_ERROR;
757 } 757 }
758 758
759 _gnutls_write_uint24 (packet_size - 3, pdata); 759 mhd_gtls_write_uint24 (packet_size - 3, pdata);
760 pdata += 3; 760 pdata += 3;
761 761
762 *pdata = PGP_KEY_FINGERPRINT; /* key fingerprint */ 762 *pdata = PGP_KEY_FINGERPRINT; /* key fingerprint */
@@ -787,12 +787,12 @@ _gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session, opaque ** data)
787 787
788 788
789int 789int
790_gnutls_gen_cert_client_certificate (gnutls_session_t session, opaque ** data) 790mhd_gtls_gen_cert_client_certificate (mhd_gtls_session_t session, opaque ** data)
791{ 791{
792 switch (session->security_parameters.cert_type) 792 switch (session->security_parameters.cert_type)
793 { 793 {
794 case MHD_GNUTLS_CRT_OPENPGP: 794 case MHD_GNUTLS_CRT_OPENPGP:
795 if (_gnutls_openpgp_send_fingerprint (session) == 0) 795 if (mhd_gtls_openpgp_send_fingerprint (session) == 0)
796 return _gnutls_gen_openpgp_certificate (session, data); 796 return _gnutls_gen_openpgp_certificate (session, data);
797 else 797 else
798 return _gnutls_gen_openpgp_certificate_fpr (session, data); 798 return _gnutls_gen_openpgp_certificate_fpr (session, data);
@@ -807,7 +807,7 @@ _gnutls_gen_cert_client_certificate (gnutls_session_t session, opaque ** data)
807} 807}
808 808
809int 809int
810_gnutls_gen_cert_server_certificate (gnutls_session_t session, opaque ** data) 810mhd_gtls_gen_cert_server_certificate (mhd_gtls_session_t session, opaque ** data)
811{ 811{
812 switch (session->security_parameters.cert_type) 812 switch (session->security_parameters.cert_type)
813 { 813 {
@@ -824,23 +824,23 @@ _gnutls_gen_cert_server_certificate (gnutls_session_t session, opaque ** data)
824/* Process server certificate 824/* Process server certificate
825 */ 825 */
826 826
827#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) _gnutls_gcert_deinit(&peer_certificate_list[x]) 827#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) mhd_gtls_gcert_deinit(&peer_certificate_list[x])
828int 828int
829_gnutls_proc_x509_server_certificate (gnutls_session_t session, 829_gnutls_proc_x509_server_certificate (mhd_gtls_session_t session,
830 opaque * data, size_t data_size) 830 opaque * data, size_t data_size)
831{ 831{
832 int size, len, ret; 832 int size, len, ret;
833 opaque *p = data; 833 opaque *p = data;
834 cert_auth_info_t info; 834 cert_auth_info_t info;
835 gnutls_certificate_credentials_t cred; 835 mhd_gtls_cert_credentials_t cred;
836 ssize_t dsize = data_size; 836 ssize_t dsize = data_size;
837 int i, j, x; 837 int i, j, x;
838 gnutls_cert *peer_certificate_list; 838 gnutls_cert *peer_certificate_list;
839 int peer_certificate_list_size = 0; 839 int peer_certificate_list_size = 0;
840 gnutls_datum_t tmp; 840 gnutls_datum_t tmp;
841 841
842 cred = (gnutls_certificate_credentials_t) 842 cred = (mhd_gtls_cert_credentials_t)
843 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 843 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
844 if (cred == NULL) 844 if (cred == NULL)
845 { 845 {
846 gnutls_assert (); 846 gnutls_assert ();
@@ -849,14 +849,14 @@ _gnutls_proc_x509_server_certificate (gnutls_session_t session,
849 849
850 850
851 if ((ret = 851 if ((ret =
852 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 852 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
853 sizeof (cert_auth_info_st), 1)) < 0) 853 sizeof (cert_auth_info_st), 1)) < 0)
854 { 854 {
855 gnutls_assert (); 855 gnutls_assert ();
856 return ret; 856 return ret;
857 } 857 }
858 858
859 info = _gnutls_get_auth_info (session); 859 info = mhd_gtls_get_auth_info (session);
860 860
861 if (data == NULL || data_size == 0) 861 if (data == NULL || data_size == 0)
862 { 862 {
@@ -866,7 +866,7 @@ _gnutls_proc_x509_server_certificate (gnutls_session_t session,
866 } 866 }
867 867
868 DECR_LEN (dsize, 3); 868 DECR_LEN (dsize, 3);
869 size = _gnutls_read_uint24 (p); 869 size = mhd_gtls_read_uint24 (p);
870 p += 3; 870 p += 3;
871 871
872 /* some implementations send 0B 00 00 06 00 00 03 00 00 00 872 /* some implementations send 0B 00 00 06 00 00 03 00 00 00
@@ -883,7 +883,7 @@ _gnutls_proc_x509_server_certificate (gnutls_session_t session,
883 while (i > 0) 883 while (i > 0)
884 { 884 {
885 DECR_LEN (dsize, 3); 885 DECR_LEN (dsize, 3);
886 len = _gnutls_read_uint24 (p); 886 len = mhd_gtls_read_uint24 (p);
887 p += 3; 887 p += 3;
888 DECR_LEN (dsize, len); 888 DECR_LEN (dsize, len);
889 peer_certificate_list_size++; 889 peer_certificate_list_size++;
@@ -921,14 +921,14 @@ _gnutls_proc_x509_server_certificate (gnutls_session_t session,
921 921
922 for (j = 0; j < peer_certificate_list_size; j++) 922 for (j = 0; j < peer_certificate_list_size; j++)
923 { 923 {
924 len = _gnutls_read_uint24 (p); 924 len = mhd_gtls_read_uint24 (p);
925 p += 3; 925 p += 3;
926 926
927 tmp.size = len; 927 tmp.size = len;
928 tmp.data = p; 928 tmp.data = p;
929 929
930 if ((ret = 930 if ((ret =
931 _gnutls_x509_raw_cert_to_gcert (&peer_certificate_list 931 mhd_gtls_x509_raw_cert_to_gcert (&peer_certificate_list
932 [j], &tmp, 932 [j], &tmp,
933 CERT_ONLY_EXTENSIONS)) < 0) 933 CERT_ONLY_EXTENSIONS)) < 0)
934 { 934 {
@@ -966,23 +966,23 @@ cleanup:
966 966
967} 967}
968 968
969#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) _gnutls_gcert_deinit(&peer_certificate_list[x]) 969#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) mhd_gtls_gcert_deinit(&peer_certificate_list[x])
970int 970int
971_gnutls_proc_openpgp_server_certificate (gnutls_session_t session, 971_gnutls_proc_openpgp_server_certificate (mhd_gtls_session_t session,
972 opaque * data, size_t data_size) 972 opaque * data, size_t data_size)
973{ 973{
974 int size, ret, len; 974 int size, ret, len;
975 opaque *p = data; 975 opaque *p = data;
976 cert_auth_info_t info; 976 cert_auth_info_t info;
977 gnutls_certificate_credentials_t cred; 977 mhd_gtls_cert_credentials_t cred;
978 ssize_t dsize = data_size; 978 ssize_t dsize = data_size;
979 int i, x; 979 int i, x;
980 gnutls_cert *peer_certificate_list = NULL; 980 gnutls_cert *peer_certificate_list = NULL;
981 int peer_certificate_list_size = 0; 981 int peer_certificate_list_size = 0;
982 gnutls_datum_t tmp, akey = { NULL, 0 }; 982 gnutls_datum_t tmp, akey = { NULL, 0 };
983 983
984 cred = (gnutls_certificate_credentials_t) 984 cred = (mhd_gtls_cert_credentials_t)
985 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 985 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
986 if (cred == NULL) 986 if (cred == NULL)
987 { 987 {
988 gnutls_assert (); 988 gnutls_assert ();
@@ -990,14 +990,14 @@ _gnutls_proc_openpgp_server_certificate (gnutls_session_t session,
990 } 990 }
991 991
992 if ((ret = 992 if ((ret =
993 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 993 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
994 sizeof (cert_auth_info_st), 1)) < 0) 994 sizeof (cert_auth_info_st), 1)) < 0)
995 { 995 {
996 gnutls_assert (); 996 gnutls_assert ();
997 return ret; 997 return ret;
998 } 998 }
999 999
1000 info = _gnutls_get_auth_info (session); 1000 info = mhd_gtls_get_auth_info (session);
1001 1001
1002 if (data == NULL || data_size == 0) 1002 if (data == NULL || data_size == 0)
1003 { 1003 {
@@ -1006,7 +1006,7 @@ _gnutls_proc_openpgp_server_certificate (gnutls_session_t session,
1006 } 1006 }
1007 1007
1008 DECR_LEN (dsize, 3); 1008 DECR_LEN (dsize, 3);
1009 size = _gnutls_read_uint24 (p); 1009 size = mhd_gtls_read_uint24 (p);
1010 p += 3; 1010 p += 3;
1011 1011
1012 if (size == 0) 1012 if (size == 0)
@@ -1060,7 +1060,7 @@ _gnutls_proc_openpgp_server_certificate (gnutls_session_t session,
1060 1060
1061 /* Read the actual certificate */ 1061 /* Read the actual certificate */
1062 DECR_LEN (dsize, 3); 1062 DECR_LEN (dsize, 3);
1063 len = _gnutls_read_uint24 (p); 1063 len = mhd_gtls_read_uint24 (p);
1064 p += 3; 1064 p += 3;
1065 1065
1066 if (len == 0) 1066 if (len == 0)
@@ -1147,7 +1147,7 @@ cleanup:
1147} 1147}
1148 1148
1149int 1149int
1150_gnutls_proc_cert_server_certificate (gnutls_session_t session, 1150mhd_gtls_proc_cert_server_certificate (mhd_gtls_session_t session,
1151 opaque * data, size_t data_size) 1151 opaque * data, size_t data_size)
1152{ 1152{
1153 switch (session->security_parameters.cert_type) 1153 switch (session->security_parameters.cert_type)
@@ -1185,21 +1185,21 @@ _gnutls_check_supported_sign_algo (CertificateSigType algo)
1185} 1185}
1186 1186
1187int 1187int
1188_gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data, 1188mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data,
1189 size_t data_size) 1189 size_t data_size)
1190{ 1190{
1191 int size, ret; 1191 int size, ret;
1192 opaque *p; 1192 opaque *p;
1193 gnutls_certificate_credentials_t cred; 1193 mhd_gtls_cert_credentials_t cred;
1194 cert_auth_info_t info; 1194 cert_auth_info_t info;
1195 ssize_t dsize; 1195 ssize_t dsize;
1196 int i, j; 1196 int i, j;
1197 gnutls_pk_algorithm_t pk_algos[MAX_SIGN_ALGOS]; 1197 gnutls_pk_algorithm_t pk_algos[MAX_SIGN_ALGOS];
1198 int pk_algos_length; 1198 int pk_algos_length;
1199 gnutls_protocol_t ver = gnutls_protocol_get_version (session); 1199 gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
1200 1200
1201 cred = (gnutls_certificate_credentials_t) 1201 cred = (mhd_gtls_cert_credentials_t)
1202 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 1202 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
1203 if (cred == NULL) 1203 if (cred == NULL)
1204 { 1204 {
1205 gnutls_assert (); 1205 gnutls_assert ();
@@ -1207,14 +1207,14 @@ _gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data,
1207 } 1207 }
1208 1208
1209 if ((ret = 1209 if ((ret =
1210 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 1210 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
1211 sizeof (cert_auth_info_st), 0)) < 0) 1211 sizeof (cert_auth_info_st), 0)) < 0)
1212 { 1212 {
1213 gnutls_assert (); 1213 gnutls_assert ();
1214 return ret; 1214 return ret;
1215 } 1215 }
1216 1216
1217 info = _gnutls_get_auth_info (session); 1217 info = mhd_gtls_get_auth_info (session);
1218 1218
1219 p = data; 1219 p = data;
1220 dsize = data_size; 1220 dsize = data_size;
@@ -1259,7 +1259,7 @@ _gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data,
1259 1259
1260 /* read the certificate authorities */ 1260 /* read the certificate authorities */
1261 DECR_LEN (dsize, 2); 1261 DECR_LEN (dsize, 2);
1262 size = _gnutls_read_uint16 (p); 1262 size = mhd_gtls_read_uint16 (p);
1263 p += 2; 1263 p += 2;
1264 1264
1265 if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_OPENPGP 1265 if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_OPENPGP
@@ -1290,7 +1290,7 @@ _gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data,
1290} 1290}
1291 1291
1292int 1292int
1293_gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data) 1293mhd_gtls_gen_cert_client_cert_vrfy (mhd_gtls_session_t session, opaque ** data)
1294{ 1294{
1295 int ret; 1295 int ret;
1296 gnutls_cert *apr_cert_list; 1296 gnutls_cert *apr_cert_list;
@@ -1302,7 +1302,7 @@ _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
1302 1302
1303 /* find the appropriate certificate */ 1303 /* find the appropriate certificate */
1304 if ((ret = 1304 if ((ret =
1305 _gnutls_get_selected_cert (session, &apr_cert_list, 1305 mhd_gtls_get_selected_cert (session, &apr_cert_list,
1306 &apr_cert_list_length, &apr_pkey)) < 0) 1306 &apr_cert_list_length, &apr_pkey)) < 0)
1307 { 1307 {
1308 gnutls_assert (); 1308 gnutls_assert ();
@@ -1312,7 +1312,7 @@ _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
1312 if (apr_cert_list_length > 0) 1312 if (apr_cert_list_length > 0)
1313 { 1313 {
1314 if ((ret = 1314 if ((ret =
1315 _gnutls_tls_sign_hdata (session, 1315 mhd_gtls_tls_sign_hdata (session,
1316 &apr_cert_list[0], 1316 &apr_cert_list[0],
1317 apr_pkey, &signature)) < 0) 1317 apr_pkey, &signature)) < 0)
1318 { 1318 {
@@ -1332,7 +1332,7 @@ _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
1332 return GNUTLS_E_MEMORY_ERROR; 1332 return GNUTLS_E_MEMORY_ERROR;
1333 } 1333 }
1334 size = signature.size; 1334 size = signature.size;
1335 _gnutls_write_uint16 (size, *data); 1335 mhd_gtls_write_uint16 (size, *data);
1336 1336
1337 memcpy (&(*data)[2], signature.data, size); 1337 memcpy (&(*data)[2], signature.data, size);
1338 1338
@@ -1342,14 +1342,14 @@ _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t session, opaque ** data)
1342} 1342}
1343 1343
1344int 1344int
1345_gnutls_proc_cert_client_cert_vrfy (gnutls_session_t session, 1345mhd_gtls_proc_cert_client_cert_vrfy (mhd_gtls_session_t session,
1346 opaque * data, size_t data_size) 1346 opaque * data, size_t data_size)
1347{ 1347{
1348 int size, ret; 1348 int size, ret;
1349 ssize_t dsize = data_size; 1349 ssize_t dsize = data_size;
1350 opaque *pdata = data; 1350 opaque *pdata = data;
1351 gnutls_datum_t sig; 1351 gnutls_datum_t sig;
1352 cert_auth_info_t info = _gnutls_get_auth_info (session); 1352 cert_auth_info_t info = mhd_gtls_get_auth_info (session);
1353 gnutls_cert peer_cert; 1353 gnutls_cert peer_cert;
1354 1354
1355 if (info == NULL || info->ncerts == 0) 1355 if (info == NULL || info->ncerts == 0)
@@ -1360,7 +1360,7 @@ _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t session,
1360 } 1360 }
1361 1361
1362 DECR_LEN (dsize, 2); 1362 DECR_LEN (dsize, 2);
1363 size = _gnutls_read_uint16 (pdata); 1363 size = mhd_gtls_read_uint16 (pdata);
1364 pdata += 2; 1364 pdata += 2;
1365 1365
1366 DECR_LEN (dsize, size); 1366 DECR_LEN (dsize, size);
@@ -1368,7 +1368,7 @@ _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t session,
1368 sig.data = pdata; 1368 sig.data = pdata;
1369 sig.size = size; 1369 sig.size = size;
1370 1370
1371 ret = _gnutls_raw_cert_to_gcert (&peer_cert, 1371 ret = mhd_gtls_raw_cert_to_gcert (&peer_cert,
1372 session->security_parameters.cert_type, 1372 session->security_parameters.cert_type,
1373 &info->raw_certificate_list[0], 1373 &info->raw_certificate_list[0],
1374 CERT_NO_COPY); 1374 CERT_NO_COPY);
@@ -1379,33 +1379,33 @@ _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t session,
1379 return ret; 1379 return ret;
1380 } 1380 }
1381 1381
1382 if ((ret = _gnutls_verify_sig_hdata (session, &peer_cert, &sig)) < 0) 1382 if ((ret = mhd_gtls_verify_sig_hdata (session, &peer_cert, &sig)) < 0)
1383 { 1383 {
1384 gnutls_assert (); 1384 gnutls_assert ();
1385 _gnutls_gcert_deinit (&peer_cert); 1385 mhd_gtls_gcert_deinit (&peer_cert);
1386 return ret; 1386 return ret;
1387 } 1387 }
1388 _gnutls_gcert_deinit (&peer_cert); 1388 mhd_gtls_gcert_deinit (&peer_cert);
1389 1389
1390 return 0; 1390 return 0;
1391} 1391}
1392 1392
1393#define CERTTYPE_SIZE 3 1393#define CERTTYPE_SIZE 3
1394int 1394int
1395_gnutls_gen_cert_server_cert_req (gnutls_session_t session, opaque ** data) 1395mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t session, opaque ** data)
1396{ 1396{
1397 gnutls_certificate_credentials_t cred; 1397 mhd_gtls_cert_credentials_t cred;
1398 int size; 1398 int size;
1399 opaque *pdata; 1399 opaque *pdata;
1400 gnutls_protocol_t ver = gnutls_protocol_get_version (session); 1400 gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
1401 1401
1402 /* Now we need to generate the RDN sequence. This is 1402 /* Now we need to generate the RDN sequence. This is
1403 * already in the CERTIFICATE_CRED structure, to improve 1403 * already in the CERTIFICATE_CRED structure, to improve
1404 * performance. 1404 * performance.
1405 */ 1405 */
1406 1406
1407 cred = (gnutls_certificate_credentials_t) 1407 cred = (mhd_gtls_cert_credentials_t)
1408 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 1408 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
1409 if (cred == NULL) 1409 if (cred == NULL)
1410 { 1410 {
1411 gnutls_assert (); 1411 gnutls_assert ();
@@ -1449,12 +1449,12 @@ _gnutls_gen_cert_server_cert_req (gnutls_session_t session, opaque ** data)
1449 if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_X509 && 1449 if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_X509 &&
1450 session->internals.ignore_rdn_sequence == 0) 1450 session->internals.ignore_rdn_sequence == 0)
1451 { 1451 {
1452 _gnutls_write_datum16 (pdata, cred->x509_rdn_sequence); 1452 mhd_gtls_write_datum16 (pdata, cred->x509_rdn_sequence);
1453 /* pdata += cred->x509_rdn_sequence.size + 2; */ 1453 /* pdata += cred->x509_rdn_sequence.size + 2; */
1454 } 1454 }
1455 else 1455 else
1456 { 1456 {
1457 _gnutls_write_uint16 (0, pdata); 1457 mhd_gtls_write_uint16 (0, pdata);
1458 /* pdata+=2; */ 1458 /* pdata+=2; */
1459 } 1459 }
1460 1460
@@ -1470,7 +1470,7 @@ _gnutls_gen_cert_server_cert_req (gnutls_session_t session, opaque ** data)
1470 * 1470 *
1471 */ 1471 */
1472int 1472int
1473_gnutls_get_selected_cert (gnutls_session_t session, 1473mhd_gtls_get_selected_cert (mhd_gtls_session_t session,
1474 gnutls_cert ** apr_cert_list, 1474 gnutls_cert ** apr_cert_list,
1475 int *apr_cert_list_length, 1475 int *apr_cert_list_length,
1476 gnutls_privkey ** apr_pkey) 1476 gnutls_privkey ** apr_pkey)
@@ -1530,7 +1530,7 @@ alloc_and_load_x509_certs (gnutls_x509_crt_t * certs, unsigned ncerts)
1530 1530
1531 for (i = 0; i < ncerts; i++) 1531 for (i = 0; i < ncerts; i++)
1532 { 1532 {
1533 ret = _gnutls_x509_crt_to_gcert (&local_certs[i], certs[i], 0); 1533 ret = mhd_gtls_x509_crt_to_gcert (&local_certs[i], certs[i], 0);
1534 if (ret < 0) 1534 if (ret < 0)
1535 break; 1535 break;
1536 } 1536 }
@@ -1540,7 +1540,7 @@ alloc_and_load_x509_certs (gnutls_x509_crt_t * certs, unsigned ncerts)
1540 gnutls_assert (); 1540 gnutls_assert ();
1541 for (j = 0; j < i; j++) 1541 for (j = 0; j < i; j++)
1542 { 1542 {
1543 _gnutls_gcert_deinit (&local_certs[j]); 1543 mhd_gtls_gcert_deinit (&local_certs[j]);
1544 } 1544 }
1545 gnutls_free (local_certs); 1545 gnutls_free (local_certs);
1546 return NULL; 1546 return NULL;
@@ -1613,7 +1613,7 @@ alloc_and_load_pgp_certs (gnutls_openpgp_crt_t cert)
1613 if (ret < 0) 1613 if (ret < 0)
1614 { 1614 {
1615 gnutls_assert (); 1615 gnutls_assert ();
1616 _gnutls_gcert_deinit (local_certs); 1616 mhd_gtls_gcert_deinit (local_certs);
1617 gnutls_free (local_certs); 1617 gnutls_free (local_certs);
1618 return NULL; 1618 return NULL;
1619 } 1619 }
@@ -1658,7 +1658,7 @@ alloc_and_load_pgp_key (const gnutls_openpgp_privkey_t key)
1658 1658
1659 1659
1660void 1660void
1661_gnutls_selected_certs_deinit (gnutls_session_t session) 1661mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session)
1662{ 1662{
1663 if (session->internals.selected_need_free != 0) 1663 if (session->internals.selected_need_free != 0)
1664 { 1664 {
@@ -1666,13 +1666,13 @@ _gnutls_selected_certs_deinit (gnutls_session_t session)
1666 1666
1667 for (i = 0; i < session->internals.selected_cert_list_length; i++) 1667 for (i = 0; i < session->internals.selected_cert_list_length; i++)
1668 { 1668 {
1669 _gnutls_gcert_deinit (&session->internals.selected_cert_list[i]); 1669 mhd_gtls_gcert_deinit (&session->internals.selected_cert_list[i]);
1670 } 1670 }
1671 gnutls_free (session->internals.selected_cert_list); 1671 gnutls_free (session->internals.selected_cert_list);
1672 session->internals.selected_cert_list = NULL; 1672 session->internals.selected_cert_list = NULL;
1673 session->internals.selected_cert_list_length = 0; 1673 session->internals.selected_cert_list_length = 0;
1674 1674
1675 _gnutls_gkey_deinit (session->internals.selected_key); 1675 mhd_gtls_gkey_deinit (session->internals.selected_key);
1676 if (session->internals.selected_key) 1676 if (session->internals.selected_key)
1677 { 1677 {
1678 gnutls_free (session->internals.selected_key); 1678 gnutls_free (session->internals.selected_key);
@@ -1684,11 +1684,11 @@ _gnutls_selected_certs_deinit (gnutls_session_t session)
1684} 1684}
1685 1685
1686void 1686void
1687_gnutls_selected_certs_set (gnutls_session_t session, 1687mhd_gtls_selected_certs_set (mhd_gtls_session_t session,
1688 gnutls_cert * certs, int ncerts, 1688 gnutls_cert * certs, int ncerts,
1689 gnutls_privkey * key, int need_free) 1689 gnutls_privkey * key, int need_free)
1690{ 1690{
1691 _gnutls_selected_certs_deinit (session); 1691 mhd_gtls_selected_certs_deinit (session);
1692 1692
1693 session->internals.selected_cert_list = certs; 1693 session->internals.selected_cert_list = certs;
1694 session->internals.selected_cert_list_length = ncerts; 1694 session->internals.selected_cert_list_length = ncerts;
@@ -1709,15 +1709,15 @@ _gnutls_selected_certs_set (gnutls_session_t session,
1709 * 1709 *
1710 */ 1710 */
1711int 1711int
1712_gnutls_server_select_cert (gnutls_session_t session, 1712mhd_gtls_server_select_cert (mhd_gtls_session_t session,
1713 gnutls_pk_algorithm_t requested_algo) 1713 gnutls_pk_algorithm_t requested_algo)
1714{ 1714{
1715 unsigned i; 1715 unsigned i;
1716 int idx, ret; 1716 int idx, ret;
1717 gnutls_certificate_credentials_t cred; 1717 mhd_gtls_cert_credentials_t cred;
1718 1718
1719 cred = (gnutls_certificate_credentials_t) 1719 cred = (mhd_gtls_cert_credentials_t)
1720 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 1720 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
1721 if (cred == NULL) 1721 if (cred == NULL)
1722 { 1722 {
1723 gnutls_assert (); 1723 gnutls_assert ();
@@ -1759,7 +1759,7 @@ _gnutls_server_select_cert (gnutls_session_t session,
1759 */ 1759 */
1760 if (idx >= 0 && ret == 0) 1760 if (idx >= 0 && ret == 0)
1761 { 1761 {
1762 _gnutls_selected_certs_set (session, 1762 mhd_gtls_selected_certs_set (session,
1763 &cred->cert_list[idx][0], 1763 &cred->cert_list[idx][0],
1764 cred->cert_list_length[idx], 1764 cred->cert_list_length[idx],
1765 &cred->pkey[idx], 0); 1765 &cred->pkey[idx], 0);
@@ -1771,10 +1771,10 @@ _gnutls_server_select_cert (gnutls_session_t session,
1771 return ret; 1771 return ret;
1772} 1772}
1773 1773
1774/* Frees the rsa_info_st structure. 1774/* Frees the mhd_gtls_rsa_info_st structure.
1775 */ 1775 */
1776void 1776void
1777_gnutls_free_rsa_info (rsa_info_st * rsa) 1777mhd_gtls_free_rsa_info (rsa_info_st * rsa)
1778{ 1778{
1779 _gnutls_free_datum (&rsa->modulus); 1779 _gnutls_free_datum (&rsa->modulus);
1780 _gnutls_free_datum (&rsa->exponent); 1780 _gnutls_free_datum (&rsa->exponent);
diff --git a/src/daemon/https/tls/auth_cert.h b/src/daemon/https/tls/auth_cert.h
index e49a6089..979a698a 100644
--- a/src/daemon/https/tls/auth_cert.h
+++ b/src/daemon/https/tls/auth_cert.h
@@ -35,10 +35,10 @@
35 * support a server that has multiple certificates 35 * support a server that has multiple certificates
36 */ 36 */
37 37
38typedef struct gnutls_certificate_credentials_st 38typedef struct mhd_gtls_certificate_credentials_st
39{ 39{
40 gnutls_dh_params_t dh_params; 40 mhd_gtls_dh_params_t dh_params;
41 gnutls_rsa_params_t rsa_params; 41 mhd_gtls_rsa_params_t rsa_params;
42 /* this callback is used to retrieve the DH or RSA 42 /* this callback is used to retrieve the DH or RSA
43 * parameters. 43 * parameters.
44 */ 44 */
@@ -100,13 +100,13 @@ typedef struct gnutls_certificate_credentials_st
100 gnutls_certificate_server_retrieve_function *server_get_cert_callback; 100 gnutls_certificate_server_retrieve_function *server_get_cert_callback;
101} certificate_credentials_st; 101} certificate_credentials_st;
102 102
103typedef struct rsa_info_st 103typedef struct mhd_gtls_rsa_info_st
104{ 104{
105 gnutls_datum_t modulus; 105 gnutls_datum_t modulus;
106 gnutls_datum_t exponent; 106 gnutls_datum_t exponent;
107} rsa_info_st; 107} rsa_info_st;
108 108
109typedef struct cert_auth_info_st 109typedef struct mhd_gtls_cert_auth_info_st
110{ 110{
111 int certificate_requested; /* if the peer requested certificate 111 int certificate_requested; /* if the peer requested certificate
112 * this is non zero; 112 * this is non zero;
@@ -124,36 +124,36 @@ typedef struct cert_auth_info_st
124 unsigned int ncerts; /* holds the size of the list above */ 124 unsigned int ncerts; /* holds the size of the list above */
125} *cert_auth_info_t; 125} *cert_auth_info_t;
126 126
127typedef struct cert_auth_info_st cert_auth_info_st; 127typedef struct mhd_gtls_cert_auth_info_st cert_auth_info_st;
128 128
129void _gnutls_free_rsa_info (rsa_info_st * rsa); 129void mhd_gtls_free_rsa_info (rsa_info_st * rsa);
130 130
131/* AUTH X509 functions */ 131/* AUTH X509 functions */
132int _gnutls_gen_cert_server_certificate (gnutls_session_t, opaque **); 132int mhd_gtls_gen_cert_server_certificate (mhd_gtls_session_t, opaque **);
133int _gnutls_gen_cert_client_certificate (gnutls_session_t, opaque **); 133int mhd_gtls_gen_cert_client_certificate (mhd_gtls_session_t, opaque **);
134int _gnutls_gen_cert_client_cert_vrfy (gnutls_session_t, opaque **); 134int mhd_gtls_gen_cert_client_cert_vrfy (mhd_gtls_session_t, opaque **);
135int _gnutls_gen_cert_server_cert_req (gnutls_session_t, opaque **); 135int mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t, opaque **);
136int _gnutls_proc_cert_cert_req (gnutls_session_t, opaque *, size_t); 136int mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t, opaque *, size_t);
137int _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t, opaque *, size_t); 137int mhd_gtls_proc_cert_client_cert_vrfy (mhd_gtls_session_t, opaque *, size_t);
138int _gnutls_proc_cert_server_certificate (gnutls_session_t, opaque *, size_t); 138int mhd_gtls_proc_cert_server_certificate (mhd_gtls_session_t, opaque *, size_t);
139int _gnutls_get_selected_cert (gnutls_session_t session, 139int mhd_gtls_get_selected_cert (mhd_gtls_session_t session,
140 gnutls_cert ** apr_cert_list, 140 gnutls_cert ** apr_cert_list,
141 int *apr_cert_list_length, 141 int *apr_cert_list_length,
142 gnutls_privkey ** apr_pkey); 142 gnutls_privkey ** apr_pkey);
143 143
144int _gnutls_server_select_cert (struct gnutls_session_int *, 144int mhd_gtls_server_select_cert (struct MHD_gtls_session_int *,
145 gnutls_pk_algorithm_t); 145 gnutls_pk_algorithm_t);
146void _gnutls_selected_certs_deinit (gnutls_session_t session); 146void mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session);
147void _gnutls_selected_certs_set (gnutls_session_t session, 147void mhd_gtls_selected_certs_set (mhd_gtls_session_t session,
148 gnutls_cert * certs, int ncerts, 148 gnutls_cert * certs, int ncerts,
149 gnutls_privkey * key, int need_free); 149 gnutls_privkey * key, int need_free);
150 150
151#define _gnutls_proc_cert_client_certificate _gnutls_proc_cert_server_certificate 151#define _gnutls_proc_cert_client_certificate mhd_gtls_proc_cert_server_certificate
152 152
153gnutls_rsa_params_t _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t 153mhd_gtls_rsa_params_t mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t
154 rsa_params, 154 rsa_params,
155 gnutls_params_function 155 gnutls_params_function
156 * func, 156 * func,
157 gnutls_session_t); 157 mhd_gtls_session_t);
158 158
159#endif 159#endif
diff --git a/src/daemon/https/tls/auth_dh_common.c b/src/daemon/https/tls/auth_dh_common.c
index f6354cb6..13e7987b 100644
--- a/src/daemon/https/tls/auth_dh_common.c
+++ b/src/daemon/https/tls/auth_dh_common.c
@@ -42,7 +42,7 @@
42/* Frees the dh_info_st structure. 42/* Frees the dh_info_st structure.
43 */ 43 */
44void 44void
45_gnutls_free_dh_info (dh_info_st * dh) 45mhd_gtls_free_dh_info (dh_info_st * dh)
46{ 46{
47 dh->secret_bits = 0; 47 dh->secret_bits = 0;
48 _gnutls_free_datum (&dh->prime); 48 _gnutls_free_datum (&dh->prime);
@@ -51,7 +51,7 @@ _gnutls_free_dh_info (dh_info_st * dh)
51} 51}
52 52
53int 53int
54_gnutls_proc_dh_common_client_kx (gnutls_session_t session, 54mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
55 opaque * data, size_t _data_size, 55 opaque * data, size_t _data_size,
56 mpi_t g, mpi_t p) 56 mpi_t g, mpi_t p)
57{ 57{
@@ -62,20 +62,20 @@ _gnutls_proc_dh_common_client_kx (gnutls_session_t session,
62 62
63 63
64 DECR_LEN (data_size, 2); 64 DECR_LEN (data_size, 2);
65 n_Y = _gnutls_read_uint16 (&data[0]); 65 n_Y = mhd_gtls_read_uint16 (&data[0]);
66 _n_Y = n_Y; 66 _n_Y = n_Y;
67 67
68 DECR_LEN (data_size, n_Y); 68 DECR_LEN (data_size, n_Y);
69 if (_gnutls_mpi_scan_nz (&session->key->client_Y, &data[2], &_n_Y)) 69 if (mhd_gtls_mpi_scan_nz (&session->key->client_Y, &data[2], &_n_Y))
70 { 70 {
71 gnutls_assert (); 71 gnutls_assert ();
72 return GNUTLS_E_MPI_SCAN_FAILED; 72 return GNUTLS_E_MPI_SCAN_FAILED;
73 } 73 }
74 74
75 _gnutls_dh_set_peer_public (session, session->key->client_Y); 75 mhd_gtls_dh_set_peer_public (session, session->key->client_Y);
76 76
77 session->key->KEY = 77 session->key->KEY =
78 gnutls_calc_dh_key (session->key->client_Y, session->key->dh_secret, p); 78 mhd_gtls_calc_dh_key (session->key->client_Y, session->key->dh_secret, p);
79 79
80 if (session->key->KEY == NULL) 80 if (session->key->KEY == NULL)
81 { 81 {
@@ -83,12 +83,12 @@ _gnutls_proc_dh_common_client_kx (gnutls_session_t session,
83 return GNUTLS_E_MEMORY_ERROR; 83 return GNUTLS_E_MEMORY_ERROR;
84 } 84 }
85 85
86 _gnutls_mpi_release (&session->key->client_Y); 86 mhd_gtls_mpi_release (&session->key->client_Y);
87 _gnutls_mpi_release (&session->key->dh_secret); 87 mhd_gtls_mpi_release (&session->key->dh_secret);
88 88
89 ret = _gnutls_mpi_dprint (&session->key->key, session->key->KEY); 89 ret = mhd_gtls_mpi_dprint (&session->key->key, session->key->KEY);
90 90
91 _gnutls_mpi_release (&session->key->KEY); 91 mhd_gtls_mpi_release (&session->key->KEY);
92 92
93 if (ret < 0) 93 if (ret < 0)
94 { 94 {
@@ -99,7 +99,7 @@ _gnutls_proc_dh_common_client_kx (gnutls_session_t session,
99} 99}
100 100
101int 101int
102_gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data) 102mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t session, opaque ** data)
103{ 103{
104 mpi_t x = NULL, X = NULL; 104 mpi_t x = NULL, X = NULL;
105 size_t n_X; 105 size_t n_X;
@@ -107,7 +107,7 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
107 107
108 *data = NULL; 108 *data = NULL;
109 109
110 X = gnutls_calc_dh_secret (&x, session->key->client_g, 110 X = mhd_gtls_calc_dh_secret (&x, session->key->client_g,
111 session->key->client_p); 111 session->key->client_p);
112 if (X == NULL || x == NULL) 112 if (X == NULL || x == NULL)
113 { 113 {
@@ -116,9 +116,9 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
116 goto error; 116 goto error;
117 } 117 }
118 118
119 _gnutls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x)); 119 mhd_gtls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x));
120 120
121 _gnutls_mpi_print (NULL, &n_X, X); 121 mhd_gtls_mpi_print (NULL, &n_X, X);
122 (*data) = gnutls_malloc (n_X + 2); 122 (*data) = gnutls_malloc (n_X + 2);
123 if (*data == NULL) 123 if (*data == NULL)
124 { 124 {
@@ -126,16 +126,16 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
126 goto error; 126 goto error;
127 } 127 }
128 128
129 _gnutls_mpi_print (&(*data)[2], &n_X, X); 129 mhd_gtls_mpi_print (&(*data)[2], &n_X, X);
130 _gnutls_mpi_release (&X); 130 mhd_gtls_mpi_release (&X);
131 131
132 _gnutls_write_uint16 (n_X, &(*data)[0]); 132 mhd_gtls_write_uint16 (n_X, &(*data)[0]);
133 133
134 /* calculate the key after calculating the message */ 134 /* calculate the key after calculating the message */
135 session->key->KEY = 135 session->key->KEY =
136 gnutls_calc_dh_key (session->key->client_Y, x, session->key->client_p); 136 mhd_gtls_calc_dh_key (session->key->client_Y, x, session->key->client_p);
137 137
138 _gnutls_mpi_release (&x); 138 mhd_gtls_mpi_release (&x);
139 if (session->key->KEY == NULL) 139 if (session->key->KEY == NULL)
140 { 140 {
141 gnutls_assert (); 141 gnutls_assert ();
@@ -144,13 +144,13 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
144 } 144 }
145 145
146 /* THESE SHOULD BE DISCARDED */ 146 /* THESE SHOULD BE DISCARDED */
147 _gnutls_mpi_release (&session->key->client_Y); 147 mhd_gtls_mpi_release (&session->key->client_Y);
148 _gnutls_mpi_release (&session->key->client_p); 148 mhd_gtls_mpi_release (&session->key->client_p);
149 _gnutls_mpi_release (&session->key->client_g); 149 mhd_gtls_mpi_release (&session->key->client_g);
150 150
151 ret = _gnutls_mpi_dprint (&session->key->key, session->key->KEY); 151 ret = mhd_gtls_mpi_dprint (&session->key->key, session->key->KEY);
152 152
153 _gnutls_mpi_release (&session->key->KEY); 153 mhd_gtls_mpi_release (&session->key->KEY);
154 154
155 if (ret < 0) 155 if (ret < 0)
156 { 156 {
@@ -161,15 +161,15 @@ _gnutls_gen_dh_common_client_kx (gnutls_session_t session, opaque ** data)
161 return n_X + 2; 161 return n_X + 2;
162 162
163error: 163error:
164 _gnutls_mpi_release (&x); 164 mhd_gtls_mpi_release (&x);
165 _gnutls_mpi_release (&X); 165 mhd_gtls_mpi_release (&X);
166 gnutls_free (*data); 166 gnutls_free (*data);
167 *data = NULL; 167 *data = NULL;
168 return ret; 168 return ret;
169} 169}
170 170
171int 171int
172_gnutls_proc_dh_common_server_kx (gnutls_session_t session, 172mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
173 opaque * data, size_t _data_size, int psk) 173 opaque * data, size_t _data_size, int psk)
174{ 174{
175 uint16_t n_Y, n_g, n_p; 175 uint16_t n_Y, n_g, n_p;
@@ -185,13 +185,13 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
185 if (psk != 0) 185 if (psk != 0)
186 { 186 {
187 DECR_LEN (data_size, 2); 187 DECR_LEN (data_size, 2);
188 psk_size = _gnutls_read_uint16 (&data[i]); 188 psk_size = mhd_gtls_read_uint16 (&data[i]);
189 DECR_LEN (data_size, psk_size); 189 DECR_LEN (data_size, psk_size);
190 i += 2 + psk_size; 190 i += 2 + psk_size;
191 } 191 }
192 192
193 DECR_LEN (data_size, 2); 193 DECR_LEN (data_size, 2);
194 n_p = _gnutls_read_uint16 (&data[i]); 194 n_p = mhd_gtls_read_uint16 (&data[i]);
195 i += 2; 195 i += 2;
196 196
197 DECR_LEN (data_size, n_p); 197 DECR_LEN (data_size, n_p);
@@ -199,7 +199,7 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
199 i += n_p; 199 i += n_p;
200 200
201 DECR_LEN (data_size, 2); 201 DECR_LEN (data_size, 2);
202 n_g = _gnutls_read_uint16 (&data[i]); 202 n_g = mhd_gtls_read_uint16 (&data[i]);
203 i += 2; 203 i += 2;
204 204
205 DECR_LEN (data_size, n_g); 205 DECR_LEN (data_size, n_g);
@@ -207,7 +207,7 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
207 i += n_g; 207 i += n_g;
208 208
209 DECR_LEN (data_size, 2); 209 DECR_LEN (data_size, 2);
210 n_Y = _gnutls_read_uint16 (&data[i]); 210 n_Y = mhd_gtls_read_uint16 (&data[i]);
211 i += 2; 211 i += 2;
212 212
213 DECR_LEN (data_size, n_Y); 213 DECR_LEN (data_size, n_Y);
@@ -218,24 +218,24 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
218 _n_g = n_g; 218 _n_g = n_g;
219 _n_p = n_p; 219 _n_p = n_p;
220 220
221 if (_gnutls_mpi_scan_nz (&session->key->client_Y, data_Y, &_n_Y) != 0) 221 if (mhd_gtls_mpi_scan_nz (&session->key->client_Y, data_Y, &_n_Y) != 0)
222 { 222 {
223 gnutls_assert (); 223 gnutls_assert ();
224 return GNUTLS_E_MPI_SCAN_FAILED; 224 return GNUTLS_E_MPI_SCAN_FAILED;
225 } 225 }
226 226
227 if (_gnutls_mpi_scan_nz (&session->key->client_g, data_g, &_n_g) != 0) 227 if (mhd_gtls_mpi_scan_nz (&session->key->client_g, data_g, &_n_g) != 0)
228 { 228 {
229 gnutls_assert (); 229 gnutls_assert ();
230 return GNUTLS_E_MPI_SCAN_FAILED; 230 return GNUTLS_E_MPI_SCAN_FAILED;
231 } 231 }
232 if (_gnutls_mpi_scan_nz (&session->key->client_p, data_p, &_n_p) != 0) 232 if (mhd_gtls_mpi_scan_nz (&session->key->client_p, data_p, &_n_p) != 0)
233 { 233 {
234 gnutls_assert (); 234 gnutls_assert ();
235 return GNUTLS_E_MPI_SCAN_FAILED; 235 return GNUTLS_E_MPI_SCAN_FAILED;
236 } 236 }
237 237
238 bits = _gnutls_dh_get_allowed_prime_bits (session); 238 bits = mhd_gtls_dh_get_allowed_prime_bits (session);
239 if (bits < 0) 239 if (bits < 0)
240 { 240 {
241 gnutls_assert (); 241 gnutls_assert ();
@@ -250,9 +250,9 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
250 return GNUTLS_E_DH_PRIME_UNACCEPTABLE; 250 return GNUTLS_E_DH_PRIME_UNACCEPTABLE;
251 } 251 }
252 252
253 _gnutls_dh_set_group (session, session->key->client_g, 253 mhd_gtls_dh_set_group (session, session->key->client_g,
254 session->key->client_p); 254 session->key->client_p);
255 _gnutls_dh_set_peer_public (session, session->key->client_Y); 255 mhd_gtls_dh_set_peer_public (session, session->key->client_Y);
256 256
257 ret = n_Y + n_p + n_g + 6; 257 ret = n_Y + n_p + n_g + 6;
258 if (psk != 0) 258 if (psk != 0)
@@ -264,7 +264,7 @@ _gnutls_proc_dh_common_server_kx (gnutls_session_t session,
264/* If the psk flag is set, then an empty psk_identity_hint will 264/* If the psk flag is set, then an empty psk_identity_hint will
265 * be inserted */ 265 * be inserted */
266int 266int
267_gnutls_dh_common_print_server_kx (gnutls_session_t session, 267mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t session,
268 mpi_t g, mpi_t p, opaque ** data, int psk) 268 mpi_t g, mpi_t p, opaque ** data, int psk)
269{ 269{
270 mpi_t x, X; 270 mpi_t x, X;
@@ -272,7 +272,7 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session,
272 int ret, data_size, pos; 272 int ret, data_size, pos;
273 uint8_t *pdata; 273 uint8_t *pdata;
274 274
275 X = gnutls_calc_dh_secret (&x, g, p); 275 X = mhd_gtls_calc_dh_secret (&x, g, p);
276 if (X == NULL || x == NULL) 276 if (X == NULL || x == NULL)
277 { 277 {
278 gnutls_assert (); 278 gnutls_assert ();
@@ -280,11 +280,11 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session,
280 } 280 }
281 281
282 session->key->dh_secret = x; 282 session->key->dh_secret = x;
283 _gnutls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x)); 283 mhd_gtls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x));
284 284
285 _gnutls_mpi_print (NULL, &n_g, g); 285 mhd_gtls_mpi_print (NULL, &n_g, g);
286 _gnutls_mpi_print (NULL, &n_p, p); 286 mhd_gtls_mpi_print (NULL, &n_p, p);
287 _gnutls_mpi_print (NULL, &n_X, X); 287 mhd_gtls_mpi_print (NULL, &n_X, X);
288 288
289 data_size = n_g + n_p + n_X + 6; 289 data_size = n_g + n_p + n_X + 6;
290 if (psk != 0) 290 if (psk != 0)
@@ -293,7 +293,7 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session,
293 (*data) = gnutls_malloc (data_size); 293 (*data) = gnutls_malloc (data_size);
294 if (*data == NULL) 294 if (*data == NULL)
295 { 295 {
296 _gnutls_mpi_release (&X); 296 mhd_gtls_mpi_release (&X);
297 return GNUTLS_E_MEMORY_ERROR; 297 return GNUTLS_E_MEMORY_ERROR;
298 } 298 }
299 299
@@ -302,24 +302,24 @@ _gnutls_dh_common_print_server_kx (gnutls_session_t session,
302 302
303 if (psk != 0) 303 if (psk != 0)
304 { 304 {
305 _gnutls_write_uint16 (0, &pdata[pos]); 305 mhd_gtls_write_uint16 (0, &pdata[pos]);
306 pos += 2; 306 pos += 2;
307 } 307 }
308 308
309 _gnutls_mpi_print (&pdata[pos + 2], &n_p, p); 309 mhd_gtls_mpi_print (&pdata[pos + 2], &n_p, p);
310 _gnutls_write_uint16 (n_p, &pdata[pos]); 310 mhd_gtls_write_uint16 (n_p, &pdata[pos]);
311 311
312 pos += n_p + 2; 312 pos += n_p + 2;
313 313
314 _gnutls_mpi_print (&pdata[pos + 2], &n_g, g); 314 mhd_gtls_mpi_print (&pdata[pos + 2], &n_g, g);
315 _gnutls_write_uint16 (n_g, &pdata[pos]); 315 mhd_gtls_write_uint16 (n_g, &pdata[pos]);
316 316
317 pos += n_g + 2; 317 pos += n_g + 2;
318 318
319 _gnutls_mpi_print (&pdata[pos + 2], &n_X, X); 319 mhd_gtls_mpi_print (&pdata[pos + 2], &n_X, X);
320 _gnutls_mpi_release (&X); 320 mhd_gtls_mpi_release (&X);
321 321
322 _gnutls_write_uint16 (n_X, &pdata[pos]); 322 mhd_gtls_write_uint16 (n_X, &pdata[pos]);
323 323
324 ret = data_size; 324 ret = data_size;
325 325
diff --git a/src/daemon/https/tls/auth_dh_common.h b/src/daemon/https/tls/auth_dh_common.h
index be0ad066..9d2d994a 100644
--- a/src/daemon/https/tls/auth_dh_common.h
+++ b/src/daemon/https/tls/auth_dh_common.h
@@ -34,14 +34,14 @@ typedef struct
34 gnutls_datum_t public_key; 34 gnutls_datum_t public_key;
35} dh_info_st; 35} dh_info_st;
36 36
37void _gnutls_free_dh_info (dh_info_st * dh); 37void mhd_gtls_free_dh_info (dh_info_st * dh);
38int _gnutls_gen_dh_common_client_kx (gnutls_session_t, opaque **); 38int mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t, opaque **);
39int _gnutls_proc_dh_common_client_kx (gnutls_session_t session, 39int mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
40 opaque * data, size_t _data_size, 40 opaque * data, size_t _data_size,
41 mpi_t p, mpi_t g); 41 mpi_t p, mpi_t g);
42int _gnutls_dh_common_print_server_kx (gnutls_session_t, mpi_t g, mpi_t p, 42int mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t, mpi_t g, mpi_t p,
43 opaque ** data, int psk); 43 opaque ** data, int psk);
44int _gnutls_proc_dh_common_server_kx (gnutls_session_t session, 44int mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
45 opaque * data, size_t _data_size, 45 opaque * data, size_t _data_size,
46 int psk); 46 int psk);
47 47
diff --git a/src/daemon/https/tls/auth_dhe.c b/src/daemon/https/tls/auth_dhe.c
index 36c3be3f..ada5efe2 100644
--- a/src/daemon/https/tls/auth_dhe.c
+++ b/src/daemon/https/tls/auth_dhe.c
@@ -39,47 +39,47 @@
39#include <gnutls_state.h> 39#include <gnutls_state.h>
40#include <auth_dh_common.h> 40#include <auth_dh_common.h>
41 41
42static int gen_dhe_server_kx (gnutls_session_t, opaque **); 42static int gen_dhe_server_kx (mhd_gtls_session_t, opaque **);
43static int proc_dhe_server_kx (gnutls_session_t, opaque *, size_t); 43static int proc_dhe_server_kx (mhd_gtls_session_t, opaque *, size_t);
44static int proc_dhe_client_kx (gnutls_session_t, opaque *, size_t); 44static int proc_dhe_client_kx (mhd_gtls_session_t, opaque *, size_t);
45 45
46const mod_auth_st dhe_rsa_auth_struct = { 46const mhd_gtls_mod_auth_st dhe_rsa_auth_struct = {
47 "DHE_RSA", 47 "DHE_RSA",
48 _gnutls_gen_cert_server_certificate, 48 mhd_gtls_gen_cert_server_certificate,
49 _gnutls_gen_cert_client_certificate, 49 mhd_gtls_gen_cert_client_certificate,
50 gen_dhe_server_kx, 50 gen_dhe_server_kx,
51 _gnutls_gen_dh_common_client_kx, 51 mhd_gtls_gen_dh_common_client_kx,
52 _gnutls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */ 52 mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
53 _gnutls_gen_cert_server_cert_req, /* server cert request */ 53 mhd_gtls_gen_cert_server_cert_req, /* server cert request */
54 54
55 _gnutls_proc_cert_server_certificate, 55 mhd_gtls_proc_cert_server_certificate,
56 _gnutls_proc_cert_client_certificate, 56 _gnutls_proc_cert_client_certificate,
57 proc_dhe_server_kx, 57 proc_dhe_server_kx,
58 proc_dhe_client_kx, 58 proc_dhe_client_kx,
59 _gnutls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ 59 mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
60 _gnutls_proc_cert_cert_req /* proc server cert request */ 60 mhd_gtls_proc_cert_cert_req /* proc server cert request */
61}; 61};
62 62
63const mod_auth_st dhe_dss_auth_struct = { 63const mhd_gtls_mod_auth_st dhe_dss_auth_struct = {
64 "DHE_DSS", 64 "DHE_DSS",
65 _gnutls_gen_cert_server_certificate, 65 mhd_gtls_gen_cert_server_certificate,
66 _gnutls_gen_cert_client_certificate, 66 mhd_gtls_gen_cert_client_certificate,
67 gen_dhe_server_kx, 67 gen_dhe_server_kx,
68 _gnutls_gen_dh_common_client_kx, 68 mhd_gtls_gen_dh_common_client_kx,
69 _gnutls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */ 69 mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
70 _gnutls_gen_cert_server_cert_req, /* server cert request */ 70 mhd_gtls_gen_cert_server_cert_req, /* server cert request */
71 71
72 _gnutls_proc_cert_server_certificate, 72 mhd_gtls_proc_cert_server_certificate,
73 _gnutls_proc_cert_client_certificate, 73 _gnutls_proc_cert_client_certificate,
74 proc_dhe_server_kx, 74 proc_dhe_server_kx,
75 proc_dhe_client_kx, 75 proc_dhe_client_kx,
76 _gnutls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ 76 mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
77 _gnutls_proc_cert_cert_req /* proc server cert request */ 77 mhd_gtls_proc_cert_cert_req /* proc server cert request */
78}; 78};
79 79
80 80
81static int 81static int
82gen_dhe_server_kx (gnutls_session_t session, opaque ** data) 82gen_dhe_server_kx (mhd_gtls_session_t session, opaque ** data)
83{ 83{
84 mpi_t g, p; 84 mpi_t g, p;
85 const mpi_t *mpis; 85 const mpi_t *mpis;
@@ -89,22 +89,22 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
89 gnutls_privkey *apr_pkey; 89 gnutls_privkey *apr_pkey;
90 int apr_cert_list_length; 90 int apr_cert_list_length;
91 gnutls_datum_t signature, ddata; 91 gnutls_datum_t signature, ddata;
92 gnutls_certificate_credentials_t cred; 92 mhd_gtls_cert_credentials_t cred;
93 gnutls_dh_params_t dh_params; 93 mhd_gtls_dh_params_t dh_params;
94 94
95 cred = (gnutls_certificate_credentials_t) 95 cred = (mhd_gtls_cert_credentials_t)
96 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 96 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
97 if (cred == NULL) 97 if (cred == NULL)
98 { 98 {
99 gnutls_assert (); 99 gnutls_assert ();
100 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 100 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
101 } 101 }
102 102
103 bits = _gnutls_dh_get_allowed_prime_bits (session); 103 bits = mhd_gtls_dh_get_allowed_prime_bits (session);
104 104
105 /* find the appropriate certificate */ 105 /* find the appropriate certificate */
106 if ((ret = 106 if ((ret =
107 _gnutls_get_selected_cert (session, &apr_cert_list, 107 mhd_gtls_get_selected_cert (session, &apr_cert_list,
108 &apr_cert_list_length, &apr_pkey)) < 0) 108 &apr_cert_list_length, &apr_pkey)) < 0)
109 { 109 {
110 gnutls_assert (); 110 gnutls_assert ();
@@ -112,8 +112,8 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
112 } 112 }
113 113
114 dh_params = 114 dh_params =
115 _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); 115 mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
116 mpis = _gnutls_dh_params_to_mpi (dh_params); 116 mpis = mhd_gtls_dh_params_to_mpi (dh_params);
117 if (mpis == NULL) 117 if (mpis == NULL)
118 { 118 {
119 gnutls_assert (); 119 gnutls_assert ();
@@ -123,16 +123,16 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
123 p = mpis[0]; 123 p = mpis[0];
124 g = mpis[1]; 124 g = mpis[1];
125 125
126 if ((ret = _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 126 if ((ret = mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
127 sizeof (cert_auth_info_st), 0)) < 0) 127 sizeof (cert_auth_info_st), 0)) < 0)
128 { 128 {
129 gnutls_assert (); 129 gnutls_assert ();
130 return ret; 130 return ret;
131 } 131 }
132 132
133 _gnutls_dh_set_group (session, g, p); 133 mhd_gtls_dh_set_group (session, g, p);
134 134
135 ret = _gnutls_dh_common_print_server_kx (session, g, p, data, 0); 135 ret = mhd_gtls_dh_common_print_server_kx (session, g, p, data, 0);
136 if (ret < 0) 136 if (ret < 0)
137 { 137 {
138 gnutls_assert (); 138 gnutls_assert ();
@@ -148,7 +148,7 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
148 if (apr_cert_list_length > 0) 148 if (apr_cert_list_length > 0)
149 { 149 {
150 if ((ret = 150 if ((ret =
151 _gnutls_tls_sign_params (session, &apr_cert_list[0], 151 mhd_gtls_tls_sign_params (session, &apr_cert_list[0],
152 apr_pkey, &ddata, &signature)) < 0) 152 apr_pkey, &ddata, &signature)) < 0)
153 { 153 {
154 gnutls_assert (); 154 gnutls_assert ();
@@ -162,7 +162,7 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
162 return data_size; /* do not put a signature - ILLEGAL! */ 162 return data_size; /* do not put a signature - ILLEGAL! */
163 } 163 }
164 164
165 *data = gnutls_realloc_fast (*data, data_size + signature.size + 2); 165 *data = mhd_gtls_realloc_fast (*data, data_size + signature.size + 2);
166 if (*data == NULL) 166 if (*data == NULL)
167 { 167 {
168 _gnutls_free_datum (&signature); 168 _gnutls_free_datum (&signature);
@@ -170,7 +170,7 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
170 return GNUTLS_E_MEMORY_ERROR; 170 return GNUTLS_E_MEMORY_ERROR;
171 } 171 }
172 172
173 _gnutls_write_datum16 (&(*data)[data_size], signature); 173 mhd_gtls_write_datum16 (&(*data)[data_size], signature);
174 data_size += signature.size + 2; 174 data_size += signature.size + 2;
175 175
176 _gnutls_free_datum (&signature); 176 _gnutls_free_datum (&signature);
@@ -179,13 +179,13 @@ gen_dhe_server_kx (gnutls_session_t session, opaque ** data)
179} 179}
180 180
181static int 181static int
182proc_dhe_server_kx (gnutls_session_t session, opaque * data, 182proc_dhe_server_kx (mhd_gtls_session_t session, opaque * data,
183 size_t _data_size) 183 size_t _data_size)
184{ 184{
185 int sigsize; 185 int sigsize;
186 gnutls_datum_t vparams, signature; 186 gnutls_datum_t vparams, signature;
187 int ret; 187 int ret;
188 cert_auth_info_t info = _gnutls_get_auth_info (session); 188 cert_auth_info_t info = mhd_gtls_get_auth_info (session);
189 ssize_t data_size = _data_size; 189 ssize_t data_size = _data_size;
190 gnutls_cert peer_cert; 190 gnutls_cert peer_cert;
191 191
@@ -196,7 +196,7 @@ proc_dhe_server_kx (gnutls_session_t session, opaque * data,
196 return GNUTLS_E_INTERNAL_ERROR; 196 return GNUTLS_E_INTERNAL_ERROR;
197 } 197 }
198 198
199 ret = _gnutls_proc_dh_common_server_kx (session, data, _data_size, 0); 199 ret = mhd_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
200 if (ret < 0) 200 if (ret < 0)
201 { 201 {
202 gnutls_assert (); 202 gnutls_assert ();
@@ -209,14 +209,14 @@ proc_dhe_server_kx (gnutls_session_t session, opaque * data,
209 vparams.data = data; 209 vparams.data = data;
210 210
211 DECR_LEN (data_size, 2); 211 DECR_LEN (data_size, 2);
212 sigsize = _gnutls_read_uint16 (&data[vparams.size]); 212 sigsize = mhd_gtls_read_uint16 (&data[vparams.size]);
213 213
214 DECR_LEN (data_size, sigsize); 214 DECR_LEN (data_size, sigsize);
215 signature.data = &data[vparams.size + 2]; 215 signature.data = &data[vparams.size + 2];
216 signature.size = sigsize; 216 signature.size = sigsize;
217 217
218 if ((ret = 218 if ((ret =
219 _gnutls_raw_cert_to_gcert (&peer_cert, 219 mhd_gtls_raw_cert_to_gcert (&peer_cert,
220 session->security_parameters.cert_type, 220 session->security_parameters.cert_type,
221 &info->raw_certificate_list[0], 221 &info->raw_certificate_list[0],
222 CERT_NO_COPY)) < 0) 222 CERT_NO_COPY)) < 0)
@@ -225,9 +225,9 @@ proc_dhe_server_kx (gnutls_session_t session, opaque * data,
225 return ret; 225 return ret;
226 } 226 }
227 227
228 ret = _gnutls_verify_sig_params (session, &peer_cert, &vparams, &signature); 228 ret = mhd_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
229 229
230 _gnutls_gcert_deinit (&peer_cert); 230 mhd_gtls_gcert_deinit (&peer_cert);
231 if (ret < 0) 231 if (ret < 0)
232 { 232 {
233 gnutls_assert (); 233 gnutls_assert ();
@@ -240,17 +240,17 @@ proc_dhe_server_kx (gnutls_session_t session, opaque * data,
240 240
241 241
242static int 242static int
243proc_dhe_client_kx (gnutls_session_t session, opaque * data, 243proc_dhe_client_kx (mhd_gtls_session_t session, opaque * data,
244 size_t _data_size) 244 size_t _data_size)
245{ 245{
246 gnutls_certificate_credentials_t cred; 246 mhd_gtls_cert_credentials_t cred;
247 int ret; 247 int ret;
248 mpi_t p, g; 248 mpi_t p, g;
249 const mpi_t *mpis; 249 const mpi_t *mpis;
250 gnutls_dh_params_t dh_params; 250 mhd_gtls_dh_params_t dh_params;
251 251
252 cred = (gnutls_certificate_credentials_t) 252 cred = (mhd_gtls_cert_credentials_t)
253 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 253 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
254 if (cred == NULL) 254 if (cred == NULL)
255 { 255 {
256 gnutls_assert (); 256 gnutls_assert ();
@@ -258,8 +258,8 @@ proc_dhe_client_kx (gnutls_session_t session, opaque * data,
258 } 258 }
259 259
260 dh_params = 260 dh_params =
261 _gnutls_get_dh_params (cred->dh_params, cred->params_func, session); 261 mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
262 mpis = _gnutls_dh_params_to_mpi (dh_params); 262 mpis = mhd_gtls_dh_params_to_mpi (dh_params);
263 if (mpis == NULL) 263 if (mpis == NULL)
264 { 264 {
265 gnutls_assert (); 265 gnutls_assert ();
@@ -269,7 +269,7 @@ proc_dhe_client_kx (gnutls_session_t session, opaque * data,
269 p = mpis[0]; 269 p = mpis[0];
270 g = mpis[1]; 270 g = mpis[1];
271 271
272 ret = _gnutls_proc_dh_common_client_kx (session, data, _data_size, g, p); 272 ret = mhd_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
273 273
274 return ret; 274 return ret;
275 275
diff --git a/src/daemon/https/tls/auth_rsa.c b/src/daemon/https/tls/auth_rsa.c
index ae5640ae..40d1913f 100644
--- a/src/daemon/https/tls/auth_rsa.c
+++ b/src/daemon/https/tls/auth_rsa.c
@@ -42,30 +42,30 @@
42#include <gnutls_x509.h> 42#include <gnutls_x509.h>
43#include <gc.h> 43#include <gc.h>
44 44
45int _gnutls_gen_rsa_client_kx (gnutls_session_t, opaque **); 45int _gnutls_gen_rsa_client_kx (mhd_gtls_session_t, opaque **);
46int _gnutls_proc_rsa_client_kx (gnutls_session_t, opaque *, size_t); 46int _gnutls_proc_rsa_client_kx (mhd_gtls_session_t, opaque *, size_t);
47 47
48const mod_auth_st rsa_auth_struct = { 48const mhd_gtls_mod_auth_st rsa_auth_struct = {
49 "RSA", 49 "RSA",
50 _gnutls_gen_cert_server_certificate, 50 mhd_gtls_gen_cert_server_certificate,
51 _gnutls_gen_cert_client_certificate, 51 mhd_gtls_gen_cert_client_certificate,
52 NULL, /* gen server kx */ 52 NULL, /* gen server kx */
53 _gnutls_gen_rsa_client_kx, 53 _gnutls_gen_rsa_client_kx,
54 _gnutls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */ 54 mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
55 _gnutls_gen_cert_server_cert_req, /* server cert request */ 55 mhd_gtls_gen_cert_server_cert_req, /* server cert request */
56 56
57 _gnutls_proc_cert_server_certificate, 57 mhd_gtls_proc_cert_server_certificate,
58 _gnutls_proc_cert_client_certificate, 58 _gnutls_proc_cert_client_certificate,
59 NULL, /* proc server kx */ 59 NULL, /* proc server kx */
60 _gnutls_proc_rsa_client_kx, /* proc client kx */ 60 _gnutls_proc_rsa_client_kx, /* proc client kx */
61 _gnutls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ 61 mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
62 _gnutls_proc_cert_cert_req /* proc server cert request */ 62 mhd_gtls_proc_cert_cert_req /* proc server cert request */
63}; 63};
64 64
65/* This function reads the RSA parameters from peer's certificate; 65/* This function reads the RSA parameters from peer's certificate;
66 */ 66 */
67int 67int
68_gnutls_get_public_rsa_params (gnutls_session_t session, 68_gnutls_get_public_rsa_params (mhd_gtls_session_t session,
69 mpi_t params[MAX_PUBLIC_PARAMS_SIZE], 69 mpi_t params[MAX_PUBLIC_PARAMS_SIZE],
70 int *params_len) 70 int *params_len)
71{ 71{
@@ -76,7 +76,7 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
76 76
77 /* normal non export case */ 77 /* normal non export case */
78 78
79 info = _gnutls_get_auth_info (session); 79 info = mhd_gtls_get_auth_info (session);
80 80
81 if (info == NULL || info->ncerts == 0) 81 if (info == NULL || info->ncerts == 0)
82 { 82 {
@@ -85,7 +85,7 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
85 } 85 }
86 86
87 ret = 87 ret =
88 _gnutls_raw_cert_to_gcert (&peer_cert, 88 mhd_gtls_raw_cert_to_gcert (&peer_cert,
89 session->security_parameters.cert_type, 89 session->security_parameters.cert_type,
90 &info->raw_certificate_list[0], 90 &info->raw_certificate_list[0],
91 CERT_ONLY_PUBKEY | CERT_NO_COPY); 91 CERT_ONLY_PUBKEY | CERT_NO_COPY);
@@ -98,13 +98,13 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
98 98
99 99
100 /* EXPORT case: */ 100 /* EXPORT case: */
101 if (_gnutls_cipher_suite_get_kx_algo 101 if (mhd_gtls_cipher_suite_get_kx_algo
102 (&session->security_parameters.current_cipher_suite) 102 (&session->security_parameters.current_cipher_suite)
103 == MHD_GNUTLS_KX_RSA_EXPORT 103 == MHD_GNUTLS_KX_RSA_EXPORT
104 && _gnutls_mpi_get_nbits (peer_cert.params[0]) > 512) 104 && _gnutls_mpi_get_nbits (peer_cert.params[0]) > 512)
105 { 105 {
106 106
107 _gnutls_gcert_deinit (&peer_cert); 107 mhd_gtls_gcert_deinit (&peer_cert);
108 108
109 if (session->key->rsa[0] == NULL || session->key->rsa[1] == NULL) 109 if (session->key->rsa[0] == NULL || session->key->rsa[1] == NULL)
110 { 110 {
@@ -139,7 +139,7 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
139 { 139 {
140 params[i] = _gnutls_mpi_copy (peer_cert.params[i]); 140 params[i] = _gnutls_mpi_copy (peer_cert.params[i]);
141 } 141 }
142 _gnutls_gcert_deinit (&peer_cert); 142 mhd_gtls_gcert_deinit (&peer_cert);
143 143
144 return 0; 144 return 0;
145} 145}
@@ -147,15 +147,15 @@ _gnutls_get_public_rsa_params (gnutls_session_t session,
147/* This function reads the RSA parameters from the private key 147/* This function reads the RSA parameters from the private key
148 */ 148 */
149int 149int
150_gnutls_get_private_rsa_params (gnutls_session_t session, 150_gnutls_get_private_rsa_params (mhd_gtls_session_t session,
151 mpi_t ** params, int *params_size) 151 mpi_t ** params, int *params_size)
152{ 152{
153 int bits; 153 int bits;
154 gnutls_certificate_credentials_t cred; 154 mhd_gtls_cert_credentials_t cred;
155 gnutls_rsa_params_t rsa_params; 155 mhd_gtls_rsa_params_t rsa_params;
156 156
157 cred = (gnutls_certificate_credentials_t) 157 cred = (mhd_gtls_cert_credentials_t)
158 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 158 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
159 if (cred == NULL) 159 if (cred == NULL)
160 { 160 {
161 gnutls_assert (); 161 gnutls_assert ();
@@ -172,13 +172,13 @@ _gnutls_get_private_rsa_params (gnutls_session_t session,
172 _gnutls_mpi_get_nbits (session->internals.selected_cert_list[0]. 172 _gnutls_mpi_get_nbits (session->internals.selected_cert_list[0].
173 params[0]); 173 params[0]);
174 174
175 if (_gnutls_cipher_suite_get_kx_algo 175 if (mhd_gtls_cipher_suite_get_kx_algo
176 (&session->security_parameters.current_cipher_suite) 176 (&session->security_parameters.current_cipher_suite)
177 == MHD_GNUTLS_KX_RSA_EXPORT && bits > 512) 177 == MHD_GNUTLS_KX_RSA_EXPORT && bits > 512)
178 { 178 {
179 179
180 rsa_params = 180 rsa_params =
181 _gnutls_certificate_get_rsa_params (cred->rsa_params, 181 mhd_gtls_certificate_get_rsa_params (cred->rsa_params,
182 cred->params_func, session); 182 cred->params_func, session);
183 /* EXPORT case: */ 183 /* EXPORT case: */
184 if (rsa_params == NULL) 184 if (rsa_params == NULL)
@@ -206,7 +206,7 @@ _gnutls_get_private_rsa_params (gnutls_session_t session,
206} 206}
207 207
208int 208int
209_gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data, 209_gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
210 size_t _data_size) 210 size_t _data_size)
211{ 211{
212 gnutls_datum_t plaintext; 212 gnutls_datum_t plaintext;
@@ -217,7 +217,7 @@ _gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
217 int randomize_key = 0; 217 int randomize_key = 0;
218 ssize_t data_size = _data_size; 218 ssize_t data_size = _data_size;
219 219
220 if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3) 220 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
221 { 221 {
222 /* SSL 3.0 222 /* SSL 3.0
223 */ 223 */
@@ -230,7 +230,7 @@ _gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
230 */ 230 */
231 DECR_LEN (data_size, 2); 231 DECR_LEN (data_size, 2);
232 ciphertext.data = &data[2]; 232 ciphertext.data = &data[2];
233 dsize = _gnutls_read_uint16 (data); 233 dsize = mhd_gtls_read_uint16 (data);
234 234
235 if (dsize != data_size) 235 if (dsize != data_size)
236 { 236 {
@@ -247,7 +247,7 @@ _gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
247 return ret; 247 return ret;
248 } 248 }
249 249
250 ret = _gnutls_pkcs1_rsa_decrypt (&plaintext, &ciphertext, params, params_len, 2); /* btype==2 */ 250 ret = mhd_gtls_pkcs1_rsa_decrypt (&plaintext, &ciphertext, params, params_len, 2); /* btype==2 */
251 251
252 if (ret < 0 || plaintext.size != TLS_MASTER_SIZE) 252 if (ret < 0 || plaintext.size != TLS_MASTER_SIZE)
253 { 253 {
@@ -318,7 +318,7 @@ _gnutls_proc_rsa_client_kx (gnutls_session_t session, opaque * data,
318/* return RSA(random) using the peers public key 318/* return RSA(random) using the peers public key
319 */ 319 */
320int 320int
321_gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data) 321_gnutls_gen_rsa_client_kx (mhd_gtls_session_t session, opaque ** data)
322{ 322{
323 cert_auth_info_t auth = session->key->auth_info; 323 cert_auth_info_t auth = session->key->auth_info;
324 gnutls_datum_t sdata; /* data to send */ 324 gnutls_datum_t sdata; /* data to send */
@@ -352,12 +352,12 @@ _gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
352 return GNUTLS_E_RANDOM_FAILED; 352 return GNUTLS_E_RANDOM_FAILED;
353 } 353 }
354 354
355 ver = _gnutls_get_adv_version (session); 355 ver = mhd_gtls_get_adv_version (session);
356 356
357 if (session->internals.rsa_pms_version[0] == 0) 357 if (session->internals.rsa_pms_version[0] == 0)
358 { 358 {
359 session->key->key.data[0] = _gnutls_version_get_major (ver); 359 session->key->key.data[0] = mhd_gtls_version_get_major (ver);
360 session->key->key.data[1] = _gnutls_version_get_minor (ver); 360 session->key->key.data[1] = mhd_gtls_version_get_minor (ver);
361 } 361 }
362 else 362 else
363 { /* use the version provided */ 363 { /* use the version provided */
@@ -375,7 +375,7 @@ _gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
375 } 375 }
376 376
377 if ((ret = 377 if ((ret =
378 _gnutls_pkcs1_rsa_encrypt (&sdata, &session->key->key, 378 mhd_gtls_pkcs1_rsa_encrypt (&sdata, &session->key->key,
379 params, params_len, 2)) < 0) 379 params, params_len, 2)) < 0)
380 { 380 {
381 gnutls_assert (); 381 gnutls_assert ();
@@ -383,9 +383,9 @@ _gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
383 } 383 }
384 384
385 for (i = 0; i < params_len; i++) 385 for (i = 0; i < params_len; i++)
386 _gnutls_mpi_release (&params[i]); 386 mhd_gtls_mpi_release (&params[i]);
387 387
388 if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3) 388 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
389 { 389 {
390 /* SSL 3.0 */ 390 /* SSL 3.0 */
391 *data = sdata.data; 391 *data = sdata.data;
@@ -399,7 +399,7 @@ _gnutls_gen_rsa_client_kx (gnutls_session_t session, opaque ** data)
399 _gnutls_free_datum (&sdata); 399 _gnutls_free_datum (&sdata);
400 return GNUTLS_E_MEMORY_ERROR; 400 return GNUTLS_E_MEMORY_ERROR;
401 } 401 }
402 _gnutls_write_datum16 (*data, sdata); 402 mhd_gtls_write_datum16 (*data, sdata);
403 ret = sdata.size + 2; 403 ret = sdata.size + 2;
404 _gnutls_free_datum (&sdata); 404 _gnutls_free_datum (&sdata);
405 return ret; 405 return ret;
diff --git a/src/daemon/https/tls/auth_rsa_export.c b/src/daemon/https/tls/auth_rsa_export.c
index 7c598226..cb01570f 100644
--- a/src/daemon/https/tls/auth_rsa_export.c
+++ b/src/daemon/https/tls/auth_rsa_export.c
@@ -43,32 +43,32 @@
43#include <gnutls_rsa_export.h> 43#include <gnutls_rsa_export.h>
44#include <gnutls_state.h> 44#include <gnutls_state.h>
45 45
46int _gnutls_gen_rsa_client_kx (gnutls_session_t, opaque **); 46int _gnutls_gen_rsa_client_kx (mhd_gtls_session_t, opaque **);
47int _gnutls_proc_rsa_client_kx (gnutls_session_t, opaque *, size_t); 47int _gnutls_proc_rsa_client_kx (mhd_gtls_session_t, opaque *, size_t);
48static int gen_rsa_export_server_kx (gnutls_session_t, opaque **); 48static int gen_rsa_export_server_kx (mhd_gtls_session_t, opaque **);
49static int proc_rsa_export_server_kx (gnutls_session_t, opaque *, size_t); 49static int proc_rsa_export_server_kx (mhd_gtls_session_t, opaque *, size_t);
50 50
51const mod_auth_st rsa_export_auth_struct = { 51const mhd_gtls_mod_auth_st rsa_export_auth_struct = {
52 "RSA EXPORT", 52 "RSA EXPORT",
53 _gnutls_gen_cert_server_certificate, 53 mhd_gtls_gen_cert_server_certificate,
54 _gnutls_gen_cert_client_certificate, 54 mhd_gtls_gen_cert_client_certificate,
55 gen_rsa_export_server_kx, 55 gen_rsa_export_server_kx,
56 _gnutls_gen_rsa_client_kx, 56 _gnutls_gen_rsa_client_kx,
57 _gnutls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */ 57 mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
58 _gnutls_gen_cert_server_cert_req, /* server cert request */ 58 mhd_gtls_gen_cert_server_cert_req, /* server cert request */
59 59
60 _gnutls_proc_cert_server_certificate, 60 mhd_gtls_proc_cert_server_certificate,
61 _gnutls_proc_cert_client_certificate, 61 _gnutls_proc_cert_client_certificate,
62 proc_rsa_export_server_kx, 62 proc_rsa_export_server_kx,
63 _gnutls_proc_rsa_client_kx, /* proc client kx */ 63 _gnutls_proc_rsa_client_kx, /* proc client kx */
64 _gnutls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ 64 mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
65 _gnutls_proc_cert_cert_req /* proc server cert request */ 65 mhd_gtls_proc_cert_cert_req /* proc server cert request */
66}; 66};
67 67
68static int 68static int
69gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data) 69gen_rsa_export_server_kx (mhd_gtls_session_t session, opaque ** data)
70{ 70{
71 gnutls_rsa_params_t rsa_params; 71 mhd_gtls_rsa_params_t rsa_params;
72 const mpi_t *rsa_mpis; 72 const mpi_t *rsa_mpis;
73 size_t n_e, n_m; 73 size_t n_e, n_m;
74 uint8_t *data_e, *data_m; 74 uint8_t *data_e, *data_m;
@@ -78,10 +78,10 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
78 int apr_cert_list_length; 78 int apr_cert_list_length;
79 gnutls_datum_t signature, ddata; 79 gnutls_datum_t signature, ddata;
80 cert_auth_info_t info; 80 cert_auth_info_t info;
81 gnutls_certificate_credentials_t cred; 81 mhd_gtls_cert_credentials_t cred;
82 82
83 cred = (gnutls_certificate_credentials_t) 83 cred = (mhd_gtls_cert_credentials_t)
84 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 84 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
85 if (cred == NULL) 85 if (cred == NULL)
86 { 86 {
87 gnutls_assert (); 87 gnutls_assert ();
@@ -90,7 +90,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
90 90
91 /* find the appropriate certificate */ 91 /* find the appropriate certificate */
92 if ((ret = 92 if ((ret =
93 _gnutls_get_selected_cert (session, &apr_cert_list, 93 mhd_gtls_get_selected_cert (session, &apr_cert_list,
94 &apr_cert_list_length, &apr_pkey)) < 0) 94 &apr_cert_list_length, &apr_pkey)) < 0)
95 { 95 {
96 gnutls_assert (); 96 gnutls_assert ();
@@ -107,7 +107,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
107 } 107 }
108 108
109 rsa_params = 109 rsa_params =
110 _gnutls_certificate_get_rsa_params (cred->rsa_params, cred->params_func, 110 mhd_gtls_certificate_get_rsa_params (cred->rsa_params, cred->params_func,
111 session); 111 session);
112 rsa_mpis = _gnutls_rsa_params_to_mpi (rsa_params); 112 rsa_mpis = _gnutls_rsa_params_to_mpi (rsa_params);
113 if (rsa_mpis == NULL) 113 if (rsa_mpis == NULL)
@@ -116,18 +116,18 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
116 return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS; 116 return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS;
117 } 117 }
118 118
119 if ((ret = _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 119 if ((ret = mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
120 sizeof (cert_auth_info_st), 0)) < 0) 120 sizeof (cert_auth_info_st), 0)) < 0)
121 { 121 {
122 gnutls_assert (); 122 gnutls_assert ();
123 return ret; 123 return ret;
124 } 124 }
125 125
126 info = _gnutls_get_auth_info (session); 126 info = mhd_gtls_get_auth_info (session);
127 _gnutls_rsa_export_set_pubkey (session, rsa_mpis[1], rsa_mpis[0]); 127 mhd_gtls_rsa_export_set_pubkey (session, rsa_mpis[1], rsa_mpis[0]);
128 128
129 _gnutls_mpi_print (NULL, &n_m, rsa_mpis[0]); 129 mhd_gtls_mpi_print (NULL, &n_m, rsa_mpis[0]);
130 _gnutls_mpi_print (NULL, &n_e, rsa_mpis[1]); 130 mhd_gtls_mpi_print (NULL, &n_e, rsa_mpis[1]);
131 131
132 (*data) = gnutls_malloc (n_e + n_m + 4); 132 (*data) = gnutls_malloc (n_e + n_m + 4);
133 if (*data == NULL) 133 if (*data == NULL)
@@ -136,14 +136,14 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
136 } 136 }
137 137
138 data_m = &(*data)[0]; 138 data_m = &(*data)[0];
139 _gnutls_mpi_print (&data_m[2], &n_m, rsa_mpis[0]); 139 mhd_gtls_mpi_print (&data_m[2], &n_m, rsa_mpis[0]);
140 140
141 _gnutls_write_uint16 (n_m, data_m); 141 mhd_gtls_write_uint16 (n_m, data_m);
142 142
143 data_e = &data_m[2 + n_m]; 143 data_e = &data_m[2 + n_m];
144 _gnutls_mpi_print (&data_e[2], &n_e, rsa_mpis[1]); 144 mhd_gtls_mpi_print (&data_e[2], &n_e, rsa_mpis[1]);
145 145
146 _gnutls_write_uint16 (n_e, data_e); 146 mhd_gtls_write_uint16 (n_e, data_e);
147 147
148 data_size = n_m + n_e + 4; 148 data_size = n_m + n_e + 4;
149 149
@@ -156,7 +156,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
156 if (apr_cert_list_length > 0) 156 if (apr_cert_list_length > 0)
157 { 157 {
158 if ((ret = 158 if ((ret =
159 _gnutls_tls_sign_params (session, &apr_cert_list[0], 159 mhd_gtls_tls_sign_params (session, &apr_cert_list[0],
160 apr_pkey, &ddata, &signature)) < 0) 160 apr_pkey, &ddata, &signature)) < 0)
161 { 161 {
162 gnutls_assert (); 162 gnutls_assert ();
@@ -171,7 +171,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
171 return data_size; /* do not put a signature - ILLEGAL! */ 171 return data_size; /* do not put a signature - ILLEGAL! */
172 } 172 }
173 173
174 *data = gnutls_realloc_fast (*data, data_size + signature.size + 2); 174 *data = mhd_gtls_realloc_fast (*data, data_size + signature.size + 2);
175 if (*data == NULL) 175 if (*data == NULL)
176 { 176 {
177 _gnutls_free_datum (&signature); 177 _gnutls_free_datum (&signature);
@@ -179,7 +179,7 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
179 return GNUTLS_E_MEMORY_ERROR; 179 return GNUTLS_E_MEMORY_ERROR;
180 } 180 }
181 181
182 _gnutls_write_datum16 (&((*data)[data_size]), signature); 182 mhd_gtls_write_datum16 (&((*data)[data_size]), signature);
183 data_size += signature.size + 2; 183 data_size += signature.size + 2;
184 184
185 _gnutls_free_datum (&signature); 185 _gnutls_free_datum (&signature);
@@ -190,11 +190,11 @@ gen_rsa_export_server_kx (gnutls_session_t session, opaque ** data)
190/* if the peer's certificate is of 512 bits or less, returns non zero. 190/* if the peer's certificate is of 512 bits or less, returns non zero.
191 */ 191 */
192int 192int
193_gnutls_peers_cert_less_512 (gnutls_session_t session) 193_gnutls_peers_cert_less_512 (mhd_gtls_session_t session)
194{ 194{
195 gnutls_cert peer_cert; 195 gnutls_cert peer_cert;
196 int ret; 196 int ret;
197 cert_auth_info_t info = _gnutls_get_auth_info (session); 197 cert_auth_info_t info = mhd_gtls_get_auth_info (session);
198 198
199 if (info == NULL || info->ncerts == 0) 199 if (info == NULL || info->ncerts == 0)
200 { 200 {
@@ -204,7 +204,7 @@ _gnutls_peers_cert_less_512 (gnutls_session_t session)
204 } 204 }
205 205
206 if ((ret = 206 if ((ret =
207 _gnutls_raw_cert_to_gcert (&peer_cert, 207 mhd_gtls_raw_cert_to_gcert (&peer_cert,
208 session->security_parameters.cert_type, 208 session->security_parameters.cert_type,
209 &info->raw_certificate_list[0], 209 &info->raw_certificate_list[0],
210 CERT_NO_COPY)) < 0) 210 CERT_NO_COPY)) < 0)
@@ -216,23 +216,23 @@ _gnutls_peers_cert_less_512 (gnutls_session_t session)
216 if (peer_cert.subject_pk_algorithm != MHD_GNUTLS_PK_RSA) 216 if (peer_cert.subject_pk_algorithm != MHD_GNUTLS_PK_RSA)
217 { 217 {
218 gnutls_assert (); 218 gnutls_assert ();
219 _gnutls_gcert_deinit (&peer_cert); 219 mhd_gtls_gcert_deinit (&peer_cert);
220 return 0; 220 return 0;
221 } 221 }
222 222
223 if (_gnutls_mpi_get_nbits (peer_cert.params[0]) <= 512) 223 if (_gnutls_mpi_get_nbits (peer_cert.params[0]) <= 512)
224 { 224 {
225 _gnutls_gcert_deinit (&peer_cert); 225 mhd_gtls_gcert_deinit (&peer_cert);
226 return 1; 226 return 1;
227 } 227 }
228 228
229 _gnutls_gcert_deinit (&peer_cert); 229 mhd_gtls_gcert_deinit (&peer_cert);
230 230
231 return 0; 231 return 0;
232} 232}
233 233
234static int 234static int
235proc_rsa_export_server_kx (gnutls_session_t session, 235proc_rsa_export_server_kx (mhd_gtls_session_t session,
236 opaque * data, size_t _data_size) 236 opaque * data, size_t _data_size)
237{ 237{
238 uint16_t n_m, n_e; 238 uint16_t n_m, n_e;
@@ -246,7 +246,7 @@ proc_rsa_export_server_kx (gnutls_session_t session,
246 cert_auth_info_t info; 246 cert_auth_info_t info;
247 gnutls_cert peer_cert; 247 gnutls_cert peer_cert;
248 248
249 info = _gnutls_get_auth_info (session); 249 info = mhd_gtls_get_auth_info (session);
250 if (info == NULL || info->ncerts == 0) 250 if (info == NULL || info->ncerts == 0)
251 { 251 {
252 gnutls_assert (); 252 gnutls_assert ();
@@ -258,7 +258,7 @@ proc_rsa_export_server_kx (gnutls_session_t session,
258 i = 0; 258 i = 0;
259 259
260 DECR_LEN (data_size, 2); 260 DECR_LEN (data_size, 2);
261 n_m = _gnutls_read_uint16 (&data[i]); 261 n_m = mhd_gtls_read_uint16 (&data[i]);
262 i += 2; 262 i += 2;
263 263
264 DECR_LEN (data_size, n_m); 264 DECR_LEN (data_size, n_m);
@@ -266,7 +266,7 @@ proc_rsa_export_server_kx (gnutls_session_t session,
266 i += n_m; 266 i += n_m;
267 267
268 DECR_LEN (data_size, 2); 268 DECR_LEN (data_size, 2);
269 n_e = _gnutls_read_uint16 (&data[i]); 269 n_e = mhd_gtls_read_uint16 (&data[i]);
270 i += 2; 270 i += 2;
271 271
272 DECR_LEN (data_size, n_e); 272 DECR_LEN (data_size, n_e);
@@ -276,19 +276,19 @@ proc_rsa_export_server_kx (gnutls_session_t session,
276 _n_e = n_e; 276 _n_e = n_e;
277 _n_m = n_m; 277 _n_m = n_m;
278 278
279 if (_gnutls_mpi_scan_nz (&session->key->rsa[0], data_m, &_n_m) != 0) 279 if (mhd_gtls_mpi_scan_nz (&session->key->rsa[0], data_m, &_n_m) != 0)
280 { 280 {
281 gnutls_assert (); 281 gnutls_assert ();
282 return GNUTLS_E_MPI_SCAN_FAILED; 282 return GNUTLS_E_MPI_SCAN_FAILED;
283 } 283 }
284 284
285 if (_gnutls_mpi_scan_nz (&session->key->rsa[1], data_e, &_n_e) != 0) 285 if (mhd_gtls_mpi_scan_nz (&session->key->rsa[1], data_e, &_n_e) != 0)
286 { 286 {
287 gnutls_assert (); 287 gnutls_assert ();
288 return GNUTLS_E_MPI_SCAN_FAILED; 288 return GNUTLS_E_MPI_SCAN_FAILED;
289 } 289 }
290 290
291 _gnutls_rsa_export_set_pubkey (session, session->key->rsa[1], 291 mhd_gtls_rsa_export_set_pubkey (session, session->key->rsa[1],
292 session->key->rsa[0]); 292 session->key->rsa[0]);
293 293
294 /* VERIFY SIGNATURE */ 294 /* VERIFY SIGNATURE */
@@ -297,14 +297,14 @@ proc_rsa_export_server_kx (gnutls_session_t session,
297 vparams.data = data; 297 vparams.data = data;
298 298
299 DECR_LEN (data_size, 2); 299 DECR_LEN (data_size, 2);
300 sigsize = _gnutls_read_uint16 (&data[vparams.size]); 300 sigsize = mhd_gtls_read_uint16 (&data[vparams.size]);
301 301
302 DECR_LEN (data_size, sigsize); 302 DECR_LEN (data_size, sigsize);
303 signature.data = &data[vparams.size + 2]; 303 signature.data = &data[vparams.size + 2];
304 signature.size = sigsize; 304 signature.size = sigsize;
305 305
306 if ((ret = 306 if ((ret =
307 _gnutls_raw_cert_to_gcert (&peer_cert, 307 mhd_gtls_raw_cert_to_gcert (&peer_cert,
308 session->security_parameters.cert_type, 308 session->security_parameters.cert_type,
309 &info->raw_certificate_list[0], 309 &info->raw_certificate_list[0],
310 CERT_NO_COPY)) < 0) 310 CERT_NO_COPY)) < 0)
@@ -313,9 +313,9 @@ proc_rsa_export_server_kx (gnutls_session_t session,
313 return ret; 313 return ret;
314 } 314 }
315 315
316 ret = _gnutls_verify_sig_params (session, &peer_cert, &vparams, &signature); 316 ret = mhd_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
317 317
318 _gnutls_gcert_deinit (&peer_cert); 318 mhd_gtls_gcert_deinit (&peer_cert);
319 if (ret < 0) 319 if (ret < 0)
320 { 320 {
321 gnutls_assert (); 321 gnutls_assert ();
diff --git a/src/daemon/https/tls/debug.c b/src/daemon/https/tls/debug.c
index 2ea31577..14c7b494 100644
--- a/src/daemon/https/tls/debug.c
+++ b/src/daemon/https/tls/debug.c
@@ -32,7 +32,7 @@
32 32
33 33
34void 34void
35_gnutls_print_state (gnutls_session_t session) 35_gnutls_print_state (mhd_gtls_session_t session)
36{ 36{
37 37
38 _gnutls_debug_log ("GNUTLS State:\n"); 38 _gnutls_debug_log ("GNUTLS State:\n");
diff --git a/src/daemon/https/tls/debug.h b/src/daemon/https/tls/debug.h
index 169bc21d..ccaf0f17 100644
--- a/src/daemon/https/tls/debug.h
+++ b/src/daemon/https/tls/debug.h
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#ifdef DEBUG 25#ifdef DEBUG
26void _gnutls_print_state (gnutls_session_t session); 26void _gnutls_print_state (mhd_gtls_session_t session);
27#endif 27#endif
28const char *_gnutls_packet2str (content_type_t packet); 28const char *_gnutls_packet2str (content_type_t packet);
29const char *_gnutls_handshake2str (gnutls_handshake_description_t handshake); 29const char *_gnutls_handshake2str (gnutls_handshake_description_t handshake);
diff --git a/src/daemon/https/tls/ext_cert_type.c b/src/daemon/https/tls/ext_cert_type.c
index a1bec6a1..fbbbab79 100644
--- a/src/daemon/https/tls/ext_cert_type.c
+++ b/src/daemon/https/tls/ext_cert_type.c
@@ -46,7 +46,7 @@ inline static int _gnutls_cert_type2num (int record_size);
46 */ 46 */
47 47
48int 48int
49_gnutls_cert_type_recv_params (gnutls_session_t session, 49mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
50 const opaque * data, size_t _data_size) 50 const opaque * data, size_t _data_size)
51{ 51{
52 int new_type = -1, ret, i; 52 int new_type = -1, ret, i;
@@ -72,7 +72,7 @@ _gnutls_cert_type_recv_params (gnutls_session_t session,
72 72
73 /* Check if we support this cert_type */ 73 /* Check if we support this cert_type */
74 if ((ret = 74 if ((ret =
75 _gnutls_session_cert_type_supported (session, new_type)) < 0) 75 mhd_gtls_session_cert_type_supported (session, new_type)) < 0)
76 { 76 {
77 gnutls_assert (); 77 gnutls_assert ();
78 return ret; 78 return ret;
@@ -100,7 +100,7 @@ _gnutls_cert_type_recv_params (gnutls_session_t session,
100 100
101 /* Check if we support this cert_type */ 101 /* Check if we support this cert_type */
102 if ((ret = 102 if ((ret =
103 _gnutls_session_cert_type_supported (session, 103 mhd_gtls_session_cert_type_supported (session,
104 new_type)) < 0) 104 new_type)) < 0)
105 { 105 {
106 gnutls_assert (); 106 gnutls_assert ();
@@ -118,7 +118,7 @@ _gnutls_cert_type_recv_params (gnutls_session_t session,
118 } 118 }
119 119
120 if ((ret = 120 if ((ret =
121 _gnutls_session_cert_type_supported (session, new_type)) < 0) 121 mhd_gtls_session_cert_type_supported (session, new_type)) < 0)
122 { 122 {
123 gnutls_assert (); 123 gnutls_assert ();
124 /* The peer has requested unsupported certificate 124 /* The peer has requested unsupported certificate
@@ -141,7 +141,7 @@ _gnutls_cert_type_recv_params (gnutls_session_t session,
141/* returns data_size or a negative number on failure 141/* returns data_size or a negative number on failure
142 */ 142 */
143int 143int
144_gnutls_cert_type_send_params (gnutls_session_t session, opaque * data, 144mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
145 size_t data_size) 145 size_t data_size)
146{ 146{
147 unsigned len, i; 147 unsigned len, i;
diff --git a/src/daemon/https/tls/ext_cert_type.h b/src/daemon/https/tls/ext_cert_type.h
index ea7cf219..616e1e7f 100644
--- a/src/daemon/https/tls/ext_cert_type.h
+++ b/src/daemon/https/tls/ext_cert_type.h
@@ -25,7 +25,7 @@
25/* Maps record size to numbers according to the 25/* Maps record size to numbers according to the
26 * extensions draft. 26 * extensions draft.
27 */ 27 */
28int _gnutls_cert_type_recv_params (gnutls_session_t session, 28int mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
29 const opaque * data, size_t data_size); 29 const opaque * data, size_t data_size);
30int _gnutls_cert_type_send_params (gnutls_session_t session, opaque * data, 30int mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
31 size_t); 31 size_t);
diff --git a/src/daemon/https/tls/ext_inner_application.c b/src/daemon/https/tls/ext_inner_application.c
index 763e8cbf..a2276589 100644
--- a/src/daemon/https/tls/ext_inner_application.c
+++ b/src/daemon/https/tls/ext_inner_application.c
@@ -32,10 +32,10 @@
32#define YES 1 32#define YES 1
33 33
34int 34int
35_gnutls_inner_application_recv_params (gnutls_session_t session, 35mhd_gtls_inner_app_rcv_params (mhd_gtls_session_t session,
36 const opaque * data, size_t data_size) 36 const opaque * data, size_t data_size)
37{ 37{
38 tls_ext_st *ext = &session->security_parameters.extensions; 38 mhd_gtls_ext_st *ext = &session->security_parameters.extensions;
39 39
40 if (data_size != 1) 40 if (data_size != 1)
41 { 41 {
@@ -66,10 +66,10 @@ _gnutls_inner_application_recv_params (gnutls_session_t session,
66/* returns data_size or a negative number on failure 66/* returns data_size or a negative number on failure
67 */ 67 */
68int 68int
69_gnutls_inner_application_send_params (gnutls_session_t session, 69mhd_gtls_inner_app_send_params (mhd_gtls_session_t session,
70 opaque * data, size_t data_size) 70 opaque * data, size_t data_size)
71{ 71{
72 tls_ext_st *ext = &session->security_parameters.extensions; 72 mhd_gtls_ext_st *ext = &session->security_parameters.extensions;
73 73
74 /* Set ext->gnutls_ia_enable depending on whether we have a TLS/IA 74 /* Set ext->gnutls_ia_enable depending on whether we have a TLS/IA
75 credential in the session. */ 75 credential in the session. */
@@ -77,7 +77,7 @@ _gnutls_inner_application_send_params (gnutls_session_t session,
77 if (session->security_parameters.entity == GNUTLS_CLIENT) 77 if (session->security_parameters.entity == GNUTLS_CLIENT)
78 { 78 {
79 gnutls_ia_client_credentials_t cred = (gnutls_ia_client_credentials_t) 79 gnutls_ia_client_credentials_t cred = (gnutls_ia_client_credentials_t)
80 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL); 80 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
81 81
82 if (cred) 82 if (cred)
83 ext->gnutls_ia_enable = 1; 83 ext->gnutls_ia_enable = 1;
@@ -85,7 +85,7 @@ _gnutls_inner_application_send_params (gnutls_session_t session,
85 else 85 else
86 { 86 {
87 gnutls_ia_server_credentials_t cred = (gnutls_ia_server_credentials_t) 87 gnutls_ia_server_credentials_t cred = (gnutls_ia_server_credentials_t)
88 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL); 88 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_IA, NULL);
89 89
90 if (cred) 90 if (cred)
91 ext->gnutls_ia_enable = 1; 91 ext->gnutls_ia_enable = 1;
diff --git a/src/daemon/https/tls/ext_inner_application.h b/src/daemon/https/tls/ext_inner_application.h
index e75719e3..c863fcaa 100644
--- a/src/daemon/https/tls/ext_inner_application.h
+++ b/src/daemon/https/tls/ext_inner_application.h
@@ -22,8 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_inner_application_recv_params (gnutls_session_t session, 25int mhd_gtls_inner_app_rcv_params (mhd_gtls_session_t session,
26 const opaque * data, 26 const opaque * data,
27 size_t data_size); 27 size_t data_size);
28int _gnutls_inner_application_send_params (gnutls_session_t session, 28int mhd_gtls_inner_app_send_params (mhd_gtls_session_t session,
29 opaque * data, size_t); 29 opaque * data, size_t);
diff --git a/src/daemon/https/tls/ext_max_record.c b/src/daemon/https/tls/ext_max_record.c
index d0787483..3f4ac68a 100644
--- a/src/daemon/https/tls/ext_max_record.c
+++ b/src/daemon/https/tls/ext_max_record.c
@@ -41,7 +41,7 @@
41 */ 41 */
42 42
43int 43int
44_gnutls_max_record_recv_params (gnutls_session_t session, 44mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
45 const opaque * data, size_t _data_size) 45 const opaque * data, size_t _data_size)
46{ 46{
47 ssize_t new_size; 47 ssize_t new_size;
@@ -53,7 +53,7 @@ _gnutls_max_record_recv_params (gnutls_session_t session,
53 { 53 {
54 DECR_LEN (data_size, 1); 54 DECR_LEN (data_size, 1);
55 55
56 new_size = _gnutls_mre_num2record (data[0]); 56 new_size = mhd_gtls_mre_num2record (data[0]);
57 57
58 if (new_size < 0) 58 if (new_size < 0)
59 { 59 {
@@ -77,7 +77,7 @@ _gnutls_max_record_recv_params (gnutls_session_t session,
77 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 77 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
78 } 78 }
79 79
80 new_size = _gnutls_mre_num2record (data[0]); 80 new_size = mhd_gtls_mre_num2record (data[0]);
81 81
82 if (new_size < 0 82 if (new_size < 0
83 || new_size != session->internals.proposed_record_size) 83 || new_size != session->internals.proposed_record_size)
@@ -102,7 +102,7 @@ _gnutls_max_record_recv_params (gnutls_session_t session,
102/* returns data_size or a negative number on failure 102/* returns data_size or a negative number on failure
103 */ 103 */
104int 104int
105_gnutls_max_record_send_params (gnutls_session_t session, opaque * data, 105mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
106 size_t data_size) 106 size_t data_size)
107{ 107{
108 uint16_t len; 108 uint16_t len;
@@ -120,7 +120,7 @@ _gnutls_max_record_send_params (gnutls_session_t session, opaque * data,
120 } 120 }
121 121
122 data[0] = 122 data[0] =
123 (uint8_t) _gnutls_mre_record2num (session->internals. 123 (uint8_t) mhd_gtls_mre_record2num (session->internals.
124 proposed_record_size); 124 proposed_record_size);
125 return len; 125 return len;
126 } 126 }
@@ -140,7 +140,7 @@ _gnutls_max_record_send_params (gnutls_session_t session, opaque * data,
140 } 140 }
141 141
142 data[0] = 142 data[0] =
143 (uint8_t) _gnutls_mre_record2num (session-> 143 (uint8_t) mhd_gtls_mre_record2num (session->
144 security_parameters. 144 security_parameters.
145 max_record_recv_size); 145 max_record_recv_size);
146 return len; 146 return len;
@@ -156,7 +156,7 @@ _gnutls_max_record_send_params (gnutls_session_t session, opaque * data,
156 * extensions draft. 156 * extensions draft.
157 */ 157 */
158int 158int
159_gnutls_mre_num2record (int num) 159mhd_gtls_mre_num2record (int num)
160{ 160{
161 switch (num) 161 switch (num)
162 { 162 {
@@ -177,7 +177,7 @@ _gnutls_mre_num2record (int num)
177 * extensions draft. 177 * extensions draft.
178 */ 178 */
179int 179int
180_gnutls_mre_record2num (uint16_t record_size) 180mhd_gtls_mre_record2num (uint16_t record_size)
181{ 181{
182 switch (record_size) 182 switch (record_size)
183 { 183 {
diff --git a/src/daemon/https/tls/ext_max_record.h b/src/daemon/https/tls/ext_max_record.h
index 751bedc8..487fe40d 100644
--- a/src/daemon/https/tls/ext_max_record.h
+++ b/src/daemon/https/tls/ext_max_record.h
@@ -25,9 +25,9 @@
25/* Maps record size to numbers according to the 25/* Maps record size to numbers according to the
26 * extensions draft. 26 * extensions draft.
27 */ 27 */
28int _gnutls_mre_num2record (int num); 28int mhd_gtls_mre_num2record (int num);
29int _gnutls_mre_record2num (uint16_t record_size); 29int mhd_gtls_mre_record2num (uint16_t record_size);
30int _gnutls_max_record_recv_params (gnutls_session_t session, 30int mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
31 const opaque * data, size_t data_size); 31 const opaque * data, size_t data_size);
32int _gnutls_max_record_send_params (gnutls_session_t session, opaque * data, 32int mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
33 size_t); 33 size_t);
diff --git a/src/daemon/https/tls/ext_oprfi.c b/src/daemon/https/tls/ext_oprfi.c
index 56a3bc3f..f8bd4953 100644
--- a/src/daemon/https/tls/ext_oprfi.c
+++ b/src/daemon/https/tls/ext_oprfi.c
@@ -33,7 +33,7 @@
33#include <gnutls_num.h> 33#include <gnutls_num.h>
34 34
35int 35int
36oprfi_recv_server (gnutls_session_t session, 36oprfi_recv_server (mhd_gtls_session_t session,
37 const opaque * data, size_t _data_size) 37 const opaque * data, size_t _data_size)
38{ 38{
39 ssize_t data_size = _data_size; 39 ssize_t data_size = _data_size;
@@ -46,7 +46,7 @@ oprfi_recv_server (gnutls_session_t session,
46 } 46 }
47 47
48 DECR_LEN (data_size, 2); 48 DECR_LEN (data_size, 2);
49 len = _gnutls_read_uint16 (data); 49 len = mhd_gtls_read_uint16 (data);
50 data += 2; 50 data += 2;
51 51
52 if (len != data_size) 52 if (len != data_size)
@@ -69,7 +69,7 @@ oprfi_recv_server (gnutls_session_t session,
69} 69}
70 70
71int 71int
72oprfi_recv_client (gnutls_session_t session, 72oprfi_recv_client (mhd_gtls_session_t session,
73 const opaque * data, size_t _data_size) 73 const opaque * data, size_t _data_size)
74{ 74{
75 ssize_t data_size = _data_size; 75 ssize_t data_size = _data_size;
@@ -82,7 +82,7 @@ oprfi_recv_client (gnutls_session_t session,
82 } 82 }
83 83
84 DECR_LEN (data_size, 2); 84 DECR_LEN (data_size, 2);
85 len = _gnutls_read_uint16 (data); 85 len = mhd_gtls_read_uint16 (data);
86 data += 2; 86 data += 2;
87 87
88 if (len != data_size) 88 if (len != data_size)
@@ -111,7 +111,7 @@ oprfi_recv_client (gnutls_session_t session,
111} 111}
112 112
113int 113int
114_gnutls_oprfi_recv_params (gnutls_session_t session, 114mhd_gtls_oprfi_recv_params (mhd_gtls_session_t session,
115 const opaque * data, size_t data_size) 115 const opaque * data, size_t data_size)
116{ 116{
117 if (session->security_parameters.entity == GNUTLS_CLIENT) 117 if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -121,7 +121,7 @@ _gnutls_oprfi_recv_params (gnutls_session_t session,
121} 121}
122 122
123int 123int
124oprfi_send_client (gnutls_session_t session, opaque * data, size_t _data_size) 124oprfi_send_client (mhd_gtls_session_t session, opaque * data, size_t _data_size)
125{ 125{
126 opaque *p = data; 126 opaque *p = data;
127 ssize_t data_size = _data_size; 127 ssize_t data_size = _data_size;
@@ -131,7 +131,7 @@ oprfi_send_client (gnutls_session_t session, opaque * data, size_t _data_size)
131 return 0; 131 return 0;
132 132
133 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER); 133 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
134 _gnutls_write_uint16 (oprf_size, p); 134 mhd_gtls_write_uint16 (oprf_size, p);
135 p += 2; 135 p += 2;
136 136
137 DECR_LENGTH_RET (data_size, oprf_size, GNUTLS_E_SHORT_MEMORY_BUFFER); 137 DECR_LENGTH_RET (data_size, oprf_size, GNUTLS_E_SHORT_MEMORY_BUFFER);
@@ -142,7 +142,7 @@ oprfi_send_client (gnutls_session_t session, opaque * data, size_t _data_size)
142} 142}
143 143
144int 144int
145oprfi_send_server (gnutls_session_t session, opaque * data, size_t _data_size) 145oprfi_send_server (mhd_gtls_session_t session, opaque * data, size_t _data_size)
146{ 146{
147 opaque *p = data; 147 opaque *p = data;
148 int ret; 148 int ret;
@@ -177,7 +177,7 @@ oprfi_send_server (gnutls_session_t session, opaque * data, size_t _data_size)
177 } 177 }
178 178
179 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER); 179 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
180 _gnutls_write_uint16 (session->security_parameters. 180 mhd_gtls_write_uint16 (session->security_parameters.
181 extensions.oprfi_server_len, p); 181 extensions.oprfi_server_len, p);
182 p += 2; 182 p += 2;
183 183
@@ -191,7 +191,7 @@ oprfi_send_server (gnutls_session_t session, opaque * data, size_t _data_size)
191} 191}
192 192
193int 193int
194_gnutls_oprfi_send_params (gnutls_session_t session, 194mhd_gtls_oprfi_send_params (mhd_gtls_session_t session,
195 opaque * data, size_t data_size) 195 opaque * data, size_t data_size)
196{ 196{
197 if (session->security_parameters.entity == GNUTLS_CLIENT) 197 if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -201,8 +201,8 @@ _gnutls_oprfi_send_params (gnutls_session_t session,
201} 201}
202 202
203/** 203/**
204 * gnutls_oprfi_enable_client: 204 * MHD_gtls_oprfi_enable_client:
205 * @session: is a #gnutls_session_t structure. 205 * @session: is a #mhd_gtls_session_t structure.
206 * @len: length of Opaque PRF data to use in client. 206 * @len: length of Opaque PRF data to use in client.
207 * @data: Opaque PRF data to use in client. 207 * @data: Opaque PRF data to use in client.
208 * 208 *
@@ -214,7 +214,7 @@ _gnutls_oprfi_send_params (gnutls_session_t session,
214 * may de-allocate it immediately after calling this function. 214 * may de-allocate it immediately after calling this function.
215 **/ 215 **/
216void 216void
217gnutls_oprfi_enable_client (gnutls_session_t session, 217MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
218 size_t len, unsigned char *data) 218 size_t len, unsigned char *data)
219{ 219{
220 session->security_parameters.extensions.oprfi_client_len = len; 220 session->security_parameters.extensions.oprfi_client_len = len;
@@ -222,8 +222,8 @@ gnutls_oprfi_enable_client (gnutls_session_t session,
222} 222}
223 223
224/** 224/**
225 * gnutls_oprfi_enable_server: 225 * MHD_gtls_oprfi_enable_server:
226 * @session: is a #gnutls_session_t structure. 226 * @session: is a #mhd_gtls_session_t structure.
227 * @cb: function pointer to Opaque PRF extension server callback. 227 * @cb: function pointer to Opaque PRF extension server callback.
228 * @userdata: hook passed to callback function for passing application state. 228 * @userdata: hook passed to callback function for passing application state.
229 * 229 *
@@ -232,7 +232,7 @@ gnutls_oprfi_enable_client (gnutls_session_t session,
232 * provided callback @cb will be invoked. The callback must have the 232 * provided callback @cb will be invoked. The callback must have the
233 * following prototype: 233 * following prototype:
234 * 234 *
235 * int callback (gnutls_session_t session, void *userdata, 235 * int callback (mhd_gtls_session_t session, void *userdata,
236 * size_t oprfi_len, const unsigned char *in_oprfi, 236 * size_t oprfi_len, const unsigned char *in_oprfi,
237 * unsigned char *out_oprfi); 237 * unsigned char *out_oprfi);
238 * 238 *
@@ -242,7 +242,7 @@ gnutls_oprfi_enable_client (gnutls_session_t session,
242 * handshake will be aborted. 242 * handshake will be aborted.
243 **/ 243 **/
244void 244void
245gnutls_oprfi_enable_server (gnutls_session_t session, 245MHD_gtls_oprfi_enable_server (mhd_gtls_session_t session,
246 gnutls_oprfi_callback_func cb, void *userdata) 246 gnutls_oprfi_callback_func cb, void *userdata)
247{ 247{
248 session->security_parameters.extensions.oprfi_cb = cb; 248 session->security_parameters.extensions.oprfi_cb = cb;
diff --git a/src/daemon/https/tls/ext_oprfi.h b/src/daemon/https/tls/ext_oprfi.h
index 7f75be9c..27a9c96a 100644
--- a/src/daemon/https/tls/ext_oprfi.h
+++ b/src/daemon/https/tls/ext_oprfi.h
@@ -24,10 +24,10 @@
24 24
25#include <gnutls_int.h> 25#include <gnutls_int.h>
26 26
27int _gnutls_oprfi_recv_params (gnutls_session_t state, 27int mhd_gtls_oprfi_recv_params (mhd_gtls_session_t state,
28 const opaque * data, 28 const opaque * data,
29 size_t data_size); 29 size_t data_size);
30 30
31int _gnutls_oprfi_send_params (gnutls_session_t state, 31int mhd_gtls_oprfi_send_params (mhd_gtls_session_t state,
32 opaque * data, 32 opaque * data,
33 size_t data_size); 33 size_t data_size);
diff --git a/src/daemon/https/tls/ext_server_name.c b/src/daemon/https/tls/ext_server_name.c
index bc6b4759..9dc1f3bb 100644
--- a/src/daemon/https/tls/ext_server_name.c
+++ b/src/daemon/https/tls/ext_server_name.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41int 41int
42_gnutls_server_name_recv_params (gnutls_session_t session, 42mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
43 const opaque * data, size_t _data_size) 43 const opaque * data, size_t _data_size)
44{ 44{
45 int i; 45 int i;
@@ -51,7 +51,7 @@ _gnutls_server_name_recv_params (gnutls_session_t session,
51 if (session->security_parameters.entity == GNUTLS_SERVER) 51 if (session->security_parameters.entity == GNUTLS_SERVER)
52 { 52 {
53 DECR_LENGTH_RET (data_size, 2, 0); 53 DECR_LENGTH_RET (data_size, 2, 0);
54 len = _gnutls_read_uint16 (data); 54 len = mhd_gtls_read_uint16 (data);
55 55
56 if (len != data_size) 56 if (len != data_size)
57 { 57 {
@@ -71,7 +71,7 @@ _gnutls_server_name_recv_params (gnutls_session_t session,
71 p++; 71 p++;
72 72
73 DECR_LEN (data_size, 2); 73 DECR_LEN (data_size, 2);
74 len = _gnutls_read_uint16 (p); 74 len = mhd_gtls_read_uint16 (p);
75 p += 2; 75 p += 2;
76 76
77 DECR_LENGTH_RET (data_size, len, 0); 77 DECR_LENGTH_RET (data_size, len, 0);
@@ -96,7 +96,7 @@ _gnutls_server_name_recv_params (gnutls_session_t session,
96 type = *p; 96 type = *p;
97 p++; 97 p++;
98 98
99 len = _gnutls_read_uint16 (p); 99 len = mhd_gtls_read_uint16 (p);
100 p += 2; 100 p += 2;
101 101
102 switch (type) 102 switch (type)
@@ -124,7 +124,7 @@ _gnutls_server_name_recv_params (gnutls_session_t session,
124/* returns data_size or a negative number on failure 124/* returns data_size or a negative number on failure
125 */ 125 */
126int 126int
127_gnutls_server_name_send_params (gnutls_session_t session, 127mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
128 opaque * data, size_t _data_size) 128 opaque * data, size_t _data_size)
129{ 129{
130 uint16_t len; 130 uint16_t len;
@@ -163,7 +163,7 @@ _gnutls_server_name_send_params (gnutls_session_t session,
163 /* UINT16: write total size of all names 163 /* UINT16: write total size of all names
164 */ 164 */
165 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER); 165 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
166 _gnutls_write_uint16 (total_size - 2, p); 166 mhd_gtls_write_uint16 (total_size - 2, p);
167 p += 2; 167 p += 2;
168 168
169 for (i = 0; 169 for (i = 0;
@@ -191,7 +191,7 @@ _gnutls_server_name_send_params (gnutls_session_t session,
191 *p = 0; /* NAME_DNS type */ 191 *p = 0; /* NAME_DNS type */
192 p++; 192 p++;
193 193
194 _gnutls_write_uint16 (len, p); 194 mhd_gtls_write_uint16 (len, p);
195 p += 2; 195 p += 2;
196 196
197 memcpy (p, 197 memcpy (p,
@@ -210,8 +210,8 @@ _gnutls_server_name_send_params (gnutls_session_t session,
210} 210}
211 211
212/** 212/**
213 * gnutls_server_name_get - Used to get the server name indicator send by a client 213 * MHD_gnutls_server_name_get - Used to get the server name indicator send by a client
214 * @session: is a #gnutls_session_t structure. 214 * @session: is a #mhd_gtls_session_t structure.
215 * @data: will hold the data 215 * @data: will hold the data
216 * @data_length: will hold the data length. Must hold the maximum size of data. 216 * @data_length: will hold the data length. Must hold the maximum size of data.
217 * @type: will hold the server name indicator type 217 * @type: will hold the server name indicator type
@@ -233,7 +233,7 @@ _gnutls_server_name_send_params (gnutls_session_t session,
233 * 233 *
234 **/ 234 **/
235int 235int
236gnutls_server_name_get (gnutls_session_t session, void *data, 236MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
237 size_t * data_length, 237 size_t * data_length,
238 unsigned int *type, unsigned int indx) 238 unsigned int *type, unsigned int indx)
239{ 239{
@@ -278,8 +278,8 @@ gnutls_server_name_get (gnutls_session_t session, void *data,
278} 278}
279 279
280/** 280/**
281 * gnutls_server_name_set - Used to set a name indicator to be sent as an extension 281 * MHD_gnutls_server_name_set - Used to set a name indicator to be sent as an extension
282 * @session: is a #gnutls_session_t structure. 282 * @session: is a #mhd_gtls_session_t structure.
283 * @type: specifies the indicator type 283 * @type: specifies the indicator type
284 * @name: is a string that contains the server name. 284 * @name: is a string that contains the server name.
285 * @name_length: holds the length of name 285 * @name_length: holds the length of name
@@ -295,7 +295,7 @@ gnutls_server_name_get (gnutls_session_t session, void *data,
295 * 295 *
296 **/ 296 **/
297int 297int
298gnutls_server_name_set (gnutls_session_t session, 298MHD_gnutls_server_name_set (mhd_gtls_session_t session,
299 gnutls_server_name_type_t type, 299 gnutls_server_name_type_t type,
300 const void *name, size_t name_length) 300 const void *name, size_t name_length)
301{ 301{
diff --git a/src/daemon/https/tls/ext_server_name.h b/src/daemon/https/tls/ext_server_name.h
index 91e727a1..7a471ad4 100644
--- a/src/daemon/https/tls/ext_server_name.h
+++ b/src/daemon/https/tls/ext_server_name.h
@@ -22,7 +22,7 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_server_name_recv_params (gnutls_session_t session, 25int mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
26 const opaque * data, size_t data_size); 26 const opaque * data, size_t data_size);
27int _gnutls_server_name_send_params (gnutls_session_t session, 27int mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
28 opaque * data, size_t); 28 opaque * data, size_t);
diff --git a/src/daemon/https/tls/gnutls_alert.c b/src/daemon/https/tls/gnutls_alert.c
index 29422dab..3a97365f 100644
--- a/src/daemon/https/tls/gnutls_alert.c
+++ b/src/daemon/https/tls/gnutls_alert.c
@@ -80,15 +80,15 @@ static const gnutls_alert_entry sup_alerts[] = {
80 80
81 81
82/** 82/**
83 * gnutls_alert_get_name - Returns a string describing the alert number given 83 * MHD_gnutls_alert_get_name - Returns a string describing the alert number given
84 * @alert: is an alert number #gnutls_session_t structure. 84 * @alert: is an alert number #mhd_gtls_session_t structure.
85 * 85 *
86 * This function will return a string that describes the given alert 86 * This function will return a string that describes the given alert
87 * number or NULL. See gnutls_alert_get(). 87 * number or NULL. See gnutls_alert_get().
88 * 88 *
89 **/ 89 **/
90const char * 90const char *
91gnutls_alert_get_name (gnutls_alert_description_t alert) 91MHD_gnutls_alert_get_name (gnutls_alert_description_t alert)
92{ 92{
93 const char *ret = NULL; 93 const char *ret = NULL;
94 94
@@ -98,8 +98,8 @@ gnutls_alert_get_name (gnutls_alert_description_t alert)
98} 98}
99 99
100/** 100/**
101 * gnutls_alert_send - This function sends an alert message to the peer 101 * MHD_gnutls_alert_send - This function sends an alert message to the peer
102 * @session: is a #gnutls_session_t structure. 102 * @session: is a #mhd_gtls_session_t structure.
103 * @level: is the level of the alert 103 * @level: is the level of the alert
104 * @desc: is the alert description 104 * @desc: is the alert description
105 * 105 *
@@ -115,7 +115,7 @@ gnutls_alert_get_name (gnutls_alert_description_t alert)
115 * 115 *
116 **/ 116 **/
117int 117int
118gnutls_alert_send (gnutls_session_t session, gnutls_alert_level_t level, 118MHD_gnutls_alert_send (mhd_gtls_session_t session, gnutls_alert_level_t level,
119 gnutls_alert_description_t desc) 119 gnutls_alert_description_t desc)
120{ 120{
121 uint8_t data[2]; 121 uint8_t data[2];
@@ -125,20 +125,20 @@ gnutls_alert_send (gnutls_session_t session, gnutls_alert_level_t level,
125 data[0] = (uint8_t) level; 125 data[0] = (uint8_t) level;
126 data[1] = (uint8_t) desc; 126 data[1] = (uint8_t) desc;
127 127
128 name = gnutls_alert_get_name ((int) data[1]); 128 name = MHD_gnutls_alert_get_name ((int) data[1]);
129 if (name == NULL) 129 if (name == NULL)
130 name = "(unknown)"; 130 name = "(unknown)";
131 _gnutls_record_log ("REC: Sending Alert[%d|%d] - %s\n", data[0], 131 _gnutls_record_log ("REC: Sending Alert[%d|%d] - %s\n", data[0],
132 data[1], name); 132 data[1], name);
133 133
134 if ((ret = _gnutls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0) 134 if ((ret = mhd_gtls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0)
135 return 0; 135 return 0;
136 else 136 else
137 return ret; 137 return ret;
138} 138}
139 139
140/** 140/**
141 * gnutls_error_to_alert - This function returns an alert code based on the given error code 141 * MHD_gtls_error_to_alert - This function returns an alert code based on the given error code
142 * @err: is a negative integer 142 * @err: is a negative integer
143 * @level: the alert level will be stored there 143 * @level: the alert level will be stored there
144 * 144 *
@@ -153,7 +153,7 @@ gnutls_alert_send (gnutls_session_t session, gnutls_alert_level_t level,
153 * 153 *
154 **/ 154 **/
155int 155int
156gnutls_error_to_alert (int err, int *level) 156MHD_gtls_error_to_alert (int err, int *level)
157{ 157{
158 int ret, _level = -1; 158 int ret, _level = -1;
159 159
@@ -254,12 +254,12 @@ gnutls_error_to_alert (int err, int *level)
254 254
255 255
256/** 256/**
257 * gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code 257 * MHD_gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code
258 * @session: is a #gnutls_session_t structure. 258 * @session: is a #mhd_gtls_session_t structure.
259 * @err: is an integer 259 * @err: is an integer
260 * 260 *
261 * Sends an alert to the peer depending on the error code returned by a gnutls 261 * Sends an alert to the peer depending on the error code returned by a gnutls
262 * function. This function will call gnutls_error_to_alert() to determine 262 * function. This function will call MHD_gtls_error_to_alert() to determine
263 * the appropriate alert to send. 263 * the appropriate alert to send.
264 * 264 *
265 * This function may also return GNUTLS_E_AGAIN, or GNUTLS_E_INTERRUPTED. 265 * This function may also return GNUTLS_E_AGAIN, or GNUTLS_E_INTERRUPTED.
@@ -270,23 +270,23 @@ gnutls_error_to_alert (int err, int *level)
270 * Returns zero on success. 270 * Returns zero on success.
271 */ 271 */
272int 272int
273gnutls_alert_send_appropriate (gnutls_session_t session, int err) 273MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err)
274{ 274{
275 int alert; 275 int alert;
276 int level; 276 int level;
277 277
278 alert = gnutls_error_to_alert (err, &level); 278 alert = MHD_gtls_error_to_alert (err, &level);
279 if (alert < 0) 279 if (alert < 0)
280 { 280 {
281 return alert; 281 return alert;
282 } 282 }
283 283
284 return gnutls_alert_send (session, level, alert); 284 return MHD_gnutls_alert_send (session, level, alert);
285} 285}
286 286
287/** 287/**
288 * gnutls_alert_get - Returns the last alert number received. 288 * gnutls_alert_get - Returns the last alert number received.
289 * @session: is a #gnutls_session_t structure. 289 * @session: is a #mhd_gtls_session_t structure.
290 * 290 *
291 * This function will return the last alert number received. This 291 * This function will return the last alert number received. This
292 * function should be called if GNUTLS_E_WARNING_ALERT_RECEIVED or 292 * function should be called if GNUTLS_E_WARNING_ALERT_RECEIVED or
@@ -298,7 +298,7 @@ gnutls_alert_send_appropriate (gnutls_session_t session, int err)
298 * 298 *
299 **/ 299 **/
300gnutls_alert_description_t 300gnutls_alert_description_t
301gnutls_alert_get (gnutls_session_t session) 301gnutls_alert_get (mhd_gtls_session_t session)
302{ 302{
303 return session->internals.last_alert; 303 return session->internals.last_alert;
304} 304}
diff --git a/src/daemon/https/tls/gnutls_algorithms.c b/src/daemon/https/tls/gnutls_algorithms.c
index 1809afda..adb65081 100644
--- a/src/daemon/https/tls/gnutls_algorithms.c
+++ b/src/daemon/https/tls/gnutls_algorithms.c
@@ -381,22 +381,22 @@ static const gnutls_compression_method_t supported_compressions[] = {
381 GNUTLS_COMPRESSION_LOOP( if(p->num == num) { a; break; } ) 381 GNUTLS_COMPRESSION_LOOP( if(p->num == num) { a; break; } )
382 382
383/* Key Exchange Section */ 383/* Key Exchange Section */
384extern mod_auth_st rsa_auth_struct; 384extern mhd_gtls_mod_auth_st rsa_auth_struct;
385extern mod_auth_st rsa_export_auth_struct; 385extern mhd_gtls_mod_auth_st rsa_export_auth_struct;
386extern mod_auth_st dhe_rsa_auth_struct; 386extern mhd_gtls_mod_auth_st dhe_rsa_auth_struct;
387extern mod_auth_st dhe_dss_auth_struct; 387extern mhd_gtls_mod_auth_st dhe_dss_auth_struct;
388extern mod_auth_st anon_auth_struct; 388extern mhd_gtls_mod_auth_st anon_auth_struct;
389extern mod_auth_st srp_auth_struct; 389extern mhd_gtls_mod_auth_st srp_auth_struct;
390extern mod_auth_st psk_auth_struct; 390extern mhd_gtls_mod_auth_st psk_auth_struct;
391extern mod_auth_st dhe_psk_auth_struct; 391extern mhd_gtls_mod_auth_st dhe_psk_auth_struct;
392extern mod_auth_st srp_rsa_auth_struct; 392extern mhd_gtls_mod_auth_st srp_rsa_auth_struct;
393extern mod_auth_st srp_dss_auth_struct; 393extern mhd_gtls_mod_auth_st srp_dss_auth_struct;
394 394
395struct gnutls_kx_algo_entry 395struct gnutls_kx_algo_entry
396{ 396{
397 const char *name; 397 const char *name;
398 gnutls_kx_algorithm_t algorithm; 398 gnutls_kx_algorithm_t algorithm;
399 mod_auth_st *auth_struct; 399 mhd_gtls_mod_auth_st *auth_struct;
400 int needs_dh_params; 400 int needs_dh_params;
401 int needs_rsa_params; 401 int needs_rsa_params;
402}; 402};
@@ -763,7 +763,7 @@ static const gnutls_cipher_suite_entry cs_algorithms[] = {
763/* Generic Functions */ 763/* Generic Functions */
764 764
765int 765int
766_gnutls_mac_priority (gnutls_session_t session, 766mhd_gtls_mac_priority (mhd_gtls_session_t session,
767 gnutls_mac_algorithm_t algorithm) 767 gnutls_mac_algorithm_t algorithm)
768{ /* actually returns the priority */ 768{ /* actually returns the priority */
769 unsigned int i; 769 unsigned int i;
@@ -776,14 +776,14 @@ _gnutls_mac_priority (gnutls_session_t session,
776} 776}
777 777
778/** 778/**
779 * gnutls_mac_get_name - Returns a string with the name of the specified mac algorithm 779 * MHD_gnutls_mac_get_name - Returns a string with the name of the specified mac algorithm
780 * @algorithm: is a MAC algorithm 780 * @algorithm: is a MAC algorithm
781 * 781 *
782 * Returns: a string that contains the name of the specified MAC 782 * Returns: a string that contains the name of the specified MAC
783 * algorithm, or %NULL. 783 * algorithm, or %NULL.
784 **/ 784 **/
785const char * 785const char *
786gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm) 786MHD_gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm)
787{ 787{
788 const char *ret = NULL; 788 const char *ret = NULL;
789 789
@@ -794,7 +794,7 @@ gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm)
794} 794}
795 795
796/** 796/**
797 * gnutls_mac_get_id - Returns the gnutls id of the specified in string algorithm 797 * MHD_gtls_mac_get_id - Returns the gnutls id of the specified in string algorithm
798 * @algorithm: is a MAC algorithm name 798 * @algorithm: is a MAC algorithm name
799 * 799 *
800 * Returns: an %gnutls_mac_algorithm_tid of the specified in a string 800 * Returns: an %gnutls_mac_algorithm_tid of the specified in a string
@@ -802,7 +802,7 @@ gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm)
802 * compared in a case insensitive way. 802 * compared in a case insensitive way.
803 **/ 803 **/
804gnutls_mac_algorithm_t 804gnutls_mac_algorithm_t
805gnutls_mac_get_id (const char *name) 805MHD_gtls_mac_get_id (const char *name)
806{ 806{
807 gnutls_mac_algorithm_t ret = MHD_GNUTLS_MAC_UNKNOWN; 807 gnutls_mac_algorithm_t ret = MHD_GNUTLS_MAC_UNKNOWN;
808 808
@@ -813,7 +813,7 @@ gnutls_mac_get_id (const char *name)
813} 813}
814 814
815/** 815/**
816 * gnutls_mac_get_key_size - Returns the length of the MAC's key size 816 * MHD_gnutls_mac_get_key_size - Returns the length of the MAC's key size
817 * @algorithm: is an encryption algorithm 817 * @algorithm: is an encryption algorithm
818 * 818 *
819 * Returns: length (in bytes) of the given MAC key size, or 0 if the 819 * Returns: length (in bytes) of the given MAC key size, or 0 if the
@@ -821,7 +821,7 @@ gnutls_mac_get_id (const char *name)
821 * 821 *
822 **/ 822 **/
823size_t 823size_t
824gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm) 824MHD_gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm)
825{ 825{
826 size_t ret = 0; 826 size_t ret = 0;
827 827
@@ -832,7 +832,7 @@ gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm)
832} 832}
833 833
834/** 834/**
835 * gnutls_mac_list: 835 * MHD_gtls_mac_list:
836 * 836 *
837 * Get a list of hash algorithms for use as MACs. Note that not 837 * Get a list of hash algorithms for use as MACs. Note that not
838 * necessarily all MACs are supported in TLS cipher suites. For 838 * necessarily all MACs are supported in TLS cipher suites. For
@@ -843,13 +843,13 @@ gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm)
843 * integers indicating the available MACs. 843 * integers indicating the available MACs.
844 **/ 844 **/
845const gnutls_mac_algorithm_t * 845const gnutls_mac_algorithm_t *
846gnutls_mac_list (void) 846MHD_gtls_mac_list (void)
847{ 847{
848 return supported_macs; 848 return supported_macs;
849} 849}
850 850
851const char * 851const char *
852_gnutls_x509_mac_to_oid (gnutls_mac_algorithm_t algorithm) 852mhd_gtls_x509_mac_to_oid (gnutls_mac_algorithm_t algorithm)
853{ 853{
854 const char *ret = NULL; 854 const char *ret = NULL;
855 855
@@ -860,7 +860,7 @@ _gnutls_x509_mac_to_oid (gnutls_mac_algorithm_t algorithm)
860} 860}
861 861
862gnutls_mac_algorithm_t 862gnutls_mac_algorithm_t
863_gnutls_x509_oid2mac_algorithm (const char *oid) 863mhd_gtls_x509_oid2mac_algorithm (const char *oid)
864{ 864{
865 gnutls_mac_algorithm_t ret = 0; 865 gnutls_mac_algorithm_t ret = 0;
866 866
@@ -876,7 +876,7 @@ _gnutls_x509_oid2mac_algorithm (const char *oid)
876} 876}
877 877
878int 878int
879_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm) 879mhd_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm)
880{ 880{
881 ssize_t ret = -1; 881 ssize_t ret = -1;
882 GNUTLS_HASH_ALG_LOOP (ret = p->id); 882 GNUTLS_HASH_ALG_LOOP (ret = p->id);
@@ -889,7 +889,7 @@ _gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm)
889 889
890/* Compression Functions */ 890/* Compression Functions */
891int 891int
892_gnutls_compression_priority (gnutls_session_t session, 892mhd_gtls_compression_priority (mhd_gtls_session_t session,
893 gnutls_compression_method_t algorithm) 893 gnutls_compression_method_t algorithm)
894{ /* actually returns the priority */ 894{ /* actually returns the priority */
895 unsigned int i; 895 unsigned int i;
@@ -902,14 +902,14 @@ _gnutls_compression_priority (gnutls_session_t session,
902} 902}
903 903
904/** 904/**
905 * gnutls_compression_get_name - Returns a string with the name of the specified compression algorithm 905 * MHD_gnutls_compression_get_name - Returns a string with the name of the specified compression algorithm
906 * @algorithm: is a Compression algorithm 906 * @algorithm: is a Compression algorithm
907 * 907 *
908 * Returns: a pointer to a string that contains the name of the 908 * Returns: a pointer to a string that contains the name of the
909 * specified compression algorithm, or %NULL. 909 * specified compression algorithm, or %NULL.
910 **/ 910 **/
911const char * 911const char *
912gnutls_compression_get_name (gnutls_compression_method_t algorithm) 912MHD_gnutls_compression_get_name (gnutls_compression_method_t algorithm)
913{ 913{
914 const char *ret = NULL; 914 const char *ret = NULL;
915 915
@@ -920,7 +920,7 @@ gnutls_compression_get_name (gnutls_compression_method_t algorithm)
920} 920}
921 921
922/** 922/**
923 * gnutls_compression_get_id - Returns the gnutls id of the specified in string algorithm 923 * MHD_gtls_compression_get_id - Returns the gnutls id of the specified in string algorithm
924 * @algorithm: is a compression method name 924 * @algorithm: is a compression method name
925 * 925 *
926 * The names are compared in a case insensitive way. 926 * The names are compared in a case insensitive way.
@@ -930,7 +930,7 @@ gnutls_compression_get_name (gnutls_compression_method_t algorithm)
930 * 930 *
931 **/ 931 **/
932gnutls_compression_method_t 932gnutls_compression_method_t
933gnutls_compression_get_id (const char *name) 933MHD_gtls_compression_get_id (const char *name)
934{ 934{
935 gnutls_compression_method_t ret = MHD_GNUTLS_COMP_UNKNOWN; 935 gnutls_compression_method_t ret = MHD_GNUTLS_COMP_UNKNOWN;
936 936
@@ -944,7 +944,7 @@ gnutls_compression_get_id (const char *name)
944} 944}
945 945
946/** 946/**
947 * gnutls_compression_list: 947 * MHD_gtls_compression_list:
948 * 948 *
949 * Get a list of compression methods. Note that to be able to use LZO 949 * Get a list of compression methods. Note that to be able to use LZO
950 * compression, you must link to libgnutls-extra and call 950 * compression, you must link to libgnutls-extra and call
@@ -954,14 +954,14 @@ gnutls_compression_get_id (const char *name)
954 * integers indicating the available compression methods. 954 * integers indicating the available compression methods.
955 **/ 955 **/
956const gnutls_compression_method_t * 956const gnutls_compression_method_t *
957gnutls_compression_list (void) 957MHD_gtls_compression_list (void)
958{ 958{
959 return supported_compressions; 959 return supported_compressions;
960} 960}
961 961
962/* return the tls number of the specified algorithm */ 962/* return the tls number of the specified algorithm */
963int 963int
964_gnutls_compression_get_num (gnutls_compression_method_t algorithm) 964mhd_gtls_compression_get_num (gnutls_compression_method_t algorithm)
965{ 965{
966 int ret = -1; 966 int ret = -1;
967 967
@@ -972,7 +972,7 @@ _gnutls_compression_get_num (gnutls_compression_method_t algorithm)
972} 972}
973 973
974int 974int
975_gnutls_compression_get_wbits (gnutls_compression_method_t algorithm) 975mhd_gtls_compression_get_wbits (gnutls_compression_method_t algorithm)
976{ 976{
977 int ret = -1; 977 int ret = -1;
978 /* avoid prefix */ 978 /* avoid prefix */
@@ -981,7 +981,7 @@ _gnutls_compression_get_wbits (gnutls_compression_method_t algorithm)
981} 981}
982 982
983int 983int
984_gnutls_compression_get_mem_level (gnutls_compression_method_t algorithm) 984mhd_gtls_compression_get_mem_level (gnutls_compression_method_t algorithm)
985{ 985{
986 int ret = -1; 986 int ret = -1;
987 /* avoid prefix */ 987 /* avoid prefix */
@@ -990,7 +990,7 @@ _gnutls_compression_get_mem_level (gnutls_compression_method_t algorithm)
990} 990}
991 991
992int 992int
993_gnutls_compression_get_comp_level (gnutls_compression_method_t algorithm) 993mhd_gtls_compression_get_comp_level (gnutls_compression_method_t algorithm)
994{ 994{
995 int ret = -1; 995 int ret = -1;
996 /* avoid prefix */ 996 /* avoid prefix */
@@ -1002,7 +1002,7 @@ _gnutls_compression_get_comp_level (gnutls_compression_method_t algorithm)
1002 * method num 1002 * method num
1003 */ 1003 */
1004gnutls_compression_method_t 1004gnutls_compression_method_t
1005_gnutls_compression_get_id (int num) 1005mhd_gtls_compression_get_id (int num)
1006{ 1006{
1007 gnutls_compression_method_t ret = -1; 1007 gnutls_compression_method_t ret = -1;
1008 1008
@@ -1013,7 +1013,7 @@ _gnutls_compression_get_id (int num)
1013} 1013}
1014 1014
1015int 1015int
1016_gnutls_compression_is_ok (gnutls_compression_method_t algorithm) 1016mhd_gtls_compression_is_ok (gnutls_compression_method_t algorithm)
1017{ 1017{
1018 ssize_t ret = -1; 1018 ssize_t ret = -1;
1019 GNUTLS_COMPRESSION_ALG_LOOP (ret = p->id); 1019 GNUTLS_COMPRESSION_ALG_LOOP (ret = p->id);
@@ -1026,7 +1026,7 @@ _gnutls_compression_is_ok (gnutls_compression_method_t algorithm)
1026 1026
1027/* CIPHER functions */ 1027/* CIPHER functions */
1028int 1028int
1029_gnutls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm) 1029mhd_gtls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm)
1030{ 1030{
1031 size_t ret = 0; 1031 size_t ret = 0;
1032 GNUTLS_ALG_LOOP (ret = p->blocksize); 1032 GNUTLS_ALG_LOOP (ret = p->blocksize);
@@ -1036,7 +1036,7 @@ _gnutls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm)
1036 1036
1037/* returns the priority */ 1037/* returns the priority */
1038int 1038int
1039_gnutls_cipher_priority (gnutls_session_t session, 1039mhd_gtls_cipher_priority (mhd_gtls_session_t session,
1040 gnutls_cipher_algorithm_t algorithm) 1040 gnutls_cipher_algorithm_t algorithm)
1041{ 1041{
1042 unsigned int i; 1042 unsigned int i;
@@ -1049,7 +1049,7 @@ _gnutls_cipher_priority (gnutls_session_t session,
1049} 1049}
1050 1050
1051int 1051int
1052_gnutls_cipher_is_block (gnutls_cipher_algorithm_t algorithm) 1052mhd_gtls_cipher_is_block (gnutls_cipher_algorithm_t algorithm)
1053{ 1053{
1054 size_t ret = 0; 1054 size_t ret = 0;
1055 1055
@@ -1059,14 +1059,14 @@ _gnutls_cipher_is_block (gnutls_cipher_algorithm_t algorithm)
1059} 1059}
1060 1060
1061/** 1061/**
1062 * gnutls_cipher_get_key_size - Returns the length of the cipher's key size 1062 * MHD_gnutls_cipher_get_key_size - Returns the length of the cipher's key size
1063 * @algorithm: is an encryption algorithm 1063 * @algorithm: is an encryption algorithm
1064 * 1064 *
1065 * Returns: length (in bytes) of the given cipher's key size, o 0 if 1065 * Returns: length (in bytes) of the given cipher's key size, o 0 if
1066 * the given cipher is invalid. 1066 * the given cipher is invalid.
1067 **/ 1067 **/
1068size_t 1068size_t
1069gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm) 1069MHD_gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm)
1070{ /* In bytes */ 1070{ /* In bytes */
1071 size_t ret = 0; 1071 size_t ret = 0;
1072 GNUTLS_ALG_LOOP (ret = p->keysize); 1072 GNUTLS_ALG_LOOP (ret = p->keysize);
@@ -1075,7 +1075,7 @@ gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm)
1075} 1075}
1076 1076
1077int 1077int
1078_gnutls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm) 1078mhd_gtls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm)
1079{ /* In bytes */ 1079{ /* In bytes */
1080 size_t ret = 0; 1080 size_t ret = 0;
1081 GNUTLS_ALG_LOOP (ret = p->iv); 1081 GNUTLS_ALG_LOOP (ret = p->iv);
@@ -1084,7 +1084,7 @@ _gnutls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm)
1084} 1084}
1085 1085
1086int 1086int
1087_gnutls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm) 1087mhd_gtls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm)
1088{ /* In bytes */ 1088{ /* In bytes */
1089 size_t ret = 0; 1089 size_t ret = 0;
1090 GNUTLS_ALG_LOOP (ret = p->export_flag); 1090 GNUTLS_ALG_LOOP (ret = p->export_flag);
@@ -1093,14 +1093,14 @@ _gnutls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm)
1093} 1093}
1094 1094
1095/** 1095/**
1096 * gnutls_cipher_get_name - Returns a string with the name of the specified cipher algorithm 1096 * MHD_gnutls_cipher_get_name - Returns a string with the name of the specified cipher algorithm
1097 * @algorithm: is an encryption algorithm 1097 * @algorithm: is an encryption algorithm
1098 * 1098 *
1099 * Returns: a pointer to a string that contains the name of the 1099 * Returns: a pointer to a string that contains the name of the
1100 * specified cipher, or %NULL. 1100 * specified cipher, or %NULL.
1101 **/ 1101 **/
1102const char * 1102const char *
1103gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm) 1103MHD_gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm)
1104{ 1104{
1105 const char *ret = NULL; 1105 const char *ret = NULL;
1106 1106
@@ -1111,7 +1111,7 @@ gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm)
1111} 1111}
1112 1112
1113/** 1113/**
1114 * gnutls_cipher_get_id - Returns the gnutls id of the specified in string algorithm 1114 * MHD_gtls_cipher_get_id - Returns the gnutls id of the specified in string algorithm
1115 * @algorithm: is a MAC algorithm name 1115 * @algorithm: is a MAC algorithm name
1116 * 1116 *
1117 * The names are compared in a case insensitive way. 1117 * The names are compared in a case insensitive way.
@@ -1121,7 +1121,7 @@ gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm)
1121 * 1121 *
1122 **/ 1122 **/
1123gnutls_cipher_algorithm_t 1123gnutls_cipher_algorithm_t
1124gnutls_cipher_get_id (const char *name) 1124MHD_gtls_cipher_get_id (const char *name)
1125{ 1125{
1126 gnutls_cipher_algorithm_t ret = MHD_GNUTLS_CIPHER_UNKNOWN; 1126 gnutls_cipher_algorithm_t ret = MHD_GNUTLS_CIPHER_UNKNOWN;
1127 1127
@@ -1132,7 +1132,7 @@ gnutls_cipher_get_id (const char *name)
1132} 1132}
1133 1133
1134/** 1134/**
1135 * gnutls_cipher_list: 1135 * MHD_gtls_cipher_list:
1136 * 1136 *
1137 * Get a list of supported cipher algorithms. Note that not 1137 * Get a list of supported cipher algorithms. Note that not
1138 * necessarily all ciphers are supported as TLS cipher suites. For 1138 * necessarily all ciphers are supported as TLS cipher suites. For
@@ -1144,13 +1144,13 @@ gnutls_cipher_get_id (const char *name)
1144 * 1144 *
1145 **/ 1145 **/
1146const gnutls_cipher_algorithm_t * 1146const gnutls_cipher_algorithm_t *
1147gnutls_cipher_list (void) 1147MHD_gtls_cipher_list (void)
1148{ 1148{
1149 return supported_ciphers; 1149 return supported_ciphers;
1150} 1150}
1151 1151
1152int 1152int
1153_gnutls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm) 1153mhd_gtls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm)
1154{ 1154{
1155 ssize_t ret = -1; 1155 ssize_t ret = -1;
1156 GNUTLS_ALG_LOOP (ret = p->id); 1156 GNUTLS_ALG_LOOP (ret = p->id);
@@ -1162,17 +1162,17 @@ _gnutls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm)
1162} 1162}
1163 1163
1164/* Key EXCHANGE functions */ 1164/* Key EXCHANGE functions */
1165mod_auth_st * 1165mhd_gtls_mod_auth_st *
1166_gnutls_kx_auth_struct (gnutls_kx_algorithm_t algorithm) 1166mhd_gtls_kx_auth_struct (gnutls_kx_algorithm_t algorithm)
1167{ 1167{
1168 mod_auth_st *ret = NULL; 1168 mhd_gtls_mod_auth_st *ret = NULL;
1169 GNUTLS_KX_ALG_LOOP (ret = p->auth_struct); 1169 GNUTLS_KX_ALG_LOOP (ret = p->auth_struct);
1170 return ret; 1170 return ret;
1171 1171
1172} 1172}
1173 1173
1174int 1174int
1175_gnutls_kx_priority (gnutls_session_t session, 1175mhd_gtls_kx_priority (mhd_gtls_session_t session,
1176 gnutls_kx_algorithm_t algorithm) 1176 gnutls_kx_algorithm_t algorithm)
1177{ 1177{
1178 unsigned int i; 1178 unsigned int i;
@@ -1185,14 +1185,14 @@ _gnutls_kx_priority (gnutls_session_t session,
1185} 1185}
1186 1186
1187/** 1187/**
1188 * gnutls_kx_get_name - Returns a string with the name of the specified key exchange algorithm 1188 * MHD_gnutls_kx_get_name - Returns a string with the name of the specified key exchange algorithm
1189 * @algorithm: is a key exchange algorithm 1189 * @algorithm: is a key exchange algorithm
1190 * 1190 *
1191 * Returns: a pointer to a string that contains the name of the 1191 * Returns: a pointer to a string that contains the name of the
1192 * specified key exchange algorithm, or %NULL. 1192 * specified key exchange algorithm, or %NULL.
1193 **/ 1193 **/
1194const char * 1194const char *
1195gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm) 1195MHD_gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm)
1196{ 1196{
1197 const char *ret = NULL; 1197 const char *ret = NULL;
1198 1198
@@ -1203,7 +1203,7 @@ gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm)
1203} 1203}
1204 1204
1205/** 1205/**
1206 * gnutls_kx_get_id - Returns the gnutls id of the specified in string algorithm 1206 * MHD_gtls_kx_get_id - Returns the gnutls id of the specified in string algorithm
1207 * @algorithm: is a KX name 1207 * @algorithm: is a KX name
1208 * 1208 *
1209 * The names are compared in a case insensitive way. 1209 * The names are compared in a case insensitive way.
@@ -1212,7 +1212,7 @@ gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm)
1212 * %GNUTLS_KX_UNKNOWN on error. 1212 * %GNUTLS_KX_UNKNOWN on error.
1213 **/ 1213 **/
1214gnutls_kx_algorithm_t 1214gnutls_kx_algorithm_t
1215gnutls_kx_get_id (const char *name) 1215MHD_gtls_kx_get_id (const char *name)
1216{ 1216{
1217 gnutls_cipher_algorithm_t ret = MHD_GNUTLS_KX_UNKNOWN; 1217 gnutls_cipher_algorithm_t ret = MHD_GNUTLS_KX_UNKNOWN;
1218 1218
@@ -1223,7 +1223,7 @@ gnutls_kx_get_id (const char *name)
1223} 1223}
1224 1224
1225/** 1225/**
1226 * gnutls_kx_list: 1226 * MHD_gtls_kx_list:
1227 * 1227 *
1228 * Get a list of supported key exchange algorithms. 1228 * Get a list of supported key exchange algorithms.
1229 * 1229 *
@@ -1231,13 +1231,13 @@ gnutls_kx_get_id (const char *name)
1231 * indicating the available key exchange algorithms. 1231 * indicating the available key exchange algorithms.
1232 **/ 1232 **/
1233const gnutls_kx_algorithm_t * 1233const gnutls_kx_algorithm_t *
1234gnutls_kx_list (void) 1234MHD_gtls_kx_list (void)
1235{ 1235{
1236 return supported_kxs; 1236 return supported_kxs;
1237} 1237}
1238 1238
1239int 1239int
1240_gnutls_kx_is_ok (gnutls_kx_algorithm_t algorithm) 1240mhd_gtls_kx_is_ok (gnutls_kx_algorithm_t algorithm)
1241{ 1241{
1242 ssize_t ret = -1; 1242 ssize_t ret = -1;
1243 GNUTLS_KX_ALG_LOOP (ret = p->algorithm); 1243 GNUTLS_KX_ALG_LOOP (ret = p->algorithm);
@@ -1249,7 +1249,7 @@ _gnutls_kx_is_ok (gnutls_kx_algorithm_t algorithm)
1249} 1249}
1250 1250
1251int 1251int
1252_gnutls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm) 1252mhd_gtls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm)
1253{ 1253{
1254 ssize_t ret = 0; 1254 ssize_t ret = 0;
1255 GNUTLS_KX_ALG_LOOP (ret = p->needs_rsa_params); 1255 GNUTLS_KX_ALG_LOOP (ret = p->needs_rsa_params);
@@ -1257,7 +1257,7 @@ _gnutls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm)
1257} 1257}
1258 1258
1259int 1259int
1260_gnutls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm) 1260mhd_gtls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm)
1261{ 1261{
1262 ssize_t ret = 0; 1262 ssize_t ret = 0;
1263 GNUTLS_KX_ALG_LOOP (ret = p->needs_dh_params); 1263 GNUTLS_KX_ALG_LOOP (ret = p->needs_dh_params);
@@ -1266,7 +1266,7 @@ _gnutls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm)
1266 1266
1267/* Version */ 1267/* Version */
1268int 1268int
1269_gnutls_version_priority (gnutls_session_t session, gnutls_protocol_t version) 1269mhd_gtls_version_priority (mhd_gtls_session_t session, gnutls_protocol_t version)
1270{ /* actually returns the priority */ 1270{ /* actually returns the priority */
1271 unsigned int i; 1271 unsigned int i;
1272 1272
@@ -1285,7 +1285,7 @@ _gnutls_version_priority (gnutls_session_t session, gnutls_protocol_t version)
1285} 1285}
1286 1286
1287gnutls_protocol_t 1287gnutls_protocol_t
1288_gnutls_version_lowest (gnutls_session_t session) 1288mhd_gtls_version_lowest (mhd_gtls_session_t session)
1289{ /* returns the lowest version supported */ 1289{ /* returns the lowest version supported */
1290 unsigned int i, min = 0xff; 1290 unsigned int i, min = 0xff;
1291 1291
@@ -1307,7 +1307,7 @@ _gnutls_version_lowest (gnutls_session_t session)
1307} 1307}
1308 1308
1309gnutls_protocol_t 1309gnutls_protocol_t
1310_gnutls_version_max (gnutls_session_t session) 1310mhd_gtls_version_max (mhd_gtls_session_t session)
1311{ /* returns the maximum version supported */ 1311{ /* returns the maximum version supported */
1312 unsigned int i, max = 0x00; 1312 unsigned int i, max = 0x00;
1313 1313
@@ -1329,14 +1329,14 @@ _gnutls_version_max (gnutls_session_t session)
1329} 1329}
1330 1330
1331/** 1331/**
1332 * gnutls_protocol_get_name - Returns a string with the name of the specified SSL/TLS version 1332 * MHD_gnutls_protocol_get_name - Returns a string with the name of the specified SSL/TLS version
1333 * @version: is a (gnutls) version number 1333 * @version: is a (gnutls) version number
1334 * 1334 *
1335 * Returns: a string that contains the name of the specified TLS 1335 * Returns: a string that contains the name of the specified TLS
1336 * version (e.g., "TLS 1.0"), or %NULL. 1336 * version (e.g., "TLS 1.0"), or %NULL.
1337 **/ 1337 **/
1338const char * 1338const char *
1339gnutls_protocol_get_name (gnutls_protocol_t version) 1339MHD_gnutls_protocol_get_name (gnutls_protocol_t version)
1340{ 1340{
1341 const char *ret = NULL; 1341 const char *ret = NULL;
1342 1342
@@ -1346,7 +1346,7 @@ gnutls_protocol_get_name (gnutls_protocol_t version)
1346} 1346}
1347 1347
1348/** 1348/**
1349 * gnutls_protocol_get_id - Returns the gnutls id of the specified in string protocol 1349 * MHD_gtls_protocol_get_id - Returns the gnutls id of the specified in string protocol
1350 * @algorithm: is a protocol name 1350 * @algorithm: is a protocol name
1351 * 1351 *
1352 * The names are compared in a case insensitive way. 1352 * The names are compared in a case insensitive way.
@@ -1355,7 +1355,7 @@ gnutls_protocol_get_name (gnutls_protocol_t version)
1355 * %GNUTLS_VERSION_UNKNOWN on error. 1355 * %GNUTLS_VERSION_UNKNOWN on error.
1356 **/ 1356 **/
1357gnutls_protocol_t 1357gnutls_protocol_t
1358gnutls_protocol_get_id (const char *name) 1358MHD_gtls_protocol_get_id (const char *name)
1359{ 1359{
1360 gnutls_protocol_t ret = MHD_GNUTLS_VERSION_UNKNOWN; 1360 gnutls_protocol_t ret = MHD_GNUTLS_VERSION_UNKNOWN;
1361 1361
@@ -1366,7 +1366,7 @@ gnutls_protocol_get_id (const char *name)
1366} 1366}
1367 1367
1368/** 1368/**
1369 * gnutls_protocol_list: 1369 * MHD_gtls_protocol_list:
1370 * 1370 *
1371 * Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc. 1371 * Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc.
1372 * 1372 *
@@ -1375,13 +1375,13 @@ gnutls_protocol_get_id (const char *name)
1375 * 1375 *
1376 **/ 1376 **/
1377const gnutls_protocol_t * 1377const gnutls_protocol_t *
1378gnutls_protocol_list (void) 1378MHD_gtls_protocol_list (void)
1379{ 1379{
1380 return supported_protocols; 1380 return supported_protocols;
1381} 1381}
1382 1382
1383int 1383int
1384_gnutls_version_get_minor (gnutls_protocol_t version) 1384mhd_gtls_version_get_minor (gnutls_protocol_t version)
1385{ 1385{
1386 int ret = -1; 1386 int ret = -1;
1387 1387
@@ -1390,7 +1390,7 @@ _gnutls_version_get_minor (gnutls_protocol_t version)
1390} 1390}
1391 1391
1392gnutls_protocol_t 1392gnutls_protocol_t
1393_gnutls_version_get (int major, int minor) 1393mhd_gtls_version_get (int major, int minor)
1394{ 1394{
1395 int ret = -1; 1395 int ret = -1;
1396 1396
@@ -1401,7 +1401,7 @@ _gnutls_version_get (int major, int minor)
1401} 1401}
1402 1402
1403int 1403int
1404_gnutls_version_get_major (gnutls_protocol_t version) 1404mhd_gtls_version_get_major (gnutls_protocol_t version)
1405{ 1405{
1406 int ret = -1; 1406 int ret = -1;
1407 1407
@@ -1412,7 +1412,7 @@ _gnutls_version_get_major (gnutls_protocol_t version)
1412/* Version Functions */ 1412/* Version Functions */
1413 1413
1414int 1414int
1415_gnutls_version_is_supported (gnutls_session_t session, 1415mhd_gtls_version_is_supported (mhd_gtls_session_t session,
1416 const gnutls_protocol_t version) 1416 const gnutls_protocol_t version)
1417{ 1417{
1418 int ret = 0; 1418 int ret = 0;
@@ -1421,7 +1421,7 @@ _gnutls_version_is_supported (gnutls_session_t session,
1421 if (ret == 0) 1421 if (ret == 0)
1422 return 0; 1422 return 0;
1423 1423
1424 if (_gnutls_version_priority (session, version) < 0) 1424 if (mhd_gtls_version_priority (session, version) < 0)
1425 return 0; /* disabled by the user */ 1425 return 0; /* disabled by the user */
1426 else 1426 else
1427 return 1; 1427 return 1;
@@ -1429,7 +1429,7 @@ _gnutls_version_is_supported (gnutls_session_t session,
1429 1429
1430/* Type to KX mappings */ 1430/* Type to KX mappings */
1431gnutls_kx_algorithm_t 1431gnutls_kx_algorithm_t
1432_gnutls_map_kx_get_kx (gnutls_credentials_type_t type, int server) 1432mhd_gtls_map_kx_get_kx (gnutls_credentials_type_t type, int server)
1433{ 1433{
1434 gnutls_kx_algorithm_t ret = -1; 1434 gnutls_kx_algorithm_t ret = -1;
1435 1435
@@ -1445,7 +1445,7 @@ _gnutls_map_kx_get_kx (gnutls_credentials_type_t type, int server)
1445} 1445}
1446 1446
1447gnutls_credentials_type_t 1447gnutls_credentials_type_t
1448_gnutls_map_kx_get_cred (gnutls_kx_algorithm_t algorithm, int server) 1448mhd_gtls_map_kx_get_cred (gnutls_kx_algorithm_t algorithm, int server)
1449{ 1449{
1450 gnutls_credentials_type_t ret = -1; 1450 gnutls_credentials_type_t ret = -1;
1451 if (server) 1451 if (server)
@@ -1464,7 +1464,7 @@ _gnutls_map_kx_get_cred (gnutls_kx_algorithm_t algorithm, int server)
1464 1464
1465/* Cipher Suite's functions */ 1465/* Cipher Suite's functions */
1466gnutls_cipher_algorithm_t 1466gnutls_cipher_algorithm_t
1467_gnutls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite) 1467mhd_gtls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite)
1468{ 1468{
1469 int ret = 0; 1469 int ret = 0;
1470 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->block_algorithm); 1470 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->block_algorithm);
@@ -1472,7 +1472,7 @@ _gnutls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite)
1472} 1472}
1473 1473
1474gnutls_protocol_t 1474gnutls_protocol_t
1475_gnutls_cipher_suite_get_version (const cipher_suite_st * suite) 1475mhd_gtls_cipher_suite_get_version (const cipher_suite_st * suite)
1476{ 1476{
1477 int ret = 0; 1477 int ret = 0;
1478 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->version); 1478 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->version);
@@ -1480,7 +1480,7 @@ _gnutls_cipher_suite_get_version (const cipher_suite_st * suite)
1480} 1480}
1481 1481
1482gnutls_kx_algorithm_t 1482gnutls_kx_algorithm_t
1483_gnutls_cipher_suite_get_kx_algo (const cipher_suite_st * suite) 1483mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st * suite)
1484{ 1484{
1485 int ret = 0; 1485 int ret = 0;
1486 1486
@@ -1490,7 +1490,7 @@ _gnutls_cipher_suite_get_kx_algo (const cipher_suite_st * suite)
1490} 1490}
1491 1491
1492gnutls_mac_algorithm_t 1492gnutls_mac_algorithm_t
1493_gnutls_cipher_suite_get_mac_algo (const cipher_suite_st * suite) 1493mhd_gtls_cipher_suite_get_mac_algo (const cipher_suite_st * suite)
1494{ /* In bytes */ 1494{ /* In bytes */
1495 int ret = 0; 1495 int ret = 0;
1496 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->mac_algorithm); 1496 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->mac_algorithm);
@@ -1499,7 +1499,7 @@ _gnutls_cipher_suite_get_mac_algo (const cipher_suite_st * suite)
1499} 1499}
1500 1500
1501const char * 1501const char *
1502_gnutls_cipher_suite_get_name (cipher_suite_st * suite) 1502mhd_gtls_cipher_suite_get_name (cipher_suite_st * suite)
1503{ 1503{
1504 const char *ret = NULL; 1504 const char *ret = NULL;
1505 1505
@@ -1509,78 +1509,6 @@ _gnutls_cipher_suite_get_name (cipher_suite_st * suite)
1509 return ret; 1509 return ret;
1510} 1510}
1511 1511
1512/**
1513 * gnutls_cipher_suite_get_name - Returns a string with the name of the specified cipher suite
1514 * @kx_algorithm: is a Key exchange algorithm
1515 * @cipher_algorithm: is a cipher algorithm
1516 * @mac_algorithm: is a MAC algorithm
1517 *
1518 * Note that the full cipher suite name must be prepended by TLS or
1519 * SSL depending of the protocol in use.
1520 *
1521 * Returns: a string that contains the name of a TLS cipher suite,
1522 * specified by the given algorithms, or %NULL.
1523 **/
1524const char *
1525gnutls_cipher_suite_get_name (gnutls_kx_algorithm_t kx_algorithm,
1526 gnutls_cipher_algorithm_t cipher_algorithm,
1527 gnutls_mac_algorithm_t mac_algorithm)
1528{
1529 const char *ret = NULL;
1530
1531 /* avoid prefix */
1532 GNUTLS_CIPHER_SUITE_LOOP (if (kx_algorithm == p->kx_algorithm &&
1533 cipher_algorithm == p->block_algorithm &&
1534 mac_algorithm == p->mac_algorithm)
1535 ret = p->name + sizeof ("GNUTLS_") - 1)
1536 ;
1537
1538 return ret;
1539}
1540
1541/**
1542 * gnutls_cipher_suite_info:
1543 * @idx: index of cipher suite to get information about, starts on 0.
1544 * @cs_id: output buffer with room for 2 bytes, indicating cipher suite value
1545 * @kx: output variable indicating key exchange algorithm, or %NULL.
1546 * @cipher: output variable indicating cipher, or %NULL.
1547 * @mac: output variable indicating MAC algorithm, or %NULL.
1548 * @version: output variable indicating TLS protocol version, or %NULL.
1549 *
1550 * Get information about supported cipher suites. Use the function
1551 * iteratively to get information about all supported cipher suites.
1552 * Call with idx=0 to get information about first cipher suite, then
1553 * idx=1 and so on until the function returns NULL.
1554 *
1555 * Returns: the name of @idx cipher suite, and set the information
1556 * about the cipher suite in the output variables. If @idx is out of
1557 * bounds, %NULL is returned.
1558 **/
1559const char *
1560gnutls_cipher_suite_info (size_t idx,
1561 char *cs_id,
1562 gnutls_kx_algorithm_t * kx,
1563 gnutls_cipher_algorithm_t * cipher,
1564 gnutls_mac_algorithm_t * mac,
1565 gnutls_protocol_t * version)
1566{
1567 if (idx >= CIPHER_SUITES_COUNT)
1568 return NULL;
1569
1570 if (cs_id)
1571 memcpy (cs_id, cs_algorithms[idx].id.suite, 2);
1572 if (kx)
1573 *kx = cs_algorithms[idx].kx_algorithm;
1574 if (cipher)
1575 *cipher = cs_algorithms[idx].block_algorithm;
1576 if (mac)
1577 *mac = cs_algorithms[idx].mac_algorithm;
1578 if (version)
1579 *version = cs_algorithms[idx].version;
1580
1581 return cs_algorithms[idx].name + sizeof ("GNU") - 1;
1582}
1583
1584static inline int 1512static inline int
1585_gnutls_cipher_suite_is_ok (cipher_suite_st * suite) 1513_gnutls_cipher_suite_is_ok (cipher_suite_st * suite)
1586{ 1514{
@@ -1602,11 +1530,11 @@ _gnutls_cipher_suite_is_ok (cipher_suite_st * suite)
1602 1530
1603#define MAX_ELEM_SIZE 4 1531#define MAX_ELEM_SIZE 4
1604static inline int 1532static inline int
1605_gnutls_partition (gnutls_session_t session, 1533_gnutls_partition (mhd_gtls_session_t session,
1606 void *_base, 1534 void *_base,
1607 size_t nmemb, 1535 size_t nmemb,
1608 size_t size, 1536 size_t size,
1609 int (*compar) (gnutls_session_t, 1537 int (*compar) (mhd_gtls_session_t,
1610 const void *, const void *)) 1538 const void *, const void *))
1611{ 1539{
1612 uint8_t *base = _base; 1540 uint8_t *base = _base;
@@ -1650,11 +1578,11 @@ _gnutls_partition (gnutls_session_t session,
1650} 1578}
1651 1579
1652static void 1580static void
1653_gnutls_qsort (gnutls_session_t session, 1581_gnutls_qsort (mhd_gtls_session_t session,
1654 void *_base, 1582 void *_base,
1655 size_t nmemb, 1583 size_t nmemb,
1656 size_t size, 1584 size_t size,
1657 int (*compar) (gnutls_session_t, const void *, const void *)) 1585 int (*compar) (mhd_gtls_session_t, const void *, const void *))
1658{ 1586{
1659 unsigned int pivot; 1587 unsigned int pivot;
1660 char *base = _base; 1588 char *base = _base;
@@ -1683,28 +1611,28 @@ _gnutls_qsort (gnutls_session_t session,
1683 * For use with qsort 1611 * For use with qsort
1684 */ 1612 */
1685static int 1613static int
1686_gnutls_compare_algo (gnutls_session_t session, 1614_gnutls_compare_algo (mhd_gtls_session_t session,
1687 const void *i_A1, const void *i_A2) 1615 const void *i_A1, const void *i_A2)
1688{ 1616{
1689 gnutls_kx_algorithm_t kA1 = 1617 gnutls_kx_algorithm_t kA1 =
1690 _gnutls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A1); 1618 mhd_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A1);
1691 gnutls_kx_algorithm_t kA2 = 1619 gnutls_kx_algorithm_t kA2 =
1692 _gnutls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A2); 1620 mhd_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A2);
1693 gnutls_cipher_algorithm_t cA1 = 1621 gnutls_cipher_algorithm_t cA1 =
1694 _gnutls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A1); 1622 mhd_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A1);
1695 gnutls_cipher_algorithm_t cA2 = 1623 gnutls_cipher_algorithm_t cA2 =
1696 _gnutls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A2); 1624 mhd_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A2);
1697 gnutls_mac_algorithm_t mA1 = 1625 gnutls_mac_algorithm_t mA1 =
1698 _gnutls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A1); 1626 mhd_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A1);
1699 gnutls_mac_algorithm_t mA2 = 1627 gnutls_mac_algorithm_t mA2 =
1700 _gnutls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A2); 1628 mhd_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A2);
1701 1629
1702 int p1 = (_gnutls_kx_priority (session, kA1) + 1) * 64; 1630 int p1 = (mhd_gtls_kx_priority (session, kA1) + 1) * 64;
1703 int p2 = (_gnutls_kx_priority (session, kA2) + 1) * 64; 1631 int p2 = (mhd_gtls_kx_priority (session, kA2) + 1) * 64;
1704 p1 += (_gnutls_cipher_priority (session, cA1) + 1) * 8; 1632 p1 += (mhd_gtls_cipher_priority (session, cA1) + 1) * 8;
1705 p2 += (_gnutls_cipher_priority (session, cA2) + 1) * 8; 1633 p2 += (mhd_gtls_cipher_priority (session, cA2) + 1) * 8;
1706 p1 += _gnutls_mac_priority (session, mA1); 1634 p1 += mhd_gtls_mac_priority (session, mA1);
1707 p2 += _gnutls_mac_priority (session, mA2); 1635 p2 += mhd_gtls_mac_priority (session, mA2);
1708 1636
1709 if (p1 > p2) 1637 if (p1 > p2)
1710 { 1638 {
@@ -1722,8 +1650,8 @@ _gnutls_compare_algo (gnutls_session_t session,
1722 1650
1723#ifdef SORT_DEBUG 1651#ifdef SORT_DEBUG
1724static void 1652static void
1725_gnutls_bsort (gnutls_session_t session, void *_base, size_t nmemb, 1653_gnutls_bsort (mhd_gtls_session_t session, void *_base, size_t nmemb,
1726 size_t size, int (*compar) (gnutls_session_t, const void *, 1654 size_t size, int (*compar) (mhd_gtls_session_t, const void *,
1727 const void *)) 1655 const void *))
1728{ 1656{
1729 unsigned int i, j; 1657 unsigned int i, j;
@@ -1746,7 +1674,7 @@ _gnutls_bsort (gnutls_session_t session, void *_base, size_t nmemb,
1746#endif 1674#endif
1747 1675
1748int 1676int
1749_gnutls_supported_ciphersuites_sorted (gnutls_session_t session, 1677mhd_gtls_supported_ciphersuites_sorted (mhd_gtls_session_t session,
1750 cipher_suite_st ** ciphers) 1678 cipher_suite_st ** ciphers)
1751{ 1679{
1752 1680
@@ -1755,7 +1683,7 @@ _gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
1755#endif 1683#endif
1756 int count; 1684 int count;
1757 1685
1758 count = _gnutls_supported_ciphersuites (session, ciphers); 1686 count = mhd_gtls_supported_ciphersuites (session, ciphers);
1759 if (count <= 0) 1687 if (count <= 0)
1760 { 1688 {
1761 gnutls_assert (); 1689 gnutls_assert ();
@@ -1765,7 +1693,7 @@ _gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
1765 _gnutls_debug_log ("Unsorted: \n"); 1693 _gnutls_debug_log ("Unsorted: \n");
1766 for (i = 0; i < count; i++) 1694 for (i = 0; i < count; i++)
1767 _gnutls_debug_log ("\t%d: %s\n", i, 1695 _gnutls_debug_log ("\t%d: %s\n", i,
1768 _gnutls_cipher_suite_get_name ((*ciphers)[i])); 1696 mhd_gtls_cipher_suite_get_name ((*ciphers)[i]));
1769#endif 1697#endif
1770 1698
1771 _gnutls_qsort (session, *ciphers, count, sizeof (cipher_suite_st), 1699 _gnutls_qsort (session, *ciphers, count, sizeof (cipher_suite_st),
@@ -1775,14 +1703,14 @@ _gnutls_supported_ciphersuites_sorted (gnutls_session_t session,
1775 _gnutls_debug_log ("Sorted: \n"); 1703 _gnutls_debug_log ("Sorted: \n");
1776 for (i = 0; i < count; i++) 1704 for (i = 0; i < count; i++)
1777 _gnutls_debug_log ("\t%d: %s\n", i, 1705 _gnutls_debug_log ("\t%d: %s\n", i,
1778 _gnutls_cipher_suite_get_name ((*ciphers)[i])); 1706 mhd_gtls_cipher_suite_get_name ((*ciphers)[i]));
1779#endif 1707#endif
1780 1708
1781 return count; 1709 return count;
1782} 1710}
1783 1711
1784int 1712int
1785_gnutls_supported_ciphersuites (gnutls_session_t session, 1713mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
1786 cipher_suite_st ** _ciphers) 1714 cipher_suite_st ** _ciphers)
1787{ 1715{
1788 1716
@@ -1808,7 +1736,7 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
1808 return GNUTLS_E_MEMORY_ERROR; 1736 return GNUTLS_E_MEMORY_ERROR;
1809 } 1737 }
1810 1738
1811 version = gnutls_protocol_get_version (session); 1739 version = MHD_gnutls_protocol_get_version (session);
1812 1740
1813 for (i = 0; i < count; i++) 1741 for (i = 0; i < count; i++)
1814 { 1742 {
@@ -1827,19 +1755,19 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
1827 /* remove cipher suites which do not support the 1755 /* remove cipher suites which do not support the
1828 * protocol version used. 1756 * protocol version used.
1829 */ 1757 */
1830 if (_gnutls_cipher_suite_get_version (&tmp_ciphers[i]) > version) 1758 if (mhd_gtls_cipher_suite_get_version (&tmp_ciphers[i]) > version)
1831 continue; 1759 continue;
1832 1760
1833 if (_gnutls_kx_priority (session, 1761 if (mhd_gtls_kx_priority (session,
1834 _gnutls_cipher_suite_get_kx_algo (&tmp_ciphers 1762 mhd_gtls_cipher_suite_get_kx_algo (&tmp_ciphers
1835 [i])) < 0) 1763 [i])) < 0)
1836 continue; 1764 continue;
1837 if (_gnutls_mac_priority (session, 1765 if (mhd_gtls_mac_priority (session,
1838 _gnutls_cipher_suite_get_mac_algo 1766 mhd_gtls_cipher_suite_get_mac_algo
1839 (&tmp_ciphers[i])) < 0) 1767 (&tmp_ciphers[i])) < 0)
1840 continue; 1768 continue;
1841 if (_gnutls_cipher_priority (session, 1769 if (mhd_gtls_cipher_priority (session,
1842 _gnutls_cipher_suite_get_cipher_algo 1770 mhd_gtls_cipher_suite_get_cipher_algo
1843 (&tmp_ciphers[i])) < 0) 1771 (&tmp_ciphers[i])) < 0)
1844 continue; 1772 continue;
1845 1773
@@ -1853,7 +1781,7 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
1853 if (ret_count > 0 && ret_count != count) 1781 if (ret_count > 0 && ret_count != count)
1854 { 1782 {
1855 ciphers = 1783 ciphers =
1856 gnutls_realloc_fast (ciphers, ret_count * sizeof (cipher_suite_st)); 1784 mhd_gtls_realloc_fast (ciphers, ret_count * sizeof (cipher_suite_st));
1857 } 1785 }
1858 else 1786 else
1859 { 1787 {
@@ -1888,7 +1816,7 @@ _gnutls_supported_ciphersuites (gnutls_session_t session,
1888 */ 1816 */
1889#define SUPPORTED_COMPRESSION_METHODS session->internals.priorities.compression.num_algorithms 1817#define SUPPORTED_COMPRESSION_METHODS session->internals.priorities.compression.num_algorithms
1890int 1818int
1891_gnutls_supported_compression_methods (gnutls_session_t session, 1819mhd_gtls_supported_compression_methods (mhd_gtls_session_t session,
1892 uint8_t ** comp) 1820 uint8_t ** comp)
1893{ 1821{
1894 unsigned int i, j; 1822 unsigned int i, j;
@@ -1899,7 +1827,7 @@ _gnutls_supported_compression_methods (gnutls_session_t session,
1899 1827
1900 for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++) 1828 for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++)
1901 { 1829 {
1902 int tmp = _gnutls_compression_get_num (session->internals.priorities. 1830 int tmp = mhd_gtls_compression_get_num (session->internals.priorities.
1903 compression.priority[i]); 1831 compression.priority[i]);
1904 1832
1905 /* remove private compression algorithms, if requested. 1833 /* remove private compression algorithms, if requested.
@@ -1926,14 +1854,14 @@ _gnutls_supported_compression_methods (gnutls_session_t session,
1926} 1854}
1927 1855
1928/** 1856/**
1929 * gnutls_certificate_type_get_name - Returns a string with the name of the specified certificate type 1857 * MHD_gnutls_certificate_type_get_name - Returns a string with the name of the specified certificate type
1930 * @type: is a certificate type 1858 * @type: is a certificate type
1931 * 1859 *
1932 * Returns: a string (or %NULL) that contains the name of the 1860 * Returns: a string (or %NULL) that contains the name of the
1933 * specified certificate type. 1861 * specified certificate type.
1934 **/ 1862 **/
1935const char * 1863const char *
1936gnutls_certificate_type_get_name (gnutls_certificate_type_t type) 1864MHD_gnutls_certificate_type_get_name (gnutls_certificate_type_t type)
1937{ 1865{
1938 const char *ret = NULL; 1866 const char *ret = NULL;
1939 1867
@@ -1946,7 +1874,7 @@ gnutls_certificate_type_get_name (gnutls_certificate_type_t type)
1946} 1874}
1947 1875
1948/** 1876/**
1949 * gnutls_certificate_type_get_id - Returns the gnutls id of the specified in string type 1877 * MHD_gtls_certificate_type_get_id - Returns the gnutls id of the specified in string type
1950 * @name: is a certificate type name 1878 * @name: is a certificate type name
1951 * 1879 *
1952 * The names are compared in a case insensitive way. 1880 * The names are compared in a case insensitive way.
@@ -1955,7 +1883,7 @@ gnutls_certificate_type_get_name (gnutls_certificate_type_t type)
1955 * %GNUTLS_CRT_UNKNOWN on error. 1883 * %GNUTLS_CRT_UNKNOWN on error.
1956 **/ 1884 **/
1957gnutls_certificate_type_t 1885gnutls_certificate_type_t
1958gnutls_certificate_type_get_id (const char *name) 1886MHD_gtls_certificate_type_get_id (const char *name)
1959{ 1887{
1960 gnutls_certificate_type_t ret = MHD_GNUTLS_CRT_UNKNOWN; 1888 gnutls_certificate_type_t ret = MHD_GNUTLS_CRT_UNKNOWN;
1961 1889
@@ -1974,7 +1902,7 @@ static const gnutls_certificate_type_t supported_certificate_types[] =
1974}; 1902};
1975 1903
1976/** 1904/**
1977 * gnutls_certificate_type_list: 1905 * MHD_gtls_certificate_type_list:
1978 * 1906 *
1979 * Get a list of certificate types. Note that to be able to use 1907 * Get a list of certificate types. Note that to be able to use
1980 * OpenPGP certificates, you must link to libgnutls-extra and call 1908 * OpenPGP certificates, you must link to libgnutls-extra and call
@@ -1985,7 +1913,7 @@ static const gnutls_certificate_type_t supported_certificate_types[] =
1985 * 1913 *
1986 **/ 1914 **/
1987const gnutls_certificate_type_t * 1915const gnutls_certificate_type_t *
1988gnutls_certificate_type_list (void) 1916MHD_gtls_certificate_type_list (void)
1989{ 1917{
1990 return supported_certificate_types; 1918 return supported_certificate_types;
1991} 1919}
@@ -1994,7 +1922,7 @@ gnutls_certificate_type_list (void)
1994 * the given gnutls_kx_algorithm_t. 1922 * the given gnutls_kx_algorithm_t.
1995 */ 1923 */
1996gnutls_pk_algorithm_t 1924gnutls_pk_algorithm_t
1997_gnutls_map_pk_get_pk (gnutls_kx_algorithm_t kx_algorithm) 1925mhd_gtls_map_pk_get_pk (gnutls_kx_algorithm_t kx_algorithm)
1998{ 1926{
1999 gnutls_pk_algorithm_t ret = -1; 1927 gnutls_pk_algorithm_t ret = -1;
2000 1928
@@ -2007,7 +1935,7 @@ _gnutls_map_pk_get_pk (gnutls_kx_algorithm_t kx_algorithm)
2007 * ex. GNUTLS_KX_RSA requires a certificate able to encrypt... so returns CIPHER_ENCRYPT. 1935 * ex. GNUTLS_KX_RSA requires a certificate able to encrypt... so returns CIPHER_ENCRYPT.
2008 */ 1936 */
2009enum encipher_type 1937enum encipher_type
2010_gnutls_kx_encipher_type (gnutls_kx_algorithm_t kx_algorithm) 1938mhd_gtls_kx_encipher_type (gnutls_kx_algorithm_t kx_algorithm)
2011{ 1939{
2012 int ret = CIPHER_IGN; 1940 int ret = CIPHER_IGN;
2013 GNUTLS_PK_MAP_ALG_LOOP (ret = p->encipher_type) return ret; 1941 GNUTLS_PK_MAP_ALG_LOOP (ret = p->encipher_type) return ret;
@@ -2068,26 +1996,8 @@ static const gnutls_sign_entry sign_algorithms[] = {
2068#define GNUTLS_SIGN_ALG_LOOP(a) \ 1996#define GNUTLS_SIGN_ALG_LOOP(a) \
2069 GNUTLS_SIGN_LOOP( if(p->id && p->id == sign) { a; break; } ) 1997 GNUTLS_SIGN_LOOP( if(p->id && p->id == sign) { a; break; } )
2070 1998
2071/**
2072 * gnutls_sign_algorithm_get_name - Returns a string with the name of the specified sign algorithm
2073 * @algorithm: is a sign algorithm
2074 *
2075 * Returns: a string that contains the name of the specified sign
2076 * algorithm, or %NULL.
2077 **/
2078const char *
2079gnutls_sign_algorithm_get_name (gnutls_sign_algorithm_t sign)
2080{
2081 const char *ret = NULL;
2082
2083 /* avoid prefix */
2084 GNUTLS_SIGN_ALG_LOOP (ret = p->name);
2085
2086 return ret;
2087}
2088
2089gnutls_sign_algorithm_t 1999gnutls_sign_algorithm_t
2090_gnutls_x509_oid2sign_algorithm (const char *oid) 2000mhd_gtls_x509_oid2sign_algorithm (const char *oid)
2091{ 2001{
2092 gnutls_sign_algorithm_t ret = 0; 2002 gnutls_sign_algorithm_t ret = 0;
2093 2003
@@ -2105,7 +2015,7 @@ _gnutls_x509_oid2sign_algorithm (const char *oid)
2105} 2015}
2106 2016
2107gnutls_sign_algorithm_t 2017gnutls_sign_algorithm_t
2108_gnutls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, gnutls_mac_algorithm_t mac) 2018mhd_gtls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, gnutls_mac_algorithm_t mac)
2109{ 2019{
2110 gnutls_sign_algorithm_t ret = 0; 2020 gnutls_sign_algorithm_t ret = 0;
2111 2021
@@ -2120,13 +2030,13 @@ _gnutls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, gnutls_mac_algorithm_t mac)
2120} 2030}
2121 2031
2122const char * 2032const char *
2123_gnutls_x509_sign_to_oid (gnutls_pk_algorithm_t pk, 2033mhd_gtls_x509_sign_to_oid (gnutls_pk_algorithm_t pk,
2124 gnutls_mac_algorithm_t mac) 2034 gnutls_mac_algorithm_t mac)
2125{ 2035{
2126 gnutls_sign_algorithm_t sign; 2036 gnutls_sign_algorithm_t sign;
2127 const char *ret = NULL; 2037 const char *ret = NULL;
2128 2038
2129 sign = _gnutls_x509_pk_to_sign (pk, mac); 2039 sign = mhd_gtls_x509_pk_to_sign (pk, mac);
2130 if (sign == GNUTLS_SIGN_UNKNOWN) 2040 if (sign == GNUTLS_SIGN_UNKNOWN)
2131 return NULL; 2041 return NULL;
2132 2042
@@ -2159,31 +2069,8 @@ static const gnutls_pk_entry pk_algorithms[] = {
2159 0} 2069 0}
2160}; 2070};
2161 2071
2162/**
2163 * gnutls_pk_algorithm_get_name - Returns a string with the name of the specified public key algorithm
2164 * @algorithm: is a pk algorithm
2165 *
2166 * Returns: a string that contains the name of the specified public
2167 * key algorithm, or %NULL.
2168 **/
2169const char *
2170gnutls_pk_algorithm_get_name (gnutls_pk_algorithm_t algorithm)
2171{
2172 const char *ret = NULL;
2173 const gnutls_pk_entry *p;
2174
2175 for (p = pk_algorithms; p->name != NULL; p++)
2176 if (p->id && p->id == algorithm)
2177 {
2178 ret = p->name;
2179 break;
2180 }
2181
2182 return ret;
2183}
2184
2185gnutls_pk_algorithm_t 2072gnutls_pk_algorithm_t
2186_gnutls_x509_oid2pk_algorithm (const char *oid) 2073mhd_gtls_x509_oid2pk_algorithm (const char *oid)
2187{ 2074{
2188 gnutls_pk_algorithm_t ret = MHD_GNUTLS_PK_UNKNOWN; 2075 gnutls_pk_algorithm_t ret = MHD_GNUTLS_PK_UNKNOWN;
2189 const gnutls_pk_entry *p; 2076 const gnutls_pk_entry *p;
@@ -2199,7 +2086,7 @@ _gnutls_x509_oid2pk_algorithm (const char *oid)
2199} 2086}
2200 2087
2201const char * 2088const char *
2202_gnutls_x509_pk_to_oid (gnutls_pk_algorithm_t algorithm) 2089mhd_gtls_x509_pk_to_oid (gnutls_pk_algorithm_t algorithm)
2203{ 2090{
2204 const char *ret = NULL; 2091 const char *ret = NULL;
2205 const gnutls_pk_entry *p; 2092 const gnutls_pk_entry *p;
diff --git a/src/daemon/https/tls/gnutls_algorithms.h b/src/daemon/https/tls/gnutls_algorithms.h
index fd23ef0a..84198c1a 100644
--- a/src/daemon/https/tls/gnutls_algorithms.h
+++ b/src/daemon/https/tls/gnutls_algorithms.h
@@ -23,87 +23,87 @@
23 */ 23 */
24 24
25#ifndef ALGORITHMS_H 25#ifndef ALGORITHMS_H
26# define ALGORITHMS_H 26#define ALGORITHMS_H
27 27
28#include "gnutls_auth.h" 28#include "gnutls_auth.h"
29 29
30/* Functions for version handling. */ 30/* Functions for version handling. */
31gnutls_protocol_t _gnutls_version_lowest (gnutls_session_t session); 31gnutls_protocol_t mhd_gtls_version_lowest (mhd_gtls_session_t session);
32gnutls_protocol_t _gnutls_version_max (gnutls_session_t session); 32gnutls_protocol_t mhd_gtls_version_max (mhd_gtls_session_t session);
33int _gnutls_version_priority (gnutls_session_t session, 33int mhd_gtls_version_priority (mhd_gtls_session_t session,
34 gnutls_protocol_t version); 34 gnutls_protocol_t version);
35int _gnutls_version_is_supported (gnutls_session_t session, 35int mhd_gtls_version_is_supported (mhd_gtls_session_t session,
36 const gnutls_protocol_t version); 36 const gnutls_protocol_t version);
37int _gnutls_version_get_major (gnutls_protocol_t ver); 37int mhd_gtls_version_get_major (gnutls_protocol_t ver);
38int _gnutls_version_get_minor (gnutls_protocol_t ver); 38int mhd_gtls_version_get_minor (gnutls_protocol_t ver);
39gnutls_protocol_t _gnutls_version_get (int major, int minor); 39gnutls_protocol_t mhd_gtls_version_get (int major, int minor);
40 40
41/* Functions for MACs. */ 41/* Functions for MACs. */
42int _gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm); 42int mhd_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm);
43gnutls_mac_algorithm_t _gnutls_x509_oid2mac_algorithm (const char *oid); 43gnutls_mac_algorithm_t mhd_gtls_x509_oid2mac_algorithm (const char *oid);
44const char *_gnutls_x509_mac_to_oid (gnutls_mac_algorithm_t mac); 44const char * mhd_gtls_x509_mac_to_oid (gnutls_mac_algorithm_t mac);
45 45
46/* Functions for cipher suites. */ 46/* Functions for cipher suites. */
47int _gnutls_supported_ciphersuites (gnutls_session_t session, 47int mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
48 cipher_suite_st ** ciphers); 48 cipher_suite_st ** ciphers);
49int _gnutls_supported_ciphersuites_sorted (gnutls_session_t session, 49int mhd_gtls_supported_ciphersuites_sorted (mhd_gtls_session_t session,
50 cipher_suite_st ** ciphers); 50 cipher_suite_st ** ciphers);
51int _gnutls_supported_compression_methods (gnutls_session_t session, 51int mhd_gtls_supported_compression_methods (mhd_gtls_session_t session,
52 uint8_t ** comp); 52 uint8_t ** comp);
53const char *_gnutls_cipher_suite_get_name (cipher_suite_st * algorithm); 53const char * mhd_gtls_cipher_suite_get_name (cipher_suite_st * algorithm);
54gnutls_cipher_algorithm_t _gnutls_cipher_suite_get_cipher_algo (const 54gnutls_cipher_algorithm_t mhd_gtls_cipher_suite_get_cipher_algo (const
55 cipher_suite_st 55 cipher_suite_st
56 * algorithm); 56 * algorithm);
57gnutls_kx_algorithm_t _gnutls_cipher_suite_get_kx_algo (const cipher_suite_st 57gnutls_kx_algorithm_t mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st
58 * algorithm); 58 * algorithm);
59gnutls_mac_algorithm_t _gnutls_cipher_suite_get_mac_algo (const 59gnutls_mac_algorithm_t mhd_gtls_cipher_suite_get_mac_algo (const
60 cipher_suite_st * 60 cipher_suite_st *
61 algorithm); 61 algorithm);
62gnutls_protocol_t _gnutls_cipher_suite_get_version (const cipher_suite_st * 62gnutls_protocol_t mhd_gtls_cipher_suite_get_version (const cipher_suite_st *
63 algorithm); 63 algorithm);
64cipher_suite_st _gnutls_cipher_suite_get_suite_name (cipher_suite_st * 64cipher_suite_st mhd_gtls_cipher_suite_get_suite_name (cipher_suite_st *
65 algorithm); 65 algorithm);
66 66
67/* Functions for ciphers. */ 67/* Functions for ciphers. */
68int _gnutls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm); 68int mhd_gtls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm);
69int _gnutls_cipher_is_block (gnutls_cipher_algorithm_t algorithm); 69int mhd_gtls_cipher_is_block (gnutls_cipher_algorithm_t algorithm);
70int _gnutls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm); 70int mhd_gtls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm);
71int _gnutls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm); 71int mhd_gtls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm);
72int _gnutls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm); 72int mhd_gtls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm);
73 73
74/* Functions for key exchange. */ 74/* Functions for key exchange. */
75int _gnutls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm); 75int mhd_gtls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm);
76int _gnutls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm); 76int mhd_gtls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm);
77mod_auth_st *_gnutls_kx_auth_struct (gnutls_kx_algorithm_t algorithm); 77mhd_gtls_mod_auth_st * mhd_gtls_kx_auth_struct (gnutls_kx_algorithm_t algorithm);
78int _gnutls_kx_is_ok (gnutls_kx_algorithm_t algorithm); 78int mhd_gtls_kx_is_ok (gnutls_kx_algorithm_t algorithm);
79 79
80/* Functions for compression. */ 80/* Functions for compression. */
81int _gnutls_compression_is_ok (gnutls_compression_method_t algorithm); 81int mhd_gtls_compression_is_ok (gnutls_compression_method_t algorithm);
82int _gnutls_compression_get_num (gnutls_compression_method_t algorithm); 82int mhd_gtls_compression_get_num (gnutls_compression_method_t algorithm);
83gnutls_compression_method_t _gnutls_compression_get_id (int num); 83gnutls_compression_method_t mhd_gtls_compression_get_id (int num);
84int _gnutls_compression_get_mem_level (gnutls_compression_method_t algorithm); 84int mhd_gtls_compression_get_mem_level (gnutls_compression_method_t algorithm);
85int _gnutls_compression_get_comp_level (gnutls_compression_method_t 85int mhd_gtls_compression_get_comp_level (gnutls_compression_method_t
86 algorithm); 86 algorithm);
87int _gnutls_compression_get_wbits (gnutls_compression_method_t algorithm); 87int mhd_gtls_compression_get_wbits (gnutls_compression_method_t algorithm);
88 88
89/* Type to KX mappings. */ 89/* Type to KX mappings. */
90gnutls_kx_algorithm_t _gnutls_map_kx_get_kx (gnutls_credentials_type_t type, 90gnutls_kx_algorithm_t mhd_gtls_map_kx_get_kx (gnutls_credentials_type_t type,
91 int server); 91 int server);
92gnutls_credentials_type_t _gnutls_map_kx_get_cred (gnutls_kx_algorithm_t 92gnutls_credentials_type_t mhd_gtls_map_kx_get_cred (gnutls_kx_algorithm_t
93 algorithm, int server); 93 algorithm, int server);
94 94
95/* KX to PK mapping. */ 95/* KX to PK mapping. */
96gnutls_pk_algorithm_t _gnutls_map_pk_get_pk (gnutls_kx_algorithm_t 96gnutls_pk_algorithm_t mhd_gtls_map_pk_get_pk (gnutls_kx_algorithm_t
97 kx_algorithm); 97 kx_algorithm);
98gnutls_pk_algorithm_t _gnutls_x509_oid2pk_algorithm (const char *oid); 98gnutls_pk_algorithm_t mhd_gtls_x509_oid2pk_algorithm (const char *oid);
99const char *_gnutls_x509_pk_to_oid (gnutls_pk_algorithm_t pk); 99const char * mhd_gtls_x509_pk_to_oid (gnutls_pk_algorithm_t pk);
100 100
101enum encipher_type 101enum encipher_type
102{ CIPHER_ENCRYPT = 0, CIPHER_SIGN = 1, CIPHER_IGN }; 102{ CIPHER_ENCRYPT = 0, CIPHER_SIGN = 1, CIPHER_IGN };
103 103
104enum encipher_type _gnutls_kx_encipher_type (gnutls_kx_algorithm_t algorithm); 104enum encipher_type mhd_gtls_kx_encipher_type (gnutls_kx_algorithm_t algorithm);
105 105
106struct gnutls_compression_entry 106struct mhd_gtls_compression_entry
107{ 107{
108 const char *name; 108 const char *name;
109 gnutls_compression_method_t id; 109 gnutls_compression_method_t id;
@@ -114,28 +114,28 @@ struct gnutls_compression_entry
114 int mem_level; 114 int mem_level;
115 int comp_level; 115 int comp_level;
116}; 116};
117typedef struct gnutls_compression_entry gnutls_compression_entry; 117typedef struct mhd_gtls_compression_entry gnutls_compression_entry;
118 118
119/* Functions for sign algorithms. */ 119/* Functions for sign algorithms. */
120gnutls_sign_algorithm_t _gnutls_x509_oid2sign_algorithm (const char *oid); 120gnutls_sign_algorithm_t mhd_gtls_x509_oid2sign_algorithm (const char *oid);
121gnutls_sign_algorithm_t _gnutls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, 121gnutls_sign_algorithm_t mhd_gtls_x509_pk_to_sign (gnutls_pk_algorithm_t pk,
122 gnutls_mac_algorithm_t mac); 122 gnutls_mac_algorithm_t mac);
123const char *_gnutls_x509_sign_to_oid (gnutls_pk_algorithm_t, 123const char * mhd_gtls_x509_sign_to_oid (gnutls_pk_algorithm_t,
124 gnutls_mac_algorithm_t mac); 124 gnutls_mac_algorithm_t mac);
125 125
126int _gnutls_mac_priority (gnutls_session_t session, 126int mhd_gtls_mac_priority (mhd_gtls_session_t session,
127 gnutls_mac_algorithm_t algorithm); 127 gnutls_mac_algorithm_t algorithm);
128int _gnutls_cipher_priority (gnutls_session_t session, 128int mhd_gtls_cipher_priority (mhd_gtls_session_t session,
129 gnutls_cipher_algorithm_t algorithm); 129 gnutls_cipher_algorithm_t algorithm);
130int _gnutls_kx_priority (gnutls_session_t session, 130int mhd_gtls_kx_priority (mhd_gtls_session_t session,
131 gnutls_kx_algorithm_t algorithm); 131 gnutls_kx_algorithm_t algorithm);
132int _gnutls_compression_priority (gnutls_session_t session, 132int mhd_gtls_compression_priority (mhd_gtls_session_t session,
133 gnutls_compression_method_t algorithm); 133 gnutls_compression_method_t algorithm);
134 134
135gnutls_mac_algorithm_t gnutls_mac_get_id (const char* name); 135gnutls_mac_algorithm_t MHD_gtls_mac_get_id (const char* name);
136gnutls_cipher_algorithm_t gnutls_cipher_get_id (const char* name); 136gnutls_cipher_algorithm_t MHD_gtls_cipher_get_id (const char* name);
137gnutls_kx_algorithm_t gnutls_kx_get_id (const char* name); 137gnutls_kx_algorithm_t MHD_gtls_kx_get_id (const char* name);
138gnutls_protocol_t gnutls_protocol_get_id (const char* name); 138gnutls_protocol_t MHD_gtls_protocol_get_id (const char* name);
139gnutls_certificate_type_t gnutls_certificate_type_get_id (const char* name); 139gnutls_certificate_type_t MHD_gtls_certificate_type_get_id (const char* name);
140 140
141#endif 141#endif
diff --git a/src/daemon/https/tls/gnutls_anon_cred.c b/src/daemon/https/tls/gnutls_anon_cred.c
index fd0917f8..9fd344db 100644
--- a/src/daemon/https/tls/gnutls_anon_cred.c
+++ b/src/daemon/https/tls/gnutls_anon_cred.c
@@ -36,22 +36,22 @@
36static const int anon_dummy; 36static const int anon_dummy;
37 37
38/** 38/**
39 * gnutls_anon_free_server_credentials - Used to free an allocated gnutls_anon_server_credentials_t structure 39 * MHD_gnutls_anon_free_server_credentials - Used to free an allocated mhd_gtls_anon_server_credentials_t structure
40 * @sc: is an #gnutls_anon_server_credentials_t structure. 40 * @sc: is an #mhd_gtls_anon_server_credentials_t structure.
41 * 41 *
42 * This structure is complex enough to manipulate directly thus this 42 * This structure is complex enough to manipulate directly thus this
43 * helper function is provided in order to free (deallocate) it. 43 * helper function is provided in order to free (deallocate) it.
44 **/ 44 **/
45void 45void
46gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t sc) 46MHD_gnutls_anon_free_server_credentials (mhd_gtls_anon_server_credentials_t sc)
47{ 47{
48 48
49 gnutls_free (sc); 49 gnutls_free (sc);
50} 50}
51 51
52/** 52/**
53 * gnutls_anon_allocate_server_credentials - Used to allocate an gnutls_anon_server_credentials_t structure 53 * MHD_gnutls_anon_allocate_server_credentials - Used to allocate an mhd_gtls_anon_server_credentials_t structure
54 * @sc: is a pointer to an #gnutls_anon_server_credentials_t structure. 54 * @sc: is a pointer to an #mhd_gtls_anon_server_credentials_t structure.
55 * 55 *
56 * This structure is complex enough to manipulate directly thus this 56 * This structure is complex enough to manipulate directly thus this
57 * helper function is provided in order to allocate it. 57 * helper function is provided in order to allocate it.
@@ -59,10 +59,10 @@ gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t sc)
59 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 59 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
60 **/ 60 **/
61int 61int
62gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t * 62MHD_gnutls_anon_allocate_server_credentials (mhd_gtls_anon_server_credentials_t *
63 sc) 63 sc)
64{ 64{
65 *sc = gnutls_calloc (1, sizeof (anon_server_credentials_st)); 65 *sc = gnutls_calloc (1, sizeof (mhd_anon_server_credentials_st));
66 if (*sc == NULL) 66 if (*sc == NULL)
67 return GNUTLS_E_MEMORY_ERROR; 67 return GNUTLS_E_MEMORY_ERROR;
68 68
@@ -71,20 +71,20 @@ gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t *
71 71
72 72
73/** 73/**
74 * gnutls_anon_free_client_credentials - Used to free an allocated gnutls_anon_client_credentials_t structure 74 * MHD_gnutls_anon_free_client_credentials - Used to free an allocated mhd_gtls_anon_client_credentials_t structure
75 * @sc: is an #gnutls_anon_client_credentials_t structure. 75 * @sc: is an #mhd_gtls_anon_client_credentials_t structure.
76 * 76 *
77 * This structure is complex enough to manipulate directly thus this 77 * This structure is complex enough to manipulate directly thus this
78 * helper function is provided in order to free (deallocate) it. 78 * helper function is provided in order to free (deallocate) it.
79 **/ 79 **/
80void 80void
81gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t sc) 81MHD_gnutls_anon_free_client_credentials (mhd_gtls_anon_client_credentials_t sc)
82{ 82{
83} 83}
84 84
85/** 85/**
86 * gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure 86 * MHD_gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure
87 * @sc: is a pointer to an #gnutls_anon_client_credentials_t structure. 87 * @sc: is a pointer to an #mhd_gtls_anon_client_credentials_t structure.
88 * 88 *
89 * This structure is complex enough to manipulate directly thus 89 * This structure is complex enough to manipulate directly thus
90 * this helper function is provided in order to allocate it. 90 * this helper function is provided in order to allocate it.
@@ -92,7 +92,7 @@ gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t sc)
92 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 92 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
93 **/ 93 **/
94int 94int
95gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t * 95MHD_gnutls_anon_allocate_client_credentials (mhd_gtls_anon_client_credentials_t *
96 sc) 96 sc)
97{ 97{
98 /* anon_dummy is only there for *sc not to be null. 98 /* anon_dummy is only there for *sc not to be null.
@@ -104,8 +104,8 @@ gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t *
104} 104}
105 105
106/** 106/**
107 * gnutls_anon_set_server_dh_params - This function will set the DH parameters for a server to use 107 * MHD_gnutls_anon_set_server_dh_params - This function will set the DH parameters for a server to use
108 * @res: is a gnutls_anon_server_credentials_t structure 108 * @res: is a mhd_gtls_anon_server_credentials_t structure
109 * @dh_params: is a structure that holds diffie hellman parameters. 109 * @dh_params: is a structure that holds diffie hellman parameters.
110 * 110 *
111 * This function will set the diffie hellman parameters for an 111 * This function will set the diffie hellman parameters for an
@@ -113,15 +113,15 @@ gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t *
113 * Anonymous Diffie Hellman cipher suites. 113 * Anonymous Diffie Hellman cipher suites.
114 **/ 114 **/
115void 115void
116gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res, 116MHD_gnutls_anon_set_server_dh_params (mhd_gtls_anon_server_credentials_t res,
117 gnutls_dh_params_t dh_params) 117 mhd_gtls_dh_params_t dh_params)
118{ 118{
119 res->dh_params = dh_params; 119 res->dh_params = dh_params;
120} 120}
121 121
122/** 122/**
123 * gnutls_anon_set_server_params_function - This function will set the DH parameters callback 123 * MHD_gnutls_anon_set_server_params_function - This function will set the DH parameters callback
124 * @res: is a gnutls_certificate_credentials_t structure 124 * @res: is a mhd_gtls_cert_credentials_t structure
125 * @func: is the function to be called 125 * @func: is the function to be called
126 * 126 *
127 * This function will set a callback in order for the server to get 127 * This function will set a callback in order for the server to get
@@ -129,7 +129,7 @@ gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res,
129 * callback should return zero on success. 129 * callback should return zero on success.
130 **/ 130 **/
131void 131void
132gnutls_anon_set_server_params_function (gnutls_anon_server_credentials_t res, 132MHD_gnutls_anon_set_server_params_function (mhd_gtls_anon_server_credentials_t res,
133 gnutls_params_function * func) 133 gnutls_params_function * func)
134{ 134{
135 res->params_func = func; 135 res->params_func = func;
diff --git a/src/daemon/https/tls/gnutls_auth.c b/src/daemon/https/tls/gnutls_auth.c
index bf4d6881..cb2f42e0 100644
--- a/src/daemon/https/tls/gnutls_auth.c
+++ b/src/daemon/https/tls/gnutls_auth.c
@@ -37,14 +37,14 @@
37 */ 37 */
38 38
39/** 39/**
40 * gnutls_credentials_clear - Clears all the credentials previously set 40 * MHD_gnutls_credentials_clear - Clears all the credentials previously set
41 * @session: is a #gnutls_session_t structure. 41 * @session: is a #mhd_gtls_session_t structure.
42 * 42 *
43 * Clears all the credentials previously set in this session. 43 * Clears all the credentials previously set in this session.
44 * 44 *
45 **/ 45 **/
46void 46void
47gnutls_credentials_clear (gnutls_session_t session) 47MHD_gnutls_credentials_clear (mhd_gtls_session_t session)
48{ 48{
49 if (session->key && session->key->cred) 49 if (session->key && session->key->cred)
50 { /* beginning of the list */ 50 { /* beginning of the list */
@@ -65,8 +65,8 @@ gnutls_credentials_clear (gnutls_session_t session)
65 * { algorithm, credentials, pointer to next } 65 * { algorithm, credentials, pointer to next }
66 */ 66 */
67/** 67/**
68 * gnutls_credentials_set - Sets the needed credentials for the specified authentication algorithm. 68 * MHD_gnutls_credentials_set - Sets the needed credentials for the specified authentication algorithm.
69 * @session: is a #gnutls_session_t structure. 69 * @session: is a #mhd_gtls_session_t structure.
70 * @type: is the type of the credentials 70 * @type: is the type of the credentials
71 * @cred: is a pointer to a structure. 71 * @cred: is a pointer to a structure.
72 * 72 *
@@ -77,20 +77,20 @@ gnutls_credentials_clear (gnutls_session_t session)
77 * [ In order to minimize memory usage, and share credentials between 77 * [ In order to minimize memory usage, and share credentials between
78 * several threads gnutls keeps a pointer to cred, and not the whole cred 78 * several threads gnutls keeps a pointer to cred, and not the whole cred
79 * structure. Thus you will have to keep the structure allocated until 79 * structure. Thus you will have to keep the structure allocated until
80 * you call gnutls_deinit(). ] 80 * you call MHD_gnutls_deinit(). ]
81 * 81 *
82 * For GNUTLS_CRD_ANON cred should be gnutls_anon_client_credentials_t in case of a client. 82 * For GNUTLS_CRD_ANON cred should be mhd_gtls_anon_client_credentials_t in case of a client.
83 * In case of a server it should be gnutls_anon_server_credentials_t. 83 * In case of a server it should be mhd_gtls_anon_server_credentials_t.
84 * 84 *
85 * For GNUTLS_CRD_SRP cred should be gnutls_srp_client_credentials_t 85 * For GNUTLS_CRD_SRP cred should be gnutls_srp_client_credentials_t
86 * in case of a client, and gnutls_srp_server_credentials_t, in case 86 * in case of a client, and gnutls_srp_server_credentials_t, in case
87 * of a server. 87 * of a server.
88 * 88 *
89 * For GNUTLS_CRD_CERTIFICATE cred should be gnutls_certificate_credentials_t. 89 * For GNUTLS_CRD_CERTIFICATE cred should be mhd_gtls_cert_credentials_t.
90 * 90 *
91 **/ 91 **/
92int 92int
93gnutls_credentials_set (gnutls_session_t session, 93MHD_gnutls_credentials_set (mhd_gtls_session_t session,
94 gnutls_credentials_type_t type, void *cred) 94 gnutls_credentials_type_t type, void *cred)
95{ 95{
96 auth_cred_st *ccred = NULL, *pcred = NULL; 96 auth_cred_st *ccred = NULL, *pcred = NULL;
@@ -150,8 +150,8 @@ gnutls_credentials_set (gnutls_session_t session,
150} 150}
151 151
152/** 152/**
153 * gnutls_auth_get_type - Returns the type of credentials for the current authentication schema. 153 * MHD_gtls_auth_get_type - Returns the type of credentials for the current authentication schema.
154 * @session: is a #gnutls_session_t structure. 154 * @session: is a #mhd_gtls_session_t structure.
155 * 155 *
156 * Returns type of credentials for the current authentication schema. 156 * Returns type of credentials for the current authentication schema.
157 * The returned information is to be used to distinguish the function used 157 * The returned information is to be used to distinguish the function used
@@ -161,7 +161,7 @@ gnutls_credentials_set (gnutls_session_t session,
161 * the same function are to be used to access the authentication data. 161 * the same function are to be used to access the authentication data.
162 **/ 162 **/
163gnutls_credentials_type_t 163gnutls_credentials_type_t
164gnutls_auth_get_type (gnutls_session_t session) 164MHD_gtls_auth_get_type (mhd_gtls_session_t session)
165{ 165{
166/* This is not the credentials we must set, but the authentication data 166/* This is not the credentials we must set, but the authentication data
167 * we get by the peer, so it should be reversed. 167 * we get by the peer, so it should be reversed.
@@ -169,14 +169,14 @@ gnutls_auth_get_type (gnutls_session_t session)
169 int server = session->security_parameters.entity == GNUTLS_SERVER ? 0 : 1; 169 int server = session->security_parameters.entity == GNUTLS_SERVER ? 0 : 1;
170 170
171 return 171 return
172 _gnutls_map_kx_get_cred (_gnutls_cipher_suite_get_kx_algo 172 mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
173 (&session->security_parameters. 173 (&session->security_parameters.
174 current_cipher_suite), server); 174 current_cipher_suite), server);
175} 175}
176 176
177/** 177/**
178 * gnutls_auth_server_get_type - Returns the type of credentials for the server authentication schema. 178 * MHD_gtls_auth_server_get_type - Returns the type of credentials for the server authentication schema.
179 * @session: is a #gnutls_session_t structure. 179 * @session: is a #mhd_gtls_session_t structure.
180 * 180 *
181 * Returns the type of credentials that were used for server authentication. 181 * Returns the type of credentials that were used for server authentication.
182 * The returned information is to be used to distinguish the function used 182 * The returned information is to be used to distinguish the function used
@@ -184,17 +184,17 @@ gnutls_auth_get_type (gnutls_session_t session)
184 * 184 *
185 **/ 185 **/
186gnutls_credentials_type_t 186gnutls_credentials_type_t
187gnutls_auth_server_get_type (gnutls_session_t session) 187MHD_gtls_auth_server_get_type (mhd_gtls_session_t session)
188{ 188{
189 return 189 return
190 _gnutls_map_kx_get_cred (_gnutls_cipher_suite_get_kx_algo 190 mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
191 (&session->security_parameters. 191 (&session->security_parameters.
192 current_cipher_suite), 1); 192 current_cipher_suite), 1);
193} 193}
194 194
195/** 195/**
196 * gnutls_auth_client_get_type - Returns the type of credentials for the client authentication schema. 196 * MHD_gtls_auth_client_get_type - Returns the type of credentials for the client authentication schema.
197 * @session: is a #gnutls_session_t structure. 197 * @session: is a #mhd_gtls_session_t structure.
198 * 198 *
199 * Returns the type of credentials that were used for client authentication. 199 * Returns the type of credentials that were used for client authentication.
200 * The returned information is to be used to distinguish the function used 200 * The returned information is to be used to distinguish the function used
@@ -202,10 +202,10 @@ gnutls_auth_server_get_type (gnutls_session_t session)
202 * 202 *
203 **/ 203 **/
204gnutls_credentials_type_t 204gnutls_credentials_type_t
205gnutls_auth_client_get_type (gnutls_session_t session) 205MHD_gtls_auth_client_get_type (mhd_gtls_session_t session)
206{ 206{
207 return 207 return
208 _gnutls_map_kx_get_cred (_gnutls_cipher_suite_get_kx_algo 208 mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
209 (&session->security_parameters. 209 (&session->security_parameters.
210 current_cipher_suite), 0); 210 current_cipher_suite), 0);
211} 211}
@@ -216,17 +216,17 @@ gnutls_auth_client_get_type (gnutls_session_t session)
216 * free that!!! 216 * free that!!!
217 */ 217 */
218const void * 218const void *
219_gnutls_get_kx_cred (gnutls_session_t session, 219mhd_gtls_get_kx_cred (mhd_gtls_session_t session,
220 gnutls_kx_algorithm_t algo, int *err) 220 gnutls_kx_algorithm_t algo, int *err)
221{ 221{
222 int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0; 222 int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0;
223 223
224 return _gnutls_get_cred (session->key, 224 return mhd_gtls_get_cred (session->key,
225 _gnutls_map_kx_get_cred (algo, server), err); 225 mhd_gtls_map_kx_get_cred (algo, server), err);
226} 226}
227 227
228const void * 228const void *
229_gnutls_get_cred (gnutls_key_st key, gnutls_credentials_type_t type, int *err) 229mhd_gtls_get_cred (mhd_gtls_key_st key, gnutls_credentials_type_t type, int *err)
230{ 230{
231 const void *retval = NULL; 231 const void *retval = NULL;
232 int _err = -1; 232 int _err = -1;
@@ -257,10 +257,10 @@ out:
257} 257}
258 258
259/*- 259/*-
260 * _gnutls_get_auth_info - Returns a pointer to authentication information. 260 * mhd_gtls_get_auth_info - Returns a pointer to authentication information.
261 * @session: is a #gnutls_session_t structure. 261 * @session: is a #mhd_gtls_session_t structure.
262 * 262 *
263 * This function must be called after a succesful gnutls_handshake(). 263 * This function must be called after a succesful MHD_gnutls_handshake().
264 * Returns a pointer to authentication information. That information 264 * Returns a pointer to authentication information. That information
265 * is data obtained by the handshake protocol, the key exchange algorithm, 265 * is data obtained by the handshake protocol, the key exchange algorithm,
266 * and the TLS extensions messages. 266 * and the TLS extensions messages.
@@ -270,21 +270,21 @@ out:
270 * In case of GNUTLS_CRD_SRP returns a type of &srp_(server/client)_auth_info_t; 270 * In case of GNUTLS_CRD_SRP returns a type of &srp_(server/client)_auth_info_t;
271 -*/ 271 -*/
272void * 272void *
273_gnutls_get_auth_info (gnutls_session_t session) 273mhd_gtls_get_auth_info (mhd_gtls_session_t session)
274{ 274{
275 return session->key->auth_info; 275 return session->key->auth_info;
276} 276}
277 277
278/*- 278/*-
279 * _gnutls_free_auth_info - Frees the auth info structure 279 * mhd_gtls_free_auth_info - Frees the auth info structure
280 * @session: is a #gnutls_session_t structure. 280 * @session: is a #mhd_gtls_session_t structure.
281 * 281 *
282 * This function frees the auth info structure and sets it to 282 * This function frees the auth info structure and sets it to
283 * null. It must be called since some structures contain malloced 283 * null. It must be called since some structures contain malloced
284 * elements. 284 * elements.
285 -*/ 285 -*/
286void 286void
287_gnutls_free_auth_info (gnutls_session_t session) 287mhd_gtls_free_auth_info (mhd_gtls_session_t session)
288{ 288{
289 dh_info_st *dh_info; 289 dh_info_st *dh_info;
290 rsa_info_st *rsa_info; 290 rsa_info_st *rsa_info;
@@ -301,19 +301,19 @@ _gnutls_free_auth_info (gnutls_session_t session)
301 break; 301 break;
302 case MHD_GNUTLS_CRD_ANON: 302 case MHD_GNUTLS_CRD_ANON:
303 { 303 {
304 anon_auth_info_t info = _gnutls_get_auth_info (session); 304 mhd_anon_auth_info_t info = mhd_gtls_get_auth_info (session);
305 305
306 if (info == NULL) 306 if (info == NULL)
307 break; 307 break;
308 308
309 dh_info = &info->dh; 309 dh_info = &info->dh;
310 _gnutls_free_dh_info (dh_info); 310 mhd_gtls_free_dh_info (dh_info);
311 } 311 }
312 break; 312 break;
313 case MHD_GNUTLS_CRD_CERTIFICATE: 313 case MHD_GNUTLS_CRD_CERTIFICATE:
314 { 314 {
315 unsigned int i; 315 unsigned int i;
316 cert_auth_info_t info = _gnutls_get_auth_info (session); 316 cert_auth_info_t info = mhd_gtls_get_auth_info (session);
317 317
318 if (info == NULL) 318 if (info == NULL)
319 break; 319 break;
@@ -329,8 +329,8 @@ _gnutls_free_auth_info (gnutls_session_t session)
329 info->raw_certificate_list = NULL; 329 info->raw_certificate_list = NULL;
330 info->ncerts = 0; 330 info->ncerts = 0;
331 331
332 _gnutls_free_dh_info (dh_info); 332 mhd_gtls_free_dh_info (dh_info);
333 _gnutls_free_rsa_info (rsa_info); 333 mhd_gtls_free_rsa_info (rsa_info);
334 } 334 }
335 335
336 336
@@ -353,7 +353,7 @@ _gnutls_free_auth_info (gnutls_session_t session)
353 * info structure to a different type. 353 * info structure to a different type.
354 */ 354 */
355int 355int
356_gnutls_auth_info_set (gnutls_session_t session, 356mhd_gtls_auth_info_set (mhd_gtls_session_t session,
357 gnutls_credentials_type_t type, int size, 357 gnutls_credentials_type_t type, int size,
358 int allow_change) 358 int allow_change)
359{ 359{
@@ -378,7 +378,7 @@ _gnutls_auth_info_set (gnutls_session_t session,
378 * ciphersuite which is negotiated has different authentication 378 * ciphersuite which is negotiated has different authentication
379 * schema. 379 * schema.
380 */ 380 */
381 if (gnutls_auth_get_type (session) != session->key->auth_info_type) 381 if (MHD_gtls_auth_get_type (session) != session->key->auth_info_type)
382 { 382 {
383 gnutls_assert (); 383 gnutls_assert ();
384 return GNUTLS_E_INVALID_REQUEST; 384 return GNUTLS_E_INVALID_REQUEST;
@@ -392,10 +392,10 @@ _gnutls_auth_info_set (gnutls_session_t session,
392 * certificate (in order to prevent revealing the certificate's contents, 392 * certificate (in order to prevent revealing the certificate's contents,
393 * to passive eavesdropers. 393 * to passive eavesdropers.
394 */ 394 */
395 if (gnutls_auth_get_type (session) != session->key->auth_info_type) 395 if (MHD_gtls_auth_get_type (session) != session->key->auth_info_type)
396 { 396 {
397 397
398 _gnutls_free_auth_info (session); 398 mhd_gtls_free_auth_info (session);
399 399
400 session->key->auth_info = calloc (1, size); 400 session->key->auth_info = calloc (1, size);
401 if (session->key->auth_info == NULL) 401 if (session->key->auth_info == NULL)
diff --git a/src/daemon/https/tls/gnutls_auth.h b/src/daemon/https/tls/gnutls_auth.h
index 07d81352..89d07d88 100644
--- a/src/daemon/https/tls/gnutls_auth.h
+++ b/src/daemon/https/tls/gnutls_auth.h
@@ -23,28 +23,28 @@
23 */ 23 */
24 24
25#ifndef GNUTLS_AUTH_H 25#ifndef GNUTLS_AUTH_H
26# define GNUTLS_AUTH_H 26#define GNUTLS_AUTH_H
27 27
28typedef struct mod_auth_st_int 28typedef struct mhd_gtls_mod_auth_st_int
29{ 29{
30 const char *name; /* null terminated */ 30 const char *name; /* null terminated */
31 int (*gnutls_generate_server_certificate) (gnutls_session_t, opaque **); 31 int (* mhd_gtls_gen_server_certificate) (mhd_gtls_session_t, opaque **);
32 int (*gnutls_generate_client_certificate) (gnutls_session_t, opaque **); 32 int (* mhd_gtls_gen_client_certificate) (mhd_gtls_session_t, opaque **);
33 int (*gnutls_generate_server_kx) (gnutls_session_t, opaque **); 33 int (* mhd_gtls_gen_server_kx) (mhd_gtls_session_t, opaque **);
34 int (*gnutls_generate_client_kx) (gnutls_session_t, opaque **); /* used in SRP */ 34 int (* mhd_gtls_gen_client_kx) (mhd_gtls_session_t, opaque **); /* used in SRP */
35 int (*gnutls_generate_client_cert_vrfy) (gnutls_session_t, opaque **); 35 int (* mhd_gtls_gen_client_cert_vrfy) (mhd_gtls_session_t, opaque **);
36 int (*gnutls_generate_server_certificate_request) (gnutls_session_t, 36 int (* mhd_gtls_gen_server_certificate_request) (mhd_gtls_session_t,
37 opaque **); 37 opaque **);
38 38
39 int (*gnutls_process_server_certificate) (gnutls_session_t, opaque *, 39 int (* mhd_gtls_process_server_certificate) (mhd_gtls_session_t, opaque *,
40 size_t); 40 size_t);
41 int (*gnutls_process_client_certificate) (gnutls_session_t, opaque *, 41 int (* mhd_gtls_process_client_certificate) (mhd_gtls_session_t, opaque *,
42 size_t); 42 size_t);
43 int (*gnutls_process_server_kx) (gnutls_session_t, opaque *, size_t); 43 int (* mhd_gtls_process_server_kx) (mhd_gtls_session_t, opaque *, size_t);
44 int (*gnutls_process_client_kx) (gnutls_session_t, opaque *, size_t); 44 int (* mhd_gtls_process_client_kx) (mhd_gtls_session_t, opaque *, size_t);
45 int (*gnutls_process_client_cert_vrfy) (gnutls_session_t, opaque *, size_t); 45 int (* mhd_gtls_process_client_cert_vrfy) (mhd_gtls_session_t, opaque *, size_t);
46 int (*gnutls_process_server_certificate_request) (gnutls_session_t, 46 int (* mhd_gtls_process_server_certificate_request) (mhd_gtls_session_t,
47 opaque *, size_t); 47 opaque *, size_t);
48} mod_auth_st; 48} mhd_gtls_mod_auth_st;
49 49
50#endif 50#endif
diff --git a/src/daemon/https/tls/gnutls_auth_int.h b/src/daemon/https/tls/gnutls_auth_int.h
index 85fe53a1..9188cc79 100644
--- a/src/daemon/https/tls/gnutls_auth_int.h
+++ b/src/daemon/https/tls/gnutls_auth_int.h
@@ -22,11 +22,11 @@
22 * 22 *
23 */ 23 */
24 24
25const void *_gnutls_get_cred (gnutls_key_st key, 25const void * mhd_gtls_get_cred (mhd_gtls_key_st key,
26 gnutls_credentials_type_t kx, int *err); 26 gnutls_credentials_type_t kx, int *err);
27const void *_gnutls_get_kx_cred (gnutls_session_t session, 27const void * mhd_gtls_get_kx_cred (mhd_gtls_session_t session,
28 gnutls_kx_algorithm_t algo, int *err); 28 gnutls_kx_algorithm_t algo, int *err);
29void *_gnutls_get_auth_info (gnutls_session_t session); 29void * mhd_gtls_get_auth_info (mhd_gtls_session_t session);
30int _gnutls_auth_info_set (gnutls_session_t session, 30int mhd_gtls_auth_info_set (mhd_gtls_session_t session,
31 gnutls_credentials_type_t type, int size, 31 gnutls_credentials_type_t type, int size,
32 int allow_change); 32 int allow_change);
diff --git a/src/daemon/https/tls/gnutls_buffer.h b/src/daemon/https/tls/gnutls_buffer.h
deleted file mode 100644
index 5c552a7a..00000000
--- a/src/daemon/https/tls/gnutls_buffer.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
3 *
4 * Author: Nikos Mavrogiannopoulos
5 *
6 * This file is part of GNUTLS.
7 *
8 * The GNUTLS library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * USA
22 *
23 */
24
25#include <gnutls_str.h>
26
27typedef gnutls_string gnutls_buffer;
28
29#define _gnutls_buffer_init(buf) _gnutls_string_init(buf, gnutls_malloc, gnutls_realloc, gnutls_free);
30#define _gnutls_buffer_clear _gnutls_string_clear
31#define _gnutls_buffer_append _gnutls_string_append_data
diff --git a/src/daemon/https/tls/gnutls_buffers.c b/src/daemon/https/tls/gnutls_buffers.c
index bbc1bcc4..92979c26 100644
--- a/src/daemon/https/tls/gnutls_buffers.c
+++ b/src/daemon/https/tls/gnutls_buffers.c
@@ -23,19 +23,19 @@
23 */ 23 */
24 24
25/* This is the only file that uses the berkeley sockets API. 25/* This is the only file that uses the berkeley sockets API.
26 * 26 *
27 * Also holds all the buffering code used in gnutls. 27 * Also holds all the buffering code used in gnutls.
28 * The buffering code works as: 28 * The buffering code works as:
29 * 29 *
30 * RECORD LAYER: 30 * RECORD LAYER:
31 * 1. uses a buffer to hold data (application/handshake), 31 * 1. uses a buffer to hold data (application/handshake),
32 * we got but they were not requested, yet. 32 * we got but they were not requested, yet.
33 * (see gnutls_record_buffer_put(), gnutls_record_buffer_get_size() etc.) 33 * (see gnutls_record_buffer_put(), gnutls_record_buffer_get_size() etc.)
34 * 34 *
35 * 2. uses a buffer to hold data that were incomplete (ie the read/write 35 * 2. uses a buffer to hold data that were incomplete (ie the read/write
36 * was interrupted) 36 * was interrupted)
37 * (see _gnutls_io_read_buffered(), _gnutls_io_write_buffered() etc.) 37 * (see mhd_gtls_io_read_buffered(), mhd_gtls_io_write_buffered() etc.)
38 * 38 *
39 * HANDSHAKE LAYER: 39 * HANDSHAKE LAYER:
40 * 1. Uses a buffer to hold data that was not sent or received 40 * 1. Uses a buffer to hold data that was not sent or received
41 * complete. (E.g. sent 10 bytes of a handshake packet that is 20 bytes 41 * complete. (E.g. sent 10 bytes of a handshake packet that is 20 bytes
@@ -43,7 +43,7 @@
43 * (see _gnutls_handshake_send_int(), _gnutls_handshake_recv_int()) 43 * (see _gnutls_handshake_send_int(), _gnutls_handshake_recv_int())
44 * 44 *
45 * 2. Uses buffer to hold the last received handshake message. 45 * 2. Uses buffer to hold the last received handshake message.
46 * (see _gnutls_handshake_buffer_put() etc.) 46 * (see mhd_gtls_handshake_buffer_put() etc.)
47 * 47 *
48 */ 48 */
49 49
@@ -68,8 +68,8 @@
68#endif 68#endif
69 69
70/** 70/**
71 * gnutls_transport_set_errno: 71 * MHD_gnutls_transport_set_errno:
72 * @session: is a #gnutls_session_t structure. 72 * @session: is a #mhd_gtls_session_t structure.
73 * @err: error value to store in session-specific errno variable. 73 * @err: error value to store in session-specific errno variable.
74 * 74 *
75 * Store @err in the session-specific errno variable. Useful values 75 * Store @err in the session-specific errno variable. Useful values
@@ -77,7 +77,7 @@
77 * treated as real errors in the push/pull function. 77 * treated as real errors in the push/pull function.
78 * 78 *
79 * This function is useful in replacement push/pull functions set by 79 * This function is useful in replacement push/pull functions set by
80 * gnutls_transport_set_push_function and 80 * MHD_gnutls_transport_set_push_function and
81 * gnutls_transport_set_pullpush_function under Windows, where the 81 * gnutls_transport_set_pullpush_function under Windows, where the
82 * replacement push/pull may not have access to the same @errno 82 * replacement push/pull may not have access to the same @errno
83 * variable that is used by GnuTLS (e.g., the application is linked to 83 * variable that is used by GnuTLS (e.g., the application is linked to
@@ -85,16 +85,16 @@
85 * 85 *
86 * If you don't have the @session variable easily accessible from the 86 * If you don't have the @session variable easily accessible from the
87 * push/pull function, and don't worry about thread conflicts, you can 87 * push/pull function, and don't worry about thread conflicts, you can
88 * also use gnutls_transport_set_global_errno(). 88 * also use MHD_gnutls_transport_set_global_errno().
89 **/ 89 **/
90void 90void
91gnutls_transport_set_errno (gnutls_session_t session, int err) 91MHD_gnutls_transport_set_errno (mhd_gtls_session_t session, int err)
92{ 92{
93 session->internals.errnum = err; 93 session->internals.errnum = err;
94} 94}
95 95
96/** 96/**
97 * gnutls_transport_set_global_errno: 97 * MHD_gnutls_transport_set_global_errno:
98 * @err: error value to store in global errno variable. 98 * @err: error value to store in global errno variable.
99 * 99 *
100 * Store @err in the global errno variable. Useful values for @err is 100 * Store @err in the global errno variable. Useful values for @err is
@@ -102,7 +102,7 @@ gnutls_transport_set_errno (gnutls_session_t session, int err)
102 * errors in the push/pull function. 102 * errors in the push/pull function.
103 * 103 *
104 * This function is useful in replacement push/pull functions set by 104 * This function is useful in replacement push/pull functions set by
105 * gnutls_transport_set_push_function and 105 * MHD_gnutls_transport_set_push_function and
106 * gnutls_transport_set_pullpush_function under Windows, where the 106 * gnutls_transport_set_pullpush_function under Windows, where the
107 * replacement push/pull may not have access to the same @errno 107 * replacement push/pull may not have access to the same @errno
108 * variable that is used by GnuTLS (e.g., the application is linked to 108 * variable that is used by GnuTLS (e.g., the application is linked to
@@ -111,10 +111,10 @@ gnutls_transport_set_errno (gnutls_session_t session, int err)
111 * Whether this function is thread safe or not depends on whether the 111 * Whether this function is thread safe or not depends on whether the
112 * global variable errno is thread safe, some system libraries make it 112 * global variable errno is thread safe, some system libraries make it
113 * a thread-local variable. When feasible, using the guaranteed 113 * a thread-local variable. When feasible, using the guaranteed
114 * thread-safe gnutls_transport_set_errno() may be better. 114 * thread-safe MHD_gnutls_transport_set_errno() may be better.
115 **/ 115 **/
116void 116void
117gnutls_transport_set_global_errno (int err) 117MHD_gnutls_transport_set_global_errno (int err)
118{ 118{
119 errno = err; 119 errno = err;
120} 120}
@@ -123,11 +123,11 @@ gnutls_transport_set_global_errno (int err)
123 * HANDSHAKE DATA. 123 * HANDSHAKE DATA.
124 */ 124 */
125int 125int
126_gnutls_record_buffer_put (content_type_t type, 126mhd_gnutls_record_buffer_put (content_type_t type,
127 gnutls_session_t session, 127 mhd_gtls_session_t session, opaque * data,
128 opaque * data, size_t length) 128 size_t length)
129{ 129{
130 gnutls_buffer *buf; 130 mhd_gtls_buffer *buf;
131 131
132 if (length == 0) 132 if (length == 0)
133 return 0; 133 return 0;
@@ -157,7 +157,7 @@ _gnutls_record_buffer_put (content_type_t type,
157 return GNUTLS_E_INVALID_REQUEST; 157 return GNUTLS_E_INVALID_REQUEST;
158 } 158 }
159 159
160 if (_gnutls_buffer_append (buf, data, length) < 0) 160 if (mhd_gtls_buffer_append (buf, data, length) < 0)
161 { 161 {
162 gnutls_assert (); 162 gnutls_assert ();
163 return GNUTLS_E_MEMORY_ERROR; 163 return GNUTLS_E_MEMORY_ERROR;
@@ -167,7 +167,8 @@ _gnutls_record_buffer_put (content_type_t type,
167} 167}
168 168
169int 169int
170_gnutls_record_buffer_get_size (content_type_t type, gnutls_session_t session) 170mhd_gnutls_record_buffer_get_size (content_type_t type,
171 mhd_gtls_session_t session)
171{ 172{
172 switch (type) 173 switch (type)
173 { 174 {
@@ -186,8 +187,8 @@ _gnutls_record_buffer_get_size (content_type_t type, gnutls_session_t session)
186} 187}
187 188
188/** 189/**
189 * gnutls_record_check_pending - checks if there are any data to receive in gnutls buffers. 190 * MHD_gtls_record_check_pending - checks if there are any data to receive in gnutls buffers.
190 * @session: is a #gnutls_session_t structure. 191 * @session: is a #mhd_gtls_session_t structure.
191 * 192 *
192 * This function checks if there are any data to receive 193 * This function checks if there are any data to receive
193 * in the gnutls buffers. Returns the size of that data or 0. 194 * in the gnutls buffers. Returns the size of that data or 0.
@@ -197,15 +198,14 @@ _gnutls_record_buffer_get_size (content_type_t type, gnutls_session_t session)
197 * to work). 198 * to work).
198 **/ 199 **/
199size_t 200size_t
200gnutls_record_check_pending (gnutls_session_t session) 201MHD_gtls_record_check_pending (mhd_gtls_session_t session)
201{ 202{
202 return _gnutls_record_buffer_get_size (GNUTLS_APPLICATION_DATA, session); 203 return mhd_gnutls_record_buffer_get_size (GNUTLS_APPLICATION_DATA, session);
203} 204}
204 205
205int 206int
206_gnutls_record_buffer_get (content_type_t type, 207mhd_gtls_record_buffer_get (content_type_t type, mhd_gtls_session_t session,
207 gnutls_session_t session, 208 opaque * data, size_t length)
208 opaque * data, size_t length)
209{ 209{
210 if (length == 0 || data == NULL) 210 if (length == 0 || data == NULL)
211 { 211 {
@@ -289,8 +289,8 @@ _gnutls_record_buffer_get (content_type_t type,
289 * Flags are only used if the default recv() function is being used. 289 * Flags are only used if the default recv() function is being used.
290 */ 290 */
291static ssize_t 291static ssize_t
292_gnutls_read (gnutls_session_t session, 292_gnutls_read (mhd_gtls_session_t session, void *iptr,
293 void *iptr, size_t sizeOfPtr, int flags) 293 size_t sizeOfPtr, int flags)
294{ 294{
295 size_t left; 295 size_t left;
296 ssize_t i = 0; 296 ssize_t i = 0;
@@ -303,13 +303,12 @@ _gnutls_read (gnutls_session_t session,
303 left = sizeOfPtr; 303 left = sizeOfPtr;
304 while (left > 0) 304 while (left > 0)
305 { 305 {
306
307 session->internals.errnum = 0; 306 session->internals.errnum = 0;
308
309 if (session->internals._gnutls_pull_func == NULL) 307 if (session->internals._gnutls_pull_func == NULL)
310 { 308 {
311 i = recv (GNUTLS_POINTER_TO_INT (fd), &ptr[sizeOfPtr - left], left, 309 i =
312 flags); 310 recv (GNUTLS_POINTER_TO_INT (fd), &ptr[sizeOfPtr - left], left,
311 flags);
313#if HAVE_WINSOCK 312#if HAVE_WINSOCK
314 if (i < 0) 313 if (i < 0)
315 { 314 {
@@ -333,8 +332,9 @@ _gnutls_read (gnutls_session_t session,
333#endif 332#endif
334 } 333 }
335 else 334 else
336 i = session->internals._gnutls_pull_func (fd, &ptr[sizeOfPtr - 335 i = session->internals._gnutls_pull_func (fd,
337 left], left); 336 &ptr[sizeOfPtr - left],
337 left);
338 338
339 if (i < 0) 339 if (i < 0)
340 { 340 {
@@ -394,14 +394,14 @@ finish:
394 line[0] = 0; 394 line[0] = 0;
395 395
396 sprintf (tmp, "%.4x - ", x); 396 sprintf (tmp, "%.4x - ", x);
397 _gnutls_str_cat (line, sizeof (line), tmp); 397 mhd_gtls_str_cat (line, sizeof (line), tmp);
398 398
399 for (j = 0; j < 16; j++) 399 for (j = 0; j < 16; j++)
400 { 400 {
401 if (sum < (sizeOfPtr - left)) 401 if (sum < (sizeOfPtr - left))
402 { 402 {
403 sprintf (tmp, "%.2x ", ((unsigned char *) ptr)[sum++]); 403 sprintf (tmp, "%.2x ", ((unsigned char *) ptr)[sum++]);
404 _gnutls_str_cat (line, sizeof (line), tmp); 404 mhd_gtls_str_cat (line, sizeof (line), tmp);
405 } 405 }
406 } 406 }
407 _gnutls_read_log ("%s\n", line); 407 _gnutls_read_log ("%s\n", line);
@@ -417,7 +417,7 @@ finish:
417 * Clears the peeked data (read with MSG_PEEK). 417 * Clears the peeked data (read with MSG_PEEK).
418 */ 418 */
419int 419int
420_gnutls_io_clear_peeked_data (gnutls_session_t session) 420mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session)
421{ 421{
422 char *peekdata; 422 char *peekdata;
423 int ret, sum; 423 int ret, sum;
@@ -457,7 +457,7 @@ _gnutls_io_clear_peeked_data (gnutls_session_t session)
457} 457}
458 458
459void 459void
460_gnutls_io_clear_read_buffer (gnutls_session_t session) 460mhd_gtls_io_clear_read_buffer (mhd_gtls_session_t session)
461{ 461{
462 session->internals.record_recv_buffer.length = 0; 462 session->internals.record_recv_buffer.length = 0;
463} 463}
@@ -465,16 +465,15 @@ _gnutls_io_clear_read_buffer (gnutls_session_t session)
465/* This function is like recv(with MSG_PEEK). But it does not return -1 on error. 465/* This function is like recv(with MSG_PEEK). But it does not return -1 on error.
466 * It does return gnutls_errno instead. 466 * It does return gnutls_errno instead.
467 * This function reads data from the socket and keeps them in a buffer, of up to 467 * This function reads data from the socket and keeps them in a buffer, of up to
468 * MAX_RECV_SIZE. 468 * MAX_RECV_SIZE.
469 * 469 *
470 * This is not a general purpose function. It returns EXACTLY the data requested, 470 * This is not a general purpose function. It returns EXACTLY the data requested,
471 * which are stored in a local (in the session) buffer. A pointer (iptr) to this buffer is returned. 471 * which are stored in a local (in the session) buffer. A pointer (iptr) to this buffer is returned.
472 * 472 *
473 */ 473 */
474ssize_t 474ssize_t
475_gnutls_io_read_buffered (gnutls_session_t session, 475mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
476 opaque ** iptr, 476 size_t sizeOfPtr, content_type_t recv_type)
477 size_t sizeOfPtr, content_type_t recv_type)
478{ 477{
479 ssize_t ret = 0, ret2 = 0; 478 ssize_t ret = 0, ret2 = 0;
480 size_t min; 479 size_t min;
@@ -501,7 +500,7 @@ _gnutls_io_read_buffered (gnutls_session_t session,
501 else 500 else
502 { 501 {
503 /* leave peeked data to the kernel space only if application data 502 /* leave peeked data to the kernel space only if application data
504 * is received and we don't have any peeked 503 * is received and we don't have any peeked
505 * data in gnutls session. 504 * data in gnutls session.
506 */ 505 */
507 if (recv_type != GNUTLS_APPLICATION_DATA 506 if (recv_type != GNUTLS_APPLICATION_DATA
@@ -534,8 +533,8 @@ _gnutls_io_read_buffered (gnutls_session_t session,
534 /* Check if the previously read data plus the new data to 533 /* Check if the previously read data plus the new data to
535 * receive are longer than the maximum receive buffer size. 534 * receive are longer than the maximum receive buffer size.
536 */ 535 */
537 if ((session->internals.record_recv_buffer.length + recvdata) > 536 if ((session->internals.record_recv_buffer.length + recvdata)
538 MAX_RECV_SIZE) 537 > MAX_RECV_SIZE)
539 { 538 {
540 gnutls_assert (); /* internal error */ 539 gnutls_assert (); /* internal error */
541 return GNUTLS_E_INVALID_REQUEST; 540 return GNUTLS_E_INVALID_REQUEST;
@@ -544,8 +543,8 @@ _gnutls_io_read_buffered (gnutls_session_t session,
544 /* Allocate the data required to store the new packet. 543 /* Allocate the data required to store the new packet.
545 */ 544 */
546 alloc_size = recvdata + session->internals.record_recv_buffer.length; 545 alloc_size = recvdata + session->internals.record_recv_buffer.length;
547 session->internals.record_recv_buffer.data 546 session->internals.record_recv_buffer.data =
548 = gnutls_realloc_fast (session->internals.record_recv_buffer.data, 547 mhd_gtls_realloc_fast (session->internals.record_recv_buffer.data,
549 alloc_size); 548 alloc_size);
550 if (session->internals.record_recv_buffer.data == NULL) 549 if (session->internals.record_recv_buffer.data == NULL)
551 { 550 {
@@ -565,7 +564,7 @@ _gnutls_io_read_buffered (gnutls_session_t session,
565 /* return immediately if we got an interrupt or eagain 564 /* return immediately if we got an interrupt or eagain
566 * error. 565 * error.
567 */ 566 */
568 if (ret < 0 && gnutls_error_is_fatal (ret) == 0) 567 if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
569 { 568 {
570 return ret; 569 return ret;
571 } 570 }
@@ -592,7 +591,7 @@ _gnutls_io_read_buffered (gnutls_session_t session,
592 { 591 {
593 ret2 = _gnutls_read (session, &buf[buf_pos], recvlowat, MSG_PEEK); 592 ret2 = _gnutls_read (session, &buf[buf_pos], recvlowat, MSG_PEEK);
594 593
595 if (ret2 < 0 && gnutls_error_is_fatal (ret2) == 0) 594 if (ret2 < 0 && MHD_gtls_error_is_fatal (ret2) == 0)
596 { 595 {
597 return ret2; 596 return ret2;
598 } 597 }
@@ -652,7 +651,7 @@ _gnutls_io_read_buffered (gnutls_session_t session,
652#define MEMSUB(x,y) ((ssize_t)((ptrdiff_t)x-(ptrdiff_t)y)) 651#define MEMSUB(x,y) ((ssize_t)((ptrdiff_t)x-(ptrdiff_t)y))
653 652
654inline static int 653inline static int
655_gnutls_buffer_insert (gnutls_buffer * buffer, 654_gnutls_buffer_insert (mhd_gtls_buffer * buffer,
656 const opaque * _data, size_t data_size) 655 const opaque * _data, size_t data_size)
657{ 656{
658 657
@@ -681,7 +680,7 @@ _gnutls_buffer_insert (gnutls_buffer * buffer,
681 680
682 } 681 }
683 682
684 if (_gnutls_buffer_append (buffer, _data, data_size) < 0) 683 if (mhd_gtls_buffer_append (buffer, _data, data_size) < 0)
685 { 684 {
686 gnutls_assert (); 685 gnutls_assert ();
687 return GNUTLS_E_MEMORY_ERROR; 686 return GNUTLS_E_MEMORY_ERROR;
@@ -691,7 +690,7 @@ _gnutls_buffer_insert (gnutls_buffer * buffer,
691} 690}
692 691
693inline static int 692inline static int
694_gnutls_buffer_get (gnutls_buffer * buffer, 693_gnutls_buffer_get (mhd_gtls_buffer * buffer,
695 const opaque ** ptr, size_t * ptr_size) 694 const opaque ** ptr, size_t * ptr_size)
696{ 695{
697 *ptr_size = buffer->length; 696 *ptr_size = buffer->length;
@@ -708,12 +707,12 @@ _gnutls_buffer_get (gnutls_buffer * buffer,
708 * 707 *
709 * We need to push exactly the data in n, since we cannot send less 708 * We need to push exactly the data in n, since we cannot send less
710 * data. In TLS the peer must receive the whole packet in order 709 * data. In TLS the peer must receive the whole packet in order
711 * to decrypt and verify the integrity. 710 * to decrypt and verify the integrity.
712 * 711 *
713 */ 712 */
714ssize_t 713ssize_t
715_gnutls_io_write_buffered (gnutls_session_t session, 714mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
716 const void *iptr, size_t n) 715 const void *iptr, size_t n)
717{ 716{
718 size_t left; 717 size_t left;
719 unsigned j, x, sum = 0; 718 unsigned j, x, sum = 0;
@@ -743,9 +742,8 @@ _gnutls_io_write_buffered (gnutls_session_t session,
743 if (iptr == NULL) 742 if (iptr == NULL)
744 { 743 {
745 /* checking is handled above */ 744 /* checking is handled above */
746 ret 745 ret = _gnutls_buffer_get (&session->internals.record_send_buffer, &ptr,
747 = 746 &n);
748 _gnutls_buffer_get (&session->internals.record_send_buffer, &ptr, &n);
749 if (ret < 0) 747 if (ret < 0)
750 { 748 {
751 gnutls_assert (); 749 gnutls_assert ();
@@ -843,14 +841,14 @@ _gnutls_io_write_buffered (gnutls_session_t session,
843 break; 841 break;
844 842
845 sprintf (tmp, "%.4x - ", x); 843 sprintf (tmp, "%.4x - ", x);
846 _gnutls_str_cat (line, sizeof (line), tmp); 844 mhd_gtls_str_cat (line, sizeof (line), tmp);
847 845
848 for (j = 0; j < 16; j++) 846 for (j = 0; j < 16; j++)
849 { 847 {
850 if (sum < n - left) 848 if (sum < n - left)
851 { 849 {
852 sprintf (tmp, "%.2x ", ((unsigned char *) ptr)[sum++]); 850 sprintf (tmp, "%.2x ", ((unsigned char *) ptr)[sum++]);
853 _gnutls_str_cat (line, sizeof (line), tmp); 851 mhd_gtls_str_cat (line, sizeof (line), tmp);
854 } 852 }
855 else 853 else
856 break; 854 break;
@@ -874,14 +872,14 @@ _gnutls_io_write_buffered (gnutls_session_t session,
874 * interrupted. 872 * interrupted.
875 */ 873 */
876ssize_t 874ssize_t
877_gnutls_io_write_flush (gnutls_session_t session) 875mhd_gtls_io_write_flush (mhd_gtls_session_t session)
878{ 876{
879 ssize_t ret; 877 ssize_t ret;
880 878
881 if (session->internals.record_send_buffer.length == 0) 879 if (session->internals.record_send_buffer.length == 0)
882 return 0; /* done */ 880 return 0; /* done */
883 881
884 ret = _gnutls_io_write_buffered (session, NULL, 0); 882 ret = mhd_gtls_io_write_buffered (session, NULL, 0);
885 _gnutls_write_log ("WRITE FLUSH: %d [buffer: %d]\n", ret, 883 _gnutls_write_log ("WRITE FLUSH: %d [buffer: %d]\n", ret,
886 session->internals.record_send_buffer.length); 884 session->internals.record_send_buffer.length);
887 885
@@ -893,10 +891,10 @@ _gnutls_io_write_flush (gnutls_session_t session)
893 * interrupted. 891 * interrupted.
894 */ 892 */
895ssize_t 893ssize_t
896_gnutls_handshake_io_write_flush (gnutls_session_t session) 894mhd_gtls_handshake_io_write_flush (mhd_gtls_session_t session)
897{ 895{
898 ssize_t ret; 896 ssize_t ret;
899 ret = _gnutls_handshake_io_send_int (session, 0, 0, NULL, 0); 897 ret = mhd_gtls_handshake_io_send_int (session, 0, 0, NULL, 0);
900 if (ret < 0) 898 if (ret < 0)
901 { 899 {
902 gnutls_assert (); 900 gnutls_assert ();
@@ -914,14 +912,14 @@ _gnutls_handshake_io_write_flush (gnutls_session_t session)
914 return ret; 912 return ret;
915} 913}
916 914
917/* This is a send function for the gnutls handshake 915/* This is a send function for the gnutls handshake
918 * protocol. Just makes sure that all data have been sent. 916 * protocol. Just makes sure that all data have been sent.
919 */ 917 */
920ssize_t 918ssize_t
921_gnutls_handshake_io_send_int (gnutls_session_t session, 919mhd_gtls_handshake_io_send_int (mhd_gtls_session_t session,
922 content_type_t type, 920 content_type_t type,
923 gnutls_handshake_description_t htype, 921 gnutls_handshake_description_t htype,
924 const void *iptr, size_t n) 922 const void *iptr, size_t n)
925{ 923{
926 size_t left; 924 size_t left;
927 ssize_t ret = 0; 925 ssize_t ret = 0;
@@ -936,9 +934,8 @@ _gnutls_handshake_io_send_int (gnutls_session_t session,
936 /* resuming previously interrupted write 934 /* resuming previously interrupted write
937 */ 935 */
938 gnutls_assert (); 936 gnutls_assert ();
939 ret = 937 ret = _gnutls_buffer_get (&session->internals.handshake_send_buffer,
940 _gnutls_buffer_get (&session->internals.handshake_send_buffer, &ptr, 938 &ptr, &n);
941 &n);
942 if (ret < 0) 939 if (ret < 0)
943 { 940 {
944 gnutls_assert (); 941 gnutls_assert ();
@@ -996,7 +993,7 @@ _gnutls_handshake_io_send_int (gnutls_session_t session,
996 left = n; 993 left = n;
997 while (left > 0) 994 while (left > 0)
998 { 995 {
999 ret = _gnutls_send_int (session, type, htype, &ptr[n - left], left); 996 ret = mhd_gtls_send_int (session, type, htype, &ptr[n - left], left);
1000 997
1001 if (ret <= 0) 998 if (ret <= 0)
1002 { 999 {
@@ -1006,14 +1003,15 @@ _gnutls_handshake_io_send_int (gnutls_session_t session,
1006 ret = GNUTLS_E_INTERNAL_ERROR; 1003 ret = GNUTLS_E_INTERNAL_ERROR;
1007 } 1004 }
1008 1005
1009 if (left > 0 1006 if (left > 0 && (ret == GNUTLS_E_INTERRUPTED || ret
1010 && (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN)) 1007 == GNUTLS_E_AGAIN))
1011 { 1008 {
1012 gnutls_assert (); 1009 gnutls_assert ();
1013 1010
1014 retval = _gnutls_buffer_insert (&session->internals. 1011 retval =
1015 handshake_send_buffer, 1012 _gnutls_buffer_insert (&session->internals.
1016 &ptr[n - left], left); 1013 handshake_send_buffer, &ptr[n - left],
1014 left);
1017 if (retval < 0) 1015 if (retval < 0)
1018 { 1016 {
1019 gnutls_assert (); 1017 gnutls_assert ();
@@ -1047,14 +1045,14 @@ _gnutls_handshake_io_send_int (gnutls_session_t session,
1047 1045
1048} 1046}
1049 1047
1050/* This is a receive function for the gnutls handshake 1048/* This is a receive function for the gnutls handshake
1051 * protocol. Makes sure that we have received all data. 1049 * protocol. Makes sure that we have received all data.
1052 */ 1050 */
1053ssize_t 1051ssize_t
1054_gnutls_handshake_io_recv_int (gnutls_session_t session, 1052mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session,
1055 content_type_t type, 1053 content_type_t type,
1056 gnutls_handshake_description_t htype, 1054 gnutls_handshake_description_t htype,
1057 void *iptr, size_t sizeOfPtr) 1055 void *iptr, size_t sizeOfPtr)
1058{ 1056{
1059 size_t left; 1057 size_t left;
1060 ssize_t i; 1058 ssize_t i;
@@ -1084,8 +1082,7 @@ _gnutls_handshake_io_recv_int (gnutls_session_t session,
1084 session->internals.handshake_recv_buffer.length -= sizeOfPtr; 1082 session->internals.handshake_recv_buffer.length -= sizeOfPtr;
1085 1083
1086 memmove (session->internals.handshake_recv_buffer.data, 1084 memmove (session->internals.handshake_recv_buffer.data,
1087 &session->internals.handshake_recv_buffer. 1085 &session->internals.handshake_recv_buffer.data[sizeOfPtr],
1088 data[sizeOfPtr],
1089 session->internals.handshake_recv_buffer.length); 1086 session->internals.handshake_recv_buffer.length);
1090 1087
1091 return sizeOfPtr; 1088 return sizeOfPtr;
@@ -1105,7 +1102,7 @@ _gnutls_handshake_io_recv_int (gnutls_session_t session,
1105 while (left > 0) 1102 while (left > 0)
1106 { 1103 {
1107 dsize = sizeOfPtr - left; 1104 dsize = sizeOfPtr - left;
1108 i = _gnutls_recv_int (session, type, htype, &ptr[dsize], left); 1105 i = mhd_gtls_recv_int (session, type, htype, &ptr[dsize], left);
1109 if (i < 0) 1106 if (i < 0)
1110 { 1107 {
1111 1108
@@ -1114,7 +1111,8 @@ _gnutls_handshake_io_recv_int (gnutls_session_t session,
1114 gnutls_assert (); 1111 gnutls_assert ();
1115 1112
1116 session->internals.handshake_recv_buffer.data 1113 session->internals.handshake_recv_buffer.data
1117 = gnutls_realloc_fast (session->internals. 1114 =
1115 mhd_gtls_realloc_fast (session->internals.
1118 handshake_recv_buffer.data, dsize); 1116 handshake_recv_buffer.data, dsize);
1119 if (session->internals.handshake_recv_buffer.data == NULL) 1117 if (session->internals.handshake_recv_buffer.data == NULL)
1120 { 1118 {
@@ -1157,15 +1155,16 @@ _gnutls_handshake_io_recv_int (gnutls_session_t session,
1157 * and finished messages. 1155 * and finished messages.
1158 */ 1156 */
1159int 1157int
1160_gnutls_handshake_buffer_put (gnutls_session_t session, 1158mhd_gtls_handshake_buffer_put (mhd_gtls_session_t session, opaque * data,
1161 opaque * data, size_t length) 1159 size_t length)
1162{ 1160{
1163 1161
1164 if (length == 0) 1162 if (length == 0)
1165 return 0; 1163 return 0;
1166 1164
1167 if ((session->internals.max_handshake_data_buffer_size > 0) && ((length 1165 if ((session->internals.max_handshake_data_buffer_size > 0) && ((length
1168 + session-> 1166 +
1167 session->
1169 internals. 1168 internals.
1170 handshake_hash_buffer. 1169 handshake_hash_buffer.
1171 length) > 1170 length) >
@@ -1179,8 +1178,8 @@ _gnutls_handshake_buffer_put (gnutls_session_t session,
1179 1178
1180 _gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data\n", length); 1179 _gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data\n", length);
1181 1180
1182 if (_gnutls_buffer_append (&session->internals.handshake_hash_buffer, data, 1181 if (mhd_gtls_buffer_append (&session->internals.handshake_hash_buffer, data,
1183 length) < 0) 1182 length) < 0)
1184 { 1183 {
1185 gnutls_assert (); 1184 gnutls_assert ();
1186 return GNUTLS_E_MEMORY_ERROR; 1185 return GNUTLS_E_MEMORY_ERROR;
@@ -1190,7 +1189,7 @@ _gnutls_handshake_buffer_put (gnutls_session_t session,
1190} 1189}
1191 1190
1192int 1191int
1193_gnutls_handshake_buffer_get_size (gnutls_session_t session) 1192mhd_gtls_handshake_buffer_get_size (mhd_gtls_session_t session)
1194{ 1193{
1195 1194
1196 return session->internals.handshake_hash_buffer.length; 1195 return session->internals.handshake_hash_buffer.length;
@@ -1200,8 +1199,8 @@ _gnutls_handshake_buffer_get_size (gnutls_session_t session)
1200 * and returns data from it (peek mode!) 1199 * and returns data from it (peek mode!)
1201 */ 1200 */
1202int 1201int
1203_gnutls_handshake_buffer_peek (gnutls_session_t session, 1202mhd_gtls_handshake_buffer_peek (mhd_gtls_session_t session, opaque * data,
1204 opaque * data, size_t length) 1203 size_t length)
1205{ 1204{
1206 if (length > session->internals.handshake_hash_buffer.length) 1205 if (length > session->internals.handshake_hash_buffer.length)
1207 { 1206 {
@@ -1218,8 +1217,8 @@ _gnutls_handshake_buffer_peek (gnutls_session_t session,
1218 * and returns data from it (peek mode!) 1217 * and returns data from it (peek mode!)
1219 */ 1218 */
1220int 1219int
1221_gnutls_handshake_buffer_get_ptr (gnutls_session_t session, 1220mhd_gtls_handshake_buffer_get_ptr (mhd_gtls_session_t session,
1222 opaque ** data_ptr, size_t * length) 1221 opaque ** data_ptr, size_t * length)
1223{ 1222{
1224 if (length != NULL) 1223 if (length != NULL)
1225 *length = session->internals.handshake_hash_buffer.length; 1224 *length = session->internals.handshake_hash_buffer.length;
@@ -1235,7 +1234,7 @@ _gnutls_handshake_buffer_get_ptr (gnutls_session_t session,
1235/* Does not free the buffer 1234/* Does not free the buffer
1236 */ 1235 */
1237int 1236int
1238_gnutls_handshake_buffer_empty (gnutls_session_t session) 1237mhd_gtls_handshake_buffer_empty (mhd_gtls_session_t session)
1239{ 1238{
1240 1239
1241 _gnutls_buffers_log ("BUF[HSK]: Emptied buffer\n"); 1240 _gnutls_buffers_log ("BUF[HSK]: Emptied buffer\n");
@@ -1246,12 +1245,9 @@ _gnutls_handshake_buffer_empty (gnutls_session_t session)
1246} 1245}
1247 1246
1248int 1247int
1249_gnutls_handshake_buffer_clear (gnutls_session_t session) 1248mhd_gtls_handshake_buffer_clear (mhd_gtls_session_t session)
1250{ 1249{
1251
1252 _gnutls_buffers_log ("BUF[HSK]: Cleared Data from buffer\n"); 1250 _gnutls_buffers_log ("BUF[HSK]: Cleared Data from buffer\n");
1253 1251 mhd_gtls_buffer_clear (&session->internals.handshake_hash_buffer);
1254 _gnutls_buffer_clear (&session->internals.handshake_hash_buffer);
1255
1256 return 0; 1252 return 0;
1257} 1253}
diff --git a/src/daemon/https/tls/gnutls_buffers.h b/src/daemon/https/tls/gnutls_buffers.h
index aaafde0d..c3a09097 100644
--- a/src/daemon/https/tls/gnutls_buffers.h
+++ b/src/daemon/https/tls/gnutls_buffers.h
@@ -22,46 +22,46 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_record_buffer_put (content_type_t type, 25int mhd_gnutls_record_buffer_put (content_type_t type,
26 gnutls_session_t session, opaque * data, 26 mhd_gtls_session_t session, opaque * data,
27 size_t length); 27 size_t length);
28int _gnutls_record_buffer_get_size (content_type_t type, 28int mhd_gnutls_record_buffer_get_size (content_type_t type,
29 gnutls_session_t session); 29 mhd_gtls_session_t session);
30int _gnutls_record_buffer_get (content_type_t type, 30int mhd_gtls_record_buffer_get (content_type_t type,
31 gnutls_session_t session, opaque * data, 31 mhd_gtls_session_t session, opaque * data,
32 size_t length); 32 size_t length);
33ssize_t _gnutls_io_read_buffered (gnutls_session_t, opaque ** iptr, 33ssize_t mhd_gtls_io_read_buffered (mhd_gtls_session_t, opaque ** iptr,
34 size_t n, content_type_t); 34 size_t n, content_type_t);
35void _gnutls_io_clear_read_buffer (gnutls_session_t); 35void mhd_gtls_io_clear_read_buffer (mhd_gtls_session_t);
36int _gnutls_io_clear_peeked_data (gnutls_session_t session); 36int mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session);
37 37
38ssize_t _gnutls_io_write_buffered (gnutls_session_t, const void *iptr, 38ssize_t mhd_gtls_io_write_buffered (mhd_gtls_session_t, const void *iptr,
39 size_t n); 39 size_t n);
40ssize_t _gnutls_io_write_buffered2 (gnutls_session_t, const void *iptr, 40ssize_t mhd_gtls_io_write_buffered2 (mhd_gtls_session_t, const void *iptr,
41 size_t n, const void *iptr2, size_t n2); 41 size_t n, const void *iptr2, size_t n2);
42 42
43int _gnutls_handshake_buffer_get_size (gnutls_session_t session); 43int mhd_gtls_handshake_buffer_get_size (mhd_gtls_session_t session);
44int _gnutls_handshake_buffer_peek (gnutls_session_t session, opaque * data, 44int mhd_gtls_handshake_buffer_peek (mhd_gtls_session_t session, opaque * data,
45 size_t length); 45 size_t length);
46int _gnutls_handshake_buffer_put (gnutls_session_t session, opaque * data, 46int mhd_gtls_handshake_buffer_put (mhd_gtls_session_t session, opaque * data,
47 size_t length); 47 size_t length);
48int _gnutls_handshake_buffer_clear (gnutls_session_t session); 48int mhd_gtls_handshake_buffer_clear (mhd_gtls_session_t session);
49int _gnutls_handshake_buffer_empty (gnutls_session_t session); 49int mhd_gtls_handshake_buffer_empty (mhd_gtls_session_t session);
50int _gnutls_handshake_buffer_get_ptr (gnutls_session_t session, 50int mhd_gtls_handshake_buffer_get_ptr (mhd_gtls_session_t session,
51 opaque ** data_ptr, size_t * length); 51 opaque ** data_ptr, size_t * length);
52 52
53#define _gnutls_handshake_io_buffer_clear( session) \ 53#define _gnutls_handshake_io_buffer_clear( session) \
54 _gnutls_buffer_clear( &session->internals.handshake_send_buffer); \ 54 mhd_gtls_buffer_clear( &session->internals.handshake_send_buffer); \
55 _gnutls_buffer_clear( &session->internals.handshake_recv_buffer); \ 55 mhd_gtls_buffer_clear( &session->internals.handshake_recv_buffer); \
56 session->internals.handshake_send_buffer_prev_size = 0 56 session->internals.handshake_send_buffer_prev_size = 0
57 57
58ssize_t _gnutls_handshake_io_recv_int (gnutls_session_t, content_type_t, 58ssize_t mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t, content_type_t,
59 gnutls_handshake_description_t, void *, 59 gnutls_handshake_description_t, void *,
60 size_t); 60 size_t);
61ssize_t _gnutls_handshake_io_send_int (gnutls_session_t, content_type_t, 61ssize_t mhd_gtls_handshake_io_send_int (mhd_gtls_session_t, content_type_t,
62 gnutls_handshake_description_t, 62 gnutls_handshake_description_t,
63 const void *, size_t); 63 const void *, size_t);
64ssize_t _gnutls_io_write_flush (gnutls_session_t session); 64ssize_t mhd_gtls_io_write_flush (mhd_gtls_session_t session);
65ssize_t _gnutls_handshake_io_write_flush (gnutls_session_t session); 65ssize_t mhd_gtls_handshake_io_write_flush (mhd_gtls_session_t session);
66 66
67size_t gnutls_record_check_pending (gnutls_session_t session); 67size_t MHD_gtls_record_check_pending (mhd_gtls_session_t session);
diff --git a/src/daemon/https/tls/gnutls_cert.c b/src/daemon/https/tls/gnutls_cert.c
index 63c0b497..ee169a75 100644
--- a/src/daemon/https/tls/gnutls_cert.c
+++ b/src/daemon/https/tls/gnutls_cert.c
@@ -46,8 +46,8 @@
46#include "mpi.h" 46#include "mpi.h"
47 47
48/** 48/**
49 * gnutls_certificate_free_keys - Used to free all the keys from a gnutls_certificate_credentials_t structure 49 * MHD_gnutls_certificate_free_keys - Used to free all the keys from a mhd_gtls_cert_credentials_t structure
50 * @sc: is an #gnutls_certificate_credentials_t structure. 50 * @sc: is an #mhd_gtls_cert_credentials_t structure.
51 * 51 *
52 * This function will delete all the keys and the certificates associated 52 * This function will delete all the keys and the certificates associated
53 * with the given credentials. This function must not be called when a 53 * with the given credentials. This function must not be called when a
@@ -55,7 +55,7 @@
55 * 55 *
56 **/ 56 **/
57void 57void
58gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc) 58MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
59{ 59{
60 unsigned i, j; 60 unsigned i, j;
61 61
@@ -63,7 +63,7 @@ gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc)
63 { 63 {
64 for (j = 0; j < sc->cert_list_length[i]; j++) 64 for (j = 0; j < sc->cert_list_length[i]; j++)
65 { 65 {
66 _gnutls_gcert_deinit (&sc->cert_list[i][j]); 66 mhd_gtls_gcert_deinit (&sc->cert_list[i][j]);
67 } 67 }
68 gnutls_free (sc->cert_list[i]); 68 gnutls_free (sc->cert_list[i]);
69 } 69 }
@@ -76,7 +76,7 @@ gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc)
76 76
77 for (i = 0; i < sc->ncerts; i++) 77 for (i = 0; i < sc->ncerts; i++)
78 { 78 {
79 _gnutls_gkey_deinit (&sc->pkey[i]); 79 mhd_gtls_gkey_deinit (&sc->pkey[i]);
80 } 80 }
81 81
82 gnutls_free (sc->pkey); 82 gnutls_free (sc->pkey);
@@ -87,17 +87,17 @@ gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc)
87} 87}
88 88
89/** 89/**
90 * gnutls_certificate_free_cas - Used to free all the CAs from a gnutls_certificate_credentials_t structure 90 * MHD_gnutls_certificate_free_cas - Used to free all the CAs from a mhd_gtls_cert_credentials_t structure
91 * @sc: is an #gnutls_certificate_credentials_t structure. 91 * @sc: is an #mhd_gtls_cert_credentials_t structure.
92 * 92 *
93 * This function will delete all the CAs associated 93 * This function will delete all the CAs associated
94 * with the given credentials. Servers that do not use 94 * with the given credentials. Servers that do not use
95 * gnutls_certificate_verify_peers2() may call this to 95 * MHD_gtls_certificate_verify_peers2() may call this to
96 * save some memory. 96 * save some memory.
97 * 97 *
98 **/ 98 **/
99void 99void
100gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc) 100MHD_gnutls_certificate_free_cas (mhd_gtls_cert_credentials_t sc)
101{ 101{
102 unsigned j; 102 unsigned j;
103 103
@@ -114,8 +114,8 @@ gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc)
114} 114}
115 115
116/** 116/**
117 * gnutls_certificate_free_ca_names - Used to free all the CA names from a gnutls_certificate_credentials_t structure 117 * MHD_gnutls_certificate_free_ca_names - Used to free all the CA names from a mhd_gtls_cert_credentials_t structure
118 * @sc: is an #gnutls_certificate_credentials_t structure. 118 * @sc: is an #mhd_gtls_cert_credentials_t structure.
119 * 119 *
120 * This function will delete all the CA name in the 120 * This function will delete all the CA name in the
121 * given credentials. Clients may call this to save some memory 121 * given credentials. Clients may call this to save some memory
@@ -126,13 +126,13 @@ gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc)
126 * 126 *
127 **/ 127 **/
128void 128void
129gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t sc) 129MHD_gnutls_certificate_free_ca_names (mhd_gtls_cert_credentials_t sc)
130{ 130{
131 _gnutls_free_datum (&sc->x509_rdn_sequence); 131 _gnutls_free_datum (&sc->x509_rdn_sequence);
132} 132}
133 133
134/*- 134/*-
135 * _gnutls_certificate_get_rsa_params - Returns the RSA parameters pointer 135 * mhd_gtls_certificate_get_rsa_params - Returns the RSA parameters pointer
136 * @rsa_params: holds the RSA parameters or NULL. 136 * @rsa_params: holds the RSA parameters or NULL.
137 * @func: function to retrieve the parameters or NULL. 137 * @func: function to retrieve the parameters or NULL.
138 * @session: The session. 138 * @session: The session.
@@ -140,10 +140,10 @@ gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t sc)
140 * This function will return the rsa parameters pointer. 140 * This function will return the rsa parameters pointer.
141 * 141 *
142 -*/ 142 -*/
143gnutls_rsa_params_t 143mhd_gtls_rsa_params_t
144_gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params, 144mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params,
145 gnutls_params_function * func, 145 gnutls_params_function * func,
146 gnutls_session_t session) 146 mhd_gtls_session_t session)
147{ 147{
148 gnutls_params_st params; 148 gnutls_params_st params;
149 int ret; 149 int ret;
@@ -172,8 +172,8 @@ _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params,
172 172
173 173
174/** 174/**
175 * gnutls_certificate_free_credentials - Used to free an allocated gnutls_certificate_credentials_t structure 175 * MHD_gnutls_certificate_free_credentials - Used to free an allocated mhd_gtls_cert_credentials_t structure
176 * @sc: is an #gnutls_certificate_credentials_t structure. 176 * @sc: is an #mhd_gtls_cert_credentials_t structure.
177 * 177 *
178 * This structure is complex enough to manipulate directly thus 178 * This structure is complex enough to manipulate directly thus
179 * this helper function is provided in order to free (deallocate) it. 179 * this helper function is provided in order to free (deallocate) it.
@@ -183,13 +183,13 @@ _gnutls_certificate_get_rsa_params (gnutls_rsa_params_t rsa_params,
183 * this function). 183 * this function).
184 **/ 184 **/
185void 185void
186gnutls_certificate_free_credentials (gnutls_certificate_credentials_t sc) 186MHD_gnutls_certificate_free_credentials (mhd_gtls_cert_credentials_t sc)
187{ 187{
188 gnutls_certificate_free_keys (sc); 188 MHD_gnutls_certificate_free_keys (sc);
189 gnutls_certificate_free_cas (sc); 189 MHD_gnutls_certificate_free_cas (sc);
190 gnutls_certificate_free_ca_names (sc); 190 MHD_gnutls_certificate_free_ca_names (sc);
191#ifdef ENABLE_PKI 191#ifdef ENABLE_PKI
192 gnutls_certificate_free_crls (sc); 192 MHD_gnutls_certificate_free_crls (sc);
193#endif 193#endif
194 194
195#ifndef KEYRING_HACK 195#ifndef KEYRING_HACK
@@ -204,8 +204,8 @@ gnutls_certificate_free_credentials (gnutls_certificate_credentials_t sc)
204 204
205 205
206/** 206/**
207 * gnutls_certificate_allocate_credentials - Used to allocate a gnutls_certificate_credentials_t structure 207 * MHD_gnutls_certificate_allocate_credentials - Used to allocate a mhd_gtls_cert_credentials_t structure
208 * @res: is a pointer to an #gnutls_certificate_credentials_t structure. 208 * @res: is a pointer to an #mhd_gtls_cert_credentials_t structure.
209 * 209 *
210 * This structure is complex enough to manipulate directly thus this 210 * This structure is complex enough to manipulate directly thus this
211 * helper function is provided in order to allocate it. 211 * helper function is provided in order to allocate it.
@@ -213,7 +213,7 @@ gnutls_certificate_free_credentials (gnutls_certificate_credentials_t sc)
213 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 213 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
214 **/ 214 **/
215int 215int
216gnutls_certificate_allocate_credentials (gnutls_certificate_credentials_t * 216MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t *
217 res) 217 res)
218{ 218{
219 *res = gnutls_calloc (1, sizeof (certificate_credentials_st)); 219 *res = gnutls_calloc (1, sizeof (certificate_credentials_st));
@@ -235,7 +235,7 @@ gnutls_certificate_allocate_credentials (gnutls_certificate_credentials_t *
235 * extensions in order to disable unneded algorithms. 235 * extensions in order to disable unneded algorithms.
236 */ 236 */
237int 237int
238_gnutls_selected_cert_supported_kx (gnutls_session_t session, 238mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
239 gnutls_kx_algorithm_t ** alg, 239 gnutls_kx_algorithm_t ** alg,
240 int *alg_size) 240 int *alg_size)
241{ 241{
@@ -257,7 +257,7 @@ _gnutls_selected_cert_supported_kx (gnutls_session_t session,
257 257
258 for (kx = 0; kx < MAX_ALGOS; kx++) 258 for (kx = 0; kx < MAX_ALGOS; kx++)
259 { 259 {
260 pk = _gnutls_map_pk_get_pk (kx); 260 pk = mhd_gtls_map_pk_get_pk (kx);
261 if (pk == cert->subject_pk_algorithm) 261 if (pk == cert->subject_pk_algorithm)
262 { 262 {
263 /* then check key usage */ 263 /* then check key usage */
@@ -288,8 +288,8 @@ _gnutls_selected_cert_supported_kx (gnutls_session_t session,
288 288
289 289
290/** 290/**
291 * gnutls_certificate_server_set_request - Used to set whether to request a client certificate 291 * MHD_gtls_certificate_server_set_request - Used to set whether to request a client certificate
292 * @session: is an #gnutls_session_t structure. 292 * @session: is an #mhd_gtls_session_t structure.
293 * @req: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE 293 * @req: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE
294 * 294 *
295 * This function specifies if we (in case of a server) are going 295 * This function specifies if we (in case of a server) are going
@@ -300,21 +300,21 @@ _gnutls_selected_cert_supported_kx (gnutls_session_t session,
300 * send a certificate. 300 * send a certificate.
301 **/ 301 **/
302void 302void
303gnutls_certificate_server_set_request (gnutls_session_t session, 303MHD_gtls_certificate_server_set_request (mhd_gtls_session_t session,
304 gnutls_certificate_request_t req) 304 gnutls_certificate_request_t req)
305{ 305{
306 session->internals.send_cert_req = req; 306 session->internals.send_cert_req = req;
307} 307}
308 308
309/** 309/**
310 * gnutls_certificate_client_set_retrieve_function - Used to set a callback to retrieve the certificate 310 * MHD_gtls_certificate_client_set_retrieve_function - Used to set a callback to retrieve the certificate
311 * @cred: is a #gnutls_certificate_credentials_t structure. 311 * @cred: is a #mhd_gtls_cert_credentials_t structure.
312 * @func: is the callback function 312 * @func: is the callback function
313 * 313 *
314 * This function sets a callback to be called in order to retrieve the certificate 314 * This function sets a callback to be called in order to retrieve the certificate
315 * to be used in the handshake. 315 * to be used in the handshake.
316 * The callback's function prototype is: 316 * The callback's function prototype is:
317 * int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs, 317 * int (*callback)(mhd_gtls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
318 * const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr_st* st); 318 * const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr_st* st);
319 * 319 *
320 * @req_ca_cert is only used in X.509 certificates. 320 * @req_ca_cert is only used in X.509 certificates.
@@ -336,22 +336,22 @@ gnutls_certificate_server_set_request (gnutls_session_t session,
336 * should be set to zero. The value (-1) indicates error and the handshake 336 * should be set to zero. The value (-1) indicates error and the handshake
337 * will be terminated. 337 * will be terminated.
338 **/ 338 **/
339void gnutls_certificate_client_set_retrieve_function 339void MHD_gtls_certificate_client_set_retrieve_function
340 (gnutls_certificate_credentials_t cred, 340 (mhd_gtls_cert_credentials_t cred,
341 gnutls_certificate_client_retrieve_function * func) 341 gnutls_certificate_client_retrieve_function * func)
342{ 342{
343 cred->client_get_cert_callback = func; 343 cred->client_get_cert_callback = func;
344} 344}
345 345
346/** 346/**
347 * gnutls_certificate_server_set_retrieve_function - Used to set a callback to retrieve the certificate 347 * MHD_gtls_certificate_server_set_retrieve_function - Used to set a callback to retrieve the certificate
348 * @cred: is a #gnutls_certificate_credentials_t structure. 348 * @cred: is a #mhd_gtls_cert_credentials_t structure.
349 * @func: is the callback function 349 * @func: is the callback function
350 * 350 *
351 * This function sets a callback to be called in order to retrieve the certificate 351 * This function sets a callback to be called in order to retrieve the certificate
352 * to be used in the handshake. 352 * to be used in the handshake.
353 * The callback's function prototype is: 353 * The callback's function prototype is:
354 * int (*callback)(gnutls_session_t, gnutls_retr_st* st); 354 * int (*callback)(mhd_gtls_session_t, gnutls_retr_st* st);
355 * 355 *
356 * @st should contain the certificates and private keys. 356 * @st should contain the certificates and private keys.
357 * 357 *
@@ -362,8 +362,8 @@ void gnutls_certificate_client_set_retrieve_function
362 * return 0 on success. The value (-1) indicates error and the handshake 362 * return 0 on success. The value (-1) indicates error and the handshake
363 * will be terminated. 363 * will be terminated.
364 **/ 364 **/
365void gnutls_certificate_server_set_retrieve_function 365void MHD_gtls_certificate_server_set_retrieve_function
366 (gnutls_certificate_credentials_t cred, 366 (mhd_gtls_cert_credentials_t cred,
367 gnutls_certificate_server_retrieve_function * func) 367 gnutls_certificate_server_retrieve_function * func)
368{ 368{
369 cred->server_get_cert_callback = func; 369 cred->server_get_cert_callback = func;
@@ -446,21 +446,21 @@ _gnutls_x509_get_raw_crt_expiration_time (const gnutls_datum_t * cert)
446 * 446 *
447 -*/ 447 -*/
448int 448int
449_gnutls_openpgp_crt_verify_peers (gnutls_session_t session, 449_gnutls_openpgp_crt_verify_peers (mhd_gtls_session_t session,
450 unsigned int *status) 450 unsigned int *status)
451{ 451{
452 cert_auth_info_t info; 452 cert_auth_info_t info;
453 gnutls_certificate_credentials_t cred; 453 mhd_gtls_cert_credentials_t cred;
454 int peer_certificate_list_size, ret; 454 int peer_certificate_list_size, ret;
455 455
456 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 456 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
457 457
458 info = _gnutls_get_auth_info (session); 458 info = mhd_gtls_get_auth_info (session);
459 if (info == NULL) 459 if (info == NULL)
460 return GNUTLS_E_INVALID_REQUEST; 460 return GNUTLS_E_INVALID_REQUEST;
461 461
462 cred = (gnutls_certificate_credentials_t) 462 cred = (mhd_gtls_cert_credentials_t)
463 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 463 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
464 if (cred == NULL) 464 if (cred == NULL)
465 { 465 {
466 gnutls_assert (); 466 gnutls_assert ();
@@ -506,7 +506,7 @@ _gnutls_openpgp_crt_verify_peers (gnutls_session_t session,
506 506
507 507
508/** 508/**
509 * gnutls_certificate_verify_peers2 - This function returns the peer's certificate verification status 509 * MHD_gtls_certificate_verify_peers2 - This function returns the peer's certificate verification status
510 * @session: is a gnutls session 510 * @session: is a gnutls session
511 * @status: is the output of the verification 511 * @status: is the output of the verification
512 * 512 *
@@ -516,7 +516,7 @@ _gnutls_openpgp_crt_verify_peers (gnutls_session_t session,
516 * elements bitwise or'd. To avoid denial of service attacks some 516 * elements bitwise or'd. To avoid denial of service attacks some
517 * default upper limits regarding the certificate key size and chain 517 * default upper limits regarding the certificate key size and chain
518 * size are set. To override them use 518 * size are set. To override them use
519 * gnutls_certificate_set_verify_limits(). 519 * MHD_gnutls_certificate_set_verify_limits().
520 * 520 *
521 * Note that you must also check the peer's name in order to check if 521 * Note that you must also check the peer's name in order to check if
522 * the verified certificate belongs to the actual peer. 522 * the verified certificate belongs to the actual peer.
@@ -526,20 +526,20 @@ _gnutls_openpgp_crt_verify_peers (gnutls_session_t session,
526 * 526 *
527 * Note that some commonly used X.509 Certificate Authorities are 527 * Note that some commonly used X.509 Certificate Authorities are
528 * still using Version 1 certificates. If you want to accept them, 528 * still using Version 1 certificates. If you want to accept them,
529 * you need to call gnutls_certificate_set_verify_flags() with, e.g., 529 * you need to call MHD_gnutls_certificate_set_verify_flags() with, e.g.,
530 * %GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT parameter. 530 * %GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT parameter.
531 * 531 *
532 * Returns: a negative error code on error and zero on success. 532 * Returns: a negative error code on error and zero on success.
533 **/ 533 **/
534int 534int
535gnutls_certificate_verify_peers2 (gnutls_session_t session, 535MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session,
536 unsigned int *status) 536 unsigned int *status)
537{ 537{
538 cert_auth_info_t info; 538 cert_auth_info_t info;
539 539
540 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 540 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
541 541
542 info = _gnutls_get_auth_info (session); 542 info = mhd_gtls_get_auth_info (session);
543 if (info == NULL) 543 if (info == NULL)
544 { 544 {
545 return GNUTLS_E_NO_CERTIFICATE_FOUND; 545 return GNUTLS_E_NO_CERTIFICATE_FOUND;
@@ -560,7 +560,7 @@ gnutls_certificate_verify_peers2 (gnutls_session_t session,
560} 560}
561 561
562/** 562/**
563 * gnutls_certificate_verify_peers - This function returns the peer's certificate verification status 563 * MHD_gtls_certificate_verify_peers - This function returns the peer's certificate verification status
564 * @session: is a gnutls session 564 * @session: is a gnutls session
565 * 565 *
566 * This function will try to verify the peer's certificate and return 566 * This function will try to verify the peer's certificate and return
@@ -574,15 +574,15 @@ gnutls_certificate_verify_peers2 (gnutls_session_t session,
574 * 574 *
575 * This is the same as gnutls_x509_crt_list_verify(). 575 * This is the same as gnutls_x509_crt_list_verify().
576 * 576 *
577 * Deprecated: Use gnutls_certificate_verify_peers2() instead. 577 * Deprecated: Use MHD_gtls_certificate_verify_peers2() instead.
578 **/ 578 **/
579int 579int
580gnutls_certificate_verify_peers (gnutls_session_t session) 580MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session)
581{ 581{
582 unsigned int status; 582 unsigned int status;
583 int ret; 583 int ret;
584 584
585 ret = gnutls_certificate_verify_peers2 (session, &status); 585 ret = MHD_gtls_certificate_verify_peers2 (session, &status);
586 586
587 if (ret < 0) 587 if (ret < 0)
588 { 588 {
@@ -594,7 +594,7 @@ gnutls_certificate_verify_peers (gnutls_session_t session)
594} 594}
595 595
596/** 596/**
597 * gnutls_certificate_expiration_time_peers - This function returns the peer's certificate expiration time 597 * MHD_gtls_certificate_expiration_time_peers - This function returns the peer's certificate expiration time
598 * @session: is a gnutls session 598 * @session: is a gnutls session
599 * 599 *
600 * This function will return the peer's certificate expiration time. 600 * This function will return the peer's certificate expiration time.
@@ -602,13 +602,13 @@ gnutls_certificate_verify_peers (gnutls_session_t session)
602 * Returns: (time_t)-1 on error. 602 * Returns: (time_t)-1 on error.
603 **/ 603 **/
604time_t 604time_t
605gnutls_certificate_expiration_time_peers (gnutls_session_t session) 605MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session)
606{ 606{
607 cert_auth_info_t info; 607 cert_auth_info_t info;
608 608
609 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 609 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
610 610
611 info = _gnutls_get_auth_info (session); 611 info = mhd_gtls_get_auth_info (session);
612 if (info == NULL) 612 if (info == NULL)
613 { 613 {
614 return (time_t) - 1; 614 return (time_t) - 1;
@@ -638,7 +638,7 @@ gnutls_certificate_expiration_time_peers (gnutls_session_t session)
638} 638}
639 639
640/** 640/**
641 * gnutls_certificate_activation_time_peers - This function returns the peer's certificate activation time 641 * MHD_gtls_certificate_activation_time_peers - This function returns the peer's certificate activation time
642 * @session: is a gnutls session 642 * @session: is a gnutls session
643 * 643 *
644 * This function will return the peer's certificate activation time. 644 * This function will return the peer's certificate activation time.
@@ -647,13 +647,13 @@ gnutls_certificate_expiration_time_peers (gnutls_session_t session)
647 * Returns: (time_t)-1 on error. 647 * Returns: (time_t)-1 on error.
648 **/ 648 **/
649time_t 649time_t
650gnutls_certificate_activation_time_peers (gnutls_session_t session) 650MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session)
651{ 651{
652 cert_auth_info_t info; 652 cert_auth_info_t info;
653 653
654 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 654 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
655 655
656 info = _gnutls_get_auth_info (session); 656 info = mhd_gtls_get_auth_info (session);
657 if (info == NULL) 657 if (info == NULL)
658 { 658 {
659 return (time_t) - 1; 659 return (time_t) - 1;
@@ -683,7 +683,7 @@ gnutls_certificate_activation_time_peers (gnutls_session_t session)
683} 683}
684 684
685int 685int
686_gnutls_raw_cert_to_gcert (gnutls_cert * gcert, 686mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert,
687 gnutls_certificate_type_t type, 687 gnutls_certificate_type_t type,
688 const gnutls_datum_t * raw_cert, 688 const gnutls_datum_t * raw_cert,
689 int flags /* OR of ConvFlags */ ) 689 int flags /* OR of ConvFlags */ )
@@ -691,7 +691,7 @@ _gnutls_raw_cert_to_gcert (gnutls_cert * gcert,
691 switch (type) 691 switch (type)
692 { 692 {
693 case MHD_GNUTLS_CRT_X509: 693 case MHD_GNUTLS_CRT_X509:
694 return _gnutls_x509_raw_cert_to_gcert (gcert, raw_cert, flags); 694 return mhd_gtls_x509_raw_cert_to_gcert (gcert, raw_cert, flags);
695 case MHD_GNUTLS_CRT_OPENPGP: 695 case MHD_GNUTLS_CRT_OPENPGP:
696 if (_E_gnutls_openpgp_raw_key_to_gcert == NULL) 696 if (_E_gnutls_openpgp_raw_key_to_gcert == NULL)
697 { 697 {
@@ -706,7 +706,7 @@ _gnutls_raw_cert_to_gcert (gnutls_cert * gcert,
706} 706}
707 707
708int 708int
709_gnutls_raw_privkey_to_gkey (gnutls_privkey * key, 709mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key,
710 gnutls_certificate_type_t type, 710 gnutls_certificate_type_t type,
711 const gnutls_datum_t * raw_key, 711 const gnutls_datum_t * raw_key,
712 int key_enc /* DER or PEM */ ) 712 int key_enc /* DER or PEM */ )
@@ -741,7 +741,7 @@ _gnutls_raw_privkey_to_gkey (gnutls_privkey * key,
741 * The critical extensions will be catched by the verification functions. 741 * The critical extensions will be catched by the verification functions.
742 */ 742 */
743int 743int
744_gnutls_x509_raw_cert_to_gcert (gnutls_cert * gcert, 744mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
745 const gnutls_datum_t * derCert, 745 const gnutls_datum_t * derCert,
746 int flags /* OR of ConvFlags */ ) 746 int flags /* OR of ConvFlags */ )
747{ 747{
@@ -763,7 +763,7 @@ _gnutls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
763 return ret; 763 return ret;
764 } 764 }
765 765
766 ret = _gnutls_x509_crt_to_gcert (gcert, cert, flags); 766 ret = mhd_gtls_x509_crt_to_gcert (gcert, cert, flags);
767 gnutls_x509_crt_deinit (cert); 767 gnutls_x509_crt_deinit (cert);
768 768
769 return ret; 769 return ret;
@@ -772,7 +772,7 @@ _gnutls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
772/* Like above but it accepts a parsed certificate instead. 772/* Like above but it accepts a parsed certificate instead.
773 */ 773 */
774int 774int
775_gnutls_x509_crt_to_gcert (gnutls_cert * gcert, 775mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
776 gnutls_x509_crt_t cert, unsigned int flags) 776 gnutls_x509_crt_t cert, unsigned int flags)
777{ 777{
778 int ret = 0; 778 int ret = 0;
@@ -857,7 +857,7 @@ _gnutls_x509_crt_to_gcert (gnutls_cert * gcert,
857} 857}
858 858
859void 859void
860_gnutls_gcert_deinit (gnutls_cert * cert) 860mhd_gtls_gcert_deinit (gnutls_cert * cert)
861{ 861{
862 int i; 862 int i;
863 863
@@ -866,21 +866,21 @@ _gnutls_gcert_deinit (gnutls_cert * cert)
866 866
867 for (i = 0; i < cert->params_size; i++) 867 for (i = 0; i < cert->params_size; i++)
868 { 868 {
869 _gnutls_mpi_release (&cert->params[i]); 869 mhd_gtls_mpi_release (&cert->params[i]);
870 } 870 }
871 871
872 _gnutls_free_datum (&cert->raw); 872 _gnutls_free_datum (&cert->raw);
873} 873}
874 874
875/** 875/**
876 * gnutls_sign_callback_set: 876 * MHD_gtls_sign_callback_set:
877 * @session: is a gnutls session 877 * @session: is a gnutls session
878 * @sign_func: function pointer to application's sign callback. 878 * @sign_func: function pointer to application's sign callback.
879 * @userdata: void pointer that will be passed to sign callback. 879 * @userdata: void pointer that will be passed to sign callback.
880 * 880 *
881 * Set the callback function. The function must have this prototype: 881 * Set the callback function. The function must have this prototype:
882 * 882 *
883 * typedef int (*gnutls_sign_func) (gnutls_session_t session, 883 * typedef int (*gnutls_sign_func) (mhd_gtls_session_t session,
884 * void *userdata, 884 * void *userdata,
885 * gnutls_certificate_type_t cert_type, 885 * gnutls_certificate_type_t cert_type,
886 * const gnutls_datum_t * cert, 886 * const gnutls_datum_t * cert,
@@ -889,10 +889,10 @@ _gnutls_gcert_deinit (gnutls_cert * cert)
889 * 889 *
890 * The @userdata parameter is passed to the @sign_func verbatim, and 890 * The @userdata parameter is passed to the @sign_func verbatim, and
891 * can be used to store application-specific data needed in the 891 * can be used to store application-specific data needed in the
892 * callback function. See also gnutls_sign_callback_get(). 892 * callback function. See also MHD_gtls_sign_callback_get().
893 **/ 893 **/
894void 894void
895gnutls_sign_callback_set (gnutls_session_t session, 895MHD_gtls_sign_callback_set (mhd_gtls_session_t session,
896 gnutls_sign_func sign_func, void *userdata) 896 gnutls_sign_func sign_func, void *userdata)
897{ 897{
898 session->internals.sign_func = sign_func; 898 session->internals.sign_func = sign_func;
@@ -900,17 +900,17 @@ gnutls_sign_callback_set (gnutls_session_t session,
900} 900}
901 901
902/** 902/**
903 * gnutls_sign_callback_get: 903 * MHD_gtls_sign_callback_get:
904 * @session: is a gnutls session 904 * @session: is a gnutls session
905 * @userdata: if non-%NULL, will be set to abstract callback pointer. 905 * @userdata: if non-%NULL, will be set to abstract callback pointer.
906 * 906 *
907 * Retrieve the callback function, and its userdata pointer. 907 * Retrieve the callback function, and its userdata pointer.
908 * 908 *
909 * Returns: The function pointer set by gnutls_sign_callback_set(), or 909 * Returns: The function pointer set by MHD_gtls_sign_callback_set(), or
910 * if not set, %NULL. 910 * if not set, %NULL.
911 **/ 911 **/
912gnutls_sign_func 912gnutls_sign_func
913gnutls_sign_callback_get (gnutls_session_t session, void **userdata) 913MHD_gtls_sign_callback_get (mhd_gtls_session_t session, void **userdata)
914{ 914{
915 if (userdata) 915 if (userdata)
916 *userdata = session->internals.sign_func_userdata; 916 *userdata = session->internals.sign_func_userdata;
diff --git a/src/daemon/https/tls/gnutls_cert.h b/src/daemon/https/tls/gnutls_cert.h
index 09df10eb..30b23b27 100644
--- a/src/daemon/https/tls/gnutls_cert.h
+++ b/src/daemon/https/tls/gnutls_cert.h
@@ -98,7 +98,7 @@ typedef struct gnutls_privkey_int
98 gnutls_pk_algorithm_t pk_algorithm; 98 gnutls_pk_algorithm_t pk_algorithm;
99} gnutls_privkey; 99} gnutls_privkey;
100 100
101struct gnutls_session_int; /* because gnutls_session_t is not defined when this file is included */ 101struct MHD_gtls_session_int; /* because mhd_gtls_session_t is not defined when this file is included */
102 102
103typedef enum ConvFlags 103typedef enum ConvFlags
104{ 104{
@@ -107,24 +107,24 @@ typedef enum ConvFlags
107 CERT_ONLY_EXTENSIONS = 16 107 CERT_ONLY_EXTENSIONS = 16
108} ConvFlags; 108} ConvFlags;
109 109
110int _gnutls_x509_raw_cert_to_gcert (gnutls_cert * gcert, 110int mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
111 const gnutls_datum_t * derCert, 111 const gnutls_datum_t * derCert,
112 int flags); 112 int flags);
113int _gnutls_x509_crt_to_gcert (gnutls_cert * gcert, gnutls_x509_crt_t cert, 113int mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert, gnutls_x509_crt_t cert,
114 unsigned int flags); 114 unsigned int flags);
115 115
116void _gnutls_gkey_deinit (gnutls_privkey * key); 116void mhd_gtls_gkey_deinit (gnutls_privkey * key);
117void _gnutls_gcert_deinit (gnutls_cert * cert); 117void mhd_gtls_gcert_deinit (gnutls_cert * cert);
118 118
119int _gnutls_selected_cert_supported_kx (struct gnutls_session_int *session, 119int mhd_gtls_selected_cert_supported_kx (struct MHD_gtls_session_int *session,
120 gnutls_kx_algorithm_t ** alg, 120 gnutls_kx_algorithm_t ** alg,
121 int *alg_size); 121 int *alg_size);
122 122
123int _gnutls_raw_cert_to_gcert (gnutls_cert * gcert, 123int mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert,
124 gnutls_certificate_type_t type, 124 gnutls_certificate_type_t type,
125 const gnutls_datum_t * raw_cert, 125 const gnutls_datum_t * raw_cert,
126 int flags /* OR of ConvFlags */ ); 126 int flags /* OR of ConvFlags */ );
127int _gnutls_raw_privkey_to_gkey (gnutls_privkey * key, 127int mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key,
128 gnutls_certificate_type_t type, 128 gnutls_certificate_type_t type,
129 const gnutls_datum_t * raw_key, 129 const gnutls_datum_t * raw_key,
130 int key_enc /* DER or PEM */ ); 130 int key_enc /* DER or PEM */ );
diff --git a/src/daemon/https/tls/gnutls_cipher.c b/src/daemon/https/tls/gnutls_cipher.c
index c9526ec6..4dd99f92 100644
--- a/src/daemon/https/tls/gnutls_cipher.c
+++ b/src/daemon/https/tls/gnutls_cipher.c
@@ -42,7 +42,7 @@
42#include <gc.h> 42#include <gc.h>
43 43
44inline static int 44inline static int
45is_write_comp_null (gnutls_session_t session) 45is_write_comp_null (mhd_gtls_session_t session)
46{ 46{
47 if (session->security_parameters.write_compression_algorithm == 47 if (session->security_parameters.write_compression_algorithm ==
48 MHD_GNUTLS_COMP_NULL) 48 MHD_GNUTLS_COMP_NULL)
@@ -52,7 +52,7 @@ is_write_comp_null (gnutls_session_t session)
52} 52}
53 53
54inline static int 54inline static int
55is_read_comp_null (gnutls_session_t session) 55is_read_comp_null (mhd_gtls_session_t session)
56{ 56{
57 if (session->security_parameters.read_compression_algorithm == 57 if (session->security_parameters.read_compression_algorithm ==
58 MHD_GNUTLS_COMP_NULL) 58 MHD_GNUTLS_COMP_NULL)
@@ -68,7 +68,7 @@ is_read_comp_null (gnutls_session_t session)
68 * If random pad != 0 then the random pad data will be appended. 68 * If random pad != 0 then the random pad data will be appended.
69 */ 69 */
70int 70int
71_gnutls_encrypt (gnutls_session_t session, const opaque * headers, 71mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
72 size_t headers_size, const opaque * data, 72 size_t headers_size, const opaque * data,
73 size_t data_size, opaque * ciphertext, 73 size_t data_size, opaque * ciphertext,
74 size_t ciphertext_size, content_type_t type, int random_pad) 74 size_t ciphertext_size, content_type_t type, int random_pad)
@@ -99,7 +99,7 @@ _gnutls_encrypt (gnutls_session_t session, const opaque * headers,
99 } 99 }
100 } 100 }
101 101
102 ret = _gnutls_compressed2ciphertext (session, &ciphertext[headers_size], 102 ret = mhd_gtls_compressed2ciphertext (session, &ciphertext[headers_size],
103 ciphertext_size - headers_size, 103 ciphertext_size - headers_size,
104 comp, type, random_pad); 104 comp, type, random_pad);
105 105
@@ -115,7 +115,7 @@ _gnutls_encrypt (gnutls_session_t session, const opaque * headers,
115 115
116 /* copy the headers */ 116 /* copy the headers */
117 memcpy (ciphertext, headers, headers_size); 117 memcpy (ciphertext, headers, headers_size);
118 _gnutls_write_uint16 (ret, &ciphertext[3]); 118 mhd_gtls_write_uint16 (ret, &ciphertext[3]);
119 119
120 return ret + headers_size; 120 return ret + headers_size;
121} 121}
@@ -124,7 +124,7 @@ _gnutls_encrypt (gnutls_session_t session, const opaque * headers,
124 * Returns the decrypted data length. 124 * Returns the decrypted data length.
125 */ 125 */
126int 126int
127_gnutls_decrypt (gnutls_session_t session, opaque * ciphertext, 127mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
128 size_t ciphertext_size, uint8_t * data, 128 size_t ciphertext_size, uint8_t * data,
129 size_t max_data_size, content_type_t type) 129 size_t max_data_size, content_type_t type)
130{ 130{
@@ -139,7 +139,7 @@ _gnutls_decrypt (gnutls_session_t session, opaque * ciphertext,
139 gcipher.data = ciphertext; 139 gcipher.data = ciphertext;
140 140
141 ret = 141 ret =
142 _gnutls_ciphertext2compressed (session, data, max_data_size, 142 mhd_gtls_ciphertext2compressed (session, data, max_data_size,
143 gcipher, type); 143 gcipher, type);
144 if (ret < 0) 144 if (ret < 0)
145 { 145 {
@@ -204,11 +204,11 @@ mac_init (gnutls_mac_algorithm_t mac, opaque * secret, int secret_size,
204 204
205 if (ver == MHD_GNUTLS_SSL3) 205 if (ver == MHD_GNUTLS_SSL3)
206 { /* SSL 3.0 */ 206 { /* SSL 3.0 */
207 td = _gnutls_mac_init_ssl3 (mac, secret, secret_size); 207 td = mhd_gnutls_mac_init_ssl3 (mac, secret, secret_size);
208 } 208 }
209 else 209 else
210 { /* TLS 1.x */ 210 { /* TLS 1.x */
211 td = _gnutls_hmac_init (mac, secret, secret_size); 211 td = mhd_gtls_hmac_init (mac, secret, secret_size);
212 } 212 }
213 213
214 return td; 214 return td;
@@ -219,16 +219,16 @@ mac_deinit (mac_hd_t td, opaque * res, int ver)
219{ 219{
220 if (ver == MHD_GNUTLS_SSL3) 220 if (ver == MHD_GNUTLS_SSL3)
221 { /* SSL 3.0 */ 221 { /* SSL 3.0 */
222 _gnutls_mac_deinit_ssl3 (td, res); 222 mhd_gnutls_mac_deinit_ssl3 (td, res);
223 } 223 }
224 else 224 else
225 { 225 {
226 _gnutls_hmac_deinit (td, res); 226 mhd_gnutls_hmac_deinit (td, res);
227 } 227 }
228} 228}
229 229
230inline static int 230inline static int
231calc_enc_length (gnutls_session_t session, int data_size, 231calc_enc_length (mhd_gtls_session_t session, int data_size,
232 int hash_size, uint8_t * pad, int random_pad, 232 int hash_size, uint8_t * pad, int random_pad,
233 cipher_type_t block_algo, uint16_t blocksize) 233 cipher_type_t block_algo, uint16_t blocksize)
234{ 234{
@@ -289,7 +289,7 @@ calc_enc_length (gnutls_session_t session, int data_size,
289 * return the actual encrypted data length. 289 * return the actual encrypted data length.
290 */ 290 */
291int 291int
292_gnutls_compressed2ciphertext (gnutls_session_t session, 292mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
293 opaque * cipher_data, int cipher_size, 293 opaque * cipher_data, int cipher_size,
294 gnutls_datum_t compressed, 294 gnutls_datum_t compressed,
295 content_type_t _type, int random_pad) 295 content_type_t _type, int random_pad)
@@ -302,21 +302,21 @@ _gnutls_compressed2ciphertext (gnutls_session_t session,
302 uint8_t type = _type; 302 uint8_t type = _type;
303 uint8_t major, minor; 303 uint8_t major, minor;
304 int hash_size = 304 int hash_size =
305 _gnutls_hash_get_algo_len (session->security_parameters. 305 mhd_gnutls_hash_get_algo_len (session->security_parameters.
306 write_mac_algorithm); 306 write_mac_algorithm);
307 gnutls_protocol_t ver; 307 gnutls_protocol_t ver;
308 int blocksize = 308 int blocksize =
309 _gnutls_cipher_get_block_size (session->security_parameters. 309 mhd_gtls_cipher_get_block_size (session->security_parameters.
310 write_bulk_cipher_algorithm); 310 write_bulk_cipher_algorithm);
311 cipher_type_t block_algo = 311 cipher_type_t block_algo =
312 _gnutls_cipher_is_block (session->security_parameters. 312 mhd_gtls_cipher_is_block (session->security_parameters.
313 write_bulk_cipher_algorithm); 313 write_bulk_cipher_algorithm);
314 opaque *data_ptr; 314 opaque *data_ptr;
315 315
316 316
317 ver = gnutls_protocol_get_version (session); 317 ver = MHD_gnutls_protocol_get_version (session);
318 minor = _gnutls_version_get_minor (ver); 318 minor = mhd_gtls_version_get_minor (ver);
319 major = _gnutls_version_get_major (ver); 319 major = mhd_gtls_version_get_major (ver);
320 320
321 321
322 /* Initialize MAC */ 322 /* Initialize MAC */
@@ -332,22 +332,22 @@ _gnutls_compressed2ciphertext (gnutls_session_t session,
332 return GNUTLS_E_INTERNAL_ERROR; 332 return GNUTLS_E_INTERNAL_ERROR;
333 } 333 }
334 334
335 c_length = _gnutls_conv_uint16 (compressed.size); 335 c_length = mhd_gtls_conv_uint16 (compressed.size);
336 336
337 if (td != GNUTLS_MAC_FAILED) 337 if (td != GNUTLS_MAC_FAILED)
338 { /* actually when the algorithm in not the NULL one */ 338 { /* actually when the algorithm in not the NULL one */
339 _gnutls_hmac (td, 339 mhd_gnutls_hash (td,
340 UINT64DATA (session->connection_state. 340 UINT64DATA (session->connection_state.
341 write_sequence_number), 8); 341 write_sequence_number), 8);
342 342
343 _gnutls_hmac (td, &type, 1); 343 mhd_gnutls_hash (td, &type, 1);
344 if (ver >= MHD_GNUTLS_TLS1_0) 344 if (ver >= MHD_GNUTLS_TLS1_0)
345 { /* TLS 1.0 or higher */ 345 { /* TLS 1.0 or higher */
346 _gnutls_hmac (td, &major, 1); 346 mhd_gnutls_hash (td, &major, 1);
347 _gnutls_hmac (td, &minor, 1); 347 mhd_gnutls_hash (td, &minor, 1);
348 } 348 }
349 _gnutls_hmac (td, &c_length, 2); 349 mhd_gnutls_hash (td, &c_length, 2);
350 _gnutls_hmac (td, compressed.data, compressed.size); 350 mhd_gnutls_hash (td, compressed.data, compressed.size);
351 mac_deinit (td, MAC, ver); 351 mac_deinit (td, MAC, ver);
352 } 352 }
353 353
@@ -401,7 +401,7 @@ _gnutls_compressed2ciphertext (gnutls_session_t session,
401 401
402 /* Actual encryption (inplace). 402 /* Actual encryption (inplace).
403 */ 403 */
404 ret = _gnutls_cipher_encrypt (session->connection_state. 404 ret = mhd_gtls_cipher_encrypt (session->connection_state.
405 write_cipher_state, cipher_data, length); 405 write_cipher_state, cipher_data, length);
406 if (ret < 0) 406 if (ret < 0)
407 { 407 {
@@ -416,7 +416,7 @@ _gnutls_compressed2ciphertext (gnutls_session_t session,
416 * Returns the actual compressed packet size. 416 * Returns the actual compressed packet size.
417 */ 417 */
418int 418int
419_gnutls_ciphertext2compressed (gnutls_session_t session, 419mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
420 opaque * compress_data, 420 opaque * compress_data,
421 int compress_size, 421 int compress_size,
422 gnutls_datum_t ciphertext, uint8_t type) 422 gnutls_datum_t ciphertext, uint8_t type)
@@ -431,14 +431,14 @@ _gnutls_ciphertext2compressed (gnutls_session_t session,
431 uint8_t major, minor; 431 uint8_t major, minor;
432 gnutls_protocol_t ver; 432 gnutls_protocol_t ver;
433 int hash_size = 433 int hash_size =
434 _gnutls_hash_get_algo_len (session->security_parameters. 434 mhd_gnutls_hash_get_algo_len (session->security_parameters.
435 read_mac_algorithm); 435 read_mac_algorithm);
436 436
437 ver = gnutls_protocol_get_version (session); 437 ver = MHD_gnutls_protocol_get_version (session);
438 minor = _gnutls_version_get_minor (ver); 438 minor = mhd_gtls_version_get_minor (ver);
439 major = _gnutls_version_get_major (ver); 439 major = mhd_gtls_version_get_major (ver);
440 440
441 blocksize = _gnutls_cipher_get_block_size (session->security_parameters. 441 blocksize = mhd_gtls_cipher_get_block_size (session->security_parameters.
442 read_bulk_cipher_algorithm); 442 read_bulk_cipher_algorithm);
443 443
444 /* initialize MAC 444 /* initialize MAC
@@ -458,11 +458,11 @@ _gnutls_ciphertext2compressed (gnutls_session_t session,
458 458
459 /* actual decryption (inplace) 459 /* actual decryption (inplace)
460 */ 460 */
461 switch (_gnutls_cipher_is_block 461 switch (mhd_gtls_cipher_is_block
462 (session->security_parameters.read_bulk_cipher_algorithm)) 462 (session->security_parameters.read_bulk_cipher_algorithm))
463 { 463 {
464 case CIPHER_STREAM: 464 case CIPHER_STREAM:
465 if ((ret = _gnutls_cipher_decrypt (session->connection_state. 465 if ((ret = mhd_gtls_cipher_decrypt (session->connection_state.
466 read_cipher_state, 466 read_cipher_state,
467 ciphertext.data, 467 ciphertext.data,
468 ciphertext.size)) < 0) 468 ciphertext.size)) < 0)
@@ -481,7 +481,7 @@ _gnutls_ciphertext2compressed (gnutls_session_t session,
481 return GNUTLS_E_DECRYPTION_FAILED; 481 return GNUTLS_E_DECRYPTION_FAILED;
482 } 482 }
483 483
484 if ((ret = _gnutls_cipher_decrypt (session->connection_state. 484 if ((ret = mhd_gtls_cipher_decrypt (session->connection_state.
485 read_cipher_state, 485 read_cipher_state,
486 ciphertext.data, 486 ciphertext.data,
487 ciphertext.size)) < 0) 487 ciphertext.size)) < 0)
@@ -534,27 +534,27 @@ _gnutls_ciphertext2compressed (gnutls_session_t session,
534 534
535 if (length < 0) 535 if (length < 0)
536 length = 0; 536 length = 0;
537 c_length = _gnutls_conv_uint16 ((uint16_t) length); 537 c_length = mhd_gtls_conv_uint16 ((uint16_t) length);
538 538
539 /* Pass the type, version, length and compressed through 539 /* Pass the type, version, length and compressed through
540 * MAC. 540 * MAC.
541 */ 541 */
542 if (td != GNUTLS_MAC_FAILED) 542 if (td != GNUTLS_MAC_FAILED)
543 { 543 {
544 _gnutls_hmac (td, 544 mhd_gnutls_hash (td,
545 UINT64DATA (session->connection_state. 545 UINT64DATA (session->connection_state.
546 read_sequence_number), 8); 546 read_sequence_number), 8);
547 547
548 _gnutls_hmac (td, &type, 1); 548 mhd_gnutls_hash (td, &type, 1);
549 if (ver >= MHD_GNUTLS_TLS1_0) 549 if (ver >= MHD_GNUTLS_TLS1_0)
550 { /* TLS 1.x */ 550 { /* TLS 1.x */
551 _gnutls_hmac (td, &major, 1); 551 mhd_gnutls_hash (td, &major, 1);
552 _gnutls_hmac (td, &minor, 1); 552 mhd_gnutls_hash (td, &minor, 1);
553 } 553 }
554 _gnutls_hmac (td, &c_length, 2); 554 mhd_gnutls_hash (td, &c_length, 2);
555 555
556 if (length > 0) 556 if (length > 0)
557 _gnutls_hmac (td, ciphertext.data, length); 557 mhd_gnutls_hash (td, ciphertext.data, length);
558 558
559 mac_deinit (td, MAC, ver); 559 mac_deinit (td, MAC, ver);
560 } 560 }
diff --git a/src/daemon/https/tls/gnutls_cipher.h b/src/daemon/https/tls/gnutls_cipher.h
index 0279e859..2bdf5a18 100644
--- a/src/daemon/https/tls/gnutls_cipher.h
+++ b/src/daemon/https/tls/gnutls_cipher.h
@@ -22,20 +22,20 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_encrypt (gnutls_session_t session, const opaque * headers, 25int mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
26 size_t headers_size, const opaque * data, 26 size_t headers_size, const opaque * data,
27 size_t data_size, opaque * ciphertext, 27 size_t data_size, opaque * ciphertext,
28 size_t ciphertext_size, content_type_t type, 28 size_t ciphertext_size, content_type_t type,
29 int random_pad); 29 int random_pad);
30 30
31int _gnutls_decrypt (gnutls_session_t session, opaque * ciphertext, 31int mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
32 size_t ciphertext_size, uint8_t * data, size_t data_size, 32 size_t ciphertext_size, uint8_t * data, size_t data_size,
33 content_type_t type); 33 content_type_t type);
34int _gnutls_compressed2ciphertext (gnutls_session_t session, 34int mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
35 opaque * cipher_data, int cipher_size, 35 opaque * cipher_data, int cipher_size,
36 gnutls_datum_t compressed, 36 gnutls_datum_t compressed,
37 content_type_t _type, int random_pad); 37 content_type_t _type, int random_pad);
38int _gnutls_ciphertext2compressed (gnutls_session_t session, 38int mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
39 opaque * compress_data, 39 opaque * compress_data,
40 int compress_size, 40 int compress_size,
41 gnutls_datum_t ciphertext, uint8_t type); 41 gnutls_datum_t ciphertext, uint8_t type);
diff --git a/src/daemon/https/tls/gnutls_cipher_int.c b/src/daemon/https/tls/gnutls_cipher_int.c
index bfe734d5..489e14c7 100644
--- a/src/daemon/https/tls/gnutls_cipher_int.c
+++ b/src/daemon/https/tls/gnutls_cipher_int.c
@@ -28,7 +28,7 @@
28#include <gnutls_datum.h> 28#include <gnutls_datum.h>
29 29
30cipher_hd_t 30cipher_hd_t
31_gnutls_cipher_init (gnutls_cipher_algorithm_t cipher, 31mhd_gtls_cipher_init (gnutls_cipher_algorithm_t cipher,
32 const gnutls_datum_t * key, const gnutls_datum_t * iv) 32 const gnutls_datum_t * key, const gnutls_datum_t * iv)
33{ 33{
34 cipher_hd_t ret = NULL; 34 cipher_hd_t ret = NULL;
@@ -95,7 +95,7 @@ _gnutls_cipher_init (gnutls_cipher_algorithm_t cipher,
95} 95}
96 96
97int 97int
98_gnutls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen) 98mhd_gtls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
99{ 99{
100 if (handle != GNUTLS_CIPHER_FAILED) 100 if (handle != GNUTLS_CIPHER_FAILED)
101 { 101 {
@@ -109,7 +109,7 @@ _gnutls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
109} 109}
110 110
111int 111int
112_gnutls_cipher_decrypt (cipher_hd_t handle, void *ciphertext, 112mhd_gtls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
113 int ciphertextlen) 113 int ciphertextlen)
114{ 114{
115 if (handle != GNUTLS_CIPHER_FAILED) 115 if (handle != GNUTLS_CIPHER_FAILED)
@@ -124,7 +124,7 @@ _gnutls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
124} 124}
125 125
126void 126void
127_gnutls_cipher_deinit (cipher_hd_t handle) 127mhd_gnutls_cipher_deinit (cipher_hd_t handle)
128{ 128{
129 if (handle != GNUTLS_CIPHER_FAILED) 129 if (handle != GNUTLS_CIPHER_FAILED)
130 { 130 {
diff --git a/src/daemon/https/tls/gnutls_cipher_int.h b/src/daemon/https/tls/gnutls_cipher_int.h
index 78ed487f..03681fc6 100644
--- a/src/daemon/https/tls/gnutls_cipher_int.h
+++ b/src/daemon/https/tls/gnutls_cipher_int.h
@@ -29,18 +29,18 @@
29#define GNUTLS_CIPHER_FAILED NULL 29#define GNUTLS_CIPHER_FAILED NULL
30 30
31// TODO gc_cipher_handle -> void * x3 31// TODO gc_cipher_handle -> void * x3
32void * _gnutls_cipher_init(gnutls_cipher_algorithm_t cipher, 32void * mhd_gtls_cipher_init(gnutls_cipher_algorithm_t cipher,
33 const gnutls_datum_t * key, 33 const gnutls_datum_t * key,
34 const gnutls_datum_t * iv); 34 const gnutls_datum_t * iv);
35 35
36int _gnutls_cipher_encrypt(void * handle, 36int mhd_gtls_cipher_encrypt(void * handle,
37 void *text, 37 void *text,
38 int textlen); 38 int textlen);
39 39
40int _gnutls_cipher_decrypt(void * handle, 40int mhd_gtls_cipher_decrypt(void * handle,
41 void *ciphertext, 41 void *ciphertext,
42 int ciphertextlen); 42 int ciphertextlen);
43 43
44void _gnutls_cipher_deinit(void * handle); 44void mhd_gnutls_cipher_deinit(void * handle);
45 45
46#endif /* GNUTLS_CIPHER_INT */ 46#endif /* GNUTLS_CIPHER_INT */
diff --git a/src/daemon/https/tls/gnutls_compress.c b/src/daemon/https/tls/gnutls_compress.c
index e6561ad6..7ee4c2fe 100644
--- a/src/daemon/https/tls/gnutls_compress.c
+++ b/src/daemon/https/tls/gnutls_compress.c
@@ -34,7 +34,7 @@
34/* These functions allocate the return value internally 34/* These functions allocate the return value internally
35 */ 35 */
36int 36int
37_gnutls_m_plaintext2compressed (gnutls_session_t session, 37_gnutls_m_plaintext2compressed (mhd_gtls_session_t session,
38 gnutls_datum_t * compressed, 38 gnutls_datum_t * compressed,
39 const gnutls_datum_t * plaintext) 39 const gnutls_datum_t * plaintext)
40{ 40{
@@ -42,7 +42,7 @@ _gnutls_m_plaintext2compressed (gnutls_session_t session,
42 opaque *data; 42 opaque *data;
43 43
44 size = 44 size =
45 _gnutls_compress (session->connection_state.write_compression_state, 45 mhd_gtls_compress (session->connection_state.write_compression_state,
46 plaintext->data, plaintext->size, &data, 46 plaintext->data, plaintext->size, &data,
47 MAX_RECORD_SEND_SIZE + EXTRA_COMP_SIZE); 47 MAX_RECORD_SEND_SIZE + EXTRA_COMP_SIZE);
48 if (size < 0) 48 if (size < 0)
@@ -57,7 +57,7 @@ _gnutls_m_plaintext2compressed (gnutls_session_t session,
57} 57}
58 58
59int 59int
60_gnutls_m_compressed2plaintext (gnutls_session_t session, 60_gnutls_m_compressed2plaintext (mhd_gtls_session_t session,
61 gnutls_datum_t * plain, 61 gnutls_datum_t * plain,
62 const gnutls_datum_t * compressed) 62 const gnutls_datum_t * compressed)
63{ 63{
@@ -65,7 +65,7 @@ _gnutls_m_compressed2plaintext (gnutls_session_t session,
65 opaque *data; 65 opaque *data;
66 66
67 size = 67 size =
68 _gnutls_decompress (session->connection_state. 68 mhd_gtls_decompress (session->connection_state.
69 read_compression_state, compressed->data, 69 read_compression_state, compressed->data,
70 compressed->size, &data, MAX_RECORD_RECV_SIZE); 70 compressed->size, &data, MAX_RECORD_RECV_SIZE);
71 if (size < 0) 71 if (size < 0)
diff --git a/src/daemon/https/tls/gnutls_compress.h b/src/daemon/https/tls/gnutls_compress.h
index 44666321..2fa07aaa 100644
--- a/src/daemon/https/tls/gnutls_compress.h
+++ b/src/daemon/https/tls/gnutls_compress.h
@@ -22,9 +22,9 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_m_plaintext2compressed (gnutls_session_t session, 25int _gnutls_m_plaintext2compressed (mhd_gtls_session_t session,
26 gnutls_datum_t * compressed, 26 gnutls_datum_t * compressed,
27 const gnutls_datum_t *plaintext); 27 const gnutls_datum_t *plaintext);
28int _gnutls_m_compressed2plaintext (gnutls_session_t session, 28int _gnutls_m_compressed2plaintext (mhd_gtls_session_t session,
29 gnutls_datum_t * plain, 29 gnutls_datum_t * plain,
30 const gnutls_datum_t* compressed); 30 const gnutls_datum_t* compressed);
diff --git a/src/daemon/https/tls/gnutls_compress_int.c b/src/daemon/https/tls/gnutls_compress_int.c
index 77c733b0..f300e297 100644
--- a/src/daemon/https/tls/gnutls_compress_int.c
+++ b/src/daemon/https/tls/gnutls_compress_int.c
@@ -31,7 +31,7 @@
31 * decompress. 31 * decompress.
32 */ 32 */
33comp_hd_t 33comp_hd_t
34_gnutls_comp_init (gnutls_compression_method_t method, int d) 34mhd_gtls_comp_init (gnutls_compression_method_t method, int d)
35{ 35{
36 comp_hd_t ret; 36 comp_hd_t ret;
37 37
@@ -54,9 +54,9 @@ _gnutls_comp_init (gnutls_compression_method_t method, int d)
54 int comp_level; 54 int comp_level;
55 z_stream *zhandle; 55 z_stream *zhandle;
56 56
57 window_bits = _gnutls_compression_get_wbits (method); 57 window_bits = mhd_gtls_compression_get_wbits (method);
58 mem_level = _gnutls_compression_get_mem_level (method); 58 mem_level = mhd_gtls_compression_get_mem_level (method);
59 comp_level = _gnutls_compression_get_comp_level (method); 59 comp_level = mhd_gtls_compression_get_comp_level (method);
60 60
61 ret->handle = gnutls_malloc (sizeof (z_stream)); 61 ret->handle = gnutls_malloc (sizeof (z_stream));
62 if (ret->handle == NULL) 62 if (ret->handle == NULL)
@@ -102,7 +102,7 @@ cleanup_ret:
102 * decompress. 102 * decompress.
103 */ 103 */
104void 104void
105_gnutls_comp_deinit (comp_hd_t handle, int d) 105mhd_gtls_comp_deinit (comp_hd_t handle, int d)
106{ 106{
107 if (handle != NULL) 107 if (handle != NULL)
108 { 108 {
@@ -129,7 +129,7 @@ _gnutls_comp_deinit (comp_hd_t handle, int d)
129 */ 129 */
130 130
131int 131int
132_gnutls_compress (comp_hd_t handle, const opaque * plain, 132mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
133 size_t plain_size, opaque ** compressed, 133 size_t plain_size, opaque ** compressed,
134 size_t max_comp_size) 134 size_t max_comp_size)
135{ 135{
@@ -204,7 +204,7 @@ _gnutls_compress (comp_hd_t handle, const opaque * plain,
204 204
205 205
206int 206int
207_gnutls_decompress (comp_hd_t handle, opaque * compressed, 207mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
208 size_t compressed_size, opaque ** plain, 208 size_t compressed_size, opaque ** plain,
209 size_t max_record_size) 209 size_t max_record_size)
210{ 210{
@@ -247,7 +247,7 @@ _gnutls_decompress (comp_hd_t handle, opaque * compressed,
247 do 247 do
248 { 248 {
249 out_size += 512; 249 out_size += 512;
250 *plain = gnutls_realloc_fast (*plain, out_size); 250 *plain = mhd_gtls_realloc_fast (*plain, out_size);
251 if (*plain == NULL) 251 if (*plain == NULL)
252 { 252 {
253 gnutls_assert (); 253 gnutls_assert ();
diff --git a/src/daemon/https/tls/gnutls_compress_int.h b/src/daemon/https/tls/gnutls_compress_int.h
index 4479fb4d..f494b0f7 100644
--- a/src/daemon/https/tls/gnutls_compress_int.h
+++ b/src/daemon/https/tls/gnutls_compress_int.h
@@ -37,13 +37,13 @@ typedef struct comp_hd_t_STRUCT
37 gnutls_compression_method_t algo; 37 gnutls_compression_method_t algo;
38} *comp_hd_t; 38} *comp_hd_t;
39 39
40comp_hd_t _gnutls_comp_init (gnutls_compression_method_t, int d); 40comp_hd_t mhd_gtls_comp_init (gnutls_compression_method_t, int d);
41void _gnutls_comp_deinit (comp_hd_t handle, int d); 41void mhd_gtls_comp_deinit (comp_hd_t handle, int d);
42 42
43int _gnutls_decompress (comp_hd_t handle, opaque * compressed, 43int mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
44 size_t compressed_size, opaque ** plain, 44 size_t compressed_size, opaque ** plain,
45 size_t max_record_size); 45 size_t max_record_size);
46int _gnutls_compress (comp_hd_t, const opaque * plain, size_t plain_size, 46int mhd_gtls_compress (comp_hd_t, const opaque * plain, size_t plain_size,
47 opaque ** compressed, size_t max_comp_size); 47 opaque ** compressed, size_t max_comp_size);
48 48
49#endif 49#endif
diff --git a/src/daemon/https/tls/gnutls_constate.c b/src/daemon/https/tls/gnutls_constate.c
index eff2184f..4e683de7 100644
--- a/src/daemon/https/tls/gnutls_constate.c
+++ b/src/daemon/https/tls/gnutls_constate.c
@@ -55,7 +55,7 @@ static const int servwrite_length = sizeof (servwrite) - 1;
55 * (session->cipher_specs) 55 * (session->cipher_specs)
56 */ 56 */
57int 57int
58_gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size, 58_gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
59 int key_size, int export_flag) 59 int key_size, int export_flag)
60{ 60{
61 61
@@ -99,7 +99,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
99 if (session->security_parameters.version == MHD_GNUTLS_SSL3) 99 if (session->security_parameters.version == MHD_GNUTLS_SSL3)
100 { /* SSL 3 */ 100 { /* SSL 3 */
101 ret = 101 ret =
102 _gnutls_ssl3_generate_random (session-> 102 mhd_gnutls_ssl3_generate_random (session->
103 security_parameters. 103 security_parameters.
104 master_secret, 104 master_secret,
105 TLS_MASTER_SIZE, rnd, 105 TLS_MASTER_SIZE, rnd,
@@ -109,7 +109,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
109 else 109 else
110 { /* TLS 1.0 */ 110 { /* TLS 1.0 */
111 ret = 111 ret =
112 _gnutls_PRF (session, session->security_parameters.master_secret, 112 mhd_gtls_PRF (session, session->security_parameters.master_secret,
113 TLS_MASTER_SIZE, keyexp, keyexp_length, 113 TLS_MASTER_SIZE, keyexp, keyexp_length,
114 rnd, 2 * TLS_RANDOM_SIZE, block_size, key_block); 114 rnd, 2 * TLS_RANDOM_SIZE, block_size, key_block);
115 } 115 }
@@ -122,7 +122,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
122 } 122 }
123 123
124 _gnutls_hard_log ("INT: KEY BLOCK[%d]: %s\n", block_size, 124 _gnutls_hard_log ("INT: KEY BLOCK[%d]: %s\n", block_size,
125 _gnutls_bin2hex (key_block, block_size, buf, 125 mhd_gtls_bin2hex (key_block, block_size, buf,
126 sizeof (buf))); 126 sizeof (buf)));
127 127
128 pos = 0; 128 pos = 0;
@@ -192,7 +192,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
192 if (session->security_parameters.version == MHD_GNUTLS_SSL3) 192 if (session->security_parameters.version == MHD_GNUTLS_SSL3)
193 { /* SSL 3 */ 193 { /* SSL 3 */
194 ret = 194 ret =
195 _gnutls_ssl3_hash_md5 (&key_block[pos], 195 mhd_gnutls_ssl3_hash_md5 (&key_block[pos],
196 key_size, rrnd, 196 key_size, rrnd,
197 2 * TLS_RANDOM_SIZE, 197 2 * TLS_RANDOM_SIZE,
198 EXPORT_FINAL_KEY_SIZE, 198 EXPORT_FINAL_KEY_SIZE,
@@ -202,7 +202,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
202 else 202 else
203 { /* TLS 1.0 */ 203 { /* TLS 1.0 */
204 ret = 204 ret =
205 _gnutls_PRF (session, &key_block[pos], key_size, 205 mhd_gtls_PRF (session, &key_block[pos], key_size,
206 cliwrite, cliwrite_length, 206 cliwrite, cliwrite_length,
207 rrnd, 207 rrnd,
208 2 * TLS_RANDOM_SIZE, 208 2 * TLS_RANDOM_SIZE,
@@ -224,7 +224,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
224 if (session->security_parameters.version == MHD_GNUTLS_SSL3) 224 if (session->security_parameters.version == MHD_GNUTLS_SSL3)
225 { /* SSL 3 */ 225 { /* SSL 3 */
226 ret = 226 ret =
227 _gnutls_ssl3_hash_md5 (&key_block[pos], key_size, 227 mhd_gnutls_ssl3_hash_md5 (&key_block[pos], key_size,
228 rnd, 2 * TLS_RANDOM_SIZE, 228 rnd, 2 * TLS_RANDOM_SIZE,
229 EXPORT_FINAL_KEY_SIZE, 229 EXPORT_FINAL_KEY_SIZE,
230 server_write_key); 230 server_write_key);
@@ -232,7 +232,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
232 else 232 else
233 { /* TLS 1.0 */ 233 { /* TLS 1.0 */
234 ret = 234 ret =
235 _gnutls_PRF (session, &key_block[pos], key_size, 235 mhd_gtls_PRF (session, &key_block[pos], key_size,
236 servwrite, servwrite_length, 236 servwrite, servwrite_length,
237 rrnd, 2 * TLS_RANDOM_SIZE, 237 rrnd, 2 * TLS_RANDOM_SIZE,
238 EXPORT_FINAL_KEY_SIZE, server_write_key); 238 EXPORT_FINAL_KEY_SIZE, server_write_key);
@@ -262,7 +262,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
262 } 262 }
263 _gnutls_hard_log ("INT: CLIENT WRITE KEY [%d]: %s\n", 263 _gnutls_hard_log ("INT: CLIENT WRITE KEY [%d]: %s\n",
264 client_write_key_size, 264 client_write_key_size,
265 _gnutls_bin2hex (client_write_key, 265 mhd_gtls_bin2hex (client_write_key,
266 client_write_key_size, buf, 266 client_write_key_size, buf,
267 sizeof (buf))); 267 sizeof (buf)));
268 268
@@ -278,7 +278,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
278 278
279 _gnutls_hard_log ("INT: SERVER WRITE KEY [%d]: %s\n", 279 _gnutls_hard_log ("INT: SERVER WRITE KEY [%d]: %s\n",
280 server_write_key_size, 280 server_write_key_size,
281 _gnutls_bin2hex (server_write_key, 281 mhd_gtls_bin2hex (server_write_key,
282 server_write_key_size, buf, 282 server_write_key_size, buf,
283 sizeof (buf))); 283 sizeof (buf)));
284 284
@@ -325,7 +325,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
325 325
326 if (session->security_parameters.version == MHD_GNUTLS_SSL3) 326 if (session->security_parameters.version == MHD_GNUTLS_SSL3)
327 { /* SSL 3 */ 327 { /* SSL 3 */
328 ret = _gnutls_ssl3_hash_md5 ("", 0, 328 ret = mhd_gnutls_ssl3_hash_md5 ("", 0,
329 rrnd, TLS_RANDOM_SIZE * 2, 329 rrnd, TLS_RANDOM_SIZE * 2,
330 IV_size, iv_block); 330 IV_size, iv_block);
331 331
@@ -337,14 +337,14 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
337 return ret; 337 return ret;
338 } 338 }
339 339
340 ret = _gnutls_ssl3_hash_md5 ("", 0, rnd, 340 ret = mhd_gnutls_ssl3_hash_md5 ("", 0, rnd,
341 TLS_RANDOM_SIZE * 2, 341 TLS_RANDOM_SIZE * 2,
342 IV_size, &iv_block[IV_size]); 342 IV_size, &iv_block[IV_size]);
343 343
344 } 344 }
345 else 345 else
346 { /* TLS 1.0 */ 346 { /* TLS 1.0 */
347 ret = _gnutls_PRF (session, "", 0, 347 ret = mhd_gtls_PRF (session, "", 0,
348 ivblock, ivblock_length, rrnd, 348 ivblock, ivblock_length, rrnd,
349 2 * TLS_RANDOM_SIZE, IV_size * 2, iv_block); 349 2 * TLS_RANDOM_SIZE, IV_size * 2, iv_block);
350 } 350 }
@@ -385,7 +385,7 @@ _gnutls_set_keys (gnutls_session_t session, int hash_size, int IV_size,
385} 385}
386 386
387int 387int
388_gnutls_set_read_keys (gnutls_session_t session) 388_gnutls_set_read_keys (mhd_gtls_session_t session)
389{ 389{
390 int hash_size; 390 int hash_size;
391 int IV_size; 391 int IV_size;
@@ -396,17 +396,17 @@ _gnutls_set_read_keys (gnutls_session_t session)
396 mac_algo = session->security_parameters.read_mac_algorithm; 396 mac_algo = session->security_parameters.read_mac_algorithm;
397 algo = session->security_parameters.read_bulk_cipher_algorithm; 397 algo = session->security_parameters.read_bulk_cipher_algorithm;
398 398
399 hash_size = _gnutls_hash_get_algo_len (mac_algo); 399 hash_size = mhd_gnutls_hash_get_algo_len (mac_algo);
400 IV_size = _gnutls_cipher_get_iv_size (algo); 400 IV_size = mhd_gtls_cipher_get_iv_size (algo);
401 key_size = gnutls_cipher_get_key_size (algo); 401 key_size = MHD_gnutls_cipher_get_key_size (algo);
402 export_flag = _gnutls_cipher_get_export_flag (algo); 402 export_flag = mhd_gtls_cipher_get_export_flag (algo);
403 403
404 return _gnutls_set_keys (session, hash_size, IV_size, key_size, 404 return _gnutls_set_keys (session, hash_size, IV_size, key_size,
405 export_flag); 405 export_flag);
406} 406}
407 407
408int 408int
409_gnutls_set_write_keys (gnutls_session_t session) 409_gnutls_set_write_keys (mhd_gtls_session_t session)
410{ 410{
411 int hash_size; 411 int hash_size;
412 int IV_size; 412 int IV_size;
@@ -417,10 +417,10 @@ _gnutls_set_write_keys (gnutls_session_t session)
417 mac_algo = session->security_parameters.write_mac_algorithm; 417 mac_algo = session->security_parameters.write_mac_algorithm;
418 algo = session->security_parameters.write_bulk_cipher_algorithm; 418 algo = session->security_parameters.write_bulk_cipher_algorithm;
419 419
420 hash_size = _gnutls_hash_get_algo_len (mac_algo); 420 hash_size = mhd_gnutls_hash_get_algo_len (mac_algo);
421 IV_size = _gnutls_cipher_get_iv_size (algo); 421 IV_size = mhd_gtls_cipher_get_iv_size (algo);
422 key_size = gnutls_cipher_get_key_size (algo); 422 key_size = MHD_gnutls_cipher_get_key_size (algo);
423 export_flag = _gnutls_cipher_get_export_flag (algo); 423 export_flag = mhd_gtls_cipher_get_export_flag (algo);
424 424
425 return _gnutls_set_keys (session, hash_size, IV_size, key_size, 425 return _gnutls_set_keys (session, hash_size, IV_size, key_size,
426 export_flag); 426 export_flag);
@@ -439,12 +439,12 @@ _gnutls_set_write_keys (gnutls_session_t session)
439 dst->max_record_recv_size = src->max_record_recv_size; \ 439 dst->max_record_recv_size = src->max_record_recv_size; \
440 dst->max_record_send_size = src->max_record_send_size; \ 440 dst->max_record_send_size = src->max_record_send_size; \
441 dst->version = src->version; \ 441 dst->version = src->version; \
442 memcpy( &dst->extensions, &src->extensions, sizeof(tls_ext_st)); \ 442 memcpy( &dst->extensions, &src->extensions, sizeof(mhd_gtls_ext_st)); \
443 memcpy( &dst->inner_secret, &src->inner_secret, TLS_MASTER_SIZE); 443 memcpy( &dst->inner_secret, &src->inner_secret, TLS_MASTER_SIZE);
444 444
445static void 445static void
446_gnutls_cpy_read_security_parameters (security_parameters_st * 446_gnutls_cpy_read_security_parameters (mhd_gtls_security_param_st *
447 dst, security_parameters_st * src) 447 dst, mhd_gtls_security_param_st * src)
448{ 448{
449 CPY_COMMON; 449 CPY_COMMON;
450 450
@@ -454,8 +454,8 @@ _gnutls_cpy_read_security_parameters (security_parameters_st *
454} 454}
455 455
456static void 456static void
457_gnutls_cpy_write_security_parameters (security_parameters_st * 457_gnutls_cpy_write_security_parameters (mhd_gtls_security_param_st *
458 dst, security_parameters_st * src) 458 dst, mhd_gtls_security_param_st * src)
459{ 459{
460 CPY_COMMON; 460 CPY_COMMON;
461 461
@@ -471,13 +471,13 @@ _gnutls_cpy_write_security_parameters (security_parameters_st *
471 * This is to be called after sending the Change Cipher Spec packet. 471 * This is to be called after sending the Change Cipher Spec packet.
472 */ 472 */
473int 473int
474_gnutls_connection_state_init (gnutls_session_t session) 474mhd_gtls_connection_state_init (mhd_gtls_session_t session)
475{ 475{
476 int ret; 476 int ret;
477 477
478/* Setup the master secret 478/* Setup the master secret
479 */ 479 */
480 if ((ret = _gnutls_generate_master (session, 0), 0) < 0) 480 if ((ret = mhd_gtls_generate_master (session, 0), 0) < 0)
481 { 481 {
482 gnutls_assert (); 482 gnutls_assert ();
483 return ret; 483 return ret;
@@ -492,7 +492,7 @@ _gnutls_connection_state_init (gnutls_session_t session)
492 * (read encrypted data) 492 * (read encrypted data)
493 */ 493 */
494int 494int
495_gnutls_read_connection_state_init (gnutls_session_t session) 495mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
496{ 496{
497 int mac_size; 497 int mac_size;
498 int rc; 498 int rc;
@@ -504,27 +504,27 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
504 */ 504 */
505 if (session->internals.resumed == RESUME_FALSE) 505 if (session->internals.resumed == RESUME_FALSE)
506 { 506 {
507 rc = _gnutls_set_read_cipher (session, 507 rc = mhd_gtls_set_read_cipher (session,
508 _gnutls_cipher_suite_get_cipher_algo 508 mhd_gtls_cipher_suite_get_cipher_algo
509 (&session->security_parameters. 509 (&session->security_parameters.
510 current_cipher_suite)); 510 current_cipher_suite));
511 if (rc < 0) 511 if (rc < 0)
512 return rc; 512 return rc;
513 rc = _gnutls_set_read_mac (session, 513 rc = mhd_gtls_set_read_mac (session,
514 _gnutls_cipher_suite_get_mac_algo 514 mhd_gtls_cipher_suite_get_mac_algo
515 (&session->security_parameters. 515 (&session->security_parameters.
516 current_cipher_suite)); 516 current_cipher_suite));
517 if (rc < 0) 517 if (rc < 0)
518 return rc; 518 return rc;
519 519
520 rc = _gnutls_set_kx (session, 520 rc = mhd_gtls_set_kx (session,
521 _gnutls_cipher_suite_get_kx_algo 521 mhd_gtls_cipher_suite_get_kx_algo
522 (&session->security_parameters. 522 (&session->security_parameters.
523 current_cipher_suite)); 523 current_cipher_suite));
524 if (rc < 0) 524 if (rc < 0)
525 return rc; 525 return rc;
526 526
527 rc = _gnutls_set_read_compression (session, 527 rc = mhd_gtls_set_read_compression (session,
528 session->internals. 528 session->internals.
529 compression_method); 529 compression_method);
530 if (rc < 0) 530 if (rc < 0)
@@ -545,18 +545,18 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
545 return rc; 545 return rc;
546 546
547 _gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", 547 _gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n",
548 session, _gnutls_cipher_suite_get_name (&session-> 548 session, mhd_gtls_cipher_suite_get_name (&session->
549 security_parameters. 549 security_parameters.
550 current_cipher_suite)); 550 current_cipher_suite));
551 551
552 if (_gnutls_compression_is_ok 552 if (mhd_gtls_compression_is_ok
553 (session->security_parameters.read_compression_algorithm) != 0) 553 (session->security_parameters.read_compression_algorithm) != 0)
554 { 554 {
555 gnutls_assert (); 555 gnutls_assert ();
556 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 556 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
557 } 557 }
558 558
559 if (_gnutls_mac_is_ok 559 if (mhd_gnutls_mac_is_ok
560 (session->security_parameters.read_mac_algorithm) != 0) 560 (session->security_parameters.read_mac_algorithm) != 0)
561 { 561 {
562 gnutls_assert (); 562 gnutls_assert ();
@@ -569,14 +569,14 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
569 _gnutls_free_datum (&session->connection_state.read_mac_secret); 569 _gnutls_free_datum (&session->connection_state.read_mac_secret);
570 570
571 if (session->connection_state.read_cipher_state != NULL) 571 if (session->connection_state.read_cipher_state != NULL)
572 _gnutls_cipher_deinit (session->connection_state.read_cipher_state); 572 mhd_gnutls_cipher_deinit (session->connection_state.read_cipher_state);
573 573
574 if (session->connection_state.read_compression_state != NULL) 574 if (session->connection_state.read_compression_state != NULL)
575 _gnutls_comp_deinit (session->connection_state.read_compression_state, 1); 575 mhd_gtls_comp_deinit (session->connection_state.read_compression_state, 1);
576 576
577 577
578 mac_size = 578 mac_size =
579 _gnutls_hash_get_algo_len (session->security_parameters. 579 mhd_gnutls_hash_get_algo_len (session->security_parameters.
580 read_mac_algorithm); 580 read_mac_algorithm);
581 581
582 _gnutls_handshake_log 582 _gnutls_handshake_log
@@ -588,7 +588,7 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
588 /* initialize cipher session 588 /* initialize cipher session
589 */ 589 */
590 session->connection_state.read_cipher_state = 590 session->connection_state.read_cipher_state =
591 _gnutls_cipher_init (session->security_parameters. 591 mhd_gtls_cipher_init (session->security_parameters.
592 read_bulk_cipher_algorithm, 592 read_bulk_cipher_algorithm,
593 &session->cipher_specs. 593 &session->cipher_specs.
594 client_write_key, 594 client_write_key,
@@ -624,7 +624,7 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
624 624
625 case GNUTLS_CLIENT: 625 case GNUTLS_CLIENT:
626 session->connection_state.read_cipher_state = 626 session->connection_state.read_cipher_state =
627 _gnutls_cipher_init (session->security_parameters. 627 mhd_gtls_cipher_init (session->security_parameters.
628 read_bulk_cipher_algorithm, 628 read_bulk_cipher_algorithm,
629 &session->cipher_specs. 629 &session->cipher_specs.
630 server_write_key, 630 server_write_key,
@@ -664,7 +664,7 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
664 } 664 }
665 665
666 session->connection_state.read_compression_state = 666 session->connection_state.read_compression_state =
667 _gnutls_comp_init (session->security_parameters. 667 mhd_gtls_comp_init (session->security_parameters.
668 read_compression_algorithm, 1); 668 read_compression_algorithm, 1);
669 669
670 if (session->connection_state.read_compression_state == GNUTLS_COMP_FAILED) 670 if (session->connection_state.read_compression_state == GNUTLS_COMP_FAILED)
@@ -682,7 +682,7 @@ _gnutls_read_connection_state_init (gnutls_session_t session)
682 * (write encrypted data) 682 * (write encrypted data)
683 */ 683 */
684int 684int
685_gnutls_write_connection_state_init (gnutls_session_t session) 685mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
686{ 686{
687 int mac_size; 687 int mac_size;
688 int rc; 688 int rc;
@@ -694,27 +694,27 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
694 */ 694 */
695 if (session->internals.resumed == RESUME_FALSE) 695 if (session->internals.resumed == RESUME_FALSE)
696 { 696 {
697 rc = _gnutls_set_write_cipher (session, 697 rc = mhd_gtls_set_write_cipher (session,
698 _gnutls_cipher_suite_get_cipher_algo 698 mhd_gtls_cipher_suite_get_cipher_algo
699 (&session->security_parameters. 699 (&session->security_parameters.
700 current_cipher_suite)); 700 current_cipher_suite));
701 if (rc < 0) 701 if (rc < 0)
702 return rc; 702 return rc;
703 rc = _gnutls_set_write_mac (session, 703 rc = mhd_gtls_set_write_mac (session,
704 _gnutls_cipher_suite_get_mac_algo 704 mhd_gtls_cipher_suite_get_mac_algo
705 (&session->security_parameters. 705 (&session->security_parameters.
706 current_cipher_suite)); 706 current_cipher_suite));
707 if (rc < 0) 707 if (rc < 0)
708 return rc; 708 return rc;
709 709
710 rc = _gnutls_set_kx (session, 710 rc = mhd_gtls_set_kx (session,
711 _gnutls_cipher_suite_get_kx_algo 711 mhd_gtls_cipher_suite_get_kx_algo
712 (&session->security_parameters. 712 (&session->security_parameters.
713 current_cipher_suite)); 713 current_cipher_suite));
714 if (rc < 0) 714 if (rc < 0)
715 return rc; 715 return rc;
716 716
717 rc = _gnutls_set_write_compression (session, 717 rc = mhd_gtls_set_write_compression (session,
718 session->internals. 718 session->internals.
719 compression_method); 719 compression_method);
720 if (rc < 0) 720 if (rc < 0)
@@ -734,18 +734,18 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
734 return rc; 734 return rc;
735 735
736 _gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session, 736 _gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session,
737 _gnutls_cipher_suite_get_name (&session-> 737 mhd_gtls_cipher_suite_get_name (&session->
738 security_parameters. 738 security_parameters.
739 current_cipher_suite)); 739 current_cipher_suite));
740 740
741 if (_gnutls_compression_is_ok 741 if (mhd_gtls_compression_is_ok
742 (session->security_parameters.write_compression_algorithm) != 0) 742 (session->security_parameters.write_compression_algorithm) != 0)
743 { 743 {
744 gnutls_assert (); 744 gnutls_assert ();
745 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 745 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
746 } 746 }
747 747
748 if (_gnutls_mac_is_ok 748 if (mhd_gnutls_mac_is_ok
749 (session->security_parameters.write_mac_algorithm) != 0) 749 (session->security_parameters.write_mac_algorithm) != 0)
750 { 750 {
751 gnutls_assert (); 751 gnutls_assert ();
@@ -760,14 +760,14 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
760 _gnutls_free_datum (&session->connection_state.write_mac_secret); 760 _gnutls_free_datum (&session->connection_state.write_mac_secret);
761 761
762 if (session->connection_state.write_cipher_state != NULL) 762 if (session->connection_state.write_cipher_state != NULL)
763 _gnutls_cipher_deinit (session->connection_state.write_cipher_state); 763 mhd_gnutls_cipher_deinit (session->connection_state.write_cipher_state);
764 764
765 if (session->connection_state.write_compression_state != NULL) 765 if (session->connection_state.write_compression_state != NULL)
766 _gnutls_comp_deinit (session->connection_state. 766 mhd_gtls_comp_deinit (session->connection_state.
767 write_compression_state, 0); 767 write_compression_state, 0);
768 768
769 mac_size = 769 mac_size =
770 _gnutls_hash_get_algo_len (session->security_parameters. 770 mhd_gnutls_hash_get_algo_len (session->security_parameters.
771 write_mac_algorithm); 771 write_mac_algorithm);
772 772
773 _gnutls_handshake_log 773 _gnutls_handshake_log
@@ -779,7 +779,7 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
779 /* initialize cipher session 779 /* initialize cipher session
780 */ 780 */
781 session->connection_state.write_cipher_state = 781 session->connection_state.write_cipher_state =
782 _gnutls_cipher_init (session->security_parameters. 782 mhd_gtls_cipher_init (session->security_parameters.
783 write_bulk_cipher_algorithm, 783 write_bulk_cipher_algorithm,
784 &session->cipher_specs. 784 &session->cipher_specs.
785 server_write_key, 785 server_write_key,
@@ -818,7 +818,7 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
818 818
819 case GNUTLS_CLIENT: 819 case GNUTLS_CLIENT:
820 session->connection_state.write_cipher_state = 820 session->connection_state.write_cipher_state =
821 _gnutls_cipher_init (session->security_parameters. 821 mhd_gtls_cipher_init (session->security_parameters.
822 write_bulk_cipher_algorithm, 822 write_bulk_cipher_algorithm,
823 &session->cipher_specs. 823 &session->cipher_specs.
824 client_write_key, 824 client_write_key,
@@ -858,7 +858,7 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
858 858
859 859
860 session->connection_state.write_compression_state = 860 session->connection_state.write_compression_state =
861 _gnutls_comp_init (session->security_parameters. 861 mhd_gtls_comp_init (session->security_parameters.
862 write_compression_algorithm, 0); 862 write_compression_algorithm, 0);
863 863
864 if (session->connection_state.write_compression_state == GNUTLS_COMP_FAILED) 864 if (session->connection_state.write_compression_state == GNUTLS_COMP_FAILED)
@@ -873,13 +873,13 @@ _gnutls_write_connection_state_init (gnutls_session_t session)
873/* Sets the specified cipher into the pending session 873/* Sets the specified cipher into the pending session
874 */ 874 */
875int 875int
876_gnutls_set_read_cipher (gnutls_session_t session, 876mhd_gtls_set_read_cipher (mhd_gtls_session_t session,
877 gnutls_cipher_algorithm_t algo) 877 gnutls_cipher_algorithm_t algo)
878{ 878{
879 879
880 if (_gnutls_cipher_is_ok (algo) == 0) 880 if (mhd_gtls_cipher_is_ok (algo) == 0)
881 { 881 {
882 if (_gnutls_cipher_priority (session, algo) < 0) 882 if (mhd_gtls_cipher_priority (session, algo) < 0)
883 { 883 {
884 gnutls_assert (); 884 gnutls_assert ();
885 return GNUTLS_E_UNWANTED_ALGORITHM; 885 return GNUTLS_E_UNWANTED_ALGORITHM;
@@ -899,13 +899,13 @@ _gnutls_set_read_cipher (gnutls_session_t session,
899} 899}
900 900
901int 901int
902_gnutls_set_write_cipher (gnutls_session_t session, 902mhd_gtls_set_write_cipher (mhd_gtls_session_t session,
903 gnutls_cipher_algorithm_t algo) 903 gnutls_cipher_algorithm_t algo)
904{ 904{
905 905
906 if (_gnutls_cipher_is_ok (algo) == 0) 906 if (mhd_gtls_cipher_is_ok (algo) == 0)
907 { 907 {
908 if (_gnutls_cipher_priority (session, algo) < 0) 908 if (mhd_gtls_cipher_priority (session, algo) < 0)
909 { 909 {
910 gnutls_assert (); 910 gnutls_assert ();
911 return GNUTLS_E_UNWANTED_ALGORITHM; 911 return GNUTLS_E_UNWANTED_ALGORITHM;
@@ -928,11 +928,11 @@ _gnutls_set_write_cipher (gnutls_session_t session,
928/* Sets the specified algorithm into pending compression session 928/* Sets the specified algorithm into pending compression session
929 */ 929 */
930int 930int
931_gnutls_set_read_compression (gnutls_session_t session, 931mhd_gtls_set_read_compression (mhd_gtls_session_t session,
932 gnutls_compression_method_t algo) 932 gnutls_compression_method_t algo)
933{ 933{
934 934
935 if (_gnutls_compression_is_ok (algo) == 0) 935 if (mhd_gtls_compression_is_ok (algo) == 0)
936 { 936 {
937 session->security_parameters.read_compression_algorithm = algo; 937 session->security_parameters.read_compression_algorithm = algo;
938 } 938 }
@@ -946,11 +946,11 @@ _gnutls_set_read_compression (gnutls_session_t session,
946} 946}
947 947
948int 948int
949_gnutls_set_write_compression (gnutls_session_t session, 949mhd_gtls_set_write_compression (mhd_gtls_session_t session,
950 gnutls_compression_method_t algo) 950 gnutls_compression_method_t algo)
951{ 951{
952 952
953 if (_gnutls_compression_is_ok (algo) == 0) 953 if (mhd_gtls_compression_is_ok (algo) == 0)
954 { 954 {
955 session->security_parameters.write_compression_algorithm = algo; 955 session->security_parameters.write_compression_algorithm = algo;
956 } 956 }
@@ -966,10 +966,10 @@ _gnutls_set_write_compression (gnutls_session_t session,
966/* Sets the specified kx algorithm into pending session 966/* Sets the specified kx algorithm into pending session
967 */ 967 */
968int 968int
969_gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo) 969mhd_gtls_set_kx (mhd_gtls_session_t session, gnutls_kx_algorithm_t algo)
970{ 970{
971 971
972 if (_gnutls_kx_is_ok (algo) == 0) 972 if (mhd_gtls_kx_is_ok (algo) == 0)
973 { 973 {
974 session->security_parameters.kx_algorithm = algo; 974 session->security_parameters.kx_algorithm = algo;
975 } 975 }
@@ -978,7 +978,7 @@ _gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo)
978 gnutls_assert (); 978 gnutls_assert ();
979 return GNUTLS_E_INTERNAL_ERROR; 979 return GNUTLS_E_INTERNAL_ERROR;
980 } 980 }
981 if (_gnutls_kx_priority (session, algo) < 0) 981 if (mhd_gtls_kx_priority (session, algo) < 0)
982 { 982 {
983 gnutls_assert (); 983 gnutls_assert ();
984 /* we shouldn't get here */ 984 /* we shouldn't get here */
@@ -991,10 +991,10 @@ _gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo)
991 991
992/* Sets the specified mac algorithm into pending session */ 992/* Sets the specified mac algorithm into pending session */
993int 993int
994_gnutls_set_read_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo) 994mhd_gtls_set_read_mac (mhd_gtls_session_t session, gnutls_mac_algorithm_t algo)
995{ 995{
996 996
997 if (_gnutls_mac_is_ok (algo) == 0) 997 if (mhd_gnutls_mac_is_ok (algo) == 0)
998 { 998 {
999 session->security_parameters.read_mac_algorithm = algo; 999 session->security_parameters.read_mac_algorithm = algo;
1000 } 1000 }
@@ -1003,7 +1003,7 @@ _gnutls_set_read_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo)
1003 gnutls_assert (); 1003 gnutls_assert ();
1004 return GNUTLS_E_INTERNAL_ERROR; 1004 return GNUTLS_E_INTERNAL_ERROR;
1005 } 1005 }
1006 if (_gnutls_mac_priority (session, algo) < 0) 1006 if (mhd_gtls_mac_priority (session, algo) < 0)
1007 { 1007 {
1008 gnutls_assert (); 1008 gnutls_assert ();
1009 return GNUTLS_E_UNWANTED_ALGORITHM; 1009 return GNUTLS_E_UNWANTED_ALGORITHM;
@@ -1015,10 +1015,10 @@ _gnutls_set_read_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo)
1015} 1015}
1016 1016
1017int 1017int
1018_gnutls_set_write_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo) 1018mhd_gtls_set_write_mac (mhd_gtls_session_t session, gnutls_mac_algorithm_t algo)
1019{ 1019{
1020 1020
1021 if (_gnutls_mac_is_ok (algo) == 0) 1021 if (mhd_gnutls_mac_is_ok (algo) == 0)
1022 { 1022 {
1023 session->security_parameters.write_mac_algorithm = algo; 1023 session->security_parameters.write_mac_algorithm = algo;
1024 } 1024 }
@@ -1027,7 +1027,7 @@ _gnutls_set_write_mac (gnutls_session_t session, gnutls_mac_algorithm_t algo)
1027 gnutls_assert (); 1027 gnutls_assert ();
1028 return GNUTLS_E_INTERNAL_ERROR; 1028 return GNUTLS_E_INTERNAL_ERROR;
1029 } 1029 }
1030 if (_gnutls_mac_priority (session, algo) < 0) 1030 if (mhd_gtls_mac_priority (session, algo) < 0)
1031 { 1031 {
1032 gnutls_assert (); 1032 gnutls_assert ();
1033 return GNUTLS_E_UNWANTED_ALGORITHM; 1033 return GNUTLS_E_UNWANTED_ALGORITHM;
diff --git a/src/daemon/https/tls/gnutls_constate.h b/src/daemon/https/tls/gnutls_constate.h
index f58c8b14..b9948587 100644
--- a/src/daemon/https/tls/gnutls_constate.h
+++ b/src/daemon/https/tls/gnutls_constate.h
@@ -22,19 +22,19 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_connection_state_init (gnutls_session_t session); 25int mhd_gtls_connection_state_init (mhd_gtls_session_t session);
26int _gnutls_read_connection_state_init (gnutls_session_t session); 26int mhd_gtls_read_connection_state_init (mhd_gtls_session_t session);
27int _gnutls_write_connection_state_init (gnutls_session_t session); 27int mhd_gtls_write_connection_state_init (mhd_gtls_session_t session);
28int _gnutls_set_write_cipher (gnutls_session_t session, 28int mhd_gtls_set_write_cipher (mhd_gtls_session_t session,
29 gnutls_cipher_algorithm_t algo); 29 gnutls_cipher_algorithm_t algo);
30int _gnutls_set_write_mac (gnutls_session_t session, 30int mhd_gtls_set_write_mac (mhd_gtls_session_t session,
31 gnutls_mac_algorithm_t algo); 31 gnutls_mac_algorithm_t algo);
32int _gnutls_set_read_cipher (gnutls_session_t session, 32int mhd_gtls_set_read_cipher (mhd_gtls_session_t session,
33 gnutls_cipher_algorithm_t algo); 33 gnutls_cipher_algorithm_t algo);
34int _gnutls_set_read_mac (gnutls_session_t session, 34int mhd_gtls_set_read_mac (mhd_gtls_session_t session,
35 gnutls_mac_algorithm_t algo); 35 gnutls_mac_algorithm_t algo);
36int _gnutls_set_read_compression (gnutls_session_t session, 36int mhd_gtls_set_read_compression (mhd_gtls_session_t session,
37 gnutls_compression_method_t algo); 37 gnutls_compression_method_t algo);
38int _gnutls_set_write_compression (gnutls_session_t session, 38int mhd_gtls_set_write_compression (mhd_gtls_session_t session,
39 gnutls_compression_method_t algo); 39 gnutls_compression_method_t algo);
40int _gnutls_set_kx (gnutls_session_t session, gnutls_kx_algorithm_t algo); 40int mhd_gtls_set_kx (mhd_gtls_session_t session, gnutls_kx_algorithm_t algo);
diff --git a/src/daemon/https/tls/gnutls_datum.c b/src/daemon/https/tls/gnutls_datum.c
index 4b2eb1f4..ea18d801 100644
--- a/src/daemon/https/tls/gnutls_datum.c
+++ b/src/daemon/https/tls/gnutls_datum.c
@@ -34,31 +34,31 @@
34 34
35 35
36void 36void
37_gnutls_write_datum16 (opaque * dest, gnutls_datum_t dat) 37mhd_gtls_write_datum16 (opaque * dest, gnutls_datum_t dat)
38{ 38{
39 _gnutls_write_uint16 (dat.size, dest); 39 mhd_gtls_write_uint16 (dat.size, dest);
40 if (dat.data != NULL) 40 if (dat.data != NULL)
41 memcpy (&dest[2], dat.data, dat.size); 41 memcpy (&dest[2], dat.data, dat.size);
42} 42}
43 43
44void 44void
45_gnutls_write_datum24 (opaque * dest, gnutls_datum_t dat) 45mhd_gtls_write_datum24 (opaque * dest, gnutls_datum_t dat)
46{ 46{
47 _gnutls_write_uint24 (dat.size, dest); 47 mhd_gtls_write_uint24 (dat.size, dest);
48 if (dat.data != NULL) 48 if (dat.data != NULL)
49 memcpy (&dest[3], dat.data, dat.size); 49 memcpy (&dest[3], dat.data, dat.size);
50} 50}
51 51
52void 52void
53_gnutls_write_datum32 (opaque * dest, gnutls_datum_t dat) 53mhd_gtls_write_datum32 (opaque * dest, gnutls_datum_t dat)
54{ 54{
55 _gnutls_write_uint32 (dat.size, dest); 55 mhd_gtls_write_uint32 (dat.size, dest);
56 if (dat.data != NULL) 56 if (dat.data != NULL)
57 memcpy (&dest[4], dat.data, dat.size); 57 memcpy (&dest[4], dat.data, dat.size);
58} 58}
59 59
60void 60void
61_gnutls_write_datum8 (opaque * dest, gnutls_datum_t dat) 61mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat)
62{ 62{
63 dest[0] = (uint8_t) dat.size; 63 dest[0] = (uint8_t) dat.size;
64 if (dat.data != NULL) 64 if (dat.data != NULL)
@@ -67,7 +67,7 @@ _gnutls_write_datum8 (opaque * dest, gnutls_datum_t dat)
67 67
68 68
69int 69int
70_gnutls_set_datum_m (gnutls_datum_t * dat, const void *data, 70mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data,
71 size_t data_size, gnutls_alloc_function galloc_func) 71 size_t data_size, gnutls_alloc_function galloc_func)
72{ 72{
73 if (data_size == 0 || data == NULL) 73 if (data_size == 0 || data == NULL)
@@ -88,7 +88,7 @@ _gnutls_set_datum_m (gnutls_datum_t * dat, const void *data,
88} 88}
89 89
90int 90int
91_gnutls_datum_append_m (gnutls_datum_t * dst, const void *data, 91mhd_gtls_datum_append_m (gnutls_datum_t * dst, const void *data,
92 size_t data_size, 92 size_t data_size,
93 gnutls_realloc_function grealloc_func) 93 gnutls_realloc_function grealloc_func)
94{ 94{
@@ -104,7 +104,7 @@ _gnutls_datum_append_m (gnutls_datum_t * dst, const void *data,
104} 104}
105 105
106void 106void
107_gnutls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function gfree_func) 107mhd_gtls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function gfree_func)
108{ 108{
109 if (dat->data != NULL) 109 if (dat->data != NULL)
110 gfree_func (dat->data); 110 gfree_func (dat->data);
diff --git a/src/daemon/https/tls/gnutls_datum.h b/src/daemon/https/tls/gnutls_datum.h
index 0f609531..cce91595 100644
--- a/src/daemon/https/tls/gnutls_datum.h
+++ b/src/daemon/https/tls/gnutls_datum.h
@@ -22,19 +22,19 @@
22 * 22 *
23 */ 23 */
24 24
25void _gnutls_write_datum16 (opaque * dest, gnutls_datum_t dat); 25void mhd_gtls_write_datum16 (opaque * dest, gnutls_datum_t dat);
26void _gnutls_write_datum24 (opaque * dest, gnutls_datum_t dat); 26void mhd_gtls_write_datum24 (opaque * dest, gnutls_datum_t dat);
27void _gnutls_write_datum32 (opaque * dest, gnutls_datum_t dat); 27void mhd_gtls_write_datum32 (opaque * dest, gnutls_datum_t dat);
28void _gnutls_write_datum8 (opaque * dest, gnutls_datum_t dat); 28void mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat);
29 29
30int _gnutls_set_datum_m (gnutls_datum_t * dat, const void *data, 30int mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data,
31 size_t data_size, gnutls_alloc_function); 31 size_t data_size, gnutls_alloc_function);
32#define _gnutls_set_datum( x, y, z) _gnutls_set_datum_m(x,y,z, gnutls_malloc) 32#define _gnutls_set_datum( x, y, z) mhd_gtls_set_datum_m(x,y,z, gnutls_malloc)
33#define _gnutls_sset_datum( x, y, z) _gnutls_set_datum_m(x,y,z, gnutls_secure_malloc) 33#define _gnutls_sset_datum( x, y, z) mhd_gtls_set_datum_m(x,y,z, gnutls_secure_malloc)
34 34
35int _gnutls_datum_append_m (gnutls_datum_t * dat, const void *data, 35int mhd_gtls_datum_append_m (gnutls_datum_t * dat, const void *data,
36 size_t data_size, gnutls_realloc_function); 36 size_t data_size, gnutls_realloc_function);
37#define _gnutls_datum_append(x,y,z) _gnutls_datum_append_m(x,y,z, gnutls_realloc) 37#define _gnutls_datum_append(x,y,z) mhd_gtls_datum_append_m(x,y,z, gnutls_realloc)
38 38
39void _gnutls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function); 39void mhd_gtls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function);
40#define _gnutls_free_datum(x) _gnutls_free_datum_m(x, gnutls_free) 40#define _gnutls_free_datum(x) mhd_gtls_free_datum_m(x, gnutls_free)
diff --git a/src/daemon/https/tls/gnutls_dh.c b/src/daemon/https/tls/gnutls_dh.c
index 19322c73..388f6e0c 100644
--- a/src/daemon/https/tls/gnutls_dh.c
+++ b/src/daemon/https/tls/gnutls_dh.c
@@ -35,11 +35,11 @@
35 his_key = X ^ y mod p; 35 his_key = X ^ y mod p;
36 36
37// generate our secret and the public value (X) for it 37// generate our secret and the public value (X) for it
38 X = gnutls_calc_dh_secret(&x, g, p); 38 X = mhd_gtls_calc_dh_secret(&x, g, p);
39// now we can calculate the shared secret 39// now we can calculate the shared secret
40 key = gnutls_calc_dh_key(Y, x, g, p); 40 key = mhd_gtls_calc_dh_key(Y, x, g, p);
41 _gnutls_mpi_release(x); 41 mhd_gtls_mpi_release(x);
42 _gnutls_mpi_release(g); 42 mhd_gtls_mpi_release(g);
43*/ 43*/
44 44
45#define MAX_BITS 18000 45#define MAX_BITS 18000
@@ -47,7 +47,7 @@
47/* returns the public value (X), and the secret (ret_x). 47/* returns the public value (X), and the secret (ret_x).
48 */ 48 */
49mpi_t 49mpi_t
50gnutls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime) 50mhd_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
51{ 51{
52 mpi_t e, x; 52 mpi_t e, x;
53 int x_size = _gnutls_mpi_get_nbits (prime) - 1; 53 int x_size = _gnutls_mpi_get_nbits (prime) - 1;
@@ -89,7 +89,7 @@ gnutls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
89 if (ret_x) 89 if (ret_x)
90 *ret_x = NULL; 90 *ret_x = NULL;
91 91
92 _gnutls_mpi_release (&x); 92 mhd_gtls_mpi_release (&x);
93 return NULL; 93 return NULL;
94 } 94 }
95 95
@@ -98,13 +98,13 @@ gnutls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
98 if (ret_x) 98 if (ret_x)
99 *ret_x = x; 99 *ret_x = x;
100 else 100 else
101 _gnutls_mpi_release (&x); 101 mhd_gtls_mpi_release (&x);
102 return e; 102 return e;
103} 103}
104 104
105 105
106mpi_t 106mpi_t
107gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime) 107mhd_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
108{ 108{
109 mpi_t k; 109 mpi_t k;
110 int bits; 110 int bits;
@@ -124,7 +124,7 @@ gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
124} 124}
125 125
126/*- 126/*-
127 * _gnutls_get_dh_params - Returns the DH parameters pointer 127 * mhd_gtls_get_dh_params - Returns the DH parameters pointer
128 * @dh_params: is an DH parameters structure, or NULL. 128 * @dh_params: is an DH parameters structure, or NULL.
129 * @func: is a callback function to receive the parameters or NULL. 129 * @func: is a callback function to receive the parameters or NULL.
130 * @session: a gnutls session. 130 * @session: a gnutls session.
@@ -132,10 +132,10 @@ gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
132 * This function will return the dh parameters pointer. 132 * This function will return the dh parameters pointer.
133 * 133 *
134 -*/ 134 -*/
135gnutls_dh_params_t 135mhd_gtls_dh_params_t
136_gnutls_get_dh_params (gnutls_dh_params_t dh_params, 136mhd_gtls_get_dh_params (mhd_gtls_dh_params_t dh_params,
137 gnutls_params_function * func, 137 gnutls_params_function * func,
138 gnutls_session_t session) 138 mhd_gtls_session_t session)
139{ 139{
140 gnutls_params_st params; 140 gnutls_params_st params;
141 int ret; 141 int ret;
diff --git a/src/daemon/https/tls/gnutls_dh.h b/src/daemon/https/tls/gnutls_dh.h
index dc8a129d..06ac6135 100644
--- a/src/daemon/https/tls/gnutls_dh.h
+++ b/src/daemon/https/tls/gnutls_dh.h
@@ -25,14 +25,14 @@
25#ifndef GNUTLS_DH_H 25#ifndef GNUTLS_DH_H
26# define GNUTLS_DH_H 26# define GNUTLS_DH_H
27 27
28const mpi_t *_gnutls_dh_params_to_mpi (gnutls_dh_params_t); 28const mpi_t * mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t);
29mpi_t gnutls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime); 29mpi_t mhd_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime);
30mpi_t gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime); 30mpi_t mhd_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime);
31int _gnutls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned bits); 31int mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned bits);
32 32
33gnutls_dh_params_t 33mhd_gtls_dh_params_t
34_gnutls_get_dh_params (gnutls_dh_params_t dh_params, 34mhd_gtls_get_dh_params (mhd_gtls_dh_params_t dh_params,
35 gnutls_params_function * func, 35 gnutls_params_function * func,
36 gnutls_session_t session); 36 mhd_gtls_session_t session);
37 37
38#endif 38#endif
diff --git a/src/daemon/https/tls/gnutls_dh_primes.c b/src/daemon/https/tls/gnutls_dh_primes.c
index 0aea5b5f..0d404bd8 100644
--- a/src/daemon/https/tls/gnutls_dh_primes.c
+++ b/src/daemon/https/tls/gnutls_dh_primes.c
@@ -36,7 +36,7 @@
36/* returns the prime and the generator of DH params. 36/* returns the prime and the generator of DH params.
37 */ 37 */
38const mpi_t * 38const mpi_t *
39_gnutls_dh_params_to_mpi (gnutls_dh_params_t dh_primes) 39mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t dh_primes)
40{ 40{
41 if (dh_primes == NULL || dh_primes->params[1] == NULL 41 if (dh_primes == NULL || dh_primes->params[1] == NULL
42 || dh_primes->params[0] == NULL) 42 || dh_primes->params[0] == NULL)
@@ -48,7 +48,7 @@ _gnutls_dh_params_to_mpi (gnutls_dh_params_t dh_primes)
48} 48}
49 49
50int 50int
51_gnutls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits) 51mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
52{ 52{
53 mpi_t g = NULL, prime = NULL; 53 mpi_t g = NULL, prime = NULL;
54 gcry_error_t err; 54 gcry_error_t err;
@@ -75,7 +75,7 @@ _gnutls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
75 75
76 if (times) 76 if (times)
77 { 77 {
78 _gnutls_mpi_release (&prime); 78 mhd_gtls_mpi_release (&prime);
79 gcry_prime_release_factors (factors); 79 gcry_prime_release_factors (factors);
80 } 80 }
81 81
@@ -119,17 +119,17 @@ _gnutls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
119 if (ret_g) 119 if (ret_g)
120 *ret_g = g; 120 *ret_g = g;
121 else 121 else
122 _gnutls_mpi_release (&g); 122 mhd_gtls_mpi_release (&g);
123 if (ret_n) 123 if (ret_n)
124 *ret_n = prime; 124 *ret_n = prime;
125 else 125 else
126 _gnutls_mpi_release (&prime); 126 mhd_gtls_mpi_release (&prime);
127 127
128 return 0; 128 return 0;
129 129
130cleanup:gcry_prime_release_factors (factors); 130cleanup:gcry_prime_release_factors (factors);
131 _gnutls_mpi_release (&g); 131 mhd_gtls_mpi_release (&g);
132 _gnutls_mpi_release (&prime); 132 mhd_gtls_mpi_release (&prime);
133 133
134 return result; 134 return result;
135 135
@@ -139,60 +139,17 @@ cleanup:gcry_prime_release_factors (factors);
139 * generated one. 139 * generated one.
140 */ 140 */
141/** 141/**
142 * gnutls_dh_params_import_raw - This function will import DH parameters 142 * MHD_gnutls_dh_params_init - This function will initialize the DH parameters
143 * @dh_params: Is a structure that will hold the prime numbers
144 * @prime: holds the new prime
145 * @generator: holds the new generator
146 *
147 * This function will replace the pair of prime and generator for use in
148 * the Diffie-Hellman key exchange. The new parameters should be stored in the
149 * appropriate gnutls_datum.
150 *
151 **/
152int
153gnutls_dh_params_import_raw (gnutls_dh_params_t dh_params,
154 const gnutls_datum_t * prime,
155 const gnutls_datum_t * generator)
156{
157 mpi_t tmp_prime, tmp_g;
158 size_t siz;
159
160 siz = prime->size;
161 if (_gnutls_mpi_scan_nz (&tmp_prime, prime->data, &siz))
162 {
163 gnutls_assert ();
164 return GNUTLS_E_MPI_SCAN_FAILED;
165 }
166
167 siz = generator->size;
168 if (_gnutls_mpi_scan_nz (&tmp_g, generator->data, &siz))
169 {
170 _gnutls_mpi_release (&tmp_prime);
171 gnutls_assert ();
172 return GNUTLS_E_MPI_SCAN_FAILED;
173 }
174
175 /* store the generated values
176 */
177 dh_params->params[0] = tmp_prime;
178 dh_params->params[1] = tmp_g;
179
180 return 0;
181
182}
183
184/**
185 * gnutls_dh_params_init - This function will initialize the DH parameters
186 * @dh_params: Is a structure that will hold the prime numbers 143 * @dh_params: Is a structure that will hold the prime numbers
187 * 144 *
188 * This function will initialize the DH parameters structure. 145 * This function will initialize the DH parameters structure.
189 * 146 *
190 **/ 147 **/
191int 148int
192gnutls_dh_params_init (gnutls_dh_params_t * dh_params) 149MHD_gnutls_dh_params_init (mhd_gtls_dh_params_t * dh_params)
193{ 150{
194 151
195 (*dh_params) = gnutls_calloc (1, sizeof (dh_params_st)); 152 (*dh_params) = gnutls_calloc (1, sizeof (mhd_gtls_dh_params_st));
196 if (*dh_params == NULL) 153 if (*dh_params == NULL)
197 { 154 {
198 gnutls_assert (); 155 gnutls_assert ();
@@ -204,59 +161,35 @@ gnutls_dh_params_init (gnutls_dh_params_t * dh_params)
204} 161}
205 162
206/** 163/**
207 * gnutls_dh_params_deinit - This function will deinitialize the DH parameters 164 * MHD_gnutls_dh_params_deinit - This function will deinitialize the DH parameters
208 * @dh_params: Is a structure that holds the prime numbers 165 * @dh_params: Is a structure that holds the prime numbers
209 * 166 *
210 * This function will deinitialize the DH parameters structure. 167 * This function will deinitialize the DH parameters structure.
211 * 168 *
212 **/ 169 **/
213void 170void
214gnutls_dh_params_deinit (gnutls_dh_params_t dh_params) 171MHD_gnutls_dh_params_deinit (mhd_gtls_dh_params_t dh_params)
215{ 172{
216 if (dh_params == NULL) 173 if (dh_params == NULL)
217 return; 174 return;
218 175
219 _gnutls_mpi_release (&dh_params->params[0]); 176 mhd_gtls_mpi_release (&dh_params->params[0]);
220 _gnutls_mpi_release (&dh_params->params[1]); 177 mhd_gtls_mpi_release (&dh_params->params[1]);
221 178
222 gnutls_free (dh_params); 179 gnutls_free (dh_params);
223 180
224} 181}
225 182
226/** 183/**
227 * gnutls_dh_params_cpy - This function will copy a DH parameters structure 184 * MHD_gnutls_dh_params_generate2 - This function will generate new DH parameters
228 * @dst: Is the destination structure, which should be initialized.
229 * @src: Is the source structure
230 *
231 * This function will copy the DH parameters structure from source
232 * to destination.
233 *
234 **/
235int
236gnutls_dh_params_cpy (gnutls_dh_params_t dst, gnutls_dh_params_t src)
237{
238 if (src == NULL)
239 return GNUTLS_E_INVALID_REQUEST;
240
241 dst->params[0] = _gnutls_mpi_copy (src->params[0]);
242 dst->params[1] = _gnutls_mpi_copy (src->params[1]);
243
244 if (dst->params[0] == NULL || dst->params[1] == NULL)
245 return GNUTLS_E_MEMORY_ERROR;
246
247 return 0;
248}
249
250/**
251 * gnutls_dh_params_generate2 - This function will generate new DH parameters
252 * @params: Is the structure that the DH parameters will be stored 185 * @params: Is the structure that the DH parameters will be stored
253 * @bits: is the prime's number of bits 186 * @bits: is the prime's number of bits
254 * 187 *
255 * This function will generate a new pair of prime and generator for use in 188 * This function will generate a new pair of prime and generator for use in
256 * the Diffie-Hellman key exchange. The new parameters will be allocated using 189 * the Diffie-Hellman key exchange. The new parameters will be allocated using
257 * gnutls_malloc() and will be stored in the appropriate datum. 190 * gnutls_malloc() and will be stored in the appropriate datum.
258 * This function is normally slow. 191 * This function is normally slow.
259 * 192 *
260 * Note that the bits value should be one of 768, 1024, 2048, 3072 or 4096. 193 * Note that the bits value should be one of 768, 1024, 2048, 3072 or 4096.
261 * Also note that the DH parameters are only useful to servers. 194 * Also note that the DH parameters are only useful to servers.
262 * Since clients use the parameters sent by the server, it's of 195 * Since clients use the parameters sent by the server, it's of
@@ -264,12 +197,12 @@ gnutls_dh_params_cpy (gnutls_dh_params_t dst, gnutls_dh_params_t src)
264 * 197 *
265 **/ 198 **/
266int 199int
267gnutls_dh_params_generate2 (gnutls_dh_params_t params, unsigned int bits) 200MHD_gnutls_dh_params_generate2 (mhd_gtls_dh_params_t params, unsigned int bits)
268{ 201{
269 int ret; 202 int ret;
270 203
271 ret = 204 ret =
272 _gnutls_dh_generate_prime (&params->params[1], &params->params[0], bits); 205 mhd_gtls_dh_generate_prime (&params->params[1], &params->params[0], bits);
273 if (ret < 0) 206 if (ret < 0)
274 { 207 {
275 gnutls_assert (); 208 gnutls_assert ();
@@ -278,349 +211,3 @@ gnutls_dh_params_generate2 (gnutls_dh_params_t params, unsigned int bits)
278 211
279 return 0; 212 return 0;
280} 213}
281
282/**
283 * gnutls_dh_params_import_pkcs3 - This function will import DH params from a pkcs3 structure
284 * @params: A structure where the parameters will be copied to
285 * @pkcs3_params: should contain a PKCS3 DHParams structure PEM or DER encoded
286 * @format: the format of params. PEM or DER.
287 *
288 * This function will extract the DHParams found in a PKCS3 formatted
289 * structure. This is the format generated by "openssl dhparam" tool.
290 *
291 * If the structure is PEM encoded, it should have a header
292 * of "BEGIN DH PARAMETERS".
293 *
294 * In case of failure a negative value will be returned, and
295 * 0 on success.
296 *
297 **/
298int
299gnutls_dh_params_import_pkcs3 (gnutls_dh_params_t params,
300 const gnutls_datum_t * pkcs3_params,
301 gnutls_x509_crt_fmt_t format)
302{
303 ASN1_TYPE c2;
304 int result, need_free = 0;
305 gnutls_datum_t _params;
306
307 if (format == GNUTLS_X509_FMT_PEM)
308 {
309 opaque *out;
310
311 result = _gnutls_fbase64_decode ("DH PARAMETERS", pkcs3_params->data,
312 pkcs3_params->size, &out);
313
314 if (result <= 0)
315 {
316 if (result == 0)
317 result = GNUTLS_E_INTERNAL_ERROR;
318 gnutls_assert ();
319 return result;
320 }
321
322 _params.data = out;
323 _params.size = result;
324
325 need_free = 1;
326
327 }
328 else
329 {
330 _params.data = pkcs3_params->data;
331 _params.size = pkcs3_params->size;
332 }
333
334 if ((result =
335 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.DHParameter",
336 &c2)) != ASN1_SUCCESS)
337 {
338 gnutls_assert ();
339 if (need_free != 0)
340 {
341 gnutls_free (_params.data);
342 _params.data = NULL;
343 }
344 return _gnutls_asn2err (result);
345 }
346
347 result = asn1_der_decoding (&c2, _params.data, _params.size, NULL);
348
349 if (need_free != 0)
350 {
351 gnutls_free (_params.data);
352 _params.data = NULL;
353 }
354
355 if (result != ASN1_SUCCESS)
356 {
357 /* couldn't decode DER */
358
359 _gnutls_x509_log ("DHParams: Decoding error %d\n", result);
360 gnutls_assert ();
361 asn1_delete_structure (&c2);
362 return _gnutls_asn2err (result);
363 }
364
365 /* Read PRIME
366 */
367 result = _gnutls_x509_read_int (c2, "prime", &params->params[0]);
368 if (result < 0)
369 {
370 asn1_delete_structure (&c2);
371 gnutls_assert ();
372 return result;
373 }
374
375 /* read the generator
376 */
377 result = _gnutls_x509_read_int (c2, "base", &params->params[1]);
378 if (result < 0)
379 {
380 asn1_delete_structure (&c2);
381 _gnutls_mpi_release (&params->params[0]);
382 gnutls_assert ();
383 return result;
384 }
385
386 asn1_delete_structure (&c2);
387
388 return 0;
389}
390
391/**
392 * gnutls_dh_params_export_pkcs3 - This function will export DH params to a pkcs3 structure
393 * @params: Holds the DH parameters
394 * @format: the format of output params. One of PEM or DER.
395 * @params_data: will contain a PKCS3 DHParams structure PEM or DER encoded
396 * @params_data_size: holds the size of params_data (and will be replaced by the actual size of parameters)
397 *
398 * This function will export the given dh parameters to a PKCS3
399 * DHParams structure. This is the format generated by "openssl dhparam" tool.
400 * If the buffer provided is not long enough to hold the output, then
401 * GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
402 *
403 * If the structure is PEM encoded, it will have a header
404 * of "BEGIN DH PARAMETERS".
405 *
406 * In case of failure a negative value will be returned, and
407 * 0 on success.
408 *
409 **/
410int
411gnutls_dh_params_export_pkcs3 (gnutls_dh_params_t params,
412 gnutls_x509_crt_fmt_t format,
413 unsigned char *params_data,
414 size_t * params_data_size)
415{
416 ASN1_TYPE c2;
417 int result, _params_data_size;
418 size_t g_size, p_size;
419 opaque *p_data, *g_data;
420 opaque *all_data;
421
422 _gnutls_mpi_print_lz (NULL, &g_size, params->params[1]);
423 _gnutls_mpi_print_lz (NULL, &p_size, params->params[0]);
424
425 all_data = gnutls_malloc (g_size + p_size);
426 if (all_data == NULL)
427 {
428 gnutls_assert ();
429 return GNUTLS_E_MEMORY_ERROR;
430 }
431
432 p_data = &all_data[0];
433 g_data = &all_data[p_size];
434
435 _gnutls_mpi_print_lz (p_data, &p_size, params->params[0]);
436 _gnutls_mpi_print_lz (g_data, &g_size, params->params[1]);
437
438 /* Ok. Now we have the data. Create the asn1 structures
439 */
440
441 if ((result =
442 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.DHParameter",
443 &c2)) != ASN1_SUCCESS)
444 {
445 gnutls_assert ();
446 gnutls_free (all_data);
447 return _gnutls_asn2err (result);
448 }
449
450 /* Write PRIME
451 */
452 if ((result =
453 asn1_write_value (c2, "prime", p_data, p_size)) != ASN1_SUCCESS)
454 {
455 gnutls_assert ();
456 gnutls_free (all_data);
457 asn1_delete_structure (&c2);
458 return _gnutls_asn2err (result);
459 }
460
461 /* Write the GENERATOR
462 */
463 if ((result =
464 asn1_write_value (c2, "base", g_data, g_size)) != ASN1_SUCCESS)
465 {
466 gnutls_assert ();
467 gnutls_free (all_data);
468 asn1_delete_structure (&c2);
469 return _gnutls_asn2err (result);
470 }
471
472 gnutls_free (all_data);
473
474 if ((result = asn1_write_value (c2, "privateValueLength",
475 NULL, 0)) != ASN1_SUCCESS)
476 {
477 gnutls_assert ();
478 asn1_delete_structure (&c2);
479 return _gnutls_asn2err (result);
480 }
481
482 if (format == GNUTLS_X509_FMT_DER)
483 {
484 if (params_data == NULL)
485 *params_data_size = 0;
486
487 _params_data_size = *params_data_size;
488 result =
489 asn1_der_coding (c2, "", params_data, &_params_data_size, NULL);
490 *params_data_size = _params_data_size;
491 asn1_delete_structure (&c2);
492
493 if (result != ASN1_SUCCESS)
494 {
495 gnutls_assert ();
496 if (result == ASN1_MEM_ERROR)
497 return GNUTLS_E_SHORT_MEMORY_BUFFER;
498
499 return _gnutls_asn2err (result);
500 }
501
502 }
503 else
504 { /* PEM */
505 opaque *tmp;
506 opaque *out;
507 int len;
508
509 len = 0;
510 asn1_der_coding (c2, "", NULL, &len, NULL);
511
512 tmp = gnutls_malloc (len);
513 if (tmp == NULL)
514 {
515 gnutls_assert ();
516 asn1_delete_structure (&c2);
517 return GNUTLS_E_MEMORY_ERROR;
518 }
519
520 if ((result =
521 asn1_der_coding (c2, "", tmp, &len, NULL)) != ASN1_SUCCESS)
522 {
523 gnutls_assert ();
524 gnutls_free (tmp);
525 asn1_delete_structure (&c2);
526 return _gnutls_asn2err (result);
527 }
528
529 asn1_delete_structure (&c2);
530
531 result = _gnutls_fbase64_encode ("DH PARAMETERS", tmp, len, &out);
532
533 gnutls_free (tmp);
534
535 if (result < 0)
536 {
537 gnutls_assert ();
538 return result;
539 }
540
541 if (result == 0)
542 { /* oooops */
543 gnutls_assert ();
544 gnutls_free (out);
545 return GNUTLS_E_INTERNAL_ERROR;
546 }
547
548 if ((unsigned) result + 1 > *params_data_size)
549 {
550 gnutls_assert ();
551 gnutls_free (out);
552 *params_data_size = result + 1;
553 return GNUTLS_E_SHORT_MEMORY_BUFFER;
554 }
555
556 *params_data_size = result;
557
558 if (params_data)
559 {
560 memcpy (params_data, out, result);
561 params_data[result] = 0;
562 }
563 gnutls_free (out);
564
565 }
566
567 return 0;
568}
569
570/**
571 * gnutls_dh_params_export_raw - This function will export the raw DH parameters
572 * @params: Holds the DH parameters
573 * @prime: will hold the new prime
574 * @generator: will hold the new generator
575 * @bits: if non null will hold is the prime's number of bits
576 *
577 * This function will export the pair of prime and generator for use in
578 * the Diffie-Hellman key exchange. The new parameters will be allocated using
579 * gnutls_malloc() and will be stored in the appropriate datum.
580 *
581 **/
582int
583gnutls_dh_params_export_raw (gnutls_dh_params_t params,
584 gnutls_datum_t * prime,
585 gnutls_datum_t * generator, unsigned int *bits)
586{
587
588 size_t size;
589
590 if (params->params[1] == NULL || params->params[0] == NULL)
591 {
592 gnutls_assert ();
593 return GNUTLS_E_INVALID_REQUEST;
594 }
595
596 size = 0;
597 _gnutls_mpi_print (NULL, &size, params->params[1]);
598
599 generator->data = gnutls_malloc (size);
600 if (generator->data == NULL)
601 {
602 return GNUTLS_E_MEMORY_ERROR;
603 }
604
605 generator->size = size;
606 _gnutls_mpi_print (generator->data, &size, params->params[1]);
607
608 size = 0;
609 _gnutls_mpi_print (NULL, &size, params->params[0]);
610
611 prime->data = gnutls_malloc (size);
612 if (prime->data == NULL)
613 {
614 gnutls_free (generator->data);
615 generator->data = NULL;
616 return GNUTLS_E_MEMORY_ERROR;
617 }
618 prime->size = size;
619 _gnutls_mpi_print (prime->data, &size, params->params[0]);
620
621 if (bits)
622 *bits = _gnutls_mpi_get_nbits (params->params[0]);
623
624 return 0;
625
626}
diff --git a/src/daemon/https/tls/gnutls_errors.c b/src/daemon/https/tls/gnutls_errors.c
index 9916dc96..9ebf67df 100644
--- a/src/daemon/https/tls/gnutls_errors.c
+++ b/src/daemon/https/tls/gnutls_errors.c
@@ -263,7 +263,7 @@ static const gnutls_error_entry error_algorithms[] = {
263 263
264 264
265/** 265/**
266 * gnutls_error_is_fatal - Returns non-zero in case of a fatal error 266 * MHD_gtls_error_is_fatal - Returns non-zero in case of a fatal error
267 * @error: is an error returned by a gnutls function. Error should be a negative value. 267 * @error: is an error returned by a gnutls function. Error should be a negative value.
268 * 268 *
269 * If a function returns a negative value you may feed that value 269 * If a function returns a negative value you may feed that value
@@ -279,7 +279,7 @@ static const gnutls_error_entry error_algorithms[] = {
279 * 279 *
280 **/ 280 **/
281int 281int
282gnutls_error_is_fatal (int error) 282MHD_gtls_error_is_fatal (int error)
283{ 283{
284 int ret = 1; 284 int ret = 1;
285 285
@@ -294,14 +294,14 @@ gnutls_error_is_fatal (int error)
294} 294}
295 295
296/** 296/**
297 * gnutls_perror - prints a string to stderr with a description of an error 297 * MHD_gtls_perror - prints a string to stderr with a description of an error
298 * @error: is an error returned by a gnutls function. Error is always a negative value. 298 * @error: is an error returned by a gnutls function. Error is always a negative value.
299 * 299 *
300 * This function is like perror(). The only difference is that it accepts an 300 * This function is like perror(). The only difference is that it accepts an
301 * error number returned by a gnutls function. 301 * error number returned by a gnutls function.
302 **/ 302 **/
303void 303void
304gnutls_perror (int error) 304MHD_gtls_perror (int error)
305{ 305{
306 const char *ret = NULL; 306 const char *ret = NULL;
307 307
@@ -314,7 +314,7 @@ gnutls_perror (int error)
314 314
315 315
316/** 316/**
317 * gnutls_strerror - Returns a string with a description of an error 317 * MHD_gtls_strerror - Returns a string with a description of an error
318 * @error: is an error returned by a gnutls function. Error is always a negative value. 318 * @error: is an error returned by a gnutls function. Error is always a negative value.
319 * 319 *
320 * This function is similar to strerror(). Differences: it accepts an error 320 * This function is similar to strerror(). Differences: it accepts an error
@@ -322,7 +322,7 @@ gnutls_perror (int error)
322 * a descriptive string is sent instead of NULL. 322 * a descriptive string is sent instead of NULL.
323 **/ 323 **/
324const char * 324const char *
325gnutls_strerror (int error) 325MHD_gtls_strerror (int error)
326{ 326{
327 const char *ret = NULL; 327 const char *ret = NULL;
328 328
diff --git a/src/daemon/https/tls/gnutls_extensions.c b/src/daemon/https/tls/gnutls_extensions.c
index 603446d7..5e09c911 100644
--- a/src/daemon/https/tls/gnutls_extensions.c
+++ b/src/daemon/https/tls/gnutls_extensions.c
@@ -43,26 +43,26 @@
43 43
44 44
45#define MAX_EXT_SIZE 10 45#define MAX_EXT_SIZE 10
46const int _gnutls_extensions_size = MAX_EXT_SIZE; 46const int mhd_gtls_extensions_size = MAX_EXT_SIZE;
47 47
48gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = { 48mhd_gtls_extension_entry mhd_gtls_extensions[MAX_EXT_SIZE] = {
49 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_MAX_RECORD_SIZE, 49 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_MAX_RECORD_SIZE,
50 EXTENSION_TLS, 50 EXTENSION_TLS,
51 _gnutls_max_record_recv_params, 51 mhd_gtls_max_record_recv_params,
52 _gnutls_max_record_send_params), 52 mhd_gtls_max_record_send_params),
53 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_CERT_TYPE, 53 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_CERT_TYPE,
54 EXTENSION_TLS, 54 EXTENSION_TLS,
55 _gnutls_cert_type_recv_params, 55 mhd_gtls_cert_type_recv_params,
56 _gnutls_cert_type_send_params), 56 mhd_gtls_cert_type_send_params),
57 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SERVER_NAME, 57 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SERVER_NAME,
58 EXTENSION_APPLICATION, 58 EXTENSION_APPLICATION,
59 _gnutls_server_name_recv_params, 59 mhd_gtls_server_name_recv_params,
60 _gnutls_server_name_send_params), 60 mhd_gtls_server_name_send_params),
61#ifdef ENABLE_OPRFI 61#ifdef ENABLE_OPRFI
62 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_OPAQUE_PRF_INPUT, 62 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_OPAQUE_PRF_INPUT,
63 EXTENSION_TLS, 63 EXTENSION_TLS,
64 _gnutls_oprfi_recv_params, 64 mhd_gtls_oprfi_recv_params,
65 _gnutls_oprfi_send_params), 65 mhd_gtls_oprfi_send_params),
66#endif 66#endif
67#ifdef ENABLE_SRP 67#ifdef ENABLE_SRP
68 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SRP, 68 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SRP,
@@ -72,14 +72,14 @@ gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = {
72#endif 72#endif
73 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_INNER_APPLICATION, 73 GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_INNER_APPLICATION,
74 EXTENSION_TLS, 74 EXTENSION_TLS,
75 _gnutls_inner_application_recv_params, 75 mhd_gtls_inner_app_rcv_params,
76 _gnutls_inner_application_send_params), 76 mhd_gtls_inner_app_send_params),
77 {0, 0, 0, 0} 77 {0, 0, 0, 0}
78}; 78};
79 79
80#define GNUTLS_EXTENSION_LOOP2(b) \ 80#define GNUTLS_EXTENSION_LOOP2(b) \
81 gnutls_extension_entry *p; \ 81 mhd_gtls_extension_entry *p; \
82 for(p = _gnutls_extensions; p->name != NULL; p++) { b ; } 82 for(p = mhd_gtls_extensions; p->name != NULL; p++) { b ; }
83 83
84#define GNUTLS_EXTENSION_LOOP(a) \ 84#define GNUTLS_EXTENSION_LOOP(a) \
85 GNUTLS_EXTENSION_LOOP2( if(p->type == type) { a; break; } ) 85 GNUTLS_EXTENSION_LOOP2( if(p->type == type) { a; break; } )
@@ -87,10 +87,10 @@ gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = {
87 87
88/* EXTENSION functions */ 88/* EXTENSION functions */
89 89
90ext_recv_func 90mhd_gtls_ext_recv_func
91_gnutls_ext_func_recv (uint16_t type, tls_ext_parse_type_t parse_type) 91mhd_gtls_ext_func_recv (uint16_t type, mhd_gtls_ext_parse_type_t parse_type)
92{ 92{
93 ext_recv_func ret = NULL; 93 mhd_gtls_ext_recv_func ret = NULL;
94 GNUTLS_EXTENSION_LOOP (if 94 GNUTLS_EXTENSION_LOOP (if
95 (parse_type == EXTENSION_ANY 95 (parse_type == EXTENSION_ANY
96 || p->parse_type == parse_type) ret = 96 || p->parse_type == parse_type) ret =
@@ -99,17 +99,17 @@ _gnutls_ext_func_recv (uint16_t type, tls_ext_parse_type_t parse_type)
99 99
100} 100}
101 101
102ext_send_func 102mhd_gtls_ext_send_func
103_gnutls_ext_func_send (uint16_t type) 103mhd_gtls_ext_func_send (uint16_t type)
104{ 104{
105 ext_send_func ret = NULL; 105 mhd_gtls_ext_send_func ret = NULL;
106 GNUTLS_EXTENSION_LOOP (ret = p->gnutls_ext_func_send); 106 GNUTLS_EXTENSION_LOOP (ret = p->gnutls_ext_func_send);
107 return ret; 107 return ret;
108 108
109} 109}
110 110
111const char * 111const char *
112_gnutls_extension_get_name (uint16_t type) 112mhd_gtls_extension_get_name (uint16_t type)
113{ 113{
114 const char *ret = NULL; 114 const char *ret = NULL;
115 115
@@ -123,7 +123,7 @@ _gnutls_extension_get_name (uint16_t type)
123 * requested ones. Otherwise it's a fatal error. 123 * requested ones. Otherwise it's a fatal error.
124 */ 124 */
125static int 125static int
126_gnutls_extension_list_check (gnutls_session_t session, uint16_t type) 126_gnutls_extension_list_check (mhd_gtls_session_t session, uint16_t type)
127{ 127{
128 if (session->security_parameters.entity == GNUTLS_CLIENT) 128 if (session->security_parameters.entity == GNUTLS_CLIENT)
129 { 129 {
@@ -140,15 +140,15 @@ _gnutls_extension_list_check (gnutls_session_t session, uint16_t type)
140} 140}
141 141
142int 142int
143_gnutls_parse_extensions (gnutls_session_t session, 143mhd_gtls_parse_extensions (mhd_gtls_session_t session,
144 tls_ext_parse_type_t parse_type, 144 mhd_gtls_ext_parse_type_t parse_type,
145 const opaque * data, int data_size) 145 const opaque * data, int data_size)
146{ 146{
147 int next, ret; 147 int next, ret;
148 int pos = 0; 148 int pos = 0;
149 uint16_t type; 149 uint16_t type;
150 const opaque *sdata; 150 const opaque *sdata;
151 ext_recv_func ext_recv; 151 mhd_gtls_ext_recv_func ext_recv;
152 uint16_t size; 152 uint16_t size;
153 153
154#ifdef DEBUG 154#ifdef DEBUG
@@ -159,14 +159,14 @@ _gnutls_parse_extensions (gnutls_session_t session,
159 { 159 {
160 _gnutls_debug_log ("EXT[%d]: expecting extension '%s'\n", 160 _gnutls_debug_log ("EXT[%d]: expecting extension '%s'\n",
161 session, 161 session,
162 _gnutls_extension_get_name (session-> 162 mhd_gtls_extension_get_name (session->
163 internals. 163 internals.
164 extensions_sent[i])); 164 extensions_sent[i]));
165 } 165 }
166#endif 166#endif
167 167
168 DECR_LENGTH_RET (data_size, 2, 0); 168 DECR_LENGTH_RET (data_size, 2, 0);
169 next = _gnutls_read_uint16 (data); 169 next = mhd_gtls_read_uint16 (data);
170 pos += 2; 170 pos += 2;
171 171
172 DECR_LENGTH_RET (data_size, next, 0); 172 DECR_LENGTH_RET (data_size, next, 0);
@@ -174,11 +174,11 @@ _gnutls_parse_extensions (gnutls_session_t session,
174 do 174 do
175 { 175 {
176 DECR_LENGTH_RET (next, 2, 0); 176 DECR_LENGTH_RET (next, 2, 0);
177 type = _gnutls_read_uint16 (&data[pos]); 177 type = mhd_gtls_read_uint16 (&data[pos]);
178 pos += 2; 178 pos += 2;
179 179
180 _gnutls_debug_log ("EXT[%x]: Received extension '%s/%d'\n", session, 180 _gnutls_debug_log ("EXT[%x]: Received extension '%s/%d'\n", session,
181 _gnutls_extension_get_name (type), type); 181 mhd_gtls_extension_get_name (type), type);
182 182
183 if ((ret = _gnutls_extension_list_check (session, type)) < 0) 183 if ((ret = _gnutls_extension_list_check (session, type)) < 0)
184 { 184 {
@@ -187,14 +187,14 @@ _gnutls_parse_extensions (gnutls_session_t session,
187 } 187 }
188 188
189 DECR_LENGTH_RET (next, 2, 0); 189 DECR_LENGTH_RET (next, 2, 0);
190 size = _gnutls_read_uint16 (&data[pos]); 190 size = mhd_gtls_read_uint16 (&data[pos]);
191 pos += 2; 191 pos += 2;
192 192
193 DECR_LENGTH_RET (next, size, 0); 193 DECR_LENGTH_RET (next, size, 0);
194 sdata = &data[pos]; 194 sdata = &data[pos];
195 pos += size; 195 pos += size;
196 196
197 ext_recv = _gnutls_ext_func_recv (type, parse_type); 197 ext_recv = mhd_gtls_ext_func_recv (type, parse_type);
198 if (ext_recv == NULL) 198 if (ext_recv == NULL)
199 continue; 199 continue;
200 if ((ret = ext_recv (session, sdata, size)) < 0) 200 if ((ret = ext_recv (session, sdata, size)) < 0)
@@ -215,7 +215,7 @@ _gnutls_parse_extensions (gnutls_session_t session,
215 * extensions are the ones we requested. 215 * extensions are the ones we requested.
216 */ 216 */
217static void 217static void
218_gnutls_extension_list_add (gnutls_session_t session, uint16_t type) 218_gnutls_extension_list_add (mhd_gtls_session_t session, uint16_t type)
219{ 219{
220 220
221 if (session->security_parameters.entity == GNUTLS_CLIENT) 221 if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -234,15 +234,15 @@ _gnutls_extension_list_add (gnutls_session_t session, uint16_t type)
234} 234}
235 235
236int 236int
237_gnutls_gen_extensions (gnutls_session_t session, opaque * data, 237mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
238 size_t data_size) 238 size_t data_size)
239{ 239{
240 int size; 240 int size;
241 uint16_t pos = 0; 241 uint16_t pos = 0;
242 opaque *sdata; 242 opaque *sdata;
243 int sdata_size; 243 int sdata_size;
244 ext_send_func ext_send; 244 mhd_gtls_ext_send_func ext_send;
245 gnutls_extension_entry *p; 245 mhd_gtls_extension_entry *p;
246 246
247 if (data_size < 2) 247 if (data_size < 2)
248 { 248 {
@@ -261,9 +261,9 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
261 } 261 }
262 262
263 pos += 2; 263 pos += 2;
264 for (p = _gnutls_extensions; p->name != NULL; p++) 264 for (p = mhd_gtls_extensions; p->name != NULL; p++)
265 { 265 {
266 ext_send = _gnutls_ext_func_send (p->type); 266 ext_send = mhd_gtls_ext_func_send (p->type);
267 if (ext_send == NULL) 267 if (ext_send == NULL)
268 continue; 268 continue;
269 size = ext_send (session, sdata, sdata_size); 269 size = ext_send (session, sdata, sdata_size);
@@ -277,11 +277,11 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
277 } 277 }
278 278
279 /* write extension type */ 279 /* write extension type */
280 _gnutls_write_uint16 (p->type, &data[pos]); 280 mhd_gtls_write_uint16 (p->type, &data[pos]);
281 pos += 2; 281 pos += 2;
282 282
283 /* write size */ 283 /* write size */
284 _gnutls_write_uint16 (size, &data[pos]); 284 mhd_gtls_write_uint16 (size, &data[pos]);
285 pos += 2; 285 pos += 2;
286 286
287 memcpy (&data[pos], sdata, size); 287 memcpy (&data[pos], sdata, size);
@@ -292,7 +292,7 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
292 _gnutls_extension_list_add (session, p->type); 292 _gnutls_extension_list_add (session, p->type);
293 293
294 _gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session, 294 _gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session,
295 _gnutls_extension_get_name (p->type)); 295 mhd_gtls_extension_get_name (p->type));
296 } 296 }
297 else if (size < 0) 297 else if (size < 0)
298 { 298 {
@@ -305,7 +305,7 @@ _gnutls_gen_extensions (gnutls_session_t session, opaque * data,
305 size = pos; 305 size = pos;
306 pos -= 2; /* remove the size of the size header! */ 306 pos -= 2; /* remove the size of the size header! */
307 307
308 _gnutls_write_uint16 (pos, data); 308 mhd_gtls_write_uint16 (pos, data);
309 309
310 if (size == 2) 310 if (size == 2)
311 { /* empty */ 311 { /* empty */
diff --git a/src/daemon/https/tls/gnutls_extensions.h b/src/daemon/https/tls/gnutls_extensions.h
index c305846c..d5e209f8 100644
--- a/src/daemon/https/tls/gnutls_extensions.h
+++ b/src/daemon/https/tls/gnutls_extensions.h
@@ -24,22 +24,22 @@
24 24
25#include <gnutls_int.h> 25#include <gnutls_int.h>
26 26
27const char *_gnutls_extension_get_name (uint16_t type); 27const char * mhd_gtls_extension_get_name (uint16_t type);
28int _gnutls_parse_extensions (gnutls_session_t, tls_ext_parse_type_t, const opaque *, int); 28int mhd_gtls_parse_extensions (mhd_gtls_session_t, mhd_gtls_ext_parse_type_t, const opaque *, int);
29int _gnutls_gen_extensions (gnutls_session_t session, opaque * data, 29int mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
30 size_t data_size); 30 size_t data_size);
31 31
32typedef int (*ext_recv_func) (gnutls_session_t, const opaque *, size_t); /* recv data */ 32typedef int (* mhd_gtls_ext_recv_func) (mhd_gtls_session_t, const opaque *, size_t); /* recv data */
33typedef int (*ext_send_func) (gnutls_session_t, opaque *, size_t); /* send data */ 33typedef int (* mhd_gtls_ext_send_func) (mhd_gtls_session_t, opaque *, size_t); /* send data */
34 34
35ext_send_func _gnutls_ext_func_send (uint16_t type); 35mhd_gtls_ext_send_func mhd_gtls_ext_func_send (uint16_t type);
36ext_recv_func _gnutls_ext_func_recv (uint16_t type, tls_ext_parse_type_t); 36mhd_gtls_ext_recv_func mhd_gtls_ext_func_recv (uint16_t type, mhd_gtls_ext_parse_type_t);
37 37
38typedef struct 38typedef struct
39{ 39{
40 const char *name; 40 const char *name;
41 uint16_t type; 41 uint16_t type;
42 tls_ext_parse_type_t parse_type; 42 mhd_gtls_ext_parse_type_t parse_type;
43 ext_recv_func gnutls_ext_func_recv; 43 mhd_gtls_ext_recv_func gnutls_ext_func_recv;
44 ext_send_func gnutls_ext_func_send; 44 mhd_gtls_ext_send_func gnutls_ext_func_send;
45} gnutls_extension_entry; 45} mhd_gtls_extension_entry;
diff --git a/src/daemon/https/tls/gnutls_extra_hooks.h b/src/daemon/https/tls/gnutls_extra_hooks.h
index ac55d06a..b4e83bad 100644
--- a/src/daemon/https/tls/gnutls_extra_hooks.h
+++ b/src/daemon/https/tls/gnutls_extra_hooks.h
@@ -29,7 +29,7 @@
29#include <auth_cert.h> 29#include <auth_cert.h>
30 30
31typedef int (*_gnutls_openpgp_verify_key_func) 31typedef int (*_gnutls_openpgp_verify_key_func)
32(const gnutls_certificate_credentials_t, 32(const mhd_gtls_cert_credentials_t,
33 const gnutls_datum_t *, int, 33 const gnutls_datum_t *, int,
34 unsigned int *); 34 unsigned int *);
35 35
@@ -40,8 +40,8 @@ typedef time_t (*_gnutls_openpgp_crt_expiration_time_func)
40(const gnutls_datum_t *); 40(const gnutls_datum_t *);
41 41
42typedef int (*_gnutls_openpgp_crt_request_func) 42typedef int (*_gnutls_openpgp_crt_request_func)
43(gnutls_session_t, gnutls_datum_t *, 43(mhd_gtls_session_t, gnutls_datum_t *,
44 const gnutls_certificate_credentials_t, 44 const mhd_gtls_cert_credentials_t,
45 opaque *, int); 45 opaque *, int);
46 46
47typedef int (*_gnutls_openpgp_fingerprint_func) 47typedef int (*_gnutls_openpgp_fingerprint_func)
diff --git a/src/daemon/https/tls/gnutls_global.c b/src/daemon/https/tls/gnutls_global.c
index 5df0619b..916e8117 100644
--- a/src/daemon/https/tls/gnutls_global.c
+++ b/src/daemon/https/tls/gnutls_global.c
@@ -59,7 +59,7 @@ ASN1_TYPE _gnutls_pkix1_asn;
59ASN1_TYPE _gnutls_gnutls_asn; 59ASN1_TYPE _gnutls_gnutls_asn;
60 60
61/** 61/**
62 * gnutls_global_set_log_function - This function sets the logging function 62 * MHD_gtls_global_set_log_function - This function sets the logging function
63 * @log_func: it's a log function 63 * @log_func: it's a log function
64 * 64 *
65 * This is the function where you set the logging function gnutls 65 * This is the function where you set the logging function gnutls
@@ -71,13 +71,13 @@ ASN1_TYPE _gnutls_gnutls_asn;
71 * void (*gnutls_log_func)( int level, const char*); 71 * void (*gnutls_log_func)( int level, const char*);
72 **/ 72 **/
73void 73void
74gnutls_global_set_log_function (gnutls_log_func log_func) 74MHD_gtls_global_set_log_function (gnutls_log_func log_func)
75{ 75{
76 _gnutls_log_func = log_func; 76 _gnutls_log_func = log_func;
77} 77}
78 78
79/** 79/**
80 * gnutls_global_set_log_level - This function sets the logging level 80 * MHD_gtls_global_set_log_level - This function sets the logging level
81 * @level: it's an integer from 0 to 9. 81 * @level: it's an integer from 0 to 9.
82 * 82 *
83 * This is the function that allows you to set the log level. 83 * This is the function that allows you to set the log level.
@@ -89,7 +89,7 @@ gnutls_global_set_log_function (gnutls_log_func log_func)
89 * 89 *
90 **/ 90 **/
91void 91void
92gnutls_global_set_log_level (int level) 92MHD_gtls_global_set_log_level (int level)
93{ 93{
94 _gnutls_log_level = level; 94 _gnutls_log_level = level;
95} 95}
@@ -105,7 +105,7 @@ extern void *(*gnutls_calloc) (size_t, size_t);
105int _gnutls_is_secure_mem_null (const void *); 105int _gnutls_is_secure_mem_null (const void *);
106 106
107/** 107/**
108 * gnutls_global_set_mem_functions - This function sets the memory allocation functions 108 * MHD_gtls_global_set_mem_functions - This function sets the memory allocation functions
109 * @alloc_func: it's the default memory allocation function. Like malloc(). 109 * @alloc_func: it's the default memory allocation function. Like malloc().
110 * @secure_alloc_func: This is the memory allocation function that will be used for sensitive data. 110 * @secure_alloc_func: This is the memory allocation function that will be used for sensitive data.
111 * @is_secure_func: a function that returns 0 if the memory given is not secure. May be NULL. 111 * @is_secure_func: a function that returns 0 if the memory given is not secure. May be NULL.
@@ -118,17 +118,16 @@ int _gnutls_is_secure_mem_null (const void *);
118 * This function is provided to set the memory allocation functions to 118 * This function is provided to set the memory allocation functions to
119 * something other than the defaults (ie the gcrypt allocation functions). 119 * something other than the defaults (ie the gcrypt allocation functions).
120 * 120 *
121 * This function must be called before gnutls_global_init() is called. 121 * This function must be called before MHD_gnutls_global_init() is called.
122 * 122 *
123 **/ 123 **/
124void 124void MHD_gtls_global_set_mem_functions(gnutls_alloc_function alloc_func,
125gnutls_global_set_mem_functions (gnutls_alloc_function alloc_func, 125 gnutls_alloc_function
126 gnutls_alloc_function 126 secure_alloc_func,
127 secure_alloc_func, 127 gnutls_is_secure_function
128 gnutls_is_secure_function 128 is_secure_func,
129 is_secure_func, 129 gnutls_realloc_function realloc_func,
130 gnutls_realloc_function realloc_func, 130 gnutls_free_function free_func)
131 gnutls_free_function free_func)
132{ 131{
133 gnutls_secure_malloc = secure_alloc_func; 132 gnutls_secure_malloc = secure_alloc_func;
134 gnutls_malloc = alloc_func; 133 gnutls_malloc = alloc_func;
@@ -148,10 +147,10 @@ gnutls_global_set_mem_functions (gnutls_alloc_function alloc_func,
148 gnutls_calloc = calloc; 147 gnutls_calloc = calloc;
149 } 148 }
150 else 149 else
151 { /* use the included ones */ 150 { /* use the included ones */
152 gnutls_calloc = _gnutls_calloc; 151 gnutls_calloc = mhd_gtls_calloc;
153 } 152 }
154 gnutls_strdup = _gnutls_strdup; 153 gnutls_strdup = mhd_gtls_strdup;
155 154
156} 155}
157 156
@@ -167,12 +166,12 @@ _gnutls_gcry_log_handler (void *dummy, int level,
167static int _gnutls_init = 0; 166static int _gnutls_init = 0;
168 167
169/** 168/**
170 * gnutls_global_init - This function initializes the global data to defaults. 169 * MHD_gnutls_global_init - This function initializes the global data to defaults.
171 * 170 *
172 * This function initializes the global data to defaults. 171 * This function initializes the global data to defaults.
173 * Every gnutls application has a global data which holds common parameters 172 * Every gnutls application has a global data which holds common parameters
174 * shared by gnutls session structures. 173 * shared by gnutls session structures.
175 * You must call gnutls_global_deinit() when gnutls usage is no longer needed 174 * You must call MHD_gnutls_global_deinit() when gnutls usage is no longer needed
176 * Returns zero on success. 175 * Returns zero on success.
177 * 176 *
178 * Note that this function will also initialize libgcrypt, if it has not 177 * Note that this function will also initialize libgcrypt, if it has not
@@ -181,8 +180,8 @@ static int _gnutls_init = 0;
181 * want to disable libgcrypt's internal lockings etc. 180 * want to disable libgcrypt's internal lockings etc.
182 * 181 *
183 * This function increment a global counter, so that 182 * This function increment a global counter, so that
184 * gnutls_global_deinit() only releases resources when it has been 183 * MHD_gnutls_global_deinit() only releases resources when it has been
185 * called as many times as gnutls_global_init(). This is useful when 184 * called as many times as MHD_gnutls_global_init(). This is useful when
186 * GnuTLS is used by more than one library in an application. This 185 * GnuTLS is used by more than one library in an application. This
187 * function can be called many times, but will only do something the 186 * function can be called many times, but will only do something the
188 * first time. 187 * first time.
@@ -197,7 +196,7 @@ static int _gnutls_init = 0;
197 * 196 *
198 **/ 197 **/
199int 198int
200gnutls_global_init (void) 199MHD_gnutls_global_init (void)
201{ 200{
202 int result = 0; 201 int result = 0;
203 int res; 202 int res;
@@ -279,7 +278,7 @@ gnutls_global_init (void)
279 } 278 }
280 279
281#ifdef DEBUG 280#ifdef DEBUG
282 gnutls_global_set_log_function (MHD_tls_log_func); 281 MHD_gtls_global_set_log_function (MHD_tls_log_func);
283#endif 282#endif
284 283
285 /* initialize parser 284 /* initialize parser
@@ -308,17 +307,17 @@ gnutls_global_init (void)
308} 307}
309 308
310/** 309/**
311 * gnutls_global_deinit - This function deinitializes the global data 310 * MHD_gnutls_global_deinit - This function deinitializes the global data
312 * 311 *
313 * This function deinitializes the global data, that were initialized 312 * This function deinitializes the global data, that were initialized
314 * using gnutls_global_init(). 313 * using MHD_gnutls_global_init().
315 * 314 *
316 * Note! This function is not thread safe. See the discussion for 315 * Note! This function is not thread safe. See the discussion for
317 * gnutls_global_init() for more information. 316 * MHD_gnutls_global_init() for more information.
318 * 317 *
319 **/ 318 **/
320void 319void
321gnutls_global_deinit (void) 320MHD_gnutls_global_deinit (void)
322{ 321{
323 if (_gnutls_init == 1) 322 if (_gnutls_init == 1)
324 { 323 {
@@ -337,7 +336,7 @@ gnutls_global_deinit (void)
337 */ 336 */
338 337
339/** 338/**
340 * gnutls_transport_set_pull_function - This function sets a read like function 339 * MHD_gnutls_transport_set_pull_function - This function sets a read like function
341 * @pull_func: a callback function similar to read() 340 * @pull_func: a callback function similar to read()
342 * @session: gnutls session 341 * @session: gnutls session
343 * 342 *
@@ -347,17 +346,17 @@ gnutls_global_deinit (void)
347 * probably be ok. 346 * probably be ok.
348 * 347 *
349 * PULL_FUNC is of the form, 348 * PULL_FUNC is of the form,
350 * ssize_t (*gnutls_pull_func)(gnutls_transport_ptr_t, void*, size_t); 349 * ssize_t (*mhd_gtls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
351 **/ 350 **/
352void 351void
353gnutls_transport_set_pull_function (gnutls_session_t session, 352MHD_gnutls_transport_set_pull_function (mhd_gtls_session_t session,
354 gnutls_pull_func pull_func) 353 mhd_gtls_pull_func pull_func)
355{ 354{
356 session->internals._gnutls_pull_func = pull_func; 355 session->internals._gnutls_pull_func = pull_func;
357} 356}
358 357
359/** 358/**
360 * gnutls_transport_set_push_function - This function sets the function to send data 359 * MHD_gnutls_transport_set_push_function - This function sets the function to send data
361 * @push_func: a callback function similar to write() 360 * @push_func: a callback function similar to write()
362 * @session: gnutls session 361 * @session: gnutls session
363 * 362 *
@@ -368,11 +367,11 @@ gnutls_transport_set_pull_function (gnutls_session_t session,
368 * specify this function for gnutls to be able to send data. 367 * specify this function for gnutls to be able to send data.
369 * 368 *
370 * PUSH_FUNC is of the form, 369 * PUSH_FUNC is of the form,
371 * ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t); 370 * ssize_t (*mhd_gtls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
372 **/ 371 **/
373void 372void
374gnutls_transport_set_push_function (gnutls_session_t session, 373MHD_gnutls_transport_set_push_function (mhd_gtls_session_t session,
375 gnutls_push_func push_func) 374 mhd_gtls_push_func push_func)
376{ 375{
377 session->internals._gnutls_push_func = push_func; 376 session->internals._gnutls_push_func = push_func;
378} 377}
diff --git a/src/daemon/https/tls/gnutls_global.h b/src/daemon/https/tls/gnutls_global.h
index 4a9488fd..7ec40882 100644
--- a/src/daemon/https/tls/gnutls_global.h
+++ b/src/daemon/https/tls/gnutls_global.h
@@ -27,7 +27,7 @@
27 27
28#include <libtasn1.h> 28#include <libtasn1.h>
29 29
30/* this mutex is used to synchronize threads attemting call gnutls_global_init / gnutls_global_deinit */ 30/* this mutex is used to synchronize threads attemting call MHD_gnutls_global_init / MHD_gnutls_global_deinit */
31pthread_mutex_t gnutls_init_mutex; 31pthread_mutex_t gnutls_init_mutex;
32 32
33int gnutls_is_secure_memory (const void *mem); 33int gnutls_is_secure_memory (const void *mem);
diff --git a/src/daemon/https/tls/gnutls_handshake.c b/src/daemon/https/tls/gnutls_handshake.c
index 5f56822e..882b43e2 100644
--- a/src/daemon/https/tls/gnutls_handshake.c
+++ b/src/daemon/https/tls/gnutls_handshake.c
@@ -46,7 +46,7 @@
46#include "gnutls_record.h" 46#include "gnutls_record.h"
47#include "gnutls_state.h" 47#include "gnutls_state.h"
48#include "gnutls_rsa_export.h" /* for gnutls_get_rsa_params() */ 48#include "gnutls_rsa_export.h" /* for gnutls_get_rsa_params() */
49#include "auth_anon.h" /* for gnutls_anon_server_credentials_t */ 49#include "auth_anon.h" /* for mhd_gtls_anon_server_credentials_t */
50#include "gc.h" 50#include "gc.h"
51 51
52#ifdef HANDSHAKE_DEBUG 52#ifdef HANDSHAKE_DEBUG
@@ -58,20 +58,20 @@
58#define TRUE 1 58#define TRUE 1
59#define FALSE 0 59#define FALSE 0
60 60
61int _gnutls_server_select_comp_method (gnutls_session_t session, 61int _gnutls_server_select_comp_method (mhd_gtls_session_t session,
62 opaque * data, int datalen); 62 opaque * data, int datalen);
63 63
64 64
65/* Clears the handshake hash buffers and handles. 65/* Clears the handshake hash buffers and handles.
66 */ 66 */
67inline static void 67inline static void
68_gnutls_handshake_hash_buffers_clear (gnutls_session_t session) 68_gnutls_handshake_hash_buffers_clear (mhd_gtls_session_t session)
69{ 69{
70 _gnutls_hash_deinit (session->internals.handshake_mac_handle_md5, NULL); 70 mhd_gnutls_hash_deinit (session->internals.handshake_mac_handle_md5, NULL);
71 _gnutls_hash_deinit (session->internals.handshake_mac_handle_sha, NULL); 71 mhd_gnutls_hash_deinit (session->internals.handshake_mac_handle_sha, NULL);
72 session->internals.handshake_mac_handle_md5 = NULL; 72 session->internals.handshake_mac_handle_md5 = NULL;
73 session->internals.handshake_mac_handle_sha = NULL; 73 session->internals.handshake_mac_handle_sha = NULL;
74 _gnutls_handshake_buffer_clear (session); 74 mhd_gtls_handshake_buffer_clear (session);
75} 75}
76 76
77/* this will copy the required values for resuming to 77/* this will copy the required values for resuming to
@@ -79,7 +79,7 @@ _gnutls_handshake_hash_buffers_clear (gnutls_session_t session)
79 * this will keep as less data to security_parameters. 79 * this will keep as less data to security_parameters.
80 */ 80 */
81static void 81static void
82resume_copy_required_values (gnutls_session_t session) 82resume_copy_required_values (mhd_gtls_session_t session)
83{ 83{
84 /* get the new random values */ 84 /* get the new random values */
85 memcpy (session->internals.resumed_security_parameters. 85 memcpy (session->internals.resumed_security_parameters.
@@ -107,7 +107,7 @@ resume_copy_required_values (gnutls_session_t session)
107 session->security_parameters.entity = 107 session->security_parameters.entity =
108 session->internals.resumed_security_parameters.entity; 108 session->internals.resumed_security_parameters.entity;
109 109
110 _gnutls_set_current_version (session, 110 mhd_gtls_set_current_version (session,
111 session->internals. 111 session->internals.
112 resumed_security_parameters.version); 112 resumed_security_parameters.version);
113 113
@@ -122,13 +122,13 @@ resume_copy_required_values (gnutls_session_t session)
122} 122}
123 123
124void 124void
125_gnutls_set_server_random (gnutls_session_t session, uint8_t * rnd) 125mhd_gtls_set_server_random (mhd_gtls_session_t session, uint8_t * rnd)
126{ 126{
127 memcpy (session->security_parameters.server_random, rnd, TLS_RANDOM_SIZE); 127 memcpy (session->security_parameters.server_random, rnd, TLS_RANDOM_SIZE);
128} 128}
129 129
130void 130void
131_gnutls_set_client_random (gnutls_session_t session, uint8_t * rnd) 131mhd_gtls_set_client_random (mhd_gtls_session_t session, uint8_t * rnd)
132{ 132{
133 memcpy (session->security_parameters.client_random, rnd, TLS_RANDOM_SIZE); 133 memcpy (session->security_parameters.client_random, rnd, TLS_RANDOM_SIZE);
134} 134}
@@ -138,25 +138,25 @@ _gnutls_set_client_random (gnutls_session_t session, uint8_t * rnd)
138#define SSL3_SERVER_MSG "SRVR" 138#define SSL3_SERVER_MSG "SRVR"
139#define SSL_MSG_LEN 4 139#define SSL_MSG_LEN 4
140static int 140static int
141_gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret) 141_gnutls_ssl3_finished (mhd_gtls_session_t session, int type, opaque * ret)
142{ 142{
143 const int siz = SSL_MSG_LEN; 143 const int siz = SSL_MSG_LEN;
144 mac_hd_t td_md5; 144 mac_hd_t td_md5;
145 mac_hd_t td_sha; 145 mac_hd_t td_sha;
146 const char *mesg; 146 const char *mesg;
147 147
148 td_md5 = _gnutls_hash_copy (session->internals.handshake_mac_handle_md5); 148 td_md5 = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
149 if (td_md5 == NULL) 149 if (td_md5 == NULL)
150 { 150 {
151 gnutls_assert (); 151 gnutls_assert ();
152 return GNUTLS_E_HASH_FAILED; 152 return GNUTLS_E_HASH_FAILED;
153 } 153 }
154 154
155 td_sha = _gnutls_hash_copy (session->internals.handshake_mac_handle_sha); 155 td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
156 if (td_sha == NULL) 156 if (td_sha == NULL)
157 { 157 {
158 gnutls_assert (); 158 gnutls_assert ();
159 _gnutls_hash_deinit (td_md5, NULL); 159 mhd_gnutls_hash_deinit (td_md5, NULL);
160 return GNUTLS_E_HASH_FAILED; 160 return GNUTLS_E_HASH_FAILED;
161 } 161 }
162 162
@@ -169,13 +169,13 @@ _gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret)
169 mesg = SSL3_CLIENT_MSG; 169 mesg = SSL3_CLIENT_MSG;
170 } 170 }
171 171
172 _gnutls_hash (td_md5, mesg, siz); 172 mhd_gnutls_hash (td_md5, mesg, siz);
173 _gnutls_hash (td_sha, mesg, siz); 173 mhd_gnutls_hash (td_sha, mesg, siz);
174 174
175 _gnutls_mac_deinit_ssl3_handshake (td_md5, ret, 175 mhd_gnutls_mac_deinit_ssl3_handshake (td_md5, ret,
176 session->security_parameters. 176 session->security_parameters.
177 master_secret, TLS_MASTER_SIZE); 177 master_secret, TLS_MASTER_SIZE);
178 _gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16], 178 mhd_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16],
179 session->security_parameters. 179 session->security_parameters.
180 master_secret, TLS_MASTER_SIZE); 180 master_secret, TLS_MASTER_SIZE);
181 181
@@ -187,7 +187,7 @@ _gnutls_ssl3_finished (gnutls_session_t session, int type, opaque * ret)
187#define CLIENT_MSG "client finished" 187#define CLIENT_MSG "client finished"
188#define TLS_MSG_LEN 15 188#define TLS_MSG_LEN 15
189int 189int
190_gnutls_finished (gnutls_session_t session, int type, void *ret) 190_gnutls_finished (mhd_gtls_session_t session, int type, void *ret)
191{ 191{
192 const int siz = TLS_MSG_LEN; 192 const int siz = TLS_MSG_LEN;
193 opaque concat[36]; 193 opaque concat[36];
@@ -195,12 +195,12 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
195 const char *mesg; 195 const char *mesg;
196 mac_hd_t td_md5 = NULL; 196 mac_hd_t td_md5 = NULL;
197 mac_hd_t td_sha; 197 mac_hd_t td_sha;
198 gnutls_protocol_t ver = gnutls_protocol_get_version (session); 198 gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
199 199
200 if (ver < MHD_GNUTLS_TLS1_2) 200 if (ver < MHD_GNUTLS_TLS1_2)
201 { 201 {
202 td_md5 = 202 td_md5 =
203 _gnutls_hash_copy (session->internals.handshake_mac_handle_md5); 203 mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
204 if (td_md5 == NULL) 204 if (td_md5 == NULL)
205 { 205 {
206 gnutls_assert (); 206 gnutls_assert ();
@@ -208,23 +208,23 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
208 } 208 }
209 } 209 }
210 210
211 td_sha = _gnutls_hash_copy (session->internals.handshake_mac_handle_sha); 211 td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
212 if (td_sha == NULL) 212 if (td_sha == NULL)
213 { 213 {
214 gnutls_assert (); 214 gnutls_assert ();
215 _gnutls_hash_deinit (td_md5, NULL); 215 mhd_gnutls_hash_deinit (td_md5, NULL);
216 return GNUTLS_E_HASH_FAILED; 216 return GNUTLS_E_HASH_FAILED;
217 } 217 }
218 218
219 if (ver < MHD_GNUTLS_TLS1_2) 219 if (ver < MHD_GNUTLS_TLS1_2)
220 { 220 {
221 _gnutls_hash_deinit (td_md5, concat); 221 mhd_gnutls_hash_deinit (td_md5, concat);
222 _gnutls_hash_deinit (td_sha, &concat[16]); 222 mhd_gnutls_hash_deinit (td_sha, &concat[16]);
223 len = 20 + 16; 223 len = 20 + 16;
224 } 224 }
225 else 225 else
226 { 226 {
227 _gnutls_hash_deinit (td_sha, concat); 227 mhd_gnutls_hash_deinit (td_sha, concat);
228 len = 20; 228 len = 20;
229 } 229 }
230 230
@@ -237,7 +237,7 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
237 mesg = CLIENT_MSG; 237 mesg = CLIENT_MSG;
238 } 238 }
239 239
240 return _gnutls_PRF (session, session->security_parameters.master_secret, 240 return mhd_gtls_PRF (session, session->security_parameters.master_secret,
241 TLS_MASTER_SIZE, mesg, siz, concat, len, 12, ret); 241 TLS_MASTER_SIZE, mesg, siz, concat, len, 12, ret);
242} 242}
243 243
@@ -245,7 +245,7 @@ _gnutls_finished (gnutls_session_t session, int type, void *ret)
245 * and put it to dst. 245 * and put it to dst.
246 */ 246 */
247int 247int
248_gnutls_tls_create_random (opaque * dst) 248mhd_gtls_tls_create_random (opaque * dst)
249{ 249{
250 uint32_t tim; 250 uint32_t tim;
251 251
@@ -256,7 +256,7 @@ _gnutls_tls_create_random (opaque * dst)
256 256
257 tim = time (NULL); 257 tim = time (NULL);
258 /* generate server random value */ 258 /* generate server random value */
259 _gnutls_write_uint32 (tim, dst); 259 mhd_gtls_write_uint32 (tim, dst);
260 260
261 if (gc_nonce (&dst[4], TLS_RANDOM_SIZE - 4) != GC_OK) 261 if (gc_nonce (&dst[4], TLS_RANDOM_SIZE - 4) != GC_OK)
262 { 262 {
@@ -270,18 +270,18 @@ _gnutls_tls_create_random (opaque * dst)
270/* returns the 0 on success or a negative value. 270/* returns the 0 on success or a negative value.
271 */ 271 */
272int 272int
273_gnutls_negotiate_version (gnutls_session_t session, 273mhd_gtls_negotiate_version (mhd_gtls_session_t session,
274 gnutls_protocol_t adv_version) 274 gnutls_protocol_t adv_version)
275{ 275{
276 int ret; 276 int ret;
277 277
278 /* if we do not support that version */ 278 /* if we do not support that version */
279 if (_gnutls_version_is_supported (session, adv_version) == 0) 279 if (mhd_gtls_version_is_supported (session, adv_version) == 0)
280 { 280 {
281 /* If he requested something we do not support 281 /* If he requested something we do not support
282 * then we send him the highest we support. 282 * then we send him the highest we support.
283 */ 283 */
284 ret = _gnutls_version_max (session); 284 ret = mhd_gtls_version_max (session);
285 if (ret == MHD_GNUTLS_VERSION_UNKNOWN) 285 if (ret == MHD_GNUTLS_VERSION_UNKNOWN)
286 { 286 {
287 /* this check is not really needed. 287 /* this check is not really needed.
@@ -295,13 +295,13 @@ _gnutls_negotiate_version (gnutls_session_t session,
295 ret = adv_version; 295 ret = adv_version;
296 } 296 }
297 297
298 _gnutls_set_current_version (session, ret); 298 mhd_gtls_set_current_version (session, ret);
299 299
300 return ret; 300 return ret;
301} 301}
302 302
303int 303int
304_gnutls_user_hello_func (gnutls_session session, 304mhd_gtls_user_hello_func (gnutls_session session,
305 gnutls_protocol_t adv_version) 305 gnutls_protocol_t adv_version)
306{ 306{
307 int ret; 307 int ret;
@@ -317,7 +317,7 @@ _gnutls_user_hello_func (gnutls_session session,
317 /* Here we need to renegotiate the version since the callee might 317 /* Here we need to renegotiate the version since the callee might
318 * have disabled some TLS versions. 318 * have disabled some TLS versions.
319 */ 319 */
320 ret = _gnutls_negotiate_version (session, adv_version); 320 ret = mhd_gtls_negotiate_version (session, adv_version);
321 if (ret < 0) 321 if (ret < 0)
322 { 322 {
323 gnutls_assert (); 323 gnutls_assert ();
@@ -333,7 +333,7 @@ _gnutls_user_hello_func (gnutls_session session,
333 * since SSL version 2.0 is not supported). 333 * since SSL version 2.0 is not supported).
334 */ 334 */
335int 335int
336_gnutls_read_client_hello (gnutls_session_t session, opaque * data, 336_gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data,
337 int datalen) 337 int datalen)
338{ 338{
339 uint8_t session_id_len; 339 uint8_t session_id_len;
@@ -349,11 +349,11 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
349 _gnutls_handshake_log ("HSK[%x]: Client's version: %d.%d\n", session, 349 _gnutls_handshake_log ("HSK[%x]: Client's version: %d.%d\n", session,
350 data[pos], data[pos + 1]); 350 data[pos], data[pos + 1]);
351 351
352 adv_version = _gnutls_version_get (data[pos], data[pos + 1]); 352 adv_version = mhd_gtls_version_get (data[pos], data[pos + 1]);
353 set_adv_version (session, data[pos], data[pos + 1]); 353 set_adv_version (session, data[pos], data[pos + 1]);
354 pos += 2; 354 pos += 2;
355 355
356 neg_version = _gnutls_negotiate_version (session, adv_version); 356 neg_version = mhd_gtls_negotiate_version (session, adv_version);
357 if (neg_version < 0) 357 if (neg_version < 0)
358 { 358 {
359 gnutls_assert (); 359 gnutls_assert ();
@@ -363,11 +363,11 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
363 /* Read client random value. 363 /* Read client random value.
364 */ 364 */
365 DECR_LEN (len, TLS_RANDOM_SIZE); 365 DECR_LEN (len, TLS_RANDOM_SIZE);
366 _gnutls_set_client_random (session, &data[pos]); 366 mhd_gtls_set_client_random (session, &data[pos]);
367 pos += TLS_RANDOM_SIZE; 367 pos += TLS_RANDOM_SIZE;
368 368
369 _gnutls_tls_create_random (rnd); 369 mhd_gtls_tls_create_random (rnd);
370 _gnutls_set_server_random (session, rnd); 370 mhd_gtls_set_server_random (session, rnd);
371 371
372 session->security_parameters.timestamp = time (NULL); 372 session->security_parameters.timestamp = time (NULL);
373 373
@@ -389,11 +389,11 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
389 { /* resumed! */ 389 { /* resumed! */
390 resume_copy_required_values (session); 390 resume_copy_required_values (session);
391 session->internals.resumed = RESUME_TRUE; 391 session->internals.resumed = RESUME_TRUE;
392 return _gnutls_user_hello_func (session, adv_version); 392 return mhd_gtls_user_hello_func (session, adv_version);
393 } 393 }
394 else 394 else
395 { 395 {
396 _gnutls_generate_session_id (session->security_parameters. 396 mhd_gtls_generate_session_id (session->security_parameters.
397 session_id, 397 session_id,
398 &session->security_parameters. 398 &session->security_parameters.
399 session_id_size); 399 session_id_size);
@@ -404,7 +404,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
404 /* Remember ciphersuites for later 404 /* Remember ciphersuites for later
405 */ 405 */
406 DECR_LEN (len, 2); 406 DECR_LEN (len, 2);
407 suite_size = _gnutls_read_uint16 (&data[pos]); 407 suite_size = mhd_gtls_read_uint16 (&data[pos]);
408 pos += 2; 408 pos += 2;
409 409
410 DECR_LEN (len, suite_size); 410 DECR_LEN (len, suite_size);
@@ -424,7 +424,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
424 */ 424 */
425 if (neg_version >= MHD_GNUTLS_TLS1_0) 425 if (neg_version >= MHD_GNUTLS_TLS1_0)
426 { 426 {
427 ret = _gnutls_parse_extensions (session, EXTENSION_APPLICATION, &data[pos], len); /* len is the rest of the parsed length */ 427 ret = mhd_gtls_parse_extensions (session, EXTENSION_APPLICATION, &data[pos], len); /* len is the rest of the parsed length */
428 if (ret < 0) 428 if (ret < 0)
429 { 429 {
430 gnutls_assert (); 430 gnutls_assert ();
@@ -432,7 +432,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
432 } 432 }
433 } 433 }
434 434
435 ret = _gnutls_user_hello_func (session, adv_version); 435 ret = mhd_gtls_user_hello_func (session, adv_version);
436 if (ret < 0) 436 if (ret < 0)
437 { 437 {
438 gnutls_assert (); 438 gnutls_assert ();
@@ -441,7 +441,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
441 441
442 if (neg_version >= MHD_GNUTLS_TLS1_0) 442 if (neg_version >= MHD_GNUTLS_TLS1_0)
443 { 443 {
444 ret = _gnutls_parse_extensions (session, EXTENSION_TLS, &data[pos], len); /* len is the rest of the parsed length */ 444 ret = mhd_gtls_parse_extensions (session, EXTENSION_TLS, &data[pos], len); /* len is the rest of the parsed length */
445 if (ret < 0) 445 if (ret < 0)
446 { 446 {
447 gnutls_assert (); 447 gnutls_assert ();
@@ -451,7 +451,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
451 451
452 /* select an appropriate cipher suite 452 /* select an appropriate cipher suite
453 */ 453 */
454 ret = _gnutls_server_select_suite (session, suite_ptr, suite_size); 454 ret = mhd_gtls_server_select_suite (session, suite_ptr, suite_size);
455 if (ret < 0) 455 if (ret < 0)
456 { 456 {
457 gnutls_assert (); 457 gnutls_assert ();
@@ -472,7 +472,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
472/* here we hash all pending data. 472/* here we hash all pending data.
473 */ 473 */
474inline static int 474inline static int
475_gnutls_handshake_hash_pending (gnutls_session_t session) 475_gnutls_handshake_hash_pending (mhd_gtls_session_t session)
476{ 476{
477 size_t siz; 477 size_t siz;
478 int ret; 478 int ret;
@@ -487,7 +487,7 @@ _gnutls_handshake_hash_pending (gnutls_session_t session)
487 487
488 /* We check if there are pending data to hash. 488 /* We check if there are pending data to hash.
489 */ 489 */
490 if ((ret = _gnutls_handshake_buffer_get_ptr (session, &data, &siz)) < 0) 490 if ((ret = mhd_gtls_handshake_buffer_get_ptr (session, &data, &siz)) < 0)
491 { 491 {
492 gnutls_assert (); 492 gnutls_assert ();
493 return ret; 493 return ret;
@@ -495,11 +495,11 @@ _gnutls_handshake_hash_pending (gnutls_session_t session)
495 495
496 if (siz > 0) 496 if (siz > 0)
497 { 497 {
498 _gnutls_hash (session->internals.handshake_mac_handle_sha, data, siz); 498 mhd_gnutls_hash (session->internals.handshake_mac_handle_sha, data, siz);
499 _gnutls_hash (session->internals.handshake_mac_handle_md5, data, siz); 499 mhd_gnutls_hash (session->internals.handshake_mac_handle_md5, data, siz);
500 } 500 }
501 501
502 _gnutls_handshake_buffer_empty (session); 502 mhd_gtls_handshake_buffer_empty (session);
503 503
504 return 0; 504 return 0;
505} 505}
@@ -510,7 +510,7 @@ _gnutls_handshake_hash_pending (gnutls_session_t session)
510 * we send. 510 * we send.
511 */ 511 */
512int 512int
513_gnutls_send_finished (gnutls_session_t session, int again) 513_gnutls_send_finished (mhd_gtls_session_t session, int again)
514{ 514{
515 uint8_t data[36]; 515 uint8_t data[36];
516 int ret; 516 int ret;
@@ -529,7 +529,7 @@ _gnutls_send_finished (gnutls_session_t session, int again)
529 return ret; 529 return ret;
530 } 530 }
531 531
532 if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3) 532 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
533 { 533 {
534 ret = 534 ret =
535 _gnutls_ssl3_finished (session, 535 _gnutls_ssl3_finished (session,
@@ -553,7 +553,7 @@ _gnutls_send_finished (gnutls_session_t session, int again)
553 } 553 }
554 554
555 ret = 555 ret =
556 _gnutls_send_handshake (session, data, data_size, 556 mhd_gtls_send_handshake (session, data, data_size,
557 GNUTLS_HANDSHAKE_FINISHED); 557 GNUTLS_HANDSHAKE_FINISHED);
558 558
559 return ret; 559 return ret;
@@ -563,7 +563,7 @@ _gnutls_send_finished (gnutls_session_t session, int again)
563 * went fine we have negotiated a secure connection 563 * went fine we have negotiated a secure connection
564 */ 564 */
565int 565int
566_gnutls_recv_finished (gnutls_session_t session) 566_gnutls_recv_finished (mhd_gtls_session_t session)
567{ 567{
568 uint8_t data[36], *vrfy; 568 uint8_t data[36], *vrfy;
569 int data_size; 569 int data_size;
@@ -571,7 +571,7 @@ _gnutls_recv_finished (gnutls_session_t session)
571 int vrfysize; 571 int vrfysize;
572 572
573 ret = 573 ret =
574 _gnutls_recv_handshake (session, &vrfy, &vrfysize, 574 mhd_gtls_recv_handshake (session, &vrfy, &vrfysize,
575 GNUTLS_HANDSHAKE_FINISHED, MANDATORY_PACKET); 575 GNUTLS_HANDSHAKE_FINISHED, MANDATORY_PACKET);
576 if (ret < 0) 576 if (ret < 0)
577 { 577 {
@@ -581,7 +581,7 @@ _gnutls_recv_finished (gnutls_session_t session)
581 } 581 }
582 582
583 583
584 if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3) 584 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
585 { 585 {
586 data_size = 36; 586 data_size = 36;
587 } 587 }
@@ -597,7 +597,7 @@ _gnutls_recv_finished (gnutls_session_t session)
597 return GNUTLS_E_ERROR_IN_FINISHED_PACKET; 597 return GNUTLS_E_ERROR_IN_FINISHED_PACKET;
598 } 598 }
599 599
600 if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3) 600 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
601 { 601 {
602 ret = 602 ret =
603 _gnutls_ssl3_finished (session, 603 _gnutls_ssl3_finished (session,
@@ -650,11 +650,11 @@ _gnutls_server_find_pk_algos_in_ciphersuites (const opaque *
650 for (j = 0; j < datalen; j += 2) 650 for (j = 0; j < datalen; j += 2)
651 { 651 {
652 memcpy (&cs.suite, &data[j], 2); 652 memcpy (&cs.suite, &data[j], 2);
653 kx = _gnutls_cipher_suite_get_kx_algo (&cs); 653 kx = mhd_gtls_cipher_suite_get_kx_algo (&cs);
654 654
655 if (_gnutls_map_kx_get_cred (kx, 1) == MHD_GNUTLS_CRD_CERTIFICATE) 655 if (mhd_gtls_map_kx_get_cred (kx, 1) == MHD_GNUTLS_CRD_CERTIFICATE)
656 { 656 {
657 algo = _gnutls_map_pk_get_pk (kx); 657 algo = mhd_gtls_map_pk_get_pk (kx);
658 658
659 if (algo != prev_algo && prev_algo != 0) 659 if (algo != prev_algo && prev_algo != 0)
660 return GNUTLS_PK_ANY; 660 return GNUTLS_PK_ANY;
@@ -670,7 +670,7 @@ _gnutls_server_find_pk_algos_in_ciphersuites (const opaque *
670 * it adds the suite to the session and performs some checks. 670 * it adds the suite to the session and performs some checks.
671 */ 671 */
672int 672int
673_gnutls_server_select_suite (gnutls_session_t session, opaque * data, 673mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
674 int datalen) 674 int datalen)
675{ 675{
676 int x, i, j; 676 int x, i, j;
@@ -682,7 +682,7 @@ _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
682 682
683 pk_algo = _gnutls_server_find_pk_algos_in_ciphersuites (data, datalen); 683 pk_algo = _gnutls_server_find_pk_algos_in_ciphersuites (data, datalen);
684 684
685 x = _gnutls_supported_ciphersuites (session, &ciphers); 685 x = mhd_gtls_supported_ciphersuites (session, &ciphers);
686 if (x < 0) 686 if (x < 0)
687 { /* the case x==0 is handled within the function. */ 687 { /* the case x==0 is handled within the function. */
688 gnutls_assert (); 688 gnutls_assert ();
@@ -693,7 +693,7 @@ _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
693 * the certificate requested, or to the 693 * the certificate requested, or to the
694 * authentication requested (e.g. SRP). 694 * authentication requested (e.g. SRP).
695 */ 695 */
696 x = _gnutls_remove_unwanted_ciphersuites (session, &ciphers, x, pk_algo); 696 x = mhd_gtls_remove_unwanted_ciphersuites (session, &ciphers, x, pk_algo);
697 if (x <= 0) 697 if (x <= 0)
698 { 698 {
699 gnutls_assert (); 699 gnutls_assert ();
@@ -719,12 +719,12 @@ _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
719 for (j = 0; j < datalen; j += 2) 719 for (j = 0; j < datalen; j += 2)
720 { 720 {
721 memcpy (&cs.suite, &data[j], 2); 721 memcpy (&cs.suite, &data[j], 2);
722 _gnutls_handshake_log ("\t%s\n", _gnutls_cipher_suite_get_name (&cs)); 722 _gnutls_handshake_log ("\t%s\n", mhd_gtls_cipher_suite_get_name (&cs));
723 } 723 }
724 _gnutls_handshake_log ("HSK[%x]: Supported cipher suites: \n", session); 724 _gnutls_handshake_log ("HSK[%x]: Supported cipher suites: \n", session);
725 for (j = 0; j < x; j++) 725 for (j = 0; j < x; j++)
726 _gnutls_handshake_log ("\t%s\n", 726 _gnutls_handshake_log ("\t%s\n",
727 _gnutls_cipher_suite_get_name (&ciphers[j])); 727 mhd_gtls_cipher_suite_get_name (&ciphers[j]));
728#endif 728#endif
729 memset (session->security_parameters.current_cipher_suite.suite, '\0', 2); 729 memset (session->security_parameters.current_cipher_suite.suite, '\0', 2);
730 730
@@ -740,7 +740,7 @@ _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
740 740
741 _gnutls_handshake_log 741 _gnutls_handshake_log
742 ("HSK[%x]: Selected cipher suite: %s\n", session, 742 ("HSK[%x]: Selected cipher suite: %s\n", session,
743 _gnutls_cipher_suite_get_name (&cs)); 743 mhd_gtls_cipher_suite_get_name (&cs));
744 memcpy (session->security_parameters.current_cipher_suite. 744 memcpy (session->security_parameters.current_cipher_suite.
745 suite, ciphers[i].suite, 2); 745 suite, ciphers[i].suite, 2);
746 retval = 0; 746 retval = 0;
@@ -760,9 +760,9 @@ finish:
760 760
761 /* check if the credentials (username, public key etc.) are ok 761 /* check if the credentials (username, public key etc.) are ok
762 */ 762 */
763 if (_gnutls_get_kx_cred 763 if (mhd_gtls_get_kx_cred
764 (session, 764 (session,
765 _gnutls_cipher_suite_get_kx_algo (&session->security_parameters. 765 mhd_gtls_cipher_suite_get_kx_algo (&session->security_parameters.
766 current_cipher_suite), 766 current_cipher_suite),
767 &err) == NULL && err != 0) 767 &err) == NULL && err != 0)
768 { 768 {
@@ -771,12 +771,12 @@ finish:
771 } 771 }
772 772
773 773
774 /* set the mod_auth_st to the appropriate struct 774 /* set the mhd_gtls_mod_auth_st to the appropriate struct
775 * according to the KX algorithm. This is needed since all the 775 * according to the KX algorithm. This is needed since all the
776 * handshake functions are read from there; 776 * handshake functions are read from there;
777 */ 777 */
778 session->internals.auth_struct = 778 session->internals.auth_struct =
779 _gnutls_kx_auth_struct (_gnutls_cipher_suite_get_kx_algo 779 mhd_gtls_kx_auth_struct (mhd_gtls_cipher_suite_get_kx_algo
780 (&session->security_parameters. 780 (&session->security_parameters.
781 current_cipher_suite)); 781 current_cipher_suite));
782 if (session->internals.auth_struct == NULL) 782 if (session->internals.auth_struct == NULL)
@@ -797,13 +797,13 @@ finish:
797/* This selects the best supported compression method from the ones provided 797/* This selects the best supported compression method from the ones provided
798 */ 798 */
799int 799int
800_gnutls_server_select_comp_method (gnutls_session_t session, 800_gnutls_server_select_comp_method (mhd_gtls_session_t session,
801 opaque * data, int datalen) 801 opaque * data, int datalen)
802{ 802{
803 int x, i, j; 803 int x, i, j;
804 uint8_t *comps; 804 uint8_t *comps;
805 805
806 x = _gnutls_supported_compression_methods (session, &comps); 806 x = mhd_gtls_supported_compression_methods (session, &comps);
807 if (x < 0) 807 if (x < 0)
808 { 808 {
809 gnutls_assert (); 809 gnutls_assert ();
@@ -820,14 +820,14 @@ _gnutls_server_select_comp_method (gnutls_session_t session,
820 if (comps[i] == data[j]) 820 if (comps[i] == data[j])
821 { 821 {
822 gnutls_compression_method_t method = 822 gnutls_compression_method_t method =
823 _gnutls_compression_get_id (comps[i]); 823 mhd_gtls_compression_get_id (comps[i]);
824 824
825 session->internals.compression_method = method; 825 session->internals.compression_method = method;
826 gnutls_free (comps); 826 gnutls_free (comps);
827 827
828 _gnutls_handshake_log 828 _gnutls_handshake_log
829 ("HSK[%x]: Selected Compression Method: %s\n", session, 829 ("HSK[%x]: Selected Compression Method: %s\n", session,
830 gnutls_compression_get_name (session->internals. 830 MHD_gnutls_compression_get_name (session->internals.
831 compression_method)); 831 compression_method));
832 832
833 833
@@ -851,7 +851,7 @@ _gnutls_server_select_comp_method (gnutls_session_t session,
851 * (until it returns ok), with NULL parameters. 851 * (until it returns ok), with NULL parameters.
852 */ 852 */
853int 853int
854_gnutls_send_empty_handshake (gnutls_session_t session, 854_gnutls_send_empty_handshake (mhd_gtls_session_t session,
855 gnutls_handshake_description_t type, int again) 855 gnutls_handshake_description_t type, int again)
856{ 856{
857 opaque data = 0; 857 opaque data = 0;
@@ -862,13 +862,13 @@ _gnutls_send_empty_handshake (gnutls_session_t session,
862 else 862 else
863 ptr = NULL; 863 ptr = NULL;
864 864
865 return _gnutls_send_handshake (session, ptr, 0, type); 865 return mhd_gtls_send_handshake (session, ptr, 0, type);
866} 866}
867 867
868 868
869/* This function will hash the handshake message we sent. */ 869/* This function will hash the handshake message we sent. */
870static int 870static int
871_gnutls_handshake_hash_add_sent (gnutls_session_t session, 871_gnutls_handshake_hash_add_sent (mhd_gtls_session_t session,
872 gnutls_handshake_description_t type, 872 gnutls_handshake_description_t type,
873 opaque * dataptr, uint32_t datalen) 873 opaque * dataptr, uint32_t datalen)
874{ 874{
@@ -882,9 +882,9 @@ _gnutls_handshake_hash_add_sent (gnutls_session_t session,
882 882
883 if (type != GNUTLS_HANDSHAKE_HELLO_REQUEST) 883 if (type != GNUTLS_HANDSHAKE_HELLO_REQUEST)
884 { 884 {
885 _gnutls_hash (session->internals.handshake_mac_handle_sha, dataptr, 885 mhd_gnutls_hash (session->internals.handshake_mac_handle_sha, dataptr,
886 datalen); 886 datalen);
887 _gnutls_hash (session->internals.handshake_mac_handle_md5, dataptr, 887 mhd_gnutls_hash (session->internals.handshake_mac_handle_md5, dataptr,
888 datalen); 888 datalen);
889 } 889 }
890 890
@@ -893,12 +893,12 @@ _gnutls_handshake_hash_add_sent (gnutls_session_t session,
893 893
894 894
895/* This function sends a handshake message of type 'type' containing the 895/* This function sends a handshake message of type 'type' containing the
896 * data specified here. If the previous _gnutls_send_handshake() returned 896 * data specified here. If the previous mhd_gtls_send_handshake() returned
897 * GNUTLS_E_AGAIN or GNUTLS_E_INTERRUPTED, then it must be called again 897 * GNUTLS_E_AGAIN or GNUTLS_E_INTERRUPTED, then it must be called again
898 * (until it returns ok), with NULL parameters. 898 * (until it returns ok), with NULL parameters.
899 */ 899 */
900int 900int
901_gnutls_send_handshake (gnutls_session_t session, void *i_data, 901mhd_gtls_send_handshake (mhd_gtls_session_t session, void *i_data,
902 uint32_t i_datasize, 902 uint32_t i_datasize,
903 gnutls_handshake_description_t type) 903 gnutls_handshake_description_t type)
904{ 904{
@@ -912,7 +912,7 @@ _gnutls_send_handshake (gnutls_session_t session, void *i_data,
912 /* we are resuming a previously interrupted 912 /* we are resuming a previously interrupted
913 * send. 913 * send.
914 */ 914 */
915 ret = _gnutls_handshake_io_write_flush (session); 915 ret = mhd_gtls_handshake_io_write_flush (session);
916 return ret; 916 return ret;
917 917
918 } 918 }
@@ -933,7 +933,7 @@ _gnutls_send_handshake (gnutls_session_t session, void *i_data,
933 } 933 }
934 934
935 data[pos++] = (uint8_t) type; 935 data[pos++] = (uint8_t) type;
936 _gnutls_write_uint24 (i_datasize, &data[pos]); 936 mhd_gtls_write_uint24 (i_datasize, &data[pos]);
937 pos += 3; 937 pos += 3;
938 938
939 if (i_datasize > 0) 939 if (i_datasize > 0)
@@ -953,7 +953,7 @@ _gnutls_send_handshake (gnutls_session_t session, void *i_data,
953 session->internals.last_handshake_out = type; 953 session->internals.last_handshake_out = type;
954 954
955 ret = 955 ret =
956 _gnutls_handshake_io_send_int (session, GNUTLS_HANDSHAKE, type, 956 mhd_gtls_handshake_io_send_int (session, GNUTLS_HANDSHAKE, type,
957 data, datasize); 957 data, datasize);
958 958
959 _gnutls_handshake_log ("HSK[%x]: %s was sent [%ld bytes]\n", 959 _gnutls_handshake_log ("HSK[%x]: %s was sent [%ld bytes]\n",
@@ -972,7 +972,7 @@ _gnutls_send_handshake (gnutls_session_t session, void *i_data,
972 */ 972 */
973#define SSL2_HEADERS 1 973#define SSL2_HEADERS 1
974static int 974static int
975_gnutls_recv_handshake_header (gnutls_session_t session, 975_gnutls_recv_handshake_header (mhd_gtls_session_t session,
976 gnutls_handshake_description_t type, 976 gnutls_handshake_description_t type,
977 gnutls_handshake_description_t * recv_type) 977 gnutls_handshake_description_t * recv_type)
978{ 978{
@@ -1006,7 +1006,7 @@ _gnutls_recv_handshake_header (gnutls_session_t session,
1006 if (session->internals.handshake_header_buffer.header_size < SSL2_HEADERS) 1006 if (session->internals.handshake_header_buffer.header_size < SSL2_HEADERS)
1007 { 1007 {
1008 ret = 1008 ret =
1009 _gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, 1009 mhd_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
1010 type, dataptr, SSL2_HEADERS); 1010 type, dataptr, SSL2_HEADERS);
1011 1011
1012 if (ret < 0) 1012 if (ret < 0)
@@ -1029,7 +1029,7 @@ _gnutls_recv_handshake_header (gnutls_session_t session,
1029 || type != GNUTLS_HANDSHAKE_CLIENT_HELLO) 1029 || type != GNUTLS_HANDSHAKE_CLIENT_HELLO)
1030 { 1030 {
1031 ret = 1031 ret =
1032 _gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, 1032 mhd_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
1033 type, 1033 type,
1034 &dataptr[session-> 1034 &dataptr[session->
1035 internals. 1035 internals.
@@ -1055,7 +1055,7 @@ _gnutls_recv_handshake_header (gnutls_session_t session,
1055 /* we do not use DECR_LEN because we know 1055 /* we do not use DECR_LEN because we know
1056 * that the packet has enough data. 1056 * that the packet has enough data.
1057 */ 1057 */
1058 length32 = _gnutls_read_uint24 (&dataptr[1]); 1058 length32 = mhd_gtls_read_uint24 (&dataptr[1]);
1059 handshake_header_size = HANDSHAKE_HEADER_SIZE; 1059 handshake_header_size = HANDSHAKE_HEADER_SIZE;
1060 1060
1061 _gnutls_handshake_log ("HSK[%x]: %s was received [%ld bytes]\n", 1061 _gnutls_handshake_log ("HSK[%x]: %s was received [%ld bytes]\n",
@@ -1105,7 +1105,7 @@ _gnutls_recv_handshake_header (gnutls_session_t session,
1105 * handshake data. 1105 * handshake data.
1106 */ 1106 */
1107static int 1107static int
1108_gnutls_handshake_hash_add_recvd (gnutls_session_t session, 1108_gnutls_handshake_hash_add_recvd (mhd_gtls_session_t session,
1109 gnutls_handshake_description_t recv_type, 1109 gnutls_handshake_description_t recv_type,
1110 opaque * header, uint16_t header_size, 1110 opaque * header, uint16_t header_size,
1111 opaque * dataptr, uint32_t datalen) 1111 opaque * dataptr, uint32_t datalen)
@@ -1127,7 +1127,7 @@ _gnutls_handshake_hash_add_recvd (gnutls_session_t session,
1127 { 1127 {
1128 1128
1129 if ((ret = 1129 if ((ret =
1130 _gnutls_handshake_buffer_put (session, header, header_size)) < 0) 1130 mhd_gtls_handshake_buffer_put (session, header, header_size)) < 0)
1131 { 1131 {
1132 gnutls_assert (); 1132 gnutls_assert ();
1133 return ret; 1133 return ret;
@@ -1136,7 +1136,7 @@ _gnutls_handshake_hash_add_recvd (gnutls_session_t session,
1136 if (datalen > 0) 1136 if (datalen > 0)
1137 { 1137 {
1138 if ((ret = 1138 if ((ret =
1139 _gnutls_handshake_buffer_put (session, dataptr, datalen)) < 0) 1139 mhd_gtls_handshake_buffer_put (session, dataptr, datalen)) < 0)
1140 { 1140 {
1141 gnutls_assert (); 1141 gnutls_assert ();
1142 return ret; 1142 return ret;
@@ -1151,10 +1151,10 @@ _gnutls_handshake_hash_add_recvd (gnutls_session_t session,
1151/* This function will receive handshake messages of the given types, 1151/* This function will receive handshake messages of the given types,
1152 * and will pass the message to the right place in order to be processed. 1152 * and will pass the message to the right place in order to be processed.
1153 * E.g. for the SERVER_HELLO message (if it is expected), it will be 1153 * E.g. for the SERVER_HELLO message (if it is expected), it will be
1154 * passed to _gnutls_recv_hello(). 1154 * passed to mhd_gtls_recv_hello().
1155 */ 1155 */
1156int 1156int
1157_gnutls_recv_handshake (gnutls_session_t session, uint8_t ** data, 1157mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
1158 int *datalen, gnutls_handshake_description_t type, 1158 int *datalen, gnutls_handshake_description_t type,
1159 Optional optional) 1159 Optional optional)
1160{ 1160{
@@ -1204,7 +1204,7 @@ _gnutls_recv_handshake (gnutls_session_t session, uint8_t ** data,
1204 if (length32 > 0) 1204 if (length32 > 0)
1205 { 1205 {
1206 ret = 1206 ret =
1207 _gnutls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, 1207 mhd_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
1208 type, dataptr, length32); 1208 type, dataptr, length32);
1209 if (ret <= 0) 1209 if (ret <= 0)
1210 { 1210 {
@@ -1241,7 +1241,7 @@ _gnutls_recv_handshake (gnutls_session_t session, uint8_t ** data,
1241 { 1241 {
1242 case GNUTLS_HANDSHAKE_CLIENT_HELLO: 1242 case GNUTLS_HANDSHAKE_CLIENT_HELLO:
1243 case GNUTLS_HANDSHAKE_SERVER_HELLO: 1243 case GNUTLS_HANDSHAKE_SERVER_HELLO:
1244 ret = _gnutls_recv_hello (session, dataptr, length32); 1244 ret = mhd_gtls_recv_hello (session, dataptr, length32);
1245 /* dataptr is freed because the caller does not 1245 /* dataptr is freed because the caller does not
1246 * need it */ 1246 * need it */
1247 gnutls_free (dataptr); 1247 gnutls_free (dataptr);
@@ -1278,7 +1278,7 @@ _gnutls_recv_handshake (gnutls_session_t session, uint8_t ** data,
1278 * to the session; 1278 * to the session;
1279 */ 1279 */
1280static int 1280static int
1281_gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2]) 1281_gnutls_client_set_ciphersuite (mhd_gtls_session_t session, opaque suite[2])
1282{ 1282{
1283 uint8_t z; 1283 uint8_t z;
1284 cipher_suite_st *cipher_suites; 1284 cipher_suite_st *cipher_suites;
@@ -1286,7 +1286,7 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
1286 int i, err; 1286 int i, err;
1287 1287
1288 z = 1; 1288 z = 1;
1289 cipher_suite_num = _gnutls_supported_ciphersuites (session, &cipher_suites); 1289 cipher_suite_num = mhd_gtls_supported_ciphersuites (session, &cipher_suites);
1290 if (cipher_suite_num < 0) 1290 if (cipher_suite_num < 0)
1291 { 1291 {
1292 gnutls_assert (); 1292 gnutls_assert ();
@@ -1313,7 +1313,7 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
1313 memcpy (session->security_parameters.current_cipher_suite.suite, suite, 2); 1313 memcpy (session->security_parameters.current_cipher_suite.suite, suite, 2);
1314 1314
1315 _gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session, 1315 _gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session,
1316 _gnutls_cipher_suite_get_name (&session-> 1316 mhd_gtls_cipher_suite_get_name (&session->
1317 security_parameters. 1317 security_parameters.
1318 current_cipher_suite)); 1318 current_cipher_suite));
1319 1319
@@ -1321,8 +1321,8 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
1321 /* check if the credentials (username, public key etc.) are ok. 1321 /* check if the credentials (username, public key etc.) are ok.
1322 * Actually checks if they exist. 1322 * Actually checks if they exist.
1323 */ 1323 */
1324 if (_gnutls_get_kx_cred 1324 if (mhd_gtls_get_kx_cred
1325 (session, _gnutls_cipher_suite_get_kx_algo (&session-> 1325 (session, mhd_gtls_cipher_suite_get_kx_algo (&session->
1326 security_parameters. 1326 security_parameters.
1327 current_cipher_suite), 1327 current_cipher_suite),
1328 &err) == NULL && err != 0) 1328 &err) == NULL && err != 0)
@@ -1332,12 +1332,12 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
1332 } 1332 }
1333 1333
1334 1334
1335 /* set the mod_auth_st to the appropriate struct 1335 /* set the mhd_gtls_mod_auth_st to the appropriate struct
1336 * according to the KX algorithm. This is needed since all the 1336 * according to the KX algorithm. This is needed since all the
1337 * handshake functions are read from there; 1337 * handshake functions are read from there;
1338 */ 1338 */
1339 session->internals.auth_struct = 1339 session->internals.auth_struct =
1340 _gnutls_kx_auth_struct (_gnutls_cipher_suite_get_kx_algo 1340 mhd_gtls_kx_auth_struct (mhd_gtls_cipher_suite_get_kx_algo
1341 (&session->security_parameters. 1341 (&session->security_parameters.
1342 current_cipher_suite)); 1342 current_cipher_suite));
1343 1343
@@ -1358,13 +1358,13 @@ _gnutls_client_set_ciphersuite (gnutls_session_t session, opaque suite[2])
1358/* This function sets the given comp method to the session. 1358/* This function sets the given comp method to the session.
1359 */ 1359 */
1360static int 1360static int
1361_gnutls_client_set_comp_method (gnutls_session_t session, opaque comp_method) 1361_gnutls_client_set_comp_method (mhd_gtls_session_t session, opaque comp_method)
1362{ 1362{
1363 int comp_methods_num; 1363 int comp_methods_num;
1364 uint8_t *compression_methods; 1364 uint8_t *compression_methods;
1365 int i; 1365 int i;
1366 1366
1367 comp_methods_num = _gnutls_supported_compression_methods (session, 1367 comp_methods_num = mhd_gtls_supported_compression_methods (session,
1368 &compression_methods); 1368 &compression_methods);
1369 if (comp_methods_num < 0) 1369 if (comp_methods_num < 0)
1370 { 1370 {
@@ -1390,7 +1390,7 @@ _gnutls_client_set_comp_method (gnutls_session_t session, opaque comp_method)
1390 } 1390 }
1391 1391
1392 session->internals.compression_method = 1392 session->internals.compression_method =
1393 _gnutls_compression_get_id (comp_method); 1393 mhd_gtls_compression_get_id (comp_method);
1394 1394
1395 1395
1396 return 0; 1396 return 0;
@@ -1401,7 +1401,7 @@ _gnutls_client_set_comp_method (gnutls_session_t session, opaque comp_method)
1401 * hello. 1401 * hello.
1402 */ 1402 */
1403static int 1403static int
1404_gnutls_client_check_if_resuming (gnutls_session_t session, 1404_gnutls_client_check_if_resuming (mhd_gtls_session_t session,
1405 opaque * session_id, int session_id_len) 1405 opaque * session_id, int session_id_len)
1406{ 1406{
1407 opaque buf[2 * TLS_MAX_SESSION_ID_SIZE + 1]; 1407 opaque buf[2 * TLS_MAX_SESSION_ID_SIZE + 1];
@@ -1409,7 +1409,7 @@ _gnutls_client_check_if_resuming (gnutls_session_t session,
1409 _gnutls_handshake_log ("HSK[%x]: SessionID length: %d\n", session, 1409 _gnutls_handshake_log ("HSK[%x]: SessionID length: %d\n", session,
1410 session_id_len); 1410 session_id_len);
1411 _gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session, 1411 _gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session,
1412 _gnutls_bin2hex (session_id, session_id_len, buf, 1412 mhd_gtls_bin2hex (session_id, session_id_len, buf,
1413 sizeof (buf))); 1413 sizeof (buf)));
1414 1414
1415 if (session_id_len > 0 && 1415 if (session_id_len > 0 &&
@@ -1448,7 +1448,7 @@ _gnutls_client_check_if_resuming (gnutls_session_t session,
1448 * session. 1448 * session.
1449 */ 1449 */
1450static int 1450static int
1451_gnutls_read_server_hello (gnutls_session_t session, 1451_gnutls_read_server_hello (mhd_gtls_session_t session,
1452 opaque * data, int datalen) 1452 opaque * data, int datalen)
1453{ 1453{
1454 uint8_t session_id_len = 0; 1454 uint8_t session_id_len = 0;
@@ -1467,21 +1467,21 @@ _gnutls_read_server_hello (gnutls_session_t session,
1467 session, data[pos], data[pos + 1]); 1467 session, data[pos], data[pos + 1]);
1468 1468
1469 DECR_LEN (len, 2); 1469 DECR_LEN (len, 2);
1470 version = _gnutls_version_get (data[pos], data[pos + 1]); 1470 version = mhd_gtls_version_get (data[pos], data[pos + 1]);
1471 if (_gnutls_version_is_supported (session, version) == 0) 1471 if (mhd_gtls_version_is_supported (session, version) == 0)
1472 { 1472 {
1473 gnutls_assert (); 1473 gnutls_assert ();
1474 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET; 1474 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;
1475 } 1475 }
1476 else 1476 else
1477 { 1477 {
1478 _gnutls_set_current_version (session, version); 1478 mhd_gtls_set_current_version (session, version);
1479 } 1479 }
1480 1480
1481 pos += 2; 1481 pos += 2;
1482 1482
1483 DECR_LEN (len, TLS_RANDOM_SIZE); 1483 DECR_LEN (len, TLS_RANDOM_SIZE);
1484 _gnutls_set_server_random (session, &data[pos]); 1484 mhd_gtls_set_server_random (session, &data[pos]);
1485 pos += TLS_RANDOM_SIZE; 1485 pos += TLS_RANDOM_SIZE;
1486 1486
1487 1487
@@ -1536,7 +1536,7 @@ _gnutls_read_server_hello (gnutls_session_t session,
1536 */ 1536 */
1537 if (version >= MHD_GNUTLS_TLS1_0) 1537 if (version >= MHD_GNUTLS_TLS1_0)
1538 { 1538 {
1539 ret = _gnutls_parse_extensions (session, EXTENSION_ANY, &data[pos], len); /* len is the rest of the parsed length */ 1539 ret = mhd_gtls_parse_extensions (session, EXTENSION_ANY, &data[pos], len); /* len is the rest of the parsed length */
1540 if (ret < 0) 1540 if (ret < 0)
1541 { 1541 {
1542 gnutls_assert (); 1542 gnutls_assert ();
@@ -1551,7 +1551,7 @@ _gnutls_read_server_hello (gnutls_session_t session,
1551 * Needed in client hello messages. Returns the new data length. 1551 * Needed in client hello messages. Returns the new data length.
1552 */ 1552 */
1553static int 1553static int
1554_gnutls_copy_ciphersuites (gnutls_session_t session, 1554_gnutls_copy_ciphersuites (mhd_gtls_session_t session,
1555 opaque * ret_data, size_t ret_data_size) 1555 opaque * ret_data, size_t ret_data_size)
1556{ 1556{
1557 int ret, i; 1557 int ret, i;
@@ -1559,7 +1559,7 @@ _gnutls_copy_ciphersuites (gnutls_session_t session,
1559 uint16_t cipher_num; 1559 uint16_t cipher_num;
1560 int datalen, pos; 1560 int datalen, pos;
1561 1561
1562 ret = _gnutls_supported_ciphersuites_sorted (session, &cipher_suites); 1562 ret = mhd_gtls_supported_ciphersuites_sorted (session, &cipher_suites);
1563 if (ret < 0) 1563 if (ret < 0)
1564 { 1564 {
1565 gnutls_assert (); 1565 gnutls_assert ();
@@ -1571,7 +1571,7 @@ _gnutls_copy_ciphersuites (gnutls_session_t session,
1571 * authentication requested (eg SRP). 1571 * authentication requested (eg SRP).
1572 */ 1572 */
1573 ret = 1573 ret =
1574 _gnutls_remove_unwanted_ciphersuites (session, &cipher_suites, ret, -1); 1574 mhd_gtls_remove_unwanted_ciphersuites (session, &cipher_suites, ret, -1);
1575 if (ret < 0) 1575 if (ret < 0)
1576 { 1576 {
1577 gnutls_assert (); 1577 gnutls_assert ();
@@ -1602,7 +1602,7 @@ _gnutls_copy_ciphersuites (gnutls_session_t session,
1602 return GNUTLS_E_INTERNAL_ERROR; 1602 return GNUTLS_E_INTERNAL_ERROR;
1603 } 1603 }
1604 1604
1605 _gnutls_write_uint16 (cipher_num, ret_data); 1605 mhd_gtls_write_uint16 (cipher_num, ret_data);
1606 pos += 2; 1606 pos += 2;
1607 1607
1608 for (i = 0; i < (cipher_num / 2); i++) 1608 for (i = 0; i < (cipher_num / 2); i++)
@@ -1620,14 +1620,14 @@ _gnutls_copy_ciphersuites (gnutls_session_t session,
1620 * Needed in hello messages. Returns the new data length. 1620 * Needed in hello messages. Returns the new data length.
1621 */ 1621 */
1622static int 1622static int
1623_gnutls_copy_comp_methods (gnutls_session_t session, 1623_gnutls_copy_comp_methods (mhd_gtls_session_t session,
1624 opaque * ret_data, size_t ret_data_size) 1624 opaque * ret_data, size_t ret_data_size)
1625{ 1625{
1626 int ret, i; 1626 int ret, i;
1627 uint8_t *compression_methods, comp_num; 1627 uint8_t *compression_methods, comp_num;
1628 int datalen, pos; 1628 int datalen, pos;
1629 1629
1630 ret = _gnutls_supported_compression_methods (session, &compression_methods); 1630 ret = mhd_gtls_supported_compression_methods (session, &compression_methods);
1631 if (ret < 0) 1631 if (ret < 0)
1632 { 1632 {
1633 gnutls_assert (); 1633 gnutls_assert ();
@@ -1665,7 +1665,7 @@ _gnutls_copy_comp_methods (gnutls_session_t session,
1665/* This function sends the client hello handshake message. 1665/* This function sends the client hello handshake message.
1666 */ 1666 */
1667static int 1667static int
1668_gnutls_send_client_hello (gnutls_session_t session, int again) 1668_gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1669{ 1669{
1670 opaque *data = NULL; 1670 opaque *data = NULL;
1671 int extdatalen; 1671 int extdatalen;
@@ -1703,7 +1703,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1703 * version number to the previously established. 1703 * version number to the previously established.
1704 */ 1704 */
1705 if (SessionID == NULL) 1705 if (SessionID == NULL)
1706 hver = _gnutls_version_max (session); 1706 hver = mhd_gtls_version_max (session);
1707 else 1707 else
1708 { /* we are resuming a session */ 1708 { /* we are resuming a session */
1709 hver = session->internals.resumed_security_parameters.version; 1709 hver = session->internals.resumed_security_parameters.version;
@@ -1716,13 +1716,13 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1716 return GNUTLS_E_INTERNAL_ERROR; 1716 return GNUTLS_E_INTERNAL_ERROR;
1717 } 1717 }
1718 1718
1719 data[pos++] = _gnutls_version_get_major (hver); 1719 data[pos++] = mhd_gtls_version_get_major (hver);
1720 data[pos++] = _gnutls_version_get_minor (hver); 1720 data[pos++] = mhd_gtls_version_get_minor (hver);
1721 1721
1722 /* Set the version we advertized as maximum 1722 /* Set the version we advertized as maximum
1723 * (RSA uses it). 1723 * (RSA uses it).
1724 */ 1724 */
1725 _gnutls_set_adv_version (session, hver); 1725 mhd_gtls_set_adv_version (session, hver);
1726 1726
1727 /* Some old implementations do not interoperate if we send a 1727 /* Some old implementations do not interoperate if we send a
1728 * different version in the record layer. 1728 * different version in the record layer.
@@ -1732,7 +1732,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1732 * handshake packet and ignore the one in the packet's record 1732 * handshake packet and ignore the one in the packet's record
1733 * header. 1733 * header.
1734 */ 1734 */
1735 _gnutls_set_current_version (session, hver); 1735 mhd_gtls_set_current_version (session, hver);
1736 1736
1737 /* In order to know when this session was initiated. 1737 /* In order to know when this session was initiated.
1738 */ 1738 */
@@ -1740,8 +1740,8 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1740 1740
1741 /* Generate random data 1741 /* Generate random data
1742 */ 1742 */
1743 _gnutls_tls_create_random (rnd); 1743 mhd_gtls_tls_create_random (rnd);
1744 _gnutls_set_client_random (session, rnd); 1744 mhd_gtls_set_client_random (session, rnd);
1745 1745
1746 memcpy (&data[pos], rnd, TLS_RANDOM_SIZE); 1746 memcpy (&data[pos], rnd, TLS_RANDOM_SIZE);
1747 pos += TLS_RANDOM_SIZE; 1747 pos += TLS_RANDOM_SIZE;
@@ -1763,7 +1763,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1763 if (extdatalen > 0) 1763 if (extdatalen > 0)
1764 { 1764 {
1765 datalen += extdatalen; 1765 datalen += extdatalen;
1766 data = gnutls_realloc_fast (data, datalen); 1766 data = mhd_gtls_realloc_fast (data, datalen);
1767 if (data == NULL) 1767 if (data == NULL)
1768 { 1768 {
1769 gnutls_assert (); 1769 gnutls_assert ();
@@ -1791,7 +1791,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1791 if (extdatalen > 0) 1791 if (extdatalen > 0)
1792 { 1792 {
1793 datalen += extdatalen; 1793 datalen += extdatalen;
1794 data = gnutls_realloc_fast (data, datalen); 1794 data = mhd_gtls_realloc_fast (data, datalen);
1795 if (data == NULL) 1795 if (data == NULL)
1796 { 1796 {
1797 gnutls_assert (); 1797 gnutls_assert ();
@@ -1816,12 +1816,12 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1816 if (hver >= MHD_GNUTLS_TLS1_0) 1816 if (hver >= MHD_GNUTLS_TLS1_0)
1817 { 1817 {
1818 extdatalen = 1818 extdatalen =
1819 _gnutls_gen_extensions (session, extdata, sizeof (extdata)); 1819 mhd_gtls_gen_extensions (session, extdata, sizeof (extdata));
1820 1820
1821 if (extdatalen > 0) 1821 if (extdatalen > 0)
1822 { 1822 {
1823 datalen += extdatalen; 1823 datalen += extdatalen;
1824 data = gnutls_realloc_fast (data, datalen); 1824 data = mhd_gtls_realloc_fast (data, datalen);
1825 if (data == NULL) 1825 if (data == NULL)
1826 { 1826 {
1827 gnutls_assert (); 1827 gnutls_assert ();
@@ -1840,7 +1840,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1840 } 1840 }
1841 1841
1842 ret = 1842 ret =
1843 _gnutls_send_handshake (session, data, datalen, 1843 mhd_gtls_send_handshake (session, data, datalen,
1844 GNUTLS_HANDSHAKE_CLIENT_HELLO); 1844 GNUTLS_HANDSHAKE_CLIENT_HELLO);
1845 gnutls_free (data); 1845 gnutls_free (data);
1846 1846
@@ -1848,7 +1848,7 @@ _gnutls_send_client_hello (gnutls_session_t session, int again)
1848} 1848}
1849 1849
1850static int 1850static int
1851_gnutls_send_server_hello (gnutls_session_t session, int again) 1851_gnutls_send_server_hello (mhd_gtls_session_t session, int again)
1852{ 1852{
1853 opaque *data = NULL; 1853 opaque *data = NULL;
1854 opaque extdata[MAX_EXT_DATA_LENGTH]; 1854 opaque extdata[MAX_EXT_DATA_LENGTH];
@@ -1867,7 +1867,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
1867 1867
1868#ifdef ENABLE_SRP 1868#ifdef ENABLE_SRP
1869 if (IS_SRP_KX 1869 if (IS_SRP_KX
1870 (_gnutls_cipher_suite_get_kx_algo 1870 (mhd_gtls_cipher_suite_get_kx_algo
1871 (&session->security_parameters.current_cipher_suite))) 1871 (&session->security_parameters.current_cipher_suite)))
1872 { 1872 {
1873 /* While resuming we cannot check the username extension since it is 1873 /* While resuming we cannot check the username extension since it is
@@ -1882,7 +1882,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
1882 * alert and abort. 1882 * alert and abort.
1883 */ 1883 */
1884 gnutls_assert (); 1884 gnutls_assert ();
1885 ret = gnutls_alert_send (session, GNUTLS_AL_FATAL, 1885 ret = MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL,
1886 GNUTLS_A_UNKNOWN_PSK_IDENTITY); 1886 GNUTLS_A_UNKNOWN_PSK_IDENTITY);
1887 if (ret < 0) 1887 if (ret < 0)
1888 { 1888 {
@@ -1899,7 +1899,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
1899 { 1899 {
1900 datalen = 2 + session_id_len + 1 + TLS_RANDOM_SIZE + 3; 1900 datalen = 2 + session_id_len + 1 + TLS_RANDOM_SIZE + 3;
1901 extdatalen = 1901 extdatalen =
1902 _gnutls_gen_extensions (session, extdata, sizeof (extdata)); 1902 mhd_gtls_gen_extensions (session, extdata, sizeof (extdata));
1903 1903
1904 if (extdatalen < 0) 1904 if (extdatalen < 0)
1905 { 1905 {
@@ -1915,9 +1915,9 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
1915 } 1915 }
1916 1916
1917 data[pos++] = 1917 data[pos++] =
1918 _gnutls_version_get_major (session->security_parameters.version); 1918 mhd_gtls_version_get_major (session->security_parameters.version);
1919 data[pos++] = 1919 data[pos++] =
1920 _gnutls_version_get_minor (session->security_parameters.version); 1920 mhd_gtls_version_get_minor (session->security_parameters.version);
1921 1921
1922 memcpy (&data[pos], 1922 memcpy (&data[pos],
1923 session->security_parameters.server_random, TLS_RANDOM_SIZE); 1923 session->security_parameters.server_random, TLS_RANDOM_SIZE);
@@ -1931,7 +1931,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
1931 pos += session_id_len; 1931 pos += session_id_len;
1932 1932
1933 _gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session, 1933 _gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session,
1934 _gnutls_bin2hex (SessionID, session_id_len, 1934 mhd_gtls_bin2hex (SessionID, session_id_len,
1935 buf, sizeof (buf))); 1935 buf, sizeof (buf)));
1936 1936
1937 memcpy (&data[pos], 1937 memcpy (&data[pos],
@@ -1939,7 +1939,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
1939 pos += 2; 1939 pos += 2;
1940 1940
1941 comp = 1941 comp =
1942 (uint8_t) _gnutls_compression_get_num (session-> 1942 (uint8_t) mhd_gtls_compression_get_num (session->
1943 internals.compression_method); 1943 internals.compression_method);
1944 data[pos++] = comp; 1944 data[pos++] = comp;
1945 1945
@@ -1953,7 +1953,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
1953 } 1953 }
1954 1954
1955 ret = 1955 ret =
1956 _gnutls_send_handshake (session, data, datalen, 1956 mhd_gtls_send_handshake (session, data, datalen,
1957 GNUTLS_HANDSHAKE_SERVER_HELLO); 1957 GNUTLS_HANDSHAKE_SERVER_HELLO);
1958 gnutls_afree (data); 1958 gnutls_afree (data);
1959 1959
@@ -1961,7 +1961,7 @@ _gnutls_send_server_hello (gnutls_session_t session, int again)
1961} 1961}
1962 1962
1963int 1963int
1964_gnutls_send_hello (gnutls_session_t session, int again) 1964mhd_gtls_send_hello (mhd_gtls_session_t session, int again)
1965{ 1965{
1966 int ret; 1966 int ret;
1967 1967
@@ -1983,7 +1983,7 @@ _gnutls_send_hello (gnutls_session_t session, int again)
1983 * and internals.compression_method. 1983 * and internals.compression_method.
1984 */ 1984 */
1985int 1985int
1986_gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen) 1986mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen)
1987{ 1987{
1988 int ret; 1988 int ret;
1989 1989
@@ -2010,7 +2010,7 @@ _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
2010 return ret; 2010 return ret;
2011} 2011}
2012 2012
2013/* The packets in gnutls_handshake (it's more broad than original TLS handshake) 2013/* The packets in MHD_gnutls_handshake (it's more broad than original TLS handshake)
2014 * 2014 *
2015 * Client Server 2015 * Client Server
2016 * 2016 *
@@ -2034,8 +2034,8 @@ _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
2034 */ 2034 */
2035 2035
2036/** 2036/**
2037 * gnutls_rehandshake - This function will renegotiate security parameters 2037 * MHD_gnutls_rehandshake - This function will renegotiate security parameters
2038 * @session: is a #gnutls_session_t structure. 2038 * @session: is a #mhd_gtls_session_t structure.
2039 * 2039 *
2040 * This function will renegotiate security parameters with the 2040 * This function will renegotiate security parameters with the
2041 * client. This should only be called in case of a server. 2041 * client. This should only be called in case of a server.
@@ -2044,7 +2044,7 @@ _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
2044 * parameters (perform a handshake). 2044 * parameters (perform a handshake).
2045 * 2045 *
2046 * If this function succeeds (returns 0), you must call the 2046 * If this function succeeds (returns 0), you must call the
2047 * gnutls_handshake() function in order to negotiate the new 2047 * MHD_gnutls_handshake() function in order to negotiate the new
2048 * parameters. 2048 * parameters.
2049 * 2049 *
2050 * If the client does not wish to renegotiate parameters he will 2050 * If the client does not wish to renegotiate parameters he will
@@ -2057,7 +2057,7 @@ _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen)
2057 * 2057 *
2058 **/ 2058 **/
2059int 2059int
2060gnutls_rehandshake (gnutls_session_t session) 2060MHD_gnutls_rehandshake (mhd_gtls_session_t session)
2061{ 2061{
2062 int ret; 2062 int ret;
2063 2063
@@ -2081,7 +2081,7 @@ gnutls_rehandshake (gnutls_session_t session)
2081} 2081}
2082 2082
2083inline static int 2083inline static int
2084_gnutls_abort_handshake (gnutls_session_t session, int ret) 2084_gnutls_abort_handshake (mhd_gtls_session_t session, int ret)
2085{ 2085{
2086 if (((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) && 2086 if (((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) &&
2087 (gnutls_alert_get (session) == GNUTLS_A_NO_RENEGOTIATION)) 2087 (gnutls_alert_get (session) == GNUTLS_A_NO_RENEGOTIATION))
@@ -2097,13 +2097,13 @@ _gnutls_abort_handshake (gnutls_session_t session, int ret)
2097 * required for finished messages. 2097 * required for finished messages.
2098 */ 2098 */
2099inline static int 2099inline static int
2100_gnutls_handshake_hash_init (gnutls_session_t session) 2100_gnutls_handshake_hash_init (mhd_gtls_session_t session)
2101{ 2101{
2102 2102
2103 if (session->internals.handshake_mac_handle_md5 == NULL) 2103 if (session->internals.handshake_mac_handle_md5 == NULL)
2104 { 2104 {
2105 session->internals.handshake_mac_handle_md5 = 2105 session->internals.handshake_mac_handle_md5 =
2106 _gnutls_hash_init (MHD_GNUTLS_MAC_MD5); 2106 mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
2107 2107
2108 if (session->internals.handshake_mac_handle_md5 == GNUTLS_HASH_FAILED) 2108 if (session->internals.handshake_mac_handle_md5 == GNUTLS_HASH_FAILED)
2109 { 2109 {
@@ -2115,7 +2115,7 @@ _gnutls_handshake_hash_init (gnutls_session_t session)
2115 if (session->internals.handshake_mac_handle_sha == NULL) 2115 if (session->internals.handshake_mac_handle_sha == NULL)
2116 { 2116 {
2117 session->internals.handshake_mac_handle_sha = 2117 session->internals.handshake_mac_handle_sha =
2118 _gnutls_hash_init (MHD_GNUTLS_MAC_SHA1); 2118 mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
2119 if (session->internals.handshake_mac_handle_sha == GNUTLS_HASH_FAILED) 2119 if (session->internals.handshake_mac_handle_sha == GNUTLS_HASH_FAILED)
2120 { 2120 {
2121 gnutls_assert (); 2121 gnutls_assert ();
@@ -2127,19 +2127,19 @@ _gnutls_handshake_hash_init (gnutls_session_t session)
2127} 2127}
2128 2128
2129int 2129int
2130_gnutls_send_supplemental (gnutls_session_t session, int again) 2130_gnutls_send_supplemental (mhd_gtls_session_t session, int again)
2131{ 2131{
2132 int ret = 0; 2132 int ret = 0;
2133 2133
2134 _gnutls_debug_log ("EXT[%x]: Sending supplemental data\n", session); 2134 _gnutls_debug_log ("EXT[%x]: Sending supplemental data\n", session);
2135 2135
2136 if (again) 2136 if (again)
2137 ret = _gnutls_send_handshake (session, NULL, 0, 2137 ret = mhd_gtls_send_handshake (session, NULL, 0,
2138 GNUTLS_HANDSHAKE_SUPPLEMENTAL); 2138 GNUTLS_HANDSHAKE_SUPPLEMENTAL);
2139 else 2139 else
2140 { 2140 {
2141 gnutls_buffer buf; 2141 mhd_gtls_buffer buf;
2142 _gnutls_buffer_init (&buf); 2142 mhd_gtls_buffer_init (&buf);
2143 2143
2144 ret = _gnutls_gen_supplemental (session, &buf); 2144 ret = _gnutls_gen_supplemental (session, &buf);
2145 if (ret < 0) 2145 if (ret < 0)
@@ -2148,16 +2148,16 @@ _gnutls_send_supplemental (gnutls_session_t session, int again)
2148 return ret; 2148 return ret;
2149 } 2149 }
2150 2150
2151 ret = _gnutls_send_handshake (session, buf.data, buf.length, 2151 ret = mhd_gtls_send_handshake (session, buf.data, buf.length,
2152 GNUTLS_HANDSHAKE_SUPPLEMENTAL); 2152 GNUTLS_HANDSHAKE_SUPPLEMENTAL);
2153 _gnutls_buffer_clear (&buf); 2153 mhd_gtls_buffer_clear (&buf);
2154 } 2154 }
2155 2155
2156 return ret; 2156 return ret;
2157} 2157}
2158 2158
2159int 2159int
2160_gnutls_recv_supplemental (gnutls_session_t session) 2160_gnutls_recv_supplemental (mhd_gtls_session_t session)
2161{ 2161{
2162 uint8_t *data = NULL; 2162 uint8_t *data = NULL;
2163 int datalen = 0; 2163 int datalen = 0;
@@ -2165,7 +2165,7 @@ _gnutls_recv_supplemental (gnutls_session_t session)
2165 2165
2166 _gnutls_debug_log ("EXT[%x]: Expecting supplemental data\n", session); 2166 _gnutls_debug_log ("EXT[%x]: Expecting supplemental data\n", session);
2167 2167
2168 ret = _gnutls_recv_handshake (session, &data, &datalen, 2168 ret = mhd_gtls_recv_handshake (session, &data, &datalen,
2169 GNUTLS_HANDSHAKE_SUPPLEMENTAL, 2169 GNUTLS_HANDSHAKE_SUPPLEMENTAL,
2170 OPTIONAL_PACKET); 2170 OPTIONAL_PACKET);
2171 if (ret < 0) 2171 if (ret < 0)
@@ -2187,8 +2187,8 @@ _gnutls_recv_supplemental (gnutls_session_t session)
2187} 2187}
2188 2188
2189/** 2189/**
2190 * gnutls_handshake - This is the main function in the handshake protocol. 2190 * MHD_gnutls_handshake - This is the main function in the handshake protocol.
2191 * @session: is a #gnutls_session_t structure. 2191 * @session: is a #mhd_gtls_session_t structure.
2192 * 2192 *
2193 * This function does the handshake of the TLS/SSL protocol, and 2193 * This function does the handshake of the TLS/SSL protocol, and
2194 * initializes the TLS connection. 2194 * initializes the TLS connection.
@@ -2201,8 +2201,8 @@ _gnutls_recv_supplemental (gnutls_session_t session)
2201 * The non-fatal errors such as %GNUTLS_E_AGAIN and 2201 * The non-fatal errors such as %GNUTLS_E_AGAIN and
2202 * %GNUTLS_E_INTERRUPTED interrupt the handshake procedure, which 2202 * %GNUTLS_E_INTERRUPTED interrupt the handshake procedure, which
2203 * should be later be resumed. Call this function again, until it 2203 * should be later be resumed. Call this function again, until it
2204 * returns 0; cf. gnutls_record_get_direction() and 2204 * returns 0; cf. MHD_gnutls_record_get_direction() and
2205 * gnutls_error_is_fatal(). 2205 * MHD_gtls_error_is_fatal().
2206 * 2206 *
2207 * If this function is called by a server after a rehandshake request 2207 * If this function is called by a server after a rehandshake request
2208 * then %GNUTLS_E_GOT_APPLICATION_DATA or 2208 * then %GNUTLS_E_GOT_APPLICATION_DATA or
@@ -2214,7 +2214,7 @@ _gnutls_recv_supplemental (gnutls_session_t session)
2214 * 2214 *
2215 **/ 2215 **/
2216int 2216int
2217gnutls_handshake (gnutls_session_t session) 2217MHD_gnutls_handshake (mhd_gtls_session_t session)
2218{ 2218{
2219 int ret; 2219 int ret;
2220 2220
@@ -2226,11 +2226,11 @@ gnutls_handshake (gnutls_session_t session)
2226 2226
2227 if (session->security_parameters.entity == GNUTLS_CLIENT) 2227 if (session->security_parameters.entity == GNUTLS_CLIENT)
2228 { 2228 {
2229 ret = _gnutls_handshake_client (session); 2229 ret = mhd_gtls_handshake_client (session);
2230 } 2230 }
2231 else 2231 else
2232 { 2232 {
2233 ret = _gnutls_handshake_server (session); 2233 ret = mhd_gtls_handshake_server (session);
2234 } 2234 }
2235 if (ret < 0) 2235 if (ret < 0)
2236 { 2236 {
@@ -2243,7 +2243,7 @@ gnutls_handshake (gnutls_session_t session)
2243 return ret; 2243 return ret;
2244 } 2244 }
2245 2245
2246 ret = _gnutls_handshake_common (session); 2246 ret = mhd_gtls_handshake_common (session);
2247 2247
2248 if (ret < 0) 2248 if (ret < 0)
2249 { 2249 {
@@ -2256,14 +2256,14 @@ gnutls_handshake (gnutls_session_t session)
2256 STATE = STATE0; 2256 STATE = STATE0;
2257 2257
2258 _gnutls_handshake_io_buffer_clear (session); 2258 _gnutls_handshake_io_buffer_clear (session);
2259 _gnutls_handshake_internal_state_clear (session); 2259 mhd_gtls_handshake_internal_state_clear (session);
2260 2260
2261 return 0; 2261 return 0;
2262} 2262}
2263 2263
2264#define IMED_RET( str, ret) do { \ 2264#define IMED_RET( str, ret) do { \
2265 if (ret < 0) { \ 2265 if (ret < 0) { \
2266 if (gnutls_error_is_fatal(ret)==0) return ret; \ 2266 if (MHD_gtls_error_is_fatal(ret)==0) return ret; \
2267 gnutls_assert(); \ 2267 gnutls_assert(); \
2268 ERR( str, ret); \ 2268 ERR( str, ret); \
2269 _gnutls_handshake_hash_buffers_clear(session); \ 2269 _gnutls_handshake_hash_buffers_clear(session); \
@@ -2273,11 +2273,11 @@ gnutls_handshake (gnutls_session_t session)
2273 2273
2274 2274
2275/* 2275/*
2276 * _gnutls_handshake_client 2276 * mhd_gtls_handshake_client
2277 * This function performs the client side of the handshake of the TLS/SSL protocol. 2277 * This function performs the client side of the handshake of the TLS/SSL protocol.
2278 */ 2278 */
2279int 2279int
2280_gnutls_handshake_client (gnutls_session_t session) 2280mhd_gtls_handshake_client (mhd_gtls_session_t session)
2281{ 2281{
2282 int ret = 0; 2282 int ret = 0;
2283 2283
@@ -2286,7 +2286,7 @@ _gnutls_handshake_client (gnutls_session_t session)
2286 2286
2287 if (session->internals.resumed_security_parameters.session_id_size > 0) 2287 if (session->internals.resumed_security_parameters.session_id_size > 0)
2288 _gnutls_handshake_log ("HSK[%x]: Ask to resume: %s\n", session, 2288 _gnutls_handshake_log ("HSK[%x]: Ask to resume: %s\n", session,
2289 _gnutls_bin2hex (session->internals. 2289 mhd_gtls_bin2hex (session->internals.
2290 resumed_security_parameters. 2290 resumed_security_parameters.
2291 session_id, 2291 session_id,
2292 session->internals. 2292 session->internals.
@@ -2299,14 +2299,14 @@ _gnutls_handshake_client (gnutls_session_t session)
2299 { 2299 {
2300 case STATE0: 2300 case STATE0:
2301 case STATE1: 2301 case STATE1:
2302 ret = _gnutls_send_hello (session, AGAIN (STATE1)); 2302 ret = mhd_gtls_send_hello (session, AGAIN (STATE1));
2303 STATE = STATE1; 2303 STATE = STATE1;
2304 IMED_RET ("send hello", ret); 2304 IMED_RET ("send hello", ret);
2305 2305
2306 case STATE2: 2306 case STATE2:
2307 /* receive the server hello */ 2307 /* receive the server hello */
2308 ret = 2308 ret =
2309 _gnutls_recv_handshake (session, NULL, NULL, 2309 mhd_gtls_recv_handshake (session, NULL, NULL,
2310 GNUTLS_HANDSHAKE_SERVER_HELLO, 2310 GNUTLS_HANDSHAKE_SERVER_HELLO,
2311 MANDATORY_PACKET); 2311 MANDATORY_PACKET);
2312 STATE = STATE2; 2312 STATE = STATE2;
@@ -2323,14 +2323,14 @@ _gnutls_handshake_client (gnutls_session_t session)
2323 case STATE3: 2323 case STATE3:
2324 /* RECV CERTIFICATE */ 2324 /* RECV CERTIFICATE */
2325 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2325 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2326 ret = _gnutls_recv_server_certificate (session); 2326 ret = mhd_gtls_recv_server_certificate (session);
2327 STATE = STATE3; 2327 STATE = STATE3;
2328 IMED_RET ("recv server certificate", ret); 2328 IMED_RET ("recv server certificate", ret);
2329 2329
2330 case STATE4: 2330 case STATE4:
2331 /* receive the server key exchange */ 2331 /* receive the server key exchange */
2332 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2332 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2333 ret = _gnutls_recv_server_kx_message (session); 2333 ret = mhd_gtls_recv_server_kx_message (session);
2334 STATE = STATE4; 2334 STATE = STATE4;
2335 IMED_RET ("recv server kx message", ret); 2335 IMED_RET ("recv server kx message", ret);
2336 2336
@@ -2339,7 +2339,7 @@ _gnutls_handshake_client (gnutls_session_t session)
2339 */ 2339 */
2340 2340
2341 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2341 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2342 ret = _gnutls_recv_server_certificate_request (session); 2342 ret = mhd_gtls_recv_server_certificate_request (session);
2343 STATE = STATE5; 2343 STATE = STATE5;
2344 IMED_RET ("recv server certificate request message", ret); 2344 IMED_RET ("recv server certificate request message", ret);
2345 2345
@@ -2347,7 +2347,7 @@ _gnutls_handshake_client (gnutls_session_t session)
2347 /* receive the server hello done */ 2347 /* receive the server hello done */
2348 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2348 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2349 ret = 2349 ret =
2350 _gnutls_recv_handshake (session, NULL, NULL, 2350 mhd_gtls_recv_handshake (session, NULL, NULL,
2351 GNUTLS_HANDSHAKE_SERVER_HELLO_DONE, 2351 GNUTLS_HANDSHAKE_SERVER_HELLO_DONE,
2352 MANDATORY_PACKET); 2352 MANDATORY_PACKET);
2353 STATE = STATE6; 2353 STATE = STATE6;
@@ -2365,13 +2365,13 @@ _gnutls_handshake_client (gnutls_session_t session)
2365 /* send our certificate - if any and if requested 2365 /* send our certificate - if any and if requested
2366 */ 2366 */
2367 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2367 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2368 ret = _gnutls_send_client_certificate (session, AGAIN (STATE7)); 2368 ret = mhd_gtls_send_client_certificate (session, AGAIN (STATE7));
2369 STATE = STATE7; 2369 STATE = STATE7;
2370 IMED_RET ("send client certificate", ret); 2370 IMED_RET ("send client certificate", ret);
2371 2371
2372 case STATE8: 2372 case STATE8:
2373 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2373 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2374 ret = _gnutls_send_client_kx_message (session, AGAIN (STATE8)); 2374 ret = mhd_gtls_send_client_kx_message (session, AGAIN (STATE8));
2375 STATE = STATE8; 2375 STATE = STATE8;
2376 IMED_RET ("send client kx", ret); 2376 IMED_RET ("send client kx", ret);
2377 2377
@@ -2379,7 +2379,7 @@ _gnutls_handshake_client (gnutls_session_t session)
2379 /* send client certificate verify */ 2379 /* send client certificate verify */
2380 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2380 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2381 ret = 2381 ret =
2382 _gnutls_send_client_certificate_verify (session, AGAIN (STATE9)); 2382 mhd_gtls_send_client_certificate_verify (session, AGAIN (STATE9));
2383 STATE = STATE9; 2383 STATE = STATE9;
2384 IMED_RET ("send client certificate verify", ret); 2384 IMED_RET ("send client certificate verify", ret);
2385 2385
@@ -2395,7 +2395,7 @@ _gnutls_handshake_client (gnutls_session_t session)
2395/* This function sends the final handshake packets and initializes connection 2395/* This function sends the final handshake packets and initializes connection
2396 */ 2396 */
2397static int 2397static int
2398_gnutls_send_handshake_final (gnutls_session_t session, int init) 2398_gnutls_send_handshake_final (mhd_gtls_session_t session, int init)
2399{ 2399{
2400 int ret = 0; 2400 int ret = 0;
2401 2401
@@ -2405,7 +2405,7 @@ _gnutls_send_handshake_final (gnutls_session_t session, int init)
2405 { 2405 {
2406 case STATE0: 2406 case STATE0:
2407 case STATE20: 2407 case STATE20:
2408 ret = _gnutls_send_change_cipher_spec (session, AGAIN (STATE20)); 2408 ret = mhd_gtls_send_change_cipher_spec (session, AGAIN (STATE20));
2409 STATE = STATE20; 2409 STATE = STATE20;
2410 if (ret < 0) 2410 if (ret < 0)
2411 { 2411 {
@@ -2418,7 +2418,7 @@ _gnutls_send_handshake_final (gnutls_session_t session, int init)
2418 */ 2418 */
2419 if (init == TRUE) 2419 if (init == TRUE)
2420 { 2420 {
2421 ret = _gnutls_connection_state_init (session); 2421 ret = mhd_gtls_connection_state_init (session);
2422 if (ret < 0) 2422 if (ret < 0)
2423 { 2423 {
2424 gnutls_assert (); 2424 gnutls_assert ();
@@ -2426,7 +2426,7 @@ _gnutls_send_handshake_final (gnutls_session_t session, int init)
2426 } 2426 }
2427 } 2427 }
2428 2428
2429 ret = _gnutls_write_connection_state_init (session); 2429 ret = mhd_gtls_write_connection_state_init (session);
2430 if (ret < 0) 2430 if (ret < 0)
2431 { 2431 {
2432 gnutls_assert (); 2432 gnutls_assert ();
@@ -2457,7 +2457,7 @@ _gnutls_send_handshake_final (gnutls_session_t session, int init)
2457 * read session. 2457 * read session.
2458 */ 2458 */
2459static int 2459static int
2460_gnutls_recv_handshake_final (gnutls_session_t session, int init) 2460_gnutls_recv_handshake_final (mhd_gtls_session_t session, int init)
2461{ 2461{
2462 int ret = 0; 2462 int ret = 0;
2463 uint8_t ch; 2463 uint8_t ch;
@@ -2466,7 +2466,7 @@ _gnutls_recv_handshake_final (gnutls_session_t session, int init)
2466 { 2466 {
2467 case STATE0: 2467 case STATE0:
2468 case STATE30: 2468 case STATE30:
2469 ret = _gnutls_recv_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, &ch, 1); 2469 ret = mhd_gtls_recv_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, &ch, 1);
2470 STATE = STATE30; 2470 STATE = STATE30;
2471 if (ret <= 0) 2471 if (ret <= 0)
2472 { 2472 {
@@ -2478,7 +2478,7 @@ _gnutls_recv_handshake_final (gnutls_session_t session, int init)
2478 /* Initialize the connection session (start encryption) - in case of server */ 2478 /* Initialize the connection session (start encryption) - in case of server */
2479 if (init == TRUE) 2479 if (init == TRUE)
2480 { 2480 {
2481 ret = _gnutls_connection_state_init (session); 2481 ret = mhd_gtls_connection_state_init (session);
2482 if (ret < 0) 2482 if (ret < 0)
2483 { 2483 {
2484 gnutls_assert (); 2484 gnutls_assert ();
@@ -2486,7 +2486,7 @@ _gnutls_recv_handshake_final (gnutls_session_t session, int init)
2486 } 2486 }
2487 } 2487 }
2488 2488
2489 ret = _gnutls_read_connection_state_init (session); 2489 ret = mhd_gtls_read_connection_state_init (session);
2490 if (ret < 0) 2490 if (ret < 0)
2491 { 2491 {
2492 gnutls_assert (); 2492 gnutls_assert ();
@@ -2512,12 +2512,12 @@ _gnutls_recv_handshake_final (gnutls_session_t session, int init)
2512} 2512}
2513 2513
2514 /* 2514 /*
2515 * _gnutls_handshake_server 2515 * mhd_gtls_handshake_server
2516 * This function does the server stuff of the handshake protocol. 2516 * This function does the server stuff of the handshake protocol.
2517 */ 2517 */
2518 2518
2519int 2519int
2520_gnutls_handshake_server (gnutls_session_t session) 2520mhd_gtls_handshake_server (mhd_gtls_session_t session)
2521{ 2521{
2522 int ret = 0; 2522 int ret = 0;
2523 2523
@@ -2526,14 +2526,14 @@ _gnutls_handshake_server (gnutls_session_t session)
2526 case STATE0: 2526 case STATE0:
2527 case STATE1: 2527 case STATE1:
2528 ret = 2528 ret =
2529 _gnutls_recv_handshake (session, NULL, NULL, 2529 mhd_gtls_recv_handshake (session, NULL, NULL,
2530 GNUTLS_HANDSHAKE_CLIENT_HELLO, 2530 GNUTLS_HANDSHAKE_CLIENT_HELLO,
2531 MANDATORY_PACKET); 2531 MANDATORY_PACKET);
2532 STATE = STATE1; 2532 STATE = STATE1;
2533 IMED_RET ("recv hello", ret); 2533 IMED_RET ("recv hello", ret);
2534 2534
2535 case STATE2: 2535 case STATE2:
2536 ret = _gnutls_send_hello (session, AGAIN (STATE2)); 2536 ret = mhd_gtls_send_hello (session, AGAIN (STATE2));
2537 STATE = STATE2; 2537 STATE = STATE2;
2538 IMED_RET ("send hello", ret); 2538 IMED_RET ("send hello", ret);
2539 2539
@@ -2550,14 +2550,14 @@ _gnutls_handshake_server (gnutls_session_t session)
2550 /* NOTE: these should not be send if we are resuming */ 2550 /* NOTE: these should not be send if we are resuming */
2551 2551
2552 if (session->internals.resumed == RESUME_FALSE) 2552 if (session->internals.resumed == RESUME_FALSE)
2553 ret = _gnutls_send_server_certificate (session, AGAIN (STATE3)); 2553 ret = mhd_gtls_send_server_certificate (session, AGAIN (STATE3));
2554 STATE = STATE3; 2554 STATE = STATE3;
2555 IMED_RET ("send server certificate", ret); 2555 IMED_RET ("send server certificate", ret);
2556 2556
2557 case STATE4: 2557 case STATE4:
2558 /* send server key exchange (A) */ 2558 /* send server key exchange (A) */
2559 if (session->internals.resumed == RESUME_FALSE) 2559 if (session->internals.resumed == RESUME_FALSE)
2560 ret = _gnutls_send_server_kx_message (session, AGAIN (STATE4)); 2560 ret = mhd_gtls_send_server_kx_message (session, AGAIN (STATE4));
2561 STATE = STATE4; 2561 STATE = STATE4;
2562 IMED_RET ("send server kx", ret); 2562 IMED_RET ("send server kx", ret);
2563 2563
@@ -2565,7 +2565,7 @@ _gnutls_handshake_server (gnutls_session_t session)
2565 /* Send certificate request - if requested to */ 2565 /* Send certificate request - if requested to */
2566 if (session->internals.resumed == RESUME_FALSE) 2566 if (session->internals.resumed == RESUME_FALSE)
2567 ret = 2567 ret =
2568 _gnutls_send_server_certificate_request (session, AGAIN (STATE5)); 2568 mhd_gtls_send_server_certificate_request (session, AGAIN (STATE5));
2569 STATE = STATE5; 2569 STATE = STATE5;
2570 IMED_RET ("send server cert request", ret); 2570 IMED_RET ("send server cert request", ret);
2571 2571
@@ -2591,21 +2591,21 @@ _gnutls_handshake_server (gnutls_session_t session)
2591 case STATE7: 2591 case STATE7:
2592 /* receive the client certificate message */ 2592 /* receive the client certificate message */
2593 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2593 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2594 ret = _gnutls_recv_client_certificate (session); 2594 ret = mhd_gtls_recv_client_certificate (session);
2595 STATE = STATE7; 2595 STATE = STATE7;
2596 IMED_RET ("recv client certificate", ret); 2596 IMED_RET ("recv client certificate", ret);
2597 2597
2598 case STATE8: 2598 case STATE8:
2599 /* receive the client key exchange message */ 2599 /* receive the client key exchange message */
2600 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2600 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2601 ret = _gnutls_recv_client_kx_message (session); 2601 ret = mhd_gtls_recv_client_kx_message (session);
2602 STATE = STATE8; 2602 STATE = STATE8;
2603 IMED_RET ("recv client kx", ret); 2603 IMED_RET ("recv client kx", ret);
2604 2604
2605 case STATE9: 2605 case STATE9:
2606 /* receive the client certificate verify message */ 2606 /* receive the client certificate verify message */
2607 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2607 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2608 ret = _gnutls_recv_client_certificate_verify_message (session); 2608 ret = mhd_gtls_recv_client_certificate_verify_message (session);
2609 STATE = STATE9; 2609 STATE = STATE9;
2610 IMED_RET ("recv client certificate verify", ret); 2610 IMED_RET ("recv client certificate verify", ret);
2611 2611
@@ -2618,7 +2618,7 @@ _gnutls_handshake_server (gnutls_session_t session)
2618} 2618}
2619 2619
2620int 2620int
2621_gnutls_handshake_common (gnutls_session_t session) 2621mhd_gtls_handshake_common (mhd_gtls_session_t session)
2622{ 2622{
2623 int ret = 0; 2623 int ret = 0;
2624 2624
@@ -2653,7 +2653,7 @@ _gnutls_handshake_common (gnutls_session_t session)
2653} 2653}
2654 2654
2655int 2655int
2656_gnutls_generate_session_id (opaque * session_id, uint8_t * len) 2656mhd_gtls_generate_session_id (opaque * session_id, uint8_t * len)
2657{ 2657{
2658 *len = TLS_MAX_SESSION_ID_SIZE; 2658 *len = TLS_MAX_SESSION_ID_SIZE;
2659 2659
@@ -2667,7 +2667,7 @@ _gnutls_generate_session_id (opaque * session_id, uint8_t * len)
2667} 2667}
2668 2668
2669int 2669int
2670_gnutls_recv_hello_request (gnutls_session_t session, void *data, 2670mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data,
2671 uint32_t data_size) 2671 uint32_t data_size)
2672{ 2672{
2673 uint8_t type; 2673 uint8_t type;
@@ -2696,33 +2696,33 @@ _gnutls_recv_hello_request (gnutls_session_t session, void *data,
2696 * (DH or RSA) set up. Otherwise returns 0. 2696 * (DH or RSA) set up. Otherwise returns 0.
2697 */ 2697 */
2698inline static int 2698inline static int
2699check_server_params (gnutls_session_t session, 2699check_server_params (mhd_gtls_session_t session,
2700 gnutls_kx_algorithm_t kx, 2700 gnutls_kx_algorithm_t kx,
2701 gnutls_kx_algorithm_t * alg, int alg_size) 2701 gnutls_kx_algorithm_t * alg, int alg_size)
2702{ 2702{
2703 int cred_type; 2703 int cred_type;
2704 gnutls_dh_params_t dh_params = NULL; 2704 mhd_gtls_dh_params_t dh_params = NULL;
2705 gnutls_rsa_params_t rsa_params = NULL; 2705 mhd_gtls_rsa_params_t rsa_params = NULL;
2706 int j; 2706 int j;
2707 2707
2708 cred_type = _gnutls_map_kx_get_cred (kx, 1); 2708 cred_type = mhd_gtls_map_kx_get_cred (kx, 1);
2709 2709
2710 /* Read the Diffie Hellman parameters, if any. 2710 /* Read the Diffie Hellman parameters, if any.
2711 */ 2711 */
2712 if (cred_type == MHD_GNUTLS_CRD_CERTIFICATE) 2712 if (cred_type == MHD_GNUTLS_CRD_CERTIFICATE)
2713 { 2713 {
2714 int delete; 2714 int delete;
2715 gnutls_certificate_credentials_t x509_cred = 2715 mhd_gtls_cert_credentials_t x509_cred =
2716 (gnutls_certificate_credentials_t) _gnutls_get_cred (session->key, 2716 (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key,
2717 cred_type, NULL); 2717 cred_type, NULL);
2718 2718
2719 if (x509_cred != NULL) 2719 if (x509_cred != NULL)
2720 { 2720 {
2721 dh_params = 2721 dh_params =
2722 _gnutls_get_dh_params (x509_cred->dh_params, 2722 mhd_gtls_get_dh_params (x509_cred->dh_params,
2723 x509_cred->params_func, session); 2723 x509_cred->params_func, session);
2724 rsa_params = 2724 rsa_params =
2725 _gnutls_certificate_get_rsa_params (x509_cred->rsa_params, 2725 mhd_gtls_certificate_get_rsa_params (x509_cred->rsa_params,
2726 x509_cred->params_func, 2726 x509_cred->params_func,
2727 session); 2727 session);
2728 } 2728 }
@@ -2747,14 +2747,14 @@ check_server_params (gnutls_session_t session,
2747 } 2747 }
2748 else if (cred_type == MHD_GNUTLS_CRD_ANON) 2748 else if (cred_type == MHD_GNUTLS_CRD_ANON)
2749 { 2749 {
2750 gnutls_anon_server_credentials_t anon_cred = 2750 mhd_gtls_anon_server_credentials_t anon_cred =
2751 (gnutls_anon_server_credentials_t) _gnutls_get_cred (session->key, 2751 (mhd_gtls_anon_server_credentials_t) mhd_gtls_get_cred (session->key,
2752 cred_type, NULL); 2752 cred_type, NULL);
2753 2753
2754 if (anon_cred != NULL) 2754 if (anon_cred != NULL)
2755 { 2755 {
2756 dh_params = 2756 dh_params =
2757 _gnutls_get_dh_params (anon_cred->dh_params, 2757 mhd_gtls_get_dh_params (anon_cred->dh_params,
2758 anon_cred->params_func, session); 2758 anon_cred->params_func, session);
2759 } 2759 }
2760#endif 2760#endif
@@ -2763,13 +2763,13 @@ check_server_params (gnutls_session_t session,
2763 else if (cred_type == MHD_GNUTLS_CRD_PSK) 2763 else if (cred_type == MHD_GNUTLS_CRD_PSK)
2764 { 2764 {
2765 gnutls_psk_server_credentials_t psk_cred = 2765 gnutls_psk_server_credentials_t psk_cred =
2766 (gnutls_psk_server_credentials_t) _gnutls_get_cred (session->key, 2766 (gnutls_psk_server_credentials_t) mhd_gtls_get_cred (session->key,
2767 cred_type, NULL); 2767 cred_type, NULL);
2768 2768
2769 if (psk_cred != NULL) 2769 if (psk_cred != NULL)
2770 { 2770 {
2771 dh_params = 2771 dh_params =
2772 _gnutls_get_dh_params (psk_cred->dh_params, psk_cred->params_func, 2772 mhd_gtls_get_dh_params (psk_cred->dh_params, psk_cred->params_func,
2773 session); 2773 session);
2774 } 2774 }
2775#endif 2775#endif
@@ -2781,7 +2781,7 @@ check_server_params (gnutls_session_t session,
2781 /* If the key exchange method needs RSA or DH params, 2781 /* If the key exchange method needs RSA or DH params,
2782 * but they are not set then remove it. 2782 * but they are not set then remove it.
2783 */ 2783 */
2784 if (_gnutls_kx_needs_rsa_params (kx) != 0) 2784 if (mhd_gtls_kx_needs_rsa_params (kx) != 0)
2785 { 2785 {
2786 /* needs rsa params. */ 2786 /* needs rsa params. */
2787 if (_gnutls_rsa_params_to_mpi (rsa_params) == NULL) 2787 if (_gnutls_rsa_params_to_mpi (rsa_params) == NULL)
@@ -2791,10 +2791,10 @@ check_server_params (gnutls_session_t session,
2791 } 2791 }
2792 } 2792 }
2793 2793
2794 if (_gnutls_kx_needs_dh_params (kx) != 0) 2794 if (mhd_gtls_kx_needs_dh_params (kx) != 0)
2795 { 2795 {
2796 /* needs DH params. */ 2796 /* needs DH params. */
2797 if (_gnutls_dh_params_to_mpi (dh_params) == NULL) 2797 if (mhd_gtls_dh_params_to_mpi (dh_params) == NULL)
2798 { 2798 {
2799 gnutls_assert (); 2799 gnutls_assert ();
2800 return 1; 2800 return 1;
@@ -2812,7 +2812,7 @@ check_server_params (gnutls_session_t session,
2812 * by checking certificates etc. 2812 * by checking certificates etc.
2813 */ 2813 */
2814int 2814int
2815_gnutls_remove_unwanted_ciphersuites (gnutls_session_t session, 2815mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2816 cipher_suite_st ** cipherSuites, 2816 cipher_suite_st ** cipherSuites,
2817 int numCipherSuites, 2817 int numCipherSuites,
2818 gnutls_pk_algorithm_t requested_pk_algo) 2818 gnutls_pk_algorithm_t requested_pk_algo)
@@ -2821,7 +2821,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2821 int ret = 0; 2821 int ret = 0;
2822 cipher_suite_st *newSuite, cs; 2822 cipher_suite_st *newSuite, cs;
2823 int newSuiteSize = 0, i; 2823 int newSuiteSize = 0, i;
2824 gnutls_certificate_credentials_t cert_cred; 2824 mhd_gtls_cert_credentials_t cert_cred;
2825 gnutls_kx_algorithm_t kx; 2825 gnutls_kx_algorithm_t kx;
2826 int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0; 2826 int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0;
2827 gnutls_kx_algorithm_t *alg = NULL; 2827 gnutls_kx_algorithm_t *alg = NULL;
@@ -2834,7 +2834,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2834 */ 2834 */
2835 2835
2836 cert_cred = 2836 cert_cred =
2837 (gnutls_certificate_credentials_t) _gnutls_get_cred (session->key, 2837 (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key,
2838 MHD_GNUTLS_CRD_CERTIFICATE, 2838 MHD_GNUTLS_CRD_CERTIFICATE,
2839 NULL); 2839 NULL);
2840 2840
@@ -2844,12 +2844,12 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2844 if (session->security_parameters.entity == GNUTLS_SERVER 2844 if (session->security_parameters.entity == GNUTLS_SERVER
2845 && cert_cred != NULL) 2845 && cert_cred != NULL)
2846 { 2846 {
2847 ret = _gnutls_server_select_cert (session, requested_pk_algo); 2847 ret = mhd_gtls_server_select_cert (session, requested_pk_algo);
2848 if (ret < 0) 2848 if (ret < 0)
2849 { 2849 {
2850 gnutls_assert (); 2850 gnutls_assert ();
2851 _gnutls_x509_log ("Could not find an appropriate certificate: %s\n", 2851 _gnutls_x509_log ("Could not find an appropriate certificate: %s\n",
2852 gnutls_strerror (ret)); 2852 MHD_gtls_strerror (ret));
2853 cert_cred = NULL; 2853 cert_cred = NULL;
2854 } 2854 }
2855 } 2855 }
@@ -2858,7 +2858,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2858 * supported by the X509 certificate parameters. 2858 * supported by the X509 certificate parameters.
2859 */ 2859 */
2860 if ((ret = 2860 if ((ret =
2861 _gnutls_selected_cert_supported_kx (session, &alg, &alg_size)) < 0) 2861 mhd_gtls_selected_cert_supported_kx (session, &alg, &alg_size)) < 0)
2862 { 2862 {
2863 gnutls_assert (); 2863 gnutls_assert ();
2864 return ret; 2864 return ret;
@@ -2881,11 +2881,11 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2881 /* finds the key exchange algorithm in 2881 /* finds the key exchange algorithm in
2882 * the ciphersuite 2882 * the ciphersuite
2883 */ 2883 */
2884 kx = _gnutls_cipher_suite_get_kx_algo (&(*cipherSuites)[i]); 2884 kx = mhd_gtls_cipher_suite_get_kx_algo (&(*cipherSuites)[i]);
2885 2885
2886 /* if it is defined but had no credentials 2886 /* if it is defined but had no credentials
2887 */ 2887 */
2888 if (_gnutls_get_kx_cred (session, kx, NULL) == NULL) 2888 if (mhd_gtls_get_kx_cred (session, kx, NULL) == NULL)
2889 { 2889 {
2890 delete = 1; 2890 delete = 1;
2891 } 2891 }
@@ -2903,7 +2903,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2903 SRP credential too. */ 2903 SRP credential too. */
2904 if (kx == MHD_GNUTLS_KX_SRP_RSA || kx == MHD_GNUTLS_KX_SRP_DSS) 2904 if (kx == MHD_GNUTLS_KX_SRP_RSA || kx == MHD_GNUTLS_KX_SRP_DSS)
2905 { 2905 {
2906 if (!_gnutls_get_cred (session->key, MHD_GNUTLS_CRD_SRP, NULL)) 2906 if (!mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_SRP, NULL))
2907 delete = 1; 2907 delete = 1;
2908 } 2908 }
2909 2909
@@ -2914,7 +2914,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2914 2914
2915 _gnutls_handshake_log ("HSK[%x]: Keeping ciphersuite: %s\n", 2915 _gnutls_handshake_log ("HSK[%x]: Keeping ciphersuite: %s\n",
2916 session, 2916 session,
2917 _gnutls_cipher_suite_get_name (&cs)); 2917 mhd_gtls_cipher_suite_get_name (&cs));
2918 2918
2919 memcpy (newSuite[newSuiteSize].suite, (*cipherSuites)[i].suite, 2); 2919 memcpy (newSuite[newSuiteSize].suite, (*cipherSuites)[i].suite, 2);
2920 newSuiteSize++; 2920 newSuiteSize++;
@@ -2923,7 +2923,7 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2923 { 2923 {
2924 _gnutls_handshake_log ("HSK[%x]: Removing ciphersuite: %s\n", 2924 _gnutls_handshake_log ("HSK[%x]: Removing ciphersuite: %s\n",
2925 session, 2925 session,
2926 _gnutls_cipher_suite_get_name (&cs)); 2926 mhd_gtls_cipher_suite_get_name (&cs));
2927 2927
2928 } 2928 }
2929 } 2929 }
@@ -2939,8 +2939,8 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2939} 2939}
2940 2940
2941/** 2941/**
2942 * gnutls_handshake_set_max_packet_length - This function will set the maximum length of a handshake message 2942 * MHD_gnutls_handshake_set_max_packet_length - This function will set the maximum length of a handshake message
2943 * @session: is a #gnutls_session_t structure. 2943 * @session: is a #mhd_gtls_session_t structure.
2944 * @max: is the maximum number. 2944 * @max: is the maximum number.
2945 * 2945 *
2946 * This function will set the maximum size of a handshake message. 2946 * This function will set the maximum size of a handshake message.
@@ -2950,28 +2950,28 @@ _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
2950 * 2950 *
2951 **/ 2951 **/
2952void 2952void
2953gnutls_handshake_set_max_packet_length (gnutls_session_t session, size_t max) 2953MHD_gnutls_handshake_set_max_packet_length (mhd_gtls_session_t session, size_t max)
2954{ 2954{
2955 session->internals.max_handshake_data_buffer_size = max; 2955 session->internals.max_handshake_data_buffer_size = max;
2956} 2956}
2957 2957
2958void 2958void
2959_gnutls_set_adv_version (gnutls_session_t session, gnutls_protocol_t ver) 2959mhd_gtls_set_adv_version (mhd_gtls_session_t session, gnutls_protocol_t ver)
2960{ 2960{
2961 set_adv_version (session, _gnutls_version_get_major (ver), 2961 set_adv_version (session, mhd_gtls_version_get_major (ver),
2962 _gnutls_version_get_minor (ver)); 2962 mhd_gtls_version_get_minor (ver));
2963} 2963}
2964 2964
2965gnutls_protocol_t 2965gnutls_protocol_t
2966_gnutls_get_adv_version (gnutls_session_t session) 2966mhd_gtls_get_adv_version (mhd_gtls_session_t session)
2967{ 2967{
2968 return _gnutls_version_get (_gnutls_get_adv_version_major (session), 2968 return mhd_gtls_version_get (_gnutls_get_adv_version_major (session),
2969 _gnutls_get_adv_version_minor (session)); 2969 _gnutls_get_adv_version_minor (session));
2970} 2970}
2971 2971
2972/** 2972/**
2973 * gnutls_handshake_get_last_in - Returns the last handshake message received. 2973 * MHD_gtls_handshake_get_last_in - Returns the last handshake message received.
2974 * @session: is a #gnutls_session_t structure. 2974 * @session: is a #mhd_gtls_session_t structure.
2975 * 2975 *
2976 * This function is only useful to check where the last performed 2976 * This function is only useful to check where the last performed
2977 * handshake failed. If the previous handshake succeed or was not 2977 * handshake failed. If the previous handshake succeed or was not
@@ -2984,14 +2984,14 @@ _gnutls_get_adv_version (gnutls_session_t session)
2984 * %gnutls_handshake_description_t. 2984 * %gnutls_handshake_description_t.
2985 **/ 2985 **/
2986gnutls_handshake_description_t 2986gnutls_handshake_description_t
2987gnutls_handshake_get_last_in (gnutls_session_t session) 2987MHD_gtls_handshake_get_last_in (mhd_gtls_session_t session)
2988{ 2988{
2989 return session->internals.last_handshake_in; 2989 return session->internals.last_handshake_in;
2990} 2990}
2991 2991
2992/** 2992/**
2993 * gnutls_handshake_get_last_out - Returns the last handshake message sent. 2993 * MHD_gtls_handshake_get_last_out - Returns the last handshake message sent.
2994 * @session: is a #gnutls_session_t structure. 2994 * @session: is a #mhd_gtls_session_t structure.
2995 * 2995 *
2996 * This function is only useful to check where the last performed 2996 * This function is only useful to check where the last performed
2997 * handshake failed. If the previous handshake succeed or was not 2997 * handshake failed. If the previous handshake succeed or was not
@@ -3004,7 +3004,7 @@ gnutls_handshake_get_last_in (gnutls_session_t session)
3004 * %gnutls_handshake_description_t. 3004 * %gnutls_handshake_description_t.
3005 **/ 3005 **/
3006gnutls_handshake_description_t 3006gnutls_handshake_description_t
3007gnutls_handshake_get_last_out (gnutls_session_t session) 3007MHD_gtls_handshake_get_last_out (mhd_gtls_session_t session)
3008{ 3008{
3009 return session->internals.last_handshake_out; 3009 return session->internals.last_handshake_out;
3010} 3010}
diff --git a/src/daemon/https/tls/gnutls_handshake.h b/src/daemon/https/tls/gnutls_handshake.h
index 5cff279a..9917fdc7 100644
--- a/src/daemon/https/tls/gnutls_handshake.h
+++ b/src/daemon/https/tls/gnutls_handshake.h
@@ -25,33 +25,33 @@
25typedef enum Optional 25typedef enum Optional
26{ OPTIONAL_PACKET, MANDATORY_PACKET } Optional; 26{ OPTIONAL_PACKET, MANDATORY_PACKET } Optional;
27 27
28int _gnutls_send_handshake (gnutls_session_t session, void *i_data, 28int mhd_gtls_send_handshake (mhd_gtls_session_t session, void *i_data,
29 uint32_t i_datasize, 29 uint32_t i_datasize,
30 gnutls_handshake_description_t type); 30 gnutls_handshake_description_t type);
31int _gnutls_recv_hello_request (gnutls_session_t session, void *data, 31int mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data,
32 uint32_t data_size); 32 uint32_t data_size);
33int _gnutls_send_hello (gnutls_session_t session, int again); 33int mhd_gtls_send_hello (mhd_gtls_session_t session, int again);
34int _gnutls_recv_hello (gnutls_session_t session, opaque * data, int datalen); 34int mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen);
35int _gnutls_recv_handshake (gnutls_session_t session, uint8_t **, int *, 35int mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t **, int *,
36 gnutls_handshake_description_t, 36 gnutls_handshake_description_t,
37 Optional optional); 37 Optional optional);
38int _gnutls_generate_session_id (opaque * session_id, uint8_t * len); 38int mhd_gtls_generate_session_id (opaque * session_id, uint8_t * len);
39int _gnutls_handshake_common (gnutls_session_t session); 39int mhd_gtls_handshake_common (mhd_gtls_session_t session);
40int _gnutls_handshake_client (gnutls_session_t session); 40int mhd_gtls_handshake_client (mhd_gtls_session_t session);
41int _gnutls_handshake_server (gnutls_session_t session); 41int mhd_gtls_handshake_server (mhd_gtls_session_t session);
42void _gnutls_set_server_random (gnutls_session_t session, uint8_t * rnd); 42void mhd_gtls_set_server_random (mhd_gtls_session_t session, uint8_t * rnd);
43void _gnutls_set_client_random (gnutls_session_t session, uint8_t * rnd); 43void mhd_gtls_set_client_random (mhd_gtls_session_t session, uint8_t * rnd);
44int _gnutls_tls_create_random (opaque * dst); 44int mhd_gtls_tls_create_random (opaque * dst);
45int _gnutls_remove_unwanted_ciphersuites (gnutls_session_t session, 45int mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
46 cipher_suite_st ** cipherSuites, 46 cipher_suite_st ** cipherSuites,
47 int numCipherSuites, 47 int numCipherSuites,
48 gnutls_pk_algorithm_t); 48 gnutls_pk_algorithm_t);
49int _gnutls_find_pk_algos_in_ciphersuites (opaque * data, int datalen); 49int mhd_gtls_find_pk_algos_in_ciphersuites (opaque * data, int datalen);
50int _gnutls_server_select_suite (gnutls_session_t session, opaque * data, 50int mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
51 int datalen); 51 int datalen);
52 52
53int _gnutls_negotiate_version( gnutls_session_t session, gnutls_protocol_t adv_version); 53int mhd_gtls_negotiate_version( mhd_gtls_session_t session, gnutls_protocol_t adv_version);
54int _gnutls_user_hello_func( gnutls_session, gnutls_protocol_t adv_version); 54int mhd_gtls_user_hello_func( gnutls_session, gnutls_protocol_t adv_version);
55 55
56#define STATE session->internals.handshake_state 56#define STATE session->internals.handshake_state
57/* This returns true if we have got there 57/* This returns true if we have got there
diff --git a/src/daemon/https/tls/gnutls_hash_int.c b/src/daemon/https/tls/gnutls_hash_int.c
index 8746613b..4afb0ea2 100644
--- a/src/daemon/https/tls/gnutls_hash_int.c
+++ b/src/daemon/https/tls/gnutls_hash_int.c
@@ -55,7 +55,7 @@ _gnutls_mac2gc (gnutls_mac_algorithm_t mac)
55} 55}
56 56
57GNUTLS_HASH_HANDLE 57GNUTLS_HASH_HANDLE
58_gnutls_hash_init (gnutls_mac_algorithm_t algorithm) 58mhd_gtls_hash_init (gnutls_mac_algorithm_t algorithm)
59{ 59{
60 mac_hd_t ret; 60 mac_hd_t ret;
61 int result; 61 int result;
@@ -81,7 +81,7 @@ _gnutls_hash_init (gnutls_mac_algorithm_t algorithm)
81} 81}
82 82
83int 83int
84_gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm) 84mhd_gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm)
85{ 85{
86 int ret; 86 int ret;
87 87
@@ -92,7 +92,7 @@ _gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm)
92} 92}
93 93
94int 94int
95_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, size_t textlen) 95mhd_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, size_t textlen)
96{ 96{
97 if (textlen > 0) 97 if (textlen > 0)
98 gc_hash_write (handle->handle, textlen, text); 98 gc_hash_write (handle->handle, textlen, text);
@@ -100,7 +100,7 @@ _gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, size_t textlen)
100} 100}
101 101
102GNUTLS_HASH_HANDLE 102GNUTLS_HASH_HANDLE
103_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle) 103mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
104{ 104{
105 GNUTLS_HASH_HANDLE ret; 105 GNUTLS_HASH_HANDLE ret;
106 int result; 106 int result;
@@ -126,12 +126,12 @@ _gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
126} 126}
127 127
128void 128void
129_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest) 129mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest)
130{ 130{
131 const opaque *mac; 131 const opaque *mac;
132 int maclen; 132 int maclen;
133 133
134 maclen = _gnutls_hash_get_algo_len (handle->algorithm); 134 maclen = mhd_gnutls_hash_get_algo_len (handle->algorithm);
135 135
136 mac = gc_hash_read (handle->handle); 136 mac = gc_hash_read (handle->handle);
137 if (digest != NULL) 137 if (digest != NULL)
@@ -144,7 +144,7 @@ _gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest)
144 144
145 145
146mac_hd_t 146mac_hd_t
147_gnutls_hmac_init (gnutls_mac_algorithm_t algorithm, 147mhd_gtls_hmac_init (gnutls_mac_algorithm_t algorithm,
148 const void *key, int keylen) 148 const void *key, int keylen)
149{ 149{
150 mac_hd_t ret; 150 mac_hd_t ret;
@@ -171,12 +171,12 @@ _gnutls_hmac_init (gnutls_mac_algorithm_t algorithm,
171} 171}
172 172
173void 173void
174_gnutls_hmac_deinit (mac_hd_t handle, void *digest) 174mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest)
175{ 175{
176 const opaque *mac; 176 const opaque *mac;
177 int maclen; 177 int maclen;
178 178
179 maclen = _gnutls_hash_get_algo_len (handle->algorithm); 179 maclen = mhd_gnutls_hash_get_algo_len (handle->algorithm);
180 180
181 mac = gc_hash_read (handle->handle); 181 mac = gc_hash_read (handle->handle);
182 182
@@ -203,7 +203,7 @@ get_padsize (gnutls_mac_algorithm_t algorithm)
203} 203}
204 204
205mac_hd_t 205mac_hd_t
206_gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key, 206mhd_gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key,
207 int keylen) 207 int keylen)
208{ 208{
209 mac_hd_t ret; 209 mac_hd_t ret;
@@ -219,22 +219,22 @@ _gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key,
219 219
220 memset (ipad, 0x36, padsize); 220 memset (ipad, 0x36, padsize);
221 221
222 ret = _gnutls_hash_init (algorithm); 222 ret = mhd_gtls_hash_init (algorithm);
223 if (ret != GNUTLS_HASH_FAILED) 223 if (ret != GNUTLS_HASH_FAILED)
224 { 224 {
225 ret->key = key; 225 ret->key = key;
226 ret->keysize = keylen; 226 ret->keysize = keylen;
227 227
228 if (keylen > 0) 228 if (keylen > 0)
229 _gnutls_hash (ret, key, keylen); 229 mhd_gnutls_hash (ret, key, keylen);
230 _gnutls_hash (ret, ipad, padsize); 230 mhd_gnutls_hash (ret, ipad, padsize);
231 } 231 }
232 232
233 return ret; 233 return ret;
234} 234}
235 235
236void 236void
237_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest) 237mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
238{ 238{
239 opaque ret[MAX_HASH_SIZE]; 239 opaque ret[MAX_HASH_SIZE];
240 mac_hd_t td; 240 mac_hd_t td;
@@ -251,23 +251,23 @@ _gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
251 251
252 memset (opad, 0x5C, padsize); 252 memset (opad, 0x5C, padsize);
253 253
254 td = _gnutls_hash_init (handle->algorithm); 254 td = mhd_gtls_hash_init (handle->algorithm);
255 if (td != GNUTLS_MAC_FAILED) 255 if (td != GNUTLS_MAC_FAILED)
256 { 256 {
257 if (handle->keysize > 0) 257 if (handle->keysize > 0)
258 _gnutls_hash (td, handle->key, handle->keysize); 258 mhd_gnutls_hash (td, handle->key, handle->keysize);
259 259
260 _gnutls_hash (td, opad, padsize); 260 mhd_gnutls_hash (td, opad, padsize);
261 block = _gnutls_hmac_get_algo_len (handle->algorithm); 261 block = mhd_gnutls_hash_get_algo_len (handle->algorithm);
262 _gnutls_hash_deinit (handle, ret); /* get the previous hash */ 262 mhd_gnutls_hash_deinit (handle, ret); /* get the previous hash */
263 _gnutls_hash (td, ret, block); 263 mhd_gnutls_hash (td, ret, block);
264 264
265 _gnutls_hash_deinit (td, digest); 265 mhd_gnutls_hash_deinit (td, digest);
266 } 266 }
267} 267}
268 268
269void 269void
270_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, 270mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
271 void *digest, opaque * key, 271 void *digest, opaque * key,
272 uint32_t key_size) 272 uint32_t key_size)
273{ 273{
@@ -288,23 +288,23 @@ _gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
288 memset (opad, 0x5C, padsize); 288 memset (opad, 0x5C, padsize);
289 memset (ipad, 0x36, padsize); 289 memset (ipad, 0x36, padsize);
290 290
291 td = _gnutls_hash_init (handle->algorithm); 291 td = mhd_gtls_hash_init (handle->algorithm);
292 if (td != GNUTLS_HASH_FAILED) 292 if (td != GNUTLS_HASH_FAILED)
293 { 293 {
294 if (key_size > 0) 294 if (key_size > 0)
295 _gnutls_hash (td, key, key_size); 295 mhd_gnutls_hash (td, key, key_size);
296 296
297 _gnutls_hash (td, opad, padsize); 297 mhd_gnutls_hash (td, opad, padsize);
298 block = _gnutls_hmac_get_algo_len (handle->algorithm); 298 block = mhd_gnutls_hash_get_algo_len (handle->algorithm);
299 299
300 if (key_size > 0) 300 if (key_size > 0)
301 _gnutls_hash (handle, key, key_size); 301 mhd_gnutls_hash (handle, key, key_size);
302 _gnutls_hash (handle, ipad, padsize); 302 mhd_gnutls_hash (handle, ipad, padsize);
303 _gnutls_hash_deinit (handle, ret); /* get the previous hash */ 303 mhd_gnutls_hash_deinit (handle, ret); /* get the previous hash */
304 304
305 _gnutls_hash (td, ret, block); 305 mhd_gnutls_hash (td, ret, block);
306 306
307 _gnutls_hash_deinit (td, digest); 307 mhd_gnutls_hash_deinit (td, digest);
308 } 308 }
309} 309}
310 310
@@ -322,18 +322,18 @@ ssl3_sha (int i, opaque * secret, int secret_len,
322 text1[j] = 65 + i; /* A==65 */ 322 text1[j] = 65 + i; /* A==65 */
323 } 323 }
324 324
325 td = _gnutls_hash_init (MHD_GNUTLS_MAC_SHA1); 325 td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
326 if (td == NULL) 326 if (td == NULL)
327 { 327 {
328 gnutls_assert (); 328 gnutls_assert ();
329 return GNUTLS_E_HASH_FAILED; 329 return GNUTLS_E_HASH_FAILED;
330 } 330 }
331 331
332 _gnutls_hash (td, text1, i + 1); 332 mhd_gnutls_hash (td, text1, i + 1);
333 _gnutls_hash (td, secret, secret_len); 333 mhd_gnutls_hash (td, secret, secret_len);
334 _gnutls_hash (td, rnd, rnd_len); 334 mhd_gnutls_hash (td, rnd, rnd_len);
335 335
336 _gnutls_hash_deinit (td, digest); 336 mhd_gnutls_hash_deinit (td, digest);
337 return 0; 337 return 0;
338} 338}
339 339
@@ -345,49 +345,49 @@ ssl3_md5 (int i, opaque * secret, int secret_len,
345 mac_hd_t td; 345 mac_hd_t td;
346 int ret; 346 int ret;
347 347
348 td = _gnutls_hash_init (MHD_GNUTLS_MAC_MD5); 348 td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
349 if (td == NULL) 349 if (td == NULL)
350 { 350 {
351 gnutls_assert (); 351 gnutls_assert ();
352 return GNUTLS_E_HASH_FAILED; 352 return GNUTLS_E_HASH_FAILED;
353 } 353 }
354 354
355 _gnutls_hash (td, secret, secret_len); 355 mhd_gnutls_hash (td, secret, secret_len);
356 356
357 ret = ssl3_sha (i, secret, secret_len, rnd, rnd_len, tmp); 357 ret = ssl3_sha (i, secret, secret_len, rnd, rnd_len, tmp);
358 if (ret < 0) 358 if (ret < 0)
359 { 359 {
360 gnutls_assert (); 360 gnutls_assert ();
361 _gnutls_hash_deinit (td, digest); 361 mhd_gnutls_hash_deinit (td, digest);
362 return ret; 362 return ret;
363 } 363 }
364 364
365 _gnutls_hash (td, tmp, _gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_SHA1)); 365 mhd_gnutls_hash (td, tmp, mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_SHA1));
366 366
367 _gnutls_hash_deinit (td, digest); 367 mhd_gnutls_hash_deinit (td, digest);
368 return 0; 368 return 0;
369} 369}
370 370
371int 371int
372_gnutls_ssl3_hash_md5 (void *first, int first_len, 372mhd_gnutls_ssl3_hash_md5 (void *first, int first_len,
373 void *second, int second_len, int ret_len, 373 void *second, int second_len, int ret_len,
374 opaque * ret) 374 opaque * ret)
375{ 375{
376 opaque digest[MAX_HASH_SIZE]; 376 opaque digest[MAX_HASH_SIZE];
377 mac_hd_t td; 377 mac_hd_t td;
378 int block = _gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5); 378 int block = mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
379 379
380 td = _gnutls_hash_init (MHD_GNUTLS_MAC_MD5); 380 td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
381 if (td == NULL) 381 if (td == NULL)
382 { 382 {
383 gnutls_assert (); 383 gnutls_assert ();
384 return GNUTLS_E_HASH_FAILED; 384 return GNUTLS_E_HASH_FAILED;
385 } 385 }
386 386
387 _gnutls_hash (td, first, first_len); 387 mhd_gnutls_hash (td, first, first_len);
388 _gnutls_hash (td, second, second_len); 388 mhd_gnutls_hash (td, second, second_len);
389 389
390 _gnutls_hash_deinit (td, digest); 390 mhd_gnutls_hash_deinit (td, digest);
391 391
392 if (ret_len > block) 392 if (ret_len > block)
393 { 393 {
@@ -402,13 +402,13 @@ _gnutls_ssl3_hash_md5 (void *first, int first_len,
402} 402}
403 403
404int 404int
405_gnutls_ssl3_generate_random (void *secret, int secret_len, 405mhd_gnutls_ssl3_generate_random (void *secret, int secret_len,
406 void *rnd, int rnd_len, 406 void *rnd, int rnd_len,
407 int ret_bytes, opaque * ret) 407 int ret_bytes, opaque * ret)
408{ 408{
409 int i = 0, copy, output_bytes; 409 int i = 0, copy, output_bytes;
410 opaque digest[MAX_HASH_SIZE]; 410 opaque digest[MAX_HASH_SIZE];
411 int block = _gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5); 411 int block = mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
412 int result, times; 412 int result, times;
413 413
414 output_bytes = 0; 414 output_bytes = 0;
diff --git a/src/daemon/https/tls/gnutls_hash_int.h b/src/daemon/https/tls/gnutls_hash_int.h
index 3e1b75e6..0b49dfd5 100644
--- a/src/daemon/https/tls/gnutls_hash_int.h
+++ b/src/daemon/https/tls/gnutls_hash_int.h
@@ -42,31 +42,30 @@ typedef mac_hd_t GNUTLS_HASH_HANDLE;
42#define GNUTLS_HASH_FAILED NULL 42#define GNUTLS_HASH_FAILED NULL
43#define GNUTLS_MAC_FAILED NULL 43#define GNUTLS_MAC_FAILED NULL
44 44
45mac_hd_t _gnutls_hmac_init (gnutls_mac_algorithm_t algorithm, 45mac_hd_t mhd_gtls_hmac_init (gnutls_mac_algorithm_t algorithm,
46 const void *key, int keylen); 46 const void *key, int keylen);
47#define _gnutls_hmac_get_algo_len _gnutls_hash_get_algo_len
48#define _gnutls_hmac _gnutls_hash
49void _gnutls_hmac_deinit (mac_hd_t handle, void *digest);
50 47
51mac_hd_t _gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key, 48void mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest);
49
50mac_hd_t mhd_gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key,
52 int keylen); 51 int keylen);
53void _gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest); 52void mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest);
54 53
55GNUTLS_HASH_HANDLE _gnutls_hash_init (gnutls_mac_algorithm_t algorithm); 54GNUTLS_HASH_HANDLE mhd_gtls_hash_init (gnutls_mac_algorithm_t algorithm);
56int _gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm); 55int mhd_gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm);
57int _gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, 56int mhd_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text,
58 size_t textlen); 57 size_t textlen);
59void _gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest); 58void mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest);
60 59
61int _gnutls_ssl3_generate_random (void *secret, int secret_len, 60int mhd_gnutls_ssl3_generate_random (void *secret, int secret_len,
62 void *rnd, int random_len, int bytes, 61 void *rnd, int random_len, int bytes,
63 opaque * ret); 62 opaque * ret);
64int _gnutls_ssl3_hash_md5 (void *first, int first_len, void *second, 63int mhd_gnutls_ssl3_hash_md5 (void *first, int first_len, void *second,
65 int second_len, int ret_len, opaque * ret); 64 int second_len, int ret_len, opaque * ret);
66 65
67void _gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, void *digest, 66void mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, void *digest,
68 opaque * key, uint32_t key_size); 67 opaque * key, uint32_t key_size);
69 68
70GNUTLS_HASH_HANDLE _gnutls_hash_copy (GNUTLS_HASH_HANDLE handle); 69GNUTLS_HASH_HANDLE mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle);
71 70
72#endif /* GNUTLS_HASH_INT_H */ 71#endif /* GNUTLS_HASH_INT_H */
diff --git a/src/daemon/https/tls/gnutls_int.h b/src/daemon/https/tls/gnutls_int.h
index 7791b554..a59c95dd 100644
--- a/src/daemon/https/tls/gnutls_int.h
+++ b/src/daemon/https/tls/gnutls_int.h
@@ -128,7 +128,13 @@ typedef enum handshake_state_t
128 STATE70, STATE71 128 STATE70, STATE71
129 } handshake_state_t; 129 } handshake_state_t;
130 130
131#include <gnutls_buffer.h> 131#include <gnutls_str.h>
132
133typedef mhd_gtls_string mhd_gtls_buffer;
134
135#define mhd_gtls_buffer_init(buf) mhd_gtls_string_init(buf, gnutls_malloc, gnutls_realloc, gnutls_free);
136#define mhd_gtls_buffer_clear mhd_gtls_string_clear
137#define mhd_gtls_buffer_append mhd_gtls_string_append_data
132 138
133/* This is the maximum number of algorithms (ciphers or macs etc). 139/* This is the maximum number of algorithms (ciphers or macs etc).
134 * keep it synced with GNUTLS_MAX_ALGORITHM_NUM in gnutls.h 140 * keep it synced with GNUTLS_MAX_ALGORITHM_NUM in gnutls.h
@@ -175,17 +181,17 @@ typedef void (*LOG_FUNC)(int,
175 const char *); 181 const char *);
176 182
177/* Store & Retrieve functions defines: */ 183/* Store & Retrieve functions defines: */
178typedef struct auth_cred_st 184typedef struct mhd_gtls_auth_cred_st
179 { 185 {
180 gnutls_credentials_type_t algorithm; 186 gnutls_credentials_type_t algorithm;
181 187
182 /* the type of credentials depends on algorithm 188 /* the type of credentials depends on algorithm
183 */ 189 */
184 void *credentials; 190 void *credentials;
185 struct auth_cred_st *next; 191 struct mhd_gtls_auth_cred_st *next;
186 } auth_cred_st; 192 } auth_cred_st;
187 193
188struct gnutls_key_st 194struct mhd_gtls_key
189 { 195 {
190 /* For DH KX */ 196 /* For DH KX */
191 gnutls_datum_t key; 197 gnutls_datum_t key;
@@ -229,7 +235,7 @@ struct gnutls_key_st
229 * for a client certificate verify 235 * for a client certificate verify
230 */ 236 */
231 }; 237 };
232typedef struct gnutls_key_st *gnutls_key_st; 238typedef struct mhd_gtls_key * mhd_gtls_key_st;
233 239
234/* STATE (cont) */ 240/* STATE (cont) */
235#include <gnutls_hash_int.h> 241#include <gnutls_hash_int.h>
@@ -276,7 +282,7 @@ typedef struct
276 uint16_t oprfi_client_len; 282 uint16_t oprfi_client_len;
277 opaque *oprfi_server; 283 opaque *oprfi_server;
278 uint16_t oprfi_server_len; 284 uint16_t oprfi_server_len;
279 } tls_ext_st; 285 } mhd_gtls_ext_st;
280 286
281/* This flag indicates for an extension whether 287/* This flag indicates for an extension whether
282 * it is useful to application level or TLS level only. 288 * it is useful to application level or TLS level only.
@@ -288,7 +294,7 @@ typedef enum tls_ext_parse_type_t
288 EXTENSION_ANY, 294 EXTENSION_ANY,
289 EXTENSION_APPLICATION, 295 EXTENSION_APPLICATION,
290 EXTENSION_TLS 296 EXTENSION_TLS
291 } tls_ext_parse_type_t; 297 } mhd_gtls_ext_parse_type_t;
292 298
293/* auth_info_t structures now MAY contain malloced 299/* auth_info_t structures now MAY contain malloced
294 * elements. 300 * elements.
@@ -335,7 +341,7 @@ typedef struct
335 opaque session_id[TLS_MAX_SESSION_ID_SIZE]; 341 opaque session_id[TLS_MAX_SESSION_ID_SIZE];
336 uint8_t session_id_size; 342 uint8_t session_id_size;
337 time_t timestamp; 343 time_t timestamp;
338 tls_ext_st extensions; 344 mhd_gtls_ext_st extensions;
339 345
340 /* The send size is the one requested by the programmer. 346 /* The send size is the one requested by the programmer.
341 * The recv size is the one negotiated with the peer. 347 * The recv size is the one negotiated with the peer.
@@ -347,7 +353,7 @@ typedef struct
347 gnutls_protocol_t version; /* moved here */ 353 gnutls_protocol_t version; /* moved here */
348 /* For TLS/IA. XXX: Move to IA credential? */ 354 /* For TLS/IA. XXX: Move to IA credential? */
349 opaque inner_secret[TLS_MASTER_SIZE]; 355 opaque inner_secret[TLS_MASTER_SIZE];
350 } security_parameters_st; 356 } mhd_gtls_security_param_st;
351 357
352/* This structure holds the generated keys 358/* This structure holds the generated keys
353 */ 359 */
@@ -363,7 +369,7 @@ typedef struct
363 * been generated. Non zero 369 * been generated. Non zero
364 * otherwise. 370 * otherwise.
365 */ 371 */
366 } cipher_specs_st; 372 } mhd_gtls_cipher_specs_st;
367 373
368typedef struct 374typedef struct
369 { 375 {
@@ -375,25 +381,25 @@ typedef struct
375 gnutls_datum_t write_mac_secret; 381 gnutls_datum_t write_mac_secret;
376 uint64 read_sequence_number; 382 uint64 read_sequence_number;
377 uint64 write_sequence_number; 383 uint64 write_sequence_number;
378 } conn_stat_st; 384 } mhd_gtls_conn_stat_st;
379 385
380typedef struct 386typedef struct
381 { 387 {
382 unsigned int priority[MAX_ALGOS]; 388 unsigned int priority[MAX_ALGOS];
383 unsigned int num_algorithms; 389 unsigned int num_algorithms;
384 } priority_st; 390 } mhd_gtls_priority_st;
385 391
386/* For the external api */ 392/* For the external api */
387struct gnutls_priority_st 393struct MHD_gtls_priority_st
388 { 394 {
389 priority_st cipher; 395 mhd_gtls_priority_st cipher;
390 priority_st mac; 396 mhd_gtls_priority_st mac;
391 priority_st kx; 397 mhd_gtls_priority_st kx;
392 priority_st compression; 398 mhd_gtls_priority_st compression;
393 priority_st protocol; 399 mhd_gtls_priority_st protocol;
394 400
395 /* certificate type : x509, OpenPGP, etc. */ 401 /* certificate type : x509, OpenPGP, etc. */
396 priority_st cert_type; 402 mhd_gtls_priority_st cert_type;
397 403
398 /* to disable record padding */ 404 /* to disable record padding */
399 int no_padding; 405 int no_padding;
@@ -401,20 +407,20 @@ struct gnutls_priority_st
401 407
402/* DH and RSA parameters types. 408/* DH and RSA parameters types.
403 */ 409 */
404typedef struct gnutls_dh_params_int 410typedef struct MHD_gtls_dh_params_int
405 { 411 {
406 /* [0] is the prime, [1] is the generator. 412 /* [0] is the prime, [1] is the generator.
407 */ 413 */
408 mpi_t params[2]; 414 mpi_t params[2];
409 } dh_params_st; 415 } mhd_gtls_dh_params_st;
410 416
411typedef struct 417typedef struct
412 { 418 {
413 gnutls_dh_params_t dh_params; 419 mhd_gtls_dh_params_t dh_params;
414 int free_dh_params; 420 int free_dh_params;
415 gnutls_rsa_params_t rsa_params; 421 mhd_gtls_rsa_params_t rsa_params;
416 int free_rsa_params; 422 int free_rsa_params;
417 } internal_params_st; 423 } mhd_gtls_internal_params_st;
418 424
419typedef struct 425typedef struct
420 { 426 {
@@ -424,18 +430,18 @@ typedef struct
424 /* this holds the length of the handshake packet */ 430 /* this holds the length of the handshake packet */
425 size_t packet_length; 431 size_t packet_length;
426 gnutls_handshake_description_t recv_type; 432 gnutls_handshake_description_t recv_type;
427 } handshake_header_buffer_st; 433 } mhd_gtls_handshake_header_buffer_st;
428 434
429typedef struct 435typedef struct
430 { 436 {
431 gnutls_buffer application_data_buffer; /* holds data to be delivered to application layer */ 437 mhd_gtls_buffer application_data_buffer; /* holds data to be delivered to application layer */
432 gnutls_buffer handshake_hash_buffer; /* used to keep the last received handshake 438 mhd_gtls_buffer handshake_hash_buffer; /* used to keep the last received handshake
433 * message */ 439 * message */
434 mac_hd_t handshake_mac_handle_sha; /* hash of the handshake messages */ 440 mac_hd_t handshake_mac_handle_sha; /* hash of the handshake messages */
435 mac_hd_t handshake_mac_handle_md5; /* hash of the handshake messages */ 441 mac_hd_t handshake_mac_handle_md5; /* hash of the handshake messages */
436 442
437 gnutls_buffer handshake_data_buffer; /* this is a buffer that holds the current handshake message */ 443 mhd_gtls_buffer handshake_data_buffer; /* this is a buffer that holds the current handshake message */
438 gnutls_buffer ia_data_buffer; /* holds inner application data (TLS/IA) */ 444 mhd_gtls_buffer ia_data_buffer; /* holds inner application data (TLS/IA) */
439 resumable_session_t resumable; /* TRUE or FALSE - if we can resume that session */ 445 resumable_session_t resumable; /* TRUE or FALSE - if we can resume that session */
440 handshake_state_t handshake_state; /* holds 446 handshake_state_t handshake_state; /* holds
441 * a number which indicates where 447 * a number which indicates where
@@ -463,11 +469,11 @@ typedef struct
463 gnutls_compression_method_t compression_method; 469 gnutls_compression_method_t compression_method;
464 470
465 /* priorities */ 471 /* priorities */
466 struct gnutls_priority_st priorities; 472 struct MHD_gtls_priority_st priorities;
467 473
468 /* resumed session */ 474 /* resumed session */
469 resumable_session_t resumed; /* RESUME_TRUE or FALSE - if we are resuming a session */ 475 resumable_session_t resumed; /* RESUME_TRUE or FALSE - if we are resuming a session */
470 security_parameters_st resumed_security_parameters; 476 mhd_gtls_security_param_st resumed_security_parameters;
471 477
472 /* sockets internals */ 478 /* sockets internals */
473 int lowat; 479 int lowat;
@@ -475,19 +481,19 @@ typedef struct
475 /* These buffers are used in the handshake 481 /* These buffers are used in the handshake
476 * protocol only. freed using _gnutls_handshake_io_buffer_clear(); 482 * protocol only. freed using _gnutls_handshake_io_buffer_clear();
477 */ 483 */
478 gnutls_buffer handshake_send_buffer; 484 mhd_gtls_buffer handshake_send_buffer;
479 size_t handshake_send_buffer_prev_size; 485 size_t handshake_send_buffer_prev_size;
480 content_type_t handshake_send_buffer_type; 486 content_type_t handshake_send_buffer_type;
481 gnutls_handshake_description_t handshake_send_buffer_htype; 487 gnutls_handshake_description_t handshake_send_buffer_htype;
482 content_type_t handshake_recv_buffer_type; 488 content_type_t handshake_recv_buffer_type;
483 gnutls_handshake_description_t handshake_recv_buffer_htype; 489 gnutls_handshake_description_t handshake_recv_buffer_htype;
484 gnutls_buffer handshake_recv_buffer; 490 mhd_gtls_buffer handshake_recv_buffer;
485 491
486 /* this buffer holds a record packet -mostly used for 492 /* this buffer holds a record packet -mostly used for
487 * non blocking IO. 493 * non blocking IO.
488 */ 494 */
489 gnutls_buffer record_recv_buffer; 495 mhd_gtls_buffer record_recv_buffer;
490 gnutls_buffer record_send_buffer; /* holds cached data 496 mhd_gtls_buffer record_send_buffer; /* holds cached data
491 * for the gnutls_io_write_buffered() 497 * for the gnutls_io_write_buffered()
492 * function. 498 * function.
493 */ 499 */
@@ -504,7 +510,7 @@ typedef struct
504 int have_peeked_data; 510 int have_peeked_data;
505 511
506 int expire_time; /* after expire_time seconds this session will expire */ 512 int expire_time; /* after expire_time seconds this session will expire */
507 struct mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */ 513 struct mhd_gtls_mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */
508 514
509 /* TODO rm */ 515 /* TODO rm */
510 int v2_hello; /* 0 if the client hello is v3+. 516 int v2_hello; /* 0 if the client hello is v3+.
@@ -512,7 +518,7 @@ typedef struct
512 */ 518 */
513 /* keeps the headers of the handshake packet 519 /* keeps the headers of the handshake packet
514 */ 520 */
515 handshake_header_buffer_st handshake_header_buffer; 521 mhd_gtls_handshake_header_buffer_st handshake_header_buffer;
516 522
517 /* this is the highest version available 523 /* this is the highest version available
518 * to the peer. (advertized version). 524 * to the peer. (advertized version).
@@ -529,7 +535,7 @@ typedef struct
529 int send_cert_req; 535 int send_cert_req;
530 536
531 /* bits to use for DHE and DHA 537 /* bits to use for DHE and DHA
532 * use _gnutls_dh_get_prime_bits() and gnutls_dh_set_prime_bits() 538 * use _gnutls_dh_get_prime_bits() and MHD_gnutls_dh_set_prime_bits()
533 * to access it. 539 * to access it.
534 */ 540 */
535 uint16_t dh_prime_bits; 541 uint16_t dh_prime_bits;
@@ -538,22 +544,14 @@ typedef struct
538 544
539 /* PUSH & PULL functions. 545 /* PUSH & PULL functions.
540 */ 546 */
541 gnutls_pull_func _gnutls_pull_func; 547 mhd_gtls_pull_func _gnutls_pull_func;
542 gnutls_push_func _gnutls_push_func; 548 mhd_gtls_push_func _gnutls_push_func;
543 /* Holds the first argument of PUSH and PULL 549 /* Holds the first argument of PUSH and PULL
544 * functions; 550 * functions;
545 */ 551 */
546 gnutls_transport_ptr_t transport_recv_ptr; 552 gnutls_transport_ptr_t transport_recv_ptr;
547 gnutls_transport_ptr_t transport_send_ptr; 553 gnutls_transport_ptr_t transport_send_ptr;
548 554
549 /* STORE & RETRIEVE functions. Only used if other
550 * backend than gdbm is used.
551 */
552 gnutls_db_store_func db_store_func;
553 gnutls_db_retr_func db_retrieve_func;
554 gnutls_db_remove_func db_remove_func;
555 void *db_ptr;
556
557 /* post client hello callback (server side only) 555 /* post client hello callback (server side only)
558 */ 556 */
559 gnutls_handshake_post_client_hello_func user_hello_func; 557 gnutls_handshake_post_client_hello_func user_hello_func;
@@ -564,7 +562,7 @@ typedef struct
564 uint16_t proposed_record_size; 562 uint16_t proposed_record_size;
565 563
566 /* holds the selected certificate and key. 564 /* holds the selected certificate and key.
567 * use _gnutls_selected_certs_deinit() and _gnutls_selected_certs_set() 565 * use mhd_gtls_selected_certs_deinit() and mhd_gtls_selected_certs_set()
568 * to change them. 566 * to change them.
569 */ 567 */
570 gnutls_cert *selected_cert_list; 568 gnutls_cert *selected_cert_list;
@@ -604,7 +602,7 @@ typedef struct
604 /* This callback will be used (if set) to receive an 602 /* This callback will be used (if set) to receive an
605 * openpgp key. (if the peer sends a fingerprint) 603 * openpgp key. (if the peer sends a fingerprint)
606 */ 604 */
607 gnutls_openpgp_recv_key_func openpgp_recv_key_func; 605 mhd_gtls_openpgp_recv_key_func openpgp_recv_key_func;
608 606
609 /* If non zero the server will not advertize the CA's he 607 /* If non zero the server will not advertize the CA's he
610 * trusts (do not send an RDN sequence). 608 * trusts (do not send an RDN sequence).
@@ -624,7 +622,7 @@ typedef struct
624 * credentials structure, or from a callback. That is to 622 * credentials structure, or from a callback. That is to
625 * minimize external calls. 623 * minimize external calls.
626 */ 624 */
627 internal_params_st params; 625 mhd_gtls_internal_params_st params;
628 626
629 /* This buffer is used by the record recv functions, 627 /* This buffer is used by the record recv functions,
630 * as a temporary store buffer. 628 * as a temporary store buffer.
@@ -633,7 +631,7 @@ typedef struct
633 631
634 /* To avoid using global variables, and especially on Windows where 632 /* To avoid using global variables, and especially on Windows where
635 * the application may use a different errno variable than GnuTLS, 633 * the application may use a different errno variable than GnuTLS,
636 * it is possible to use gnutls_transport_set_errno to set a 634 * it is possible to use MHD_gnutls_transport_set_errno to set a
637 * session-specific errno variable in the user-replaceable push/pull 635 * session-specific errno variable in the user-replaceable push/pull
638 * functions. This value is used by the send/recv functions. (The 636 * functions. This value is used by the send/recv functions. (The
639 * strange name of this variable is because 'errno' is typically 637 * strange name of this variable is because 'errno' is typically
@@ -643,28 +641,28 @@ typedef struct
643 641
644 /* Function used to perform public-key signing operation during 642 /* Function used to perform public-key signing operation during
645 handshake. Used by gnutls_sig.c:_gnutls_tls_sign(), see also 643 handshake. Used by gnutls_sig.c:_gnutls_tls_sign(), see also
646 gnutls_sign_callback_set(). */ 644 MHD_gtls_sign_callback_set(). */
647 gnutls_sign_func sign_func; 645 gnutls_sign_func sign_func;
648 void *sign_func_userdata; 646 void *sign_func_userdata;
649 647
650 /* If you add anything here, check _gnutls_handshake_internal_state_clear(). 648 /* If you add anything here, check mhd_gtls_handshake_internal_state_clear().
651 */ 649 */
652 } internals_st; 650 } mhd_gtls_internals_st;
653 651
654struct gnutls_session_int 652struct MHD_gtls_session_int
655 { 653 {
656 security_parameters_st security_parameters; 654 mhd_gtls_security_param_st security_parameters;
657 cipher_specs_st cipher_specs; 655 mhd_gtls_cipher_specs_st cipher_specs;
658 conn_stat_st connection_state; 656 mhd_gtls_conn_stat_st connection_state;
659 internals_st internals; 657 mhd_gtls_internals_st internals;
660 gnutls_key_st key; 658 mhd_gtls_key_st key;
661 }; 659 };
662 660
663/* functions */ 661/* functions */
664void _gnutls_set_current_version(gnutls_session_t session, 662void mhd_gtls_set_current_version(mhd_gtls_session_t session,
665 gnutls_protocol_t version); 663 gnutls_protocol_t version);
666 664
667void _gnutls_free_auth_info(gnutls_session_t session); 665void mhd_gtls_free_auth_info(mhd_gtls_session_t session);
668 666
669/* These two macros return the advertized TLS version of 667/* These two macros return the advertized TLS version of
670 * the peer. 668 * the peer.
@@ -679,8 +677,8 @@ void _gnutls_free_auth_info(gnutls_session_t session);
679 session->internals.adv_version_major = major; \ 677 session->internals.adv_version_major = major; \
680 session->internals.adv_version_minor = minor 678 session->internals.adv_version_minor = minor
681 679
682void _gnutls_set_adv_version(gnutls_session_t, 680void mhd_gtls_set_adv_version(mhd_gtls_session_t,
683 gnutls_protocol_t); 681 gnutls_protocol_t);
684gnutls_protocol_t _gnutls_get_adv_version(gnutls_session_t); 682gnutls_protocol_t mhd_gtls_get_adv_version(mhd_gtls_session_t);
685 683
686#endif /* GNUTLS_INT_H */ 684#endif /* GNUTLS_INT_H */
diff --git a/src/daemon/https/tls/gnutls_kx.c b/src/daemon/https/tls/gnutls_kx.c
index 2153a791..ad42e5a1 100644
--- a/src/daemon/https/tls/gnutls_kx.c
+++ b/src/daemon/https/tls/gnutls_kx.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25/* This file contains functions which are wrappers for the key exchange 25/* This file contains functions which are wrappers for the key exchange
26 * part of TLS. They are called by the handshake functions (gnutls_handshake) 26 * part of TLS. They are called by the handshake functions (MHD_gnutls_handshake)
27 */ 27 */
28 28
29#include "gnutls_int.h" 29#include "gnutls_int.h"
@@ -42,10 +42,10 @@
42 */ 42 */
43 43
44#define MASTER_SECRET "master secret" 44#define MASTER_SECRET "master secret"
45static int generate_normal_master (gnutls_session_t session, int); 45static int generate_normal_master (mhd_gtls_session_t session, int);
46 46
47int 47int
48_gnutls_generate_master (gnutls_session_t session, int keep_premaster) 48mhd_gtls_generate_master (mhd_gtls_session_t session, int keep_premaster)
49{ 49{
50 if (session->internals.resumed == RESUME_FALSE) 50 if (session->internals.resumed == RESUME_FALSE)
51 return generate_normal_master (session, keep_premaster); 51 return generate_normal_master (session, keep_premaster);
@@ -56,22 +56,22 @@ _gnutls_generate_master (gnutls_session_t session, int keep_premaster)
56 */ 56 */
57#define PREMASTER session->key->key 57#define PREMASTER session->key->key
58static int 58static int
59generate_normal_master (gnutls_session_t session, int keep_premaster) 59generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
60{ 60{
61 int ret = 0; 61 int ret = 0;
62 char buf[512]; 62 char buf[512];
63 63
64 _gnutls_hard_log ("INT: PREMASTER SECRET[%d]: %s\n", PREMASTER.size, 64 _gnutls_hard_log ("INT: PREMASTER SECRET[%d]: %s\n", PREMASTER.size,
65 _gnutls_bin2hex (PREMASTER.data, PREMASTER.size, buf, 65 mhd_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf,
66 sizeof (buf))); 66 sizeof (buf)));
67 _gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32, 67 _gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32,
68 _gnutls_bin2hex (session->security_parameters. 68 mhd_gtls_bin2hex (session->security_parameters.
69 client_random, 32, buf, sizeof (buf))); 69 client_random, 32, buf, sizeof (buf)));
70 _gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32, 70 _gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32,
71 _gnutls_bin2hex (session->security_parameters. 71 mhd_gtls_bin2hex (session->security_parameters.
72 server_random, 32, buf, sizeof (buf))); 72 server_random, 32, buf, sizeof (buf)));
73 73
74 if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3) 74 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3)
75 { 75 {
76 opaque rnd[2 * TLS_RANDOM_SIZE + 1]; 76 opaque rnd[2 * TLS_RANDOM_SIZE + 1];
77 77
@@ -81,7 +81,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
81 session->security_parameters.server_random, TLS_RANDOM_SIZE); 81 session->security_parameters.server_random, TLS_RANDOM_SIZE);
82 82
83 ret = 83 ret =
84 _gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size, 84 mhd_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size,
85 rnd, 2 * TLS_RANDOM_SIZE, 85 rnd, 2 * TLS_RANDOM_SIZE,
86 TLS_MASTER_SIZE, 86 TLS_MASTER_SIZE,
87 session->security_parameters. 87 session->security_parameters.
@@ -107,7 +107,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
107 _gnutls_hard_log ("INT: CLIENT OPRFI[%d]: %s\n", 107 _gnutls_hard_log ("INT: CLIENT OPRFI[%d]: %s\n",
108 session->security_parameters. 108 session->security_parameters.
109 extensions.oprfi_server_len, 109 extensions.oprfi_server_len,
110 _gnutls_bin2hex (session->security_parameters. 110 mhd_gtls_bin2hex (session->security_parameters.
111 extensions.oprfi_client, 111 extensions.oprfi_client,
112 session->security_parameters. 112 session->security_parameters.
113 extensions.oprfi_client_len, 113 extensions.oprfi_client_len,
@@ -115,7 +115,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
115 _gnutls_hard_log ("INT: SERVER OPRFI[%d]: %s\n", 115 _gnutls_hard_log ("INT: SERVER OPRFI[%d]: %s\n",
116 session->security_parameters. 116 session->security_parameters.
117 extensions.oprfi_server_len, 117 extensions.oprfi_server_len,
118 _gnutls_bin2hex (session->security_parameters. 118 mhd_gtls_bin2hex (session->security_parameters.
119 extensions.oprfi_server, 119 extensions.oprfi_server,
120 session->security_parameters. 120 session->security_parameters.
121 extensions.oprfi_server_len, 121 extensions.oprfi_server_len,
@@ -135,7 +135,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
135 session->security_parameters.extensions.oprfi_server, 135 session->security_parameters.extensions.oprfi_server,
136 session->security_parameters.extensions.oprfi_server_len); 136 session->security_parameters.extensions.oprfi_server_len);
137 137
138 ret = _gnutls_PRF (session, PREMASTER.data, PREMASTER.size, 138 ret = mhd_gtls_PRF (session, PREMASTER.data, PREMASTER.size,
139 MASTER_SECRET, strlen (MASTER_SECRET), 139 MASTER_SECRET, strlen (MASTER_SECRET),
140 rnd, rndlen, TLS_MASTER_SIZE, 140 rnd, rndlen, TLS_MASTER_SIZE,
141 session->security_parameters.master_secret); 141 session->security_parameters.master_secret);
@@ -152,7 +152,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
152 session->security_parameters.server_random, TLS_RANDOM_SIZE); 152 session->security_parameters.server_random, TLS_RANDOM_SIZE);
153 153
154 ret = 154 ret =
155 _gnutls_PRF (session, PREMASTER.data, PREMASTER.size, 155 mhd_gtls_PRF (session, PREMASTER.data, PREMASTER.size,
156 MASTER_SECRET, strlen (MASTER_SECRET), 156 MASTER_SECRET, strlen (MASTER_SECRET),
157 rnd, 2 * TLS_RANDOM_SIZE, TLS_MASTER_SIZE, 157 rnd, 2 * TLS_RANDOM_SIZE, TLS_MASTER_SIZE,
158 session->security_parameters.master_secret); 158 session->security_parameters.master_secret);
@@ -169,7 +169,7 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
169 return ret; 169 return ret;
170 170
171 _gnutls_hard_log ("INT: MASTER SECRET: %s\n", 171 _gnutls_hard_log ("INT: MASTER SECRET: %s\n",
172 _gnutls_bin2hex (session->security_parameters. 172 mhd_gtls_bin2hex (session->security_parameters.
173 master_secret, TLS_MASTER_SIZE, buf, 173 master_secret, TLS_MASTER_SIZE, buf,
174 sizeof (buf))); 174 sizeof (buf)));
175 175
@@ -182,13 +182,13 @@ generate_normal_master (gnutls_session_t session, int keep_premaster)
182 * by the selected ciphersuite. 182 * by the selected ciphersuite.
183 */ 183 */
184int 184int
185_gnutls_send_server_kx_message (gnutls_session_t session, int again) 185mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again)
186{ 186{
187 uint8_t *data = NULL; 187 uint8_t *data = NULL;
188 int data_size = 0; 188 int data_size = 0;
189 int ret = 0; 189 int ret = 0;
190 190
191 if (session->internals.auth_struct->gnutls_generate_server_kx == NULL) 191 if (session->internals.auth_struct->mhd_gtls_gen_server_kx == NULL)
192 return 0; 192 return 0;
193 193
194 data = NULL; 194 data = NULL;
@@ -198,7 +198,7 @@ _gnutls_send_server_kx_message (gnutls_session_t session, int again)
198 { 198 {
199 data_size = 199 data_size =
200 session->internals.auth_struct-> 200 session->internals.auth_struct->
201 gnutls_generate_server_kx (session, &data); 201 mhd_gtls_gen_server_kx (session, &data);
202 202
203 if (data_size == GNUTLS_E_INT_RET_0) 203 if (data_size == GNUTLS_E_INT_RET_0)
204 { 204 {
@@ -214,7 +214,7 @@ _gnutls_send_server_kx_message (gnutls_session_t session, int again)
214 } 214 }
215 215
216 ret = 216 ret =
217 _gnutls_send_handshake (session, data, data_size, 217 mhd_gtls_send_handshake (session, data, data_size,
218 GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE); 218 GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE);
219 gnutls_free (data); 219 gnutls_free (data);
220 220
@@ -230,14 +230,14 @@ _gnutls_send_server_kx_message (gnutls_session_t session, int again)
230 * client. 230 * client.
231 */ 231 */
232int 232int
233_gnutls_send_server_certificate_request (gnutls_session_t session, int again) 233mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session, int again)
234{ 234{
235 uint8_t *data = NULL; 235 uint8_t *data = NULL;
236 int data_size = 0; 236 int data_size = 0;
237 int ret = 0; 237 int ret = 0;
238 238
239 if (session->internals.auth_struct-> 239 if (session->internals.auth_struct->
240 gnutls_generate_server_certificate_request == NULL) 240 mhd_gtls_gen_server_certificate_request == NULL)
241 return 0; 241 return 0;
242 242
243 if (session->internals.send_cert_req <= 0) 243 if (session->internals.send_cert_req <= 0)
@@ -250,7 +250,7 @@ _gnutls_send_server_certificate_request (gnutls_session_t session, int again)
250 { 250 {
251 data_size = 251 data_size =
252 session->internals.auth_struct-> 252 session->internals.auth_struct->
253 gnutls_generate_server_certificate_request (session, &data); 253 mhd_gtls_gen_server_certificate_request (session, &data);
254 254
255 if (data_size < 0) 255 if (data_size < 0)
256 { 256 {
@@ -259,7 +259,7 @@ _gnutls_send_server_certificate_request (gnutls_session_t session, int again)
259 } 259 }
260 } 260 }
261 ret = 261 ret =
262 _gnutls_send_handshake (session, data, data_size, 262 mhd_gtls_send_handshake (session, data, data_size,
263 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST); 263 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST);
264 gnutls_free (data); 264 gnutls_free (data);
265 265
@@ -276,13 +276,13 @@ _gnutls_send_server_certificate_request (gnutls_session_t session, int again)
276 * exchange message 276 * exchange message
277 */ 277 */
278int 278int
279_gnutls_send_client_kx_message (gnutls_session_t session, int again) 279mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again)
280{ 280{
281 uint8_t *data; 281 uint8_t *data;
282 int data_size; 282 int data_size;
283 int ret = 0; 283 int ret = 0;
284 284
285 if (session->internals.auth_struct->gnutls_generate_client_kx == NULL) 285 if (session->internals.auth_struct->mhd_gtls_gen_client_kx == NULL)
286 return 0; 286 return 0;
287 287
288 288
@@ -293,7 +293,7 @@ _gnutls_send_client_kx_message (gnutls_session_t session, int again)
293 { 293 {
294 data_size = 294 data_size =
295 session->internals.auth_struct-> 295 session->internals.auth_struct->
296 gnutls_generate_client_kx (session, &data); 296 mhd_gtls_gen_client_kx (session, &data);
297 if (data_size < 0) 297 if (data_size < 0)
298 { 298 {
299 gnutls_assert (); 299 gnutls_assert ();
@@ -301,7 +301,7 @@ _gnutls_send_client_kx_message (gnutls_session_t session, int again)
301 } 301 }
302 } 302 }
303 ret = 303 ret =
304 _gnutls_send_handshake (session, data, data_size, 304 mhd_gtls_send_handshake (session, data, data_size,
305 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE); 305 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE);
306 gnutls_free (data); 306 gnutls_free (data);
307 307
@@ -319,7 +319,7 @@ _gnutls_send_client_kx_message (gnutls_session_t session, int again)
319 * verify message 319 * verify message
320 */ 320 */
321int 321int
322_gnutls_send_client_certificate_verify (gnutls_session_t session, int again) 322mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session, int again)
323{ 323{
324 uint8_t *data; 324 uint8_t *data;
325 int ret = 0; 325 int ret = 0;
@@ -335,7 +335,7 @@ _gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
335 if (session->key->certificate_requested == 0) 335 if (session->key->certificate_requested == 0)
336 return 0; 336 return 0;
337 337
338 if (session->internals.auth_struct->gnutls_generate_client_cert_vrfy == 338 if (session->internals.auth_struct->mhd_gtls_gen_client_cert_vrfy ==
339 NULL) 339 NULL)
340 { 340 {
341 gnutls_assert (); 341 gnutls_assert ();
@@ -350,7 +350,7 @@ _gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
350 { 350 {
351 data_size = 351 data_size =
352 session->internals.auth_struct-> 352 session->internals.auth_struct->
353 gnutls_generate_client_cert_vrfy (session, &data); 353 mhd_gtls_gen_client_cert_vrfy (session, &data);
354 if (data_size < 0) 354 if (data_size < 0)
355 { 355 {
356 gnutls_assert (); 356 gnutls_assert ();
@@ -361,7 +361,7 @@ _gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
361 361
362 } 362 }
363 ret = 363 ret =
364 _gnutls_send_handshake (session, data, 364 mhd_gtls_send_handshake (session, data,
365 data_size, GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY); 365 data_size, GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY);
366 gnutls_free (data); 366 gnutls_free (data);
367 367
@@ -370,18 +370,18 @@ _gnutls_send_client_certificate_verify (gnutls_session_t session, int again)
370 370
371 371
372int 372int
373_gnutls_recv_server_kx_message (gnutls_session_t session) 373mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session)
374{ 374{
375 uint8_t *data = NULL; 375 uint8_t *data = NULL;
376 int datasize; 376 int datasize;
377 int ret = 0; 377 int ret = 0;
378 378
379 if (session->internals.auth_struct->gnutls_process_server_kx != NULL) 379 if (session->internals.auth_struct->mhd_gtls_process_server_kx != NULL)
380 { 380 {
381 381
382 /* EXCEPTION FOR RSA_EXPORT cipher suite 382 /* EXCEPTION FOR RSA_EXPORT cipher suite
383 */ 383 */
384 if (_gnutls_session_is_export (session) != 0 && 384 if (mhd_gtls_session_is_export (session) != 0 &&
385 _gnutls_peers_cert_less_512 (session) != 0) 385 _gnutls_peers_cert_less_512 (session) != 0)
386 { 386 {
387 gnutls_assert (); 387 gnutls_assert ();
@@ -389,7 +389,7 @@ _gnutls_recv_server_kx_message (gnutls_session_t session)
389 } 389 }
390 390
391 ret = 391 ret =
392 _gnutls_recv_handshake (session, &data, 392 mhd_gtls_recv_handshake (session, &data,
393 &datasize, 393 &datasize,
394 GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE, 394 GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE,
395 MANDATORY_PACKET); 395 MANDATORY_PACKET);
@@ -401,7 +401,7 @@ _gnutls_recv_server_kx_message (gnutls_session_t session)
401 401
402 ret = 402 ret =
403 session->internals.auth_struct-> 403 session->internals.auth_struct->
404 gnutls_process_server_kx (session, data, datasize); 404 mhd_gtls_process_server_kx (session, data, datasize);
405 gnutls_free (data); 405 gnutls_free (data);
406 406
407 if (ret < 0) 407 if (ret < 0)
@@ -415,18 +415,18 @@ _gnutls_recv_server_kx_message (gnutls_session_t session)
415} 415}
416 416
417int 417int
418_gnutls_recv_server_certificate_request (gnutls_session_t session) 418mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session)
419{ 419{
420 uint8_t *data; 420 uint8_t *data;
421 int datasize; 421 int datasize;
422 int ret = 0; 422 int ret = 0;
423 423
424 if (session->internals.auth_struct-> 424 if (session->internals.auth_struct->
425 gnutls_process_server_certificate_request != NULL) 425 mhd_gtls_process_server_certificate_request != NULL)
426 { 426 {
427 427
428 ret = 428 ret =
429 _gnutls_recv_handshake (session, &data, 429 mhd_gtls_recv_handshake (session, &data,
430 &datasize, 430 &datasize,
431 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST, 431 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST,
432 OPTIONAL_PACKET); 432 OPTIONAL_PACKET);
@@ -438,7 +438,7 @@ _gnutls_recv_server_certificate_request (gnutls_session_t session)
438 438
439 ret = 439 ret =
440 session->internals.auth_struct-> 440 session->internals.auth_struct->
441 gnutls_process_server_certificate_request (session, data, datasize); 441 mhd_gtls_process_server_certificate_request (session, data, datasize);
442 gnutls_free (data); 442 gnutls_free (data);
443 if (ret < 0) 443 if (ret < 0)
444 return ret; 444 return ret;
@@ -448,7 +448,7 @@ _gnutls_recv_server_certificate_request (gnutls_session_t session)
448} 448}
449 449
450int 450int
451_gnutls_recv_client_kx_message (gnutls_session_t session) 451mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
452{ 452{
453 uint8_t *data; 453 uint8_t *data;
454 int datasize; 454 int datasize;
@@ -456,11 +456,11 @@ _gnutls_recv_client_kx_message (gnutls_session_t session)
456 456
457 457
458 /* Do key exchange only if the algorithm permits it */ 458 /* Do key exchange only if the algorithm permits it */
459 if (session->internals.auth_struct->gnutls_process_client_kx != NULL) 459 if (session->internals.auth_struct->mhd_gtls_process_client_kx != NULL)
460 { 460 {
461 461
462 ret = 462 ret =
463 _gnutls_recv_handshake (session, &data, 463 mhd_gtls_recv_handshake (session, &data,
464 &datasize, 464 &datasize,
465 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE, 465 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE,
466 MANDATORY_PACKET); 466 MANDATORY_PACKET);
@@ -469,7 +469,7 @@ _gnutls_recv_client_kx_message (gnutls_session_t session)
469 469
470 ret = 470 ret =
471 session->internals.auth_struct-> 471 session->internals.auth_struct->
472 gnutls_process_client_kx (session, data, datasize); 472 mhd_gtls_process_client_kx (session, data, datasize);
473 gnutls_free (data); 473 gnutls_free (data);
474 if (ret < 0) 474 if (ret < 0)
475 return ret; 475 return ret;
@@ -483,7 +483,7 @@ _gnutls_recv_client_kx_message (gnutls_session_t session)
483/* This is called when we want send our certificate 483/* This is called when we want send our certificate
484 */ 484 */
485int 485int
486_gnutls_send_client_certificate (gnutls_session_t session, int again) 486mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
487{ 487{
488 uint8_t *data = NULL; 488 uint8_t *data = NULL;
489 int data_size = 0; 489 int data_size = 0;
@@ -494,7 +494,7 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
494 return 0; 494 return 0;
495 495
496 if (session->internals.auth_struct-> 496 if (session->internals.auth_struct->
497 gnutls_generate_client_certificate == NULL) 497 mhd_gtls_gen_client_certificate == NULL)
498 return 0; 498 return 0;
499 499
500 data = NULL; 500 data = NULL;
@@ -502,14 +502,14 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
502 502
503 if (again == 0) 503 if (again == 0)
504 { 504 {
505 if (gnutls_protocol_get_version (session) != MHD_GNUTLS_SSL3 || 505 if (MHD_gnutls_protocol_get_version (session) != MHD_GNUTLS_SSL3 ||
506 session->internals.selected_cert_list_length > 0) 506 session->internals.selected_cert_list_length > 0)
507 { 507 {
508 /* TLS 1.0 or SSL 3.0 with a valid certificate 508 /* TLS 1.0 or SSL 3.0 with a valid certificate
509 */ 509 */
510 data_size = 510 data_size =
511 session->internals.auth_struct-> 511 session->internals.auth_struct->
512 gnutls_generate_client_certificate (session, &data); 512 mhd_gtls_gen_client_certificate (session, &data);
513 513
514 if (data_size < 0) 514 if (data_size < 0)
515 { 515 {
@@ -523,11 +523,11 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
523 * no certificate alert instead of an 523 * no certificate alert instead of an
524 * empty certificate. 524 * empty certificate.
525 */ 525 */
526 if (gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3 && 526 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3 &&
527 session->internals.selected_cert_list_length == 0) 527 session->internals.selected_cert_list_length == 0)
528 { 528 {
529 ret = 529 ret =
530 gnutls_alert_send (session, GNUTLS_AL_WARNING, 530 MHD_gnutls_alert_send (session, GNUTLS_AL_WARNING,
531 GNUTLS_A_SSL3_NO_CERTIFICATE); 531 GNUTLS_A_SSL3_NO_CERTIFICATE);
532 532
533 } 533 }
@@ -535,7 +535,7 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
535 { /* TLS 1.0 or SSL 3.0 with a valid certificate 535 { /* TLS 1.0 or SSL 3.0 with a valid certificate
536 */ 536 */
537 ret = 537 ret =
538 _gnutls_send_handshake (session, data, data_size, 538 mhd_gtls_send_handshake (session, data, data_size,
539 GNUTLS_HANDSHAKE_CERTIFICATE_PKT); 539 GNUTLS_HANDSHAKE_CERTIFICATE_PKT);
540 gnutls_free (data); 540 gnutls_free (data);
541 } 541 }
@@ -553,7 +553,7 @@ _gnutls_send_client_certificate (gnutls_session_t session, int again)
553/* This is called when we want send our certificate 553/* This is called when we want send our certificate
554 */ 554 */
555int 555int
556_gnutls_send_server_certificate (gnutls_session_t session, int again) 556mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again)
557{ 557{
558 uint8_t *data = NULL; 558 uint8_t *data = NULL;
559 int data_size = 0; 559 int data_size = 0;
@@ -561,7 +561,7 @@ _gnutls_send_server_certificate (gnutls_session_t session, int again)
561 561
562 562
563 if (session->internals.auth_struct-> 563 if (session->internals.auth_struct->
564 gnutls_generate_server_certificate == NULL) 564 mhd_gtls_gen_server_certificate == NULL)
565 return 0; 565 return 0;
566 566
567 data = NULL; 567 data = NULL;
@@ -571,7 +571,7 @@ _gnutls_send_server_certificate (gnutls_session_t session, int again)
571 { 571 {
572 data_size = 572 data_size =
573 session->internals.auth_struct-> 573 session->internals.auth_struct->
574 gnutls_generate_server_certificate (session, &data); 574 mhd_gtls_gen_server_certificate (session, &data);
575 575
576 if (data_size < 0) 576 if (data_size < 0)
577 { 577 {
@@ -580,7 +580,7 @@ _gnutls_send_server_certificate (gnutls_session_t session, int again)
580 } 580 }
581 } 581 }
582 ret = 582 ret =
583 _gnutls_send_handshake (session, data, data_size, 583 mhd_gtls_send_handshake (session, data, data_size,
584 GNUTLS_HANDSHAKE_CERTIFICATE_PKT); 584 GNUTLS_HANDSHAKE_CERTIFICATE_PKT);
585 gnutls_free (data); 585 gnutls_free (data);
586 586
@@ -595,7 +595,7 @@ _gnutls_send_server_certificate (gnutls_session_t session, int again)
595 595
596 596
597int 597int
598_gnutls_recv_client_certificate (gnutls_session_t session) 598mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
599{ 599{
600 int datasize; 600 int datasize;
601 opaque *data; 601 opaque *data;
@@ -603,7 +603,7 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
603 int optional; 603 int optional;
604 604
605 if (session->internals.auth_struct-> 605 if (session->internals.auth_struct->
606 gnutls_process_client_certificate != NULL) 606 mhd_gtls_process_client_certificate != NULL)
607 { 607 {
608 608
609 /* if we have not requested a certificate then just return 609 /* if we have not requested a certificate then just return
@@ -619,7 +619,7 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
619 optional = OPTIONAL_PACKET; 619 optional = OPTIONAL_PACKET;
620 620
621 ret = 621 ret =
622 _gnutls_recv_handshake (session, &data, 622 mhd_gtls_recv_handshake (session, &data,
623 &datasize, 623 &datasize,
624 GNUTLS_HANDSHAKE_CERTIFICATE_PKT, optional); 624 GNUTLS_HANDSHAKE_CERTIFICATE_PKT, optional);
625 625
@@ -631,7 +631,7 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
631 */ 631 */
632 if (optional == OPTIONAL_PACKET && 632 if (optional == OPTIONAL_PACKET &&
633 ret == GNUTLS_E_WARNING_ALERT_RECEIVED && 633 ret == GNUTLS_E_WARNING_ALERT_RECEIVED &&
634 gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3 && 634 MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_SSL3 &&
635 gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE) 635 gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE)
636 { 636 {
637 637
@@ -666,7 +666,7 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
666 } 666 }
667 ret = 667 ret =
668 session->internals.auth_struct-> 668 session->internals.auth_struct->
669 gnutls_process_client_certificate (session, data, datasize); 669 mhd_gtls_process_client_certificate (session, data, datasize);
670 670
671 gnutls_free (data); 671 gnutls_free (data);
672 if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND) 672 if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND)
@@ -688,18 +688,18 @@ _gnutls_recv_client_certificate (gnutls_session_t session)
688} 688}
689 689
690int 690int
691_gnutls_recv_server_certificate (gnutls_session_t session) 691mhd_gtls_recv_server_certificate (mhd_gtls_session_t session)
692{ 692{
693 int datasize; 693 int datasize;
694 opaque *data; 694 opaque *data;
695 int ret = 0; 695 int ret = 0;
696 696
697 if (session->internals.auth_struct-> 697 if (session->internals.auth_struct->
698 gnutls_process_server_certificate != NULL) 698 mhd_gtls_process_server_certificate != NULL)
699 { 699 {
700 700
701 ret = 701 ret =
702 _gnutls_recv_handshake (session, &data, 702 mhd_gtls_recv_handshake (session, &data,
703 &datasize, 703 &datasize,
704 GNUTLS_HANDSHAKE_CERTIFICATE_PKT, 704 GNUTLS_HANDSHAKE_CERTIFICATE_PKT,
705 MANDATORY_PACKET); 705 MANDATORY_PACKET);
@@ -711,7 +711,7 @@ _gnutls_recv_server_certificate (gnutls_session_t session)
711 711
712 ret = 712 ret =
713 session->internals.auth_struct-> 713 session->internals.auth_struct->
714 gnutls_process_server_certificate (session, data, datasize); 714 mhd_gtls_process_server_certificate (session, data, datasize);
715 gnutls_free (data); 715 gnutls_free (data);
716 if (ret < 0) 716 if (ret < 0)
717 { 717 {
@@ -728,14 +728,14 @@ _gnutls_recv_server_certificate (gnutls_session_t session)
728 * arrive if the peer did not send us a certificate. 728 * arrive if the peer did not send us a certificate.
729 */ 729 */
730int 730int
731_gnutls_recv_client_certificate_verify_message (gnutls_session_t session) 731mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session)
732{ 732{
733 uint8_t *data; 733 uint8_t *data;
734 int datasize; 734 int datasize;
735 int ret = 0; 735 int ret = 0;
736 736
737 737
738 if (session->internals.auth_struct->gnutls_process_client_cert_vrfy != NULL) 738 if (session->internals.auth_struct->mhd_gtls_process_client_cert_vrfy != NULL)
739 { 739 {
740 740
741 if (session->internals.send_cert_req == 0 || 741 if (session->internals.send_cert_req == 0 ||
@@ -745,7 +745,7 @@ _gnutls_recv_client_certificate_verify_message (gnutls_session_t session)
745 } 745 }
746 746
747 ret = 747 ret =
748 _gnutls_recv_handshake (session, &data, 748 mhd_gtls_recv_handshake (session, &data,
749 &datasize, 749 &datasize,
750 GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY, 750 GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY,
751 OPTIONAL_PACKET); 751 OPTIONAL_PACKET);
@@ -762,7 +762,7 @@ _gnutls_recv_client_certificate_verify_message (gnutls_session_t session)
762 762
763 ret = 763 ret =
764 session->internals.auth_struct-> 764 session->internals.auth_struct->
765 gnutls_process_client_cert_vrfy (session, data, datasize); 765 mhd_gtls_process_client_cert_vrfy (session, data, datasize);
766 gnutls_free (data); 766 gnutls_free (data);
767 if (ret < 0) 767 if (ret < 0)
768 return ret; 768 return ret;
diff --git a/src/daemon/https/tls/gnutls_kx.h b/src/daemon/https/tls/gnutls_kx.h
index 45ba68bd..bc99eb5c 100644
--- a/src/daemon/https/tls/gnutls_kx.h
+++ b/src/daemon/https/tls/gnutls_kx.h
@@ -22,18 +22,18 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_send_server_kx_message (gnutls_session_t session, int again); 25int mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again);
26int _gnutls_send_client_kx_message (gnutls_session_t session, int again); 26int mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again);
27int _gnutls_recv_server_kx_message (gnutls_session_t session); 27int mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session);
28int _gnutls_recv_client_kx_message (gnutls_session_t session); 28int mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session);
29int _gnutls_send_client_certificate_verify (gnutls_session_t session, 29int mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
30 int again); 30 int again);
31int _gnutls_send_server_certificate (gnutls_session_t session, int again); 31int mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again);
32int _gnutls_generate_master (gnutls_session_t session, int keep_premaster); 32int mhd_gtls_generate_master (mhd_gtls_session_t session, int keep_premaster);
33int _gnutls_recv_client_certificate (gnutls_session_t session); 33int mhd_gtls_recv_client_certificate (mhd_gtls_session_t session);
34int _gnutls_recv_server_certificate (gnutls_session_t session); 34int mhd_gtls_recv_server_certificate (mhd_gtls_session_t session);
35int _gnutls_send_client_certificate (gnutls_session_t session, int again); 35int mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again);
36int _gnutls_recv_server_certificate_request (gnutls_session_t session); 36int mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session);
37int _gnutls_send_server_certificate_request (gnutls_session_t session, 37int mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
38 int again); 38 int again);
39int _gnutls_recv_client_certificate_verify_message (gnutls_session_t session); 39int mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session);
diff --git a/src/daemon/https/tls/gnutls_mem.c b/src/daemon/https/tls/gnutls_mem.c
index 91a6fa3c..2d7537b8 100644
--- a/src/daemon/https/tls/gnutls_mem.c
+++ b/src/daemon/https/tls/gnutls_mem.c
@@ -32,7 +32,7 @@ gnutls_free_function gnutls_free = free;
32gnutls_realloc_function gnutls_realloc = realloc; 32gnutls_realloc_function gnutls_realloc = realloc;
33 33
34void *(*gnutls_calloc) (size_t, size_t) = calloc; 34void *(*gnutls_calloc) (size_t, size_t) = calloc;
35char *(*gnutls_strdup) (const char *) = _gnutls_strdup; 35char *(*gnutls_strdup) (const char *) = mhd_gtls_strdup;
36 36
37int 37int
38_gnutls_is_secure_mem_null (const void *ign) 38_gnutls_is_secure_mem_null (const void *ign)
@@ -44,7 +44,7 @@ int (*_gnutls_is_secure_memory) (const void *) = _gnutls_is_secure_mem_null;
44 44
45 45
46void * 46void *
47_gnutls_calloc (size_t nmemb, size_t size) 47mhd_gtls_calloc (size_t nmemb, size_t size)
48{ 48{
49 void *ret; 49 void *ret;
50 size *= nmemb; 50 size *= nmemb;
@@ -55,7 +55,7 @@ _gnutls_calloc (size_t nmemb, size_t size)
55} 55}
56 56
57svoid * 57svoid *
58gnutls_secure_calloc (size_t nmemb, size_t size) 58mhd_gtls_secure_calloc (size_t nmemb, size_t size)
59{ 59{
60 svoid *ret; 60 svoid *ret;
61 size *= nmemb; 61 size *= nmemb;
@@ -69,7 +69,7 @@ gnutls_secure_calloc (size_t nmemb, size_t size)
69 * fails. 69 * fails.
70 */ 70 */
71void * 71void *
72gnutls_realloc_fast (void *ptr, size_t size) 72mhd_gtls_realloc_fast (void *ptr, size_t size)
73{ 73{
74 void *ret; 74 void *ret;
75 75
@@ -86,7 +86,7 @@ gnutls_realloc_fast (void *ptr, size_t size)
86} 86}
87 87
88char * 88char *
89_gnutls_strdup (const char *str) 89mhd_gtls_strdup (const char *str)
90{ 90{
91 size_t siz = strlen (str) + 1; 91 size_t siz = strlen (str) + 1;
92 char *ret; 92 char *ret;
@@ -109,7 +109,7 @@ _gnutls_strdup (const char *str)
109 * return a pointer to memory. This function is supposed 109 * return a pointer to memory. This function is supposed
110 * to be used by callbacks. 110 * to be used by callbacks.
111 * 111 *
112 * The allocation function used is the one set by gnutls_global_set_mem_functions(). 112 * The allocation function used is the one set by MHD_gtls_global_set_mem_functions().
113 * 113 *
114 **/ 114 **/
115void * 115void *
@@ -123,7 +123,7 @@ gnutls_malloc (size_t s)
123 * 123 *
124 * This function will free data pointed by ptr. 124 * This function will free data pointed by ptr.
125 * 125 *
126 * The deallocation function used is the one set by gnutls_global_set_mem_functions(). 126 * The deallocation function used is the one set by MHD_gtls_global_set_mem_functions().
127 * 127 *
128 **/ 128 **/
129void 129void
diff --git a/src/daemon/https/tls/gnutls_mem.h b/src/daemon/https/tls/gnutls_mem.h
index f76081e5..2d32d6e1 100644
--- a/src/daemon/https/tls/gnutls_mem.h
+++ b/src/daemon/https/tls/gnutls_mem.h
@@ -60,11 +60,11 @@ extern int (*_gnutls_is_secure_memory) (const void *);
60/* this realloc function will return ptr if size==0, and 60/* this realloc function will return ptr if size==0, and
61 * will free the ptr if the new allocation failed. 61 * will free the ptr if the new allocation failed.
62 */ 62 */
63void *gnutls_realloc_fast (void *ptr, size_t size); 63void * mhd_gtls_realloc_fast (void *ptr, size_t size);
64 64
65svoid *gnutls_secure_calloc (size_t nmemb, size_t size); 65svoid * mhd_gtls_secure_calloc (size_t nmemb, size_t size);
66 66
67void *_gnutls_calloc (size_t nmemb, size_t size); 67void * mhd_gtls_calloc (size_t nmemb, size_t size);
68char *_gnutls_strdup (const char *); 68char * mhd_gtls_strdup (const char *);
69 69
70#endif /* GNUTLS_MEM_H */ 70#endif /* GNUTLS_MEM_H */
diff --git a/src/daemon/https/tls/gnutls_mpi.c b/src/daemon/https/tls/gnutls_mpi.c
index 0d807a18..6e2b5c4f 100644
--- a/src/daemon/https/tls/gnutls_mpi.c
+++ b/src/daemon/https/tls/gnutls_mpi.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37void 37void
38_gnutls_mpi_release (mpi_t * x) 38mhd_gtls_mpi_release (mpi_t * x)
39{ 39{
40 if (*x == NULL) 40 if (*x == NULL)
41 return; 41 return;
@@ -46,7 +46,7 @@ _gnutls_mpi_release (mpi_t * x)
46/* returns zero on success 46/* returns zero on success
47 */ 47 */
48int 48int
49_gnutls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes) 49mhd_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
50{ 50{
51 int ret; 51 int ret;
52 52
@@ -60,7 +60,7 @@ _gnutls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
60/* returns zero on success. Fails if the number is zero. 60/* returns zero on success. Fails if the number is zero.
61 */ 61 */
62int 62int
63_gnutls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes) 63mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
64{ 64{
65 int ret; 65 int ret;
66 66
@@ -72,7 +72,7 @@ _gnutls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
72 */ 72 */
73 if (_gnutls_mpi_get_nbits (*ret_mpi) == 0) 73 if (_gnutls_mpi_get_nbits (*ret_mpi) == 0)
74 { 74 {
75 _gnutls_mpi_release (ret_mpi); 75 mhd_gtls_mpi_release (ret_mpi);
76 return GNUTLS_E_MPI_SCAN_FAILED; 76 return GNUTLS_E_MPI_SCAN_FAILED;
77 } 77 }
78 78
@@ -80,7 +80,7 @@ _gnutls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
80} 80}
81 81
82int 82int
83_gnutls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes) 83mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
84{ 84{
85 int ret; 85 int ret;
86 ret = gcry_mpi_scan (ret_mpi, GCRYMPI_FMT_PGP, buffer, *nbytes, nbytes); 86 ret = gcry_mpi_scan (ret_mpi, GCRYMPI_FMT_PGP, buffer, *nbytes, nbytes);
@@ -91,7 +91,7 @@ _gnutls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
91 */ 91 */
92 if (_gnutls_mpi_get_nbits (*ret_mpi) == 0) 92 if (_gnutls_mpi_get_nbits (*ret_mpi) == 0)
93 { 93 {
94 _gnutls_mpi_release (ret_mpi); 94 mhd_gtls_mpi_release (ret_mpi);
95 return GNUTLS_E_MPI_SCAN_FAILED; 95 return GNUTLS_E_MPI_SCAN_FAILED;
96 } 96 }
97 97
@@ -99,7 +99,7 @@ _gnutls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
99} 99}
100 100
101int 101int
102_gnutls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a) 102mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
103{ 103{
104 int ret; 104 int ret;
105 105
@@ -115,7 +115,7 @@ _gnutls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
115 115
116/* Always has the first bit zero */ 116/* Always has the first bit zero */
117int 117int
118_gnutls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a) 118mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
119{ 119{
120 int ret; 120 int ret;
121 121
@@ -131,7 +131,7 @@ _gnutls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
131 131
132/* Always has the first bit zero */ 132/* Always has the first bit zero */
133int 133int
134_gnutls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a) 134mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
135{ 135{
136 int ret; 136 int ret;
137 opaque *buf = NULL; 137 opaque *buf = NULL;
@@ -160,7 +160,7 @@ _gnutls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
160} 160}
161 161
162int 162int
163_gnutls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a) 163mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
164{ 164{
165 int ret; 165 int ret;
166 opaque *buf = NULL; 166 opaque *buf = NULL;
@@ -225,7 +225,7 @@ _gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
225 } 225 }
226 226
227 s_len = tmpstr_size; 227 s_len = tmpstr_size;
228 if (_gnutls_mpi_scan (ret_mpi, tmpstr, &s_len) != 0) 228 if (mhd_gtls_mpi_scan (ret_mpi, tmpstr, &s_len) != 0)
229 { 229 {
230 gnutls_assert (); 230 gnutls_assert ();
231 gnutls_afree (tmpstr); 231 gnutls_afree (tmpstr);
@@ -248,9 +248,9 @@ _gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
248 248
249 s_len = 0; 249 s_len = 0;
250 if (lz) 250 if (lz)
251 result = _gnutls_mpi_print_lz (NULL, &s_len, mpi); 251 result = mhd_gtls_mpi_print_lz (NULL, &s_len, mpi);
252 else 252 else
253 result = _gnutls_mpi_print (NULL, &s_len, mpi); 253 result = mhd_gtls_mpi_print (NULL, &s_len, mpi);
254 254
255 tmpstr = gnutls_alloca (s_len); 255 tmpstr = gnutls_alloca (s_len);
256 if (tmpstr == NULL) 256 if (tmpstr == NULL)
@@ -260,9 +260,9 @@ _gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
260 } 260 }
261 261
262 if (lz) 262 if (lz)
263 result = _gnutls_mpi_print_lz (tmpstr, &s_len, mpi); 263 result = mhd_gtls_mpi_print_lz (tmpstr, &s_len, mpi);
264 else 264 else
265 result = _gnutls_mpi_print (tmpstr, &s_len, mpi); 265 result = mhd_gtls_mpi_print (tmpstr, &s_len, mpi);
266 266
267 if (result != 0) 267 if (result != 0)
268 { 268 {
diff --git a/src/daemon/https/tls/gnutls_mpi.h b/src/daemon/https/tls/gnutls_mpi.h
index d242e9e9..dc70e36f 100644
--- a/src/daemon/https/tls/gnutls_mpi.h
+++ b/src/daemon/https/tls/gnutls_mpi.h
@@ -60,19 +60,19 @@ typedef gcry_mpi_t mpi_t;
60#define _gnutls_mpi_alloc_like(x) _gnutls_mpi_new(_gnutls_mpi_get_nbits(x)) 60#define _gnutls_mpi_alloc_like(x) _gnutls_mpi_new(_gnutls_mpi_get_nbits(x))
61#define _gnutls_mpi_salloc_like(x) _gnutls_mpi_snew(_gnutls_mpi_get_nbits(x)) 61#define _gnutls_mpi_salloc_like(x) _gnutls_mpi_snew(_gnutls_mpi_get_nbits(x))
62 62
63void _gnutls_mpi_release (mpi_t * x); 63void mhd_gtls_mpi_release (mpi_t * x);
64 64
65int _gnutls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, 65int mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer,
66 size_t * nbytes); 66 size_t * nbytes);
67int _gnutls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, 67int mhd_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer,
68 size_t * nbytes); 68 size_t * nbytes);
69int _gnutls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, 69int mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
70 size_t * nbytes); 70 size_t * nbytes);
71 71
72int _gnutls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a); 72int mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a);
73int _gnutls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a); 73int mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a);
74 74
75int _gnutls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a); 75int mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a);
76int _gnutls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a); 76int mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a);
77 77
78#endif 78#endif
diff --git a/src/daemon/https/tls/gnutls_num.c b/src/daemon/https/tls/gnutls_num.c
index 474cb73b..ab5c7196 100644
--- a/src/daemon/https/tls/gnutls_num.c
+++ b/src/daemon/https/tls/gnutls_num.c
@@ -35,7 +35,7 @@
35 * has been reached. 35 * has been reached.
36 */ 36 */
37int 37int
38_gnutls_uint64pp (uint64 * x) 38mhd_gtls_uint64pp (uint64 * x)
39{ 39{
40 register int i, y = 0; 40 register int i, y = 0;
41 41
@@ -60,7 +60,7 @@ _gnutls_uint64pp (uint64 * x)
60} 60}
61 61
62uint32_t 62uint32_t
63_gnutls_uint24touint32 (uint24 num) 63mhd_gtls_uint24touint32 (uint24 num)
64{ 64{
65 uint32_t ret = 0; 65 uint32_t ret = 0;
66 66
@@ -71,7 +71,7 @@ _gnutls_uint24touint32 (uint24 num)
71} 71}
72 72
73uint24 73uint24
74_gnutls_uint32touint24 (uint32_t num) 74mhd_gtls_uint32touint24 (uint32_t num)
75{ 75{
76 uint24 ret; 76 uint24 ret;
77 77
@@ -84,7 +84,7 @@ _gnutls_uint32touint24 (uint32_t num)
84 84
85/* data should be at least 3 bytes */ 85/* data should be at least 3 bytes */
86uint32_t 86uint32_t
87_gnutls_read_uint24 (const opaque * data) 87mhd_gtls_read_uint24 (const opaque * data)
88{ 88{
89 uint32_t res; 89 uint32_t res;
90 uint24 num; 90 uint24 num;
@@ -93,7 +93,7 @@ _gnutls_read_uint24 (const opaque * data)
93 num.pint[1] = data[1]; 93 num.pint[1] = data[1];
94 num.pint[2] = data[2]; 94 num.pint[2] = data[2];
95 95
96 res = _gnutls_uint24touint32 (num); 96 res = mhd_gtls_uint24touint32 (num);
97#ifndef WORDS_BIGENDIAN 97#ifndef WORDS_BIGENDIAN
98 res = byteswap32 (res); 98 res = byteswap32 (res);
99#endif 99#endif
@@ -101,14 +101,14 @@ _gnutls_read_uint24 (const opaque * data)
101} 101}
102 102
103void 103void
104_gnutls_write_uint24 (uint32_t num, opaque * data) 104mhd_gtls_write_uint24 (uint32_t num, opaque * data)
105{ 105{
106 uint24 tmp; 106 uint24 tmp;
107 107
108#ifndef WORDS_BIGENDIAN 108#ifndef WORDS_BIGENDIAN
109 num = byteswap32 (num); 109 num = byteswap32 (num);
110#endif 110#endif
111 tmp = _gnutls_uint32touint24 (num); 111 tmp = mhd_gtls_uint32touint24 (num);
112 112
113 data[0] = tmp.pint[0]; 113 data[0] = tmp.pint[0];
114 data[1] = tmp.pint[1]; 114 data[1] = tmp.pint[1];
@@ -116,7 +116,7 @@ _gnutls_write_uint24 (uint32_t num, opaque * data)
116} 116}
117 117
118uint32_t 118uint32_t
119_gnutls_read_uint32 (const opaque * data) 119mhd_gtls_read_uint32 (const opaque * data)
120{ 120{
121 uint32_t res; 121 uint32_t res;
122 122
@@ -128,7 +128,7 @@ _gnutls_read_uint32 (const opaque * data)
128} 128}
129 129
130void 130void
131_gnutls_write_uint32 (uint32_t num, opaque * data) 131mhd_gtls_write_uint32 (uint32_t num, opaque * data)
132{ 132{
133 133
134#ifndef WORDS_BIGENDIAN 134#ifndef WORDS_BIGENDIAN
@@ -138,7 +138,7 @@ _gnutls_write_uint32 (uint32_t num, opaque * data)
138} 138}
139 139
140uint16_t 140uint16_t
141_gnutls_read_uint16 (const opaque * data) 141mhd_gtls_read_uint16 (const opaque * data)
142{ 142{
143 uint16_t res; 143 uint16_t res;
144 memcpy (&res, data, sizeof (uint16_t)); 144 memcpy (&res, data, sizeof (uint16_t));
@@ -149,7 +149,7 @@ _gnutls_read_uint16 (const opaque * data)
149} 149}
150 150
151void 151void
152_gnutls_write_uint16 (uint16_t num, opaque * data) 152mhd_gtls_write_uint16 (uint16_t num, opaque * data)
153{ 153{
154 154
155#ifndef WORDS_BIGENDIAN 155#ifndef WORDS_BIGENDIAN
@@ -159,7 +159,7 @@ _gnutls_write_uint16 (uint16_t num, opaque * data)
159} 159}
160 160
161uint32_t 161uint32_t
162_gnutls_conv_uint32 (uint32_t data) 162mhd_gtls_conv_uint32 (uint32_t data)
163{ 163{
164#ifndef WORDS_BIGENDIAN 164#ifndef WORDS_BIGENDIAN
165 return byteswap32 (data); 165 return byteswap32 (data);
@@ -169,7 +169,7 @@ _gnutls_conv_uint32 (uint32_t data)
169} 169}
170 170
171uint16_t 171uint16_t
172_gnutls_conv_uint16 (uint16_t data) 172mhd_gtls_conv_uint16 (uint16_t data)
173{ 173{
174#ifndef WORDS_BIGENDIAN 174#ifndef WORDS_BIGENDIAN
175 return byteswap16 (data); 175 return byteswap16 (data);
@@ -179,7 +179,7 @@ _gnutls_conv_uint16 (uint16_t data)
179} 179}
180 180
181uint32_t 181uint32_t
182_gnutls_uint64touint32 (const uint64 * num) 182mhd_gtls_uint64touint32 (const uint64 * num)
183{ 183{
184 uint32_t ret; 184 uint32_t ret;
185 185
diff --git a/src/daemon/https/tls/gnutls_num.h b/src/daemon/https/tls/gnutls_num.h
index 3ab226ae..37ce0c6d 100644
--- a/src/daemon/https/tls/gnutls_num.h
+++ b/src/daemon/https/tls/gnutls_num.h
@@ -32,18 +32,18 @@
32#define byteswap16(x) ((rotl16(x, 8) & 0x00ff) | (rotr16(x, 8) & 0xff00)) 32#define byteswap16(x) ((rotl16(x, 8) & 0x00ff) | (rotr16(x, 8) & 0xff00))
33#define byteswap32(x) ((rotl32(x, 8) & 0x00ff00ffUL) | (rotr32(x, 8) & 0xff00ff00UL)) 33#define byteswap32(x) ((rotl32(x, 8) & 0x00ff00ffUL) | (rotr32(x, 8) & 0xff00ff00UL))
34 34
35uint32_t _gnutls_uint24touint32 (uint24 num); 35uint32_t mhd_gtls_uint24touint32 (uint24 num);
36uint24 _gnutls_uint32touint24 (uint32_t num); 36uint24 mhd_gtls_uint32touint24 (uint32_t num);
37uint32_t _gnutls_read_uint32 (const opaque * data); 37uint32_t mhd_gtls_read_uint32 (const opaque * data);
38uint16_t _gnutls_read_uint16 (const opaque * data); 38uint16_t mhd_gtls_read_uint16 (const opaque * data);
39uint32_t _gnutls_conv_uint32 (uint32_t data); 39uint32_t mhd_gtls_conv_uint32 (uint32_t data);
40uint16_t _gnutls_conv_uint16 (uint16_t data); 40uint16_t mhd_gtls_conv_uint16 (uint16_t data);
41uint32_t _gnutls_read_uint24 (const opaque * data); 41uint32_t mhd_gtls_read_uint24 (const opaque * data);
42void _gnutls_write_uint24 (uint32_t num, opaque * data); 42void mhd_gtls_write_uint24 (uint32_t num, opaque * data);
43void _gnutls_write_uint32 (uint32_t num, opaque * data); 43void mhd_gtls_write_uint32 (uint32_t num, opaque * data);
44void _gnutls_write_uint16 (uint16_t num, opaque * data); 44void mhd_gtls_write_uint16 (uint16_t num, opaque * data);
45uint32_t _gnutls_uint64touint32 (const uint64 *); 45uint32_t mhd_gtls_uint64touint32 (const uint64 *);
46 46
47int _gnutls_uint64pp (uint64 *); 47int mhd_gtls_uint64pp (uint64 *);
48# define _gnutls_uint64zero(x) x.i[0] = x.i[1] = x.i[2] = x.i[3] = x.i[4] = x.i[5] = x.i[6] = x.i[7] = 0 48# define _gnutls_uint64zero(x) x.i[0] = x.i[1] = x.i[2] = x.i[3] = x.i[4] = x.i[5] = x.i[6] = x.i[7] = 0
49# define UINT64DATA(x) x.i 49# define UINT64DATA(x) x.i
diff --git a/src/daemon/https/tls/gnutls_pk.c b/src/daemon/https/tls/gnutls_pk.c
index cfec9463..2e748bab 100644
--- a/src/daemon/https/tls/gnutls_pk.c
+++ b/src/daemon/https/tls/gnutls_pk.c
@@ -54,7 +54,7 @@ static int _gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data,
54 * params is modulus, public exp. 54 * params is modulus, public exp.
55 */ 55 */
56int 56int
57_gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, 57mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
58 const gnutls_datum_t * plaintext, 58 const gnutls_datum_t * plaintext,
59 mpi_t * params, unsigned params_len, 59 mpi_t * params, unsigned params_len,
60 unsigned btype) 60 unsigned btype)
@@ -143,7 +143,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
143 ps[psize] = 0; 143 ps[psize] = 0;
144 memcpy (&ps[psize + 1], plaintext->data, plaintext->size); 144 memcpy (&ps[psize + 1], plaintext->data, plaintext->size);
145 145
146 if (_gnutls_mpi_scan_nz (&m, edata, &k) != 0) 146 if (mhd_gtls_mpi_scan_nz (&m, edata, &k) != 0)
147 { 147 {
148 gnutls_assert (); 148 gnutls_assert ();
149 gnutls_afree (edata); 149 gnutls_afree (edata);
@@ -156,7 +156,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
156 else /* sign */ 156 else /* sign */
157 ret = _gnutls_pk_sign (GCRY_PK_RSA, &res, m, params, params_len); 157 ret = _gnutls_pk_sign (GCRY_PK_RSA, &res, m, params, params_len);
158 158
159 _gnutls_mpi_release (&m); 159 mhd_gtls_mpi_release (&m);
160 160
161 if (ret < 0) 161 if (ret < 0)
162 { 162 {
@@ -164,7 +164,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
164 return ret; 164 return ret;
165 } 165 }
166 166
167 _gnutls_mpi_print (NULL, &psize, res); 167 mhd_gtls_mpi_print (NULL, &psize, res);
168 168
169 if (psize < k) 169 if (psize < k)
170 { 170 {
@@ -180,7 +180,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
180 { /* psize > k !!! */ 180 { /* psize > k !!! */
181 /* This is an impossible situation */ 181 /* This is an impossible situation */
182 gnutls_assert (); 182 gnutls_assert ();
183 _gnutls_mpi_release (&res); 183 mhd_gtls_mpi_release (&res);
184 return GNUTLS_E_INTERNAL_ERROR; 184 return GNUTLS_E_INTERNAL_ERROR;
185 } 185 }
186 186
@@ -188,16 +188,16 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
188 if (ciphertext->data == NULL) 188 if (ciphertext->data == NULL)
189 { 189 {
190 gnutls_assert (); 190 gnutls_assert ();
191 _gnutls_mpi_release (&res); 191 mhd_gtls_mpi_release (&res);
192 return GNUTLS_E_MEMORY_ERROR; 192 return GNUTLS_E_MEMORY_ERROR;
193 } 193 }
194 _gnutls_mpi_print (&ciphertext->data[pad], &psize, res); 194 mhd_gtls_mpi_print (&ciphertext->data[pad], &psize, res);
195 for (i = 0; i < pad; i++) 195 for (i = 0; i < pad; i++)
196 ciphertext->data[i] = 0; 196 ciphertext->data[i] = 0;
197 197
198 ciphertext->size = k; 198 ciphertext->size = k;
199 199
200 _gnutls_mpi_release (&res); 200 mhd_gtls_mpi_release (&res);
201 201
202 return 0; 202 return 0;
203} 203}
@@ -208,7 +208,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
208 * Can decrypt block type 1 and type 2 packets. 208 * Can decrypt block type 1 and type 2 packets.
209 */ 209 */
210int 210int
211_gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, 211mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
212 const gnutls_datum_t * ciphertext, 212 const gnutls_datum_t * ciphertext,
213 mpi_t * params, unsigned params_len, 213 mpi_t * params, unsigned params_len,
214 unsigned btype) 214 unsigned btype)
@@ -232,7 +232,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
232 return GNUTLS_E_PK_DECRYPTION_FAILED; 232 return GNUTLS_E_PK_DECRYPTION_FAILED;
233 } 233 }
234 234
235 if (_gnutls_mpi_scan_nz (&c, ciphertext->data, &esize) != 0) 235 if (mhd_gtls_mpi_scan_nz (&c, ciphertext->data, &esize) != 0)
236 { 236 {
237 gnutls_assert (); 237 gnutls_assert ();
238 return GNUTLS_E_MPI_SCAN_FAILED; 238 return GNUTLS_E_MPI_SCAN_FAILED;
@@ -247,7 +247,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
247 { 247 {
248 ret = _gnutls_pk_encrypt (GCRY_PK_RSA, &res, c, params, params_len); 248 ret = _gnutls_pk_encrypt (GCRY_PK_RSA, &res, c, params, params_len);
249 } 249 }
250 _gnutls_mpi_release (&c); 250 mhd_gtls_mpi_release (&c);
251 251
252 if (ret < 0) 252 if (ret < 0)
253 { 253 {
@@ -255,17 +255,17 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
255 return ret; 255 return ret;
256 } 256 }
257 257
258 _gnutls_mpi_print (NULL, &esize, res); 258 mhd_gtls_mpi_print (NULL, &esize, res);
259 edata = gnutls_alloca (esize + 1); 259 edata = gnutls_alloca (esize + 1);
260 if (edata == NULL) 260 if (edata == NULL)
261 { 261 {
262 gnutls_assert (); 262 gnutls_assert ();
263 _gnutls_mpi_release (&res); 263 mhd_gtls_mpi_release (&res);
264 return GNUTLS_E_MEMORY_ERROR; 264 return GNUTLS_E_MEMORY_ERROR;
265 } 265 }
266 _gnutls_mpi_print (&edata[1], &esize, res); 266 mhd_gtls_mpi_print (&edata[1], &esize, res);
267 267
268 _gnutls_mpi_release (&res); 268 mhd_gtls_mpi_release (&res);
269 269
270 /* EB = 00||BT||PS||00||D 270 /* EB = 00||BT||PS||00||D
271 * (use block type 'btype') 271 * (use block type 'btype')
@@ -345,7 +345,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
345 345
346 346
347int 347int
348_gnutls_rsa_verify (const gnutls_datum_t * vdata, 348mhd_gtls_rsa_verify (const gnutls_datum_t * vdata,
349 const gnutls_datum_t * ciphertext, mpi_t * params, 349 const gnutls_datum_t * ciphertext, mpi_t * params,
350 int params_len, int btype) 350 int params_len, int btype)
351{ 351{
@@ -355,7 +355,7 @@ _gnutls_rsa_verify (const gnutls_datum_t * vdata,
355 355
356 /* decrypt signature */ 356 /* decrypt signature */
357 if ((ret = 357 if ((ret =
358 _gnutls_pkcs1_rsa_decrypt (&plain, ciphertext, params, params_len, 358 mhd_gtls_pkcs1_rsa_decrypt (&plain, ciphertext, params, params_len,
359 btype)) < 0) 359 btype)) < 0)
360 { 360 {
361 gnutls_assert (); 361 gnutls_assert ();
@@ -433,7 +433,7 @@ encode_ber_rs (gnutls_datum_t * sig_value, mpi_t r, mpi_t s)
433/* Do DSA signature calculation. params is p, q, g, y, x in that order. 433/* Do DSA signature calculation. params is p, q, g, y, x in that order.
434 */ 434 */
435int 435int
436_gnutls_dsa_sign (gnutls_datum_t * signature, 436mhd_gtls_dsa_sign (gnutls_datum_t * signature,
437 const gnutls_datum_t * hash, mpi_t * params, 437 const gnutls_datum_t * hash, mpi_t * params,
438 unsigned params_len) 438 unsigned params_len)
439{ 439{
@@ -448,7 +448,7 @@ _gnutls_dsa_sign (gnutls_datum_t * signature,
448 return GNUTLS_E_PK_SIGN_FAILED; 448 return GNUTLS_E_PK_SIGN_FAILED;
449 } 449 }
450 450
451 if (_gnutls_mpi_scan_nz (&mdata, hash->data, &k) != 0) 451 if (mhd_gtls_mpi_scan_nz (&mdata, hash->data, &k) != 0)
452 { 452 {
453 gnutls_assert (); 453 gnutls_assert ();
454 return GNUTLS_E_MPI_SCAN_FAILED; 454 return GNUTLS_E_MPI_SCAN_FAILED;
@@ -456,7 +456,7 @@ _gnutls_dsa_sign (gnutls_datum_t * signature,
456 456
457 ret = _gnutls_pk_sign (GCRY_PK_DSA, rs, mdata, params, params_len); 457 ret = _gnutls_pk_sign (GCRY_PK_DSA, rs, mdata, params, params_len);
458 /* rs[0], rs[1] now hold r,s */ 458 /* rs[0], rs[1] now hold r,s */
459 _gnutls_mpi_release (&mdata); 459 mhd_gtls_mpi_release (&mdata);
460 460
461 if (ret < 0) 461 if (ret < 0)
462 { 462 {
@@ -467,8 +467,8 @@ _gnutls_dsa_sign (gnutls_datum_t * signature,
467 ret = encode_ber_rs (signature, rs[0], rs[1]); 467 ret = encode_ber_rs (signature, rs[0], rs[1]);
468 468
469 /* free r,s */ 469 /* free r,s */
470 _gnutls_mpi_release (&rs[0]); 470 mhd_gtls_mpi_release (&rs[0]);
471 _gnutls_mpi_release (&rs[1]); 471 mhd_gtls_mpi_release (&rs[1]);
472 472
473 if (ret != 0) 473 if (ret != 0)
474 { 474 {
@@ -516,7 +516,7 @@ decode_ber_rs (const gnutls_datum_t * sig_value, mpi_t * r, mpi_t * s)
516 if (result < 0) 516 if (result < 0)
517 { 517 {
518 gnutls_assert (); 518 gnutls_assert ();
519 _gnutls_mpi_release (s); 519 mhd_gtls_mpi_release (s);
520 asn1_delete_structure (&sig); 520 asn1_delete_structure (&sig);
521 return result; 521 return result;
522 } 522 }
@@ -529,7 +529,7 @@ decode_ber_rs (const gnutls_datum_t * sig_value, mpi_t * r, mpi_t * s)
529/* params is p, q, g, y in that order 529/* params is p, q, g, y in that order
530 */ 530 */
531int 531int
532_gnutls_dsa_verify (const gnutls_datum_t * vdata, 532mhd_gtls_dsa_verify (const gnutls_datum_t * vdata,
533 const gnutls_datum_t * sig_value, mpi_t * params, 533 const gnutls_datum_t * sig_value, mpi_t * params,
534 int params_len) 534 int params_len)
535{ 535{
@@ -552,19 +552,19 @@ _gnutls_dsa_verify (const gnutls_datum_t * vdata,
552 } 552 }
553 553
554 k = vdata->size; 554 k = vdata->size;
555 if (_gnutls_mpi_scan_nz (&mdata, vdata->data, &k) != 0) 555 if (mhd_gtls_mpi_scan_nz (&mdata, vdata->data, &k) != 0)
556 { 556 {
557 gnutls_assert (); 557 gnutls_assert ();
558 _gnutls_mpi_release (&rs[0]); 558 mhd_gtls_mpi_release (&rs[0]);
559 _gnutls_mpi_release (&rs[1]); 559 mhd_gtls_mpi_release (&rs[1]);
560 return GNUTLS_E_MPI_SCAN_FAILED; 560 return GNUTLS_E_MPI_SCAN_FAILED;
561 } 561 }
562 562
563 /* decrypt signature */ 563 /* decrypt signature */
564 ret = _gnutls_pk_verify (GCRY_PK_DSA, mdata, rs, params, params_len); 564 ret = _gnutls_pk_verify (GCRY_PK_DSA, mdata, rs, params, params_len);
565 _gnutls_mpi_release (&mdata); 565 mhd_gtls_mpi_release (&mdata);
566 _gnutls_mpi_release (&rs[0]); 566 mhd_gtls_mpi_release (&rs[0]);
567 _gnutls_mpi_release (&rs[1]); 567 mhd_gtls_mpi_release (&rs[1]);
568 568
569 if (ret < 0) 569 if (ret < 0)
570 { 570 {
diff --git a/src/daemon/https/tls/gnutls_pk.h b/src/daemon/https/tls/gnutls_pk.h
index 83f87689..bde27a2a 100644
--- a/src/daemon/https/tls/gnutls_pk.h
+++ b/src/daemon/https/tls/gnutls_pk.h
@@ -25,21 +25,21 @@
25#ifndef GNUTLS_PK_H 25#ifndef GNUTLS_PK_H
26#define GNUTLS_PK_H 26#define GNUTLS_PK_H
27 27
28int _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, 28int mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
29 const gnutls_datum_t * plaintext, 29 const gnutls_datum_t * plaintext,
30 mpi_t * params, unsigned params_len, 30 mpi_t * params, unsigned params_len,
31 unsigned btype); 31 unsigned btype);
32int _gnutls_dsa_sign (gnutls_datum_t * signature, 32int mhd_gtls_dsa_sign (gnutls_datum_t * signature,
33 const gnutls_datum_t * plaintext, mpi_t * params, 33 const gnutls_datum_t * plaintext, mpi_t * params,
34 unsigned params_len); 34 unsigned params_len);
35int _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, 35int mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
36 const gnutls_datum_t * ciphertext, 36 const gnutls_datum_t * ciphertext,
37 mpi_t * params, unsigned params_len, 37 mpi_t * params, unsigned params_len,
38 unsigned btype); 38 unsigned btype);
39int _gnutls_rsa_verify (const gnutls_datum_t * vdata, 39int mhd_gtls_rsa_verify (const gnutls_datum_t * vdata,
40 const gnutls_datum_t * ciphertext, mpi_t * params, 40 const gnutls_datum_t * ciphertext, mpi_t * params,
41 int params_len, int btype); 41 int params_len, int btype);
42int _gnutls_dsa_verify (const gnutls_datum_t * vdata, 42int mhd_gtls_dsa_verify (const gnutls_datum_t * vdata,
43 const gnutls_datum_t * sig_value, mpi_t * params, 43 const gnutls_datum_t * sig_value, mpi_t * params,
44 int params_len); 44 int params_len);
45 45
diff --git a/src/daemon/https/tls/gnutls_priority.c b/src/daemon/https/tls/gnutls_priority.c
index cea6446b..e865fd27 100644
--- a/src/daemon/https/tls/gnutls_priority.c
+++ b/src/daemon/https/tls/gnutls_priority.c
@@ -33,8 +33,8 @@
33#define MAX_ELEMENTS 48 33#define MAX_ELEMENTS 48
34 34
35/** 35/**
36 * gnutls_cipher_set_priority - Sets the priority on the ciphers supported by gnutls. 36 * MHD_gnutls_cipher_set_priority - Sets the priority on the ciphers supported by gnutls.
37 * @session: is a #gnutls_session_t structure. 37 * @session: is a #mhd_gtls_session_t structure.
38 * @list: is a 0 terminated list of gnutls_cipher_algorithm_t elements. 38 * @list: is a 0 terminated list of gnutls_cipher_algorithm_t elements.
39 * 39 *
40 * Sets the priority on the ciphers supported by gnutls. 40 * Sets the priority on the ciphers supported by gnutls.
@@ -48,7 +48,7 @@
48 * 48 *
49 **/ 49 **/
50int 50int
51gnutls_cipher_set_priority (gnutls_session_t session, const int *list) 51MHD_gnutls_cipher_set_priority (mhd_gtls_session_t session, const int *list)
52{ 52{
53 int num = 0, i; 53 int num = 0, i;
54 54
@@ -67,7 +67,7 @@ gnutls_cipher_set_priority (gnutls_session_t session, const int *list)
67} 67}
68 68
69inline static int 69inline static int
70_set_priority (priority_st * st, const int *list) 70_set_priority (mhd_gtls_priority_st * st, const int *list)
71{ 71{
72 int num = 0, i; 72 int num = 0, i;
73 73
@@ -86,8 +86,8 @@ _set_priority (priority_st * st, const int *list)
86} 86}
87 87
88/** 88/**
89 * gnutls_kx_set_priority - Sets the priority on the key exchange algorithms supported by gnutls. 89 * MHD_gnutls_kx_set_priority - Sets the priority on the key exchange algorithms supported by gnutls.
90 * @session: is a #gnutls_session_t structure. 90 * @session: is a #mhd_gtls_session_t structure.
91 * @list: is a 0 terminated list of gnutls_kx_algorithm_t elements. 91 * @list: is a 0 terminated list of gnutls_kx_algorithm_t elements.
92 * 92 *
93 * Sets the priority on the key exchange algorithms supported by gnutls. 93 * Sets the priority on the key exchange algorithms supported by gnutls.
@@ -101,14 +101,14 @@ _set_priority (priority_st * st, const int *list)
101 * 101 *
102 **/ 102 **/
103int 103int
104gnutls_kx_set_priority (gnutls_session_t session, const int *list) 104MHD_gnutls_kx_set_priority (mhd_gtls_session_t session, const int *list)
105{ 105{
106 return _set_priority (&session->internals.priorities.kx, list); 106 return _set_priority (&session->internals.priorities.kx, list);
107} 107}
108 108
109/** 109/**
110 * gnutls_mac_set_priority - Sets the priority on the mac algorithms supported by gnutls. 110 * MHD_gnutls_mac_set_priority - Sets the priority on the mac algorithms supported by gnutls.
111 * @session: is a #gnutls_session_t structure. 111 * @session: is a #mhd_gtls_session_t structure.
112 * @list: is a 0 terminated list of gnutls_mac_algorithm_t elements. 112 * @list: is a 0 terminated list of gnutls_mac_algorithm_t elements.
113 * 113 *
114 * Sets the priority on the mac algorithms supported by gnutls. 114 * Sets the priority on the mac algorithms supported by gnutls.
@@ -122,14 +122,14 @@ gnutls_kx_set_priority (gnutls_session_t session, const int *list)
122 * 122 *
123 **/ 123 **/
124int 124int
125gnutls_mac_set_priority (gnutls_session_t session, const int *list) 125MHD_gnutls_mac_set_priority (mhd_gtls_session_t session, const int *list)
126{ 126{
127 return _set_priority (&session->internals.priorities.mac, list); 127 return _set_priority (&session->internals.priorities.mac, list);
128} 128}
129 129
130/** 130/**
131 * gnutls_compression_set_priority - Sets the priority on the compression algorithms supported by gnutls. 131 * MHD_gnutls_compression_set_priority - Sets the priority on the compression algorithms supported by gnutls.
132 * @session: is a #gnutls_session_t structure. 132 * @session: is a #mhd_gtls_session_t structure.
133 * @list: is a 0 terminated list of gnutls_compression_method_t elements. 133 * @list: is a 0 terminated list of gnutls_compression_method_t elements.
134 * 134 *
135 * Sets the priority on the compression algorithms supported by gnutls. 135 * Sets the priority on the compression algorithms supported by gnutls.
@@ -147,14 +147,14 @@ gnutls_mac_set_priority (gnutls_session_t session, const int *list)
147 * 147 *
148 **/ 148 **/
149int 149int
150gnutls_compression_set_priority (gnutls_session_t session, const int *list) 150MHD_gnutls_compression_set_priority (mhd_gtls_session_t session, const int *list)
151{ 151{
152 return _set_priority (&session->internals.priorities.compression, list); 152 return _set_priority (&session->internals.priorities.compression, list);
153} 153}
154 154
155/** 155/**
156 * gnutls_protocol_set_priority - Sets the priority on the protocol versions supported by gnutls. 156 * MHD_gnutls_protocol_set_priority - Sets the priority on the protocol versions supported by gnutls.
157 * @session: is a #gnutls_session_t structure. 157 * @session: is a #mhd_gtls_session_t structure.
158 * @list: is a 0 terminated list of gnutls_protocol_t elements. 158 * @list: is a 0 terminated list of gnutls_protocol_t elements.
159 * 159 *
160 * Sets the priority on the protocol versions supported by gnutls. 160 * Sets the priority on the protocol versions supported by gnutls.
@@ -165,7 +165,7 @@ gnutls_compression_set_priority (gnutls_session_t session, const int *list)
165 * 165 *
166 **/ 166 **/
167int 167int
168gnutls_protocol_set_priority (gnutls_session_t session, const int *list) 168MHD_gnutls_protocol_set_priority (mhd_gtls_session_t session, const int *list)
169{ 169{
170 int ret; 170 int ret;
171 171
@@ -175,14 +175,14 @@ gnutls_protocol_set_priority (gnutls_session_t session, const int *list)
175 * This will be overridden later. 175 * This will be overridden later.
176 */ 176 */
177 if (list) 177 if (list)
178 _gnutls_set_current_version (session, list[0]); 178 mhd_gtls_set_current_version (session, list[0]);
179 179
180 return ret; 180 return ret;
181} 181}
182 182
183/** 183/**
184 * gnutls_certificate_type_set_priority - Sets the priority on the certificate types supported by gnutls. 184 * MHD_gnutls_certificate_type_set_priority - Sets the priority on the certificate types supported by gnutls.
185 * @session: is a #gnutls_session_t structure. 185 * @session: is a #mhd_gtls_session_t structure.
186 * @list: is a 0 terminated list of gnutls_certificate_type_t elements. 186 * @list: is a 0 terminated list of gnutls_certificate_type_t elements.
187 * 187 *
188 * Sets the priority on the certificate types supported by gnutls. 188 * Sets the priority on the certificate types supported by gnutls.
@@ -196,7 +196,7 @@ gnutls_protocol_set_priority (gnutls_session_t session, const int *list)
196 * 196 *
197 **/ 197 **/
198int 198int
199gnutls_certificate_type_set_priority (gnutls_session_t session, 199MHD_gnutls_certificate_type_set_priority (mhd_gtls_session_t session,
200 const int *list) 200 const int *list)
201{ 201{
202#if ENABLE_OPENPGP 202#if ENABLE_OPENPGP
@@ -235,11 +235,11 @@ static const int comp_priority[] = { MHD_GNUTLS_COMP_NULL,
235 0 235 0
236}; 236};
237 237
238typedef void (rmadd_func) (priority_st * priority_list, int alg); 238typedef void (rmadd_func) (mhd_gtls_priority_st * priority_list, int alg);
239 239
240/** 240/**
241 * gnutls_priority_set - Sets priorities for the cipher suites supported by gnutls. 241 * MHD_gnutls_priority_set - Sets priorities for the cipher suites supported by gnutls.
242 * @session: is a #gnutls_session_t structure. 242 * @session: is a #mhd_gtls_session_t structure.
243 * @priority: is a #gnutls_priority_t structure. 243 * @priority: is a #gnutls_priority_t structure.
244 * 244 *
245 * Sets the priorities to use on the ciphers, key exchange methods, 245 * Sets the priorities to use on the ciphers, key exchange methods,
@@ -249,7 +249,7 @@ typedef void (rmadd_func) (priority_st * priority_list, int alg);
249 * 249 *
250 **/ 250 **/
251int 251int
252gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority) 252MHD_gnutls_priority_set (mhd_gtls_session_t session, gnutls_priority_t priority)
253{ 253{
254 if (priority == NULL) 254 if (priority == NULL)
255 { 255 {
@@ -258,13 +258,13 @@ gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority)
258 } 258 }
259 259
260 memcpy (&session->internals.priorities, priority, 260 memcpy (&session->internals.priorities, priority,
261 sizeof (struct gnutls_priority_st)); 261 sizeof (struct MHD_gtls_priority_st));
262 262
263 return 0; 263 return 0;
264} 264}
265 265
266/** 266/**
267 * gnutls_priority_init - Sets priorities for the cipher suites supported by gnutls. 267 * MHD_tls_set_default_priority - Sets priorities for the cipher suites supported by gnutls.
268 * @priority_cache: is a #gnutls_prioritity_t structure. 268 * @priority_cache: is a #gnutls_prioritity_t structure.
269 * @priorities: is a string describing priorities 269 * @priorities: is a string describing priorities
270 * @err_pos: In case of an error this will have the position in the string the error occured 270 * @err_pos: In case of an error this will have the position in the string the error occured
@@ -329,10 +329,10 @@ gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority)
329 * 0 on success. 329 * 0 on success.
330 **/ 330 **/
331int 331int
332gnutls_priority_init (gnutls_priority_t * priority_cache, 332MHD_tls_set_default_priority (gnutls_priority_t * priority_cache,
333 const char *priorities, const char **err_pos) 333 const char *priorities, const char **err_pos)
334{ 334{
335 *priority_cache = gnutls_calloc (1, sizeof (struct gnutls_priority_st)); 335 *priority_cache = gnutls_calloc (1, sizeof (struct MHD_gtls_priority_st));
336 if (*priority_cache == NULL) 336 if (*priority_cache == NULL)
337 { 337 {
338 gnutls_assert (); 338 gnutls_assert ();
@@ -352,104 +352,54 @@ gnutls_priority_init (gnutls_priority_t * priority_cache,
352} 352}
353 353
354/** 354/**
355 * gnutls_priority_deinit - Deinitialize the priorities cache for the cipher suites supported by gnutls. 355 * MHD_gnutls_priority_deinit - Deinitialize the priorities cache for the cipher suites supported by gnutls.
356 * @priority_cache: is a #gnutls_prioritity_t structure. 356 * @priority_cache: is a #gnutls_prioritity_t structure.
357 * 357 *
358 * Deinitializes the priority cache. 358 * Deinitializes the priority cache.
359 * 359 *
360 **/ 360 **/
361void 361void
362gnutls_priority_deinit (gnutls_priority_t priority_cache) 362MHD_gnutls_priority_deinit (gnutls_priority_t priority_cache)
363{ 363{
364 gnutls_free (priority_cache); 364 gnutls_free (priority_cache);
365} 365}
366 366
367/** 367/**
368 * gnutls_priority_set_direct - Sets priorities for the cipher suites supported by gnutls. 368 * MHD_gnutls_priority_set_direct - Sets priorities for the cipher suites supported by gnutls.
369 * @session: is a #gnutls_session_t structure. 369 * @session: is a #mhd_gtls_session_t structure.
370 * @priorities: is a string describing priorities 370 * @priorities: is a string describing priorities
371 * @err_pos: In case of an error this will have the position in the string the error occured 371 * @err_pos: In case of an error this will have the position in the string the error occured
372 * 372 *
373 * Sets the priorities to use on the ciphers, key exchange methods, 373 * Sets the priorities to use on the ciphers, key exchange methods,
374 * macs and compression methods. This function avoids keeping a 374 * macs and compression methods. This function avoids keeping a
375 * priority cache and is used to directly set string priorities to a 375 * priority cache and is used to directly set string priorities to a
376 * TLS session. For documentation check the gnutls_priority_init(). 376 * TLS session. For documentation check the MHD_tls_set_default_priority().
377 * 377 *
378 * On syntax error GNUTLS_E_INVALID_REQUEST is returned and 0 on success. 378 * On syntax error GNUTLS_E_INVALID_REQUEST is returned and 0 on success.
379 * 379 *
380 **/ 380 **/
381int 381int
382gnutls_priority_set_direct (gnutls_session_t session, 382MHD_gnutls_priority_set_direct (mhd_gtls_session_t session,
383 const char *priorities, const char **err_pos) 383 const char *priorities, const char **err_pos)
384{ 384{
385 gnutls_priority_t prio; 385 gnutls_priority_t prio;
386 int ret; 386 int ret;
387 387
388 ret = gnutls_priority_init (&prio, priorities, err_pos); 388 ret = MHD_tls_set_default_priority (&prio, priorities, err_pos);
389 if (ret < 0) 389 if (ret < 0)
390 { 390 {
391 gnutls_assert (); 391 gnutls_assert ();
392 return ret; 392 return ret;
393 } 393 }
394 394
395 ret = gnutls_priority_set (session, prio); 395 ret = MHD_gnutls_priority_set (session, prio);
396 if (ret < 0) 396 if (ret < 0)
397 { 397 {
398 gnutls_assert (); 398 gnutls_assert ();
399 return ret; 399 return ret;
400 } 400 }
401 401
402 gnutls_priority_deinit (prio); 402 MHD_gnutls_priority_deinit (prio);
403 403
404 return 0; 404 return 0;
405} 405}
406
407/**
408 * gnutls_set_default_priority - Sets some default priority on the cipher suites supported by gnutls.
409 * @session: is a #gnutls_session_t structure.
410 *
411 * Sets some default priority on the ciphers, key exchange methods,
412 * macs and compression methods.
413 *
414 * This is the same as calling:
415 *
416 * gnutls_priority_set_direct (session, "NORMAL", NULL);
417 *
418 * This function is kept around for backwards compatibility, but
419 * because of its wide use it is still fully supported. If you wish
420 * to allow users to provide a string that specify which ciphers to
421 * use (which is recommended), you should use
422 * gnutls_priority_set_direct() or gnutls_priority_set() instead.
423 *
424 * Returns 0 on success.
425 **/
426int
427gnutls_set_default_priority (gnutls_session_t session)
428{
429 return gnutls_priority_set_direct (session, "NORMAL", NULL);
430}
431
432/**
433 * gnutls_set_default_export_priority - Sets some default priority on the cipher suites supported by gnutls.
434 * @session: is a #gnutls_session_t structure.
435 *
436 * Sets some default priority on the ciphers, key exchange methods, macs
437 * and compression methods. This function also includes weak algorithms.
438 *
439 * This is the same as calling:
440 *
441 * gnutls_priority_set_direct (session, "EXPORT", NULL);
442 *
443 * This function is kept around for backwards compatibility, but
444 * because of its wide use it is still fully supported. If you wish
445 * to allow users to provide a string that specify which ciphers to
446 * use (which is recommended), you should use
447 * gnutls_priority_set_direct() or gnutls_priority_set() instead.
448 *
449 * Returns 0 on success.
450 **/
451int
452gnutls_set_default_export_priority (gnutls_session_t session)
453{
454 return gnutls_priority_set_direct (session, "EXPORT", NULL);
455}
diff --git a/src/daemon/https/tls/gnutls_record.c b/src/daemon/https/tls/gnutls_record.c
index 68c83330..22bf60db 100644
--- a/src/daemon/https/tls/gnutls_record.c
+++ b/src/daemon/https/tls/gnutls_record.c
@@ -44,27 +44,27 @@
44#include <gnutls_dh.h> 44#include <gnutls_dh.h>
45 45
46/** 46/**
47 * gnutls_protocol_get_version - Returns the version of the currently used protocol 47 * MHD_gnutls_protocol_get_version - Returns the version of the currently used protocol
48 * @session: is a #gnutls_session_t structure. 48 * @session: is a #mhd_gtls_session_t structure.
49 * 49 *
50 * Returns: the version of the currently used protocol. 50 * Returns: the version of the currently used protocol.
51 **/ 51 **/
52gnutls_protocol_t 52gnutls_protocol_t
53gnutls_protocol_get_version (gnutls_session_t session) 53MHD_gnutls_protocol_get_version (mhd_gtls_session_t session)
54{ 54{
55 return session->security_parameters.version; 55 return session->security_parameters.version;
56} 56}
57 57
58void 58void
59_gnutls_set_current_version (gnutls_session_t session, 59mhd_gtls_set_current_version (mhd_gtls_session_t session,
60 gnutls_protocol_t version) 60 gnutls_protocol_t version)
61{ 61{
62 session->security_parameters.version = version; 62 session->security_parameters.version = version;
63} 63}
64 64
65/** 65/**
66 * gnutls_transport_set_lowat - Used to set the lowat value in order for select to check for pending data. 66 * MHD_gnutls_transport_set_lowat - Used to set the lowat value in order for select to check for pending data.
67 * @session: is a #gnutls_session_t structure. 67 * @session: is a #mhd_gtls_session_t structure.
68 * @num: is the low water value. 68 * @num: is the low water value.
69 * 69 *
70 * Used to set the lowat value in order for select to check if there 70 * Used to set the lowat value in order for select to check if there
@@ -75,14 +75,14 @@ _gnutls_set_current_version (gnutls_session_t session,
75 * to zero. 75 * to zero.
76 **/ 76 **/
77void 77void
78gnutls_transport_set_lowat (gnutls_session_t session, int num) 78MHD_gnutls_transport_set_lowat (mhd_gtls_session_t session, int num)
79{ 79{
80 session->internals.lowat = num; 80 session->internals.lowat = num;
81} 81}
82 82
83/** 83/**
84 * gnutls_record_disable_padding - Used to disabled padding in TLS 1.0 and above 84 * MHD_gtls_record_disable_padding - Used to disabled padding in TLS 1.0 and above
85 * @session: is a #gnutls_session_t structure. 85 * @session: is a #mhd_gtls_session_t structure.
86 * 86 *
87 * Used to disabled padding in TLS 1.0 and above. Normally you do 87 * Used to disabled padding in TLS 1.0 and above. Normally you do
88 * not need to use this function, but there are buggy clients that 88 * not need to use this function, but there are buggy clients that
@@ -93,14 +93,14 @@ gnutls_transport_set_lowat (gnutls_session_t session, int num)
93 * out there, need to call this function. 93 * out there, need to call this function.
94 **/ 94 **/
95void 95void
96gnutls_record_disable_padding (gnutls_session_t session) 96MHD_gtls_record_disable_padding (mhd_gtls_session_t session)
97{ 97{
98 session->internals.priorities.no_padding = 1; 98 session->internals.priorities.no_padding = 1;
99} 99}
100 100
101/** 101/**
102 * gnutls_transport_set_ptr - Used to set first argument of the transport functions 102 * MHD_gnutls_transport_set_ptr - Used to set first argument of the transport functions
103 * @session: is a #gnutls_session_t structure. 103 * @session: is a #mhd_gtls_session_t structure.
104 * @ptr: is the value. 104 * @ptr: is the value.
105 * 105 *
106 * Used to set the first argument of the transport function (like 106 * Used to set the first argument of the transport function (like
@@ -108,7 +108,7 @@ gnutls_record_disable_padding (gnutls_session_t session)
108 * the connection handle. 108 * the connection handle.
109 **/ 109 **/
110void 110void
111gnutls_transport_set_ptr (gnutls_session_t session, 111MHD_gnutls_transport_set_ptr (mhd_gtls_session_t session,
112 gnutls_transport_ptr_t ptr) 112 gnutls_transport_ptr_t ptr)
113{ 113{
114 session->internals.transport_recv_ptr = ptr; 114 session->internals.transport_recv_ptr = ptr;
@@ -116,8 +116,8 @@ gnutls_transport_set_ptr (gnutls_session_t session,
116} 116}
117 117
118/** 118/**
119 * gnutls_transport_set_ptr2 - Used to set first argument of the transport functions 119 * MHD_gnutls_transport_set_ptr2 - Used to set first argument of the transport functions
120 * @session: is a #gnutls_session_t structure. 120 * @session: is a #mhd_gtls_session_t structure.
121 * @recv_ptr: is the value for the pull function 121 * @recv_ptr: is the value for the pull function
122 * @send_ptr: is the value for the push function 122 * @send_ptr: is the value for the push function
123 * 123 *
@@ -127,7 +127,7 @@ gnutls_transport_set_ptr (gnutls_session_t session,
127 * different pointers for receiving and sending. 127 * different pointers for receiving and sending.
128 **/ 128 **/
129void 129void
130gnutls_transport_set_ptr2 (gnutls_session_t session, 130MHD_gnutls_transport_set_ptr2 (mhd_gtls_session_t session,
131 gnutls_transport_ptr_t recv_ptr, 131 gnutls_transport_ptr_t recv_ptr,
132 gnutls_transport_ptr_t send_ptr) 132 gnutls_transport_ptr_t send_ptr)
133{ 133{
@@ -136,48 +136,12 @@ gnutls_transport_set_ptr2 (gnutls_session_t session,
136} 136}
137 137
138/** 138/**
139 * gnutls_transport_get_ptr - Used to return the first argument of the transport functions 139 * MHD_gnutls_bye - This function terminates the current TLS/SSL connection.
140 * @session: is a #gnutls_session_t structure. 140 * @session: is a #mhd_gtls_session_t structure.
141 *
142 * Used to get the first argument of the transport function (like
143 * PUSH and PULL). This must have been set using
144 * gnutls_transport_set_ptr().
145 *
146 * Returns: first argument of the transport function.
147 **/
148gnutls_transport_ptr_t
149gnutls_transport_get_ptr (gnutls_session_t session)
150{
151 return session->internals.transport_recv_ptr;
152}
153
154/**
155 * gnutls_transport_get_ptr2 - Used to return the first argument of the transport functions
156 * @session: is a #gnutls_session_t structure.
157 * @recv_ptr: will hold the value for the pull function
158 * @send_ptr: will hold the value for the push function
159 *
160 * Used to get the arguments of the transport functions (like PUSH
161 * and PULL). These should have been set using
162 * gnutls_transport_set_ptr2().
163 **/
164void
165gnutls_transport_get_ptr2 (gnutls_session_t session,
166 gnutls_transport_ptr_t * recv_ptr,
167 gnutls_transport_ptr_t * send_ptr)
168{
169
170 *recv_ptr = session->internals.transport_recv_ptr;
171 *send_ptr = session->internals.transport_send_ptr;
172}
173
174/**
175 * gnutls_bye - This function terminates the current TLS/SSL connection.
176 * @session: is a #gnutls_session_t structure.
177 * @how: is an integer 141 * @how: is an integer
178 * 142 *
179 * Terminates the current TLS/SSL connection. The connection should 143 * Terminates the current TLS/SSL connection. The connection should
180 * have been initiated using gnutls_handshake(). @how should be one 144 * have been initiated using MHD_gnutls_handshake(). @how should be one
181 * of %GNUTLS_SHUT_RDWR, %GNUTLS_SHUT_WR. 145 * of %GNUTLS_SHUT_RDWR, %GNUTLS_SHUT_WR.
182 * 146 *
183 * In case of %GNUTLS_SHUT_RDWR then the TLS connection gets 147 * In case of %GNUTLS_SHUT_RDWR then the TLS connection gets
@@ -199,13 +163,13 @@ gnutls_transport_get_ptr2 (gnutls_session_t session,
199 * session, thus this behavior is not recommended. 163 * session, thus this behavior is not recommended.
200 * 164 *
201 * This function may also return %GNUTLS_E_AGAIN or 165 * This function may also return %GNUTLS_E_AGAIN or
202 * %GNUTLS_E_INTERRUPTED; cf. gnutls_record_get_direction(). 166 * %GNUTLS_E_INTERRUPTED; cf. MHD_gnutls_record_get_direction().
203 * 167 *
204 * Returns: %GNUTLS_E_SUCCESS on success, or an error code, see 168 * Returns: %GNUTLS_E_SUCCESS on success, or an error code, see
205 * function documentation for entire semantics. 169 * function documentation for entire semantics.
206 **/ 170 **/
207int 171int
208gnutls_bye (gnutls_session_t session, gnutls_close_request_t how) 172MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how)
209{ 173{
210 int ret = 0; 174 int ret = 0;
211 175
@@ -213,7 +177,7 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
213 { 177 {
214 case STATE0: 178 case STATE0:
215 case STATE60: 179 case STATE60:
216 ret = _gnutls_io_write_flush (session); 180 ret = mhd_gtls_io_write_flush (session);
217 STATE = STATE60; 181 STATE = STATE60;
218 if (ret < 0) 182 if (ret < 0)
219 { 183 {
@@ -223,7 +187,7 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
223 187
224 case STATE61: 188 case STATE61:
225 ret = 189 ret =
226 gnutls_alert_send (session, GNUTLS_AL_WARNING, GNUTLS_A_CLOSE_NOTIFY); 190 MHD_gnutls_alert_send (session, GNUTLS_AL_WARNING, GNUTLS_A_CLOSE_NOTIFY);
227 STATE = STATE61; 191 STATE = STATE61;
228 if (ret < 0) 192 if (ret < 0)
229 { 193 {
@@ -237,8 +201,8 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
237 { 201 {
238 do 202 do
239 { 203 {
240 _gnutls_io_clear_peeked_data (session); 204 mhd_gtls_io_clear_peeked_data (session);
241 ret = _gnutls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0); 205 ret = mhd_gtls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0);
242 } 206 }
243 while (ret == GNUTLS_E_GOT_APPLICATION_DATA); 207 while (ret == GNUTLS_E_GOT_APPLICATION_DATA);
244 208
@@ -266,13 +230,13 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
266} 230}
267 231
268inline static void 232inline static void
269session_invalidate (gnutls_session_t session) 233session_invalidate (mhd_gtls_session_t session)
270{ 234{
271 session->internals.valid_connection = VALID_FALSE; 235 session->internals.valid_connection = VALID_FALSE;
272} 236}
273 237
274inline static void 238inline static void
275session_unresumable (gnutls_session_t session) 239session_unresumable (mhd_gtls_session_t session)
276{ 240{
277 session->internals.resumable = RESUME_FALSE; 241 session->internals.resumable = RESUME_FALSE;
278} 242}
@@ -280,7 +244,7 @@ session_unresumable (gnutls_session_t session)
280/* returns 0 if session is valid 244/* returns 0 if session is valid
281 */ 245 */
282inline static int 246inline static int
283session_is_valid (gnutls_session_t session) 247session_is_valid (mhd_gtls_session_t session)
284{ 248{
285 if (session->internals.valid_connection == VALID_FALSE) 249 if (session->internals.valid_connection == VALID_FALSE)
286 return GNUTLS_E_INVALID_SESSION; 250 return GNUTLS_E_INVALID_SESSION;
@@ -292,7 +256,7 @@ session_is_valid (gnutls_session_t session)
292 * version must have 2 bytes at least. 256 * version must have 2 bytes at least.
293 */ 257 */
294inline static void 258inline static void
295copy_record_version (gnutls_session_t session, 259copy_record_version (mhd_gtls_session_t session,
296 gnutls_handshake_description_t htype, opaque version[2]) 260 gnutls_handshake_description_t htype, opaque version[2])
297{ 261{
298 gnutls_protocol_t lver; 262 gnutls_protocol_t lver;
@@ -300,10 +264,10 @@ copy_record_version (gnutls_session_t session,
300 if (htype != GNUTLS_HANDSHAKE_CLIENT_HELLO 264 if (htype != GNUTLS_HANDSHAKE_CLIENT_HELLO
301 || session->internals.default_record_version[0] == 0) 265 || session->internals.default_record_version[0] == 0)
302 { 266 {
303 lver = gnutls_protocol_get_version (session); 267 lver = MHD_gnutls_protocol_get_version (session);
304 268
305 version[0] = _gnutls_version_get_major (lver); 269 version[0] = mhd_gtls_version_get_major (lver);
306 version[1] = _gnutls_version_get_minor (lver); 270 version[1] = mhd_gtls_version_get_minor (lver);
307 } 271 }
308 else 272 else
309 { 273 {
@@ -313,7 +277,7 @@ copy_record_version (gnutls_session_t session,
313} 277}
314 278
315/* This function behaves exactly like write(). The only difference is 279/* This function behaves exactly like write(). The only difference is
316 * that it accepts, the gnutls_session_t and the content_type_t of data to 280 * that it accepts, the mhd_gtls_session_t and the content_type_t of data to
317 * send (if called by the user the Content is specific) 281 * send (if called by the user the Content is specific)
318 * It is intended to transfer data, under the current session. 282 * It is intended to transfer data, under the current session.
319 * 283 *
@@ -327,7 +291,7 @@ copy_record_version (gnutls_session_t session,
327 * 291 *
328 */ 292 */
329ssize_t 293ssize_t
330_gnutls_send_int (gnutls_session_t session, 294mhd_gtls_send_int (mhd_gtls_session_t session,
331 content_type_t type, 295 content_type_t type,
332 gnutls_handshake_description_t htype, 296 gnutls_handshake_description_t htype,
333 const void *_data, size_t sizeofdata) 297 const void *_data, size_t sizeofdata)
@@ -366,7 +330,7 @@ _gnutls_send_int (gnutls_session_t session,
366 330
367 _gnutls_record_log 331 _gnutls_record_log
368 ("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session, 332 ("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session,
369 (int) _gnutls_uint64touint32 (&session->connection_state. 333 (int) mhd_gtls_uint64touint32 (&session->connection_state.
370 write_sequence_number), 334 write_sequence_number),
371 _gnutls_packet2str (type), type, sizeofdata); 335 _gnutls_packet2str (type), type, sizeofdata);
372 336
@@ -380,7 +344,7 @@ _gnutls_send_int (gnutls_session_t session,
380 */ 344 */
381 if (session->internals.record_send_buffer.length > 0) 345 if (session->internals.record_send_buffer.length > 0)
382 { 346 {
383 ret = _gnutls_io_write_flush (session); 347 ret = mhd_gtls_io_write_flush (session);
384 if (ret > 0) 348 if (ret > 0)
385 cipher_size = ret; 349 cipher_size = ret;
386 else 350 else
@@ -403,7 +367,7 @@ _gnutls_send_int (gnutls_session_t session,
403 } 367 }
404 368
405 cipher_size = 369 cipher_size =
406 _gnutls_encrypt (session, headers, RECORD_HEADER_SIZE, data, 370 mhd_gtls_encrypt (session, headers, RECORD_HEADER_SIZE, data,
407 data2send_size, cipher, cipher_size, type, 371 data2send_size, cipher, cipher_size, type,
408 (session->internals.priorities.no_padding == 372 (session->internals.priorities.no_padding ==
409 0) ? 1 : 0); 373 0) ? 1 : 0);
@@ -421,7 +385,7 @@ _gnutls_send_int (gnutls_session_t session,
421 385
422 /* increase sequence number 386 /* increase sequence number
423 */ 387 */
424 if (_gnutls_uint64pp 388 if (mhd_gtls_uint64pp
425 (&session->connection_state.write_sequence_number) != 0) 389 (&session->connection_state.write_sequence_number) != 0)
426 { 390 {
427 session_invalidate (session); 391 session_invalidate (session);
@@ -430,13 +394,13 @@ _gnutls_send_int (gnutls_session_t session,
430 return GNUTLS_E_RECORD_LIMIT_REACHED; 394 return GNUTLS_E_RECORD_LIMIT_REACHED;
431 } 395 }
432 396
433 ret = _gnutls_io_write_buffered (session, cipher, cipher_size); 397 ret = mhd_gtls_io_write_buffered (session, cipher, cipher_size);
434 gnutls_free (cipher); 398 gnutls_free (cipher);
435 } 399 }
436 400
437 if (ret != cipher_size) 401 if (ret != cipher_size)
438 { 402 {
439 if (ret < 0 && gnutls_error_is_fatal (ret) == 0) 403 if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
440 { 404 {
441 /* If we have sent any data then just return 405 /* If we have sent any data then just return
442 * the error value. Do not invalidate the session. 406 * the error value. Do not invalidate the session.
@@ -460,7 +424,7 @@ _gnutls_send_int (gnutls_session_t session,
460 424
461 _gnutls_record_log ("REC[%x]: Sent Packet[%d] %s(%d) with length: %d\n", 425 _gnutls_record_log ("REC[%x]: Sent Packet[%d] %s(%d) with length: %d\n",
462 session, 426 session,
463 (int) _gnutls_uint64touint32 (&session-> 427 (int) mhd_gtls_uint64touint32 (&session->
464 connection_state. 428 connection_state.
465 write_sequence_number), 429 write_sequence_number),
466 _gnutls_packet2str (type), type, cipher_size); 430 _gnutls_packet2str (type), type, cipher_size);
@@ -472,7 +436,7 @@ _gnutls_send_int (gnutls_session_t session,
472 * completed. This sends a Change Cipher Spec packet to the peer. 436 * completed. This sends a Change Cipher Spec packet to the peer.
473 */ 437 */
474ssize_t 438ssize_t
475_gnutls_send_change_cipher_spec (gnutls_session_t session, int again) 439mhd_gtls_send_change_cipher_spec (mhd_gtls_session_t session, int again)
476{ 440{
477 static const opaque data[1] = { 441 static const opaque data[1] = {
478 GNUTLS_TYPE_CHANGE_CIPHER_SPEC 442 GNUTLS_TYPE_CHANGE_CIPHER_SPEC
@@ -481,10 +445,10 @@ _gnutls_send_change_cipher_spec (gnutls_session_t session, int again)
481 _gnutls_handshake_log ("REC[%x]: Sent ChangeCipherSpec\n", session); 445 _gnutls_handshake_log ("REC[%x]: Sent ChangeCipherSpec\n", session);
482 446
483 if (again == 0) 447 if (again == 0)
484 return _gnutls_send_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, data, 1); 448 return mhd_gtls_send_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, data, 1);
485 else 449 else
486 { 450 {
487 return _gnutls_io_write_flush (session); 451 return mhd_gtls_io_write_flush (session);
488 } 452 }
489} 453}
490 454
@@ -510,16 +474,16 @@ check_recv_type (content_type_t recv_type)
510 * then it copies the data. 474 * then it copies the data.
511 */ 475 */
512static int 476static int
513check_buffers (gnutls_session_t session, 477check_buffers (mhd_gtls_session_t session,
514 content_type_t type, opaque * data, int sizeofdata) 478 content_type_t type, opaque * data, int sizeofdata)
515{ 479{
516 if ((type == GNUTLS_APPLICATION_DATA || type == GNUTLS_HANDSHAKE || type 480 if ((type == GNUTLS_APPLICATION_DATA || type == GNUTLS_HANDSHAKE || type
517 == GNUTLS_INNER_APPLICATION) && _gnutls_record_buffer_get_size (type, 481 == GNUTLS_INNER_APPLICATION) && mhd_gnutls_record_buffer_get_size (type,
518 session) 482 session)
519 > 0) 483 > 0)
520 { 484 {
521 int ret, ret2; 485 int ret, ret2;
522 ret = _gnutls_record_buffer_get (type, session, data, sizeofdata); 486 ret = mhd_gtls_record_buffer_get (type, session, data, sizeofdata);
523 if (ret < 0) 487 if (ret < 0)
524 { 488 {
525 gnutls_assert (); 489 gnutls_assert ();
@@ -527,9 +491,9 @@ check_buffers (gnutls_session_t session,
527 } 491 }
528 492
529 /* if the buffer just got empty */ 493 /* if the buffer just got empty */
530 if (_gnutls_record_buffer_get_size (type, session) == 0) 494 if (mhd_gnutls_record_buffer_get_size (type, session) == 0)
531 { 495 {
532 if ((ret2 = _gnutls_io_clear_peeked_data (session)) < 0) 496 if ((ret2 = mhd_gtls_io_clear_peeked_data (session)) < 0)
533 { 497 {
534 gnutls_assert (); 498 gnutls_assert ();
535 return ret2; 499 return ret2;
@@ -546,7 +510,7 @@ check_buffers (gnutls_session_t session,
546 * content type. 510 * content type.
547 */ 511 */
548static int 512static int
549record_check_headers (gnutls_session_t session, 513record_check_headers (mhd_gtls_session_t session,
550 uint8_t headers[RECORD_HEADER_SIZE], 514 uint8_t headers[RECORD_HEADER_SIZE],
551 content_type_t type, 515 content_type_t type,
552 gnutls_handshake_description_t htype, 516 gnutls_handshake_description_t htype,
@@ -594,7 +558,7 @@ record_check_headers (gnutls_session_t session,
594 558
595 /* No DECR_LEN, since headers has enough size. 559 /* No DECR_LEN, since headers has enough size.
596 */ 560 */
597 *length = _gnutls_read_uint16 (&headers[3]); 561 *length = mhd_gtls_read_uint16 (&headers[3]);
598 } 562 }
599 563
600 return 0; 564 return 0;
@@ -604,7 +568,7 @@ record_check_headers (gnutls_session_t session,
604 * negotiated in the handshake. 568 * negotiated in the handshake.
605 */ 569 */
606inline static int 570inline static int
607record_check_version (gnutls_session_t session, 571record_check_version (mhd_gtls_session_t session,
608 gnutls_handshake_description_t htype, opaque version[2]) 572 gnutls_handshake_description_t htype, opaque version[2])
609{ 573{
610 if (htype == GNUTLS_HANDSHAKE_CLIENT_HELLO) 574 if (htype == GNUTLS_HANDSHAKE_CLIENT_HELLO)
@@ -621,8 +585,8 @@ record_check_version (gnutls_session_t session,
621 } 585 }
622 } 586 }
623 else if (htype != GNUTLS_HANDSHAKE_SERVER_HELLO 587 else if (htype != GNUTLS_HANDSHAKE_SERVER_HELLO
624 && gnutls_protocol_get_version (session) 588 && MHD_gnutls_protocol_get_version (session)
625 != _gnutls_version_get (version[0], version[1])) 589 != mhd_gtls_version_get (version[0], version[1]))
626 { 590 {
627 /* Reject record packets that have a different version than the 591 /* Reject record packets that have a different version than the
628 * one negotiated. Note that this version is not protected by any 592 * one negotiated. Note that this version is not protected by any
@@ -642,7 +606,7 @@ record_check_version (gnutls_session_t session,
642 * the one we actually expect. 606 * the one we actually expect.
643 */ 607 */
644static int 608static int
645record_check_type (gnutls_session_t session, 609record_check_type (mhd_gtls_session_t session,
646 content_type_t recv_type, 610 content_type_t recv_type,
647 content_type_t type, 611 content_type_t type,
648 gnutls_handshake_description_t htype, 612 gnutls_handshake_description_t htype,
@@ -655,7 +619,7 @@ record_check_type (gnutls_session_t session,
655 == GNUTLS_HANDSHAKE 619 == GNUTLS_HANDSHAKE
656 || type == GNUTLS_INNER_APPLICATION)) 620 || type == GNUTLS_INNER_APPLICATION))
657 { 621 {
658 _gnutls_record_buffer_put (type, session, (void *) data, data_size); 622 mhd_gnutls_record_buffer_put (type, session, (void *) data, data_size);
659 } 623 }
660 else 624 else
661 { 625 {
@@ -665,7 +629,7 @@ record_check_type (gnutls_session_t session,
665 629
666 _gnutls_record_log 630 _gnutls_record_log
667 ("REC[%x]: Alert[%d|%d] - %s - was received\n", session, 631 ("REC[%x]: Alert[%d|%d] - %s - was received\n", session,
668 data[0], data[1], gnutls_alert_get_name ((int) data[1])); 632 data[0], data[1], MHD_gnutls_alert_get_name ((int) data[1]));
669 633
670 session->internals.last_alert = data[1]; 634 session->internals.last_alert = data[1];
671 session->internals.last_alert_level = data[0]; 635 session->internals.last_alert_level = data[0];
@@ -710,7 +674,7 @@ record_check_type (gnutls_session_t session,
710 case GNUTLS_APPLICATION_DATA: 674 case GNUTLS_APPLICATION_DATA:
711 /* even if data is unexpected put it into the buffer */ 675 /* even if data is unexpected put it into the buffer */
712 if ((ret = 676 if ((ret =
713 _gnutls_record_buffer_put (recv_type, session, (void *) data, 677 mhd_gnutls_record_buffer_put (recv_type, session, (void *) data,
714 data_size)) < 0) 678 data_size)) < 0)
715 { 679 {
716 gnutls_assert (); 680 gnutls_assert ();
@@ -747,13 +711,13 @@ record_check_type (gnutls_session_t session,
747 */ 711 */
748 712
749 /* So we accept it */ 713 /* So we accept it */
750 return _gnutls_recv_hello_request (session, data, data_size); 714 return mhd_gtls_recv_hello_request (session, data, data_size);
751 715
752 break; 716 break;
753 case GNUTLS_INNER_APPLICATION: 717 case GNUTLS_INNER_APPLICATION:
754 /* even if data is unexpected put it into the buffer */ 718 /* even if data is unexpected put it into the buffer */
755 if ((ret = 719 if ((ret =
756 _gnutls_record_buffer_put (recv_type, session, (void *) data, 720 mhd_gnutls_record_buffer_put (recv_type, session, (void *) data,
757 data_size)) < 0) 721 data_size)) < 0)
758 { 722 {
759 gnutls_assert (); 723 gnutls_assert ();
@@ -782,7 +746,7 @@ record_check_type (gnutls_session_t session,
782 * also initialize it. 746 * also initialize it.
783 */ 747 */
784inline static int 748inline static int
785get_temp_recv_buffer (gnutls_session_t session, gnutls_datum_t * tmp) 749get_temp_recv_buffer (mhd_gtls_session_t session, gnutls_datum_t * tmp)
786{ 750{
787 size_t max_record_size; 751 size_t max_record_size;
788 752
@@ -824,14 +788,14 @@ get_temp_recv_buffer (gnutls_session_t session, gnutls_datum_t * tmp)
824#define MAX_EMPTY_PACKETS_SEQUENCE 4 788#define MAX_EMPTY_PACKETS_SEQUENCE 4
825 789
826/* This function behaves exactly like read(). The only difference is 790/* This function behaves exactly like read(). The only difference is
827 * that it accepts the gnutls_session_t and the content_type_t of data to 791 * that it accepts the mhd_gtls_session_t and the content_type_t of data to
828 * receive (if called by the user the Content is Userdata only) 792 * receive (if called by the user the Content is Userdata only)
829 * It is intended to receive data, under the current session. 793 * It is intended to receive data, under the current session.
830 * 794 *
831 * The gnutls_handshake_description_t was introduced to support SSL V2.0 client hellos. 795 * The gnutls_handshake_description_t was introduced to support SSL V2.0 client hellos.
832 */ 796 */
833ssize_t 797ssize_t
834_gnutls_recv_int (gnutls_session_t session, 798mhd_gtls_recv_int (mhd_gtls_session_t session,
835 content_type_t type, 799 content_type_t type,
836 gnutls_handshake_description_t htype, 800 gnutls_handshake_description_t htype,
837 opaque * data, size_t sizeofdata) 801 opaque * data, size_t sizeofdata)
@@ -885,10 +849,10 @@ begin:
885 */ 849 */
886 header_size = RECORD_HEADER_SIZE; 850 header_size = RECORD_HEADER_SIZE;
887 851
888 if ((ret = _gnutls_io_read_buffered (session, &headers, header_size, -1)) 852 if ((ret = mhd_gtls_io_read_buffered (session, &headers, header_size, -1))
889 != header_size) 853 != header_size)
890 { 854 {
891 if (ret < 0 && gnutls_error_is_fatal (ret) == 0) 855 if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
892 return ret; 856 return ret;
893 857
894 session_invalidate (session); 858 session_invalidate (session);
@@ -930,12 +894,12 @@ begin:
930 894
931 _gnutls_record_log 895 _gnutls_record_log
932 ("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session, 896 ("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session,
933 (int) _gnutls_uint64touint32 (&session->connection_state. 897 (int) mhd_gtls_uint64touint32 (&session->connection_state.
934 read_sequence_number), 898 read_sequence_number),
935 _gnutls_packet2str (type), type, sizeofdata); 899 _gnutls_packet2str (type), type, sizeofdata);
936 _gnutls_record_log 900 _gnutls_record_log
937 ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", session, 901 ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", session,
938 (int) _gnutls_uint64touint32 (&session->connection_state. 902 (int) mhd_gtls_uint64touint32 (&session->connection_state.
939 read_sequence_number), 903 read_sequence_number),
940 _gnutls_packet2str (recv_type), recv_type, length); 904 _gnutls_packet2str (recv_type), recv_type, length);
941 905
@@ -953,11 +917,11 @@ begin:
953 917
954 /* check if we have that data into buffer. 918 /* check if we have that data into buffer.
955 */ 919 */
956 if ((ret = _gnutls_io_read_buffered (session, &recv_data, 920 if ((ret = mhd_gtls_io_read_buffered (session, &recv_data,
957 header_size + length, recv_type)) 921 header_size + length, recv_type))
958 != header_size + length) 922 != header_size + length)
959 { 923 {
960 if (ret < 0 && gnutls_error_is_fatal (ret) == 0) 924 if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
961 return ret; 925 return ret;
962 926
963 session_unresumable (session); 927 session_unresumable (session);
@@ -969,7 +933,7 @@ begin:
969 /* ok now we are sure that we can read all the data - so 933 /* ok now we are sure that we can read all the data - so
970 * move on ! 934 * move on !
971 */ 935 */
972 _gnutls_io_clear_read_buffer (session); 936 mhd_gtls_io_clear_read_buffer (session);
973 ciphertext = &recv_data[header_size]; 937 ciphertext = &recv_data[header_size];
974 938
975 ret = get_temp_recv_buffer (session, &tmp); 939 ret = get_temp_recv_buffer (session, &tmp);
@@ -980,7 +944,7 @@ begin:
980 } 944 }
981 945
982 /* decrypt the data we got. */ 946 /* decrypt the data we got. */
983 ret = _gnutls_decrypt (session, ciphertext, length, tmp.data, tmp.size, 947 ret = mhd_gtls_decrypt (session, ciphertext, length, tmp.data, tmp.size,
984 recv_type); 948 recv_type);
985 if (ret < 0) 949 if (ret < 0)
986 { 950 {
@@ -1012,13 +976,13 @@ begin:
1012 976
1013 _gnutls_record_log 977 _gnutls_record_log
1014 ("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session, 978 ("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session,
1015 (int) _gnutls_uint64touint32 (&session->connection_state. 979 (int) mhd_gtls_uint64touint32 (&session->connection_state.
1016 read_sequence_number), 980 read_sequence_number),
1017 _gnutls_packet2str (recv_type), recv_type, decrypted_length); 981 _gnutls_packet2str (recv_type), recv_type, decrypted_length);
1018 982
1019 /* increase sequence number 983 /* increase sequence number
1020 */ 984 */
1021 if (_gnutls_uint64pp (&session->connection_state.read_sequence_number) != 0) 985 if (mhd_gtls_uint64pp (&session->connection_state.read_sequence_number) != 0)
1022 { 986 {
1023 session_invalidate (session); 987 session_invalidate (session);
1024 gnutls_assert (); 988 gnutls_assert ();
@@ -1043,7 +1007,7 @@ begin:
1043 || type == GNUTLS_INNER_APPLICATION)) 1007 || type == GNUTLS_INNER_APPLICATION))
1044 { 1008 {
1045 1009
1046 ret = _gnutls_record_buffer_get (type, session, data, sizeofdata); 1010 ret = mhd_gtls_record_buffer_get (type, session, data, sizeofdata);
1047 if (ret < 0) 1011 if (ret < 0)
1048 { 1012 {
1049 gnutls_assert (); 1013 gnutls_assert ();
@@ -1052,9 +1016,9 @@ begin:
1052 1016
1053 /* if the buffer just got empty 1017 /* if the buffer just got empty
1054 */ 1018 */
1055 if (_gnutls_record_buffer_get_size (type, session) == 0) 1019 if (mhd_gnutls_record_buffer_get_size (type, session) == 0)
1056 { 1020 {
1057 if ((ret2 = _gnutls_io_clear_peeked_data (session)) < 0) 1021 if ((ret2 = mhd_gtls_io_clear_peeked_data (session)) < 0)
1058 { 1022 {
1059 gnutls_assert (); 1023 gnutls_assert ();
1060 return ret2; 1024 return ret2;
@@ -1086,8 +1050,8 @@ begin:
1086} 1050}
1087 1051
1088/** 1052/**
1089 * gnutls_record_send - sends to the peer the specified data 1053 * MHD_gnutls_record_send - sends to the peer the specified data
1090 * @session: is a #gnutls_session_t structure. 1054 * @session: is a #mhd_gtls_session_t structure.
1091 * @data: contains the data to send 1055 * @data: contains the data to send
1092 * @sizeofdata: is the length of the data 1056 * @sizeofdata: is the length of the data
1093 * 1057 *
@@ -1098,7 +1062,7 @@ begin:
1098 * Note that if the send buffer is full, send() will block this 1062 * Note that if the send buffer is full, send() will block this
1099 * function. See the send() documentation for full information. You 1063 * function. See the send() documentation for full information. You
1100 * can replace the default push function by using 1064 * can replace the default push function by using
1101 * gnutls_transport_set_ptr2() with a call to send() with a 1065 * MHD_gnutls_transport_set_ptr2() with a call to send() with a
1102 * MSG_DONTWAIT flag if blocking is a problem. 1066 * MSG_DONTWAIT flag if blocking is a problem.
1103 * 1067 *
1104 * If the EINTR is returned by the internal push function (the 1068 * If the EINTR is returned by the internal push function (the
@@ -1106,7 +1070,7 @@ begin:
1106 * %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must 1070 * %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must
1107 * call this function again, with the same parameters; alternatively 1071 * call this function again, with the same parameters; alternatively
1108 * you could provide a %NULL pointer for data, and 0 for 1072 * you could provide a %NULL pointer for data, and 0 for
1109 * size. cf. gnutls_record_get_direction(). 1073 * size. cf. MHD_gnutls_record_get_direction().
1110 * 1074 *
1111 * Returns: the number of bytes sent, or a negative error code. The 1075 * Returns: the number of bytes sent, or a negative error code. The
1112 * number of bytes sent might be less than @sizeofdata. The maximum 1076 * number of bytes sent might be less than @sizeofdata. The maximum
@@ -1114,16 +1078,16 @@ begin:
1114 * the negotiated maximum record size. 1078 * the negotiated maximum record size.
1115 **/ 1079 **/
1116ssize_t 1080ssize_t
1117gnutls_record_send (gnutls_session_t session, 1081MHD_gnutls_record_send (mhd_gtls_session_t session,
1118 const void *data, size_t sizeofdata) 1082 const void *data, size_t sizeofdata)
1119{ 1083{
1120 return _gnutls_send_int (session, GNUTLS_APPLICATION_DATA, -1, data, 1084 return mhd_gtls_send_int (session, GNUTLS_APPLICATION_DATA, -1, data,
1121 sizeofdata); 1085 sizeofdata);
1122} 1086}
1123 1087
1124/** 1088/**
1125 * gnutls_record_recv - reads data from the TLS record protocol 1089 * MHD_gnutls_record_recv - reads data from the TLS record protocol
1126 * @session: is a #gnutls_session_t structure. 1090 * @session: is a #mhd_gtls_session_t structure.
1127 * @data: the buffer that the data will be read into 1091 * @data: the buffer that the data will be read into
1128 * @sizeofdata: the number of requested bytes 1092 * @sizeofdata: the number of requested bytes
1129 * 1093 *
@@ -1141,7 +1105,7 @@ gnutls_record_send (gnutls_session_t session,
1141 * is recv()) then %GNUTLS_E_INTERRUPTED will be returned. If 1105 * is recv()) then %GNUTLS_E_INTERRUPTED will be returned. If
1142 * %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must 1106 * %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must
1143 * call this function again to get the data. See also 1107 * call this function again to get the data. See also
1144 * gnutls_record_get_direction(). 1108 * MHD_gnutls_record_get_direction().
1145 * 1109 *
1146 * A server may also receive %GNUTLS_E_REHANDSHAKE when a client has 1110 * A server may also receive %GNUTLS_E_REHANDSHAKE when a client has
1147 * initiated a handshake. In that case the server can only initiate a 1111 * initiated a handshake. In that case the server can only initiate a
@@ -1152,22 +1116,22 @@ gnutls_record_send (gnutls_session_t session,
1152 * received might be less than @sizeofdata. 1116 * received might be less than @sizeofdata.
1153 **/ 1117 **/
1154ssize_t 1118ssize_t
1155gnutls_record_recv (gnutls_session_t session, void *data, size_t sizeofdata) 1119MHD_gnutls_record_recv (mhd_gtls_session_t session, void *data, size_t sizeofdata)
1156{ 1120{
1157 return _gnutls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data, 1121 return mhd_gtls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data,
1158 sizeofdata); 1122 sizeofdata);
1159} 1123}
1160 1124
1161/** 1125/**
1162 * gnutls_record_get_max_size - returns the maximum record size 1126 * MHD_gnutls_record_get_max_size - returns the maximum record size
1163 * @session: is a #gnutls_session_t structure. 1127 * @session: is a #mhd_gtls_session_t structure.
1164 * 1128 *
1165 * This function returns the maximum record packet size in this 1129 * This function returns the maximum record packet size in this
1166 * connection. The maximum record size is negotiated by the client 1130 * connection. The maximum record size is negotiated by the client
1167 * after the first handshake message. 1131 * after the first handshake message.
1168 **/ 1132 **/
1169size_t 1133size_t
1170gnutls_record_get_max_size (gnutls_session_t session) 1134MHD_gnutls_record_get_max_size (mhd_gtls_session_t session)
1171{ 1135{
1172 /* Recv will hold the negotiated max record size 1136 /* Recv will hold the negotiated max record size
1173 * always. 1137 * always.
@@ -1176,8 +1140,8 @@ gnutls_record_get_max_size (gnutls_session_t session)
1176} 1140}
1177 1141
1178/** 1142/**
1179 * gnutls_record_set_max_size - sets the maximum record size 1143 * MHD_gnutls_record_set_max_size - sets the maximum record size
1180 * @session: is a #gnutls_session_t structure. 1144 * @session: is a #mhd_gtls_session_t structure.
1181 * @size: is the new size 1145 * @size: is the new size
1182 * 1146 *
1183 * This function sets the maximum record packet size in this 1147 * This function sets the maximum record packet size in this
@@ -1193,14 +1157,14 @@ gnutls_record_get_max_size (gnutls_session_t session)
1193 * all TLS implementations use or even understand this extension. 1157 * all TLS implementations use or even understand this extension.
1194 **/ 1158 **/
1195ssize_t 1159ssize_t
1196gnutls_record_set_max_size (gnutls_session_t session, size_t size) 1160MHD_gnutls_record_set_max_size (mhd_gtls_session_t session, size_t size)
1197{ 1161{
1198 ssize_t new_size; 1162 ssize_t new_size;
1199 1163
1200 if (session->security_parameters.entity == GNUTLS_SERVER) 1164 if (session->security_parameters.entity == GNUTLS_SERVER)
1201 return GNUTLS_E_INVALID_REQUEST; 1165 return GNUTLS_E_INVALID_REQUEST;
1202 1166
1203 new_size = _gnutls_mre_record2num (size); 1167 new_size = mhd_gtls_mre_record2num (size);
1204 1168
1205 if (new_size < 0) 1169 if (new_size < 0)
1206 { 1170 {
diff --git a/src/daemon/https/tls/gnutls_record.h b/src/daemon/https/tls/gnutls_record.h
index 5595f32a..74069bfc 100644
--- a/src/daemon/https/tls/gnutls_record.h
+++ b/src/daemon/https/tls/gnutls_record.h
@@ -22,11 +22,11 @@
22 * 22 *
23 */ 23 */
24 24
25ssize_t _gnutls_send_int (gnutls_session_t session, content_type_t type, 25ssize_t mhd_gtls_send_int (mhd_gtls_session_t session, content_type_t type,
26 gnutls_handshake_description_t htype, 26 gnutls_handshake_description_t htype,
27 const void *data, size_t sizeofdata); 27 const void *data, size_t sizeofdata);
28ssize_t _gnutls_recv_int (gnutls_session_t session, content_type_t type, 28ssize_t mhd_gtls_recv_int (mhd_gtls_session_t session, content_type_t type,
29 gnutls_handshake_description_t, opaque * data, 29 gnutls_handshake_description_t, opaque * data,
30 size_t sizeofdata); 30 size_t sizeofdata);
31ssize_t _gnutls_send_change_cipher_spec (gnutls_session_t session, int again); 31ssize_t mhd_gtls_send_change_cipher_spec (mhd_gtls_session_t session, int again);
32void gnutls_transport_set_lowat (gnutls_session_t session, int num); 32void MHD_gnutls_transport_set_lowat (mhd_gtls_session_t session, int num);
diff --git a/src/daemon/https/tls/gnutls_rsa_export.c b/src/daemon/https/tls/gnutls_rsa_export.c
index 7f4fafe1..c939f06e 100644
--- a/src/daemon/https/tls/gnutls_rsa_export.c
+++ b/src/daemon/https/tls/gnutls_rsa_export.c
@@ -46,7 +46,7 @@
46 * We only support limited key sizes. 46 * We only support limited key sizes.
47 */ 47 */
48const mpi_t * 48const mpi_t *
49_gnutls_rsa_params_to_mpi (gnutls_rsa_params_t rsa_params) 49_gnutls_rsa_params_to_mpi (mhd_gtls_rsa_params_t rsa_params)
50{ 50{
51 if (rsa_params == NULL) 51 if (rsa_params == NULL)
52 { 52 {
@@ -167,42 +167,15 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
167 167
168} 168}
169 169
170
171/**
172 * gnutls_rsa_params_import_raw - This function will replace the old RSA parameters
173 * @rsa_params: Is a structure will hold the parameters
174 * @m: holds the modulus
175 * @e: holds the public exponent
176 * @d: holds the private exponent
177 * @p: holds the first prime (p)
178 * @q: holds the second prime (q)
179 * @u: holds the coefficient
180 *
181 * This function will replace the parameters in the given structure.
182 * The new parameters should be stored in the appropriate gnutls_datum.
183 *
184 **/
185int
186gnutls_rsa_params_import_raw (gnutls_rsa_params_t rsa_params,
187 const gnutls_datum_t * m,
188 const gnutls_datum_t * e,
189 const gnutls_datum_t * d,
190 const gnutls_datum_t * p,
191 const gnutls_datum_t * q,
192 const gnutls_datum_t * u)
193{
194 return gnutls_x509_privkey_import_rsa_raw (rsa_params, m, e, d, p, q, u);
195}
196
197/** 170/**
198 * gnutls_rsa_params_init - This function will initialize the temporary RSA parameters 171 * MHD_gnutls_rsa_params_init - This function will initialize the temporary RSA parameters
199 * @rsa_params: Is a structure that will hold the parameters 172 * @rsa_params: Is a structure that will hold the parameters
200 * 173 *
201 * This function will initialize the temporary RSA parameters structure. 174 * This function will initialize the temporary RSA parameters structure.
202 * 175 *
203 **/ 176 **/
204int 177int
205gnutls_rsa_params_init (gnutls_rsa_params_t * rsa_params) 178MHD_gnutls_rsa_params_init (mhd_gtls_rsa_params_t * rsa_params)
206{ 179{
207 int ret; 180 int ret;
208 181
@@ -219,42 +192,27 @@ gnutls_rsa_params_init (gnutls_rsa_params_t * rsa_params)
219} 192}
220 193
221/** 194/**
222 * gnutls_rsa_params_deinit - This function will deinitialize the RSA parameters 195 * MHD_gnutls_rsa_params_deinit - This function will deinitialize the RSA parameters
223 * @rsa_params: Is a structure that holds the parameters 196 * @rsa_params: Is a structure that holds the parameters
224 * 197 *
225 * This function will deinitialize the RSA parameters structure. 198 * This function will deinitialize the RSA parameters structure.
226 * 199 *
227 **/ 200 **/
228void 201void
229gnutls_rsa_params_deinit (gnutls_rsa_params_t rsa_params) 202MHD_gnutls_rsa_params_deinit (mhd_gtls_rsa_params_t rsa_params)
230{ 203{
231 gnutls_x509_privkey_deinit (rsa_params); 204 gnutls_x509_privkey_deinit (rsa_params);
232} 205}
233 206
234/** 207/**
235 * gnutls_rsa_params_cpy - This function will copy an RSA parameters structure 208 * MHD_gnutls_rsa_params_generate2 - This function will generate temporary RSA parameters
236 * @dst: Is the destination structure, which should be initialized.
237 * @src: Is the source structure
238 *
239 * This function will copy the RSA parameters structure from source
240 * to destination.
241 *
242 **/
243int
244gnutls_rsa_params_cpy (gnutls_rsa_params_t dst, gnutls_rsa_params_t src)
245{
246 return gnutls_x509_privkey_cpy (dst, src);
247}
248
249/**
250 * gnutls_rsa_params_generate2 - This function will generate temporary RSA parameters
251 * @params: The structure where the parameters will be stored 209 * @params: The structure where the parameters will be stored
252 * @bits: is the prime's number of bits 210 * @bits: is the prime's number of bits
253 * 211 *
254 * This function will generate new temporary RSA parameters for use in 212 * This function will generate new temporary RSA parameters for use in
255 * RSA-EXPORT ciphersuites. This function is normally slow. 213 * RSA-EXPORT ciphersuites. This function is normally slow.
256 * 214 *
257 * Note that if the parameters are to be used in export cipher suites the 215 * Note that if the parameters are to be used in export cipher suites the
258 * bits value should be 512 or less. 216 * bits value should be 512 or less.
259 * Also note that the generation of new RSA parameters is only useful 217 * Also note that the generation of new RSA parameters is only useful
260 * to servers. Clients use the parameters sent by the server, thus it's 218 * to servers. Clients use the parameters sent by the server, thus it's
@@ -262,100 +220,7 @@ gnutls_rsa_params_cpy (gnutls_rsa_params_t dst, gnutls_rsa_params_t src)
262 * 220 *
263 **/ 221 **/
264int 222int
265gnutls_rsa_params_generate2 (gnutls_rsa_params_t params, unsigned int bits) 223MHD_gnutls_rsa_params_generate2 (mhd_gtls_rsa_params_t params, unsigned int bits)
266{ 224{
267 return gnutls_x509_privkey_generate (params, MHD_GNUTLS_PK_RSA, bits, 0); 225 return gnutls_x509_privkey_generate (params, MHD_GNUTLS_PK_RSA, bits, 0);
268} 226}
269
270/**
271 * gnutls_rsa_params_import_pkcs1 - This function will import RSA params from a pkcs1 structure
272 * @params: A structure where the parameters will be copied to
273 * @pkcs1_params: should contain a PKCS1 RSAPublicKey structure PEM or DER encoded
274 * @format: the format of params. PEM or DER.
275 *
276 * This function will extract the RSAPublicKey found in a PKCS1 formatted
277 * structure.
278 *
279 * If the structure is PEM encoded, it should have a header
280 * of "BEGIN RSA PRIVATE KEY".
281 *
282 * In case of failure a negative value will be returned, and
283 * 0 on success.
284 *
285 **/
286int
287gnutls_rsa_params_import_pkcs1 (gnutls_rsa_params_t params,
288 const gnutls_datum_t * pkcs1_params,
289 gnutls_x509_crt_fmt_t format)
290{
291 return gnutls_x509_privkey_import (params, pkcs1_params, format);
292}
293
294
295/**
296 * gnutls_rsa_params_export_pkcs1 - This function will export RSA params to a pkcs1 structure
297 * @params: Holds the RSA parameters
298 * @format: the format of output params. One of PEM or DER.
299 * @params_data: will contain a PKCS1 RSAPublicKey structure PEM or DER encoded
300 * @params_data_size: holds the size of params_data (and will be replaced by the actual size of parameters)
301 *
302 * This function will export the given RSA parameters to a PKCS1
303 * RSAPublicKey structure. If the buffer provided is not long enough to
304 * hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
305 *
306 * If the structure is PEM encoded, it will have a header
307 * of "BEGIN RSA PRIVATE KEY".
308 *
309 * In case of failure a negative value will be returned, and
310 * 0 on success.
311 *
312 **/
313int
314gnutls_rsa_params_export_pkcs1 (gnutls_rsa_params_t params,
315 gnutls_x509_crt_fmt_t format,
316 unsigned char *params_data,
317 size_t * params_data_size)
318{
319 return gnutls_x509_privkey_export (params, format,
320 params_data, params_data_size);
321}
322
323
324/**
325 * gnutls_rsa_params_export_raw - This function will export the RSA parameters
326 * @params: a structure that holds the rsa parameters
327 * @m: will hold the modulus
328 * @e: will hold the public exponent
329 * @d: will hold the private exponent
330 * @p: will hold the first prime (p)
331 * @q: will hold the second prime (q)
332 * @u: will hold the coefficient
333 * @bits: if non null will hold the prime's number of bits
334 *
335 * This function will export the RSA parameters found in the given
336 * structure. The new parameters will be allocated using
337 * gnutls_malloc() and will be stored in the appropriate datum.
338 *
339 **/
340int
341gnutls_rsa_params_export_raw (gnutls_rsa_params_t params,
342 gnutls_datum_t * m, gnutls_datum_t * e,
343 gnutls_datum_t * d, gnutls_datum_t * p,
344 gnutls_datum_t * q, gnutls_datum_t * u,
345 unsigned int *bits)
346{
347 int ret;
348
349 ret = gnutls_x509_privkey_export_rsa_raw (params, m, e, d, p, q, u);
350 if (ret < 0)
351 {
352 gnutls_assert ();
353 return ret;
354 }
355
356 if (bits)
357 *bits = _gnutls_mpi_get_nbits (params->params[3]);
358
359 return 0;
360
361}
diff --git a/src/daemon/https/tls/gnutls_rsa_export.h b/src/daemon/https/tls/gnutls_rsa_export.h
index b39e5e93..029e38c5 100644
--- a/src/daemon/https/tls/gnutls_rsa_export.h
+++ b/src/daemon/https/tls/gnutls_rsa_export.h
@@ -22,6 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25const mpi_t *_gnutls_rsa_params_to_mpi (gnutls_rsa_params_t); 25const mpi_t * _gnutls_rsa_params_to_mpi (mhd_gtls_rsa_params_t);
26int _gnutls_peers_cert_less_512 (gnutls_session_t session); 26int _gnutls_peers_cert_less_512 (mhd_gtls_session_t session);
27int _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits); 27int _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits);
diff --git a/src/daemon/https/tls/gnutls_session.c b/src/daemon/https/tls/gnutls_session.c
index fb9b5e80..94c7405b 100644
--- a/src/daemon/https/tls/gnutls_session.c
+++ b/src/daemon/https/tls/gnutls_session.c
@@ -27,9 +27,11 @@
27#include "gnutls_session_pack.h" 27#include "gnutls_session_pack.h"
28#include <gnutls_datum.h> 28#include <gnutls_datum.h>
29 29
30/* TODO this file should be removed if session resumption will be abandoned */
31
30/** 32/**
31 * gnutls_session_get_data - Returns all session parameters. 33 * gnutls_session_get_data - Returns all session parameters.
32 * @session: is a #gnutls_session_t structure. 34 * @session: is a #mhd_gtls_session_t structure.
33 * @session_data: is a pointer to space to hold the session. 35 * @session_data: is a pointer to space to hold the session.
34 * @session_data_size: is the session_data's size, or it will be set by the function. 36 * @session_data_size: is the session_data's size, or it will be set by the function.
35 * 37 *
@@ -40,46 +42,46 @@
40 * 42 *
41 * Resuming sessions is really useful and speedups connections after a succesful one. 43 * Resuming sessions is really useful and speedups connections after a succesful one.
42 **/ 44 **/
43int 45//int
44gnutls_session_get_data (gnutls_session_t session, 46//gnutls_session_get_data (mhd_gtls_session_t session,
45 void *session_data, size_t * session_data_size) 47// void *session_data, size_t * session_data_size)
46{ 48//{
47 49//
48 gnutls_datum_t psession; 50// gnutls_datum_t psession;
49 int ret; 51// int ret;
50 52//
51 if (session->internals.resumable == RESUME_FALSE) 53// if (session->internals.resumable == RESUME_FALSE)
52 return GNUTLS_E_INVALID_SESSION; 54// return GNUTLS_E_INVALID_SESSION;
53 55//
54 psession.data = session_data; 56// psession.data = session_data;
55 57//
56 ret = _gnutls_session_pack (session, &psession); 58// ret = _gnutls_session_pack (session, &psession);
57 if (ret < 0) 59// if (ret < 0)
58 { 60// {
59 gnutls_assert (); 61// gnutls_assert ();
60 return ret; 62// return ret;
61 } 63// }
62 *session_data_size = psession.size; 64// *session_data_size = psession.size;
63 65//
64 if (psession.size > *session_data_size) 66// if (psession.size > *session_data_size)
65 { 67// {
66 ret = GNUTLS_E_SHORT_MEMORY_BUFFER; 68// ret = GNUTLS_E_SHORT_MEMORY_BUFFER;
67 goto error; 69// goto error;
68 } 70// }
69 71//
70 if (session_data != NULL) 72// if (session_data != NULL)
71 memcpy (session_data, psession.data, psession.size); 73// memcpy (session_data, psession.data, psession.size);
72 74//
73 ret = 0; 75// ret = 0;
74 76//
75error: 77//error:
76 _gnutls_free_datum (&psession); 78// _gnutls_free_datum (&psession);
77 return ret; 79// return ret;
78} 80//}
79 81
80/** 82/**
81 * gnutls_session_get_data2 - Returns all session parameters. 83 * gnutls_session_get_data2 - Returns all session parameters.
82 * @session: is a #gnutls_session_t structure. 84 * @session: is a #mhd_gtls_session_t structure.
83 * @session_data: is a pointer to a datum that will hold the session. 85 * @session_data: is a pointer to a datum that will hold the session.
84 * 86 *
85 * Returns all session parameters, in order to support resuming. 87 * Returns all session parameters, in order to support resuming.
@@ -90,34 +92,34 @@ error:
90 * 92 *
91 * Resuming sessions is really useful and speedups connections after a succesful one. 93 * Resuming sessions is really useful and speedups connections after a succesful one.
92 **/ 94 **/
93int 95//int
94gnutls_session_get_data2 (gnutls_session_t session, gnutls_datum_t * data) 96//gnutls_session_get_data2 (mhd_gtls_session_t session, gnutls_datum_t * data)
95{ 97//{
96 98//
97 int ret; 99// int ret;
98 100//
99 if (data == NULL) 101// if (data == NULL)
100 { 102// {
101 return GNUTLS_E_INVALID_REQUEST; 103// return GNUTLS_E_INVALID_REQUEST;
102 } 104// }
103 105//
104 if (session->internals.resumable == RESUME_FALSE) 106// if (session->internals.resumable == RESUME_FALSE)
105 return GNUTLS_E_INVALID_SESSION; 107// return GNUTLS_E_INVALID_SESSION;
106 108//
107 ret = _gnutls_session_pack (session, data); 109// ret = _gnutls_session_pack (session, data);
108 if (ret < 0) 110// if (ret < 0)
109 { 111// {
110 gnutls_assert (); 112// gnutls_assert ();
111 return ret; 113// return ret;
112 } 114// }
113 115//
114 return 0; 116// return 0;
115} 117//}
116 118
117 119
118/** 120/**
119 * gnutls_session_get_id - Returns session id. 121 * MHD_gtls_session_get_id - Returns session id.
120 * @session: is a #gnutls_session_t structure. 122 * @session: is a #mhd_gtls_session_t structure.
121 * @session_id: is a pointer to space to hold the session id. 123 * @session_id: is a pointer to space to hold the session id.
122 * @session_id_size: is the session id's size, or it will be set by the function. 124 * @session_id_size: is the session id's size, or it will be set by the function.
123 * 125 *
@@ -132,7 +134,7 @@ gnutls_session_get_data2 (gnutls_session_t session, gnutls_datum_t * data)
132 * Returns zero on success. 134 * Returns zero on success.
133 **/ 135 **/
134int 136int
135gnutls_session_get_id (gnutls_session_t session, 137MHD_gtls_session_get_id (mhd_gtls_session_t session,
136 void *session_id, size_t * session_id_size) 138 void *session_id, size_t * session_id_size)
137{ 139{
138 size_t given_session_id_size = *session_id_size; 140 size_t given_session_id_size = *session_id_size;
@@ -158,13 +160,13 @@ gnutls_session_get_id (gnutls_session_t session,
158 160
159/** 161/**
160 * gnutls_session_set_data - Sets all session parameters 162 * gnutls_session_set_data - Sets all session parameters
161 * @session: is a #gnutls_session_t structure. 163 * @session: is a #mhd_gtls_session_t structure.
162 * @session_data: is a pointer to space to hold the session. 164 * @session_data: is a pointer to space to hold the session.
163 * @session_data_size: is the session's size 165 * @session_data_size: is the session's size
164 * 166 *
165 * Sets all session parameters, in order to resume a previously established 167 * Sets all session parameters, in order to resume a previously established
166 * session. The session data given must be the one returned by gnutls_session_get_data(). 168 * session. The session data given must be the one returned by gnutls_session_get_data().
167 * This function should be called before gnutls_handshake(). 169 * This function should be called before MHD_gnutls_handshake().
168 * 170 *
169 * Keep in mind that session resuming is advisory. The server may 171 * Keep in mind that session resuming is advisory. The server may
170 * choose not to resume the session, thus a full handshake will be 172 * choose not to resume the session, thus a full handshake will be
@@ -173,27 +175,27 @@ gnutls_session_get_id (gnutls_session_t session,
173 * Returns a negative value on error. 175 * Returns a negative value on error.
174 * 176 *
175 **/ 177 **/
176int 178//int
177gnutls_session_set_data (gnutls_session_t session, 179//gnutls_session_set_data (mhd_gtls_session_t session,
178 const void *session_data, size_t session_data_size) 180// const void *session_data, size_t session_data_size)
179{ 181//{
180 int ret; 182// int ret;
181 gnutls_datum_t psession; 183// gnutls_datum_t psession;
182 184//
183 psession.data = (opaque *) session_data; 185// psession.data = (opaque *) session_data;
184 psession.size = session_data_size; 186// psession.size = session_data_size;
185 187//
186 if (session_data == NULL || session_data_size == 0) 188// if (session_data == NULL || session_data_size == 0)
187 { 189// {
188 gnutls_assert (); 190// gnutls_assert ();
189 return GNUTLS_E_INVALID_REQUEST; 191// return GNUTLS_E_INVALID_REQUEST;
190 } 192// }
191 ret = _gnutls_session_unpack (session, &psession); 193// ret = _gnutls_session_unpack (session, &psession);
192 if (ret < 0) 194// if (ret < 0)
193 { 195// {
194 gnutls_assert (); 196// gnutls_assert ();
195 return ret; 197// return ret;
196 } 198// }
197 199//
198 return 0; 200// return 0;
199} 201//}
diff --git a/src/daemon/https/tls/gnutls_session_pack.c b/src/daemon/https/tls/gnutls_session_pack.c
index 3e549c4c..c11f6d77 100644
--- a/src/daemon/https/tls/gnutls_session_pack.c
+++ b/src/daemon/https/tls/gnutls_session_pack.c
@@ -43,15 +43,15 @@
43 43
44#define PACK_HEADER_SIZE 1 44#define PACK_HEADER_SIZE 1
45#define MAX_SEC_PARAMS 7+MAX_SRP_USERNAME+MAX_SERVER_NAME_EXTENSIONS*(3+MAX_SERVER_NAME_SIZE)+165 45#define MAX_SEC_PARAMS 7+MAX_SRP_USERNAME+MAX_SERVER_NAME_EXTENSIONS*(3+MAX_SERVER_NAME_SIZE)+165
46static int pack_certificate_auth_info (gnutls_session_t, 46static int pack_certificate_auth_info (mhd_gtls_session_t,
47 gnutls_datum_t * packed_session); 47 gnutls_datum_t * packed_session);
48static int unpack_certificate_auth_info (gnutls_session_t, 48static int unpack_certificate_auth_info (mhd_gtls_session_t,
49 const gnutls_datum_t * 49 const gnutls_datum_t *
50 packed_session); 50 packed_session);
51 51
52static int unpack_security_parameters (gnutls_session_t session, 52static int unpack_security_parameters (mhd_gtls_session_t session,
53 const gnutls_datum_t * packed_session); 53 const gnutls_datum_t * packed_session);
54static int pack_security_parameters (gnutls_session_t session, 54static int pack_security_parameters (mhd_gtls_session_t session,
55 gnutls_datum_t * packed_session); 55 gnutls_datum_t * packed_session);
56 56
57/* Packs the ANON session authentication data. */ 57/* Packs the ANON session authentication data. */
@@ -69,9 +69,9 @@ static int pack_security_parameters (gnutls_session_t session,
69 * x bytes the public key 69 * x bytes the public key
70 */ 70 */
71static int 71static int
72pack_anon_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session) 72pack_anon_auth_info (mhd_gtls_session_t session, gnutls_datum_t * packed_session)
73{ 73{
74 anon_auth_info_t info = _gnutls_get_auth_info (session); 74 mhd_anon_auth_info_t info = mhd_gtls_get_auth_info (session);
75 int pos = 0; 75 int pos = 0;
76 size_t pack_size; 76 size_t pack_size;
77 77
@@ -95,19 +95,19 @@ pack_anon_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
95 } 95 }
96 96
97 packed_session->data[0] = MHD_GNUTLS_CRD_ANON; 97 packed_session->data[0] = MHD_GNUTLS_CRD_ANON;
98 _gnutls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]); 98 mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
99 pos += 4 + PACK_HEADER_SIZE; 99 pos += 4 + PACK_HEADER_SIZE;
100 100
101 if (pack_size > 0) 101 if (pack_size > 0)
102 { 102 {
103 _gnutls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]); 103 mhd_gtls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
104 pos += 2; 104 pos += 2;
105 105
106 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.prime); 106 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
107 pos += 4 + info->dh.prime.size; 107 pos += 4 + info->dh.prime.size;
108 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.generator); 108 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
109 pos += 4 + info->dh.generator.size; 109 pos += 4 + info->dh.generator.size;
110 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.public_key); 110 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
111 pos += 4 + info->dh.public_key.size; 111 pos += 4 + info->dh.public_key.size;
112 112
113 } 113 }
@@ -127,12 +127,12 @@ pack_anon_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
127 * x bytes the public key 127 * x bytes the public key
128 */ 128 */
129static int 129static int
130unpack_anon_auth_info (gnutls_session_t session, 130unpack_anon_auth_info (mhd_gtls_session_t session,
131 const gnutls_datum_t * packed_session) 131 const gnutls_datum_t * packed_session)
132{ 132{
133 size_t pack_size; 133 size_t pack_size;
134 int pos = 0, size, ret; 134 int pos = 0, size, ret;
135 anon_auth_info_t info; 135 mhd_anon_auth_info_t info;
136 136
137 if (packed_session->data[0] != MHD_GNUTLS_CRD_ANON) 137 if (packed_session->data[0] != MHD_GNUTLS_CRD_ANON)
138 { 138 {
@@ -140,7 +140,7 @@ unpack_anon_auth_info (gnutls_session_t session,
140 return GNUTLS_E_INVALID_REQUEST; 140 return GNUTLS_E_INVALID_REQUEST;
141 } 141 }
142 142
143 pack_size = _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]); 143 pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
144 pos += PACK_HEADER_SIZE + 4; 144 pos += PACK_HEADER_SIZE + 4;
145 145
146 146
@@ -157,7 +157,7 @@ unpack_anon_auth_info (gnutls_session_t session,
157 /* client and serer have the same auth_info here 157 /* client and serer have the same auth_info here
158 */ 158 */
159 ret = 159 ret =
160 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_ANON, 160 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
161 sizeof (anon_auth_info_st), 1); 161 sizeof (anon_auth_info_st), 1);
162 if (ret < 0) 162 if (ret < 0)
163 { 163 {
@@ -165,17 +165,17 @@ unpack_anon_auth_info (gnutls_session_t session,
165 return ret; 165 return ret;
166 } 166 }
167 167
168 info = _gnutls_get_auth_info (session); 168 info = mhd_gtls_get_auth_info (session);
169 if (info == NULL) 169 if (info == NULL)
170 { 170 {
171 gnutls_assert (); 171 gnutls_assert ();
172 return GNUTLS_E_INTERNAL_ERROR; 172 return GNUTLS_E_INTERNAL_ERROR;
173 } 173 }
174 174
175 info->dh.secret_bits = _gnutls_read_uint16 (&packed_session->data[pos]); 175 info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]);
176 pos += 2; 176 pos += 2;
177 177
178 size = _gnutls_read_uint32 (&packed_session->data[pos]); 178 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
179 pos += 4; 179 pos += 4;
180 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); 180 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
181 if (ret < 0) 181 if (ret < 0)
@@ -185,7 +185,7 @@ unpack_anon_auth_info (gnutls_session_t session,
185 } 185 }
186 pos += size; 186 pos += size;
187 187
188 size = _gnutls_read_uint32 (&packed_session->data[pos]); 188 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
189 pos += 4; 189 pos += 4;
190 ret = 190 ret =
191 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); 191 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
@@ -196,7 +196,7 @@ unpack_anon_auth_info (gnutls_session_t session,
196 } 196 }
197 pos += size; 197 pos += size;
198 198
199 size = _gnutls_read_uint32 (&packed_session->data[pos]); 199 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
200 pos += 4; 200 pos += 4;
201 ret = 201 ret =
202 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], 202 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
@@ -227,7 +227,7 @@ error:
227 * The data will be in a platform independent format. 227 * The data will be in a platform independent format.
228 */ 228 */
229int 229int
230_gnutls_session_pack (gnutls_session_t session, 230_gnutls_session_pack (mhd_gtls_session_t session,
231 gnutls_datum_t * packed_session) 231 gnutls_datum_t * packed_session)
232{ 232{
233 int ret; 233 int ret;
@@ -239,7 +239,7 @@ _gnutls_session_pack (gnutls_session_t session,
239 } 239 }
240 240
241 241
242 switch (gnutls_auth_get_type (session)) 242 switch (MHD_gtls_auth_get_type (session))
243 { 243 {
244#ifdef ENABLE_SRP 244#ifdef ENABLE_SRP
245 case MHD_GNUTLS_CRD_SRP: 245 case MHD_GNUTLS_CRD_SRP:
@@ -284,7 +284,7 @@ _gnutls_session_pack (gnutls_session_t session,
284 284
285 } 285 }
286 286
287 /* Auth_info structures copied. Now copy security_parameters_st. 287 /* Auth_info structures copied. Now copy mhd_gtls_security_param_st.
288 * packed_session must have allocated space for the security parameters. 288 * packed_session must have allocated space for the security parameters.
289 */ 289 */
290 ret = pack_security_parameters (session, packed_session); 290 ret = pack_security_parameters (session, packed_session);
@@ -302,7 +302,7 @@ _gnutls_session_pack (gnutls_session_t session,
302/* Load session data from a buffer. 302/* Load session data from a buffer.
303 */ 303 */
304int 304int
305_gnutls_session_unpack (gnutls_session_t session, 305_gnutls_session_unpack (mhd_gtls_session_t session,
306 const gnutls_datum_t * packed_session) 306 const gnutls_datum_t * packed_session)
307{ 307{
308 int ret; 308 int ret;
@@ -313,9 +313,9 @@ _gnutls_session_unpack (gnutls_session_t session,
313 return GNUTLS_E_INTERNAL_ERROR; 313 return GNUTLS_E_INTERNAL_ERROR;
314 } 314 }
315 315
316 if (_gnutls_get_auth_info (session) != NULL) 316 if (mhd_gtls_get_auth_info (session) != NULL)
317 { 317 {
318 _gnutls_free_auth_info (session); 318 mhd_gtls_free_auth_info (session);
319 } 319 }
320 320
321 switch (packed_session->data[0]) 321 switch (packed_session->data[0])
@@ -364,7 +364,7 @@ _gnutls_session_unpack (gnutls_session_t session,
364 364
365 } 365 }
366 366
367 /* Auth_info structures copied. Now copy security_parameters_st. 367 /* Auth_info structures copied. Now copy mhd_gtls_security_param_st.
368 * packed_session must have allocated space for the security parameters. 368 * packed_session must have allocated space for the security parameters.
369 */ 369 */
370 ret = unpack_security_parameters (session, packed_session); 370 ret = unpack_security_parameters (session, packed_session);
@@ -401,12 +401,12 @@ _gnutls_session_unpack (gnutls_session_t session,
401 * and so on... 401 * and so on...
402 */ 402 */
403static int 403static int
404pack_certificate_auth_info (gnutls_session_t session, 404pack_certificate_auth_info (mhd_gtls_session_t session,
405 gnutls_datum_t * packed_session) 405 gnutls_datum_t * packed_session)
406{ 406{
407 unsigned int pos = 0, i; 407 unsigned int pos = 0, i;
408 int cert_size, pack_size; 408 int cert_size, pack_size;
409 cert_auth_info_t info = _gnutls_get_auth_info (session); 409 cert_auth_info_t info = mhd_gtls_get_auth_info (session);
410 410
411 if (info) 411 if (info)
412 { 412 {
@@ -437,36 +437,36 @@ pack_certificate_auth_info (gnutls_session_t session,
437 } 437 }
438 438
439 packed_session->data[0] = MHD_GNUTLS_CRD_CERTIFICATE; 439 packed_session->data[0] = MHD_GNUTLS_CRD_CERTIFICATE;
440 _gnutls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]); 440 mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
441 pos += 4 + PACK_HEADER_SIZE; 441 pos += 4 + PACK_HEADER_SIZE;
442 442
443 443
444 if (pack_size > 0) 444 if (pack_size > 0)
445 { 445 {
446 446
447 _gnutls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]); 447 mhd_gtls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
448 pos += 2; 448 pos += 2;
449 449
450 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.prime); 450 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
451 pos += 4 + info->dh.prime.size; 451 pos += 4 + info->dh.prime.size;
452 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.generator); 452 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
453 pos += 4 + info->dh.generator.size; 453 pos += 4 + info->dh.generator.size;
454 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.public_key); 454 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
455 pos += 4 + info->dh.public_key.size; 455 pos += 4 + info->dh.public_key.size;
456 456
457 _gnutls_write_datum32 (&packed_session->data[pos], 457 mhd_gtls_write_datum32 (&packed_session->data[pos],
458 info->rsa_export.modulus); 458 info->rsa_export.modulus);
459 pos += 4 + info->rsa_export.modulus.size; 459 pos += 4 + info->rsa_export.modulus.size;
460 _gnutls_write_datum32 (&packed_session->data[pos], 460 mhd_gtls_write_datum32 (&packed_session->data[pos],
461 info->rsa_export.exponent); 461 info->rsa_export.exponent);
462 pos += 4 + info->rsa_export.exponent.size; 462 pos += 4 + info->rsa_export.exponent.size;
463 463
464 _gnutls_write_uint32 (info->ncerts, &packed_session->data[pos]); 464 mhd_gtls_write_uint32 (info->ncerts, &packed_session->data[pos]);
465 pos += 4; 465 pos += 4;
466 466
467 for (i = 0; i < info->ncerts; i++) 467 for (i = 0; i < info->ncerts; i++)
468 { 468 {
469 _gnutls_write_datum32 (&packed_session->data[pos], 469 mhd_gtls_write_datum32 (&packed_session->data[pos],
470 info->raw_certificate_list[i]); 470 info->raw_certificate_list[i]);
471 pos += sizeof (uint32_t) + info->raw_certificate_list[i].size; 471 pos += sizeof (uint32_t) + info->raw_certificate_list[i].size;
472 } 472 }
@@ -479,7 +479,7 @@ pack_certificate_auth_info (gnutls_session_t session,
479/* Upack certificate info. 479/* Upack certificate info.
480 */ 480 */
481static int 481static int
482unpack_certificate_auth_info (gnutls_session_t session, 482unpack_certificate_auth_info (mhd_gtls_session_t session,
483 const gnutls_datum_t * packed_session) 483 const gnutls_datum_t * packed_session)
484{ 484{
485 int pos = 0, size, ret; 485 int pos = 0, size, ret;
@@ -493,7 +493,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
493 return GNUTLS_E_INVALID_REQUEST; 493 return GNUTLS_E_INVALID_REQUEST;
494 } 494 }
495 495
496 pack_size = _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]); 496 pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
497 pos += PACK_HEADER_SIZE + 4; 497 pos += PACK_HEADER_SIZE + 4;
498 498
499 if (pack_size == 0) 499 if (pack_size == 0)
@@ -509,7 +509,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
509 /* client and server have the same auth_info here 509 /* client and server have the same auth_info here
510 */ 510 */
511 ret = 511 ret =
512 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 512 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
513 sizeof (cert_auth_info_st), 1); 513 sizeof (cert_auth_info_st), 1);
514 if (ret < 0) 514 if (ret < 0)
515 { 515 {
@@ -517,17 +517,17 @@ unpack_certificate_auth_info (gnutls_session_t session,
517 return ret; 517 return ret;
518 } 518 }
519 519
520 info = _gnutls_get_auth_info (session); 520 info = mhd_gtls_get_auth_info (session);
521 if (info == NULL) 521 if (info == NULL)
522 { 522 {
523 gnutls_assert (); 523 gnutls_assert ();
524 return GNUTLS_E_INTERNAL_ERROR; 524 return GNUTLS_E_INTERNAL_ERROR;
525 } 525 }
526 526
527 info->dh.secret_bits = _gnutls_read_uint16 (&packed_session->data[pos]); 527 info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]);
528 pos += 2; 528 pos += 2;
529 529
530 size = _gnutls_read_uint32 (&packed_session->data[pos]); 530 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
531 pos += 4; 531 pos += 4;
532 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); 532 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
533 if (ret < 0) 533 if (ret < 0)
@@ -537,7 +537,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
537 } 537 }
538 pos += size; 538 pos += size;
539 539
540 size = _gnutls_read_uint32 (&packed_session->data[pos]); 540 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
541 pos += 4; 541 pos += 4;
542 ret = 542 ret =
543 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); 543 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
@@ -548,7 +548,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
548 } 548 }
549 pos += size; 549 pos += size;
550 550
551 size = _gnutls_read_uint32 (&packed_session->data[pos]); 551 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
552 pos += 4; 552 pos += 4;
553 ret = 553 ret =
554 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], 554 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
@@ -560,7 +560,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
560 } 560 }
561 pos += size; 561 pos += size;
562 562
563 size = _gnutls_read_uint32 (&packed_session->data[pos]); 563 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
564 pos += 4; 564 pos += 4;
565 ret = 565 ret =
566 _gnutls_set_datum (&info->rsa_export.modulus, 566 _gnutls_set_datum (&info->rsa_export.modulus,
@@ -572,7 +572,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
572 } 572 }
573 pos += size; 573 pos += size;
574 574
575 size = _gnutls_read_uint32 (&packed_session->data[pos]); 575 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
576 pos += 4; 576 pos += 4;
577 ret = 577 ret =
578 _gnutls_set_datum (&info->rsa_export.exponent, 578 _gnutls_set_datum (&info->rsa_export.exponent,
@@ -584,7 +584,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
584 } 584 }
585 pos += size; 585 pos += size;
586 586
587 info->ncerts = _gnutls_read_uint32 (&packed_session->data[pos]); 587 info->ncerts = mhd_gtls_read_uint32 (&packed_session->data[pos]);
588 pos += 4; 588 pos += 4;
589 589
590 if (info->ncerts > 0) 590 if (info->ncerts > 0)
@@ -601,7 +601,7 @@ unpack_certificate_auth_info (gnutls_session_t session,
601 601
602 for (i = 0; i < info->ncerts; i++) 602 for (i = 0; i < info->ncerts; i++)
603 { 603 {
604 size = _gnutls_read_uint32 (&packed_session->data[pos]); 604 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
605 pos += sizeof (uint32_t); 605 pos += sizeof (uint32_t);
606 606
607 ret = 607 ret =
@@ -646,9 +646,9 @@ error:
646 * x bytes the SRP username 646 * x bytes the SRP username
647 */ 647 */
648static int 648static int
649pack_srp_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session) 649pack_srp_auth_info (mhd_gtls_session_t session, gnutls_datum_t * packed_session)
650{ 650{
651 srp_server_auth_info_t info = _gnutls_get_auth_info (session); 651 srp_server_auth_info_t info = mhd_gtls_get_auth_info (session);
652 int pack_size; 652 int pack_size;
653 653
654 if (info && info->username) 654 if (info && info->username)
@@ -670,7 +670,7 @@ pack_srp_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
670 } 670 }
671 671
672 packed_session->data[0] = MHD_GNUTLS_CRD_SRP; 672 packed_session->data[0] = MHD_GNUTLS_CRD_SRP;
673 _gnutls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]); 673 mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
674 674
675 if (pack_size > 0) 675 if (pack_size > 0)
676 memcpy (&packed_session->data[PACK_HEADER_SIZE + sizeof (uint32_t)], 676 memcpy (&packed_session->data[PACK_HEADER_SIZE + sizeof (uint32_t)],
@@ -681,7 +681,7 @@ pack_srp_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
681 681
682 682
683static int 683static int
684unpack_srp_auth_info (gnutls_session_t session, 684unpack_srp_auth_info (mhd_gtls_session_t session,
685 const gnutls_datum_t * packed_session) 685 const gnutls_datum_t * packed_session)
686{ 686{
687 size_t username_size; 687 size_t username_size;
@@ -695,7 +695,7 @@ unpack_srp_auth_info (gnutls_session_t session,
695 } 695 }
696 696
697 username_size = 697 username_size =
698 _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]); 698 mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
699 699
700 if (username_size == 0) 700 if (username_size == 0)
701 return 0; /* nothing to be done */ 701 return 0; /* nothing to be done */
@@ -708,7 +708,7 @@ unpack_srp_auth_info (gnutls_session_t session,
708 } 708 }
709 709
710 ret = 710 ret =
711 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_SRP, 711 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_SRP,
712 sizeof (srp_server_auth_info_st), 1); 712 sizeof (srp_server_auth_info_st), 1);
713 if (ret < 0) 713 if (ret < 0)
714 { 714 {
@@ -716,7 +716,7 @@ unpack_srp_auth_info (gnutls_session_t session,
716 return ret; 716 return ret;
717 } 717 }
718 718
719 info = _gnutls_get_auth_info (session); 719 info = mhd_gtls_get_auth_info (session);
720 if (info == NULL) 720 if (info == NULL)
721 { 721 {
722 gnutls_assert (); 722 gnutls_assert ();
@@ -751,12 +751,12 @@ unpack_srp_auth_info (gnutls_session_t session,
751 * x bytes the public key 751 * x bytes the public key
752 */ 752 */
753static int 753static int
754pack_psk_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session) 754pack_psk_auth_info (mhd_gtls_session_t session, gnutls_datum_t * packed_session)
755{ 755{
756 psk_auth_info_t info; 756 psk_auth_info_t info;
757 int pack_size, username_size = 0, pos; 757 int pack_size, username_size = 0, pos;
758 758
759 info = _gnutls_get_auth_info (session); 759 info = mhd_gtls_get_auth_info (session);
760 760
761 if (info) 761 if (info)
762 { 762 {
@@ -786,26 +786,26 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
786 packed_session->data[pos] = MHD_GNUTLS_CRD_PSK; 786 packed_session->data[pos] = MHD_GNUTLS_CRD_PSK;
787 pos++; 787 pos++;
788 788
789 _gnutls_write_uint32 (pack_size, &packed_session->data[pos]); 789 mhd_gtls_write_uint32 (pack_size, &packed_session->data[pos]);
790 pos += 4; 790 pos += 4;
791 791
792 792
793 if (pack_size > 0) 793 if (pack_size > 0)
794 { 794 {
795 _gnutls_write_uint32 (username_size, &packed_session->data[pos]); 795 mhd_gtls_write_uint32 (username_size, &packed_session->data[pos]);
796 pos += 4; 796 pos += 4;
797 797
798 memcpy (&packed_session->data[pos], info->username, username_size); 798 memcpy (&packed_session->data[pos], info->username, username_size);
799 pos += username_size; 799 pos += username_size;
800 800
801 _gnutls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]); 801 mhd_gtls_write_uint16 (info->dh.secret_bits, &packed_session->data[pos]);
802 pos += 2; 802 pos += 2;
803 803
804 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.prime); 804 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
805 pos += 4 + info->dh.prime.size; 805 pos += 4 + info->dh.prime.size;
806 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.generator); 806 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
807 pos += 4 + info->dh.generator.size; 807 pos += 4 + info->dh.generator.size;
808 _gnutls_write_datum32 (&packed_session->data[pos], info->dh.public_key); 808 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.public_key);
809 pos += 4 + info->dh.public_key.size; 809 pos += 4 + info->dh.public_key.size;
810 810
811 } 811 }
@@ -815,7 +815,7 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session)
815} 815}
816 816
817static int 817static int
818unpack_psk_auth_info (gnutls_session_t session, 818unpack_psk_auth_info (mhd_gtls_session_t session,
819 const gnutls_datum_t * packed_session) 819 const gnutls_datum_t * packed_session)
820{ 820{
821 size_t username_size; 821 size_t username_size;
@@ -829,7 +829,7 @@ unpack_psk_auth_info (gnutls_session_t session,
829 return GNUTLS_E_INVALID_REQUEST; 829 return GNUTLS_E_INVALID_REQUEST;
830 } 830 }
831 831
832 pack_size = _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]); 832 pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
833 pos += PACK_HEADER_SIZE + 4; 833 pos += PACK_HEADER_SIZE + 4;
834 834
835 835
@@ -846,7 +846,7 @@ unpack_psk_auth_info (gnutls_session_t session,
846 /* client and serer have the same auth_info here 846 /* client and serer have the same auth_info here
847 */ 847 */
848 ret = 848 ret =
849 _gnutls_auth_info_set (session, MHD_GNUTLS_CRD_PSK, 849 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_PSK,
850 sizeof (psk_auth_info_st), 1); 850 sizeof (psk_auth_info_st), 1);
851 if (ret < 0) 851 if (ret < 0)
852 { 852 {
@@ -854,23 +854,23 @@ unpack_psk_auth_info (gnutls_session_t session,
854 return ret; 854 return ret;
855 } 855 }
856 856
857 info = _gnutls_get_auth_info (session); 857 info = mhd_gtls_get_auth_info (session);
858 if (info == NULL) 858 if (info == NULL)
859 { 859 {
860 gnutls_assert (); 860 gnutls_assert ();
861 return GNUTLS_E_INTERNAL_ERROR; 861 return GNUTLS_E_INTERNAL_ERROR;
862 } 862 }
863 863
864 username_size = _gnutls_read_uint32 (&packed_session->data[pos]); 864 username_size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
865 pos += 4; 865 pos += 4;
866 866
867 memcpy (info->username, &packed_session->data[pos], username_size); 867 memcpy (info->username, &packed_session->data[pos], username_size);
868 pos += username_size; 868 pos += username_size;
869 869
870 info->dh.secret_bits = _gnutls_read_uint16 (&packed_session->data[pos]); 870 info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]);
871 pos += 2; 871 pos += 2;
872 872
873 size = _gnutls_read_uint32 (&packed_session->data[pos]); 873 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
874 pos += 4; 874 pos += 4;
875 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); 875 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
876 if (ret < 0) 876 if (ret < 0)
@@ -880,7 +880,7 @@ unpack_psk_auth_info (gnutls_session_t session,
880 } 880 }
881 pos += size; 881 pos += size;
882 882
883 size = _gnutls_read_uint32 (&packed_session->data[pos]); 883 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
884 pos += 4; 884 pos += 4;
885 ret = 885 ret =
886 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); 886 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
@@ -891,7 +891,7 @@ unpack_psk_auth_info (gnutls_session_t session,
891 } 891 }
892 pos += size; 892 pos += size;
893 893
894 size = _gnutls_read_uint32 (&packed_session->data[pos]); 894 size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
895 pos += 4; 895 pos += 4;
896 ret = 896 ret =
897 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], 897 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
@@ -963,7 +963,7 @@ error:
963 * MAX: 7+MAX_SRP_USERNAME+MAX_SERVER_NAME_EXTENSIONS*(3+MAX_SERVER_NAME_SIZE) 963 * MAX: 7+MAX_SRP_USERNAME+MAX_SERVER_NAME_EXTENSIONS*(3+MAX_SERVER_NAME_SIZE)
964 */ 964 */
965static int 965static int
966pack_security_parameters (gnutls_session_t session, 966pack_security_parameters (mhd_gtls_session_t session,
967 gnutls_datum_t * packed_session) 967 gnutls_datum_t * packed_session)
968{ 968{
969 int pos = 0; 969 int pos = 0;
@@ -972,7 +972,7 @@ pack_security_parameters (gnutls_session_t session,
972 /* move after the auth info stuff. 972 /* move after the auth info stuff.
973 */ 973 */
974 init = 974 init =
975 _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 + 975 mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 +
976 PACK_HEADER_SIZE; 976 PACK_HEADER_SIZE;
977 977
978 pos = init + 4; /* make some space to write later the size */ 978 pos = init + 4; /* make some space to write later the size */
@@ -1015,16 +1015,16 @@ pack_security_parameters (gnutls_session_t session,
1015 session->security_parameters.session_id_size); 1015 session->security_parameters.session_id_size);
1016 pos += session->security_parameters.session_id_size; 1016 pos += session->security_parameters.session_id_size;
1017 1017
1018 _gnutls_write_uint32 (session->security_parameters.timestamp, 1018 mhd_gtls_write_uint32 (session->security_parameters.timestamp,
1019 &packed_session->data[pos]); 1019 &packed_session->data[pos]);
1020 pos += 4; 1020 pos += 4;
1021 1021
1022 /* Extensions */ 1022 /* Extensions */
1023 _gnutls_write_uint16 (session->security_parameters.max_record_send_size, 1023 mhd_gtls_write_uint16 (session->security_parameters.max_record_send_size,
1024 &packed_session->data[pos]); 1024 &packed_session->data[pos]);
1025 pos += 2; 1025 pos += 2;
1026 1026
1027 _gnutls_write_uint16 (session->security_parameters.max_record_recv_size, 1027 mhd_gtls_write_uint16 (session->security_parameters.max_record_recv_size,
1028 &packed_session->data[pos]); 1028 &packed_session->data[pos]);
1029 pos += 2; 1029 pos += 2;
1030 1030
@@ -1036,7 +1036,7 @@ pack_security_parameters (gnutls_session_t session,
1036 session->security_parameters.extensions.srp_username, len); 1036 session->security_parameters.extensions.srp_username, len);
1037 pos += len; 1037 pos += len;
1038 1038
1039 _gnutls_write_uint16 (session->security_parameters.extensions. 1039 mhd_gtls_write_uint16 (session->security_parameters.extensions.
1040 server_names_size, &packed_session->data[pos]); 1040 server_names_size, &packed_session->data[pos]);
1041 pos += 2; 1041 pos += 2;
1042 1042
@@ -1045,7 +1045,7 @@ pack_security_parameters (gnutls_session_t session,
1045 { 1045 {
1046 packed_session->data[pos++] = 1046 packed_session->data[pos++] =
1047 session->security_parameters.extensions.server_names[i].type; 1047 session->security_parameters.extensions.server_names[i].type;
1048 _gnutls_write_uint16 (session->security_parameters.extensions. 1048 mhd_gtls_write_uint16 (session->security_parameters.extensions.
1049 server_names[i].name_length, 1049 server_names[i].name_length,
1050 &packed_session->data[pos]); 1050 &packed_session->data[pos]);
1051 pos += 2; 1051 pos += 2;
@@ -1059,7 +1059,7 @@ pack_security_parameters (gnutls_session_t session,
1059 } 1059 }
1060 1060
1061 /* write the total size */ 1061 /* write the total size */
1062 _gnutls_write_uint32 (pos - init - 4, &packed_session->data[init]); 1062 mhd_gtls_write_uint32 (pos - init - 4, &packed_session->data[init]);
1063 packed_session->size += pos - init; 1063 packed_session->size += pos - init;
1064 1064
1065 return 0; 1065 return 0;
@@ -1067,7 +1067,7 @@ pack_security_parameters (gnutls_session_t session,
1067 1067
1068 1068
1069static int 1069static int
1070unpack_security_parameters (gnutls_session_t session, 1070unpack_security_parameters (mhd_gtls_session_t session,
1071 const gnutls_datum_t * packed_session) 1071 const gnutls_datum_t * packed_session)
1072{ 1072{
1073 size_t pack_size, init, i; 1073 size_t pack_size, init, i;
@@ -1077,12 +1077,12 @@ unpack_security_parameters (gnutls_session_t session,
1077 1077
1078 /* skip the auth info stuff */ 1078 /* skip the auth info stuff */
1079 init = 1079 init =
1080 _gnutls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 + 1080 mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 +
1081 PACK_HEADER_SIZE; 1081 PACK_HEADER_SIZE;
1082 1082
1083 pos = init; 1083 pos = init;
1084 1084
1085 pack_size = _gnutls_read_uint32 (&packed_session->data[pos]); 1085 pack_size = mhd_gtls_read_uint32 (&packed_session->data[pos]);
1086 pos += 4; 1086 pos += 4;
1087 1087
1088 1088
@@ -1141,7 +1141,7 @@ unpack_security_parameters (gnutls_session_t session,
1141 pos += session->internals.resumed_security_parameters.session_id_size; 1141 pos += session->internals.resumed_security_parameters.session_id_size;
1142 1142
1143 session->internals.resumed_security_parameters.timestamp = 1143 session->internals.resumed_security_parameters.timestamp =
1144 _gnutls_read_uint32 (&packed_session->data[pos]); 1144 mhd_gtls_read_uint32 (&packed_session->data[pos]);
1145 pos += 4; 1145 pos += 4;
1146 1146
1147 if (timestamp - session->internals.resumed_security_parameters.timestamp > 1147 if (timestamp - session->internals.resumed_security_parameters.timestamp >
@@ -1154,11 +1154,11 @@ unpack_security_parameters (gnutls_session_t session,
1154 1154
1155 /* Extensions */ 1155 /* Extensions */
1156 session->internals.resumed_security_parameters.max_record_send_size = 1156 session->internals.resumed_security_parameters.max_record_send_size =
1157 _gnutls_read_uint16 (&packed_session->data[pos]); 1157 mhd_gtls_read_uint16 (&packed_session->data[pos]);
1158 pos += 2; 1158 pos += 2;
1159 1159
1160 session->internals.resumed_security_parameters.max_record_recv_size = 1160 session->internals.resumed_security_parameters.max_record_recv_size =
1161 _gnutls_read_uint16 (&packed_session->data[pos]); 1161 mhd_gtls_read_uint16 (&packed_session->data[pos]);
1162 pos += 2; 1162 pos += 2;
1163 1163
1164 1164
@@ -1171,7 +1171,7 @@ unpack_security_parameters (gnutls_session_t session,
1171 pos += len; 1171 pos += len;
1172 1172
1173 session->internals.resumed_security_parameters.extensions. 1173 session->internals.resumed_security_parameters.extensions.
1174 server_names_size = _gnutls_read_uint16 (&packed_session->data[pos]); 1174 server_names_size = mhd_gtls_read_uint16 (&packed_session->data[pos]);
1175 pos += 2; 1175 pos += 2;
1176 for (i = 0; 1176 for (i = 0;
1177 i < 1177 i <
@@ -1182,7 +1182,7 @@ unpack_security_parameters (gnutls_session_t session,
1182 server_names[i].type = packed_session->data[pos++]; 1182 server_names[i].type = packed_session->data[pos++];
1183 session->internals.resumed_security_parameters.extensions. 1183 session->internals.resumed_security_parameters.extensions.
1184 server_names[i].name_length = 1184 server_names[i].name_length =
1185 _gnutls_read_uint16 (&packed_session->data[pos]); 1185 mhd_gtls_read_uint16 (&packed_session->data[pos]);
1186 pos += 2; 1186 pos += 2;
1187 1187
1188 memcpy (session->internals.resumed_security_parameters.extensions. 1188 memcpy (session->internals.resumed_security_parameters.extensions.
diff --git a/src/daemon/https/tls/gnutls_session_pack.h b/src/daemon/https/tls/gnutls_session_pack.h
index 93dd32de..abc3fe46 100644
--- a/src/daemon/https/tls/gnutls_session_pack.h
+++ b/src/daemon/https/tls/gnutls_session_pack.h
@@ -22,7 +22,7 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_session_pack (gnutls_session_t session, 25int _gnutls_session_pack (mhd_gtls_session_t session,
26 gnutls_datum_t * packed_session); 26 gnutls_datum_t * packed_session);
27int _gnutls_session_unpack (gnutls_session_t session, 27int _gnutls_session_unpack (mhd_gtls_session_t session,
28 const gnutls_datum_t * packed_session); 28 const gnutls_datum_t * packed_session);
diff --git a/src/daemon/https/tls/gnutls_sig.c b/src/daemon/https/tls/gnutls_sig.c
index da09e199..1d926649 100644
--- a/src/daemon/https/tls/gnutls_sig.c
+++ b/src/daemon/https/tls/gnutls_sig.c
@@ -37,7 +37,7 @@
37#include <gnutls_sig.h> 37#include <gnutls_sig.h>
38#include <gnutls_kx.h> 38#include <gnutls_kx.h>
39 39
40static int _gnutls_tls_sign (gnutls_session_t session, 40static int _gnutls_tls_sign (mhd_gtls_session_t session,
41 gnutls_cert * cert, 41 gnutls_cert * cert,
42 gnutls_privkey * pkey, 42 gnutls_privkey * pkey,
43 const gnutls_datum_t * hash_concat, 43 const gnutls_datum_t * hash_concat,
@@ -47,7 +47,7 @@ static int _gnutls_tls_sign (gnutls_session_t session,
47 * handshake procedure. (20040227: now it works for SSL 3.0 as well) 47 * handshake procedure. (20040227: now it works for SSL 3.0 as well)
48 */ 48 */
49int 49int
50_gnutls_tls_sign_hdata (gnutls_session_t session, 50mhd_gtls_tls_sign_hdata (mhd_gtls_session_t session,
51 gnutls_cert * cert, 51 gnutls_cert * cert,
52 gnutls_privkey * pkey, gnutls_datum_t * signature) 52 gnutls_privkey * pkey, gnutls_datum_t * signature)
53{ 53{
@@ -56,9 +56,9 @@ _gnutls_tls_sign_hdata (gnutls_session_t session,
56 opaque concat[36]; 56 opaque concat[36];
57 mac_hd_t td_md5; 57 mac_hd_t td_md5;
58 mac_hd_t td_sha; 58 mac_hd_t td_sha;
59 gnutls_protocol_t ver = gnutls_protocol_get_version (session); 59 gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
60 60
61 td_sha = _gnutls_hash_copy (session->internals.handshake_mac_handle_sha); 61 td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
62 if (td_sha == NULL) 62 if (td_sha == NULL)
63 { 63 {
64 gnutls_assert (); 64 gnutls_assert ();
@@ -67,25 +67,25 @@ _gnutls_tls_sign_hdata (gnutls_session_t session,
67 67
68 if (ver == MHD_GNUTLS_SSL3) 68 if (ver == MHD_GNUTLS_SSL3)
69 { 69 {
70 ret = _gnutls_generate_master (session, 1); 70 ret = mhd_gtls_generate_master (session, 1);
71 if (ret < 0) 71 if (ret < 0)
72 { 72 {
73 gnutls_assert (); 73 gnutls_assert ();
74 return ret; 74 return ret;
75 } 75 }
76 76
77 _gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], 77 mhd_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16],
78 session->security_parameters. 78 session->security_parameters.
79 master_secret, TLS_MASTER_SIZE); 79 master_secret, TLS_MASTER_SIZE);
80 } 80 }
81 else 81 else
82 _gnutls_hash_deinit (td_sha, &concat[16]); 82 mhd_gnutls_hash_deinit (td_sha, &concat[16]);
83 83
84 switch (cert->subject_pk_algorithm) 84 switch (cert->subject_pk_algorithm)
85 { 85 {
86 case MHD_GNUTLS_PK_RSA: 86 case MHD_GNUTLS_PK_RSA:
87 td_md5 = 87 td_md5 =
88 _gnutls_hash_copy (session->internals.handshake_mac_handle_md5); 88 mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
89 if (td_md5 == NULL) 89 if (td_md5 == NULL)
90 { 90 {
91 gnutls_assert (); 91 gnutls_assert ();
@@ -93,11 +93,11 @@ _gnutls_tls_sign_hdata (gnutls_session_t session,
93 } 93 }
94 94
95 if (ver == MHD_GNUTLS_SSL3) 95 if (ver == MHD_GNUTLS_SSL3)
96 _gnutls_mac_deinit_ssl3_handshake (td_md5, concat, 96 mhd_gnutls_mac_deinit_ssl3_handshake (td_md5, concat,
97 session->security_parameters. 97 session->security_parameters.
98 master_secret, TLS_MASTER_SIZE); 98 master_secret, TLS_MASTER_SIZE);
99 else 99 else
100 _gnutls_hash_deinit (td_md5, concat); 100 mhd_gnutls_hash_deinit (td_md5, concat);
101 101
102 dconcat.data = concat; 102 dconcat.data = concat;
103 dconcat.size = 36; 103 dconcat.size = 36;
@@ -119,7 +119,7 @@ _gnutls_tls_sign_hdata (gnutls_session_t session,
119 * Used in DHE_* ciphersuites. 119 * Used in DHE_* ciphersuites.
120 */ 120 */
121int 121int
122_gnutls_tls_sign_params (gnutls_session_t session, 122mhd_gtls_tls_sign_params (mhd_gtls_session_t session,
123 gnutls_cert * cert, 123 gnutls_cert * cert,
124 gnutls_privkey * pkey, 124 gnutls_privkey * pkey,
125 gnutls_datum_t * params, gnutls_datum_t * signature) 125 gnutls_datum_t * params, gnutls_datum_t * signature)
@@ -128,41 +128,41 @@ _gnutls_tls_sign_params (gnutls_session_t session,
128 int ret; 128 int ret;
129 mac_hd_t td_sha; 129 mac_hd_t td_sha;
130 opaque concat[36]; 130 opaque concat[36];
131 gnutls_protocol_t ver = gnutls_protocol_get_version (session); 131 gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
132 132
133 td_sha = _gnutls_hash_init (MHD_GNUTLS_MAC_SHA1); 133 td_sha = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
134 if (td_sha == NULL) 134 if (td_sha == NULL)
135 { 135 {
136 gnutls_assert (); 136 gnutls_assert ();
137 return GNUTLS_E_HASH_FAILED; 137 return GNUTLS_E_HASH_FAILED;
138 } 138 }
139 139
140 _gnutls_hash (td_sha, session->security_parameters.client_random, 140 mhd_gnutls_hash (td_sha, session->security_parameters.client_random,
141 TLS_RANDOM_SIZE); 141 TLS_RANDOM_SIZE);
142 _gnutls_hash (td_sha, session->security_parameters.server_random, 142 mhd_gnutls_hash (td_sha, session->security_parameters.server_random,
143 TLS_RANDOM_SIZE); 143 TLS_RANDOM_SIZE);
144 _gnutls_hash (td_sha, params->data, params->size); 144 mhd_gnutls_hash (td_sha, params->data, params->size);
145 145
146 switch (cert->subject_pk_algorithm) 146 switch (cert->subject_pk_algorithm)
147 { 147 {
148 case MHD_GNUTLS_PK_RSA: 148 case MHD_GNUTLS_PK_RSA:
149 if (ver < MHD_GNUTLS_TLS1_2) 149 if (ver < MHD_GNUTLS_TLS1_2)
150 { 150 {
151 mac_hd_t td_md5 = _gnutls_hash_init (MHD_GNUTLS_MAC_MD5); 151 mac_hd_t td_md5 = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
152 if (td_md5 == NULL) 152 if (td_md5 == NULL)
153 { 153 {
154 gnutls_assert (); 154 gnutls_assert ();
155 return GNUTLS_E_HASH_FAILED; 155 return GNUTLS_E_HASH_FAILED;
156 } 156 }
157 157
158 _gnutls_hash (td_md5, session->security_parameters.client_random, 158 mhd_gnutls_hash (td_md5, session->security_parameters.client_random,
159 TLS_RANDOM_SIZE); 159 TLS_RANDOM_SIZE);
160 _gnutls_hash (td_md5, session->security_parameters.server_random, 160 mhd_gnutls_hash (td_md5, session->security_parameters.server_random,
161 TLS_RANDOM_SIZE); 161 TLS_RANDOM_SIZE);
162 _gnutls_hash (td_md5, params->data, params->size); 162 mhd_gnutls_hash (td_md5, params->data, params->size);
163 163
164 _gnutls_hash_deinit (td_md5, concat); 164 mhd_gnutls_hash_deinit (td_md5, concat);
165 _gnutls_hash_deinit (td_sha, &concat[16]); 165 mhd_gnutls_hash_deinit (td_sha, &concat[16]);
166 166
167 dconcat.size = 36; 167 dconcat.size = 36;
168 } 168 }
@@ -173,13 +173,13 @@ _gnutls_tls_sign_params (gnutls_session_t session,
173 memcpy (concat, 173 memcpy (concat,
174 "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14", 174 "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14",
175 15); 175 15);
176 _gnutls_hash_deinit (td_sha, &concat[15]); 176 mhd_gnutls_hash_deinit (td_sha, &concat[15]);
177 dconcat.size = 35; 177 dconcat.size = 35;
178#else 178#else
179 /* No parameters field. */ 179 /* No parameters field. */
180 memcpy (concat, 180 memcpy (concat,
181 "\x30\x1f\x30\x07\x06\x05\x2b\x0e\x03\x02\x1a\x04\x14", 13); 181 "\x30\x1f\x30\x07\x06\x05\x2b\x0e\x03\x02\x1a\x04\x14", 13);
182 _gnutls_hash_deinit (td_sha, &concat[13]); 182 mhd_gnutls_hash_deinit (td_sha, &concat[13]);
183 dconcat.size = 33; 183 dconcat.size = 33;
184#endif 184#endif
185 } 185 }
@@ -187,7 +187,7 @@ _gnutls_tls_sign_params (gnutls_session_t session,
187 break; 187 break;
188 default: 188 default:
189 gnutls_assert (); 189 gnutls_assert ();
190 _gnutls_hash_deinit (td_sha, NULL); 190 mhd_gnutls_hash_deinit (td_sha, NULL);
191 return GNUTLS_E_INTERNAL_ERROR; 191 return GNUTLS_E_INTERNAL_ERROR;
192 } 192 }
193 ret = _gnutls_tls_sign (session, cert, pkey, &dconcat, signature); 193 ret = _gnutls_tls_sign (session, cert, pkey, &dconcat, signature);
@@ -204,7 +204,7 @@ _gnutls_tls_sign_params (gnutls_session_t session,
204 * given data. The output will be allocated and be put in signature. 204 * given data. The output will be allocated and be put in signature.
205 */ 205 */
206int 206int
207_gnutls_sign (gnutls_pk_algorithm_t algo, 207mhd_gtls_sign (gnutls_pk_algorithm_t algo,
208 mpi_t * params, 208 mpi_t * params,
209 int params_size, 209 int params_size,
210 const gnutls_datum_t * data, gnutls_datum_t * signature) 210 const gnutls_datum_t * data, gnutls_datum_t * signature)
@@ -216,7 +216,7 @@ _gnutls_sign (gnutls_pk_algorithm_t algo,
216 case MHD_GNUTLS_PK_RSA: 216 case MHD_GNUTLS_PK_RSA:
217 /* encrypt */ 217 /* encrypt */
218 if ((ret = 218 if ((ret =
219 _gnutls_pkcs1_rsa_encrypt (signature, data, params, params_size, 219 mhd_gtls_pkcs1_rsa_encrypt (signature, data, params, params_size,
220 1)) < 0) 220 1)) < 0)
221 { 221 {
222 gnutls_assert (); 222 gnutls_assert ();
@@ -238,7 +238,7 @@ _gnutls_sign (gnutls_pk_algorithm_t algo,
238 * it supports signing. 238 * it supports signing.
239 */ 239 */
240static int 240static int
241_gnutls_tls_sign (gnutls_session_t session, 241_gnutls_tls_sign (mhd_gtls_session_t session,
242 gnutls_cert * cert, 242 gnutls_cert * cert,
243 gnutls_privkey * pkey, 243 gnutls_privkey * pkey,
244 const gnutls_datum_t * hash_concat, 244 const gnutls_datum_t * hash_concat,
@@ -269,7 +269,7 @@ _gnutls_tls_sign (gnutls_session_t session,
269 hash_concat, signature); 269 hash_concat, signature);
270 } 270 }
271 271
272 return _gnutls_sign (pkey->pk_algorithm, pkey->params, pkey->params_size, 272 return mhd_gtls_sign (pkey->pk_algorithm, pkey->params, pkey->params_size,
273 hash_concat, signature); 273 hash_concat, signature);
274} 274}
275 275
@@ -307,7 +307,7 @@ _gnutls_verify_sig (gnutls_cert * cert,
307 vdata.size = hash_concat->size; 307 vdata.size = hash_concat->size;
308 308
309 /* verify signature */ 309 /* verify signature */
310 if ((ret = _gnutls_rsa_verify (&vdata, signature, cert->params, 310 if ((ret = mhd_gtls_rsa_verify (&vdata, signature, cert->params,
311 cert->params_size, 1)) < 0) 311 cert->params_size, 1)) < 0)
312 { 312 {
313 gnutls_assert (); 313 gnutls_assert ();
@@ -327,7 +327,7 @@ _gnutls_verify_sig (gnutls_cert * cert,
327 * verify message). 327 * verify message).
328 */ 328 */
329int 329int
330_gnutls_verify_sig_hdata (gnutls_session_t session, 330mhd_gtls_verify_sig_hdata (mhd_gtls_session_t session,
331 gnutls_cert * cert, gnutls_datum_t * signature) 331 gnutls_cert * cert, gnutls_datum_t * signature)
332{ 332{
333 int ret; 333 int ret;
@@ -335,43 +335,43 @@ _gnutls_verify_sig_hdata (gnutls_session_t session,
335 mac_hd_t td_md5; 335 mac_hd_t td_md5;
336 mac_hd_t td_sha; 336 mac_hd_t td_sha;
337 gnutls_datum_t dconcat; 337 gnutls_datum_t dconcat;
338 gnutls_protocol_t ver = gnutls_protocol_get_version (session); 338 gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
339 339
340 td_md5 = _gnutls_hash_copy (session->internals.handshake_mac_handle_md5); 340 td_md5 = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
341 if (td_md5 == NULL) 341 if (td_md5 == NULL)
342 { 342 {
343 gnutls_assert (); 343 gnutls_assert ();
344 return GNUTLS_E_HASH_FAILED; 344 return GNUTLS_E_HASH_FAILED;
345 } 345 }
346 346
347 td_sha = _gnutls_hash_copy (session->internals.handshake_mac_handle_sha); 347 td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
348 if (td_sha == NULL) 348 if (td_sha == NULL)
349 { 349 {
350 gnutls_assert (); 350 gnutls_assert ();
351 _gnutls_hash_deinit (td_md5, NULL); 351 mhd_gnutls_hash_deinit (td_md5, NULL);
352 return GNUTLS_E_HASH_FAILED; 352 return GNUTLS_E_HASH_FAILED;
353 } 353 }
354 354
355 if (ver == MHD_GNUTLS_SSL3) 355 if (ver == MHD_GNUTLS_SSL3)
356 { 356 {
357 ret = _gnutls_generate_master (session, 1); 357 ret = mhd_gtls_generate_master (session, 1);
358 if (ret < 0) 358 if (ret < 0)
359 { 359 {
360 gnutls_assert (); 360 gnutls_assert ();
361 return ret; 361 return ret;
362 } 362 }
363 363
364 _gnutls_mac_deinit_ssl3_handshake (td_md5, concat, 364 mhd_gnutls_mac_deinit_ssl3_handshake (td_md5, concat,
365 session->security_parameters. 365 session->security_parameters.
366 master_secret, TLS_MASTER_SIZE); 366 master_secret, TLS_MASTER_SIZE);
367 _gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], 367 mhd_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16],
368 session->security_parameters. 368 session->security_parameters.
369 master_secret, TLS_MASTER_SIZE); 369 master_secret, TLS_MASTER_SIZE);
370 } 370 }
371 else 371 else
372 { 372 {
373 _gnutls_hash_deinit (td_md5, concat); 373 mhd_gnutls_hash_deinit (td_md5, concat);
374 _gnutls_hash_deinit (td_sha, &concat[16]); 374 mhd_gnutls_hash_deinit (td_sha, &concat[16]);
375 } 375 }
376 376
377 dconcat.data = concat; 377 dconcat.data = concat;
@@ -392,7 +392,7 @@ _gnutls_verify_sig_hdata (gnutls_session_t session,
392 * Used in DHE_* ciphersuites. 392 * Used in DHE_* ciphersuites.
393 */ 393 */
394int 394int
395_gnutls_verify_sig_params (gnutls_session_t session, 395mhd_gtls_verify_sig_params (mhd_gtls_session_t session,
396 gnutls_cert * cert, 396 gnutls_cert * cert,
397 const gnutls_datum_t * params, 397 const gnutls_datum_t * params,
398 gnutls_datum_t * signature) 398 gnutls_datum_t * signature)
@@ -402,43 +402,43 @@ _gnutls_verify_sig_params (gnutls_session_t session,
402 mac_hd_t td_md5 = NULL; 402 mac_hd_t td_md5 = NULL;
403 mac_hd_t td_sha; 403 mac_hd_t td_sha;
404 opaque concat[36]; 404 opaque concat[36];
405 gnutls_protocol_t ver = gnutls_protocol_get_version (session); 405 gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
406 406
407 if (ver < MHD_GNUTLS_TLS1_2) 407 if (ver < MHD_GNUTLS_TLS1_2)
408 { 408 {
409 td_md5 = _gnutls_hash_init (MHD_GNUTLS_MAC_MD5); 409 td_md5 = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
410 if (td_md5 == NULL) 410 if (td_md5 == NULL)
411 { 411 {
412 gnutls_assert (); 412 gnutls_assert ();
413 return GNUTLS_E_HASH_FAILED; 413 return GNUTLS_E_HASH_FAILED;
414 } 414 }
415 415
416 _gnutls_hash (td_md5, session->security_parameters.client_random, 416 mhd_gnutls_hash (td_md5, session->security_parameters.client_random,
417 TLS_RANDOM_SIZE); 417 TLS_RANDOM_SIZE);
418 _gnutls_hash (td_md5, session->security_parameters.server_random, 418 mhd_gnutls_hash (td_md5, session->security_parameters.server_random,
419 TLS_RANDOM_SIZE); 419 TLS_RANDOM_SIZE);
420 _gnutls_hash (td_md5, params->data, params->size); 420 mhd_gnutls_hash (td_md5, params->data, params->size);
421 } 421 }
422 422
423 td_sha = _gnutls_hash_init (MHD_GNUTLS_MAC_SHA1); 423 td_sha = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
424 if (td_sha == NULL) 424 if (td_sha == NULL)
425 { 425 {
426 gnutls_assert (); 426 gnutls_assert ();
427 if (td_md5) 427 if (td_md5)
428 _gnutls_hash_deinit (td_md5, NULL); 428 mhd_gnutls_hash_deinit (td_md5, NULL);
429 return GNUTLS_E_HASH_FAILED; 429 return GNUTLS_E_HASH_FAILED;
430 } 430 }
431 431
432 _gnutls_hash (td_sha, session->security_parameters.client_random, 432 mhd_gnutls_hash (td_sha, session->security_parameters.client_random,
433 TLS_RANDOM_SIZE); 433 TLS_RANDOM_SIZE);
434 _gnutls_hash (td_sha, session->security_parameters.server_random, 434 mhd_gnutls_hash (td_sha, session->security_parameters.server_random,
435 TLS_RANDOM_SIZE); 435 TLS_RANDOM_SIZE);
436 _gnutls_hash (td_sha, params->data, params->size); 436 mhd_gnutls_hash (td_sha, params->data, params->size);
437 437
438 if (ver < MHD_GNUTLS_TLS1_2) 438 if (ver < MHD_GNUTLS_TLS1_2)
439 { 439 {
440 _gnutls_hash_deinit (td_md5, concat); 440 mhd_gnutls_hash_deinit (td_md5, concat);
441 _gnutls_hash_deinit (td_sha, &concat[16]); 441 mhd_gnutls_hash_deinit (td_sha, &concat[16]);
442 dconcat.size = 36; 442 dconcat.size = 36;
443 } 443 }
444 else 444 else
@@ -448,13 +448,13 @@ _gnutls_verify_sig_params (gnutls_session_t session,
448 memcpy (concat, 448 memcpy (concat,
449 "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14", 449 "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14",
450 15); 450 15);
451 _gnutls_hash_deinit (td_sha, &concat[15]); 451 mhd_gnutls_hash_deinit (td_sha, &concat[15]);
452 dconcat.size = 35; 452 dconcat.size = 35;
453#else 453#else
454 /* No parameters field. */ 454 /* No parameters field. */
455 memcpy (concat, 455 memcpy (concat,
456 "\x30\x1f\x30\x07\x06\x05\x2b\x0e\x03\x02\x1a\x04\x14", 13); 456 "\x30\x1f\x30\x07\x06\x05\x2b\x0e\x03\x02\x1a\x04\x14", 13);
457 _gnutls_hash_deinit (td_sha, &concat[13]); 457 mhd_gnutls_hash_deinit (td_sha, &concat[13]);
458 dconcat.size = 33; 458 dconcat.size = 33;
459#endif 459#endif
460 } 460 }
diff --git a/src/daemon/https/tls/gnutls_sig.h b/src/daemon/https/tls/gnutls_sig.h
index 4d770716..b484137b 100644
--- a/src/daemon/https/tls/gnutls_sig.h
+++ b/src/daemon/https/tls/gnutls_sig.h
@@ -25,26 +25,26 @@
25#ifndef GNUTLS_SIG_H 25#ifndef GNUTLS_SIG_H
26# define GNUTLS_SIG_H 26# define GNUTLS_SIG_H
27 27
28int _gnutls_tls_sign_hdata (gnutls_session_t session, 28int mhd_gtls_tls_sign_hdata (mhd_gtls_session_t session,
29 gnutls_cert * cert, 29 gnutls_cert * cert,
30 gnutls_privkey * pkey, 30 gnutls_privkey * pkey,
31 gnutls_datum_t * signature); 31 gnutls_datum_t * signature);
32 32
33int _gnutls_tls_sign_params (gnutls_session_t session, 33int mhd_gtls_tls_sign_params (mhd_gtls_session_t session,
34 gnutls_cert * cert, 34 gnutls_cert * cert,
35 gnutls_privkey * pkey, 35 gnutls_privkey * pkey,
36 gnutls_datum_t * params, 36 gnutls_datum_t * params,
37 gnutls_datum_t * signature); 37 gnutls_datum_t * signature);
38 38
39int _gnutls_verify_sig_hdata (gnutls_session_t session, 39int mhd_gtls_verify_sig_hdata (mhd_gtls_session_t session,
40 gnutls_cert * cert, gnutls_datum_t * signature); 40 gnutls_cert * cert, gnutls_datum_t * signature);
41 41
42int _gnutls_verify_sig_params (gnutls_session_t session, 42int mhd_gtls_verify_sig_params (mhd_gtls_session_t session,
43 gnutls_cert * cert, 43 gnutls_cert * cert,
44 const gnutls_datum_t * params, 44 const gnutls_datum_t * params,
45 gnutls_datum_t * signature); 45 gnutls_datum_t * signature);
46 46
47int _gnutls_sign (gnutls_pk_algorithm_t algo, 47int mhd_gtls_sign (gnutls_pk_algorithm_t algo,
48 mpi_t * params, int params_size, 48 mpi_t * params, int params_size,
49 const gnutls_datum_t * data, gnutls_datum_t * signature); 49 const gnutls_datum_t * data, gnutls_datum_t * signature);
50 50
diff --git a/src/daemon/https/tls/gnutls_state.c b/src/daemon/https/tls/gnutls_state.c
index 3931b393..bb5b8390 100644
--- a/src/daemon/https/tls/gnutls_state.c
+++ b/src/daemon/https/tls/gnutls_state.c
@@ -43,7 +43,7 @@
43#include <gnutls_rsa_export.h> 43#include <gnutls_rsa_export.h>
44 44
45void 45void
46_gnutls_session_cert_type_set (gnutls_session_t session, 46_gnutls_session_cert_type_set (mhd_gtls_session_t session,
47 gnutls_certificate_type_t ct) 47 gnutls_certificate_type_t ct)
48{ 48{
49 session->security_parameters.cert_type = ct; 49 session->security_parameters.cert_type = ct;
@@ -51,19 +51,19 @@ _gnutls_session_cert_type_set (gnutls_session_t session,
51 51
52/** 52/**
53 * gnutls_cipher_get - Returns the currently used cipher. 53 * gnutls_cipher_get - Returns the currently used cipher.
54 * @session: is a #gnutls_session_t structure. 54 * @session: is a #mhd_gtls_session_t structure.
55 * 55 *
56 * Returns: the currently used cipher. 56 * Returns: the currently used cipher.
57 **/ 57 **/
58gnutls_cipher_algorithm_t 58gnutls_cipher_algorithm_t
59gnutls_cipher_get (gnutls_session_t session) 59gnutls_cipher_get (mhd_gtls_session_t session)
60{ 60{
61 return session->security_parameters.read_bulk_cipher_algorithm; 61 return session->security_parameters.read_bulk_cipher_algorithm;
62} 62}
63 63
64/** 64/**
65 * gnutls_certificate_type_get - Returns the currently used certificate type. 65 * gnutls_certificate_type_get - Returns the currently used certificate type.
66 * @session: is a #gnutls_session_t structure. 66 * @session: is a #mhd_gtls_session_t structure.
67 * 67 *
68 * The certificate type is by default X.509, unless it is negotiated 68 * The certificate type is by default X.509, unless it is negotiated
69 * as a TLS extension. 69 * as a TLS extension.
@@ -72,43 +72,43 @@ gnutls_cipher_get (gnutls_session_t session)
72 * type. 72 * type.
73 **/ 73 **/
74gnutls_certificate_type_t 74gnutls_certificate_type_t
75gnutls_certificate_type_get (gnutls_session_t session) 75gnutls_certificate_type_get (mhd_gtls_session_t session)
76{ 76{
77 return session->security_parameters.cert_type; 77 return session->security_parameters.cert_type;
78} 78}
79 79
80/** 80/**
81 * gnutls_kx_get - Returns the key exchange algorithm. 81 * gnutls_kx_get - Returns the key exchange algorithm.
82 * @session: is a #gnutls_session_t structure. 82 * @session: is a #mhd_gtls_session_t structure.
83 * 83 *
84 * Returns: the key exchange algorithm used in the last handshake. 84 * Returns: the key exchange algorithm used in the last handshake.
85 **/ 85 **/
86gnutls_kx_algorithm_t 86gnutls_kx_algorithm_t
87gnutls_kx_get (gnutls_session_t session) 87gnutls_kx_get (mhd_gtls_session_t session)
88{ 88{
89 return session->security_parameters.kx_algorithm; 89 return session->security_parameters.kx_algorithm;
90} 90}
91 91
92/** 92/**
93 * gnutls_mac_get - Returns the currently used mac algorithm. 93 * gnutls_mac_get - Returns the currently used mac algorithm.
94 * @session: is a #gnutls_session_t structure. 94 * @session: is a #mhd_gtls_session_t structure.
95 * 95 *
96 * Returns: the currently used mac algorithm. 96 * Returns: the currently used mac algorithm.
97 **/ 97 **/
98gnutls_mac_algorithm_t 98gnutls_mac_algorithm_t
99gnutls_mac_get (gnutls_session_t session) 99gnutls_mac_get (mhd_gtls_session_t session)
100{ 100{
101 return session->security_parameters.read_mac_algorithm; 101 return session->security_parameters.read_mac_algorithm;
102} 102}
103 103
104/** 104/**
105 * gnutls_compression_get - Returns the currently used compression algorithm. 105 * gnutls_compression_get - Returns the currently used compression algorithm.
106 * @session: is a #gnutls_session_t structure. 106 * @session: is a #mhd_gtls_session_t structure.
107 * 107 *
108 * Returns: the currently used compression method. 108 * Returns: the currently used compression method.
109 **/ 109 **/
110gnutls_compression_method_t 110gnutls_compression_method_t
111gnutls_compression_get (gnutls_session_t session) 111gnutls_compression_get (mhd_gtls_session_t session)
112{ 112{
113 return session->security_parameters.read_compression_algorithm; 113 return session->security_parameters.read_compression_algorithm;
114} 114}
@@ -118,17 +118,17 @@ gnutls_compression_get (gnutls_session_t session)
118 * and a matching certificate exists. 118 * and a matching certificate exists.
119 */ 119 */
120int 120int
121_gnutls_session_cert_type_supported (gnutls_session_t session, 121mhd_gtls_session_cert_type_supported (mhd_gtls_session_t session,
122 gnutls_certificate_type_t cert_type) 122 gnutls_certificate_type_t cert_type)
123{ 123{
124 unsigned i; 124 unsigned i;
125 unsigned cert_found = 0; 125 unsigned cert_found = 0;
126 gnutls_certificate_credentials_t cred; 126 mhd_gtls_cert_credentials_t cred;
127 127
128 if (session->security_parameters.entity == GNUTLS_SERVER) 128 if (session->security_parameters.entity == GNUTLS_SERVER)
129 { 129 {
130 cred 130 cred
131 = (gnutls_certificate_credentials_t) _gnutls_get_cred (session->key, 131 = (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key,
132 MHD_GNUTLS_CRD_CERTIFICATE, 132 MHD_GNUTLS_CRD_CERTIFICATE,
133 NULL); 133 NULL);
134 134
@@ -172,13 +172,13 @@ _gnutls_session_cert_type_supported (gnutls_session_t session,
172 * in a session struct. 172 * in a session struct.
173 */ 173 */
174inline static void 174inline static void
175deinit_internal_params (gnutls_session_t session) 175deinit_internal_params (mhd_gtls_session_t session)
176{ 176{
177 if (session->internals.params.free_dh_params) 177 if (session->internals.params.free_dh_params)
178 gnutls_dh_params_deinit (session->internals.params.dh_params); 178 MHD_gnutls_dh_params_deinit (session->internals.params.dh_params);
179 179
180 if (session->internals.params.free_rsa_params) 180 if (session->internals.params.free_rsa_params)
181 gnutls_rsa_params_deinit (session->internals.params.rsa_params); 181 MHD_gnutls_rsa_params_deinit (session->internals.params.rsa_params);
182 182
183 memset (&session->internals.params, 0, sizeof (session->internals.params)); 183 memset (&session->internals.params, 0, sizeof (session->internals.params));
184} 184}
@@ -188,7 +188,7 @@ deinit_internal_params (gnutls_session_t session)
188 * This is used to allow further handshakes. 188 * This is used to allow further handshakes.
189 */ 189 */
190void 190void
191_gnutls_handshake_internal_state_clear (gnutls_session_t session) 191mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t session)
192{ 192{
193 session->internals.extensions_sent_size = 0; 193 session->internals.extensions_sent_size = 0;
194 194
@@ -198,7 +198,7 @@ _gnutls_handshake_internal_state_clear (gnutls_session_t session)
198 session->internals.adv_version_minor = 0; 198 session->internals.adv_version_minor = 0;
199 session->internals.v2_hello = 0; 199 session->internals.v2_hello = 0;
200 memset (&session->internals.handshake_header_buffer, 0, 200 memset (&session->internals.handshake_header_buffer, 0,
201 sizeof (handshake_header_buffer_st)); 201 sizeof (mhd_gtls_handshake_header_buffer_st));
202 session->internals.adv_version_minor = 0; 202 session->internals.adv_version_minor = 0;
203 session->internals.adv_version_minor = 0; 203 session->internals.adv_version_minor = 0;
204 session->internals.direction = 0; 204 session->internals.direction = 0;
@@ -218,14 +218,14 @@ _gnutls_handshake_internal_state_clear (gnutls_session_t session)
218 218
219#define MIN_DH_BITS 727 219#define MIN_DH_BITS 727
220/** 220/**
221 * gnutls_init - This function initializes the session to null (null encryption etc...). 221 * MHD_gnutls_init - This function initializes the session to null (null encryption etc...).
222 * @con_end: indicate if this session is to be used for server or client. 222 * @con_end: indicate if this session is to be used for server or client.
223 * @session: is a pointer to a #gnutls_session_t structure. 223 * @session: is a pointer to a #mhd_gtls_session_t structure.
224 * 224 *
225 * This function initializes the current session to null. Every 225 * This function initializes the current session to null. Every
226 * session must be initialized before use, so internal structures can 226 * session must be initialized before use, so internal structures can
227 * be allocated. This function allocates structures which can only 227 * be allocated. This function allocates structures which can only
228 * be free'd by calling gnutls_deinit(). Returns zero on success. 228 * be free'd by calling MHD_gnutls_deinit(). Returns zero on success.
229 * 229 *
230 * @con_end can be one of %GNUTLS_CLIENT and %GNUTLS_SERVER. 230 * @con_end can be one of %GNUTLS_CLIENT and %GNUTLS_SERVER.
231 * 231 *
@@ -234,9 +234,9 @@ _gnutls_handshake_internal_state_clear (gnutls_session_t session)
234 234
235/* TODO rm redundent pointer ref */ 235/* TODO rm redundent pointer ref */
236int 236int
237gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end) 237MHD_gnutls_init (mhd_gtls_session_t * session, gnutls_connection_end_t con_end)
238{ 238{
239 *session = gnutls_calloc (1, sizeof (struct gnutls_session_int)); 239 *session = gnutls_calloc (1, sizeof (struct MHD_gtls_session_int));
240 if (*session == NULL) 240 if (*session == NULL)
241 return GNUTLS_E_MEMORY_ERROR; 241 return GNUTLS_E_MEMORY_ERROR;
242 242
@@ -261,18 +261,18 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
261 (*session)->internals.enable_private = 0; 261 (*session)->internals.enable_private = 0;
262 262
263 /* Initialize buffers */ 263 /* Initialize buffers */
264 _gnutls_buffer_init (&(*session)->internals.application_data_buffer); 264 mhd_gtls_buffer_init (&(*session)->internals.application_data_buffer);
265 _gnutls_buffer_init (&(*session)->internals.handshake_data_buffer); 265 mhd_gtls_buffer_init (&(*session)->internals.handshake_data_buffer);
266 _gnutls_buffer_init (&(*session)->internals.handshake_hash_buffer); 266 mhd_gtls_buffer_init (&(*session)->internals.handshake_hash_buffer);
267 _gnutls_buffer_init (&(*session)->internals.ia_data_buffer); 267 mhd_gtls_buffer_init (&(*session)->internals.ia_data_buffer);
268 268
269 _gnutls_buffer_init (&(*session)->internals.record_send_buffer); 269 mhd_gtls_buffer_init (&(*session)->internals.record_send_buffer);
270 _gnutls_buffer_init (&(*session)->internals.record_recv_buffer); 270 mhd_gtls_buffer_init (&(*session)->internals.record_recv_buffer);
271 271
272 _gnutls_buffer_init (&(*session)->internals.handshake_send_buffer); 272 mhd_gtls_buffer_init (&(*session)->internals.handshake_send_buffer);
273 _gnutls_buffer_init (&(*session)->internals.handshake_recv_buffer); 273 mhd_gtls_buffer_init (&(*session)->internals.handshake_recv_buffer);
274 274
275 (*session)->key = gnutls_calloc (1, sizeof (struct gnutls_key_st)); 275 (*session)->key = gnutls_calloc (1, sizeof (struct mhd_gtls_key));
276 if ((*session)->key == NULL) 276 if ((*session)->key == NULL)
277 { 277 {
278 cleanup_session:gnutls_free (*session); 278 cleanup_session:gnutls_free (*session);
@@ -282,11 +282,11 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
282 282
283 (*session)->internals.expire_time = DEFAULT_EXPIRE_TIME; /* one hour default */ 283 (*session)->internals.expire_time = DEFAULT_EXPIRE_TIME; /* one hour default */
284 284
285 gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS); 285 MHD_gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS);
286 286
287 gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */ 287 MHD_gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */
288 288
289 gnutls_handshake_set_max_packet_length ((*session), 289 MHD_gnutls_handshake_set_max_packet_length ((*session),
290 MAX_HANDSHAKE_PACKET_SIZE); 290 MAX_HANDSHAKE_PACKET_SIZE);
291 291
292 /* Allocate a minimum size for recv_data 292 /* Allocate a minimum size for recv_data
@@ -316,7 +316,7 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
316 * as NULL or 0. This is why calloc is used. 316 * as NULL or 0. This is why calloc is used.
317 */ 317 */
318 318
319 _gnutls_handshake_internal_state_clear (*session); 319 mhd_gtls_handshake_internal_state_clear (*session);
320 320
321 return 0; 321 return 0;
322} 322}
@@ -324,54 +324,54 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end)
324/* returns RESUME_FALSE or RESUME_TRUE. 324/* returns RESUME_FALSE or RESUME_TRUE.
325 */ 325 */
326int 326int
327_gnutls_session_is_resumable (gnutls_session_t session) 327mhd_gtls_session_is_resumable (mhd_gtls_session_t session)
328{ 328{
329 return session->internals.resumable; 329 return session->internals.resumable;
330} 330}
331 331
332/** 332/**
333 * gnutls_deinit - This function clears all buffers associated with a session 333 * MHD_gnutls_deinit - This function clears all buffers associated with a session
334 * @session: is a #gnutls_session_t structure. 334 * @session: is a #mhd_gtls_session_t structure.
335 * 335 *
336 * This function clears all buffers associated with the @session. 336 * This function clears all buffers associated with the @session.
337 * This function will also remove session data from the session 337 * This function will also remove session data from the session
338 * database if the session was terminated abnormally. 338 * database if the session was terminated abnormally.
339 **/ 339 **/
340void 340void
341gnutls_deinit (gnutls_session_t session) 341MHD_gnutls_deinit (mhd_gtls_session_t session)
342{ 342{
343 343
344 if (session == NULL) 344 if (session == NULL)
345 return; 345 return;
346 346
347 /* remove auth info firstly */ 347 /* remove auth info firstly */
348 _gnutls_free_auth_info (session); 348 mhd_gtls_free_auth_info (session);
349 349
350 _gnutls_handshake_internal_state_clear (session); 350 mhd_gtls_handshake_internal_state_clear (session);
351 _gnutls_handshake_io_buffer_clear (session); 351 _gnutls_handshake_io_buffer_clear (session);
352 352
353 _gnutls_free_datum (&session->connection_state.read_mac_secret); 353 _gnutls_free_datum (&session->connection_state.read_mac_secret);
354 _gnutls_free_datum (&session->connection_state.write_mac_secret); 354 _gnutls_free_datum (&session->connection_state.write_mac_secret);
355 355
356 _gnutls_buffer_clear (&session->internals.ia_data_buffer); 356 mhd_gtls_buffer_clear (&session->internals.ia_data_buffer);
357 _gnutls_buffer_clear (&session->internals.handshake_hash_buffer); 357 mhd_gtls_buffer_clear (&session->internals.handshake_hash_buffer);
358 _gnutls_buffer_clear (&session->internals.handshake_data_buffer); 358 mhd_gtls_buffer_clear (&session->internals.handshake_data_buffer);
359 _gnutls_buffer_clear (&session->internals.application_data_buffer); 359 mhd_gtls_buffer_clear (&session->internals.application_data_buffer);
360 _gnutls_buffer_clear (&session->internals.record_recv_buffer); 360 mhd_gtls_buffer_clear (&session->internals.record_recv_buffer);
361 _gnutls_buffer_clear (&session->internals.record_send_buffer); 361 mhd_gtls_buffer_clear (&session->internals.record_send_buffer);
362 362
363 gnutls_credentials_clear (session); 363 MHD_gnutls_credentials_clear (session);
364 _gnutls_selected_certs_deinit (session); 364 mhd_gtls_selected_certs_deinit (session);
365 365
366 if (session->connection_state.read_cipher_state != NULL) 366 if (session->connection_state.read_cipher_state != NULL)
367 _gnutls_cipher_deinit (session->connection_state.read_cipher_state); 367 mhd_gnutls_cipher_deinit (session->connection_state.read_cipher_state);
368 if (session->connection_state.write_cipher_state != NULL) 368 if (session->connection_state.write_cipher_state != NULL)
369 _gnutls_cipher_deinit (session->connection_state.write_cipher_state); 369 mhd_gnutls_cipher_deinit (session->connection_state.write_cipher_state);
370 370
371 if (session->connection_state.read_compression_state != NULL) 371 if (session->connection_state.read_compression_state != NULL)
372 _gnutls_comp_deinit (session->connection_state.read_compression_state, 1); 372 mhd_gtls_comp_deinit (session->connection_state.read_compression_state, 1);
373 if (session->connection_state.write_compression_state != NULL) 373 if (session->connection_state.write_compression_state != NULL)
374 _gnutls_comp_deinit (session->connection_state. 374 mhd_gtls_comp_deinit (session->connection_state.
375 write_compression_state, 0); 375 write_compression_state, 0);
376 376
377 _gnutls_free_datum (&session->cipher_specs.server_write_mac_secret); 377 _gnutls_free_datum (&session->cipher_specs.server_write_mac_secret);
@@ -383,23 +383,23 @@ gnutls_deinit (gnutls_session_t session)
383 383
384 if (session->key != NULL) 384 if (session->key != NULL)
385 { 385 {
386 _gnutls_mpi_release (&session->key->KEY); 386 mhd_gtls_mpi_release (&session->key->KEY);
387 _gnutls_mpi_release (&session->key->client_Y); 387 mhd_gtls_mpi_release (&session->key->client_Y);
388 _gnutls_mpi_release (&session->key->client_p); 388 mhd_gtls_mpi_release (&session->key->client_p);
389 _gnutls_mpi_release (&session->key->client_g); 389 mhd_gtls_mpi_release (&session->key->client_g);
390 390
391 _gnutls_mpi_release (&session->key->u); 391 mhd_gtls_mpi_release (&session->key->u);
392 _gnutls_mpi_release (&session->key->a); 392 mhd_gtls_mpi_release (&session->key->a);
393 _gnutls_mpi_release (&session->key->x); 393 mhd_gtls_mpi_release (&session->key->x);
394 _gnutls_mpi_release (&session->key->A); 394 mhd_gtls_mpi_release (&session->key->A);
395 _gnutls_mpi_release (&session->key->B); 395 mhd_gtls_mpi_release (&session->key->B);
396 _gnutls_mpi_release (&session->key->b); 396 mhd_gtls_mpi_release (&session->key->b);
397 397
398 /* RSA */ 398 /* RSA */
399 _gnutls_mpi_release (&session->key->rsa[0]); 399 mhd_gtls_mpi_release (&session->key->rsa[0]);
400 _gnutls_mpi_release (&session->key->rsa[1]); 400 mhd_gtls_mpi_release (&session->key->rsa[1]);
401 401
402 _gnutls_mpi_release (&session->key->dh_secret); 402 mhd_gtls_mpi_release (&session->key->dh_secret);
403 gnutls_free (session->key); 403 gnutls_free (session->key);
404 404
405 session->key = NULL; 405 session->key = NULL;
@@ -414,30 +414,30 @@ gnutls_deinit (gnutls_session_t session)
414 gnutls_free (session->internals.srp_password); 414 gnutls_free (session->internals.srp_password);
415 } 415 }
416 416
417 memset (session, 0, sizeof (struct gnutls_session_int)); 417 memset (session, 0, sizeof (struct MHD_gtls_session_int));
418 gnutls_free (session); 418 gnutls_free (session);
419} 419}
420 420
421/* Returns the minimum prime bits that are acceptable. 421/* Returns the minimum prime bits that are acceptable.
422 */ 422 */
423int 423int
424_gnutls_dh_get_allowed_prime_bits (gnutls_session_t session) 424mhd_gtls_dh_get_allowed_prime_bits (mhd_gtls_session_t session)
425{ 425{
426 return session->internals.dh_prime_bits; 426 return session->internals.dh_prime_bits;
427} 427}
428 428
429int 429int
430_gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public) 430mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public)
431{ 431{
432 dh_info_st *dh; 432 dh_info_st *dh;
433 int ret; 433 int ret;
434 434
435 switch (gnutls_auth_get_type (session)) 435 switch (MHD_gtls_auth_get_type (session))
436 { 436 {
437 case MHD_GNUTLS_CRD_ANON: 437 case MHD_GNUTLS_CRD_ANON:
438 { 438 {
439 anon_auth_info_t info; 439 mhd_anon_auth_info_t info;
440 info = _gnutls_get_auth_info (session); 440 info = mhd_gtls_get_auth_info (session);
441 if (info == NULL) 441 if (info == NULL)
442 return GNUTLS_E_INTERNAL_ERROR; 442 return GNUTLS_E_INTERNAL_ERROR;
443 443
@@ -448,7 +448,7 @@ _gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public)
448 { 448 {
449 cert_auth_info_t info; 449 cert_auth_info_t info;
450 450
451 info = _gnutls_get_auth_info (session); 451 info = mhd_gtls_get_auth_info (session);
452 if (info == NULL) 452 if (info == NULL)
453 return GNUTLS_E_INTERNAL_ERROR; 453 return GNUTLS_E_INTERNAL_ERROR;
454 454
@@ -460,7 +460,7 @@ _gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public)
460 return GNUTLS_E_INTERNAL_ERROR; 460 return GNUTLS_E_INTERNAL_ERROR;
461 } 461 }
462 462
463 ret = _gnutls_mpi_dprint_lz (&dh->public_key, public); 463 ret = mhd_gtls_mpi_dprint_lz (&dh->public_key, public);
464 if (ret < 0) 464 if (ret < 0)
465 { 465 {
466 gnutls_assert (); 466 gnutls_assert ();
@@ -471,14 +471,14 @@ _gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public)
471} 471}
472 472
473int 473int
474_gnutls_dh_set_secret_bits (gnutls_session_t session, unsigned bits) 474mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits)
475{ 475{
476 switch (gnutls_auth_get_type (session)) 476 switch (MHD_gtls_auth_get_type (session))
477 { 477 {
478 case MHD_GNUTLS_CRD_ANON: 478 case MHD_GNUTLS_CRD_ANON:
479 { 479 {
480 anon_auth_info_t info; 480 mhd_anon_auth_info_t info;
481 info = _gnutls_get_auth_info (session); 481 info = mhd_gtls_get_auth_info (session);
482 if (info == NULL) 482 if (info == NULL)
483 return GNUTLS_E_INTERNAL_ERROR; 483 return GNUTLS_E_INTERNAL_ERROR;
484 info->dh.secret_bits = bits; 484 info->dh.secret_bits = bits;
@@ -488,7 +488,7 @@ _gnutls_dh_set_secret_bits (gnutls_session_t session, unsigned bits)
488 { 488 {
489 cert_auth_info_t info; 489 cert_auth_info_t info;
490 490
491 info = _gnutls_get_auth_info (session); 491 info = mhd_gtls_get_auth_info (session);
492 if (info == NULL) 492 if (info == NULL)
493 return GNUTLS_E_INTERNAL_ERROR; 493 return GNUTLS_E_INTERNAL_ERROR;
494 494
@@ -507,24 +507,24 @@ _gnutls_dh_set_secret_bits (gnutls_session_t session, unsigned bits)
507 * RSA exponent and the modulus. 507 * RSA exponent and the modulus.
508 */ 508 */
509int 509int
510_gnutls_rsa_export_set_pubkey (gnutls_session_t session, 510mhd_gtls_rsa_export_set_pubkey (mhd_gtls_session_t session,
511 mpi_t exponent, mpi_t modulus) 511 mpi_t exponent, mpi_t modulus)
512{ 512{
513 cert_auth_info_t info; 513 cert_auth_info_t info;
514 int ret; 514 int ret;
515 515
516 info = _gnutls_get_auth_info (session); 516 info = mhd_gtls_get_auth_info (session);
517 if (info == NULL) 517 if (info == NULL)
518 return GNUTLS_E_INTERNAL_ERROR; 518 return GNUTLS_E_INTERNAL_ERROR;
519 519
520 ret = _gnutls_mpi_dprint_lz (&info->rsa_export.modulus, modulus); 520 ret = mhd_gtls_mpi_dprint_lz (&info->rsa_export.modulus, modulus);
521 if (ret < 0) 521 if (ret < 0)
522 { 522 {
523 gnutls_assert (); 523 gnutls_assert ();
524 return ret; 524 return ret;
525 } 525 }
526 526
527 ret = _gnutls_mpi_dprint_lz (&info->rsa_export.exponent, exponent); 527 ret = mhd_gtls_mpi_dprint_lz (&info->rsa_export.exponent, exponent);
528 if (ret < 0) 528 if (ret < 0)
529 { 529 {
530 gnutls_assert (); 530 gnutls_assert ();
@@ -538,17 +538,17 @@ _gnutls_rsa_export_set_pubkey (gnutls_session_t session,
538/* Sets the prime and the generator in the auth info structure. 538/* Sets the prime and the generator in the auth info structure.
539 */ 539 */
540int 540int
541_gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime) 541mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime)
542{ 542{
543 dh_info_st *dh; 543 dh_info_st *dh;
544 int ret; 544 int ret;
545 545
546 switch (gnutls_auth_get_type (session)) 546 switch (MHD_gtls_auth_get_type (session))
547 { 547 {
548 case MHD_GNUTLS_CRD_ANON: 548 case MHD_GNUTLS_CRD_ANON:
549 { 549 {
550 anon_auth_info_t info; 550 mhd_anon_auth_info_t info;
551 info = _gnutls_get_auth_info (session); 551 info = mhd_gtls_get_auth_info (session);
552 if (info == NULL) 552 if (info == NULL)
553 return GNUTLS_E_INTERNAL_ERROR; 553 return GNUTLS_E_INTERNAL_ERROR;
554 554
@@ -559,7 +559,7 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
559 { 559 {
560 cert_auth_info_t info; 560 cert_auth_info_t info;
561 561
562 info = _gnutls_get_auth_info (session); 562 info = mhd_gtls_get_auth_info (session);
563 if (info == NULL) 563 if (info == NULL)
564 return GNUTLS_E_INTERNAL_ERROR; 564 return GNUTLS_E_INTERNAL_ERROR;
565 565
@@ -573,7 +573,7 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
573 573
574 /* prime 574 /* prime
575 */ 575 */
576 ret = _gnutls_mpi_dprint_lz (&dh->prime, prime); 576 ret = mhd_gtls_mpi_dprint_lz (&dh->prime, prime);
577 if (ret < 0) 577 if (ret < 0)
578 { 578 {
579 gnutls_assert (); 579 gnutls_assert ();
@@ -582,7 +582,7 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
582 582
583 /* generator 583 /* generator
584 */ 584 */
585 ret = _gnutls_mpi_dprint_lz (&dh->generator, gen); 585 ret = mhd_gtls_mpi_dprint_lz (&dh->generator, gen);
586 if (ret < 0) 586 if (ret < 0)
587 { 587 {
588 gnutls_assert (); 588 gnutls_assert ();
@@ -594,8 +594,8 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
594} 594}
595 595
596/** 596/**
597 * gnutls_openpgp_send_cert - This function will order gnutls to send the openpgp fingerprint instead of the key 597 * MHD_gtls_openpgp_send_cert - This function will order gnutls to send the openpgp fingerprint instead of the key
598 * @session: is a pointer to a #gnutls_session_t structure. 598 * @session: is a pointer to a #mhd_gtls_session_t structure.
599 * @status: is one of GNUTLS_OPENPGP_CERT, or GNUTLS_OPENPGP_CERT_FINGERPRINT 599 * @status: is one of GNUTLS_OPENPGP_CERT, or GNUTLS_OPENPGP_CERT_FINGERPRINT
600 * 600 *
601 * This function will order gnutls to send the key fingerprint 601 * This function will order gnutls to send the key fingerprint
@@ -604,15 +604,15 @@ _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime)
604 * that the server can obtain the client's key. 604 * that the server can obtain the client's key.
605 **/ 605 **/
606void 606void
607gnutls_openpgp_send_cert (gnutls_session_t session, 607MHD_gtls_openpgp_send_cert (mhd_gtls_session_t session,
608 gnutls_openpgp_crt_status_t status) 608 gnutls_openpgp_crt_status_t status)
609{ 609{
610 session->internals.pgp_fingerprint = status; 610 session->internals.pgp_fingerprint = status;
611} 611}
612 612
613/** 613/**
614 * gnutls_certificate_send_x509_rdn_sequence - This function will order gnutls to send or not the x.509 rdn sequence 614 * MHD_gnutls_certificate_send_x509_rdn_sequence - This function will order gnutls to send or not the x.509 rdn sequence
615 * @session: is a pointer to a #gnutls_session_t structure. 615 * @session: is a pointer to a #mhd_gtls_session_t structure.
616 * @status: is 0 or 1 616 * @status: is 0 or 1
617 * 617 *
618 * If status is non zero, this function will order gnutls not to send 618 * If status is non zero, this function will order gnutls not to send
@@ -625,21 +625,21 @@ gnutls_openpgp_send_cert (gnutls_session_t session,
625 * methods other than certificate with X.509 certificates. 625 * methods other than certificate with X.509 certificates.
626 **/ 626 **/
627void 627void
628gnutls_certificate_send_x509_rdn_sequence (gnutls_session_t session, 628MHD_gnutls_certificate_send_x509_rdn_sequence (mhd_gtls_session_t session,
629 int status) 629 int status)
630{ 630{
631 session->internals.ignore_rdn_sequence = status; 631 session->internals.ignore_rdn_sequence = status;
632} 632}
633 633
634int 634int
635_gnutls_openpgp_send_fingerprint (gnutls_session_t session) 635mhd_gtls_openpgp_send_fingerprint (mhd_gtls_session_t session)
636{ 636{
637 return session->internals.pgp_fingerprint; 637 return session->internals.pgp_fingerprint;
638} 638}
639 639
640/*- 640/*-
641 * _gnutls_record_set_default_version - Used to set the default version for the first record packet 641 * _gnutls_record_set_default_version - Used to set the default version for the first record packet
642 * @session: is a #gnutls_session_t structure. 642 * @session: is a #mhd_gtls_session_t structure.
643 * @major: is a tls major version 643 * @major: is a tls major version
644 * @minor: is a tls minor version 644 * @minor: is a tls minor version
645 * 645 *
@@ -649,7 +649,7 @@ _gnutls_openpgp_send_fingerprint (gnutls_session_t session)
649 * 649 *
650 -*/ 650 -*/
651void 651void
652_gnutls_record_set_default_version (gnutls_session_t session, 652_gnutls_record_set_default_version (mhd_gtls_session_t session,
653 unsigned char major, unsigned char minor) 653 unsigned char major, unsigned char minor)
654{ 654{
655 session->internals.default_record_version[0] = major; 655 session->internals.default_record_version[0] = major;
@@ -657,8 +657,8 @@ _gnutls_record_set_default_version (gnutls_session_t session,
657} 657}
658 658
659/** 659/**
660 * gnutls_handshake_set_private_extensions - Used to enable the private cipher suites 660 * MHD_gtls_handshake_set_private_extensions - Used to enable the private cipher suites
661 * @session: is a #gnutls_session_t structure. 661 * @session: is a #mhd_gtls_session_t structure.
662 * @allow: is an integer (0 or 1) 662 * @allow: is an integer (0 or 1)
663 * 663 *
664 * This function will enable or disable the use of private cipher 664 * This function will enable or disable the use of private cipher
@@ -673,7 +673,7 @@ _gnutls_record_set_default_version (gnutls_session_t session,
673 * gnutls servers and clients may cause interoperability problems. 673 * gnutls servers and clients may cause interoperability problems.
674 **/ 674 **/
675void 675void
676gnutls_handshake_set_private_extensions (gnutls_session_t session, int allow) 676MHD_gtls_handshake_set_private_extensions (mhd_gtls_session_t session, int allow)
677{ 677{
678 session->internals.enable_private = allow; 678 session->internals.enable_private = allow;
679} 679}
@@ -686,15 +686,15 @@ _gnutls_cal_PRF_A (gnutls_mac_algorithm_t algorithm,
686{ 686{
687 mac_hd_t td1; 687 mac_hd_t td1;
688 688
689 td1 = _gnutls_hmac_init (algorithm, secret, secret_size); 689 td1 = mhd_gtls_hmac_init (algorithm, secret, secret_size);
690 if (td1 == GNUTLS_MAC_FAILED) 690 if (td1 == GNUTLS_MAC_FAILED)
691 { 691 {
692 gnutls_assert (); 692 gnutls_assert ();
693 return GNUTLS_E_INTERNAL_ERROR; 693 return GNUTLS_E_INTERNAL_ERROR;
694 } 694 }
695 695
696 _gnutls_hmac (td1, seed, seed_size); 696 mhd_gnutls_hash (td1, seed, seed_size);
697 _gnutls_hmac_deinit (td1, result); 697 mhd_gnutls_hmac_deinit (td1, result);
698 698
699 return 0; 699 return 0;
700} 700}
@@ -723,7 +723,7 @@ _gnutls_P_hash (gnutls_mac_algorithm_t algorithm,
723 return GNUTLS_E_INTERNAL_ERROR; 723 return GNUTLS_E_INTERNAL_ERROR;
724 } 724 }
725 725
726 blocksize = _gnutls_hmac_get_algo_len (algorithm); 726 blocksize = mhd_gnutls_hash_get_algo_len (algorithm);
727 727
728 output_bytes = 0; 728 output_bytes = 0;
729 do 729 do
@@ -741,7 +741,7 @@ _gnutls_P_hash (gnutls_mac_algorithm_t algorithm,
741 741
742 for (i = 0; i < times; i++) 742 for (i = 0; i < times; i++)
743 { 743 {
744 td2 = _gnutls_hmac_init (algorithm, secret, secret_size); 744 td2 = mhd_gtls_hmac_init (algorithm, secret, secret_size);
745 if (td2 == GNUTLS_MAC_FAILED) 745 if (td2 == GNUTLS_MAC_FAILED)
746 { 746 {
747 gnutls_assert (); 747 gnutls_assert ();
@@ -753,15 +753,15 @@ _gnutls_P_hash (gnutls_mac_algorithm_t algorithm,
753 A_size, Atmp)) < 0) 753 A_size, Atmp)) < 0)
754 { 754 {
755 gnutls_assert (); 755 gnutls_assert ();
756 _gnutls_hmac_deinit (td2, final); 756 mhd_gnutls_hmac_deinit (td2, final);
757 return result; 757 return result;
758 } 758 }
759 759
760 A_size = blocksize; 760 A_size = blocksize;
761 761
762 _gnutls_hmac (td2, Atmp, A_size); 762 mhd_gnutls_hash (td2, Atmp, A_size);
763 _gnutls_hmac (td2, seed, seed_size); 763 mhd_gnutls_hash (td2, seed, seed_size);
764 _gnutls_hmac_deinit (td2, final); 764 mhd_gnutls_hmac_deinit (td2, final);
765 765
766 if ((1 + i) * blocksize < total_bytes) 766 if ((1 + i) * blocksize < total_bytes)
767 { 767 {
@@ -800,7 +800,7 @@ _gnutls_xor (opaque * o1, opaque * o2, int length)
800 * available. 800 * available.
801 */ 801 */
802int 802int
803_gnutls_PRF (gnutls_session_t session, 803mhd_gtls_PRF (mhd_gtls_session_t session,
804 const opaque * secret, 804 const opaque * secret,
805 int secret_size, 805 int secret_size,
806 const char *label, 806 const char *label,
@@ -812,7 +812,7 @@ _gnutls_PRF (gnutls_session_t session,
812 opaque s_seed[MAX_SEED_SIZE]; 812 opaque s_seed[MAX_SEED_SIZE];
813 opaque o1[MAX_PRF_BYTES], o2[MAX_PRF_BYTES]; 813 opaque o1[MAX_PRF_BYTES], o2[MAX_PRF_BYTES];
814 int result; 814 int result;
815 gnutls_protocol_t ver = gnutls_protocol_get_version (session); 815 gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session);
816 816
817 if (total_bytes > MAX_PRF_BYTES) 817 if (total_bytes > MAX_PRF_BYTES)
818 { 818 {
@@ -882,8 +882,8 @@ _gnutls_PRF (gnutls_session_t session,
882} 882}
883 883
884/** 884/**
885 * gnutls_prf_raw - access the TLS PRF directly 885 * MHD_gnutls_prf_raw - access the TLS PRF directly
886 * @session: is a #gnutls_session_t structure. 886 * @session: is a #mhd_gtls_session_t structure.
887 * @label_size: length of the @label variable. 887 * @label_size: length of the @label variable.
888 * @label: label used in PRF computation, typically a short string. 888 * @label: label used in PRF computation, typically a short string.
889 * @seed_size: length of the @seed variable. 889 * @seed_size: length of the @seed variable.
@@ -904,21 +904,21 @@ _gnutls_PRF (gnutls_session_t session,
904 * session unless @seed include the client random and server random 904 * session unless @seed include the client random and server random
905 * fields (the PRF would output the same data on another connection 905 * fields (the PRF would output the same data on another connection
906 * resumed from the first one), it is not recommended to use this 906 * resumed from the first one), it is not recommended to use this
907 * function directly. The gnutls_prf() function seed the PRF with the 907 * function directly. The MHD_gnutls_prf() function seed the PRF with the
908 * client and server random fields directly, and is recommended if you 908 * client and server random fields directly, and is recommended if you
909 * want to generate pseudo random data unique for each session. 909 * want to generate pseudo random data unique for each session.
910 * 910 *
911 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 911 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
912 **/ 912 **/
913int 913int
914gnutls_prf_raw (gnutls_session_t session, 914MHD_gnutls_prf_raw (mhd_gtls_session_t session,
915 size_t label_size, 915 size_t label_size,
916 const char *label, 916 const char *label,
917 size_t seed_size, const char *seed, size_t outsize, char *out) 917 size_t seed_size, const char *seed, size_t outsize, char *out)
918{ 918{
919 int ret; 919 int ret;
920 920
921 ret = _gnutls_PRF (session, session->security_parameters.master_secret, 921 ret = mhd_gtls_PRF (session, session->security_parameters.master_secret,
922 TLS_MASTER_SIZE, label, label_size, (opaque *) seed, 922 TLS_MASTER_SIZE, label, label_size, (opaque *) seed,
923 seed_size, outsize, out); 923 seed_size, outsize, out);
924 924
@@ -926,8 +926,8 @@ gnutls_prf_raw (gnutls_session_t session,
926} 926}
927 927
928/** 928/**
929 * gnutls_prf - derive pseudo-random data using the TLS PRF 929 * MHD_gnutls_prf - derive pseudo-random data using the TLS PRF
930 * @session: is a #gnutls_session_t structure. 930 * @session: is a #mhd_gtls_session_t structure.
931 * @label_size: length of the @label variable. 931 * @label_size: length of the @label variable.
932 * @label: label used in PRF computation, typically a short string. 932 * @label: label used in PRF computation, typically a short string.
933 * @server_random_first: non-0 if server random field should be first in seed 933 * @server_random_first: non-0 if server random field should be first in seed
@@ -955,7 +955,7 @@ gnutls_prf_raw (gnutls_session_t session,
955 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 955 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
956 **/ 956 **/
957int 957int
958gnutls_prf (gnutls_session_t session, 958MHD_gnutls_prf (mhd_gtls_session_t session,
959 size_t label_size, 959 size_t label_size,
960 const char *label, 960 const char *label,
961 int server_random_first, 961 int server_random_first,
@@ -981,7 +981,7 @@ gnutls_prf (gnutls_session_t session,
981 981
982 memcpy (seed + 2 * TLS_RANDOM_SIZE, extra, extra_size); 982 memcpy (seed + 2 * TLS_RANDOM_SIZE, extra, extra_size);
983 983
984 ret = _gnutls_PRF (session, session->security_parameters.master_secret, 984 ret = mhd_gtls_PRF (session, session->security_parameters.master_secret,
985 TLS_MASTER_SIZE, label, label_size, seed, seedsize, 985 TLS_MASTER_SIZE, label, label_size, seed, seedsize,
986 outsize, out); 986 outsize, out);
987 987
@@ -991,8 +991,8 @@ gnutls_prf (gnutls_session_t session,
991} 991}
992 992
993/** 993/**
994 * gnutls_session_get_client_random - get the session's client random value 994 * MHD_gtls_session_get_client_random - get the session's client random value
995 * @session: is a #gnutls_session_t structure. 995 * @session: is a #mhd_gtls_session_t structure.
996 * 996 *
997 * Return a pointer to the 32-byte client random field used in the 997 * Return a pointer to the 32-byte client random field used in the
998 * session. The pointer must not be modified or deallocated. 998 * session. The pointer must not be modified or deallocated.
@@ -1004,14 +1004,14 @@ gnutls_prf (gnutls_session_t session,
1004 * Returns: pointer to client random data. 1004 * Returns: pointer to client random data.
1005 **/ 1005 **/
1006const void * 1006const void *
1007gnutls_session_get_client_random (gnutls_session_t session) 1007MHD_gtls_session_get_client_random (mhd_gtls_session_t session)
1008{ 1008{
1009 return (char *) session->security_parameters.client_random; 1009 return (char *) session->security_parameters.client_random;
1010} 1010}
1011 1011
1012/** 1012/**
1013 * gnutls_session_get_server_random - get the session's server random value 1013 * MHD_gtls_session_get_server_random - get the session's server random value
1014 * @session: is a #gnutls_session_t structure. 1014 * @session: is a #mhd_gtls_session_t structure.
1015 * 1015 *
1016 * Return a pointer to the 32-byte server random field used in the 1016 * Return a pointer to the 32-byte server random field used in the
1017 * session. The pointer must not be modified or deallocated. 1017 * session. The pointer must not be modified or deallocated.
@@ -1023,14 +1023,14 @@ gnutls_session_get_client_random (gnutls_session_t session)
1023 * Returns: pointer to server random data. 1023 * Returns: pointer to server random data.
1024 **/ 1024 **/
1025const void * 1025const void *
1026gnutls_session_get_server_random (gnutls_session_t session) 1026MHD_gtls_session_get_server_random (mhd_gtls_session_t session)
1027{ 1027{
1028 return (char *) session->security_parameters.server_random; 1028 return (char *) session->security_parameters.server_random;
1029} 1029}
1030 1030
1031/** 1031/**
1032 * gnutls_session_get_master_secret - get the session's master secret value 1032 * MHD_gtls_session_get_master_secret - get the session's master secret value
1033 * @session: is a #gnutls_session_t structure. 1033 * @session: is a #mhd_gtls_session_t structure.
1034 * 1034 *
1035 * Return a pointer to the 48-byte master secret in the session. The 1035 * Return a pointer to the 48-byte master secret in the session. The
1036 * pointer must not be modified or deallocated. 1036 * pointer must not be modified or deallocated.
@@ -1039,26 +1039,26 @@ gnutls_session_get_server_random (gnutls_session_t session)
1039 * will be garbage; in particular, a %NULL return value should not be 1039 * will be garbage; in particular, a %NULL return value should not be
1040 * expected. 1040 * expected.
1041 * 1041 *
1042 * Consider using gnutls_prf() rather than extracting the master 1042 * Consider using MHD_gnutls_prf() rather than extracting the master
1043 * secret and use it to derive further data. 1043 * secret and use it to derive further data.
1044 * 1044 *
1045 * Returns: pointer to master secret data. 1045 * Returns: pointer to master secret data.
1046 **/ 1046 **/
1047const void * 1047const void *
1048gnutls_session_get_master_secret (gnutls_session_t session) 1048MHD_gtls_session_get_master_secret (mhd_gtls_session_t session)
1049{ 1049{
1050 return (char *) session->security_parameters.master_secret; 1050 return (char *) session->security_parameters.master_secret;
1051} 1051}
1052 1052
1053/** 1053/**
1054 * gnutls_session_is_resumed - Used to check whether this session is a resumed one 1054 * MHD_gtls_session_is_resumed - Used to check whether this session is a resumed one
1055 * @session: is a #gnutls_session_t structure. 1055 * @session: is a #mhd_gtls_session_t structure.
1056 * 1056 *
1057 * Returns: non zero if this session is resumed, or a zero if this is 1057 * Returns: non zero if this session is resumed, or a zero if this is
1058 * a new session. 1058 * a new session.
1059 **/ 1059 **/
1060int 1060int
1061gnutls_session_is_resumed (gnutls_session_t session) 1061MHD_gtls_session_is_resumed (mhd_gtls_session_t session)
1062{ 1062{
1063 if (session->security_parameters.entity == GNUTLS_CLIENT) 1063 if (session->security_parameters.entity == GNUTLS_CLIENT)
1064 { 1064 {
@@ -1081,81 +1081,81 @@ gnutls_session_is_resumed (gnutls_session_t session)
1081} 1081}
1082 1082
1083/*- 1083/*-
1084 * _gnutls_session_is_export - Used to check whether this session is of export grade 1084 * mhd_gtls_session_is_export - Used to check whether this session is of export grade
1085 * @session: is a #gnutls_session_t structure. 1085 * @session: is a #mhd_gtls_session_t structure.
1086 * 1086 *
1087 * This function will return non zero if this session is of export grade. 1087 * This function will return non zero if this session is of export grade.
1088 * 1088 *
1089 -*/ 1089 -*/
1090int 1090int
1091_gnutls_session_is_export (gnutls_session_t session) 1091mhd_gtls_session_is_export (mhd_gtls_session_t session)
1092{ 1092{
1093 gnutls_cipher_algorithm_t cipher; 1093 gnutls_cipher_algorithm_t cipher;
1094 1094
1095 cipher = 1095 cipher =
1096 _gnutls_cipher_suite_get_cipher_algo (&session->security_parameters. 1096 mhd_gtls_cipher_suite_get_cipher_algo (&session->security_parameters.
1097 current_cipher_suite); 1097 current_cipher_suite);
1098 1098
1099 if (_gnutls_cipher_get_export_flag (cipher) != 0) 1099 if (mhd_gtls_cipher_get_export_flag (cipher) != 0)
1100 return 1; 1100 return 1;
1101 1101
1102 return 0; 1102 return 0;
1103} 1103}
1104 1104
1105/** 1105/**
1106 * gnutls_session_get_ptr - Used to get the user pointer from the session structure 1106 * MHD_gtls_session_get_ptr - Used to get the user pointer from the session structure
1107 * @session: is a #gnutls_session_t structure. 1107 * @session: is a #mhd_gtls_session_t structure.
1108 * 1108 *
1109 * Returns: the user given pointer from the session structure. This 1109 * Returns: the user given pointer from the session structure. This
1110 * is the pointer set with gnutls_session_set_ptr(). 1110 * is the pointer set with MHD_gnutls_session_set_ptr().
1111 **/ 1111 **/
1112void * 1112void *
1113gnutls_session_get_ptr (gnutls_session_t session) 1113MHD_gtls_session_get_ptr (mhd_gtls_session_t session)
1114{ 1114{
1115 return session->internals.user_ptr; 1115 return session->internals.user_ptr;
1116} 1116}
1117 1117
1118/** 1118/**
1119 * gnutls_session_set_ptr - Used to set the user pointer to the session structure 1119 * MHD_gnutls_session_set_ptr - Used to set the user pointer to the session structure
1120 * @session: is a #gnutls_session_t structure. 1120 * @session: is a #mhd_gtls_session_t structure.
1121 * @ptr: is the user pointer 1121 * @ptr: is the user pointer
1122 * 1122 *
1123 * This function will set (associate) the user given pointer to the 1123 * This function will set (associate) the user given pointer to the
1124 * session structure. This is pointer can be accessed with 1124 * session structure. This is pointer can be accessed with
1125 * gnutls_session_get_ptr(). 1125 * MHD_gtls_session_get_ptr().
1126 **/ 1126 **/
1127void 1127void
1128gnutls_session_set_ptr (gnutls_session_t session, void *ptr) 1128MHD_gnutls_session_set_ptr (mhd_gtls_session_t session, void *ptr)
1129{ 1129{
1130 session->internals.user_ptr = ptr; 1130 session->internals.user_ptr = ptr;
1131} 1131}
1132 1132
1133/** 1133/**
1134 * gnutls_record_get_direction - This function will return the direction of the last interrupted function call 1134 * MHD_gnutls_record_get_direction - This function will return the direction of the last interrupted function call
1135 * @session: is a #gnutls_session_t structure. 1135 * @session: is a #mhd_gtls_session_t structure.
1136 * 1136 *
1137 * This function provides information about the internals of the 1137 * This function provides information about the internals of the
1138 * record protocol and is only useful if a prior gnutls function call 1138 * record protocol and is only useful if a prior gnutls function call
1139 * (e.g. gnutls_handshake()) was interrupted for some reason, that 1139 * (e.g. MHD_gnutls_handshake()) was interrupted for some reason, that
1140 * is, if a function returned %GNUTLS_E_INTERRUPTED or 1140 * is, if a function returned %GNUTLS_E_INTERRUPTED or
1141 * %GNUTLS_E_AGAIN. In such a case, you might want to call select() 1141 * %GNUTLS_E_AGAIN. In such a case, you might want to call select()
1142 * or poll() before calling the interrupted gnutls function again. 1142 * or poll() before calling the interrupted gnutls function again.
1143 * To tell you whether a file descriptor should be selected for 1143 * To tell you whether a file descriptor should be selected for
1144 * either reading or writing, gnutls_record_get_direction() returns 0 1144 * either reading or writing, MHD_gnutls_record_get_direction() returns 0
1145 * if the interrupted function was trying to read data, and 1 if it 1145 * if the interrupted function was trying to read data, and 1 if it
1146 * was trying to write data. 1146 * was trying to write data.
1147 * 1147 *
1148 * Returns: 0 if trying to read data, 1 if trying to write data. 1148 * Returns: 0 if trying to read data, 1 if trying to write data.
1149 **/ 1149 **/
1150int 1150int
1151gnutls_record_get_direction (gnutls_session_t session) 1151MHD_gnutls_record_get_direction (mhd_gtls_session_t session)
1152{ 1152{
1153 return session->internals.direction; 1153 return session->internals.direction;
1154} 1154}
1155 1155
1156/*- 1156/*-
1157 * _gnutls_rsa_pms_set_version - Sets a version to be used at the RSA PMS 1157 * _gnutls_rsa_pms_set_version - Sets a version to be used at the RSA PMS
1158 * @session: is a #gnutls_session_t structure. 1158 * @session: is a #mhd_gtls_session_t structure.
1159 * @major: is the major version to use 1159 * @major: is the major version to use
1160 * @minor: is the minor version to use 1160 * @minor: is the minor version to use
1161 * 1161 *
@@ -1165,7 +1165,7 @@ gnutls_record_get_direction (gnutls_session_t session)
1165 * 1165 *
1166 -*/ 1166 -*/
1167void 1167void
1168_gnutls_rsa_pms_set_version (gnutls_session_t session, 1168_gnutls_rsa_pms_set_version (mhd_gtls_session_t session,
1169 unsigned char major, unsigned char minor) 1169 unsigned char major, unsigned char minor)
1170{ 1170{
1171 session->internals.rsa_pms_version[0] = major; 1171 session->internals.rsa_pms_version[0] = major;
@@ -1173,8 +1173,8 @@ _gnutls_rsa_pms_set_version (gnutls_session_t session,
1173} 1173}
1174 1174
1175/** 1175/**
1176 * gnutls_handshake_set_post_client_hello_function - This function will a callback to be called after the client hello is received 1176 * MHD_gnutls_handshake_set_post_client_hello_function - This function will a callback to be called after the client hello is received
1177 * @res: is a gnutls_anon_server_credentials_t structure 1177 * @res: is a mhd_gtls_anon_server_credentials_t structure
1178 * @func: is the function to be called 1178 * @func: is the function to be called
1179 * 1179 *
1180 * This function will set a callback to be called after the client 1180 * This function will set a callback to be called after the client
@@ -1195,27 +1195,9 @@ _gnutls_rsa_pms_set_version (gnutls_session_t session,
1195 * 1195 *
1196 **/ 1196 **/
1197void 1197void
1198gnutls_handshake_set_post_client_hello_function (gnutls_session_t session, 1198MHD_gnutls_handshake_set_post_client_hello_function (mhd_gtls_session_t session,
1199 gnutls_handshake_post_client_hello_func 1199 gnutls_handshake_post_client_hello_func
1200 func) 1200 func)
1201{ 1201{
1202 session->internals.user_hello_func = func; 1202 session->internals.user_hello_func = func;
1203} 1203}
1204
1205/**
1206 * gnutls_session_enable_compatibility_mode - Used to disable certain features in TLS in order to honour compatibility
1207 * @session: is a #gnutls_session_t structure.
1208 *
1209 * This function can be used to disable certain (security) features
1210 * in TLS in order to maintain maximum compatibility with buggy
1211 * clients. It is equivalent to calling:
1212 * gnutls_record_disable_padding()
1213 *
1214 * Normally only servers that require maximum compatibility with
1215 * everything out there, need to call this function.
1216 **/
1217void
1218gnutls_session_enable_compatibility_mode (gnutls_session_t session)
1219{
1220 gnutls_record_disable_padding (session);
1221}
diff --git a/src/daemon/https/tls/gnutls_state.h b/src/daemon/https/tls/gnutls_state.h
index 246432e6..2616b71d 100644
--- a/src/daemon/https/tls/gnutls_state.h
+++ b/src/daemon/https/tls/gnutls_state.h
@@ -27,46 +27,46 @@
27 27
28#include <gnutls_int.h> 28#include <gnutls_int.h>
29 29
30void _gnutls_session_cert_type_set (gnutls_session_t session, 30void _gnutls_session_cert_type_set (mhd_gtls_session_t session,
31 gnutls_certificate_type_t); 31 gnutls_certificate_type_t);
32gnutls_kx_algorithm_t gnutls_kx_get (gnutls_session_t session); 32gnutls_kx_algorithm_t gnutls_kx_get (mhd_gtls_session_t session);
33gnutls_cipher_algorithm_t gnutls_cipher_get (gnutls_session_t session); 33gnutls_cipher_algorithm_t gnutls_cipher_get (mhd_gtls_session_t session);
34gnutls_certificate_type_t gnutls_certificate_type_get (gnutls_session_t); 34gnutls_certificate_type_t gnutls_certificate_type_get (mhd_gtls_session_t);
35 35
36#include <gnutls_auth_int.h> 36#include <gnutls_auth_int.h>
37 37
38#define CHECK_AUTH(auth, ret) if (gnutls_auth_get_type(session) != auth) { \ 38#define CHECK_AUTH(auth, ret) if (MHD_gtls_auth_get_type(session) != auth) { \
39 gnutls_assert(); \ 39 gnutls_assert(); \
40 return ret; \ 40 return ret; \
41 } 41 }
42 42
43#endif 43#endif
44 44
45int _gnutls_session_cert_type_supported (gnutls_session_t, 45int mhd_gtls_session_cert_type_supported (mhd_gtls_session_t,
46 gnutls_certificate_type_t); 46 gnutls_certificate_type_t);
47 47
48int _gnutls_dh_set_secret_bits (gnutls_session_t session, unsigned bits); 48int mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits);
49 49
50int _gnutls_dh_set_peer_public (gnutls_session_t session, mpi_t public); 50int mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public);
51int _gnutls_dh_set_group (gnutls_session_t session, mpi_t gen, mpi_t prime); 51int mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime);
52 52
53int _gnutls_dh_get_allowed_prime_bits (gnutls_session_t session); 53int mhd_gtls_dh_get_allowed_prime_bits (mhd_gtls_session_t session);
54void _gnutls_handshake_internal_state_clear (gnutls_session_t); 54void mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t);
55 55
56int _gnutls_rsa_export_set_pubkey (gnutls_session_t session, 56int mhd_gtls_rsa_export_set_pubkey (mhd_gtls_session_t session,
57 mpi_t exponent, mpi_t modulus); 57 mpi_t exponent, mpi_t modulus);
58 58
59int _gnutls_session_is_resumable (gnutls_session_t session); 59int mhd_gtls_session_is_resumable (mhd_gtls_session_t session);
60int _gnutls_session_is_export (gnutls_session_t session); 60int mhd_gtls_session_is_export (mhd_gtls_session_t session);
61 61
62int _gnutls_openpgp_send_fingerprint (gnutls_session_t session); 62int mhd_gtls_openpgp_send_fingerprint (mhd_gtls_session_t session);
63 63
64int _gnutls_PRF (gnutls_session_t session, 64int mhd_gtls_PRF (mhd_gtls_session_t session,
65 const opaque * secret, int secret_size, 65 const opaque * secret, int secret_size,
66 const char *label, int label_size, 66 const char *label, int label_size,
67 const opaque * seed, int seed_size, 67 const opaque * seed, int seed_size,
68 int total_bytes, void *ret); 68 int total_bytes, void *ret);
69 69
70int gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end); 70int MHD_gnutls_init (mhd_gtls_session_t * session, gnutls_connection_end_t con_end);
71 71
72#define DEFAULT_CERT_TYPE MHD_GNUTLS_CRT_X509 72#define DEFAULT_CERT_TYPE MHD_GNUTLS_CRT_X509
diff --git a/src/daemon/https/tls/gnutls_str.c b/src/daemon/https/tls/gnutls_str.c
index 34657c03..0a2a656a 100644
--- a/src/daemon/https/tls/gnutls_str.c
+++ b/src/daemon/https/tls/gnutls_str.c
@@ -34,7 +34,7 @@
34 * They should be used only with null terminated strings. 34 * They should be used only with null terminated strings.
35 */ 35 */
36void 36void
37_gnutls_str_cat (char *dest, size_t dest_tot_size, const char *src) 37mhd_gtls_str_cat (char *dest, size_t dest_tot_size, const char *src)
38{ 38{
39 size_t str_size = strlen (src); 39 size_t str_size = strlen (src);
40 size_t dest_size = strlen (dest); 40 size_t dest_size = strlen (dest);
@@ -54,7 +54,7 @@ _gnutls_str_cat (char *dest, size_t dest_tot_size, const char *src)
54} 54}
55 55
56void 56void
57_gnutls_str_cpy (char *dest, size_t dest_tot_size, const char *src) 57mhd_gtls_str_cpy (char *dest, size_t dest_tot_size, const char *src)
58{ 58{
59 size_t str_size = strlen (src); 59 size_t str_size = strlen (src);
60 60
@@ -73,7 +73,7 @@ _gnutls_str_cpy (char *dest, size_t dest_tot_size, const char *src)
73} 73}
74 74
75void 75void
76_gnutls_mem_cpy (char *dest, 76mhd_gtls_mem_cpy (char *dest,
77 size_t dest_tot_size, const char *src, size_t src_size) 77 size_t dest_tot_size, const char *src, size_t src_size)
78{ 78{
79 79
@@ -91,7 +91,7 @@ _gnutls_mem_cpy (char *dest,
91} 91}
92 92
93void 93void
94_gnutls_string_init (gnutls_string * str, 94mhd_gtls_string_init (mhd_gtls_string * str,
95 gnutls_alloc_function alloc_func, 95 gnutls_alloc_function alloc_func,
96 gnutls_realloc_function realloc_func, 96 gnutls_realloc_function realloc_func,
97 gnutls_free_function free_func) 97 gnutls_free_function free_func)
@@ -106,7 +106,7 @@ _gnutls_string_init (gnutls_string * str,
106} 106}
107 107
108void 108void
109_gnutls_string_clear (gnutls_string * str) 109mhd_gtls_string_clear (mhd_gtls_string * str)
110{ 110{
111 if (str == NULL || str->data == NULL) 111 if (str == NULL || str->data == NULL)
112 return; 112 return;
@@ -120,7 +120,7 @@ _gnutls_string_clear (gnutls_string * str)
120/* This one does not copy the string. 120/* This one does not copy the string.
121 */ 121 */
122gnutls_datum_t 122gnutls_datum_t
123_gnutls_string2datum (gnutls_string * str) 123mhd_gtls_string2datum (mhd_gtls_string * str)
124{ 124{
125 gnutls_datum_t ret; 125 gnutls_datum_t ret;
126 126
@@ -133,7 +133,7 @@ _gnutls_string2datum (gnutls_string * str)
133#define MIN_CHUNK 256 133#define MIN_CHUNK 256
134 134
135int 135int
136_gnutls_string_copy_str (gnutls_string * dest, const char *src) 136mhd_gtls_string_copy_str (mhd_gtls_string * dest, const char *src)
137{ 137{
138 size_t src_len = strlen (src); 138 size_t src_len = strlen (src);
139 size_t max; 139 size_t max;
@@ -163,7 +163,7 @@ _gnutls_string_copy_str (gnutls_string * dest, const char *src)
163} 163}
164 164
165int 165int
166_gnutls_string_append_str (gnutls_string * dest, const char *src) 166mhd_gtls_string_append_str (mhd_gtls_string * dest, const char *src)
167{ 167{
168 size_t src_len = strlen (src); 168 size_t src_len = strlen (src);
169 size_t tot_len = src_len + dest->length; 169 size_t tot_len = src_len + dest->length;
@@ -196,7 +196,7 @@ _gnutls_string_append_str (gnutls_string * dest, const char *src)
196} 196}
197 197
198int 198int
199_gnutls_string_append_data (gnutls_string * dest, 199mhd_gtls_string_append_data (mhd_gtls_string * dest,
200 const void *data, size_t data_size) 200 const void *data, size_t data_size)
201{ 201{
202 size_t tot_len = data_size + dest->length; 202 size_t tot_len = data_size + dest->length;
@@ -229,7 +229,7 @@ _gnutls_string_append_data (gnutls_string * dest,
229} 229}
230 230
231int 231int
232_gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...) 232mhd_gtls_string_append_printf (mhd_gtls_string * dest, const char *fmt, ...)
233{ 233{
234 va_list args; 234 va_list args;
235 int len; 235 int len;
@@ -242,7 +242,7 @@ _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
242 if (len < 0 || !str) 242 if (len < 0 || !str)
243 return -1; 243 return -1;
244 244
245 len = _gnutls_string_append_str (dest, str); 245 len = mhd_gtls_string_append_str (dest, str);
246 246
247 free (str); 247 free (str);
248 248
@@ -255,7 +255,7 @@ _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...)
255 * truncated hex string is returned (always null terminated). 255 * truncated hex string is returned (always null terminated).
256 */ 256 */
257char * 257char *
258_gnutls_bin2hex (const void *_old, 258mhd_gtls_bin2hex (const void *_old,
259 size_t oldlen, char *buffer, size_t buffer_size) 259 size_t oldlen, char *buffer, size_t buffer_size)
260{ 260{
261 unsigned int i, j; 261 unsigned int i, j;
@@ -274,7 +274,7 @@ _gnutls_bin2hex (const void *_old,
274/* just a hex2bin function. 274/* just a hex2bin function.
275 */ 275 */
276int 276int
277_gnutls_hex2bin (const opaque * hex_data, 277mhd_gtls_hex2bin (const opaque * hex_data,
278 int hex_size, opaque * bin_data, size_t * bin_size) 278 int hex_size, opaque * bin_data, size_t * bin_size)
279{ 279{
280 int i, j; 280 int i, j;
diff --git a/src/daemon/https/tls/gnutls_str.h b/src/daemon/https/tls/gnutls_str.h
index 62415557..84ff8eb5 100644
--- a/src/daemon/https/tls/gnutls_str.h
+++ b/src/daemon/https/tls/gnutls_str.h
@@ -27,10 +27,10 @@
27 27
28#include <gnutls_int.h> 28#include <gnutls_int.h>
29 29
30void _gnutls_str_cpy (char *dest, size_t dest_tot_size, const char *src); 30void mhd_gtls_str_cpy (char *dest, size_t dest_tot_size, const char *src);
31void _gnutls_mem_cpy (char *dest, size_t dest_tot_size, const char *src, 31void mhd_gtls_mem_cpy (char *dest, size_t dest_tot_size, const char *src,
32 size_t src_size); 32 size_t src_size);
33void _gnutls_str_cat (char *dest, size_t dest_tot_size, const char *src); 33void mhd_gtls_str_cat (char *dest, size_t dest_tot_size, const char *src);
34 34
35typedef struct 35typedef struct
36{ 36{
@@ -40,26 +40,26 @@ typedef struct
40 gnutls_realloc_function realloc_func; 40 gnutls_realloc_function realloc_func;
41 gnutls_alloc_function alloc_func; 41 gnutls_alloc_function alloc_func;
42 gnutls_free_function free_func; 42 gnutls_free_function free_func;
43} gnutls_string; 43} mhd_gtls_string;
44 44
45void _gnutls_string_init (gnutls_string *, gnutls_alloc_function, 45void mhd_gtls_string_init (mhd_gtls_string *, gnutls_alloc_function,
46 gnutls_realloc_function, gnutls_free_function); 46 gnutls_realloc_function, gnutls_free_function);
47void _gnutls_string_clear (gnutls_string *); 47void mhd_gtls_string_clear (mhd_gtls_string *);
48 48
49/* Beware, do not clear the string, after calling this 49/* Beware, do not clear the string, after calling this
50 * function 50 * function
51 */ 51 */
52gnutls_datum_t _gnutls_string2datum (gnutls_string * str); 52gnutls_datum_t mhd_gtls_string2datum (mhd_gtls_string * str);
53 53
54int _gnutls_string_copy_str (gnutls_string * dest, const char *src); 54int mhd_gtls_string_copy_str (mhd_gtls_string * dest, const char *src);
55int _gnutls_string_append_str (gnutls_string *, const char *str); 55int mhd_gtls_string_append_str (mhd_gtls_string *, const char *str);
56int _gnutls_string_append_data (gnutls_string *, const void *data, 56int mhd_gtls_string_append_data (mhd_gtls_string *, const void *data,
57 size_t data_size); 57 size_t data_size);
58int _gnutls_string_append_printf (gnutls_string * dest, const char *fmt, ...); 58int mhd_gtls_string_append_printf (mhd_gtls_string * dest, const char *fmt, ...);
59 59
60char *_gnutls_bin2hex (const void *old, size_t oldlen, char *buffer, 60char * mhd_gtls_bin2hex (const void *old, size_t oldlen, char *buffer,
61 size_t buffer_size); 61 size_t buffer_size);
62int _gnutls_hex2bin (const opaque * hex_data, int hex_size, opaque * bin_data, 62int mhd_gtls_hex2bin (const opaque * hex_data, int hex_size, opaque * bin_data,
63 size_t * bin_size); 63 size_t * bin_size);
64 64
65#endif 65#endif
diff --git a/src/daemon/https/tls/gnutls_supplemental.c b/src/daemon/https/tls/gnutls_supplemental.c
index a47b9aaa..1a5fcd6f 100644
--- a/src/daemon/https/tls/gnutls_supplemental.c
+++ b/src/daemon/https/tls/gnutls_supplemental.c
@@ -25,7 +25,7 @@
25/* This file contains support functions for 'TLS Handshake Message for 25/* This file contains support functions for 'TLS Handshake Message for
26 * Supplemental Data' (RFC 4680). 26 * Supplemental Data' (RFC 4680).
27 * 27 *
28 * The idea here is simple. gnutls_handshake() in gnuts_handshake.c 28 * The idea here is simple. MHD_gnutls_handshake() in gnuts_handshake.c
29 * will call _gnutls_gen_supplemental and _gnutls_parse_supplemental 29 * will call _gnutls_gen_supplemental and _gnutls_parse_supplemental
30 * when some extension requested that supplemental data be sent or 30 * when some extension requested that supplemental data be sent or
31 * received. Extension request this by setting the flags 31 * received. Extension request this by setting the flags
@@ -50,9 +50,9 @@
50#include "gnutls_errors.h" 50#include "gnutls_errors.h"
51#include "gnutls_num.h" 51#include "gnutls_num.h"
52 52
53typedef int (*supp_recv_func) (gnutls_session_t session, 53typedef int (*supp_recv_func) (mhd_gtls_session_t session,
54 const opaque * data, size_t data_size); 54 const opaque * data, size_t data_size);
55typedef int (*supp_send_func) (gnutls_session_t session, gnutls_buffer * buf); 55typedef int (*supp_send_func) (mhd_gtls_session_t session, mhd_gtls_buffer * buf);
56 56
57typedef struct 57typedef struct
58{ 58{
@@ -67,7 +67,7 @@ gnutls_supplemental_entry _gnutls_supplemental[] = {
67}; 67};
68 68
69const char * 69const char *
70gnutls_supplemental_get_name (gnutls_supplemental_data_format_type_t type) 70MHD_gtls_supplemental_get_name (gnutls_supplemental_data_format_type_t type)
71{ 71{
72 gnutls_supplemental_entry *p; 72 gnutls_supplemental_entry *p;
73 73
@@ -91,13 +91,13 @@ get_supp_func_recv (gnutls_supplemental_data_format_type_t type)
91} 91}
92 92
93int 93int
94_gnutls_gen_supplemental (gnutls_session_t session, gnutls_buffer * buf) 94_gnutls_gen_supplemental (mhd_gtls_session_t session, mhd_gtls_buffer * buf)
95{ 95{
96 gnutls_supplemental_entry *p; 96 gnutls_supplemental_entry *p;
97 int ret; 97 int ret;
98 98
99 /* Make room for 3 byte length field. */ 99 /* Make room for 3 byte length field. */
100 ret = _gnutls_buffer_append (buf, "\0\0\0", 3); 100 ret = mhd_gtls_buffer_append (buf, "\0\0\0", 3);
101 if (ret < 0) 101 if (ret < 0)
102 { 102 {
103 gnutls_assert (); 103 gnutls_assert ();
@@ -111,7 +111,7 @@ _gnutls_gen_supplemental (gnutls_session_t session, gnutls_buffer * buf)
111 int ret; 111 int ret;
112 112
113 /* Make room for supplement type and length byte length field. */ 113 /* Make room for supplement type and length byte length field. */
114 ret = _gnutls_buffer_append (buf, "\0\0\0\0", 4); 114 ret = mhd_gtls_buffer_append (buf, "\0\0\0\0", 4);
115 if (ret < 0) 115 if (ret < 0)
116 { 116 {
117 gnutls_assert (); 117 gnutls_assert ();
@@ -148,7 +148,7 @@ _gnutls_gen_supplemental (gnutls_session_t session, gnutls_buffer * buf)
148} 148}
149 149
150int 150int
151_gnutls_parse_supplemental (gnutls_session_t session, 151_gnutls_parse_supplemental (mhd_gtls_session_t session,
152 const uint8_t * data, int datalen) 152 const uint8_t * data, int datalen)
153{ 153{
154 const opaque *p = data; 154 const opaque *p = data;
@@ -156,7 +156,7 @@ _gnutls_parse_supplemental (gnutls_session_t session,
156 size_t total_size; 156 size_t total_size;
157 157
158 DECR_LEN (dsize, 3); 158 DECR_LEN (dsize, 3);
159 total_size = _gnutls_read_uint24 (p); 159 total_size = mhd_gtls_read_uint24 (p);
160 p += 3; 160 p += 3;
161 161
162 if (dsize != total_size) 162 if (dsize != total_size)
@@ -172,11 +172,11 @@ _gnutls_parse_supplemental (gnutls_session_t session,
172 supp_recv_func recv_func; 172 supp_recv_func recv_func;
173 173
174 DECR_LEN (dsize, 2); 174 DECR_LEN (dsize, 2);
175 supp_data_type = _gnutls_read_uint16 (p); 175 supp_data_type = mhd_gtls_read_uint16 (p);
176 p += 2; 176 p += 2;
177 177
178 DECR_LEN (dsize, 2); 178 DECR_LEN (dsize, 2);
179 supp_data_length = _gnutls_read_uint16 (p); 179 supp_data_length = mhd_gtls_read_uint16 (p);
180 p += 2; 180 p += 2;
181 181
182 _gnutls_debug_log ("EXT[%x]: Got supplemental type=%02x length=%d\n", 182 _gnutls_debug_log ("EXT[%x]: Got supplemental type=%02x length=%d\n",
diff --git a/src/daemon/https/tls/gnutls_supplemental.h b/src/daemon/https/tls/gnutls_supplemental.h
index 0b9c1207..3f8d9217 100644
--- a/src/daemon/https/tls/gnutls_supplemental.h
+++ b/src/daemon/https/tls/gnutls_supplemental.h
@@ -24,8 +24,8 @@
24 24
25#include <gnutls_int.h> 25#include <gnutls_int.h>
26 26
27int _gnutls_parse_supplemental (gnutls_session_t session, 27int _gnutls_parse_supplemental (mhd_gtls_session_t session,
28 const uint8_t *data, 28 const uint8_t *data,
29 int data_size); 29 int data_size);
30int _gnutls_gen_supplemental (gnutls_session_t session, 30int _gnutls_gen_supplemental (mhd_gtls_session_t session,
31 gnutls_buffer *buf); 31 mhd_gtls_buffer *buf);
diff --git a/src/daemon/https/tls/gnutls_ui.c b/src/daemon/https/tls/gnutls_ui.c
index e3511baa..b5b0fbee 100644
--- a/src/daemon/https/tls/gnutls_ui.c
+++ b/src/daemon/https/tls/gnutls_ui.c
@@ -37,8 +37,8 @@
37/* ANON & DHE */ 37/* ANON & DHE */
38 38
39/** 39/**
40 * gnutls_dh_set_prime_bits - Used to set the bits for a DH ciphersuite 40 * MHD_gnutls_dh_set_prime_bits - Used to set the bits for a DH ciphersuite
41 * @session: is a #gnutls_session_t structure. 41 * @session: is a #mhd_gtls_session_t structure.
42 * @bits: is the number of bits 42 * @bits: is the number of bits
43 * 43 *
44 * This function sets the number of bits, for use in an 44 * This function sets the number of bits, for use in an
@@ -53,13 +53,13 @@
53 * 53 *
54 **/ 54 **/
55void 55void
56gnutls_dh_set_prime_bits (gnutls_session_t session, unsigned int bits) 56MHD_gnutls_dh_set_prime_bits (mhd_gtls_session_t session, unsigned int bits)
57{ 57{
58 session->internals.dh_prime_bits = bits; 58 session->internals.dh_prime_bits = bits;
59} 59}
60 60
61/** 61/**
62 * gnutls_dh_get_group - This function returns the group of the DH authentication 62 * MHD_gnutls_dh_get_group - This function returns the group of the DH authentication
63 * @session: is a gnutls session 63 * @session: is a gnutls session
64 * @raw_gen: will hold the generator. 64 * @raw_gen: will hold the generator.
65 * @raw_prime: will hold the prime. 65 * @raw_prime: will hold the prime.
@@ -73,24 +73,24 @@ gnutls_dh_set_prime_bits (gnutls_session_t session, unsigned int bits)
73 * 73 *
74 **/ 74 **/
75int 75int
76gnutls_dh_get_group (gnutls_session_t session, 76MHD_gnutls_dh_get_group (mhd_gtls_session_t session,
77 gnutls_datum_t * raw_gen, gnutls_datum_t * raw_prime) 77 gnutls_datum_t * raw_gen, gnutls_datum_t * raw_prime)
78{ 78{
79 dh_info_st *dh; 79 dh_info_st *dh;
80 int ret; 80 int ret;
81 anon_auth_info_t anon_info; 81 mhd_anon_auth_info_t anon_info;
82 cert_auth_info_t cert_info; 82 cert_auth_info_t cert_info;
83 83
84 switch (gnutls_auth_get_type (session)) 84 switch (MHD_gtls_auth_get_type (session))
85 { 85 {
86 case MHD_GNUTLS_CRD_ANON: 86 case MHD_GNUTLS_CRD_ANON:
87 anon_info = _gnutls_get_auth_info (session); 87 anon_info = mhd_gtls_get_auth_info (session);
88 if (anon_info == NULL) 88 if (anon_info == NULL)
89 return GNUTLS_E_INTERNAL_ERROR; 89 return GNUTLS_E_INTERNAL_ERROR;
90 dh = &anon_info->dh; 90 dh = &anon_info->dh;
91 break; 91 break;
92 case MHD_GNUTLS_CRD_CERTIFICATE: 92 case MHD_GNUTLS_CRD_CERTIFICATE:
93 cert_info = _gnutls_get_auth_info (session); 93 cert_info = mhd_gtls_get_auth_info (session);
94 if (cert_info == NULL) 94 if (cert_info == NULL)
95 return GNUTLS_E_INTERNAL_ERROR; 95 return GNUTLS_E_INTERNAL_ERROR;
96 dh = &cert_info->dh; 96 dh = &cert_info->dh;
@@ -119,7 +119,7 @@ gnutls_dh_get_group (gnutls_session_t session,
119} 119}
120 120
121/** 121/**
122 * gnutls_dh_get_pubkey - This function returns the peer's public key used in DH authentication 122 * MHD_gnutls_dh_get_pubkey - This function returns the peer's public key used in DH authentication
123 * @session: is a gnutls session 123 * @session: is a gnutls session
124 * @raw_key: will hold the public key. 124 * @raw_key: will hold the public key.
125 * 125 *
@@ -131,18 +131,18 @@ gnutls_dh_get_group (gnutls_session_t session,
131 * 131 *
132 **/ 132 **/
133int 133int
134gnutls_dh_get_pubkey (gnutls_session_t session, gnutls_datum_t * raw_key) 134MHD_gnutls_dh_get_pubkey (mhd_gtls_session_t session, gnutls_datum_t * raw_key)
135{ 135{
136 dh_info_st *dh; 136 dh_info_st *dh;
137 anon_auth_info_t anon_info; 137 mhd_anon_auth_info_t anon_info;
138 cert_auth_info_t cert_info; 138 cert_auth_info_t cert_info;
139 cert_auth_info_t psk_info; 139 cert_auth_info_t psk_info;
140 140
141 switch (gnutls_auth_get_type (session)) 141 switch (MHD_gtls_auth_get_type (session))
142 { 142 {
143 case MHD_GNUTLS_CRD_ANON: 143 case MHD_GNUTLS_CRD_ANON:
144 { 144 {
145 anon_info = _gnutls_get_auth_info (session); 145 anon_info = mhd_gtls_get_auth_info (session);
146 if (anon_info == NULL) 146 if (anon_info == NULL)
147 return GNUTLS_E_INTERNAL_ERROR; 147 return GNUTLS_E_INTERNAL_ERROR;
148 dh = &anon_info->dh; 148 dh = &anon_info->dh;
@@ -150,7 +150,7 @@ gnutls_dh_get_pubkey (gnutls_session_t session, gnutls_datum_t * raw_key)
150 } 150 }
151 case MHD_GNUTLS_CRD_PSK: 151 case MHD_GNUTLS_CRD_PSK:
152 { 152 {
153 psk_info = _gnutls_get_auth_info (session); 153 psk_info = mhd_gtls_get_auth_info (session);
154 if (psk_info == NULL) 154 if (psk_info == NULL)
155 return GNUTLS_E_INTERNAL_ERROR; 155 return GNUTLS_E_INTERNAL_ERROR;
156 dh = &psk_info->dh; 156 dh = &psk_info->dh;
@@ -159,7 +159,7 @@ gnutls_dh_get_pubkey (gnutls_session_t session, gnutls_datum_t * raw_key)
159 case MHD_GNUTLS_CRD_CERTIFICATE: 159 case MHD_GNUTLS_CRD_CERTIFICATE:
160 { 160 {
161 161
162 cert_info = _gnutls_get_auth_info (session); 162 cert_info = mhd_gtls_get_auth_info (session);
163 if (cert_info == NULL) 163 if (cert_info == NULL)
164 return GNUTLS_E_INTERNAL_ERROR; 164 return GNUTLS_E_INTERNAL_ERROR;
165 dh = &cert_info->dh; 165 dh = &cert_info->dh;
@@ -175,7 +175,7 @@ gnutls_dh_get_pubkey (gnutls_session_t session, gnutls_datum_t * raw_key)
175} 175}
176 176
177/** 177/**
178 * gnutls_rsa_export_get_pubkey - This function returns the peer's public key used in RSA-EXPORT authentication 178 * MHD_gtls_rsa_export_get_pubkey - This function returns the peer's public key used in RSA-EXPORT authentication
179 * @session: is a gnutls session 179 * @session: is a gnutls session
180 * @exponent: will hold the exponent. 180 * @exponent: will hold the exponent.
181 * @modulus: will hold the modulus. 181 * @modulus: will hold the modulus.
@@ -188,16 +188,16 @@ gnutls_dh_get_pubkey (gnutls_session_t session, gnutls_datum_t * raw_key)
188 * 188 *
189 **/ 189 **/
190int 190int
191gnutls_rsa_export_get_pubkey (gnutls_session_t session, 191MHD_gtls_rsa_export_get_pubkey (mhd_gtls_session_t session,
192 gnutls_datum_t * exponent, 192 gnutls_datum_t * exponent,
193 gnutls_datum_t * modulus) 193 gnutls_datum_t * modulus)
194{ 194{
195 cert_auth_info_t info; 195 cert_auth_info_t info;
196 int ret; 196 int ret;
197 197
198 if (gnutls_auth_get_type (session) == MHD_GNUTLS_CRD_CERTIFICATE) 198 if (MHD_gtls_auth_get_type (session) == MHD_GNUTLS_CRD_CERTIFICATE)
199 { 199 {
200 info = _gnutls_get_auth_info (session); 200 info = mhd_gtls_get_auth_info (session);
201 if (info == NULL) 201 if (info == NULL)
202 return GNUTLS_E_INTERNAL_ERROR; 202 return GNUTLS_E_INTERNAL_ERROR;
203 203
@@ -225,7 +225,7 @@ gnutls_rsa_export_get_pubkey (gnutls_session_t session,
225} 225}
226 226
227/** 227/**
228 * gnutls_dh_get_secret_bits - This function returns the bits used in DH authentication 228 * MHD_gnutls_dh_get_secret_bits - This function returns the bits used in DH authentication
229 * @session: is a gnutls session 229 * @session: is a gnutls session
230 * 230 *
231 * This function will return the bits used in the last Diffie Hellman authentication 231 * This function will return the bits used in the last Diffie Hellman authentication
@@ -234,15 +234,15 @@ gnutls_rsa_export_get_pubkey (gnutls_session_t session,
234 * 234 *
235 **/ 235 **/
236int 236int
237gnutls_dh_get_secret_bits (gnutls_session_t session) 237MHD_gnutls_dh_get_secret_bits (mhd_gtls_session_t session)
238{ 238{
239 switch (gnutls_auth_get_type (session)) 239 switch (MHD_gtls_auth_get_type (session))
240 { 240 {
241 case MHD_GNUTLS_CRD_ANON: 241 case MHD_GNUTLS_CRD_ANON:
242 { 242 {
243 anon_auth_info_t info; 243 mhd_anon_auth_info_t info;
244 244
245 info = _gnutls_get_auth_info (session); 245 info = mhd_gtls_get_auth_info (session);
246 if (info == NULL) 246 if (info == NULL)
247 return GNUTLS_E_INTERNAL_ERROR; 247 return GNUTLS_E_INTERNAL_ERROR;
248 return info->dh.secret_bits; 248 return info->dh.secret_bits;
@@ -251,7 +251,7 @@ gnutls_dh_get_secret_bits (gnutls_session_t session)
251 { 251 {
252 cert_auth_info_t info; 252 cert_auth_info_t info;
253 253
254 info = _gnutls_get_auth_info (session); 254 info = mhd_gtls_get_auth_info (session);
255 if (info == NULL) 255 if (info == NULL)
256 return GNUTLS_E_INTERNAL_ERROR; 256 return GNUTLS_E_INTERNAL_ERROR;
257 257
@@ -264,7 +264,7 @@ gnutls_dh_get_secret_bits (gnutls_session_t session)
264} 264}
265 265
266/** 266/**
267 * gnutls_dh_get_prime_bits - This function returns the bits used in DH authentication 267 * MHD_gnutls_dh_get_prime_bits - This function returns the bits used in DH authentication
268 * @session: is a gnutls session 268 * @session: is a gnutls session
269 * 269 *
270 * This function will return the bits of the prime used in the last Diffie Hellman authentication 270 * This function will return the bits of the prime used in the last Diffie Hellman authentication
@@ -273,17 +273,17 @@ gnutls_dh_get_secret_bits (gnutls_session_t session)
273 * 273 *
274 **/ 274 **/
275int 275int
276gnutls_dh_get_prime_bits (gnutls_session_t session) 276MHD_gnutls_dh_get_prime_bits (mhd_gtls_session_t session)
277{ 277{
278 dh_info_st *dh; 278 dh_info_st *dh;
279 279
280 switch (gnutls_auth_get_type (session)) 280 switch (MHD_gtls_auth_get_type (session))
281 { 281 {
282 case MHD_GNUTLS_CRD_ANON: 282 case MHD_GNUTLS_CRD_ANON:
283 { 283 {
284 anon_auth_info_t info; 284 mhd_anon_auth_info_t info;
285 285
286 info = _gnutls_get_auth_info (session); 286 info = mhd_gtls_get_auth_info (session);
287 if (info == NULL) 287 if (info == NULL)
288 return GNUTLS_E_INTERNAL_ERROR; 288 return GNUTLS_E_INTERNAL_ERROR;
289 dh = &info->dh; 289 dh = &info->dh;
@@ -293,7 +293,7 @@ gnutls_dh_get_prime_bits (gnutls_session_t session)
293 { 293 {
294 cert_auth_info_t info; 294 cert_auth_info_t info;
295 295
296 info = _gnutls_get_auth_info (session); 296 info = mhd_gtls_get_auth_info (session);
297 if (info == NULL) 297 if (info == NULL)
298 return GNUTLS_E_INTERNAL_ERROR; 298 return GNUTLS_E_INTERNAL_ERROR;
299 299
@@ -310,7 +310,7 @@ gnutls_dh_get_prime_bits (gnutls_session_t session)
310} 310}
311 311
312/** 312/**
313 * gnutls_rsa_export_get_modulus_bits - This function returns the bits used in RSA-export key exchange 313 * MHD_gtls_rsa_export_get_modulus_bits - This function returns the bits used in RSA-export key exchange
314 * @session: is a gnutls session 314 * @session: is a gnutls session
315 * 315 *
316 * This function will return the bits used in the last RSA-EXPORT key exchange 316 * This function will return the bits used in the last RSA-EXPORT key exchange
@@ -319,11 +319,11 @@ gnutls_dh_get_prime_bits (gnutls_session_t session)
319 * 319 *
320 **/ 320 **/
321int 321int
322gnutls_rsa_export_get_modulus_bits (gnutls_session_t session) 322MHD_gtls_rsa_export_get_modulus_bits (mhd_gtls_session_t session)
323{ 323{
324 cert_auth_info_t info; 324 cert_auth_info_t info;
325 325
326 info = _gnutls_get_auth_info (session); 326 info = mhd_gtls_get_auth_info (session);
327 if (info == NULL) 327 if (info == NULL)
328 return GNUTLS_E_INTERNAL_ERROR; 328 return GNUTLS_E_INTERNAL_ERROR;
329 329
@@ -331,7 +331,7 @@ gnutls_rsa_export_get_modulus_bits (gnutls_session_t session)
331} 331}
332 332
333/** 333/**
334 * gnutls_dh_get_peers_public_bits - This function returns the bits used in DH authentication 334 * MHD_gnutls_dh_get_peers_public_bits - This function returns the bits used in DH authentication
335 * @session: is a gnutls session 335 * @session: is a gnutls session
336 * 336 *
337 * This function will return the bits used in the last Diffie Hellman authentication 337 * This function will return the bits used in the last Diffie Hellman authentication
@@ -340,17 +340,17 @@ gnutls_rsa_export_get_modulus_bits (gnutls_session_t session)
340 * 340 *
341 **/ 341 **/
342int 342int
343gnutls_dh_get_peers_public_bits (gnutls_session_t session) 343MHD_gnutls_dh_get_peers_public_bits (mhd_gtls_session_t session)
344{ 344{
345 dh_info_st *dh; 345 dh_info_st *dh;
346 346
347 switch (gnutls_auth_get_type (session)) 347 switch (MHD_gtls_auth_get_type (session))
348 { 348 {
349 case MHD_GNUTLS_CRD_ANON: 349 case MHD_GNUTLS_CRD_ANON:
350 { 350 {
351 anon_auth_info_t info; 351 mhd_anon_auth_info_t info;
352 352
353 info = _gnutls_get_auth_info (session); 353 info = mhd_gtls_get_auth_info (session);
354 if (info == NULL) 354 if (info == NULL)
355 return GNUTLS_E_INTERNAL_ERROR; 355 return GNUTLS_E_INTERNAL_ERROR;
356 356
@@ -361,7 +361,7 @@ gnutls_dh_get_peers_public_bits (gnutls_session_t session)
361 { 361 {
362 cert_auth_info_t info; 362 cert_auth_info_t info;
363 363
364 info = _gnutls_get_auth_info (session); 364 info = mhd_gtls_get_auth_info (session);
365 if (info == NULL) 365 if (info == NULL)
366 return GNUTLS_E_INTERNAL_ERROR; 366 return GNUTLS_E_INTERNAL_ERROR;
367 367
@@ -380,7 +380,7 @@ gnutls_dh_get_peers_public_bits (gnutls_session_t session)
380/* CERTIFICATE STUFF */ 380/* CERTIFICATE STUFF */
381 381
382/** 382/**
383 * gnutls_certificate_get_ours - This function returns the raw certificate sent in the last handshake 383 * MHD_gtls_certificate_get_ours - This function returns the raw certificate sent in the last handshake
384 * @session: is a gnutls session 384 * @session: is a gnutls session
385 * 385 *
386 * This function will return the certificate as sent to the peer, 386 * This function will return the certificate as sent to the peer,
@@ -391,14 +391,14 @@ gnutls_dh_get_peers_public_bits (gnutls_session_t session)
391 * 391 *
392 **/ 392 **/
393const gnutls_datum_t * 393const gnutls_datum_t *
394gnutls_certificate_get_ours (gnutls_session_t session) 394MHD_gtls_certificate_get_ours (mhd_gtls_session_t session)
395{ 395{
396 gnutls_certificate_credentials_t cred; 396 mhd_gtls_cert_credentials_t cred;
397 397
398 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, NULL); 398 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, NULL);
399 399
400 cred 400 cred
401 = (gnutls_certificate_credentials_t) _gnutls_get_cred (session->key, 401 = (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key,
402 MHD_GNUTLS_CRD_CERTIFICATE, 402 MHD_GNUTLS_CRD_CERTIFICATE,
403 NULL); 403 NULL);
404 if (cred == NULL || cred->cert_list == NULL) 404 if (cred == NULL || cred->cert_list == NULL)
@@ -414,7 +414,7 @@ gnutls_certificate_get_ours (gnutls_session_t session)
414} 414}
415 415
416/** 416/**
417 * gnutls_certificate_get_peers - This function returns the peer's raw certificate 417 * MHD_gtls_certificate_get_peers - This function returns the peer's raw certificate
418 * @session: is a gnutls session 418 * @session: is a gnutls session
419 * @list_size: is the length of the certificate list 419 * @list_size: is the length of the certificate list
420 * 420 *
@@ -431,14 +431,14 @@ gnutls_certificate_get_ours (gnutls_session_t session)
431 * 431 *
432 **/ 432 **/
433const gnutls_datum_t * 433const gnutls_datum_t *
434gnutls_certificate_get_peers (gnutls_session_t 434MHD_gtls_certificate_get_peers (mhd_gtls_session_t
435 session, unsigned int *list_size) 435 session, unsigned int *list_size)
436{ 436{
437 cert_auth_info_t info; 437 cert_auth_info_t info;
438 438
439 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, NULL); 439 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, NULL);
440 440
441 info = _gnutls_get_auth_info (session); 441 info = mhd_gtls_get_auth_info (session);
442 if (info == NULL) 442 if (info == NULL)
443 return NULL; 443 return NULL;
444 444
@@ -447,7 +447,7 @@ gnutls_certificate_get_peers (gnutls_session_t
447} 447}
448 448
449/** 449/**
450 * gnutls_certificate_client_get_request_status - This function returns the certificate request status 450 * MHD_gtls_certificate_client_get_request_status - This function returns the certificate request status
451 * @session: is a gnutls session 451 * @session: is a gnutls session
452 * 452 *
453 * This function will return 0 if the peer (server) did not request client 453 * This function will return 0 if the peer (server) did not request client
@@ -456,20 +456,20 @@ gnutls_certificate_get_peers (gnutls_session_t
456 * 456 *
457 **/ 457 **/
458int 458int
459gnutls_certificate_client_get_request_status (gnutls_session_t session) 459MHD_gtls_certificate_client_get_request_status (mhd_gtls_session_t session)
460{ 460{
461 cert_auth_info_t info; 461 cert_auth_info_t info;
462 462
463 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, 0); 463 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, 0);
464 464
465 info = _gnutls_get_auth_info (session); 465 info = mhd_gtls_get_auth_info (session);
466 if (info == NULL) 466 if (info == NULL)
467 return GNUTLS_E_INTERNAL_ERROR; 467 return GNUTLS_E_INTERNAL_ERROR;
468 return info->certificate_requested; 468 return info->certificate_requested;
469} 469}
470 470
471/** 471/**
472 * gnutls_fingerprint - This function calculates the fingerprint of the given data 472 * MHD_gnutls_fingerprint - This function calculates the fingerprint of the given data
473 * @algo: is a digest algorithm 473 * @algo: is a digest algorithm
474 * @data: is the data 474 * @data: is the data
475 * @result: is the place where the result will be copied (may be null). 475 * @result: is the place where the result will be copied (may be null).
@@ -489,12 +489,12 @@ gnutls_certificate_client_get_request_status (gnutls_session_t session)
489 * 489 *
490 **/ 490 **/
491int 491int
492gnutls_fingerprint (gnutls_digest_algorithm_t algo, 492MHD_gnutls_fingerprint (gnutls_digest_algorithm_t algo,
493 const gnutls_datum_t * data, 493 const gnutls_datum_t * data,
494 void *result, size_t * result_size) 494 void *result, size_t * result_size)
495{ 495{
496 GNUTLS_HASH_HANDLE td; 496 GNUTLS_HASH_HANDLE td;
497 int hash_len = _gnutls_hash_get_algo_len (HASH2MAC (algo)); 497 int hash_len = mhd_gnutls_hash_get_algo_len (HASH2MAC (algo));
498 498
499 if (hash_len < 0 || (unsigned) hash_len > *result_size || result == NULL) 499 if (hash_len < 0 || (unsigned) hash_len > *result_size || result == NULL)
500 { 500 {
@@ -505,21 +505,21 @@ gnutls_fingerprint (gnutls_digest_algorithm_t algo,
505 505
506 if (result) 506 if (result)
507 { 507 {
508 td = _gnutls_hash_init (HASH2MAC (algo)); 508 td = mhd_gtls_hash_init (HASH2MAC (algo));
509 if (td == NULL) 509 if (td == NULL)
510 return GNUTLS_E_HASH_FAILED; 510 return GNUTLS_E_HASH_FAILED;
511 511
512 _gnutls_hash (td, data->data, data->size); 512 mhd_gnutls_hash (td, data->data, data->size);
513 513
514 _gnutls_hash_deinit (td, result); 514 mhd_gnutls_hash_deinit (td, result);
515 } 515 }
516 516
517 return 0; 517 return 0;
518} 518}
519 519
520/** 520/**
521 * gnutls_certificate_set_dh_params - This function will set the DH parameters for a server to use 521 * MHD_gnutls_certificate_set_dh_params - This function will set the DH parameters for a server to use
522 * @res: is a gnutls_certificate_credentials_t structure 522 * @res: is a mhd_gtls_cert_credentials_t structure
523 * @dh_params: is a structure that holds diffie hellman parameters. 523 * @dh_params: is a structure that holds diffie hellman parameters.
524 * 524 *
525 * This function will set the diffie hellman parameters for a 525 * This function will set the diffie hellman parameters for a
@@ -531,15 +531,15 @@ gnutls_fingerprint (gnutls_digest_algorithm_t algo,
531 * 531 *
532 **/ 532 **/
533void 533void
534gnutls_certificate_set_dh_params (gnutls_certificate_credentials_t res, 534MHD_gnutls_certificate_set_dh_params (mhd_gtls_cert_credentials_t res,
535 gnutls_dh_params_t dh_params) 535 mhd_gtls_dh_params_t dh_params)
536{ 536{
537 res->dh_params = dh_params; 537 res->dh_params = dh_params;
538} 538}
539 539
540/** 540/**
541 * gnutls_certificate_set_params_function - This function will set the DH or RSA parameters callback 541 * gnutls_certificate_set_params_function - This function will set the DH or RSA parameters callback
542 * @res: is a gnutls_certificate_credentials_t structure 542 * @res: is a mhd_gtls_cert_credentials_t structure
543 * @func: is the function to be called 543 * @func: is the function to be called
544 * 544 *
545 * This function will set a callback in order for the server to get the 545 * This function will set a callback in order for the server to get the
@@ -548,15 +548,15 @@ gnutls_certificate_set_dh_params (gnutls_certificate_credentials_t res,
548 * 548 *
549 **/ 549 **/
550void 550void
551gnutls_certificate_set_params_function (gnutls_certificate_credentials_t res, 551gnutls_certificate_set_params_function (mhd_gtls_cert_credentials_t res,
552 gnutls_params_function * func) 552 gnutls_params_function * func)
553{ 553{
554 res->params_func = func; 554 res->params_func = func;
555} 555}
556 556
557/** 557/**
558 * gnutls_certificate_set_verify_flags - This function will set the flags to be used at certificate verification 558 * MHD_gnutls_certificate_set_verify_flags - This function will set the flags to be used at certificate verification
559 * @res: is a gnutls_certificate_credentials_t structure 559 * @res: is a mhd_gtls_cert_credentials_t structure
560 * @flags: are the flags 560 * @flags: are the flags
561 * 561 *
562 * This function will set the flags to be used at verification of the 562 * This function will set the flags to be used at verification of the
@@ -565,25 +565,25 @@ gnutls_certificate_set_params_function (gnutls_certificate_credentials_t res,
565 * 565 *
566 **/ 566 **/
567void 567void
568gnutls_certificate_set_verify_flags (gnutls_certificate_credentials_t 568MHD_gnutls_certificate_set_verify_flags (mhd_gtls_cert_credentials_t
569 res, unsigned int flags) 569 res, unsigned int flags)
570{ 570{
571 res->verify_flags = flags; 571 res->verify_flags = flags;
572} 572}
573 573
574/** 574/**
575 * gnutls_certificate_set_verify_limits - This function will set the upper limits to be used at certificate verification 575 * MHD_gnutls_certificate_set_verify_limits - This function will set the upper limits to be used at certificate verification
576 * @res: is a gnutls_certificate_credentials structure 576 * @res: is a gnutls_certificate_credentials structure
577 * @max_bits: is the number of bits of an acceptable certificate (default 8200) 577 * @max_bits: is the number of bits of an acceptable certificate (default 8200)
578 * @max_depth: is maximum depth of the verification of a certificate chain (default 5) 578 * @max_depth: is maximum depth of the verification of a certificate chain (default 5)
579 * 579 *
580 * This function will set some upper limits for the default verification function, 580 * This function will set some upper limits for the default verification function,
581 * gnutls_certificate_verify_peers2(), to avoid denial of service attacks. 581 * MHD_gtls_certificate_verify_peers2(), to avoid denial of service attacks.
582 * You can set them to zero to disable limits. 582 * You can set them to zero to disable limits.
583 * 583 *
584 **/ 584 **/
585void 585void
586gnutls_certificate_set_verify_limits (gnutls_certificate_credentials_t 586MHD_gnutls_certificate_set_verify_limits (mhd_gtls_cert_credentials_t
587 res, 587 res,
588 unsigned int max_bits, 588 unsigned int max_bits,
589 unsigned int max_depth) 589 unsigned int max_depth)
@@ -593,8 +593,8 @@ gnutls_certificate_set_verify_limits (gnutls_certificate_credentials_t
593} 593}
594 594
595/** 595/**
596 * gnutls_certificate_set_rsa_export_params - This function will set the RSA parameters for a server to use 596 * MHD_gnutls_certificate_set_rsa_export_params - This function will set the RSA parameters for a server to use
597 * @res: is a gnutls_certificate_credentials_t structure 597 * @res: is a mhd_gtls_cert_credentials_t structure
598 * @rsa_params: is a structure that holds temporary RSA parameters. 598 * @rsa_params: is a structure that holds temporary RSA parameters.
599 * 599 *
600 * This function will set the temporary RSA parameters for a certificate 600 * This function will set the temporary RSA parameters for a certificate
@@ -603,15 +603,15 @@ gnutls_certificate_set_verify_limits (gnutls_certificate_credentials_t
603 * 603 *
604 **/ 604 **/
605void 605void
606gnutls_certificate_set_rsa_export_params (gnutls_certificate_credentials_t 606MHD_gnutls_certificate_set_rsa_export_params (mhd_gtls_cert_credentials_t
607 res, gnutls_rsa_params_t rsa_params) 607 res, mhd_gtls_rsa_params_t rsa_params)
608{ 608{
609 res->rsa_params = rsa_params; 609 res->rsa_params = rsa_params;
610} 610}
611 611
612/** 612/**
613 * gnutls_anon_set_params_function - This function will set the DH or RSA parameters callback 613 * gnutls_anon_set_params_function - This function will set the DH or RSA parameters callback
614 * @res: is a gnutls_anon_server_credentials_t structure 614 * @res: is a mhd_gtls_anon_server_credentials_t structure
615 * @func: is the function to be called 615 * @func: is the function to be called
616 * 616 *
617 * This function will set a callback in order for the server to get the 617 * This function will set a callback in order for the server to get the
@@ -620,7 +620,7 @@ gnutls_certificate_set_rsa_export_params (gnutls_certificate_credentials_t
620 * 620 *
621 **/ 621 **/
622void 622void
623gnutls_anon_set_params_function (gnutls_anon_server_credentials_t res, 623gnutls_anon_set_params_function (mhd_gtls_anon_server_credentials_t res,
624 gnutls_params_function * func) 624 gnutls_params_function * func)
625{ 625{
626 res->params_func = func; 626 res->params_func = func;
diff --git a/src/daemon/https/tls/gnutls_x509.c b/src/daemon/https/tls/gnutls_x509.c
index a9b6829d..bf66e632 100644
--- a/src/daemon/https/tls/gnutls_x509.c
+++ b/src/daemon/https/tls/gnutls_x509.c
@@ -100,25 +100,25 @@ check_bits (gnutls_x509_crt_t crt, unsigned int max_bits)
100 * 100 *
101 -*/ 101 -*/
102int 102int
103_gnutls_x509_cert_verify_peers (gnutls_session_t session, 103_gnutls_x509_cert_verify_peers (mhd_gtls_session_t session,
104 unsigned int *status) 104 unsigned int *status)
105{ 105{
106 cert_auth_info_t info; 106 cert_auth_info_t info;
107 gnutls_certificate_credentials_t cred; 107 mhd_gtls_cert_credentials_t cred;
108 gnutls_x509_crt_t *peer_certificate_list; 108 gnutls_x509_crt_t *peer_certificate_list;
109 int peer_certificate_list_size, i, x, ret; 109 int peer_certificate_list_size, i, x, ret;
110 110
111 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 111 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
112 112
113 info = _gnutls_get_auth_info (session); 113 info = mhd_gtls_get_auth_info (session);
114 if (info == NULL) 114 if (info == NULL)
115 { 115 {
116 gnutls_assert (); 116 gnutls_assert ();
117 return GNUTLS_E_INVALID_REQUEST; 117 return GNUTLS_E_INVALID_REQUEST;
118 } 118 }
119 119
120 cred = (gnutls_certificate_credentials_t) 120 cred = (mhd_gtls_cert_credentials_t)
121 _gnutls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 121 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
122 if (cred == NULL) 122 if (cred == NULL)
123 { 123 {
124 gnutls_assert (); 124 gnutls_assert ();
@@ -206,7 +206,7 @@ _gnutls_x509_cert_verify_peers (gnutls_session_t session,
206 * the given key parameters. 206 * the given key parameters.
207 */ 207 */
208static int 208static int
209_gnutls_check_key_cert_match (gnutls_certificate_credentials_t res) 209_gnutls_check_key_cert_match (mhd_gtls_cert_credentials_t res)
210{ 210{
211 gnutls_datum_t cid; 211 gnutls_datum_t cid;
212 gnutls_datum_t kid; 212 gnutls_datum_t kid;
@@ -263,7 +263,7 @@ parse_crt_mem (gnutls_cert ** cert_list, unsigned *ncerts,
263 i = *ncerts + 1; 263 i = *ncerts + 1;
264 264
265 *cert_list = 265 *cert_list =
266 (gnutls_cert *) gnutls_realloc_fast (*cert_list, 266 (gnutls_cert *) mhd_gtls_realloc_fast (*cert_list,
267 i * sizeof (gnutls_cert)); 267 i * sizeof (gnutls_cert));
268 268
269 if (*cert_list == NULL) 269 if (*cert_list == NULL)
@@ -272,7 +272,7 @@ parse_crt_mem (gnutls_cert ** cert_list, unsigned *ncerts,
272 return GNUTLS_E_MEMORY_ERROR; 272 return GNUTLS_E_MEMORY_ERROR;
273 } 273 }
274 274
275 ret = _gnutls_x509_crt_to_gcert (&cert_list[0][i - 1], cert, 0); 275 ret = mhd_gtls_x509_crt_to_gcert (&cert_list[0][i - 1], cert, 0);
276 if (ret < 0) 276 if (ret < 0)
277 { 277 {
278 gnutls_assert (); 278 gnutls_assert ();
@@ -408,7 +408,7 @@ parse_pkcs7_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts, const
408 if (ret >= 0) 408 if (ret >= 0)
409 { 409 {
410 *cert_list = 410 *cert_list =
411 (gnutls_cert *) gnutls_realloc_fast (*cert_list, 411 (gnutls_cert *) mhd_gtls_realloc_fast (*cert_list,
412 i * sizeof (gnutls_cert)); 412 i * sizeof (gnutls_cert));
413 413
414 if (*cert_list == NULL) 414 if (*cert_list == NULL)
@@ -422,7 +422,7 @@ parse_pkcs7_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts, const
422 tmp2.size = pcert_size; 422 tmp2.size = pcert_size;
423 423
424 ret = 424 ret =
425 _gnutls_x509_raw_cert_to_gcert (&cert_list[0][i - 1], &tmp2, 0); 425 mhd_gtls_x509_raw_cert_to_gcert (&cert_list[0][i - 1], &tmp2, 0);
426 426
427 if (ret < 0) 427 if (ret < 0)
428 { 428 {
@@ -502,7 +502,7 @@ parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts,
502 } 502 }
503 503
504 *cert_list = 504 *cert_list =
505 (gnutls_cert *) gnutls_realloc_fast (*cert_list, 505 (gnutls_cert *) mhd_gtls_realloc_fast (*cert_list,
506 i * sizeof (gnutls_cert)); 506 i * sizeof (gnutls_cert));
507 507
508 if (*cert_list == NULL) 508 if (*cert_list == NULL)
@@ -514,7 +514,7 @@ parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts,
514 tmp.data = ptr2; 514 tmp.data = ptr2;
515 tmp.size = siz2; 515 tmp.size = siz2;
516 516
517 ret = _gnutls_x509_raw_cert_to_gcert (&cert_list[0][i - 1], &tmp, 0); 517 ret = mhd_gtls_x509_raw_cert_to_gcert (&cert_list[0][i - 1], &tmp, 0);
518 if (ret < 0) 518 if (ret < 0)
519 { 519 {
520 gnutls_assert (); 520 gnutls_assert ();
@@ -559,14 +559,14 @@ parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts,
559/* Reads a DER or PEM certificate from memory 559/* Reads a DER or PEM certificate from memory
560 */ 560 */
561static int 561static int
562read_cert_mem (gnutls_certificate_credentials_t res, const void *cert, 562read_cert_mem (mhd_gtls_cert_credentials_t res, const void *cert,
563 int cert_size, gnutls_x509_crt_fmt_t type) 563 int cert_size, gnutls_x509_crt_fmt_t type)
564{ 564{
565 int ret; 565 int ret;
566 566
567 /* allocate space for the certificate to add 567 /* allocate space for the certificate to add
568 */ 568 */
569 res->cert_list = gnutls_realloc_fast (res->cert_list, 569 res->cert_list = mhd_gtls_realloc_fast (res->cert_list,
570 (1 + 570 (1 +
571 res->ncerts) * 571 res->ncerts) *
572 sizeof (gnutls_cert *)); 572 sizeof (gnutls_cert *));
@@ -576,7 +576,7 @@ read_cert_mem (gnutls_certificate_credentials_t res, const void *cert,
576 return GNUTLS_E_MEMORY_ERROR; 576 return GNUTLS_E_MEMORY_ERROR;
577 } 577 }
578 578
579 res->cert_list_length = gnutls_realloc_fast (res->cert_list_length, 579 res->cert_list_length = mhd_gtls_realloc_fast (res->cert_list_length,
580 (1 + 580 (1 +
581 res->ncerts) * sizeof (int)); 581 res->ncerts) * sizeof (int));
582 if (res->cert_list_length == NULL) 582 if (res->cert_list_length == NULL)
@@ -636,13 +636,13 @@ cleanup:
636 636
637 for (i = 0; i < src->params_size; i++) 637 for (i = 0; i < src->params_size; i++)
638 { 638 {
639 _gnutls_mpi_release (&dest->params[i]); 639 mhd_gtls_mpi_release (&dest->params[i]);
640 } 640 }
641 return ret; 641 return ret;
642} 642}
643 643
644void 644void
645_gnutls_gkey_deinit (gnutls_privkey * key) 645mhd_gtls_gkey_deinit (gnutls_privkey * key)
646{ 646{
647 int i; 647 int i;
648 if (key == NULL) 648 if (key == NULL)
@@ -650,7 +650,7 @@ _gnutls_gkey_deinit (gnutls_privkey * key)
650 650
651 for (i = 0; i < key->params_size; i++) 651 for (i = 0; i < key->params_size; i++)
652 { 652 {
653 _gnutls_mpi_release (&key->params[i]); 653 mhd_gtls_mpi_release (&key->params[i]);
654 } 654 }
655} 655}
656 656
@@ -702,7 +702,7 @@ _gnutls_x509_raw_privkey_to_gkey (gnutls_privkey * privkey,
702 * that GnuTLS doesn't know the private key. 702 * that GnuTLS doesn't know the private key.
703 */ 703 */
704static int 704static int
705read_key_mem (gnutls_certificate_credentials_t res, 705read_key_mem (mhd_gtls_cert_credentials_t res,
706 const void *key, int key_size, gnutls_x509_crt_fmt_t type) 706 const void *key, int key_size, gnutls_x509_crt_fmt_t type)
707{ 707{
708 int ret; 708 int ret;
@@ -711,7 +711,7 @@ read_key_mem (gnutls_certificate_credentials_t res,
711 /* allocate space for the pkey list 711 /* allocate space for the pkey list
712 */ 712 */
713 res->pkey = 713 res->pkey =
714 gnutls_realloc_fast (res->pkey, 714 mhd_gtls_realloc_fast (res->pkey,
715 (res->ncerts + 1) * sizeof (gnutls_privkey)); 715 (res->ncerts + 1) * sizeof (gnutls_privkey));
716 if (res->pkey == NULL) 716 if (res->pkey == NULL)
717 { 717 {
@@ -742,7 +742,7 @@ read_key_mem (gnutls_certificate_credentials_t res,
742/* Reads a certificate file 742/* Reads a certificate file
743 */ 743 */
744static int 744static int
745read_cert_file (gnutls_certificate_credentials_t res, 745read_cert_file (mhd_gtls_cert_credentials_t res,
746 const char *certfile, gnutls_x509_crt_fmt_t type) 746 const char *certfile, gnutls_x509_crt_fmt_t type)
747{ 747{
748 int ret; 748 int ret;
@@ -768,7 +768,7 @@ read_cert_file (gnutls_certificate_credentials_t res,
768 * stores it). 768 * stores it).
769 */ 769 */
770static int 770static int
771read_key_file (gnutls_certificate_credentials_t res, 771read_key_file (mhd_gtls_cert_credentials_t res,
772 const char *keyfile, gnutls_x509_crt_fmt_t type) 772 const char *keyfile, gnutls_x509_crt_fmt_t type)
773{ 773{
774 int ret; 774 int ret;
@@ -788,14 +788,14 @@ read_key_file (gnutls_certificate_credentials_t res,
788} 788}
789 789
790/** 790/**
791 * gnutls_certificate_set_x509_key_mem - Used to set keys in a gnutls_certificate_credentials_t structure 791 * MHD_gnutls_certificate_set_x509_key_mem - Used to set keys in a mhd_gtls_cert_credentials_t structure
792 * @res: is an #gnutls_certificate_credentials_t structure. 792 * @res: is an #mhd_gtls_cert_credentials_t structure.
793 * @cert: contains a certificate list (path) for the specified private key 793 * @cert: contains a certificate list (path) for the specified private key
794 * @key: is the private key, or %NULL 794 * @key: is the private key, or %NULL
795 * @type: is PEM or DER 795 * @type: is PEM or DER
796 * 796 *
797 * This function sets a certificate/private key pair in the 797 * This function sets a certificate/private key pair in the
798 * gnutls_certificate_credentials_t structure. This function may be called 798 * mhd_gtls_cert_credentials_t structure. This function may be called
799 * more than once (in case multiple keys/certificates exist for the 799 * more than once (in case multiple keys/certificates exist for the
800 * server). 800 * server).
801 * 801 *
@@ -813,12 +813,12 @@ read_key_file (gnutls_certificate_credentials_t res,
813 * then the strings that hold their values must be null terminated. 813 * then the strings that hold their values must be null terminated.
814 * 814 *
815 * The @key may be %NULL if you are using a sign callback, see 815 * The @key may be %NULL if you are using a sign callback, see
816 * gnutls_sign_callback_set(). 816 * MHD_gtls_sign_callback_set().
817 * 817 *
818 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 818 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
819 **/ 819 **/
820int 820int
821gnutls_certificate_set_x509_key_mem (gnutls_certificate_credentials_t 821MHD_gnutls_certificate_set_x509_key_mem (mhd_gtls_cert_credentials_t
822 res, const gnutls_datum_t * cert, 822 res, const gnutls_datum_t * cert,
823 const gnutls_datum_t * key, 823 const gnutls_datum_t * key,
824 gnutls_x509_crt_fmt_t type) 824 gnutls_x509_crt_fmt_t type)
@@ -846,100 +846,15 @@ gnutls_certificate_set_x509_key_mem (gnutls_certificate_credentials_t
846} 846}
847 847
848/** 848/**
849 * gnutls_certificate_set_x509_key - Used to set keys in a gnutls_certificate_credentials_t structure 849 * MHD_gnutls_certificate_set_x509_key_file - Used to set keys in a mhd_gtls_cert_credentials_t structure
850 * @res: is an #gnutls_certificate_credentials_t structure. 850 * @res: is an #mhd_gtls_cert_credentials_t structure.
851 * @cert_list: contains a certificate list (path) for the specified private key
852 * @cert_list_size: holds the size of the certificate list
853 * @key: is a gnutls_x509_privkey_t key
854 *
855 * This function sets a certificate/private key pair in the
856 * gnutls_certificate_credentials_t structure. This function may be
857 * called more than once (in case multiple keys/certificates exist
858 * for the server).
859 *
860 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
861 **/
862int
863gnutls_certificate_set_x509_key (gnutls_certificate_credentials_t res,
864 gnutls_x509_crt_t * cert_list,
865 int cert_list_size,
866 gnutls_x509_privkey_t key)
867{
868 int ret, i;
869
870 /* this should be first
871 */
872
873 res->pkey =
874 gnutls_realloc_fast (res->pkey,
875 (res->ncerts + 1) * sizeof (gnutls_privkey));
876 if (res->pkey == NULL)
877 {
878 gnutls_assert ();
879 return GNUTLS_E_MEMORY_ERROR;
880 }
881
882 ret = _gnutls_x509_privkey_to_gkey (&res->pkey[res->ncerts], key);
883 if (ret < 0)
884 {
885 gnutls_assert ();
886 return ret;
887 }
888
889 res->cert_list = gnutls_realloc_fast (res->cert_list,
890 (1 +
891 res->ncerts) *
892 sizeof (gnutls_cert *));
893 if (res->cert_list == NULL)
894 {
895 gnutls_assert ();
896 return GNUTLS_E_MEMORY_ERROR;
897 }
898
899 res->cert_list_length = gnutls_realloc_fast (res->cert_list_length,
900 (1 +
901 res->ncerts) * sizeof (int));
902 if (res->cert_list_length == NULL)
903 {
904 gnutls_assert ();
905 return GNUTLS_E_MEMORY_ERROR;
906 }
907
908 res->cert_list[res->ncerts] = NULL; /* for realloc */
909 res->cert_list_length[res->ncerts] = 0;
910
911
912 for (i = 0; i < cert_list_size; i++)
913 {
914 ret = parse_crt_mem (&res->cert_list[res->ncerts],
915 &res->cert_list_length[res->ncerts], cert_list[i]);
916 if (ret < 0)
917 {
918 gnutls_assert ();
919 return ret;
920 }
921 }
922 res->ncerts++;
923
924 if ((ret = _gnutls_check_key_cert_match (res)) < 0)
925 {
926 gnutls_assert ();
927 return ret;
928 }
929
930 return 0;
931}
932
933/**
934 * gnutls_certificate_set_x509_key_file - Used to set keys in a gnutls_certificate_credentials_t structure
935 * @res: is an #gnutls_certificate_credentials_t structure.
936 * @CERTFILE: is a file that containing the certificate list (path) for 851 * @CERTFILE: is a file that containing the certificate list (path) for
937 * the specified private key, in PKCS7 format, or a list of certificates 852 * the specified private key, in PKCS7 format, or a list of certificates
938 * @KEYFILE: is a file that contains the private key 853 * @KEYFILE: is a file that contains the private key
939 * @type: is PEM or DER 854 * @type: is PEM or DER
940 * 855 *
941 * This function sets a certificate/private key pair in the 856 * This function sets a certificate/private key pair in the
942 * gnutls_certificate_credentials_t structure. This function may be 857 * mhd_gtls_cert_credentials_t structure. This function may be
943 * called more than once (in case multiple keys/certificates exist 858 * called more than once (in case multiple keys/certificates exist
944 * for the server). 859 * for the server).
945 * 860 *
@@ -949,7 +864,7 @@ gnutls_certificate_set_x509_key (gnutls_certificate_credentials_t res,
949 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 864 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
950 **/ 865 **/
951int 866int
952gnutls_certificate_set_x509_key_file (gnutls_certificate_credentials_t 867MHD_gnutls_certificate_set_x509_key_file (mhd_gtls_cert_credentials_t
953 res, const char *CERTFILE, 868 res, const char *CERTFILE,
954 const char *KEYFILE, 869 const char *KEYFILE,
955 gnutls_x509_crt_fmt_t type) 870 gnutls_x509_crt_fmt_t type)
@@ -976,7 +891,7 @@ gnutls_certificate_set_x509_key_file (gnutls_certificate_credentials_t
976} 891}
977 892
978static int 893static int
979generate_rdn_seq (gnutls_certificate_credentials_t res) 894generate_rdn_seq (mhd_gtls_cert_credentials_t res)
980{ 895{
981 gnutls_datum_t tmp; 896 gnutls_datum_t tmp;
982 int ret; 897 int ret;
@@ -1028,7 +943,7 @@ generate_rdn_seq (gnutls_certificate_credentials_t res)
1028 return ret; 943 return ret;
1029 } 944 }
1030 945
1031 _gnutls_write_datum16 (pdata, tmp); 946 mhd_gtls_write_datum16 (pdata, tmp);
1032 pdata += (2 + tmp.size); 947 pdata += (2 + tmp.size);
1033 _gnutls_free_datum (&tmp); 948 _gnutls_free_datum (&tmp);
1034 } 949 }
@@ -1051,13 +966,13 @@ _gnutls_check_key_usage (const gnutls_cert * cert, gnutls_kx_algorithm_t alg)
1051 return GNUTLS_E_INTERNAL_ERROR; 966 return GNUTLS_E_INTERNAL_ERROR;
1052 } 967 }
1053 968
1054 if (_gnutls_map_kx_get_cred (alg, 1) == MHD_GNUTLS_CRD_CERTIFICATE || 969 if (mhd_gtls_map_kx_get_cred (alg, 1) == MHD_GNUTLS_CRD_CERTIFICATE ||
1055 _gnutls_map_kx_get_cred (alg, 0) == MHD_GNUTLS_CRD_CERTIFICATE) 970 mhd_gtls_map_kx_get_cred (alg, 0) == MHD_GNUTLS_CRD_CERTIFICATE)
1056 { 971 {
1057 972
1058 key_usage = cert->key_usage; 973 key_usage = cert->key_usage;
1059 974
1060 encipher_type = _gnutls_kx_encipher_type (alg); 975 encipher_type = mhd_gtls_kx_encipher_type (alg);
1061 976
1062 if (key_usage != 0 && encipher_type != CIPHER_IGN) 977 if (key_usage != 0 && encipher_type != CIPHER_IGN)
1063 { 978 {
@@ -1125,7 +1040,7 @@ parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
1125 { 1040 {
1126 1041
1127 *cert_list = 1042 *cert_list =
1128 (gnutls_x509_crt_t *) gnutls_realloc_fast (*cert_list, 1043 (gnutls_x509_crt_t *) mhd_gtls_realloc_fast (*cert_list,
1129 i * 1044 i *
1130 sizeof 1045 sizeof
1131 (gnutls_x509_crt_t)); 1046 (gnutls_x509_crt_t));
@@ -1203,7 +1118,7 @@ parse_der_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
1203 i = *ncerts + 1; 1118 i = *ncerts + 1;
1204 1119
1205 *cert_list = 1120 *cert_list =
1206 (gnutls_x509_crt_t *) gnutls_realloc_fast (*cert_list, 1121 (gnutls_x509_crt_t *) mhd_gtls_realloc_fast (*cert_list,
1207 i * 1122 i *
1208 sizeof (gnutls_x509_crt_t)); 1123 sizeof (gnutls_x509_crt_t));
1209 1124
@@ -1237,26 +1152,26 @@ parse_der_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
1237} 1152}
1238 1153
1239/** 1154/**
1240 * gnutls_certificate_set_x509_trust_mem - Used to add trusted CAs in a gnutls_certificate_credentials_t structure 1155 * MHD_gnutls_certificate_set_x509_trust_mem - Used to add trusted CAs in a mhd_gtls_cert_credentials_t structure
1241 * @res: is an #gnutls_certificate_credentials_t structure. 1156 * @res: is an #mhd_gtls_cert_credentials_t structure.
1242 * @ca: is a list of trusted CAs or a DER certificate 1157 * @ca: is a list of trusted CAs or a DER certificate
1243 * @type: is DER or PEM 1158 * @type: is DER or PEM
1244 * 1159 *
1245 * This function adds the trusted CAs in order to verify client or 1160 * This function adds the trusted CAs in order to verify client or
1246 * server certificates. In case of a client this is not required to 1161 * server certificates. In case of a client this is not required to
1247 * be called if the certificates are not verified using 1162 * be called if the certificates are not verified using
1248 * gnutls_certificate_verify_peers2(). This function may be called 1163 * MHD_gtls_certificate_verify_peers2(). This function may be called
1249 * multiple times. 1164 * multiple times.
1250 * 1165 *
1251 * In case of a server the CAs set here will be sent to the client if 1166 * In case of a server the CAs set here will be sent to the client if
1252 * a certificate request is sent. This can be disabled using 1167 * a certificate request is sent. This can be disabled using
1253 * gnutls_certificate_send_x509_rdn_sequence(). 1168 * MHD_gnutls_certificate_send_x509_rdn_sequence().
1254 * 1169 *
1255 * Returns: the number of certificates processed or a negative value 1170 * Returns: the number of certificates processed or a negative value
1256 * on error. 1171 * on error.
1257 **/ 1172 **/
1258int 1173int
1259gnutls_certificate_set_x509_trust_mem (gnutls_certificate_credentials_t 1174MHD_gnutls_certificate_set_x509_trust_mem (mhd_gtls_cert_credentials_t
1260 res, const gnutls_datum_t * ca, 1175 res, const gnutls_datum_t * ca,
1261 gnutls_x509_crt_fmt_t type) 1176 gnutls_x509_crt_fmt_t type)
1262{ 1177{
@@ -1276,87 +1191,26 @@ gnutls_certificate_set_x509_trust_mem (gnutls_certificate_credentials_t
1276} 1191}
1277 1192
1278/** 1193/**
1279 * gnutls_certificate_set_x509_trust - Used to add trusted CAs in a gnutls_certificate_credentials_t structure 1194 * MHD_gnutls_certificate_set_x509_trust_file - Used to add trusted CAs in a mhd_gtls_cert_credentials_t structure
1280 * @res: is an #gnutls_certificate_credentials_t structure. 1195 * @res: is an #mhd_gtls_cert_credentials_t structure.
1281 * @ca_list: is a list of trusted CAs
1282 * @ca_list_size: holds the size of the CA list
1283 *
1284 * This function adds the trusted CAs in order to verify client
1285 * or server certificates. In case of a client this is not required
1286 * to be called if the certificates are not verified using
1287 * gnutls_certificate_verify_peers2().
1288 * This function may be called multiple times.
1289 *
1290 * In case of a server the CAs set here will be sent to the client if
1291 * a certificate request is sent. This can be disabled using
1292 * gnutls_certificate_send_x509_rdn_sequence().
1293 *
1294 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
1295 **/
1296int
1297gnutls_certificate_set_x509_trust (gnutls_certificate_credentials_t res,
1298 gnutls_x509_crt_t * ca_list,
1299 int ca_list_size)
1300{
1301 int ret, i, ret2;
1302
1303 res->x509_ca_list = gnutls_realloc_fast (res->x509_ca_list,
1304 (ca_list_size +
1305 res->x509_ncas) *
1306 sizeof (gnutls_x509_crt_t));
1307 if (res->x509_ca_list == NULL)
1308 {
1309 gnutls_assert ();
1310 return GNUTLS_E_MEMORY_ERROR;
1311 }
1312
1313 for (i = 0; i < ca_list_size; i++)
1314 {
1315 ret = gnutls_x509_crt_init (&res->x509_ca_list[res->x509_ncas]);
1316 if (ret < 0)
1317 {
1318 gnutls_assert ();
1319 return ret;
1320 }
1321
1322 ret = _gnutls_x509_crt_cpy (res->x509_ca_list[res->x509_ncas],
1323 ca_list[i]);
1324 if (ret < 0)
1325 {
1326 gnutls_assert ();
1327 gnutls_x509_crt_deinit (res->x509_ca_list[res->x509_ncas]);
1328 return ret;
1329 }
1330 res->x509_ncas++;
1331 }
1332
1333 if ((ret2 = generate_rdn_seq (res)) < 0)
1334 return ret2;
1335
1336 return 0;
1337}
1338
1339/**
1340 * gnutls_certificate_set_x509_trust_file - Used to add trusted CAs in a gnutls_certificate_credentials_t structure
1341 * @res: is an #gnutls_certificate_credentials_t structure.
1342 * @cafile: is a file containing the list of trusted CAs (DER or PEM list) 1196 * @cafile: is a file containing the list of trusted CAs (DER or PEM list)
1343 * @type: is PEM or DER 1197 * @type: is PEM or DER
1344 * 1198 *
1345 * This function adds the trusted CAs in order to verify client or 1199 * This function adds the trusted CAs in order to verify client or
1346 * server certificates. In case of a client this is not required to 1200 * server certificates. In case of a client this is not required to
1347 * be called if the certificates are not verified using 1201 * be called if the certificates are not verified using
1348 * gnutls_certificate_verify_peers2(). This function may be called 1202 * MHD_gtls_certificate_verify_peers2(). This function may be called
1349 * multiple times. 1203 * multiple times.
1350 * 1204 *
1351 * In case of a server the names of the CAs set here will be sent to 1205 * In case of a server the names of the CAs set here will be sent to
1352 * the client if a certificate request is sent. This can be disabled 1206 * the client if a certificate request is sent. This can be disabled
1353 * using gnutls_certificate_send_x509_rdn_sequence(). 1207 * using MHD_gnutls_certificate_send_x509_rdn_sequence().
1354 * 1208 *
1355 * Returns: number of certificates processed, or a negative value on 1209 * Returns: number of certificates processed, or a negative value on
1356 * error. 1210 * error.
1357 **/ 1211 **/
1358int 1212int
1359gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t 1213MHD_gnutls_certificate_set_x509_trust_file (mhd_gtls_cert_credentials_t
1360 res, const char *cafile, 1214 res, const char *cafile,
1361 gnutls_x509_crt_fmt_t type) 1215 gnutls_x509_crt_fmt_t type)
1362{ 1216{
@@ -1419,7 +1273,7 @@ parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
1419 { 1273 {
1420 1274
1421 *crl_list = 1275 *crl_list =
1422 (gnutls_x509_crl_t *) gnutls_realloc_fast (*crl_list, 1276 (gnutls_x509_crl_t *) mhd_gtls_realloc_fast (*crl_list,
1423 i * 1277 i *
1424 sizeof 1278 sizeof
1425 (gnutls_x509_crl_t)); 1279 (gnutls_x509_crl_t));
@@ -1487,7 +1341,7 @@ parse_der_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
1487 i = *ncrls + 1; 1341 i = *ncrls + 1;
1488 1342
1489 *crl_list = 1343 *crl_list =
1490 (gnutls_x509_crl_t *) gnutls_realloc_fast (*crl_list, 1344 (gnutls_x509_crl_t *) mhd_gtls_realloc_fast (*crl_list,
1491 i * 1345 i *
1492 sizeof (gnutls_x509_crl_t)); 1346 sizeof (gnutls_x509_crl_t));
1493 1347
@@ -1524,14 +1378,14 @@ parse_der_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
1524/* Reads a DER or PEM CRL from memory 1378/* Reads a DER or PEM CRL from memory
1525 */ 1379 */
1526static int 1380static int
1527read_crl_mem (gnutls_certificate_credentials_t res, const void *crl, 1381read_crl_mem (mhd_gtls_cert_credentials_t res, const void *crl,
1528 int crl_size, gnutls_x509_crt_fmt_t type) 1382 int crl_size, gnutls_x509_crt_fmt_t type)
1529{ 1383{
1530 int ret; 1384 int ret;
1531 1385
1532 /* allocate space for the certificate to add 1386 /* allocate space for the certificate to add
1533 */ 1387 */
1534 res->x509_crl_list = gnutls_realloc_fast (res->x509_crl_list, 1388 res->x509_crl_list = mhd_gtls_realloc_fast (res->x509_crl_list,
1535 (1 + 1389 (1 +
1536 res->x509_ncrls) * 1390 res->x509_ncrls) *
1537 sizeof (gnutls_x509_crl_t)); 1391 sizeof (gnutls_x509_crl_t));
@@ -1558,21 +1412,21 @@ read_crl_mem (gnutls_certificate_credentials_t res, const void *crl,
1558} 1412}
1559 1413
1560/** 1414/**
1561 * gnutls_certificate_set_x509_crl_mem - Used to add CRLs in a gnutls_certificate_credentials_t structure 1415 * MHD_gnutls_certificate_set_x509_crl_mem - Used to add CRLs in a mhd_gtls_cert_credentials_t structure
1562 * @res: is an #gnutls_certificate_credentials_t structure. 1416 * @res: is an #mhd_gtls_cert_credentials_t structure.
1563 * @CRL: is a list of trusted CRLs. They should have been verified before. 1417 * @CRL: is a list of trusted CRLs. They should have been verified before.
1564 * @type: is DER or PEM 1418 * @type: is DER or PEM
1565 * 1419 *
1566 * This function adds the trusted CRLs in order to verify client or 1420 * This function adds the trusted CRLs in order to verify client or
1567 * server certificates. In case of a client this is not required to 1421 * server certificates. In case of a client this is not required to
1568 * be called if the certificates are not verified using 1422 * be called if the certificates are not verified using
1569 * gnutls_certificate_verify_peers2(). This function may be called 1423 * MHD_gtls_certificate_verify_peers2(). This function may be called
1570 * multiple times. 1424 * multiple times.
1571 * 1425 *
1572 * Returns: number of CRLs processed, or a negative value on error. 1426 * Returns: number of CRLs processed, or a negative value on error.
1573 **/ 1427 **/
1574int 1428int
1575gnutls_certificate_set_x509_crl_mem (gnutls_certificate_credentials_t 1429MHD_gnutls_certificate_set_x509_crl_mem (mhd_gtls_cert_credentials_t
1576 res, const gnutls_datum_t * CRL, 1430 res, const gnutls_datum_t * CRL,
1577 gnutls_x509_crt_fmt_t type) 1431 gnutls_x509_crt_fmt_t type)
1578{ 1432{
@@ -1585,74 +1439,21 @@ gnutls_certificate_set_x509_crl_mem (gnutls_certificate_credentials_t
1585} 1439}
1586 1440
1587/** 1441/**
1588 * gnutls_certificate_set_x509_crl - Used to add CRLs in a gnutls_certificate_credentials_t structure 1442 * MHD_gnutls_certificate_set_x509_crl_file - Used to add CRLs in a mhd_gtls_cert_credentials_t structure
1589 * @res: is an #gnutls_certificate_credentials_t structure. 1443 * @res: is an #mhd_gtls_cert_credentials_t structure.
1590 * @crl_list: is a list of trusted CRLs. They should have been verified before.
1591 * @crl_list_size: holds the size of the crl_list
1592 *
1593 * This function adds the trusted CRLs in order to verify client or
1594 * server certificates. In case of a client this is not required to
1595 * be called if the certificates are not verified using
1596 * gnutls_certificate_verify_peers2(). This function may be called
1597 * multiple times.
1598 *
1599 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
1600 **/
1601int
1602gnutls_certificate_set_x509_crl (gnutls_certificate_credentials_t res,
1603 gnutls_x509_crl_t * crl_list,
1604 int crl_list_size)
1605{
1606 int ret, i;
1607
1608 res->x509_crl_list = gnutls_realloc_fast (res->x509_crl_list,
1609 (crl_list_size +
1610 res->x509_ncrls) *
1611 sizeof (gnutls_x509_crl_t));
1612 if (res->x509_crl_list == NULL)
1613 {
1614 gnutls_assert ();
1615 return GNUTLS_E_MEMORY_ERROR;
1616 }
1617
1618 for (i = 0; i < crl_list_size; i++)
1619 {
1620 ret = gnutls_x509_crl_init (&res->x509_crl_list[res->x509_ncrls]);
1621 if (ret < 0)
1622 {
1623 gnutls_assert ();
1624 return ret;
1625 }
1626
1627 ret = _gnutls_x509_crl_cpy (res->x509_crl_list[res->x509_ncrls],
1628 crl_list[i]);
1629 if (ret < 0)
1630 {
1631 gnutls_assert ();
1632 return ret;
1633 }
1634 res->x509_ncrls++;
1635 }
1636
1637 return 0;
1638}
1639
1640/**
1641 * gnutls_certificate_set_x509_crl_file - Used to add CRLs in a gnutls_certificate_credentials_t structure
1642 * @res: is an #gnutls_certificate_credentials_t structure.
1643 * @crlfile: is a file containing the list of verified CRLs (DER or PEM list) 1444 * @crlfile: is a file containing the list of verified CRLs (DER or PEM list)
1644 * @type: is PEM or DER 1445 * @type: is PEM or DER
1645 * 1446 *
1646 * This function adds the trusted CRLs in order to verify client or server 1447 * This function adds the trusted CRLs in order to verify client or server
1647 * certificates. In case of a client this is not required 1448 * certificates. In case of a client this is not required
1648 * to be called if the certificates are not verified using 1449 * to be called if the certificates are not verified using
1649 * gnutls_certificate_verify_peers2(). 1450 * MHD_gtls_certificate_verify_peers2().
1650 * This function may be called multiple times. 1451 * This function may be called multiple times.
1651 * 1452 *
1652 * Returns: number of CRLs processed or a negative value on error. 1453 * Returns: number of CRLs processed or a negative value on error.
1653 **/ 1454 **/
1654int 1455int
1655gnutls_certificate_set_x509_crl_file (gnutls_certificate_credentials_t 1456MHD_gnutls_certificate_set_x509_crl_file (mhd_gtls_cert_credentials_t
1656 res, const char *crlfile, 1457 res, const char *crlfile,
1657 gnutls_x509_crt_fmt_t type) 1458 gnutls_x509_crt_fmt_t type)
1658{ 1459{
@@ -1687,7 +1488,7 @@ gnutls_certificate_set_x509_crl_file (gnutls_certificate_credentials_t
1687#include <pkcs12.h> 1488#include <pkcs12.h>
1688 1489
1689static int 1490static int
1690parse_pkcs12 (gnutls_certificate_credentials_t res, 1491parse_pkcs12 (mhd_gtls_cert_credentials_t res,
1691 gnutls_pkcs12_t p12, 1492 gnutls_pkcs12_t p12,
1692 const char *password, 1493 const char *password,
1693 gnutls_x509_privkey_t * key, 1494 gnutls_x509_privkey_t * key,
@@ -1840,13 +1641,13 @@ done:
1840 1641
1841/** 1642/**
1842 * gnutls_certificate_set_x509_simple_pkcs12_file: 1643 * gnutls_certificate_set_x509_simple_pkcs12_file:
1843 * @res: is an #gnutls_certificate_credentials_t structure. 1644 * @res: is an #mhd_gtls_cert_credentials_t structure.
1844 * @pkcs12file: filename of file containing PKCS#12 blob. 1645 * @pkcs12file: filename of file containing PKCS#12 blob.
1845 * @type: is PEM or DER of the @pkcs12file. 1646 * @type: is PEM or DER of the @pkcs12file.
1846 * @password: optional password used to decrypt PKCS#12 file, bags and keys. 1647 * @password: optional password used to decrypt PKCS#12 file, bags and keys.
1847 * 1648 *
1848 * This function sets a certificate/private key pair and/or a CRL in 1649 * This function sets a certificate/private key pair and/or a CRL in
1849 * the gnutls_certificate_credentials_t structure. This function may 1650 * the mhd_gtls_cert_credentials_t structure. This function may
1850 * be called more than once (in case multiple keys/certificates exist 1651 * be called more than once (in case multiple keys/certificates exist
1851 * for the server). 1652 * for the server).
1852 * 1653 *
@@ -1870,107 +1671,107 @@ done:
1870 * 1671 *
1871 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 1672 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
1872 **/ 1673 **/
1873int 1674//int
1874 gnutls_certificate_set_x509_simple_pkcs12_file 1675// gnutls_certificate_set_x509_simple_pkcs12_file
1875 (gnutls_certificate_credentials_t res, const char *pkcs12file, 1676// (mhd_gtls_cert_credentials_t res, const char *pkcs12file,
1876 gnutls_x509_crt_fmt_t type, const char *password) 1677// gnutls_x509_crt_fmt_t type, const char *password)
1877{ 1678//{
1878 gnutls_pkcs12_t p12; 1679// gnutls_pkcs12_t p12;
1879 gnutls_datum_t p12blob; 1680// gnutls_datum_t p12blob;
1880 gnutls_x509_privkey_t key = NULL; 1681// gnutls_x509_privkey_t key = NULL;
1881 gnutls_x509_crt_t cert = NULL; 1682// gnutls_x509_crt_t cert = NULL;
1882 gnutls_x509_crl_t crl = NULL; 1683// gnutls_x509_crl_t crl = NULL;
1883 int ret; 1684// int ret;
1884 size_t size; 1685// size_t size;
1885 1686//
1886 ret = gnutls_pkcs12_init (&p12); 1687// ret = gnutls_pkcs12_init (&p12);
1887 if (ret < 0) 1688// if (ret < 0)
1888 { 1689// {
1889 gnutls_assert (); 1690// gnutls_assert ();
1890 return ret; 1691// return ret;
1891 } 1692// }
1892 1693//
1893 p12blob.data = read_binary_file (pkcs12file, &size); 1694// p12blob.data = read_binary_file (pkcs12file, &size);
1894 p12blob.size = (unsigned int) size; 1695// p12blob.size = (unsigned int) size;
1895 if (p12blob.data == NULL) 1696// if (p12blob.data == NULL)
1896 { 1697// {
1897 gnutls_assert (); 1698// gnutls_assert ();
1898 gnutls_pkcs12_deinit (p12); 1699// gnutls_pkcs12_deinit (p12);
1899 return GNUTLS_E_FILE_ERROR; 1700// return GNUTLS_E_FILE_ERROR;
1900 } 1701// }
1901 1702//
1902 ret = gnutls_pkcs12_import (p12, &p12blob, type, 0); 1703// ret = gnutls_pkcs12_import (p12, &p12blob, type, 0);
1903 free (p12blob.data); 1704// free (p12blob.data);
1904 if (ret < 0) 1705// if (ret < 0)
1905 { 1706// {
1906 gnutls_assert (); 1707// gnutls_assert ();
1907 gnutls_pkcs12_deinit (p12); 1708// gnutls_pkcs12_deinit (p12);
1908 return ret; 1709// return ret;
1909 } 1710// }
1910 1711//
1911 if (password) 1712// if (password)
1912 { 1713// {
1913 ret = gnutls_pkcs12_verify_mac (p12, password); 1714// ret = gnutls_pkcs12_verify_mac (p12, password);
1914 if (ret < 0) 1715// if (ret < 0)
1915 { 1716// {
1916 gnutls_assert (); 1717// gnutls_assert ();
1917 gnutls_pkcs12_deinit (p12); 1718// gnutls_pkcs12_deinit (p12);
1918 return ret; 1719// return ret;
1919 } 1720// }
1920 } 1721// }
1921 1722//
1922 ret = parse_pkcs12 (res, p12, password, &key, &cert, &crl); 1723// ret = parse_pkcs12 (res, p12, password, &key, &cert, &crl);
1923 gnutls_pkcs12_deinit (p12); 1724// gnutls_pkcs12_deinit (p12);
1924 if (ret < 0) 1725// if (ret < 0)
1925 { 1726// {
1926 gnutls_assert (); 1727// gnutls_assert ();
1927 return ret; 1728// return ret;
1928 } 1729// }
1929 1730//
1930 if (key && cert) 1731// if (key && cert)
1931 { 1732// {
1932 ret = gnutls_certificate_set_x509_key (res, &cert, 1, key); 1733// ret = gnutls_certificate_set_x509_key (res, &cert, 1, key);
1933 if (ret < 0) 1734// if (ret < 0)
1934 { 1735// {
1935 gnutls_assert (); 1736// gnutls_assert ();
1936 goto done; 1737// goto done;
1937 } 1738// }
1938 } 1739// }
1939 1740//
1940 if (crl) 1741// if (crl)
1941 { 1742// {
1942 ret = gnutls_certificate_set_x509_crl (res, &crl, 1); 1743// ret = gnutls_certificate_set_x509_crl (res, &crl, 1);
1943 if (ret < 0) 1744// if (ret < 0)
1944 { 1745// {
1945 gnutls_assert (); 1746// gnutls_assert ();
1946 goto done; 1747// goto done;
1947 } 1748// }
1948 } 1749// }
1949 1750//
1950 ret = 0; 1751// ret = 0;
1951 1752//
1952done: 1753//done:
1953 if (cert) 1754// if (cert)
1954 gnutls_x509_crt_deinit (cert); 1755// gnutls_x509_crt_deinit (cert);
1955 if (key) 1756// if (key)
1956 gnutls_x509_privkey_deinit (key); 1757// gnutls_x509_privkey_deinit (key);
1957 if (crl) 1758// if (crl)
1958 gnutls_x509_crl_deinit (crl); 1759// gnutls_x509_crl_deinit (crl);
1959 1760//
1960 return ret; 1761// return ret;
1961} 1762//}
1962 1763
1963 1764
1964/** 1765/**
1965 * gnutls_certificate_free_crls - Used to free all the CRLs from a gnutls_certificate_credentials_t structure 1766 * MHD_gnutls_certificate_free_crls - Used to free all the CRLs from a mhd_gtls_cert_credentials_t structure
1966 * @sc: is an #gnutls_certificate_credentials_t structure. 1767 * @sc: is an #mhd_gtls_cert_credentials_t structure.
1967 * 1768 *
1968 * This function will delete all the CRLs associated 1769 * This function will delete all the CRLs associated
1969 * with the given credentials. 1770 * with the given credentials.
1970 * 1771 *
1971 **/ 1772 **/
1972void 1773void
1973gnutls_certificate_free_crls (gnutls_certificate_credentials_t sc) 1774MHD_gnutls_certificate_free_crls (mhd_gtls_cert_credentials_t sc)
1974{ 1775{
1975 unsigned j; 1776 unsigned j;
1976 1777
diff --git a/src/daemon/https/tls/gnutls_x509.h b/src/daemon/https/tls/gnutls_x509.h
index 3aa0d915..aaf32cae 100644
--- a/src/daemon/https/tls/gnutls_x509.h
+++ b/src/daemon/https/tls/gnutls_x509.h
@@ -24,7 +24,7 @@
24 24
25#include <libtasn1.h> 25#include <libtasn1.h>
26 26
27int _gnutls_x509_cert_verify_peers (gnutls_session_t session, 27int _gnutls_x509_cert_verify_peers (mhd_gtls_session_t session,
28 unsigned int *status); 28 unsigned int *status);
29 29
30#define PEM_CERT_SEP2 "-----BEGIN X509 CERTIFICATE" 30#define PEM_CERT_SEP2 "-----BEGIN X509 CERTIFICATE"
diff --git a/src/daemon/https/tls/x509_b64.c b/src/daemon/https/tls/x509_b64.c
index 50a9b475..5bb2b4a5 100644
--- a/src/daemon/https/tls/x509_b64.c
+++ b/src/daemon/https/tls/x509_b64.c
@@ -287,7 +287,7 @@ _gnutls_fbase64_encode (const char *msg, const uint8_t * data,
287} 287}
288 288
289/** 289/**
290 * gnutls_pem_base64_encode - This function will convert raw data to Base64 encoded 290 * MHD_gtls_pem_base64_encode - This function will convert raw data to Base64 encoded
291 * @msg: is a message to be put in the header 291 * @msg: is a message to be put in the header
292 * @data: contain the raw data 292 * @data: contain the raw data
293 * @result: the place where base64 data will be copied 293 * @result: the place where base64 data will be copied
@@ -302,7 +302,7 @@ _gnutls_fbase64_encode (const char *msg, const uint8_t * data,
302 * 302 *
303 **/ 303 **/
304int 304int
305gnutls_pem_base64_encode (const char *msg, const gnutls_datum_t * data, 305MHD_gtls_pem_base64_encode (const char *msg, const gnutls_datum_t * data,
306 char *result, size_t * result_size) 306 char *result, size_t * result_size)
307{ 307{
308 opaque *ret; 308 opaque *ret;
@@ -329,7 +329,7 @@ gnutls_pem_base64_encode (const char *msg, const gnutls_datum_t * data,
329} 329}
330 330
331/** 331/**
332 * gnutls_pem_base64_encode_alloc - This function will convert raw data to Base64 encoded 332 * MHD_gtls_pem_base64_encode_alloc - This function will convert raw data to Base64 encoded
333 * @msg: is a message to be put in the encoded header 333 * @msg: is a message to be put in the encoded header
334 * @data: contains the raw data 334 * @data: contains the raw data
335 * @result: will hold the newly allocated encoded data 335 * @result: will hold the newly allocated encoded data
@@ -342,7 +342,7 @@ gnutls_pem_base64_encode (const char *msg, const gnutls_datum_t * data,
342 * 342 *
343 **/ 343 **/
344int 344int
345gnutls_pem_base64_encode_alloc (const char *msg, 345MHD_gtls_pem_base64_encode_alloc (const char *msg,
346 const gnutls_datum_t * data, 346 const gnutls_datum_t * data,
347 gnutls_datum_t * result) 347 gnutls_datum_t * result)
348{ 348{
@@ -436,9 +436,9 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
436 int kdata_size; 436 int kdata_size;
437 char pem_header[128]; 437 char pem_header[128];
438 438
439 _gnutls_str_cpy (pem_header, sizeof (pem_header), top); 439 mhd_gtls_str_cpy (pem_header, sizeof (pem_header), top);
440 if (header != NULL) 440 if (header != NULL)
441 _gnutls_str_cat (pem_header, sizeof (pem_header), header); 441 mhd_gtls_str_cat (pem_header, sizeof (pem_header), header);
442 442
443 rdata = memmem (data, data_size, pem_header, strlen (pem_header)); 443 rdata = memmem (data, data_size, pem_header, strlen (pem_header));
444 444
@@ -520,7 +520,7 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
520} 520}
521 521
522/** 522/**
523 * gnutls_pem_base64_decode - This function will decode base64 encoded data 523 * MHD_gtls_pem_base64_decode - This function will decode base64 encoded data
524 * @header: A null terminated string with the PEM header (eg. CERTIFICATE) 524 * @header: A null terminated string with the PEM header (eg. CERTIFICATE)
525 * @b64_data: contain the encoded data 525 * @b64_data: contain the encoded data
526 * @result: the place where decoded data will be copied 526 * @result: the place where decoded data will be copied
@@ -534,7 +534,7 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
534 * or 0 on success. 534 * or 0 on success.
535 **/ 535 **/
536int 536int
537gnutls_pem_base64_decode (const char *header, 537MHD_gtls_pem_base64_decode (const char *header,
538 const gnutls_datum_t * b64_data, 538 const gnutls_datum_t * b64_data,
539 unsigned char *result, size_t * result_size) 539 unsigned char *result, size_t * result_size)
540{ 540{
@@ -563,7 +563,7 @@ gnutls_pem_base64_decode (const char *header,
563} 563}
564 564
565/** 565/**
566 * gnutls_pem_base64_decode_alloc - This function will decode base64 encoded data 566 * MHD_gtls_pem_base64_decode_alloc - This function will decode base64 encoded data
567 * @header: The PEM header (eg. CERTIFICATE) 567 * @header: The PEM header (eg. CERTIFICATE)
568 * @b64_data: contains the encoded data 568 * @b64_data: contains the encoded data
569 * @result: the place where decoded data lie 569 * @result: the place where decoded data lie
@@ -578,7 +578,7 @@ gnutls_pem_base64_decode (const char *header,
578 * 578 *
579 **/ 579 **/
580int 580int
581gnutls_pem_base64_decode_alloc (const char *header, 581MHD_gtls_pem_base64_decode_alloc (const char *header,
582 const gnutls_datum_t * b64_data, 582 const gnutls_datum_t * b64_data,
583 gnutls_datum_t * result) 583 gnutls_datum_t * result)
584{ 584{