aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/daemon/connection.c2
-rw-r--r--src/daemon/connection_https.c10
-rw-r--r--src/daemon/daemon.c70
-rw-r--r--src/daemon/https/gnutls.h680
-rw-r--r--src/daemon/https/lgl/Makefile.am1
-rw-r--r--src/daemon/https/lgl/des.c40
-rw-r--r--src/daemon/https/lgl/des.h28
-rw-r--r--src/daemon/https/lgl/gc-gnulib.c122
-rw-r--r--src/daemon/https/lgl/gc-libgcrypt.c74
-rw-r--r--src/daemon/https/lgl/gc-pbkdf2-sha1.c6
-rw-r--r--src/daemon/https/lgl/gc.h78
-rw-r--r--src/daemon/https/lgl/hmac-md5.c34
-rw-r--r--src/daemon/https/lgl/hmac-sha1.c34
-rw-r--r--src/daemon/https/lgl/hmac.h4
-rw-r--r--src/daemon/https/lgl/md5.c58
-rw-r--r--src/daemon/https/lgl/md5.h36
-rw-r--r--src/daemon/https/lgl/memmem.c4
-rw-r--r--src/daemon/https/lgl/memxor.c6
-rw-r--r--src/daemon/https/lgl/memxor.h6
-rw-r--r--src/daemon/https/lgl/sha1.c46
-rw-r--r--src/daemon/https/lgl/sha1.h20
-rw-r--r--src/daemon/https/lgl/time_r.c46
-rw-r--r--src/daemon/https/minitasn1/coding.c206
-rw-r--r--src/daemon/https/minitasn1/decoding.c536
-rw-r--r--src/daemon/https/minitasn1/element.c198
-rw-r--r--src/daemon/https/minitasn1/element.h6
-rw-r--r--src/daemon/https/minitasn1/errors.c20
-rw-r--r--src/daemon/https/minitasn1/errors.h2
-rw-r--r--src/daemon/https/minitasn1/gstr.c4
-rw-r--r--src/daemon/https/minitasn1/gstr.h8
-rw-r--r--src/daemon/https/minitasn1/libtasn1.h68
-rw-r--r--src/daemon/https/minitasn1/mem.h20
-rw-r--r--src/daemon/https/minitasn1/parser_aux.c224
-rw-r--r--src/daemon/https/minitasn1/parser_aux.h40
-rw-r--r--src/daemon/https/minitasn1/structure.c242
-rw-r--r--src/daemon/https/minitasn1/structure.h10
-rw-r--r--src/daemon/https/tls/auth_anon.c76
-rw-r--r--src/daemon/https/tls/auth_anon.h16
-rw-r--r--src/daemon/https/tls/auth_cert.c408
-rw-r--r--src/daemon/https/tls/auth_cert.h84
-rw-r--r--src/daemon/https/tls/auth_dh_common.c142
-rw-r--r--src/daemon/https/tls/auth_dh_common.h18
-rw-r--r--src/daemon/https/tls/auth_dhe.c150
-rw-r--r--src/daemon/https/tls/auth_rsa.c169
-rw-r--r--src/daemon/https/tls/auth_rsa_export.c158
-rw-r--r--src/daemon/https/tls/debug.c22
-rw-r--r--src/daemon/https/tls/debug.h8
-rw-r--r--src/daemon/https/tls/ext_cert_type.c48
-rw-r--r--src/daemon/https/tls/ext_cert_type.h4
-rw-r--r--src/daemon/https/tls/ext_max_record.c28
-rw-r--r--src/daemon/https/tls/ext_max_record.h8
-rw-r--r--src/daemon/https/tls/ext_oprfi.c58
-rw-r--r--src/daemon/https/tls/ext_oprfi.h4
-rw-r--r--src/daemon/https/tls/ext_server_name.c40
-rw-r--r--src/daemon/https/tls/ext_server_name.h4
-rw-r--r--src/daemon/https/tls/gnutls_alert.c48
-rw-r--r--src/daemon/https/tls/gnutls_algorithms.c416
-rw-r--r--src/daemon/https/tls/gnutls_algorithms.h98
-rw-r--r--src/daemon/https/tls/gnutls_anon_cred.c48
-rw-r--r--src/daemon/https/tls/gnutls_asn1_tab.c2
-rw-r--r--src/daemon/https/tls/gnutls_auth.c104
-rw-r--r--src/daemon/https/tls/gnutls_auth.h28
-rw-r--r--src/daemon/https/tls/gnutls_auth_int.h8
-rw-r--r--src/daemon/https/tls/gnutls_buffers.c302
-rw-r--r--src/daemon/https/tls/gnutls_buffers.h54
-rw-r--r--src/daemon/https/tls/gnutls_cert.c282
-rw-r--r--src/daemon/https/tls/gnutls_cert.h32
-rw-r--r--src/daemon/https/tls/gnutls_cipher.c156
-rw-r--r--src/daemon/https/tls/gnutls_cipher.h12
-rw-r--r--src/daemon/https/tls/gnutls_cipher_int.c48
-rw-r--r--src/daemon/https/tls/gnutls_cipher_int.h16
-rw-r--r--src/daemon/https/tls/gnutls_compress.c20
-rw-r--r--src/daemon/https/tls/gnutls_compress.h12
-rw-r--r--src/daemon/https/tls/gnutls_compress_int.c66
-rw-r--r--src/daemon/https/tls/gnutls_compress_int.h8
-rw-r--r--src/daemon/https/tls/gnutls_constate.c374
-rw-r--r--src/daemon/https/tls/gnutls_constate.h20
-rw-r--r--src/daemon/https/tls/gnutls_datum.c24
-rw-r--r--src/daemon/https/tls/gnutls_datum.h26
-rw-r--r--src/daemon/https/tls/gnutls_dh.c54
-rw-r--r--src/daemon/https/tls/gnutls_dh.h16
-rw-r--r--src/daemon/https/tls/gnutls_dh_primes.c48
-rw-r--r--src/daemon/https/tls/gnutls_errors.c24
-rw-r--r--src/daemon/https/tls/gnutls_errors.h58
-rw-r--r--src/daemon/https/tls/gnutls_extensions.c118
-rw-r--r--src/daemon/https/tls/gnutls_extensions.h24
-rw-r--r--src/daemon/https/tls/gnutls_global.c148
-rw-r--r--src/daemon/https/tls/gnutls_global.h14
-rw-r--r--src/daemon/https/tls/gnutls_handshake.c954
-rw-r--r--src/daemon/https/tls/gnutls_handshake.h38
-rw-r--r--src/daemon/https/tls/gnutls_hash_int.c162
-rw-r--r--src/daemon/https/tls/gnutls_hash_int.h26
-rw-r--r--src/daemon/https/tls/gnutls_int.h176
-rw-r--r--src/daemon/https/tls/gnutls_kx.c228
-rw-r--r--src/daemon/https/tls/gnutls_kx.h26
-rw-r--r--src/daemon/https/tls/gnutls_mem.c42
-rw-r--r--src/daemon/https/tls/gnutls_mem.h30
-rw-r--r--src/daemon/https/tls/gnutls_mpi.c86
-rw-r--r--src/daemon/https/tls/gnutls_mpi.h66
-rw-r--r--src/daemon/https/tls/gnutls_num.c28
-rw-r--r--src/daemon/https/tls/gnutls_num.h26
-rw-r--r--src/daemon/https/tls/gnutls_pk.c316
-rw-r--r--src/daemon/https/tls/gnutls_pk.h20
-rw-r--r--src/daemon/https/tls/gnutls_priority.c114
-rw-r--r--src/daemon/https/tls/gnutls_record.c336
-rw-r--r--src/daemon/https/tls/gnutls_record.h12
-rw-r--r--src/daemon/https/tls/gnutls_rsa_export.c52
-rw-r--r--src/daemon/https/tls/gnutls_rsa_export.h6
-rw-r--r--src/daemon/https/tls/gnutls_session.c4
-rw-r--r--src/daemon/https/tls/gnutls_session_pack.c366
-rw-r--r--src/daemon/https/tls/gnutls_session_pack.h8
-rw-r--r--src/daemon/https/tls/gnutls_sig.c216
-rw-r--r--src/daemon/https/tls/gnutls_sig.h36
-rw-r--r--src/daemon/https/tls/gnutls_state.c410
-rw-r--r--src/daemon/https/tls/gnutls_state.h36
-rw-r--r--src/daemon/https/tls/gnutls_str.c42
-rw-r--r--src/daemon/https/tls/gnutls_str.h32
-rw-r--r--src/daemon/https/tls/gnutls_supplemental.c64
-rw-r--r--src/daemon/https/tls/gnutls_supplemental.h6
-rw-r--r--src/daemon/https/tls/gnutls_ui.c190
-rw-r--r--src/daemon/https/tls/gnutls_x509.c424
-rw-r--r--src/daemon/https/tls/gnutls_x509.h18
-rw-r--r--src/daemon/https/tls/pkix_asn1_tab.c2
-rw-r--r--src/daemon/https/tls/x509_b64.c104
-rw-r--r--src/daemon/https/tls/x509_b64.h8
-rw-r--r--src/daemon/https/x509/common.c484
-rw-r--r--src/daemon/https/x509/common.h62
-rw-r--r--src/daemon/https/x509/crl.c264
-rw-r--r--src/daemon/https/x509/crq.c288
-rw-r--r--src/daemon/https/x509/crq.h4
-rw-r--r--src/daemon/https/x509/dn.c434
-rw-r--r--src/daemon/https/x509/dn.h16
-rw-r--r--src/daemon/https/x509/dsa.c30
-rw-r--r--src/daemon/https/x509/dsa.h2
-rw-r--r--src/daemon/https/x509/extensions.c488
-rw-r--r--src/daemon/https/x509/extensions.h42
-rw-r--r--src/daemon/https/x509/mpi.c274
-rw-r--r--src/daemon/https/x509/mpi.h32
-rw-r--r--src/daemon/https/x509/pkcs12.c502
-rw-r--r--src/daemon/https/x509/pkcs12.h142
-rw-r--r--src/daemon/https/x509/pkcs12_bag.c284
-rw-r--r--src/daemon/https/x509/pkcs12_encr.c38
-rw-r--r--src/daemon/https/x509/pkcs7.c358
-rw-r--r--src/daemon/https/x509/pkcs7.h4
-rw-r--r--src/daemon/https/x509/privkey.h6
-rw-r--r--src/daemon/https/x509/privkey_pkcs8.c692
-rw-r--r--src/daemon/https/x509/rfc2818.h2
-rw-r--r--src/daemon/https/x509/rfc2818_hostname.c18
-rw-r--r--src/daemon/https/x509/sign.c162
-rw-r--r--src/daemon/https/x509/sign.h18
-rw-r--r--src/daemon/https/x509/verify.h16
-rw-r--r--src/daemon/https/x509/x509.c1068
-rw-r--r--src/daemon/https/x509/x509.h648
-rw-r--r--src/daemon/https/x509/x509_privkey.c508
-rw-r--r--src/daemon/https/x509/x509_verify.c386
-rw-r--r--src/daemon/internal.h10
156 files changed, 9547 insertions, 9587 deletions
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
index 08e9367c..9c37a5c0 100644
--- a/src/daemon/connection.c
+++ b/src/daemon/connection.c
@@ -1632,7 +1632,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1632#if HTTPS_SUPPORT 1632#if HTTPS_SUPPORT
1633 if (connection->daemon->options & MHD_USE_SSL) 1633 if (connection->daemon->options & MHD_USE_SSL)
1634 { 1634 {
1635 ret = MHD_gnutls_record_send (connection->tls_session, 1635 ret = MHD__gnutls_record_send (connection->tls_session,
1636 &connection->response->data 1636 &connection->response->data
1637 [connection-> 1637 [connection->
1638 response_write_position - 1638 response_write_position -
diff --git a/src/daemon/connection_https.c b/src/daemon/connection_https.c
index e9a2226f..622c2564 100644
--- a/src/daemon/connection_https.c
+++ b/src/daemon/connection_https.c
@@ -99,7 +99,7 @@ MHD_tls_connection_close (struct MHD_Connection *connection,
99 enum MHD_RequestTerminationCode 99 enum MHD_RequestTerminationCode
100 termination_code) 100 termination_code)
101{ 101{
102 MHD_gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR); 102 MHD__gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR);
103 connection->tls_session->internals.read_eof = 1; 103 connection->tls_session->internals.read_eof = 1;
104 SHUTDOWN (connection->socket_fd, SHUT_RDWR); 104 SHUTDOWN (connection->socket_fd, SHUT_RDWR);
105 CLOSE (connection->socket_fd); 105 CLOSE (connection->socket_fd);
@@ -211,7 +211,7 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
211 if (connection->state == MHD_TLS_CONNECTION_INIT || 211 if (connection->state == MHD_TLS_CONNECTION_INIT ||
212 connection->state == MHD_TLS_HELLO_REQUEST) 212 connection->state == MHD_TLS_HELLO_REQUEST)
213 { 213 {
214 ret = MHD_gnutls_handshake (connection->tls_session); 214 ret = MHD__gnutls_handshake (connection->tls_session);
215 if (ret == 0) 215 if (ret == 0)
216 { 216 {
217 /* set connection state to enable HTTP processing */ 217 /* set connection state to enable HTTP processing */
@@ -249,10 +249,10 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
249 249
250 case GNUTLS_ALERT: 250 case GNUTLS_ALERT:
251 /* 251 /*
252 * this call of mhd_gtls_recv_int expects 0 bytes read. 252 * this call of MHD_gtls_recv_int expects 0 bytes read.
253 * done to decrypt alert message 253 * done to decrypt alert message
254 */ 254 */
255 mhd_gtls_recv_int (connection->tls_session, GNUTLS_ALERT, 255 MHD_gtls_recv_int (connection->tls_session, GNUTLS_ALERT,
256 GNUTLS_HANDSHAKE_FINISHED, 0, 0); 256 GNUTLS_HANDSHAKE_FINISHED, 0, 0);
257 257
258 /* CLOSE_NOTIFY */ 258 /* CLOSE_NOTIFY */
@@ -269,7 +269,7 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
269#if HAVE_MESSAGES 269#if HAVE_MESSAGES
270 MHD_DLOG (connection->daemon, 270 MHD_DLOG (connection->daemon,
271 "Received TLS alert: %s\n", 271 "Received TLS alert: %s\n",
272 MHD_gnutls_alert_get_name ((int) connection->tls_session-> 272 MHD__gnutls_alert_get_name ((int) connection->tls_session->
273 internals.last_alert)); 273 internals.last_alert));
274#endif 274#endif
275 return MHD_YES; 275 return MHD_YES;
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 77dcf990..860d3b1f 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -67,12 +67,12 @@
67 67
68#if HTTPS_SUPPORT 68#if HTTPS_SUPPORT
69/** 69/**
70 * Note: code duplication with code in gnutls_priority.c 70 * Note: code duplication with code in MHD_gnutls_priority.c
71 * 71 *
72 * @return 0 72 * @return 0
73 */ 73 */
74static int 74static int
75_set_priority (mhd_gtls_priority_st * st, const int *list) 75_set_priority (MHD_gtls_priority_st * st, const int *list)
76{ 76{
77 int num = 0; 77 int num = 0;
78 78
@@ -98,7 +98,7 @@ recv_tls_adapter (struct MHD_Connection* connection,
98 void *other, 98 void *other,
99 size_t i) 99 size_t i)
100{ 100{
101 return MHD_gnutls_record_recv(connection->tls_session, 101 return MHD__gnutls_record_recv(connection->tls_session,
102 other, i); 102 other, i);
103} 103}
104 104
@@ -115,7 +115,7 @@ send_tls_adapter (struct MHD_Connection* connection,
115 const void *other, 115 const void *other,
116 size_t i) 116 size_t i)
117{ 117{
118 return MHD_gnutls_record_send(connection->tls_session, 118 return MHD__gnutls_record_send(connection->tls_session,
119 other, i); 119 other, i);
120} 120}
121 121
@@ -128,8 +128,8 @@ send_tls_adapter (struct MHD_Connection* connection,
128static int 128static int
129MHD_init_daemon_certificate (struct MHD_Daemon *daemon) 129MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
130{ 130{
131 gnutls_datum_t key; 131 MHD_gnutls_datum_t key;
132 gnutls_datum_t cert; 132 MHD_gnutls_datum_t cert;
133 133
134 /* certificate & key loaded from memory */ 134 /* certificate & key loaded from memory */
135 if (daemon->https_mem_cert && daemon->https_mem_key) 135 if (daemon->https_mem_cert && daemon->https_mem_key)
@@ -139,7 +139,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
139 cert.data = (unsigned char *) daemon->https_mem_cert; 139 cert.data = (unsigned char *) daemon->https_mem_cert;
140 cert.size = strlen (daemon->https_mem_cert); 140 cert.size = strlen (daemon->https_mem_cert);
141 141
142 return MHD_gnutls_certificate_set_x509_key_mem (daemon->x509_cred, 142 return MHD__gnutls_certificate_set_x509_key_mem (daemon->x509_cred,
143 &cert, &key, 143 &cert, &key,
144 GNUTLS_X509_FMT_PEM); 144 GNUTLS_X509_FMT_PEM);
145 } 145 }
@@ -160,15 +160,15 @@ MHD_TLS_init (struct MHD_Daemon *daemon)
160 switch (daemon->cred_type) 160 switch (daemon->cred_type)
161 { 161 {
162 case MHD_GNUTLS_CRD_ANON: 162 case MHD_GNUTLS_CRD_ANON:
163 if ( (0 != MHD_gnutls_anon_allocate_server_credentials (&daemon->anon_cred)) || 163 if ( (0 != MHD__gnutls_anon_allocate_server_credentials (&daemon->anon_cred)) ||
164 (0 != MHD_gnutls_dh_params_init (&daemon->dh_params)) ) 164 (0 != MHD__gnutls_dh_params_init (&daemon->dh_params)) )
165 return GNUTLS_E_MEMORY_ERROR; 165 return GNUTLS_E_MEMORY_ERROR;
166 MHD_gnutls_dh_params_generate2 (daemon->dh_params, 1024); 166 MHD__gnutls_dh_params_generate2 (daemon->dh_params, 1024);
167 MHD_gnutls_anon_set_server_dh_params (daemon->anon_cred, 167 MHD__gnutls_anon_set_server_dh_params (daemon->anon_cred,
168 daemon->dh_params); 168 daemon->dh_params);
169 return 0; 169 return 0;
170 case MHD_GNUTLS_CRD_CERTIFICATE: 170 case MHD_GNUTLS_CRD_CERTIFICATE:
171 if (0 != MHD_gnutls_certificate_allocate_credentials (&daemon->x509_cred)) 171 if (0 != MHD__gnutls_certificate_allocate_credentials (&daemon->x509_cred))
172 return GNUTLS_E_MEMORY_ERROR; 172 return GNUTLS_E_MEMORY_ERROR;
173 return MHD_init_daemon_certificate (daemon); 173 return MHD_init_daemon_certificate (daemon);
174 default: 174 default:
@@ -491,21 +491,21 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
491 connection->send_cls = &send_tls_adapter; 491 connection->send_cls = &send_tls_adapter;
492 connection->state = MHD_TLS_CONNECTION_INIT; 492 connection->state = MHD_TLS_CONNECTION_INIT;
493 MHD_set_https_calbacks (connection); 493 MHD_set_https_calbacks (connection);
494 MHD_gnutls_init (&connection->tls_session, GNUTLS_SERVER); 494 MHD__gnutls_init (&connection->tls_session, GNUTLS_SERVER);
495 MHD_gnutls_priority_set (connection->tls_session, connection->daemon->priority_cache); 495 MHD__gnutls_priority_set (connection->tls_session, connection->daemon->priority_cache);
496 switch (connection->daemon->cred_type) 496 switch (connection->daemon->cred_type)
497 { 497 {
498 /* set needed credentials for certificate authentication. */ 498 /* set needed credentials for certificate authentication. */
499 case MHD_GNUTLS_CRD_CERTIFICATE: 499 case MHD_GNUTLS_CRD_CERTIFICATE:
500 MHD_gnutls_credentials_set (connection->tls_session, 500 MHD__gnutls_credentials_set (connection->tls_session,
501 MHD_GNUTLS_CRD_CERTIFICATE, 501 MHD_GNUTLS_CRD_CERTIFICATE,
502 connection->daemon->x509_cred); 502 connection->daemon->x509_cred);
503 break; 503 break;
504 case MHD_GNUTLS_CRD_ANON: 504 case MHD_GNUTLS_CRD_ANON:
505 /* set needed credentials for anonymous authentication. */ 505 /* set needed credentials for anonymous authentication. */
506 MHD_gnutls_credentials_set (connection->tls_session, MHD_GNUTLS_CRD_ANON, 506 MHD__gnutls_credentials_set (connection->tls_session, MHD_GNUTLS_CRD_ANON,
507 connection->daemon->anon_cred); 507 connection->daemon->anon_cred);
508 MHD_gnutls_dh_set_prime_bits (connection->tls_session, 1024); 508 MHD__gnutls_dh_set_prime_bits (connection->tls_session, 1024);
509 break; 509 break;
510 default: 510 default:
511#if HAVE_MESSAGES 511#if HAVE_MESSAGES
@@ -515,12 +515,12 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
515#endif 515#endif
516 abort(); 516 abort();
517 } 517 }
518 MHD_gnutls_transport_set_ptr (connection->tls_session, 518 MHD__gnutls_transport_set_ptr (connection->tls_session,
519 (gnutls_transport_ptr_t) connection); 519 (MHD_gnutls_transport_ptr_t) connection);
520 MHD_gnutls_transport_set_pull_function(connection->tls_session, 520 MHD__gnutls_transport_set_pull_function(connection->tls_session,
521 (mhd_gtls_pull_func) &recv_param_adapter); 521 (MHD_gtls_pull_func) &recv_param_adapter);
522 MHD_gnutls_transport_set_push_function(connection->tls_session, 522 MHD__gnutls_transport_set_push_function(connection->tls_session,
523 (mhd_gtls_push_func) &send_param_adapter); 523 (MHD_gtls_push_func) &send_param_adapter);
524 } 524 }
525#endif 525#endif
526 526
@@ -583,7 +583,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
583 MHD_pool_destroy (pos->pool); 583 MHD_pool_destroy (pos->pool);
584#if HTTPS_SUPPORT 584#if HTTPS_SUPPORT
585 if (pos->tls_session != NULL) 585 if (pos->tls_session != NULL)
586 MHD_gnutls_deinit (pos->tls_session); 586 MHD__gnutls_deinit (pos->tls_session);
587#endif 587#endif
588 free (pos->addr); 588 free (pos->addr);
589 free (pos); 589 free (pos);
@@ -859,10 +859,10 @@ MHD_start_daemon_va (unsigned int options,
859#if HTTPS_SUPPORT 859#if HTTPS_SUPPORT
860 if (options & MHD_USE_SSL) 860 if (options & MHD_USE_SSL)
861 { 861 {
862 /* lock gnutls_global mutex since it uses reference counting */ 862 /* lock MHD_gnutls_global mutex since it uses reference counting */
863 pthread_mutex_lock (&gnutls_init_mutex); 863 pthread_mutex_lock (&MHD_gnutls_init_mutex);
864 MHD_gnutls_global_init (); 864 MHD__gnutls_global_init ();
865 pthread_mutex_unlock (&gnutls_init_mutex); 865 pthread_mutex_unlock (&MHD_gnutls_init_mutex);
866 /* set default priorities */ 866 /* set default priorities */
867 MHD_tls_set_default_priority (&retVal->priority_cache, "", NULL); 867 MHD_tls_set_default_priority (&retVal->priority_cache, "", NULL);
868 retVal->cred_type = MHD_GNUTLS_CRD_CERTIFICATE; 868 retVal->cred_type = MHD_GNUTLS_CRD_CERTIFICATE;
@@ -1104,15 +1104,15 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
1104#if HTTPS_SUPPORT 1104#if HTTPS_SUPPORT
1105 if (daemon->options & MHD_USE_SSL) 1105 if (daemon->options & MHD_USE_SSL)
1106 { 1106 {
1107 MHD_gnutls_priority_deinit (daemon->priority_cache); 1107 MHD__gnutls_priority_deinit (daemon->priority_cache);
1108 if (daemon->x509_cred) 1108 if (daemon->x509_cred)
1109 MHD_gnutls_certificate_free_credentials (daemon->x509_cred); 1109 MHD__gnutls_certificate_free_credentials (daemon->x509_cred);
1110 if (daemon->anon_cred) 1110 if (daemon->anon_cred)
1111 MHD_gnutls_anon_free_server_credentials (daemon->anon_cred); 1111 MHD__gnutls_anon_free_server_credentials (daemon->anon_cred);
1112 /* lock gnutls_global mutex since it uses reference counting */ 1112 /* lock MHD_gnutls_global mutex since it uses reference counting */
1113 pthread_mutex_lock (&gnutls_init_mutex); 1113 pthread_mutex_lock (&MHD_gnutls_init_mutex);
1114 MHD_gnutls_global_deinit (); 1114 MHD__gnutls_global_deinit ();
1115 pthread_mutex_unlock (&gnutls_init_mutex); 1115 pthread_mutex_unlock (&MHD_gnutls_init_mutex);
1116 } 1116 }
1117#endif 1117#endif
1118 free (daemon); 1118 free (daemon);
diff --git a/src/daemon/https/gnutls.h b/src/daemon/https/gnutls.h
index ed939584..fb1b280f 100644
--- a/src/daemon/https/gnutls.h
+++ b/src/daemon/https/gnutls.h
@@ -60,7 +60,7 @@ extern "C"
60 { 60 {
61 GNUTLS_PARAMS_RSA_EXPORT = 1, 61 GNUTLS_PARAMS_RSA_EXPORT = 1,
62 GNUTLS_PARAMS_DH 62 GNUTLS_PARAMS_DH
63 } gnutls_params_type_t; 63 } MHD_gnutls_params_type_t;
64 64
65 /* exported for other gnutls headers. This is the maximum number of 65 /* exported for other gnutls headers. This is the maximum number of
66 * algorithms (ciphers, kx or macs). 66 * algorithms (ciphers, kx or macs).
@@ -72,13 +72,13 @@ extern "C"
72 { 72 {
73 GNUTLS_SERVER = 1, 73 GNUTLS_SERVER = 1,
74 GNUTLS_CLIENT 74 GNUTLS_CLIENT
75 } gnutls_connection_end_t; 75 } MHD_gnutls_connection_end_t;
76 76
77 typedef enum 77 typedef enum
78 { 78 {
79 GNUTLS_AL_WARNING = 1, 79 GNUTLS_AL_WARNING = 1,
80 GNUTLS_AL_FATAL 80 GNUTLS_AL_FATAL
81 } gnutls_alert_level_t; 81 } MHD_gnutls_alert_level_t;
82 82
83 typedef enum 83 typedef enum
84 { 84 {
@@ -110,7 +110,7 @@ extern "C"
110 GNUTLS_A_CERTIFICATE_UNOBTAINABLE = 111, 110 GNUTLS_A_CERTIFICATE_UNOBTAINABLE = 111,
111 GNUTLS_A_UNRECOGNIZED_NAME = 112, 111 GNUTLS_A_UNRECOGNIZED_NAME = 112,
112 GNUTLS_A_UNKNOWN_PSK_IDENTITY = 115, 112 GNUTLS_A_UNKNOWN_PSK_IDENTITY = 115,
113 } gnutls_alert_description_t; 113 } MHD_gnutls_alert_description_t;
114 114
115 typedef enum 115 typedef enum
116 { GNUTLS_HANDSHAKE_HELLO_REQUEST = 0, 116 { GNUTLS_HANDSHAKE_HELLO_REQUEST = 0,
@@ -124,7 +124,7 @@ extern "C"
124 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE = 16, 124 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE = 16,
125 GNUTLS_HANDSHAKE_FINISHED = 20, 125 GNUTLS_HANDSHAKE_FINISHED = 20,
126 GNUTLS_HANDSHAKE_SUPPLEMENTAL = 23 126 GNUTLS_HANDSHAKE_SUPPLEMENTAL = 23
127 } gnutls_handshake_description_t; 127 } MHD_gnutls_handshake_description_t;
128 128
129 typedef enum 129 typedef enum
130 { 130 {
@@ -141,26 +141,26 @@ extern "C"
141 GNUTLS_CERT_SIGNER_NOT_FOUND = 64, 141 GNUTLS_CERT_SIGNER_NOT_FOUND = 64,
142 GNUTLS_CERT_SIGNER_NOT_CA = 128, 142 GNUTLS_CERT_SIGNER_NOT_CA = 128,
143 GNUTLS_CERT_INSECURE_ALGORITHM = 256 143 GNUTLS_CERT_INSECURE_ALGORITHM = 256
144 } gnutls_certificate_status_t; 144 } MHD_gnutls_certificate_status_t;
145 145
146 typedef enum 146 typedef enum
147 { 147 {
148 GNUTLS_CERT_IGNORE, 148 GNUTLS_CERT_IGNORE,
149 GNUTLS_CERT_REQUEST = 1, 149 GNUTLS_CERT_REQUEST = 1,
150 GNUTLS_CERT_REQUIRE 150 GNUTLS_CERT_REQUIRE
151 } gnutls_certificate_request_t; 151 } MHD_gnutls_certificate_request_t;
152 152
153 typedef enum 153 typedef enum
154 { 154 {
155 GNUTLS_SHUT_RDWR = 0, 155 GNUTLS_SHUT_RDWR = 0,
156 GNUTLS_SHUT_WR = 1 156 GNUTLS_SHUT_WR = 1
157 } gnutls_close_request_t; 157 } MHD_gnutls_close_request_t;
158 158
159 typedef enum 159 typedef enum
160 { 160 {
161 GNUTLS_X509_FMT_DER, 161 GNUTLS_X509_FMT_DER,
162 GNUTLS_X509_FMT_PEM 162 GNUTLS_X509_FMT_PEM
163 } gnutls_x509_crt_fmt_t; 163 } MHD_gnutls_x509_crt_fmt_t;
164 164
165 typedef enum 165 typedef enum
166 { 166 {
@@ -173,92 +173,92 @@ extern "C"
173 GNUTLS_SIGN_RSA_SHA256, 173 GNUTLS_SIGN_RSA_SHA256,
174 GNUTLS_SIGN_RSA_SHA384, 174 GNUTLS_SIGN_RSA_SHA384,
175 GNUTLS_SIGN_RSA_SHA512 175 GNUTLS_SIGN_RSA_SHA512
176 } gnutls_sign_algorithm_t; 176 } MHD_gnutls_sign_algorithm_t;
177 177
178/* If you want to change this, then also change the define in 178/* If you want to change this, then also change the define in
179 * gnutls_int.h, and recompile. 179 * MHD_gnutls_int.h, and recompile.
180 */ 180 */
181 typedef void *gnutls_transport_ptr_t; 181 typedef void *MHD_gnutls_transport_ptr_t;
182 182
183 struct MHD_gtls_session_int; 183 struct MHD_gtls_session_int;
184 typedef struct MHD_gtls_session_int *mhd_gtls_session_t; 184 typedef struct MHD_gtls_session_int *MHD_gtls_session_t;
185 185
186 struct MHD_gtls_dh_params_int; 186 struct MHD_gtls_dh_params_int;
187 typedef struct MHD_gtls_dh_params_int *mhd_gtls_dh_params_t; 187 typedef struct MHD_gtls_dh_params_int *MHD_gtls_dh_params_t;
188 188
189 struct MHD_gtls_x509_privkey_int; /* XXX ugly. */ 189 struct MHD_gtls_x509_privkey_int; /* XXX ugly. */
190 typedef struct MHD_gtls_x509_privkey_int *mhd_gtls_rsa_params_t; /* XXX ugly. */ 190 typedef struct MHD_gtls_x509_privkey_int *MHD_gtls_rsa_params_t; /* XXX ugly. */
191 191
192 struct MHD_gtls_priority_st; 192 struct MHD_gtls_priority_st;
193 typedef struct MHD_gtls_priority_st *gnutls_priority_t; 193 typedef struct MHD_gtls_priority_st *MHD_gnutls_priority_t;
194 194
195 typedef struct 195 typedef struct
196 { 196 {
197 unsigned char *data; 197 unsigned char *data;
198 unsigned int size; 198 unsigned int size;
199 } gnutls_datum_t; 199 } MHD_gnutls_datum_t;
200 200
201 201
202 typedef struct gnutls_params_st 202 typedef struct MHD_gnutls_params_st
203 { 203 {
204 gnutls_params_type_t type; 204 MHD_gnutls_params_type_t type;
205 union params 205 union params
206 { 206 {
207 mhd_gtls_dh_params_t dh; 207 MHD_gtls_dh_params_t dh;
208 mhd_gtls_rsa_params_t rsa_export; 208 MHD_gtls_rsa_params_t rsa_export;
209 } params; 209 } params;
210 int deinit; 210 int deinit;
211 } gnutls_params_st; 211 } MHD_gnutls_params_st;
212 212
213 typedef int gnutls_params_function (mhd_gtls_session_t, 213 typedef int MHD_gnutls_params_function (MHD_gtls_session_t,
214 gnutls_params_type_t, 214 MHD_gnutls_params_type_t,
215 gnutls_params_st *); 215 MHD_gnutls_params_st *);
216 216
217/* internal functions */ 217/* internal functions */
218 int MHD_gnutls_global_init (void); 218 int MHD__gnutls_global_init (void);
219 void MHD_gnutls_global_deinit (void); 219 void MHD__gnutls_global_deinit (void);
220 220
221 int MHD_gnutls_init (mhd_gtls_session_t * session, 221 int MHD__gnutls_init (MHD_gtls_session_t * session,
222 gnutls_connection_end_t con_end); 222 MHD_gnutls_connection_end_t con_end);
223 void MHD_gnutls_deinit (mhd_gtls_session_t session); 223 void MHD__gnutls_deinit (MHD_gtls_session_t session);
224 224
225 int MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how); 225 int MHD__gnutls_bye (MHD_gtls_session_t session, MHD_gnutls_close_request_t how);
226 int MHD_gnutls_handshake (mhd_gtls_session_t session); 226 int MHD__gnutls_handshake (MHD_gtls_session_t session);
227 int MHD_gnutls_rehandshake (mhd_gtls_session_t session); 227 int MHD__gnutls_rehandshake (MHD_gtls_session_t session);
228 228
229 int mhd_gtls_handshake_client (mhd_gtls_session_t session); 229 int MHD_gtls_handshake_client (MHD_gtls_session_t session);
230 230
231 gnutls_alert_description_t gnutls_alert_get (mhd_gtls_session_t session); 231 MHD_gnutls_alert_description_t MHD_gnutls_alert_get (MHD_gtls_session_t session);
232 int MHD_gnutls_alert_send (mhd_gtls_session_t session, 232 int MHD__gnutls_alert_send (MHD_gtls_session_t session,
233 gnutls_alert_level_t level, 233 MHD_gnutls_alert_level_t level,
234 gnutls_alert_description_t desc); 234 MHD_gnutls_alert_description_t desc);
235 int MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err); 235 int MHD__gnutls_alert_send_appropriate (MHD_gtls_session_t session, int err);
236 const char *MHD_gnutls_alert_get_name (gnutls_alert_description_t alert); 236 const char *MHD__gnutls_alert_get_name (MHD_gnutls_alert_description_t alert);
237 237
238 enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get (mhd_gtls_session_t 238 enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get (MHD_gtls_session_t
239 session); 239 session);
240// enum MHD_GNUTLS_CipherAlgorithm gnutls_cipher_get (mhd_gtls_session_t session); 240// enum MHD_GNUTLS_CipherAlgorithm MHD_gnutls_cipher_get (MHD_gtls_session_t session);
241// enum MHD_GNUTLS_KeyExchangeAlgorithm gnutls_kx_get (mhd_gtls_session_t session); 241// enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gnutls_kx_get (MHD_gtls_session_t session);
242// enum MHD_GNUTLS_HashAlgorithm gnutls_mac_get (mhd_gtls_session_t session); 242// enum MHD_GNUTLS_HashAlgorithm MHD_gnutls_mac_get (MHD_gtls_session_t session);
243// enum MHD_GNUTLS_CertificateType gnutls_certificate_type_get (mhd_gtls_session_t 243// enum MHD_GNUTLS_CertificateType MHD_gnutls_certificate_type_get (MHD_gtls_session_t
244// session); 244// session);
245 245
246 size_t MHD_gnutls_cipher_get_key_size (enum MHD_GNUTLS_CipherAlgorithm 246 size_t MHD__gnutls_cipher_get_key_size (enum MHD_GNUTLS_CipherAlgorithm
247 algorithm); 247 algorithm);
248 size_t MHD_gnutls_mac_get_key_size (enum MHD_GNUTLS_HashAlgorithm 248 size_t MHD__gnutls_mac_get_key_size (enum MHD_GNUTLS_HashAlgorithm
249 algorithm); 249 algorithm);
250 250
251/* the name of the specified algorithms */ 251/* the name of the specified algorithms */
252 const char *MHD_gnutls_cipher_get_name (enum MHD_GNUTLS_CipherAlgorithm 252 const char *MHD__gnutls_cipher_get_name (enum MHD_GNUTLS_CipherAlgorithm
253 algorithm); 253 algorithm);
254 const char *MHD_gnutls_mac_get_name (enum MHD_GNUTLS_HashAlgorithm 254 const char *MHD__gnutls_mac_get_name (enum MHD_GNUTLS_HashAlgorithm
255 algorithm); 255 algorithm);
256 const char *MHD_gtls_compression_get_name (enum 256 const char *MHD_gtls_compression_get_name (enum
257 MHD_GNUTLS_CompressionMethod 257 MHD_GNUTLS_CompressionMethod
258 algorithm); 258 algorithm);
259 const char *MHD_gnutls_kx_get_name (enum MHD_GNUTLS_KeyExchangeAlgorithm 259 const char *MHD__gnutls_kx_get_name (enum MHD_GNUTLS_KeyExchangeAlgorithm
260 algorithm); 260 algorithm);
261 const char *MHD_gnutls_certificate_type_get_name (enum 261 const char *MHD__gnutls_certificate_type_get_name (enum
262 MHD_GNUTLS_CertificateType 262 MHD_GNUTLS_CertificateType
263 type); 263 type);
264 264
@@ -286,38 +286,38 @@ extern "C"
286 void MHD_gtls_perror (int error); 286 void MHD_gtls_perror (int error);
287 const char *MHD_gtls_strerror (int error); 287 const char *MHD_gtls_strerror (int error);
288 288
289 void MHD_gtls_handshake_set_private_extensions (mhd_gtls_session_t session, 289 void MHD_gtls_handshake_set_private_extensions (MHD_gtls_session_t session,
290 int allow); 290 int allow);
291 gnutls_handshake_description_t 291 MHD_gnutls_handshake_description_t
292 MHD_gtls_handshake_get_last_out (mhd_gtls_session_t session); 292 MHD_gtls_handshake_get_last_out (MHD_gtls_session_t session);
293 gnutls_handshake_description_t 293 MHD_gnutls_handshake_description_t
294 MHD_gtls_handshake_get_last_in (mhd_gtls_session_t session); 294 MHD_gtls_handshake_get_last_in (MHD_gtls_session_t session);
295 295
296/* 296/*
297 * Record layer functions. 297 * Record layer functions.
298 */ 298 */
299 ssize_t MHD_gnutls_record_send (mhd_gtls_session_t session, 299 ssize_t MHD__gnutls_record_send (MHD_gtls_session_t session,
300 const void *data, size_t sizeofdata); 300 const void *data, size_t sizeofdata);
301 ssize_t MHD_gnutls_record_recv (mhd_gtls_session_t session, void *data, 301 ssize_t MHD__gnutls_record_recv (MHD_gtls_session_t session, void *data,
302 size_t sizeofdata); 302 size_t sizeofdata);
303 303
304 /* provides extra compatibility */ 304 /* provides extra compatibility */
305 void MHD_gtls_record_disable_padding (mhd_gtls_session_t session); 305 void MHD_gtls_record_disable_padding (MHD_gtls_session_t session);
306 size_t MHD_gtls_record_check_pending (mhd_gtls_session_t session); 306 size_t MHD_gtls_record_check_pending (MHD_gtls_session_t session);
307 307
308 int MHD_gnutls_record_get_direction (mhd_gtls_session_t session); 308 int MHD__gnutls_record_get_direction (MHD_gtls_session_t session);
309 size_t MHD_gnutls_record_get_max_size (mhd_gtls_session_t session); 309 size_t MHD__gnutls_record_get_max_size (MHD_gtls_session_t session);
310 ssize_t MHD_gnutls_record_set_max_size (mhd_gtls_session_t session, 310 ssize_t MHD__gnutls_record_set_max_size (MHD_gtls_session_t session,
311 size_t size); 311 size_t size);
312 312
313 313
314 int MHD_gnutls_prf (mhd_gtls_session_t session, 314 int MHD__gnutls_prf (MHD_gtls_session_t session,
315 size_t label_size, const char *label, 315 size_t label_size, const char *label,
316 int server_random_first, 316 int server_random_first,
317 size_t extra_size, const char *extra, 317 size_t extra_size, const char *extra,
318 size_t outsize, char *out); 318 size_t outsize, char *out);
319 319
320 int MHD_gnutls_prf_raw (mhd_gtls_session_t session, 320 int MHD__gnutls_prf_raw (MHD_gtls_session_t session,
321 size_t label_size, const char *label, 321 size_t label_size, const char *label,
322 size_t seed_size, const char *seed, 322 size_t seed_size, const char *seed,
323 size_t outsize, char *out); 323 size_t outsize, char *out);
@@ -328,13 +328,13 @@ extern "C"
328 typedef enum 328 typedef enum
329 { 329 {
330 GNUTLS_NAME_DNS = 1 330 GNUTLS_NAME_DNS = 1
331 } gnutls_server_name_type_t; 331 } MHD_gnutls_server_name_type_t;
332 332
333 int MHD_gnutls_server_name_set (mhd_gtls_session_t session, 333 int MHD__gnutls_server_name_set (MHD_gtls_session_t session,
334 gnutls_server_name_type_t type, 334 MHD_gnutls_server_name_type_t type,
335 const void *name, size_t name_length); 335 const void *name, size_t name_length);
336 336
337 int MHD_gnutls_server_name_get (mhd_gtls_session_t session, 337 int MHD__gnutls_server_name_get (MHD_gtls_session_t session,
338 void *data, size_t * data_length, 338 void *data, size_t * data_length,
339 unsigned int *type, unsigned int indx); 339 unsigned int *type, unsigned int indx);
340 340
@@ -343,437 +343,437 @@ extern "C"
343 */ 343 */
344 344
345 void 345 void
346 MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session, 346 MHD_gtls_oprfi_enable_client (MHD_gtls_session_t session,
347 size_t len, unsigned char *data); 347 size_t len, unsigned char *data);
348 348
349 typedef int (*gnutls_oprfi_callback_func) (mhd_gtls_session_t session, 349 typedef int (*MHD_gnutls_oprfi_callback_func) (MHD_gtls_session_t session,
350 void *userdata, 350 void *userdata,
351 size_t oprfi_len, 351 size_t oprfi_len,
352 const unsigned char *in_oprfi, 352 const unsigned char *in_oprfi,
353 unsigned char *out_oprfi); 353 unsigned char *out_oprfi);
354 354
355 void 355 void
356 MHD_gtls_oprfi_enable_server (mhd_gtls_session_t session, 356 MHD_gtls_oprfi_enable_server (MHD_gtls_session_t session,
357 gnutls_oprfi_callback_func cb, 357 MHD_gnutls_oprfi_callback_func cb,
358 void *userdata); 358 void *userdata);
359 359
360 /* Supplemental data, RFC 4680. */ 360 /* Supplemental data, RFC 4680. */
361 typedef enum 361 typedef enum
362 { 362 {
363 GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA = 0 363 GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA = 0
364 } gnutls_supplemental_data_format_type_t; 364 } MHD_gnutls_supplemental_data_format_type_t;
365 365
366 const char *MHD_gtls_supplemental_get_name 366 const char *MHD_gtls_supplemental_get_name
367 (gnutls_supplemental_data_format_type_t type); 367 (MHD_gnutls_supplemental_data_format_type_t type);
368 368
369 int MHD_gnutls_cipher_set_priority (mhd_gtls_session_t session, 369 int MHD__gnutls_cipher_set_priority (MHD_gtls_session_t session,
370 const int *list); 370 const int *list);
371 int MHD_gnutls_mac_set_priority (mhd_gtls_session_t session, 371 int MHD__gnutls_mac_set_priority (MHD_gtls_session_t session,
372 const int *list); 372 const int *list);
373 int MHD_gnutls_compression_set_priority (mhd_gtls_session_t session, 373 int MHD__gnutls_compression_set_priority (MHD_gtls_session_t session,
374 const int *list); 374 const int *list);
375 int MHD_gnutls_kx_set_priority (mhd_gtls_session_t session, 375 int MHD__gnutls_kx_set_priority (MHD_gtls_session_t session,
376 const int *list); 376 const int *list);
377 int MHD_gnutls_protocol_set_priority (mhd_gtls_session_t session, 377 int MHD__gnutls_protocol_set_priority (MHD_gtls_session_t session,
378 const int *list); 378 const int *list);
379 int MHD_gnutls_certificate_type_set_priority (mhd_gtls_session_t session, 379 int MHD__gnutls_certificate_type_set_priority (MHD_gtls_session_t session,
380 const int *list); 380 const int *list);
381 381
382 int MHD_tls_set_default_priority (gnutls_priority_t *, const char *priority, 382 int MHD_tls_set_default_priority (MHD_gnutls_priority_t *, const char *priority,
383 const char **err_pos); 383 const char **err_pos);
384 void MHD_gnutls_priority_deinit (gnutls_priority_t); 384 void MHD__gnutls_priority_deinit (MHD_gnutls_priority_t);
385 385
386 int MHD_gnutls_priority_set (mhd_gtls_session_t session, gnutls_priority_t); 386 int MHD__gnutls_priority_set (MHD_gtls_session_t session, MHD_gnutls_priority_t);
387 int MHD_gnutls_priority_set_direct (mhd_gtls_session_t session, 387 int MHD__gnutls_priority_set_direct (MHD_gtls_session_t session,
388 const char *priority, 388 const char *priority,
389 const char **err_pos); 389 const char **err_pos);
390 390
391/* get the currently used protocol version */ 391/* get the currently used protocol version */
392 enum MHD_GNUTLS_Protocol MHD_gnutls_protocol_get_version (mhd_gtls_session_t 392 enum MHD_GNUTLS_Protocol MHD__gnutls_protocol_get_version (MHD_gtls_session_t
393 session); 393 session);
394 394
395 const char *MHD_gnutls_protocol_get_name (enum MHD_GNUTLS_Protocol version); 395 const char *MHD__gnutls_protocol_get_name (enum MHD_GNUTLS_Protocol version);
396 396
397/* 397/*
398 * get/set session 398 * get/set session
399 */ 399 */
400// int gnutls_session_set_data (mhd_gtls_session_t session, 400// int MHD_gnutls_session_set_data (MHD_gtls_session_t session,
401// const void *session_data, 401// const void *session_data,
402// size_t session_data_size); 402// size_t session_data_size);
403// int gnutls_session_get_data (mhd_gtls_session_t session, void *session_data, 403// int MHD_gnutls_session_get_data (MHD_gtls_session_t session, void *session_data,
404// size_t * session_data_size); 404// size_t * session_data_size);
405// int gnutls_session_get_data2 (mhd_gtls_session_t session, 405// int MHD_gnutls_session_get_data2 (MHD_gtls_session_t session,
406// gnutls_datum_t * data); 406// MHD_gnutls_datum_t * data);
407 407
408 int MHD_gtls_session_get_id (mhd_gtls_session_t session, void *session_id, 408 int MHD_gtls_session_get_id (MHD_gtls_session_t session, void *session_id,
409 size_t * session_id_size); 409 size_t * session_id_size);
410 410
411/* returns security values. 411/* returns security values.
412 * Do not use them unless you know what you're doing. 412 * Do not use them unless you know what you're doing.
413 */ 413 */
414 const void *MHD_gtls_session_get_server_random (mhd_gtls_session_t session); 414 const void *MHD_gtls_session_get_server_random (MHD_gtls_session_t session);
415 const void *MHD_gtls_session_get_client_random (mhd_gtls_session_t session); 415 const void *MHD_gtls_session_get_client_random (MHD_gtls_session_t session);
416 const void *MHD_gtls_session_get_master_secret (mhd_gtls_session_t session); 416 const void *MHD_gtls_session_get_master_secret (MHD_gtls_session_t session);
417 417
418 int MHD_gtls_session_is_resumed (mhd_gtls_session_t session); 418 int MHD_gtls_session_is_resumed (MHD_gtls_session_t session);
419 419
420 typedef int (*gnutls_handshake_post_client_hello_func) (mhd_gtls_session_t); 420 typedef int (*MHD_gnutls_handshake_post_client_hello_func) (MHD_gtls_session_t);
421 void 421 void
422 MHD_gnutls_handshake_set_post_client_hello_function (mhd_gtls_session_t, 422 MHD__gnutls_handshake_set_post_client_hello_function (MHD_gtls_session_t,
423 gnutls_handshake_post_client_hello_func); 423 MHD_gnutls_handshake_post_client_hello_func);
424 424
425 void MHD_gnutls_handshake_set_max_packet_length (mhd_gtls_session_t session, 425 void MHD__gnutls_handshake_set_max_packet_length (MHD_gtls_session_t session,
426 size_t max); 426 size_t max);
427 427
428/* 428/*
429 * Functions for setting/clearing credentials 429 * Functions for setting/clearing credentials
430 */ 430 */
431 void MHD_gnutls_credentials_clear (mhd_gtls_session_t session); 431 void MHD__gnutls_credentials_clear (MHD_gtls_session_t session);
432 432
433/* 433/*
434 * cred is a structure defined by the kx algorithm 434 * cred is a structure defined by the kx algorithm
435 */ 435 */
436 int MHD_gnutls_credentials_set (mhd_gtls_session_t session, 436 int MHD__gnutls_credentials_set (MHD_gtls_session_t session,
437 enum MHD_GNUTLS_CredentialsType type, 437 enum MHD_GNUTLS_CredentialsType type,
438 void *cred); 438 void *cred);
439 439
440/* Credential structures - used in MHD_gnutls_credentials_set(); */ 440/* Credential structures - used in MHD__gnutls_credentials_set(); */
441 struct mhd_gtls_certificate_credentials_st; 441 struct MHD_gtls_certificate_credentials_st;
442 typedef struct mhd_gtls_certificate_credentials_st 442 typedef struct MHD_gtls_certificate_credentials_st
443 *mhd_gtls_cert_credentials_t; 443 *MHD_gtls_cert_credentials_t;
444 typedef mhd_gtls_cert_credentials_t mhd_gtls_cert_server_credentials; 444 typedef MHD_gtls_cert_credentials_t MHD_gtls_cert_server_credentials;
445 typedef mhd_gtls_cert_credentials_t mhd_gtls_cert_client_credentials; 445 typedef MHD_gtls_cert_credentials_t MHD_gtls_cert_client_credentials;
446 446
447 typedef struct mhd_gtls_anon_server_credentials_st 447 typedef struct MHD_gtls_anon_server_credentials_st
448 *mhd_gtls_anon_server_credentials_t; 448 *MHD_gtls_anon_server_credentials_t;
449 typedef struct mhd_gtls_anon_client_credentials_st 449 typedef struct MHD_gtls_anon_client_credentials_st
450 *mhd_gtls_anon_client_credentials_t; 450 *MHD_gtls_anon_client_credentials_t;
451 451
452 void 452 void
453 MHD_gnutls_anon_free_server_credentials 453 MHD__gnutls_anon_free_server_credentials
454 (mhd_gtls_anon_server_credentials_t sc); 454 (MHD_gtls_anon_server_credentials_t sc);
455 int 455 int
456 MHD_gnutls_anon_allocate_server_credentials 456 MHD__gnutls_anon_allocate_server_credentials
457 (mhd_gtls_anon_server_credentials_t * sc); 457 (MHD_gtls_anon_server_credentials_t * sc);
458 458
459 void 459 void
460 MHD_gnutls_anon_set_server_dh_params (mhd_gtls_anon_server_credentials_t 460 MHD__gnutls_anon_set_server_dh_params (MHD_gtls_anon_server_credentials_t
461 res, 461 res,
462 mhd_gtls_dh_params_t dh_params); 462 MHD_gtls_dh_params_t dh_params);
463 463
464 void 464 void
465 MHD_gnutls_anon_set_server_params_function 465 MHD__gnutls_anon_set_server_params_function
466 (mhd_gtls_anon_server_credentials_t res, gnutls_params_function * func); 466 (MHD_gtls_anon_server_credentials_t res, MHD_gnutls_params_function * func);
467 467
468 void 468 void
469 MHD_gnutls_anon_free_client_credentials 469 MHD__gnutls_anon_free_client_credentials
470 (mhd_gtls_anon_client_credentials_t sc); 470 (MHD_gtls_anon_client_credentials_t sc);
471 int 471 int
472 MHD_gnutls_anon_allocate_client_credentials 472 MHD__gnutls_anon_allocate_client_credentials
473 (mhd_gtls_anon_client_credentials_t * sc); 473 (MHD_gtls_anon_client_credentials_t * sc);
474 474
475 void MHD_gnutls_certificate_free_credentials (mhd_gtls_cert_credentials_t 475 void MHD__gnutls_certificate_free_credentials (MHD_gtls_cert_credentials_t
476 sc); 476 sc);
477 int 477 int
478 MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t 478 MHD__gnutls_certificate_allocate_credentials (MHD_gtls_cert_credentials_t
479 * res); 479 * res);
480 480
481 void MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc); 481 void MHD__gnutls_certificate_free_keys (MHD_gtls_cert_credentials_t sc);
482 void MHD_gnutls_certificate_free_cas (mhd_gtls_cert_credentials_t sc); 482 void MHD__gnutls_certificate_free_cas (MHD_gtls_cert_credentials_t sc);
483 void MHD_gnutls_certificate_free_ca_names (mhd_gtls_cert_credentials_t sc); 483 void MHD__gnutls_certificate_free_ca_names (MHD_gtls_cert_credentials_t sc);
484 void MHD_gnutls_certificate_free_crls (mhd_gtls_cert_credentials_t sc); 484 void MHD__gnutls_certificate_free_crls (MHD_gtls_cert_credentials_t sc);
485 485
486 void MHD_gnutls_certificate_set_dh_params (mhd_gtls_cert_credentials_t res, 486 void MHD__gnutls_certificate_set_dh_params (MHD_gtls_cert_credentials_t res,
487 mhd_gtls_dh_params_t dh_params); 487 MHD_gtls_dh_params_t dh_params);
488 void 488 void
489 MHD_gnutls_certificate_set_rsa_export_params (mhd_gtls_cert_credentials_t 489 MHD__gnutls_certificate_set_rsa_export_params (MHD_gtls_cert_credentials_t
490 res, 490 res,
491 mhd_gtls_rsa_params_t 491 MHD_gtls_rsa_params_t
492 rsa_params); 492 rsa_params);
493 void MHD_gnutls_certificate_set_verify_flags (mhd_gtls_cert_credentials_t 493 void MHD__gnutls_certificate_set_verify_flags (MHD_gtls_cert_credentials_t
494 res, unsigned int flags); 494 res, unsigned int flags);
495 void MHD_gnutls_certificate_set_verify_limits (mhd_gtls_cert_credentials_t 495 void MHD__gnutls_certificate_set_verify_limits (MHD_gtls_cert_credentials_t
496 res, unsigned int max_bits, 496 res, unsigned int max_bits,
497 unsigned int max_depth); 497 unsigned int max_depth);
498 498
499 int MHD_gnutls_certificate_set_x509_trust_file (mhd_gtls_cert_credentials_t 499 int MHD__gnutls_certificate_set_x509_trust_file (MHD_gtls_cert_credentials_t
500 res, const char *CAFILE, 500 res, const char *CAFILE,
501 gnutls_x509_crt_fmt_t type); 501 MHD_gnutls_x509_crt_fmt_t type);
502 int MHD_gnutls_certificate_set_x509_trust_mem (mhd_gtls_cert_credentials_t 502 int MHD__gnutls_certificate_set_x509_trust_mem (MHD_gtls_cert_credentials_t
503 res, 503 res,
504 const gnutls_datum_t * CA, 504 const MHD_gnutls_datum_t * CA,
505 gnutls_x509_crt_fmt_t type); 505 MHD_gnutls_x509_crt_fmt_t type);
506 506
507 int MHD_gnutls_certificate_set_x509_crl_file (mhd_gtls_cert_credentials_t 507 int MHD__gnutls_certificate_set_x509_crl_file (MHD_gtls_cert_credentials_t
508 res, const char *crlfile, 508 res, const char *crlfile,
509 gnutls_x509_crt_fmt_t type); 509 MHD_gnutls_x509_crt_fmt_t type);
510 int MHD_gnutls_certificate_set_x509_crl_mem (mhd_gtls_cert_credentials_t 510 int MHD__gnutls_certificate_set_x509_crl_mem (MHD_gtls_cert_credentials_t
511 res, 511 res,
512 const gnutls_datum_t * CRL, 512 const MHD_gnutls_datum_t * CRL,
513 gnutls_x509_crt_fmt_t type); 513 MHD_gnutls_x509_crt_fmt_t type);
514 514
515 /* 515 /*
516 * CERTFILE is an x509 certificate in PEM form. 516 * CERTFILE is an x509 certificate in PEM form.
517 * KEYFILE is a pkcs-1 private key in PEM form (for RSA keys). 517 * KEYFILE is a pkcs-1 private key in PEM form (for RSA keys).
518 */ 518 */
519 int MHD_gnutls_certificate_set_x509_key_file (mhd_gtls_cert_credentials_t 519 int MHD__gnutls_certificate_set_x509_key_file (MHD_gtls_cert_credentials_t
520 res, const char *CERTFILE, 520 res, const char *CERTFILE,
521 const char *KEYFILE, 521 const char *KEYFILE,
522 gnutls_x509_crt_fmt_t type); 522 MHD_gnutls_x509_crt_fmt_t type);
523 int MHD_gnutls_certificate_set_x509_key_mem (mhd_gtls_cert_credentials_t 523 int MHD__gnutls_certificate_set_x509_key_mem (MHD_gtls_cert_credentials_t
524 res, 524 res,
525 const gnutls_datum_t * CERT, 525 const MHD_gnutls_datum_t * CERT,
526 const gnutls_datum_t * KEY, 526 const MHD_gnutls_datum_t * KEY,
527 gnutls_x509_crt_fmt_t type); 527 MHD_gnutls_x509_crt_fmt_t type);
528 528
529 void MHD_gnutls_certificate_send_x509_rdn_sequence (mhd_gtls_session_t 529 void MHD__gnutls_certificate_send_x509_rdn_sequence (MHD_gtls_session_t
530 session, int status); 530 session, int status);
531 531
532/* 532/*
533 * New functions to allow setting already parsed X.509 stuff. 533 * New functions to allow setting already parsed X.509 stuff.
534 */ 534 */
535 struct MHD_gtls_x509_privkey_int; 535 struct MHD_gtls_x509_privkey_int;
536 typedef struct MHD_gtls_x509_privkey_int *gnutls_x509_privkey_t; 536 typedef struct MHD_gtls_x509_privkey_int *MHD_gnutls_x509_privkey_t;
537 537
538 struct gnutls_x509_crl_int; 538 struct MHD_gnutls_x509_crl_int;
539 typedef struct gnutls_x509_crl_int *gnutls_x509_crl_t; 539 typedef struct MHD_gnutls_x509_crl_int *MHD_gnutls_x509_crl_t;
540 540
541 struct gnutls_x509_crt_int; 541 struct MHD_gnutls_x509_crt_int;
542 typedef struct gnutls_x509_crt_int *gnutls_x509_crt_t; 542 typedef struct MHD_gnutls_x509_crt_int *MHD_gnutls_x509_crt_t;
543 543
544// int gnutls_certificate_set_x509_key (mhd_gtls_cert_credentials_t res, 544// int MHD_gnutls_certificate_set_x509_key (MHD_gtls_cert_credentials_t res,
545// gnutls_x509_crt_t * cert_list, 545// MHD_gnutls_x509_crt_t * cert_list,
546// int cert_list_size, 546// int cert_list_size,
547// gnutls_x509_privkey_t key); 547// MHD_gnutls_x509_privkey_t key);
548// int gnutls_certificate_set_x509_trust (mhd_gtls_cert_credentials_t res, 548// int MHD_gnutls_certificate_set_x509_trust (MHD_gtls_cert_credentials_t res,
549// gnutls_x509_crt_t * ca_list, 549// MHD_gnutls_x509_crt_t * ca_list,
550// int ca_list_size); 550// int ca_list_size);
551// int gnutls_certificate_set_x509_crl (mhd_gtls_cert_credentials_t res, 551// int MHD_gnutls_certificate_set_x509_crl (MHD_gtls_cert_credentials_t res,
552// gnutls_x509_crl_t * crl_list, 552// MHD_gnutls_x509_crl_t * crl_list,
553// int crl_list_size); 553// int crl_list_size);
554 554
555/* global state functions 555/* global state functions
556 */ 556 */
557 557
558 558
559 typedef void *(*gnutls_alloc_function) (size_t); 559 typedef void *(*MHD_gnutls_alloc_function) (size_t);
560 typedef void *(*gnutls_calloc_function) (size_t, size_t); 560 typedef void *(*MHD_gnutls_calloc_function) (size_t, size_t);
561 typedef int (*gnutls_is_secure_function) (const void *); 561 typedef int (*MHD_gnutls_is_secure_function) (const void *);
562 typedef void (*gnutls_free_function) (void *); 562 typedef void (*MHD_gnutls_free_function) (void *);
563 typedef void *(*gnutls_realloc_function) (void *, size_t); 563 typedef void *(*MHD_gnutls_realloc_function) (void *, size_t);
564 564
565 extern void 565 extern void
566 MHD_gtls_global_set_mem_functions (gnutls_alloc_function gt_alloc_func, 566 MHD_gtls_global_set_mem_functions (MHD_gnutls_alloc_function gt_alloc_func,
567 gnutls_alloc_function 567 MHD_gnutls_alloc_function
568 gt_secure_alloc_func, 568 gt_secure_alloc_func,
569 gnutls_is_secure_function 569 MHD_gnutls_is_secure_function
570 gt_is_secure_func, 570 gt_is_secure_func,
571 gnutls_realloc_function 571 MHD_gnutls_realloc_function
572 gt_realloc_func, 572 gt_realloc_func,
573 gnutls_free_function gt_free_func); 573 MHD_gnutls_free_function gt_free_func);
574 574
575/* For use in callbacks */ 575/* For use in callbacks */
576 extern gnutls_alloc_function gnutls_malloc; 576 extern MHD_gnutls_alloc_function MHD_gnutls_malloc;
577 extern gnutls_alloc_function gnutls_secure_malloc; 577 extern MHD_gnutls_alloc_function MHD_gnutls_secure_malloc;
578 extern gnutls_realloc_function gnutls_realloc; 578 extern MHD_gnutls_realloc_function MHD_gnutls_realloc;
579 extern gnutls_calloc_function gnutls_calloc; 579 extern MHD_gnutls_calloc_function MHD_gnutls_calloc;
580 extern gnutls_free_function gnutls_free; 580 extern MHD_gnutls_free_function MHD_gnutls_free;
581 581
582 extern char *(*gnutls_strdup) (const char *); 582 extern char *(*MHD_gnutls_strdup) (const char *);
583 583
584 typedef void (*gnutls_log_func) (int, const char *); 584 typedef void (*MHD_gnutls_log_func) (int, const char *);
585 void MHD_gtls_global_set_log_function (gnutls_log_func log_func); 585 void MHD_gtls_global_set_log_function (MHD_gnutls_log_func log_func);
586 void MHD_gtls_global_set_log_level (int level); 586 void MHD_gtls_global_set_log_level (int level);
587 587
588/* 588/*
589 * Diffie Hellman parameter handling. 589 * Diffie Hellman parameter handling.
590 */ 590 */
591 int MHD_gnutls_dh_params_init (mhd_gtls_dh_params_t * dh_params); 591 int MHD__gnutls_dh_params_init (MHD_gtls_dh_params_t * dh_params);
592 void MHD_gnutls_dh_params_deinit (mhd_gtls_dh_params_t dh_params); 592 void MHD__gnutls_dh_params_deinit (MHD_gtls_dh_params_t dh_params);
593 int MHD_gnutls_dh_params_generate2 (mhd_gtls_dh_params_t params, 593 int MHD__gnutls_dh_params_generate2 (MHD_gtls_dh_params_t params,
594 unsigned int bits); 594 unsigned int bits);
595 595
596 596
597/* RSA params */ 597/* RSA params */
598 int MHD_gnutls_rsa_params_init (mhd_gtls_rsa_params_t * rsa_params); 598 int MHD__gnutls_rsa_params_init (MHD_gtls_rsa_params_t * rsa_params);
599 void MHD_gnutls_rsa_params_deinit (mhd_gtls_rsa_params_t rsa_params); 599 void MHD__gnutls_rsa_params_deinit (MHD_gtls_rsa_params_t rsa_params);
600 int MHD_gnutls_rsa_params_generate2 (mhd_gtls_rsa_params_t params, 600 int MHD__gnutls_rsa_params_generate2 (MHD_gtls_rsa_params_t params,
601 unsigned int bits); 601 unsigned int bits);
602 602
603 603
604/* 604/*
605 * Session stuff 605 * Session stuff
606 */ 606 */
607 typedef ssize_t (*mhd_gtls_pull_func) (gnutls_transport_ptr_t, void *, 607 typedef ssize_t (*MHD_gtls_pull_func) (MHD_gnutls_transport_ptr_t, void *,
608 size_t); 608 size_t);
609 typedef ssize_t (*mhd_gtls_push_func) (gnutls_transport_ptr_t, const void *, 609 typedef ssize_t (*MHD_gtls_push_func) (MHD_gnutls_transport_ptr_t, const void *,
610 size_t); 610 size_t);
611 void MHD_gnutls_transport_set_ptr (mhd_gtls_session_t session, 611 void MHD__gnutls_transport_set_ptr (MHD_gtls_session_t session,
612 gnutls_transport_ptr_t ptr); 612 MHD_gnutls_transport_ptr_t ptr);
613 void MHD_gnutls_transport_set_ptr2 (mhd_gtls_session_t session, 613 void MHD__gnutls_transport_set_ptr2 (MHD_gtls_session_t session,
614 gnutls_transport_ptr_t recv_ptr, 614 MHD_gnutls_transport_ptr_t recv_ptr,
615 gnutls_transport_ptr_t send_ptr); 615 MHD_gnutls_transport_ptr_t send_ptr);
616 616
617 void MHD_gnutls_transport_set_lowat (mhd_gtls_session_t session, int num); 617 void MHD__gnutls_transport_set_lowat (MHD_gtls_session_t session, int num);
618 618
619 619
620 void MHD_gnutls_transport_set_push_function (mhd_gtls_session_t session, 620 void MHD__gnutls_transport_set_push_function (MHD_gtls_session_t session,
621 mhd_gtls_push_func push_func); 621 MHD_gtls_push_func push_func);
622 void MHD_gnutls_transport_set_pull_function (mhd_gtls_session_t session, 622 void MHD__gnutls_transport_set_pull_function (MHD_gtls_session_t session,
623 mhd_gtls_pull_func pull_func); 623 MHD_gtls_pull_func pull_func);
624 624
625 void MHD_gnutls_transport_set_errno (mhd_gtls_session_t session, int err); 625 void MHD__gnutls_transport_set_errno (MHD_gtls_session_t session, int err);
626 void MHD_gnutls_transport_set_global_errno (int err); 626 void MHD__gnutls_transport_set_global_errno (int err);
627 627
628/* 628/*
629 * session specific 629 * session specific
630 */ 630 */
631 void MHD_gnutls_session_set_ptr (mhd_gtls_session_t session, void *ptr); 631 void MHD__gnutls_session_set_ptr (MHD_gtls_session_t session, void *ptr);
632 void *MHD_gtls_session_get_ptr (mhd_gtls_session_t session); 632 void *MHD_gtls_session_get_ptr (MHD_gtls_session_t session);
633 633
634/* 634/*
635 * this function returns the hash of the given data. 635 * this function returns the hash of the given data.
636 */ 636 */
637 int MHD_gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo, 637 int MHD__gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo,
638 const gnutls_datum_t * data, void *result, 638 const MHD_gnutls_datum_t * data, void *result,
639 size_t * result_size); 639 size_t * result_size);
640 640
641/* 641/*
642 * SRP 642 * SRP
643 */ 643 */
644// typedef struct gnutls_srp_server_credentials_st 644// typedef struct MHD_gnutls_srp_server_credentials_st
645// *gnutls_srp_server_credentials_t; 645// *MHD_gnutls_srp_server_credentials_t;
646// typedef struct gnutls_srp_client_credentials_st 646// typedef struct MHD_gnutls_srp_client_credentials_st
647// *gnutls_srp_client_credentials_t; 647// *MHD_gnutls_srp_client_credentials_t;
648// 648//
649// void gnutls_srp_free_client_credentials (gnutls_srp_client_credentials_t 649// void MHD_gnutls_srp_free_client_credentials (MHD_gnutls_srp_client_credentials_t
650// sc); 650// sc);
651// int gnutls_srp_allocate_client_credentials (gnutls_srp_client_credentials_t 651// int MHD_gnutls_srp_allocate_client_credentials (MHD_gnutls_srp_client_credentials_t
652// * sc); 652// * sc);
653// int gnutls_srp_set_client_credentials (gnutls_srp_client_credentials_t res, 653// int MHD_gnutls_srp_set_client_credentials (MHD_gnutls_srp_client_credentials_t res,
654// const char *username, 654// const char *username,
655// const char *password); 655// const char *password);
656// 656//
657// void gnutls_srp_free_server_credentials (gnutls_srp_server_credentials_t 657// void MHD_gnutls_srp_free_server_credentials (MHD_gnutls_srp_server_credentials_t
658// sc); 658// sc);
659// int gnutls_srp_allocate_server_credentials (gnutls_srp_server_credentials_t 659// int MHD_gnutls_srp_allocate_server_credentials (MHD_gnutls_srp_server_credentials_t
660// * sc); 660// * sc);
661// int gnutls_srp_set_server_credentials_file (gnutls_srp_server_credentials_t 661// int MHD_gnutls_srp_set_server_credentials_file (MHD_gnutls_srp_server_credentials_t
662// res, const char *password_file, 662// res, const char *password_file,
663// const char *password_conf_file); 663// const char *password_conf_file);
664// 664//
665// const char *gnutls_srp_server_get_username (mhd_gtls_session_t session); 665// const char *MHD_gnutls_srp_server_get_username (MHD_gtls_session_t session);
666// 666//
667// extern int gnutls_srp_verifier (const char *username, 667// extern int MHD_gnutls_srp_verifier (const char *username,
668// const char *password, 668// const char *password,
669// const gnutls_datum_t * salt, 669// const MHD_gnutls_datum_t * salt,
670// const gnutls_datum_t * generator, 670// const MHD_gnutls_datum_t * generator,
671// const gnutls_datum_t * prime, 671// const MHD_gnutls_datum_t * prime,
672// gnutls_datum_t * res); 672// MHD_gnutls_datum_t * res);
673// 673//
674///* The static parameters defined in draft-ietf-tls-srp-05 674///* The static parameters defined in draft-ietf-tls-srp-05
675// * Those should be used as input to gnutls_srp_verifier(). 675// * Those should be used as input to MHD_gnutls_srp_verifier().
676// */ 676// */
677// extern const gnutls_datum_t gnutls_srp_2048_group_prime; 677// extern const MHD_gnutls_datum_t MHD_gnutls_srp_2048_group_prime;
678// extern const gnutls_datum_t gnutls_srp_2048_group_generator; 678// extern const MHD_gnutls_datum_t MHD_gnutls_srp_2048_group_generator;
679// 679//
680// extern const gnutls_datum_t gnutls_srp_1536_group_prime; 680// extern const MHD_gnutls_datum_t MHD_gnutls_srp_1536_group_prime;
681// extern const gnutls_datum_t gnutls_srp_1536_group_generator; 681// extern const MHD_gnutls_datum_t MHD_gnutls_srp_1536_group_generator;
682// 682//
683// extern const gnutls_datum_t gnutls_srp_1024_group_prime; 683// extern const MHD_gnutls_datum_t MHD_gnutls_srp_1024_group_prime;
684// extern const gnutls_datum_t gnutls_srp_1024_group_generator; 684// extern const MHD_gnutls_datum_t MHD_gnutls_srp_1024_group_generator;
685// 685//
686// typedef int gnutls_srp_server_credentials_function (mhd_gtls_session_t, 686// typedef int MHD_gnutls_srp_server_credentials_function (MHD_gtls_session_t,
687// const char *username, 687// const char *username,
688// gnutls_datum_t * salt, 688// MHD_gnutls_datum_t * salt,
689// gnutls_datum_t * 689// MHD_gnutls_datum_t *
690// verifier, 690// verifier,
691// gnutls_datum_t * 691// MHD_gnutls_datum_t *
692// generator, 692// generator,
693// gnutls_datum_t * prime); 693// MHD_gnutls_datum_t * prime);
694// void 694// void
695// gnutls_srp_set_server_credentials_function 695// MHD_gnutls_srp_set_server_credentials_function
696// (gnutls_srp_server_credentials_t cred, 696// (MHD_gnutls_srp_server_credentials_t cred,
697// gnutls_srp_server_credentials_function * func); 697// MHD_gnutls_srp_server_credentials_function * func);
698// 698//
699// typedef int gnutls_srp_client_credentials_function (mhd_gtls_session_t, 699// typedef int MHD_gnutls_srp_client_credentials_function (MHD_gtls_session_t,
700// char **, char **); 700// char **, char **);
701// void 701// void
702// gnutls_srp_set_client_credentials_function 702// MHD_gnutls_srp_set_client_credentials_function
703// (gnutls_srp_client_credentials_t cred, 703// (MHD_gnutls_srp_client_credentials_t cred,
704// gnutls_srp_client_credentials_function * func); 704// MHD_gnutls_srp_client_credentials_function * func);
705// 705//
706// int gnutls_srp_base64_encode (const gnutls_datum_t * data, char *result, 706// int MHD_gnutls_srp_base64_encode (const MHD_gnutls_datum_t * data, char *result,
707// size_t * result_size); 707// size_t * result_size);
708// int gnutls_srp_base64_encode_alloc (const gnutls_datum_t * data, 708// int MHD_gnutls_srp_base64_encode_alloc (const MHD_gnutls_datum_t * data,
709// gnutls_datum_t * result); 709// MHD_gnutls_datum_t * result);
710// 710//
711// int gnutls_srp_base64_decode (const gnutls_datum_t * b64_data, char *result, 711// int MHD_gnutls_srp_base64_decode (const MHD_gnutls_datum_t * b64_data, char *result,
712// size_t * result_size); 712// size_t * result_size);
713// int gnutls_srp_base64_decode_alloc (const gnutls_datum_t * b64_data, 713// int MHD_gnutls_srp_base64_decode_alloc (const MHD_gnutls_datum_t * b64_data,
714// gnutls_datum_t * result); 714// MHD_gnutls_datum_t * result);
715 715
716/* 716/*
717 * PSK stuff 717 * PSK stuff
718 */ 718 */
719// typedef struct gnutls_psk_server_credentials_st 719// typedef struct MHD_gnutls_psk_server_credentials_st
720// *gnutls_psk_server_credentials_t; 720// *MHD_gnutls_psk_server_credentials_t;
721// typedef struct gnutls_psk_client_credentials_st 721// typedef struct MHD_gnutls_psk_client_credentials_st
722// *gnutls_psk_client_credentials_t; 722// *MHD_gnutls_psk_client_credentials_t;
723// 723//
724// typedef enum gnutls_psk_key_flags 724// typedef enum MHD_gnutls_psk_key_flags
725// { 725// {
726// GNUTLS_PSK_KEY_RAW = 0, 726// GNUTLS_PSK_KEY_RAW = 0,
727// GNUTLS_PSK_KEY_HEX 727// GNUTLS_PSK_KEY_HEX
728// } gnutls_psk_key_flags; 728// } MHD_gnutls_psk_key_flags;
729// 729//
730// void gnutls_psk_free_client_credentials (gnutls_psk_client_credentials_t 730// void MHD_gnutls_psk_free_client_credentials (MHD_gnutls_psk_client_credentials_t
731// sc); 731// sc);
732// int gnutls_psk_allocate_client_credentials (gnutls_psk_client_credentials_t 732// int MHD_gnutls_psk_allocate_client_credentials (MHD_gnutls_psk_client_credentials_t
733// * sc); 733// * sc);
734// int gnutls_psk_set_client_credentials (gnutls_psk_client_credentials_t res, 734// int MHD_gnutls_psk_set_client_credentials (MHD_gnutls_psk_client_credentials_t res,
735// const char *username, 735// const char *username,
736// const gnutls_datum_t * key, 736// const MHD_gnutls_datum_t * key,
737// gnutls_psk_key_flags format); 737// MHD_gnutls_psk_key_flags format);
738// 738//
739// void gnutls_psk_free_server_credentials (gnutls_psk_server_credentials_t 739// void MHD_gnutls_psk_free_server_credentials (MHD_gnutls_psk_server_credentials_t
740// sc); 740// sc);
741// int gnutls_psk_allocate_server_credentials (gnutls_psk_server_credentials_t 741// int MHD_gnutls_psk_allocate_server_credentials (MHD_gnutls_psk_server_credentials_t
742// * sc); 742// * sc);
743// int gnutls_psk_set_server_credentials_file (gnutls_psk_server_credentials_t 743// int MHD_gnutls_psk_set_server_credentials_file (MHD_gnutls_psk_server_credentials_t
744// res, const char *password_file); 744// res, const char *password_file);
745// 745//
746// const char *gnutls_psk_server_get_username (mhd_gtls_session_t session); 746// const char *MHD_gnutls_psk_server_get_username (MHD_gtls_session_t session);
747// 747//
748// typedef int gnutls_psk_server_credentials_function (mhd_gtls_session_t, 748// typedef int MHD_gnutls_psk_server_credentials_function (MHD_gtls_session_t,
749// const char *username, 749// const char *username,
750// gnutls_datum_t * key); 750// MHD_gnutls_datum_t * key);
751// void 751// void
752// gnutls_psk_set_server_credentials_function 752// MHD_gnutls_psk_set_server_credentials_function
753// (gnutls_psk_server_credentials_t cred, 753// (MHD_gnutls_psk_server_credentials_t cred,
754// gnutls_psk_server_credentials_function * func); 754// MHD_gnutls_psk_server_credentials_function * func);
755// 755//
756// typedef int gnutls_psk_client_credentials_function (mhd_gtls_session_t, 756// typedef int MHD_gnutls_psk_client_credentials_function (MHD_gtls_session_t,
757// char **username, 757// char **username,
758// gnutls_datum_t * key); 758// MHD_gnutls_datum_t * key);
759// void 759// void
760// gnutls_psk_set_client_credentials_function 760// MHD_gnutls_psk_set_client_credentials_function
761// (gnutls_psk_client_credentials_t cred, 761// (MHD_gnutls_psk_client_credentials_t cred,
762// gnutls_psk_client_credentials_function * func); 762// MHD_gnutls_psk_client_credentials_function * func);
763// 763//
764// int gnutls_hex_encode (const gnutls_datum_t * data, char *result, 764// int MHD_gnutls_hex_encode (const MHD_gnutls_datum_t * data, char *result,
765// size_t * result_size); 765// size_t * result_size);
766// int gnutls_hex_decode (const gnutls_datum_t * hex_data, char *result, 766// int MHD_gnutls_hex_decode (const MHD_gnutls_datum_t * hex_data, char *result,
767// size_t * result_size); 767// size_t * result_size);
768// 768//
769// void gnutls_psk_set_server_dh_params (gnutls_psk_server_credentials_t res, 769// void MHD_gnutls_psk_set_server_dh_params (MHD_gnutls_psk_server_credentials_t res,
770// mhd_gtls_dh_params_t dh_params); 770// MHD_gtls_dh_params_t dh_params);
771// 771//
772// void gnutls_psk_set_server_params_function (gnutls_psk_server_credentials_t 772// void MHD_gnutls_psk_set_server_params_function (MHD_gnutls_psk_server_credentials_t
773// res, 773// res,
774// gnutls_params_function * func); 774// MHD_gnutls_params_function * func);
775 775
776 typedef enum gnutls_x509_subject_alt_name_t 776 typedef enum MHD_gnutls_x509_subject_alt_name_t
777 { 777 {
778 GNUTLS_SAN_DNSNAME = 1, 778 GNUTLS_SAN_DNSNAME = 1,
779 GNUTLS_SAN_RFC822NAME, 779 GNUTLS_SAN_RFC822NAME,
@@ -783,30 +783,30 @@ extern "C"
783 GNUTLS_SAN_DN, 783 GNUTLS_SAN_DN,
784 /* The following are "virtual" subject alternative name types, in 784 /* The following are "virtual" subject alternative name types, in
785 that they are represented by an otherName value and an OID. 785 that they are represented by an otherName value and an OID.
786 Used by gnutls_x509_crt_get_subject_alt_othername_oid(). */ 786 Used by MHD_gnutls_x509_crt_get_subject_alt_othername_oid(). */
787 GNUTLS_SAN_OTHERNAME_XMPP = 1000 787 GNUTLS_SAN_OTHERNAME_XMPP = 1000
788 } gnutls_x509_subject_alt_name_t; 788 } MHD_gnutls_x509_subject_alt_name_t;
789 789
790 typedef struct gnutls_retr_st 790 typedef struct MHD_gnutls_retr_st
791 { 791 {
792 enum MHD_GNUTLS_CertificateType type; 792 enum MHD_GNUTLS_CertificateType type;
793 union cert 793 union cert
794 { 794 {
795 gnutls_x509_crt_t *x509; 795 MHD_gnutls_x509_crt_t *x509;
796 } cert; 796 } cert;
797 unsigned int ncerts; 797 unsigned int ncerts;
798 798
799 union key 799 union key
800 { 800 {
801 gnutls_x509_privkey_t x509; 801 MHD_gnutls_x509_privkey_t x509;
802 } key; 802 } key;
803 803
804 unsigned int deinit_all; /* if non zero all keys will be deinited */ 804 unsigned int deinit_all; /* if non zero all keys will be deinited */
805 } gnutls_retr_st; 805 } MHD_gnutls_retr_st;
806 806
807 typedef int gnutls_certificate_client_retrieve_function (mhd_gtls_session_t, 807 typedef int MHD_gnutls_certificate_client_retrieve_function (MHD_gtls_session_t,
808 const 808 const
809 gnutls_datum_t * 809 MHD_gnutls_datum_t *
810 req_ca_rdn, 810 req_ca_rdn,
811 int nreqs, 811 int nreqs,
812 const 812 const
@@ -815,115 +815,115 @@ extern "C"
815 *pk_algos, 815 *pk_algos,
816 int 816 int
817 pk_algos_length, 817 pk_algos_length,
818 gnutls_retr_st *); 818 MHD_gnutls_retr_st *);
819 819
820 typedef int gnutls_certificate_server_retrieve_function (mhd_gtls_session_t, 820 typedef int MHD_gnutls_certificate_server_retrieve_function (MHD_gtls_session_t,
821 gnutls_retr_st *); 821 MHD_gnutls_retr_st *);
822 822
823 /* 823 /*
824 * Functions that allow auth_info_t structures handling 824 * Functions that allow auth_info_t structures handling
825 */ 825 */
826 enum MHD_GNUTLS_CredentialsType MHD_gtls_auth_get_type (mhd_gtls_session_t 826 enum MHD_GNUTLS_CredentialsType MHD_gtls_auth_get_type (MHD_gtls_session_t
827 session); 827 session);
828 enum MHD_GNUTLS_CredentialsType 828 enum MHD_GNUTLS_CredentialsType
829 MHD_gtls_auth_server_get_type (mhd_gtls_session_t session); 829 MHD_gtls_auth_server_get_type (MHD_gtls_session_t session);
830 enum MHD_GNUTLS_CredentialsType 830 enum MHD_GNUTLS_CredentialsType
831 MHD_gtls_auth_client_get_type (mhd_gtls_session_t session); 831 MHD_gtls_auth_client_get_type (MHD_gtls_session_t session);
832 832
833 /* 833 /*
834 * DH 834 * DH
835 */ 835 */
836 void MHD_gnutls_dh_set_prime_bits (mhd_gtls_session_t session, 836 void MHD__gnutls_dh_set_prime_bits (MHD_gtls_session_t session,
837 unsigned int bits); 837 unsigned int bits);
838 int MHD_gnutls_dh_get_secret_bits (mhd_gtls_session_t session); 838 int MHD__gnutls_dh_get_secret_bits (MHD_gtls_session_t session);
839 int MHD_gnutls_dh_get_peers_public_bits (mhd_gtls_session_t session); 839 int MHD__gnutls_dh_get_peers_public_bits (MHD_gtls_session_t session);
840 int MHD_gnutls_dh_get_prime_bits (mhd_gtls_session_t session); 840 int MHD__gnutls_dh_get_prime_bits (MHD_gtls_session_t session);
841 841
842 int MHD_gnutls_dh_get_group (mhd_gtls_session_t session, 842 int MHD__gnutls_dh_get_group (MHD_gtls_session_t session,
843 gnutls_datum_t * raw_gen, 843 MHD_gnutls_datum_t * raw_gen,
844 gnutls_datum_t * raw_prime); 844 MHD_gnutls_datum_t * raw_prime);
845 int MHD_gnutls_dh_get_pubkey (mhd_gtls_session_t session, 845 int MHD__gnutls_dh_get_pubkey (MHD_gtls_session_t session,
846 gnutls_datum_t * raw_key); 846 MHD_gnutls_datum_t * raw_key);
847 847
848 /* 848 /*
849 * RSA 849 * RSA
850 */ 850 */
851 int MHD_gtls_rsa_export_get_pubkey (mhd_gtls_session_t session, 851 int MHD_gtls_rsa_export_get_pubkey (MHD_gtls_session_t session,
852 gnutls_datum_t * exponent, 852 MHD_gnutls_datum_t * exponent,
853 gnutls_datum_t * modulus); 853 MHD_gnutls_datum_t * modulus);
854 int MHD_gtls_rsa_export_get_modulus_bits (mhd_gtls_session_t session); 854 int MHD_gtls_rsa_export_get_modulus_bits (MHD_gtls_session_t session);
855 855
856 /* External signing callback. Experimental. */ 856 /* External signing callback. Experimental. */
857 typedef int (*gnutls_sign_func) (mhd_gtls_session_t session, 857 typedef int (*MHD_gnutls_sign_func) (MHD_gtls_session_t session,
858 void *userdata, 858 void *userdata,
859 enum MHD_GNUTLS_CertificateType cert_type, 859 enum MHD_GNUTLS_CertificateType cert_type,
860 const gnutls_datum_t * cert, 860 const MHD_gnutls_datum_t * cert,
861 const gnutls_datum_t * hash, 861 const MHD_gnutls_datum_t * hash,
862 gnutls_datum_t * signature); 862 MHD_gnutls_datum_t * signature);
863 863
864 void MHD_gtls_sign_callback_set (mhd_gtls_session_t session, 864 void MHD_gtls_sign_callback_set (MHD_gtls_session_t session,
865 gnutls_sign_func sign_func, 865 MHD_gnutls_sign_func sign_func,
866 void *userdata); 866 void *userdata);
867 gnutls_sign_func MHD_gtls_sign_callback_get (mhd_gtls_session_t session, 867 MHD_gnutls_sign_func MHD_gtls_sign_callback_get (MHD_gtls_session_t session,
868 void **userdata); 868 void **userdata);
869 869
870 /* These are set on the credentials structure. 870 /* These are set on the credentials structure.
871 */ 871 */
872 void MHD_gtls_certificate_client_set_retrieve_function 872 void MHD_gtls_certificate_client_set_retrieve_function
873 (mhd_gtls_cert_credentials_t cred, 873 (MHD_gtls_cert_credentials_t cred,
874 gnutls_certificate_client_retrieve_function * func); 874 MHD_gnutls_certificate_client_retrieve_function * func);
875 void MHD_gtls_certificate_server_set_retrieve_function 875 void MHD_gtls_certificate_server_set_retrieve_function
876 (mhd_gtls_cert_credentials_t cred, 876 (MHD_gtls_cert_credentials_t cred,
877 gnutls_certificate_server_retrieve_function * func); 877 MHD_gnutls_certificate_server_retrieve_function * func);
878 878
879 void MHD_gtls_certificate_server_set_request (mhd_gtls_session_t session, 879 void MHD_gtls_certificate_server_set_request (MHD_gtls_session_t session,
880 gnutls_certificate_request_t 880 MHD_gnutls_certificate_request_t
881 req); 881 req);
882 882
883 /* get data from the session */ 883 /* get data from the session */
884 const gnutls_datum_t *MHD_gtls_certificate_get_peers (mhd_gtls_session_t 884 const MHD_gnutls_datum_t *MHD_gtls_certificate_get_peers (MHD_gtls_session_t
885 session, 885 session,
886 unsigned int 886 unsigned int
887 *list_size); 887 *list_size);
888 const gnutls_datum_t *MHD_gtls_certificate_get_ours (mhd_gtls_session_t 888 const MHD_gnutls_datum_t *MHD_gtls_certificate_get_ours (MHD_gtls_session_t
889 session); 889 session);
890 890
891 time_t MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t 891 time_t MHD_gtls_certificate_activation_time_peers (MHD_gtls_session_t
892 session); 892 session);
893 time_t MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t 893 time_t MHD_gtls_certificate_expiration_time_peers (MHD_gtls_session_t
894 session); 894 session);
895 895
896 int MHD_gtls_certificate_client_get_request_status (mhd_gtls_session_t 896 int MHD_gtls_certificate_client_get_request_status (MHD_gtls_session_t
897 session); 897 session);
898 int MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session, 898 int MHD_gtls_certificate_verify_peers2 (MHD_gtls_session_t session,
899 unsigned int *status); 899 unsigned int *status);
900 900
901 /* this is obsolete (?). */ 901 /* this is obsolete (?). */
902 int MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session); 902 int MHD_gtls_certificate_verify_peers (MHD_gtls_session_t session);
903 903
904 int MHD_gtls_pem_base64_encode (const char *msg, 904 int MHD_gtls_pem_base64_encode (const char *msg,
905 const gnutls_datum_t * data, char *result, 905 const MHD_gnutls_datum_t * data, char *result,
906 size_t * result_size); 906 size_t * result_size);
907 int MHD_gtls_pem_base64_decode (const char *header, 907 int MHD_gtls_pem_base64_decode (const char *header,
908 const gnutls_datum_t * b64_data, 908 const MHD_gnutls_datum_t * b64_data,
909 unsigned char *result, 909 unsigned char *result,
910 size_t * result_size); 910 size_t * result_size);
911 911
912 int MHD_gtls_pem_base64_encode_alloc (const char *msg, 912 int MHD_gtls_pem_base64_encode_alloc (const char *msg,
913 const gnutls_datum_t * data, 913 const MHD_gnutls_datum_t * data,
914 gnutls_datum_t * result); 914 MHD_gnutls_datum_t * result);
915 int MHD_gtls_pem_base64_decode_alloc (const char *header, 915 int MHD_gtls_pem_base64_decode_alloc (const char *header,
916 const gnutls_datum_t * b64_data, 916 const MHD_gnutls_datum_t * b64_data,
917 gnutls_datum_t * result); 917 MHD_gnutls_datum_t * result);
918 918
919 // void 919 // void
920 // gnutls_certificate_set_params_function (mhd_gtls_cert_credentials_t 920 // MHD_gnutls_certificate_set_params_function (MHD_gtls_cert_credentials_t
921 // res, 921 // res,
922 // gnutls_params_function * func); 922 // MHD_gnutls_params_function * func);
923 // void gnutls_anon_set_params_function (mhd_gtls_anon_server_credentials_t res, 923 // void MHD_gnutls_anon_set_params_function (MHD_gtls_anon_server_credentials_t res,
924 // gnutls_params_function * func); 924 // MHD_gnutls_params_function * func);
925 // void gnutls_psk_set_params_function (gnutls_psk_server_credentials_t res, 925 // void MHD_gnutls_psk_set_params_function (MHD_gnutls_psk_server_credentials_t res,
926 // gnutls_params_function * func); 926 // MHD_gnutls_params_function * func);
927 927
928 928
929 /* key_usage will be an OR of the following values: */ 929 /* key_usage will be an OR of the following values: */
@@ -1002,7 +1002,7 @@ extern "C"
1002 1002
1003 1003
1004 /* returned if libextra functionality was requested but 1004 /* returned if libextra functionality was requested but
1005 * gnutls_global_init_extra() was not called. 1005 * MHD_gnutls_global_init_extra() was not called.
1006 */ 1006 */
1007#define GNUTLS_E_INIT_LIBEXTRA -82 1007#define GNUTLS_E_INIT_LIBEXTRA -82
1008#define GNUTLS_E_LIBRARY_VERSION_MISMATCH -83 1008#define GNUTLS_E_LIBRARY_VERSION_MISMATCH -83
diff --git a/src/daemon/https/lgl/Makefile.am b/src/daemon/https/lgl/Makefile.am
index 93423d2d..17a8bafc 100644
--- a/src/daemon/https/lgl/Makefile.am
+++ b/src/daemon/https/lgl/Makefile.am
@@ -14,7 +14,6 @@ liblgl_la_LDFLAGS = -lgcrypt
14liblgl_la_SOURCES = \ 14liblgl_la_SOURCES = \
15sha1.c sha1.h \ 15sha1.c sha1.h \
16gc-libgcrypt.c \ 16gc-libgcrypt.c \
17time_r.c \
18rijndael-api-fst.c rijndael-api-fst.h \ 17rijndael-api-fst.c rijndael-api-fst.h \
19gc-pbkdf2-sha1.c gc.h \ 18gc-pbkdf2-sha1.c gc.h \
20rijndael-alg-fst.c rijndael-alg-fst.h \ 19rijndael-alg-fst.c rijndael-alg-fst.h \
diff --git a/src/daemon/https/lgl/des.c b/src/daemon/https/lgl/des.c
index 4f6c5be0..7bc4c4d0 100644
--- a/src/daemon/https/lgl/des.c
+++ b/src/daemon/https/lgl/des.c
@@ -54,13 +54,13 @@
54 * unsigned char plaintext[8]; 54 * unsigned char plaintext[8];
55 * unsigned char ciphertext[8]; 55 * unsigned char ciphertext[8];
56 * unsigned char recoverd[8]; 56 * unsigned char recoverd[8];
57 * gl_des_ctx context; 57 * MHD_gl_des_ctx context;
58 * 58 *
59 * // Fill 'key' and 'plaintext' with some data 59 * // Fill 'key' and 'plaintext' with some data
60 * .... 60 * ....
61 * 61 *
62 * // Set up the DES encryption context 62 * // Set up the DES encryption context
63 * gl_des_setkey(&context, key); 63 * MHD_gl_des_setkey(&context, key);
64 * 64 *
65 * // Encrypt the plaintext 65 * // Encrypt the plaintext
66 * des_ecb_encrypt(&context, plaintext, ciphertext); 66 * des_ecb_encrypt(&context, plaintext, ciphertext);
@@ -77,20 +77,20 @@
77 * unsigned char plaintext[8]; 77 * unsigned char plaintext[8];
78 * unsigned char ciphertext[8]; 78 * unsigned char ciphertext[8];
79 * unsigned char recoverd[8]; 79 * unsigned char recoverd[8];
80 * gl_3des_ctx context; 80 * MHD_gl_3des_ctx context;
81 * 81 *
82 * // If you would like to use two 64bit keys, fill 'key1' and'key2' 82 * // If you would like to use two 64bit keys, fill 'key1' and'key2'
83 * // then setup the encryption context: 83 * // then setup the encryption context:
84 * gl_3des_set2keys(&context, key1, key2); 84 * MHD_gl_3des_set2keys(&context, key1, key2);
85 * 85 *
86 * // To use three 64bit keys with Triple-DES use: 86 * // To use three 64bit keys with Triple-DES use:
87 * gl_3des_set3keys(&context, key1, key2, key3); 87 * MHD_gl_3des_set3keys(&context, key1, key2, key3);
88 * 88 *
89 * // Encrypting plaintext with Triple-DES 89 * // Encrypting plaintext with Triple-DES
90 * gl_3des_ecb_encrypt(&context, plaintext, ciphertext); 90 * MHD_gl_3des_ecb_encrypt(&context, plaintext, ciphertext);
91 * 91 *
92 * // Decrypting ciphertext to recover the plaintext with Triple-DES 92 * // Decrypting ciphertext to recover the plaintext with Triple-DES
93 * gl_3des_ecb_decrypt(&context, ciphertext, recoverd); 93 * MHD_gl_3des_ecb_decrypt(&context, ciphertext, recoverd);
94 */ 94 */
95 95
96 96
@@ -320,7 +320,7 @@ static const unsigned char weak_keys[64][8] = {
320}; 320};
321 321
322bool 322bool
323gl_des_is_weak_key (const char *key) 323MHD_gl_des_is_weak_key (const char *key)
324{ 324{
325 char work[8]; 325 char work[8];
326 int i, left, right, middle, cmp_result; 326 int i, left, right, middle, cmp_result;
@@ -518,7 +518,7 @@ des_key_schedule (const char *_rawkey, uint32_t * subkey)
518} 518}
519 519
520void 520void
521gl_des_setkey (gl_des_ctx * ctx, const char *key) 521MHD_gl_des_setkey (MHD_gl_des_ctx * ctx, const char *key)
522{ 522{
523 int i; 523 int i;
524 524
@@ -532,18 +532,18 @@ gl_des_setkey (gl_des_ctx * ctx, const char *key)
532} 532}
533 533
534bool 534bool
535gl_des_makekey (gl_des_ctx * ctx, const char *key, size_t keylen) 535MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, size_t keylen)
536{ 536{
537 if (keylen != 8) 537 if (keylen != 8)
538 return false; 538 return false;
539 539
540 gl_des_setkey (ctx, key); 540 MHD_gl_des_setkey (ctx, key);
541 541
542 return !gl_des_is_weak_key (key); 542 return !MHD_gl_des_is_weak_key (key);
543} 543}
544 544
545void 545void
546gl_des_ecb_crypt (gl_des_ctx * ctx, const char *_from, char *_to, int mode) 546MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *_from, char *_to, int mode)
547{ 547{
548 const unsigned char *from = (const unsigned char *) _from; 548 const unsigned char *from = (const unsigned char *) _from;
549 unsigned char *to = (unsigned char *) _to; 549 unsigned char *to = (unsigned char *) _to;
@@ -565,7 +565,7 @@ READ_64BIT_DATA (from, left, right)
565 FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)} 565 FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)}
566 566
567void 567void
568gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2) 568MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2)
569{ 569{
570 int i; 570 int i;
571 571
@@ -589,7 +589,7 @@ gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2)
589} 589}
590 590
591void 591void
592gl_3des_set3keys (gl_3des_ctx * ctx, const char *key1, 592MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx, const char *key1,
593 const char *key2, const char *key3) 593 const char *key2, const char *key3)
594{ 594{
595 int i; 595 int i;
@@ -612,7 +612,7 @@ gl_3des_set3keys (gl_3des_ctx * ctx, const char *key1,
612} 612}
613 613
614void 614void
615gl_3des_ecb_crypt (gl_3des_ctx * ctx, const char *_from, char *_to, int mode) 615MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *_from, char *_to, int mode)
616{ 616{
617 const unsigned char *from = (const unsigned char *) _from; 617 const unsigned char *from = (const unsigned char *) _from;
618 unsigned char *to = (unsigned char *) _to; 618 unsigned char *to = (unsigned char *) _to;
@@ -650,13 +650,13 @@ READ_64BIT_DATA (from, left, right)
650 FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)} 650 FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)}
651 651
652bool 652bool
653gl_3des_makekey (gl_3des_ctx * ctx, const char *key, size_t keylen) 653MHD_gl_3des_makekey (MHD_gl_3des_ctx * ctx, const char *key, size_t keylen)
654{ 654{
655 if (keylen != 24) 655 if (keylen != 24)
656 return false; 656 return false;
657 657
658 gl_3des_set3keys (ctx, key, key + 8, key + 16); 658 MHD_gl_3des_set3keys (ctx, key, key + 8, key + 16);
659 659
660 return !(gl_des_is_weak_key (key) 660 return !(MHD_gl_des_is_weak_key (key)
661 || gl_des_is_weak_key (key + 8) || gl_des_is_weak_key (key + 16)); 661 || MHD_gl_des_is_weak_key (key + 8) || MHD_gl_des_is_weak_key (key + 16));
662} 662}
diff --git a/src/daemon/https/lgl/des.h b/src/daemon/https/lgl/des.h
index a80ede84..4d9eb20c 100644
--- a/src/daemon/https/lgl/des.h
+++ b/src/daemon/https/lgl/des.h
@@ -34,7 +34,7 @@ typedef struct
34{ 34{
35 uint32_t encrypt_subkeys[32]; 35 uint32_t encrypt_subkeys[32];
36 uint32_t decrypt_subkeys[32]; 36 uint32_t decrypt_subkeys[32];
37} gl_des_ctx; 37} MHD_gl_des_ctx;
38 38
39/* 39/*
40 * Encryption/Decryption context of Triple-DES 40 * Encryption/Decryption context of Triple-DES
@@ -43,11 +43,11 @@ typedef struct
43{ 43{
44 uint32_t encrypt_subkeys[96]; 44 uint32_t encrypt_subkeys[96];
45 uint32_t decrypt_subkeys[96]; 45 uint32_t decrypt_subkeys[96];
46} gl_3des_ctx; 46} MHD_gl_3des_ctx;
47 47
48/* Check whether the 8 byte key is weak. Does not check the parity 48/* Check whether the 8 byte key is weak. Does not check the parity
49 * bits of the key but simple ignore them. */ 49 * bits of the key but simple ignore them. */
50extern bool gl_des_is_weak_key (const char *key); 50extern bool MHD_gl_des_is_weak_key (const char *key);
51 51
52/* 52/*
53 * DES 53 * DES
@@ -57,20 +57,20 @@ extern bool gl_des_is_weak_key (const char *key);
57/* Fill a DES context CTX with subkeys calculated from 64bit KEY. 57/* Fill a DES context CTX with subkeys calculated from 64bit KEY.
58 * Does not check parity bits, but simply ignore them. Does not check 58 * Does not check parity bits, but simply ignore them. Does not check
59 * for weak keys. */ 59 * for weak keys. */
60extern void gl_des_setkey (gl_des_ctx * ctx, const char *key); 60extern void MHD_gl_des_setkey (MHD_gl_des_ctx * ctx, const char *key);
61 61
62/* Fill a DES context CTX with subkeys calculated from 64bit KEY, with 62/* Fill a DES context CTX with subkeys calculated from 64bit KEY, with
63 * weak key checking. Does not check parity bits, but simply ignore 63 * weak key checking. Does not check parity bits, but simply ignore
64 * them. */ 64 * them. */
65extern bool gl_des_makekey (gl_des_ctx * ctx, const char *key, size_t keylen); 65extern bool MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, size_t keylen);
66 66
67/* Electronic Codebook Mode DES encryption/decryption of data 67/* Electronic Codebook Mode DES encryption/decryption of data
68 * according to 'mode'. */ 68 * according to 'mode'. */
69extern void 69extern void
70gl_des_ecb_crypt (gl_des_ctx * ctx, const char *from, char *to, int mode); 70MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *from, char *to, int mode);
71 71
72#define gl_des_ecb_encrypt(ctx, from, to) gl_des_ecb_crypt(ctx, from, to, 0) 72#define MHD_gl_des_ecb_encrypt(ctx, from, to) MHD_gl_des_ecb_crypt(ctx, from, to, 0)
73#define gl_des_ecb_decrypt(ctx, from, to) gl_des_ecb_crypt(ctx, from, to, 1) 73#define MHD_gl_des_ecb_decrypt(ctx, from, to) MHD_gl_des_ecb_crypt(ctx, from, to, 1)
74 74
75/* Triple-DES 75/* Triple-DES
76 * ---------- 76 * ----------
@@ -80,7 +80,7 @@ gl_des_ecb_crypt (gl_des_ctx * ctx, const char *from, char *to, int mode);
80 * 64bit keys in KEY1 and KEY2. Does not check the parity bits of the 80 * 64bit keys in KEY1 and KEY2. Does not check the parity bits of the
81 * keys, but simply ignore them. Does not check for weak keys. */ 81 * keys, but simply ignore them. Does not check for weak keys. */
82extern void 82extern void
83gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2); 83MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2);
84 84
85/* 85/*
86 * Fill a Triple-DES context CTX with subkeys calculated from three 86 * Fill a Triple-DES context CTX with subkeys calculated from three
@@ -88,22 +88,22 @@ gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2);
88 * of the keys, but simply ignore them. Does not check for weak 88 * of the keys, but simply ignore them. Does not check for weak
89 * keys. */ 89 * keys. */
90extern void 90extern void
91gl_3des_set3keys (gl_3des_ctx * ctx, 91MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx,
92 const char *key1, const char *key2, const char *key3); 92 const char *key1, const char *key2, const char *key3);
93 93
94/* Fill a Triple-DES context CTX with subkeys calculated from three 94/* Fill a Triple-DES context CTX with subkeys calculated from three
95 * concatenated 64bit keys in KEY, with weak key checking. Does not 95 * concatenated 64bit keys in KEY, with weak key checking. Does not
96 * check the parity bits of the keys, but simply ignore them. */ 96 * check the parity bits of the keys, but simply ignore them. */
97extern bool 97extern bool
98gl_3des_makekey (gl_3des_ctx * ctx, const char *key, size_t keylen); 98MHD_gl_3des_makekey (MHD_gl_3des_ctx * ctx, const char *key, size_t keylen);
99 99
100/* Electronic Codebook Mode Triple-DES encryption/decryption of data 100/* Electronic Codebook Mode Triple-DES encryption/decryption of data
101 * according to 'mode'. Sometimes this mode is named 'EDE' mode 101 * according to 'mode'. Sometimes this mode is named 'EDE' mode
102 * (Encryption-Decryption-Encryption). */ 102 * (Encryption-Decryption-Encryption). */
103extern void 103extern void
104gl_3des_ecb_crypt (gl_3des_ctx * ctx, const char *from, char *to, int mode); 104MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *from, char *to, int mode);
105 105
106#define gl_3des_ecb_encrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,0) 106#define MHD_gl_3des_ecb_encrypt(ctx, from, to) MHD_gl_3des_ecb_crypt(ctx,from,to,0)
107#define gl_3des_ecb_decrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,1) 107#define MHD_gl_3des_ecb_decrypt(ctx, from, to) MHD_gl_3des_ecb_crypt(ctx,from,to,1)
108 108
109#endif /* DES_H */ 109#endif /* DES_H */
diff --git a/src/daemon/https/lgl/gc-gnulib.c b/src/daemon/https/lgl/gc-gnulib.c
index 237eb45c..46448679 100644
--- a/src/daemon/https/lgl/gc-gnulib.c
+++ b/src/daemon/https/lgl/gc-gnulib.c
@@ -68,13 +68,13 @@
68#undef close 68#undef close
69 69
70Gc_rc 70Gc_rc
71gc_init (void) 71MHD_gc_init (void)
72{ 72{
73 return GC_OK; 73 return GC_OK;
74} 74}
75 75
76void 76void
77gc_done (void) 77MHD_gc_done (void)
78{ 78{
79 return; 79 return;
80} 80}
@@ -139,19 +139,19 @@ randomize (int level, char *data, size_t datalen)
139} 139}
140 140
141Gc_rc 141Gc_rc
142gc_nonce (char *data, size_t datalen) 142MHD_gc_nonce (char *data, size_t datalen)
143{ 143{
144 return randomize (0, data, datalen); 144 return randomize (0, data, datalen);
145} 145}
146 146
147Gc_rc 147Gc_rc
148gc_pseudo_random (char *data, size_t datalen) 148MHD_gc_pseudo_random (char *data, size_t datalen)
149{ 149{
150 return randomize (1, data, datalen); 150 return randomize (1, data, datalen);
151} 151}
152 152
153Gc_rc 153Gc_rc
154gc_random (char *data, size_t datalen) 154MHD_gc_random (char *data, size_t datalen)
155{ 155{
156 return randomize (2, data, datalen); 156 return randomize (2, data, datalen);
157} 157}
@@ -160,17 +160,17 @@ gc_random (char *data, size_t datalen)
160 160
161/* Memory allocation. */ 161/* Memory allocation. */
162void 162void
163gc_set_allocators (gc_malloc_t func_malloc, 163MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
164 gc_malloc_t secure_malloc, 164 MHD_gc_malloc_t secure_malloc,
165 gc_secure_check_t secure_check, 165 MHD_gc_secure_check_t secure_check,
166 gc_realloc_t func_realloc, gc_free_t func_free) 166 MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free)
167{ 167{
168 return; 168 return;
169} 169}
170 170
171/* Ciphers. */ 171/* Ciphers. */
172 172
173typedef struct _gc_cipher_ctx 173typedef struct _MHD_gc_cipher_ctx
174{ 174{
175 Gc_cipher alg; 175 Gc_cipher alg;
176 Gc_cipher_mode mode; 176 Gc_cipher_mode mode;
@@ -182,20 +182,20 @@ typedef struct _gc_cipher_ctx
182 arcfour_context arcfourContext; 182 arcfour_context arcfourContext;
183#endif 183#endif
184#ifdef GNULIB_GC_DES 184#ifdef GNULIB_GC_DES
185 gl_des_ctx desContext; 185 MHD_gl_des_ctx desContext;
186#endif 186#endif
187#ifdef GNULIB_GC_RIJNDAEL 187#ifdef GNULIB_GC_RIJNDAEL
188 rijndaelKeyInstance aesEncKey; 188 rijndaelKeyInstance aesEncKey;
189 rijndaelKeyInstance aesDecKey; 189 rijndaelKeyInstance aesDecKey;
190 rijndaelCipherInstance aesContext; 190 rijndaelCipherInstance aesContext;
191#endif 191#endif
192} _gc_cipher_ctx; 192} _MHD_gc_cipher_ctx;
193 193
194Gc_rc 194Gc_rc
195gc_cipher_open (Gc_cipher alg, 195MHD_gc_cipher_open (Gc_cipher alg,
196 Gc_cipher_mode mode, gc_cipher_handle * outhandle) 196 Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle)
197{ 197{
198 _gc_cipher_ctx *ctx; 198 _MHD_gc_cipher_ctx *ctx;
199 Gc_rc rc = GC_OK; 199 Gc_rc rc = GC_OK;
200 200
201 ctx = calloc (sizeof (*ctx), 1); 201 ctx = calloc (sizeof (*ctx), 1);
@@ -277,9 +277,9 @@ gc_cipher_open (Gc_cipher alg,
277} 277}
278 278
279Gc_rc 279Gc_rc
280gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key) 280MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *key)
281{ 281{
282 _gc_cipher_ctx *ctx = handle; 282 _MHD_gc_cipher_ctx *ctx = handle;
283 283
284 switch (ctx->alg) 284 switch (ctx->alg)
285 { 285 {
@@ -300,7 +300,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
300 case GC_DES: 300 case GC_DES:
301 if (keylen != 8) 301 if (keylen != 8)
302 return GC_INVALID_CIPHER; 302 return GC_INVALID_CIPHER;
303 gl_des_setkey (&ctx->desContext, key); 303 MHD_gl_des_setkey (&ctx->desContext, key);
304 break; 304 break;
305#endif 305#endif
306 306
@@ -341,9 +341,9 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
341} 341}
342 342
343Gc_rc 343Gc_rc
344gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv) 344MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv)
345{ 345{
346 _gc_cipher_ctx *ctx = handle; 346 _MHD_gc_cipher_ctx *ctx = handle;
347 347
348 switch (ctx->alg) 348 switch (ctx->alg)
349 { 349 {
@@ -395,9 +395,9 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
395} 395}
396 396
397Gc_rc 397Gc_rc
398gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data) 398MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
399{ 399{
400 _gc_cipher_ctx *ctx = handle; 400 _MHD_gc_cipher_ctx *ctx = handle;
401 401
402 switch (ctx->alg) 402 switch (ctx->alg)
403 { 403 {
@@ -438,7 +438,7 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
438#ifdef GNULIB_GC_DES 438#ifdef GNULIB_GC_DES
439 case GC_DES: 439 case GC_DES:
440 for (; len >= 8; len -= 8, data += 8) 440 for (; len >= 8; len -= 8, data += 8)
441 gl_des_ecb_encrypt (&ctx->desContext, data, data); 441 MHD_gl_des_ecb_encrypt (&ctx->desContext, data, data);
442 break; 442 break;
443#endif 443#endif
444 444
@@ -465,9 +465,9 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
465} 465}
466 466
467Gc_rc 467Gc_rc
468gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data) 468MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
469{ 469{
470 _gc_cipher_ctx *ctx = handle; 470 _MHD_gc_cipher_ctx *ctx = handle;
471 471
472 switch (ctx->alg) 472 switch (ctx->alg)
473 { 473 {
@@ -510,7 +510,7 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
510#ifdef GNULIB_GC_DES 510#ifdef GNULIB_GC_DES
511 case GC_DES: 511 case GC_DES:
512 for (; len >= 8; len -= 8, data += 8) 512 for (; len >= 8; len -= 8, data += 8)
513 gl_des_ecb_decrypt (&ctx->desContext, data, data); 513 MHD_gl_des_ecb_decrypt (&ctx->desContext, data, data);
514 break; 514 break;
515#endif 515#endif
516 516
@@ -537,9 +537,9 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
537} 537}
538 538
539Gc_rc 539Gc_rc
540gc_cipher_close (gc_cipher_handle handle) 540MHD_gc_cipher_close (MHD_gc_cipher_handle handle)
541{ 541{
542 _gc_cipher_ctx *ctx = handle; 542 _MHD_gc_cipher_ctx *ctx = handle;
543 543
544 if (ctx) 544 if (ctx)
545 free (ctx); 545 free (ctx);
@@ -551,23 +551,23 @@ gc_cipher_close (gc_cipher_handle handle)
551 551
552#define MAX_DIGEST_SIZE 20 552#define MAX_DIGEST_SIZE 20
553 553
554typedef struct _gc_hash_ctx 554typedef struct _MHD_gc_hash_ctx
555{ 555{
556 Gc_hash alg; 556 Gc_hash alg;
557 Gc_hash_mode mode; 557 Gc_hash_mode mode;
558 char hash[MAX_DIGEST_SIZE]; 558 char hash[MAX_DIGEST_SIZE];
559#ifdef GNULIB_GC_MD5 559#ifdef GNULIB_GC_MD5
560 struct md5_ctx md5Context; 560 struct MHD_md5_ctx md5Context;
561#endif 561#endif
562#ifdef GNULIB_GC_SHA1 562#ifdef GNULIB_GC_SHA1
563 struct sha1_ctx sha1Context; 563 struct MHD_sha1_ctx sha1Context;
564#endif 564#endif
565} _gc_hash_ctx; 565} _MHD_gc_hash_ctx;
566 566
567Gc_rc 567Gc_rc
568gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle) 568MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, MHD_gc_hash_handle * outhandle)
569{ 569{
570 _gc_hash_ctx *ctx; 570 _MHD_gc_hash_ctx *ctx;
571 Gc_rc rc = GC_OK; 571 Gc_rc rc = GC_OK;
572 572
573 ctx = calloc (sizeof (*ctx), 1); 573 ctx = calloc (sizeof (*ctx), 1);
@@ -581,13 +581,13 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
581 { 581 {
582#ifdef GNULIB_GC_MD5 582#ifdef GNULIB_GC_MD5
583 case GC_MD5: 583 case GC_MD5:
584 md5_init_ctx (&ctx->md5Context); 584 MHD_md5_init_ctx (&ctx->md5Context);
585 break; 585 break;
586#endif 586#endif
587 587
588#ifdef GNULIB_GC_SHA1 588#ifdef GNULIB_GC_SHA1
589 case GC_SHA1: 589 case GC_SHA1:
590 sha1_init_ctx (&ctx->sha1Context); 590 MHD_sha1_init_ctx (&ctx->sha1Context);
591 break; 591 break;
592#endif 592#endif
593 593
@@ -615,10 +615,10 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
615} 615}
616 616
617Gc_rc 617Gc_rc
618gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle) 618MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle)
619{ 619{
620 _gc_hash_ctx *in = handle; 620 _MHD_gc_hash_ctx *in = handle;
621 _gc_hash_ctx *out; 621 _MHD_gc_hash_ctx *out;
622 622
623 *outhandle = out = calloc (sizeof (*out), 1); 623 *outhandle = out = calloc (sizeof (*out), 1);
624 if (!out) 624 if (!out)
@@ -630,7 +630,7 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
630} 630}
631 631
632size_t 632size_t
633gc_hash_digest_length (Gc_hash hash) 633MHD_gc_hash_digest_length (Gc_hash hash)
634{ 634{
635 size_t len; 635 size_t len;
636 636
@@ -664,21 +664,21 @@ gc_hash_digest_length (Gc_hash hash)
664} 664}
665 665
666void 666void
667gc_hash_write (gc_hash_handle handle, size_t len, const char *data) 667MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data)
668{ 668{
669 _gc_hash_ctx *ctx = handle; 669 _MHD_gc_hash_ctx *ctx = handle;
670 670
671 switch (ctx->alg) 671 switch (ctx->alg)
672 { 672 {
673#ifdef GNULIB_GC_MD5 673#ifdef GNULIB_GC_MD5
674 case GC_MD5: 674 case GC_MD5:
675 md5_process_bytes (data, len, &ctx->md5Context); 675 MHD_md5_process_bytes (data, len, &ctx->md5Context);
676 break; 676 break;
677#endif 677#endif
678 678
679#ifdef GNULIB_GC_SHA1 679#ifdef GNULIB_GC_SHA1
680 case GC_SHA1: 680 case GC_SHA1:
681 sha1_process_bytes (data, len, &ctx->sha1Context); 681 MHD_sha1_process_bytes (data, len, &ctx->sha1Context);
682 break; 682 break;
683#endif 683#endif
684 684
@@ -688,23 +688,23 @@ gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
688} 688}
689 689
690const char * 690const char *
691gc_hash_read (gc_hash_handle handle) 691MHD_gc_hash_read (MHD_gc_hash_handle handle)
692{ 692{
693 _gc_hash_ctx *ctx = handle; 693 _MHD_gc_hash_ctx *ctx = handle;
694 const char *ret = NULL; 694 const char *ret = NULL;
695 695
696 switch (ctx->alg) 696 switch (ctx->alg)
697 { 697 {
698#ifdef GNULIB_GC_MD5 698#ifdef GNULIB_GC_MD5
699 case GC_MD5: 699 case GC_MD5:
700 md5_finish_ctx (&ctx->md5Context, ctx->hash); 700 MHD_md5_finish_ctx (&ctx->md5Context, ctx->hash);
701 ret = ctx->hash; 701 ret = ctx->hash;
702 break; 702 break;
703#endif 703#endif
704 704
705#ifdef GNULIB_GC_SHA1 705#ifdef GNULIB_GC_SHA1
706 case GC_SHA1: 706 case GC_SHA1:
707 sha1_finish_ctx (&ctx->sha1Context, ctx->hash); 707 MHD_sha1_finish_ctx (&ctx->sha1Context, ctx->hash);
708 ret = ctx->hash; 708 ret = ctx->hash;
709 break; 709 break;
710#endif 710#endif
@@ -717,27 +717,27 @@ gc_hash_read (gc_hash_handle handle)
717} 717}
718 718
719void 719void
720gc_hash_close (gc_hash_handle handle) 720MHD_gc_hash_close (MHD_gc_hash_handle handle)
721{ 721{
722 _gc_hash_ctx *ctx = handle; 722 _MHD_gc_hash_ctx *ctx = handle;
723 723
724 free (ctx); 724 free (ctx);
725} 725}
726 726
727Gc_rc 727Gc_rc
728gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) 728MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
729{ 729{
730 switch (hash) 730 switch (hash)
731 { 731 {
732#ifdef GNULIB_GC_MD5 732#ifdef GNULIB_GC_MD5
733 case GC_MD5: 733 case GC_MD5:
734 md5_buffer (in, inlen, resbuf); 734 MHD_md5_buffer (in, inlen, resbuf);
735 break; 735 break;
736#endif 736#endif
737 737
738#ifdef GNULIB_GC_SHA1 738#ifdef GNULIB_GC_SHA1
739 case GC_SHA1: 739 case GC_SHA1:
740 sha1_buffer (in, inlen, resbuf); 740 MHD_sha1_buffer (in, inlen, resbuf);
741 break; 741 break;
742#endif 742#endif
743 743
@@ -750,38 +750,38 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
750 750
751#ifdef GNULIB_GC_MD5 751#ifdef GNULIB_GC_MD5
752Gc_rc 752Gc_rc
753gc_md5 (const void *in, size_t inlen, void *resbuf) 753MHD_gc_md5 (const void *in, size_t inlen, void *resbuf)
754{ 754{
755 md5_buffer (in, inlen, resbuf); 755 MHD_md5_buffer (in, inlen, resbuf);
756 return GC_OK; 756 return GC_OK;
757} 757}
758#endif 758#endif
759 759
760#ifdef GNULIB_GC_SHA1 760#ifdef GNULIB_GC_SHA1
761Gc_rc 761Gc_rc
762gc_sha1 (const void *in, size_t inlen, void *resbuf) 762MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf)
763{ 763{
764 sha1_buffer (in, inlen, resbuf); 764 MHD_sha1_buffer (in, inlen, resbuf);
765 return GC_OK; 765 return GC_OK;
766} 766}
767#endif 767#endif
768 768
769#ifdef GNULIB_GC_HMAC_MD5 769#ifdef GNULIB_GC_HMAC_MD5
770Gc_rc 770Gc_rc
771gc_hmac_md5 (const void *key, size_t keylen, 771MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen,
772 const void *in, size_t inlen, char *resbuf) 772 const void *in, size_t inlen, char *resbuf)
773{ 773{
774 hmac_md5 (key, keylen, in, inlen, resbuf); 774 MHD_hmac_md5 (key, keylen, in, inlen, resbuf);
775 return GC_OK; 775 return GC_OK;
776} 776}
777#endif 777#endif
778 778
779#ifdef GNULIB_GC_HMAC_SHA1 779#ifdef GNULIB_GC_HMAC_SHA1
780Gc_rc 780Gc_rc
781gc_hmac_sha1 (const void *key, 781MHD_gc_MHD_hmac_sha1 (const void *key,
782 size_t keylen, const void *in, size_t inlen, char *resbuf) 782 size_t keylen, const void *in, size_t inlen, char *resbuf)
783{ 783{
784 hmac_sha1 (key, keylen, in, inlen, resbuf); 784 MHD_hmac_sha1 (key, keylen, in, inlen, resbuf);
785 return GC_OK; 785 return GC_OK;
786} 786}
787#endif 787#endif
diff --git a/src/daemon/https/lgl/gc-libgcrypt.c b/src/daemon/https/lgl/gc-libgcrypt.c
index 884bf31a..2a87d482 100644
--- a/src/daemon/https/lgl/gc-libgcrypt.c
+++ b/src/daemon/https/lgl/gc-libgcrypt.c
@@ -36,7 +36,7 @@
36/* Initialization. */ 36/* Initialization. */
37 37
38Gc_rc 38Gc_rc
39gc_init (void) 39MHD_gc_init (void)
40{ 40{
41 gcry_error_t err; 41 gcry_error_t err;
42 42
@@ -54,7 +54,7 @@ gc_init (void)
54} 54}
55 55
56void 56void
57gc_done (void) 57MHD_gc_done (void)
58{ 58{
59 return; 59 return;
60} 60}
@@ -64,21 +64,21 @@ gc_done (void)
64/* Randomness. */ 64/* Randomness. */
65 65
66Gc_rc 66Gc_rc
67gc_nonce (char *data, size_t datalen) 67MHD_gc_nonce (char *data, size_t datalen)
68{ 68{
69 gcry_create_nonce ((unsigned char *) data, datalen); 69 gcry_create_nonce ((unsigned char *) data, datalen);
70 return GC_OK; 70 return GC_OK;
71} 71}
72 72
73Gc_rc 73Gc_rc
74gc_pseudo_random (char *data, size_t datalen) 74MHD_gc_pseudo_random (char *data, size_t datalen)
75{ 75{
76 gcry_randomize ((unsigned char *) data, datalen, GCRY_STRONG_RANDOM); 76 gcry_randomize ((unsigned char *) data, datalen, GCRY_STRONG_RANDOM);
77 return GC_OK; 77 return GC_OK;
78} 78}
79 79
80Gc_rc 80Gc_rc
81gc_random (char *data, size_t datalen) 81MHD_gc_random (char *data, size_t datalen)
82{ 82{
83 gcry_randomize ((unsigned char *) data, datalen, GCRY_VERY_STRONG_RANDOM); 83 gcry_randomize ((unsigned char *) data, datalen, GCRY_VERY_STRONG_RANDOM);
84 return GC_OK; 84 return GC_OK;
@@ -89,10 +89,10 @@ gc_random (char *data, size_t datalen)
89/* Memory allocation. */ 89/* Memory allocation. */
90 90
91void 91void
92gc_set_allocators (gc_malloc_t func_malloc, 92MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
93 gc_malloc_t secure_malloc, 93 MHD_gc_malloc_t secure_malloc,
94 gc_secure_check_t secure_check, 94 MHD_gc_secure_check_t secure_check,
95 gc_realloc_t func_realloc, gc_free_t func_free) 95 MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free)
96{ 96{
97 gcry_set_allocation_handler (func_malloc, secure_malloc, secure_check, 97 gcry_set_allocation_handler (func_malloc, secure_malloc, secure_check,
98 func_realloc, func_free); 98 func_realloc, func_free);
@@ -101,8 +101,8 @@ gc_set_allocators (gc_malloc_t func_malloc,
101/* Ciphers. */ 101/* Ciphers. */
102 102
103Gc_rc 103Gc_rc
104gc_cipher_open (Gc_cipher alg, 104MHD_gc_cipher_open (Gc_cipher alg,
105 Gc_cipher_mode mode, gc_cipher_handle * outhandle) 105 Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle)
106{ 106{
107 int gcryalg, gcrymode; 107 int gcryalg, gcrymode;
108 gcry_error_t err; 108 gcry_error_t err;
@@ -179,7 +179,7 @@ gc_cipher_open (Gc_cipher alg,
179} 179}
180 180
181Gc_rc 181Gc_rc
182gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key) 182MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *key)
183{ 183{
184 gcry_error_t err; 184 gcry_error_t err;
185 185
@@ -191,7 +191,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
191} 191}
192 192
193Gc_rc 193Gc_rc
194gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv) 194MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv)
195{ 195{
196 gcry_error_t err; 196 gcry_error_t err;
197 197
@@ -203,7 +203,7 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
203} 203}
204 204
205Gc_rc 205Gc_rc
206gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data) 206MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
207{ 207{
208 if (gcry_cipher_encrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) != 208 if (gcry_cipher_encrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) !=
209 0) 209 0)
@@ -213,7 +213,7 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
213} 213}
214 214
215Gc_rc 215Gc_rc
216gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data) 216MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
217{ 217{
218 if (gcry_cipher_decrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) != 218 if (gcry_cipher_decrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) !=
219 0) 219 0)
@@ -223,7 +223,7 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
223} 223}
224 224
225Gc_rc 225Gc_rc
226gc_cipher_close (gc_cipher_handle handle) 226MHD_gc_cipher_close (MHD_gc_cipher_handle handle)
227{ 227{
228 gcry_cipher_close (handle); 228 gcry_cipher_close (handle);
229 229
@@ -232,17 +232,17 @@ gc_cipher_close (gc_cipher_handle handle)
232 232
233/* Hashes. */ 233/* Hashes. */
234 234
235typedef struct _gc_hash_ctx 235typedef struct _MHD_gc_hash_ctx
236{ 236{
237 Gc_hash alg; 237 Gc_hash alg;
238 Gc_hash_mode mode; 238 Gc_hash_mode mode;
239 gcry_md_hd_t gch; 239 gcry_md_hd_t gch;
240} _gc_hash_ctx; 240} _MHD_gc_hash_ctx;
241 241
242Gc_rc 242Gc_rc
243gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle) 243MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, MHD_gc_hash_handle * outhandle)
244{ 244{
245 _gc_hash_ctx *ctx; 245 _MHD_gc_hash_ctx *ctx;
246 int gcryalg = 0, gcrymode = 0; 246 int gcryalg = 0, gcrymode = 0;
247 gcry_error_t err; 247 gcry_error_t err;
248 Gc_rc rc = GC_OK; 248 Gc_rc rc = GC_OK;
@@ -322,10 +322,10 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
322} 322}
323 323
324Gc_rc 324Gc_rc
325gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle) 325MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle)
326{ 326{
327 _gc_hash_ctx *in = handle; 327 _MHD_gc_hash_ctx *in = handle;
328 _gc_hash_ctx *out; 328 _MHD_gc_hash_ctx *out;
329 int err; 329 int err;
330 330
331 *outhandle = out = calloc (sizeof (*out), 1); 331 *outhandle = out = calloc (sizeof (*out), 1);
@@ -345,7 +345,7 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
345} 345}
346 346
347size_t 347size_t
348gc_hash_digest_length (Gc_hash hash) 348MHD_gc_hash_digest_length (Gc_hash hash)
349{ 349{
350 size_t len; 350 size_t len;
351 351
@@ -391,23 +391,23 @@ gc_hash_digest_length (Gc_hash hash)
391} 391}
392 392
393void 393void
394gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key) 394MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, const char *key)
395{ 395{
396 _gc_hash_ctx *ctx = handle; 396 _MHD_gc_hash_ctx *ctx = handle;
397 gcry_md_setkey (ctx->gch, key, len); 397 gcry_md_setkey (ctx->gch, key, len);
398} 398}
399 399
400void 400void
401gc_hash_write (gc_hash_handle handle, size_t len, const char *data) 401MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data)
402{ 402{
403 _gc_hash_ctx *ctx = handle; 403 _MHD_gc_hash_ctx *ctx = handle;
404 gcry_md_write (ctx->gch, data, len); 404 gcry_md_write (ctx->gch, data, len);
405} 405}
406 406
407const char * 407const char *
408gc_hash_read (gc_hash_handle handle) 408MHD_gc_hash_read (MHD_gc_hash_handle handle)
409{ 409{
410 _gc_hash_ctx *ctx = handle; 410 _MHD_gc_hash_ctx *ctx = handle;
411 const char *digest; 411 const char *digest;
412 { 412 {
413 gcry_md_final (ctx->gch); 413 gcry_md_final (ctx->gch);
@@ -418,9 +418,9 @@ gc_hash_read (gc_hash_handle handle)
418} 418}
419 419
420void 420void
421gc_hash_close (gc_hash_handle handle) 421MHD_gc_hash_close (MHD_gc_hash_handle handle)
422{ 422{
423 _gc_hash_ctx *ctx = handle; 423 _MHD_gc_hash_ctx *ctx = handle;
424 424
425 gcry_md_close (ctx->gch); 425 gcry_md_close (ctx->gch);
426 426
@@ -428,7 +428,7 @@ gc_hash_close (gc_hash_handle handle)
428} 428}
429 429
430Gc_rc 430Gc_rc
431gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) 431MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
432{ 432{
433 int gcryalg; 433 int gcryalg;
434 434
@@ -482,7 +482,7 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
482/* One-call interface. */ 482/* One-call interface. */
483#ifdef GNULIB_GC_MD5 483#ifdef GNULIB_GC_MD5
484Gc_rc 484Gc_rc
485gc_md5 (const void *in, size_t inlen, void *resbuf) 485MHD_gc_md5 (const void *in, size_t inlen, void *resbuf)
486{ 486{
487 size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD5); 487 size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
488 gcry_md_hd_t hd; 488 gcry_md_hd_t hd;
@@ -514,7 +514,7 @@ gc_md5 (const void *in, size_t inlen, void *resbuf)
514 514
515#ifdef GNULIB_GC_SHA1 515#ifdef GNULIB_GC_SHA1
516Gc_rc 516Gc_rc
517gc_sha1 (const void *in, size_t inlen, void *resbuf) 517MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf)
518{ 518{
519 size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1); 519 size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
520 gcry_md_hd_t hd; 520 gcry_md_hd_t hd;
@@ -546,7 +546,7 @@ gc_sha1 (const void *in, size_t inlen, void *resbuf)
546 546
547#ifdef GNULIB_GC_HMAC_MD5 547#ifdef GNULIB_GC_HMAC_MD5
548Gc_rc 548Gc_rc
549gc_hmac_md5 (const void *key, size_t keylen, 549MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen,
550 const void *in, size_t inlen, char *resbuf) 550 const void *in, size_t inlen, char *resbuf)
551{ 551{
552 size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_MD5); 552 size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
@@ -586,7 +586,7 @@ gc_hmac_md5 (const void *key, size_t keylen,
586 586
587#ifdef GNULIB_GC_HMAC_SHA1 587#ifdef GNULIB_GC_HMAC_SHA1
588Gc_rc 588Gc_rc
589gc_hmac_sha1 (const void *key, 589MHD_gc_MHD_hmac_sha1 (const void *key,
590 size_t keylen, const void *in, size_t inlen, char *resbuf) 590 size_t keylen, const void *in, size_t inlen, char *resbuf)
591{ 591{
592 size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1); 592 size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
diff --git a/src/daemon/https/lgl/gc-pbkdf2-sha1.c b/src/daemon/https/lgl/gc-pbkdf2-sha1.c
index b29b42fd..98ac9f96 100644
--- a/src/daemon/https/lgl/gc-pbkdf2-sha1.c
+++ b/src/daemon/https/lgl/gc-pbkdf2-sha1.c
@@ -52,7 +52,7 @@
52 */ 52 */
53 53
54Gc_rc 54Gc_rc
55gc_pbkdf2_sha1 (const char *P, size_t Plen, 55MHD_gc_pbkdf2_sha1 (const char *P, size_t Plen,
56 const char *S, size_t Slen, 56 const char *S, size_t Slen,
57 unsigned int c, char *DK, size_t dkLen) 57 unsigned int c, char *DK, size_t dkLen)
58{ 58{
@@ -161,10 +161,10 @@ gc_pbkdf2_sha1 (const char *P, size_t Plen,
161 tmp[Slen + 2] = (i & 0x0000ff00) >> 8; 161 tmp[Slen + 2] = (i & 0x0000ff00) >> 8;
162 tmp[Slen + 3] = (i & 0x000000ff) >> 0; 162 tmp[Slen + 3] = (i & 0x000000ff) >> 0;
163 163
164 rc = gc_hmac_sha1 (P, Plen, tmp, tmplen, U); 164 rc = MHD_gc_MHD_hmac_sha1 (P, Plen, tmp, tmplen, U);
165 } 165 }
166 else 166 else
167 rc = gc_hmac_sha1 (P, Plen, U, hLen, U); 167 rc = MHD_gc_MHD_hmac_sha1 (P, Plen, U, hLen, U);
168 168
169 if (rc != GC_OK) 169 if (rc != GC_OK)
170 { 170 {
diff --git a/src/daemon/https/lgl/gc.h b/src/daemon/https/lgl/gc.h
index 1e1f808c..ecc506fc 100644
--- a/src/daemon/https/lgl/gc.h
+++ b/src/daemon/https/lgl/gc.h
@@ -58,7 +58,7 @@ enum Gc_hash_mode
58}; 58};
59typedef enum Gc_hash_mode Gc_hash_mode; 59typedef enum Gc_hash_mode Gc_hash_mode;
60 60
61typedef void *gc_hash_handle; 61typedef void *MHD_gc_hash_handle;
62 62
63#define GC_MD2_DIGEST_SIZE 16 63#define GC_MD2_DIGEST_SIZE 16
64#define GC_MD4_DIGEST_SIZE 16 64#define GC_MD4_DIGEST_SIZE 16
@@ -93,49 +93,49 @@ enum Gc_cipher_mode
93}; 93};
94typedef enum Gc_cipher_mode Gc_cipher_mode; 94typedef enum Gc_cipher_mode Gc_cipher_mode;
95 95
96typedef void *gc_cipher_handle; 96typedef void *MHD_gc_cipher_handle;
97 97
98/* Call before respectively after any other functions. */ 98/* Call before respectively after any other functions. */
99Gc_rc gc_init (void); 99Gc_rc MHD_gc_init (void);
100void gc_done (void); 100void MHD_gc_done (void);
101 101
102/* Memory allocation (avoid). */ 102/* Memory allocation (avoid). */
103typedef void *(*gc_malloc_t) (size_t n); 103typedef void *(*MHD_gc_malloc_t) (size_t n);
104typedef int (*gc_secure_check_t) (const void *); 104typedef int (*MHD_gc_secure_check_t) (const void *);
105typedef void *(*gc_realloc_t) (void *p, size_t n); 105typedef void *(*MHD_gc_realloc_t) (void *p, size_t n);
106typedef void (*gc_free_t) (void *); 106typedef void (*MHD_gc_free_t) (void *);
107void gc_set_allocators (gc_malloc_t func_malloc, 107void MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
108 gc_malloc_t secure_malloc, 108 MHD_gc_malloc_t secure_malloc,
109 gc_secure_check_t secure_check, 109 MHD_gc_secure_check_t secure_check,
110 gc_realloc_t func_realloc, gc_free_t func_free); 110 MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free);
111 111
112/* Randomness. */ 112/* Randomness. */
113Gc_rc gc_nonce (char *data, size_t datalen); 113Gc_rc MHD_gc_nonce (char *data, size_t datalen);
114Gc_rc gc_pseudo_random (char *data, size_t datalen); 114Gc_rc MHD_gc_pseudo_random (char *data, size_t datalen);
115Gc_rc gc_random (char *data, size_t datalen); 115Gc_rc MHD_gc_random (char *data, size_t datalen);
116 116
117/* Ciphers. */ 117/* Ciphers. */
118Gc_rc gc_cipher_open (Gc_cipher cipher, 118Gc_rc MHD_gc_cipher_open (Gc_cipher cipher,
119 Gc_cipher_mode mode, gc_cipher_handle * outhandle); 119 Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle);
120Gc_rc gc_cipher_setkey (gc_cipher_handle handle, 120Gc_rc MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle,
121 size_t keylen, const char *key); 121 size_t keylen, const char *key);
122Gc_rc gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv); 122Gc_rc MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv);
123Gc_rc gc_cipher_encrypt_inline (gc_cipher_handle handle, 123Gc_rc MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle,
124 size_t len, char *data); 124 size_t len, char *data);
125Gc_rc gc_cipher_decrypt_inline (gc_cipher_handle handle, 125Gc_rc MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle,
126 size_t len, char *data); 126 size_t len, char *data);
127Gc_rc gc_cipher_close (gc_cipher_handle handle); 127Gc_rc MHD_gc_cipher_close (MHD_gc_cipher_handle handle);
128 128
129/* Hashes. */ 129/* Hashes. */
130 130
131Gc_rc gc_hash_open (Gc_hash hash, 131Gc_rc MHD_gc_hash_open (Gc_hash hash,
132 Gc_hash_mode mode, gc_hash_handle * outhandle); 132 Gc_hash_mode mode, MHD_gc_hash_handle * outhandle);
133Gc_rc gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle); 133Gc_rc MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle);
134size_t gc_hash_digest_length (Gc_hash hash); 134size_t MHD_gc_hash_digest_length (Gc_hash hash);
135void gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key); 135void MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, const char *key);
136void gc_hash_write (gc_hash_handle handle, size_t len, const char *data); 136void MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data);
137const char *gc_hash_read (gc_hash_handle handle); 137const char *MHD_gc_hash_read (MHD_gc_hash_handle handle);
138void gc_hash_close (gc_hash_handle handle); 138void MHD_gc_hash_close (MHD_gc_hash_handle handle);
139 139
140/* Compute a hash value over buffer IN of INLEN bytes size using the 140/* Compute a hash value over buffer IN of INLEN bytes size using the
141 algorithm HASH, placing the result in the pre-allocated buffer OUT. 141 algorithm HASH, placing the result in the pre-allocated buffer OUT.
@@ -143,16 +143,16 @@ void gc_hash_close (gc_hash_handle handle);
143 GC_<HASH>_DIGEST_SIZE. For example, for GC_MD5 the output buffer 143 GC_<HASH>_DIGEST_SIZE. For example, for GC_MD5 the output buffer
144 must be 16 bytes. The return value is 0 (GC_OK) on success, or 144 must be 16 bytes. The return value is 0 (GC_OK) on success, or
145 another Gc_rc error code. */ 145 another Gc_rc error code. */
146Gc_rc gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out); 146Gc_rc MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out);
147 147
148/* One-call interface. */ 148/* One-call interface. */
149Gc_rc gc_md2 (const void *in, size_t inlen, void *resbuf); 149Gc_rc MHD_gc_md2 (const void *in, size_t inlen, void *resbuf);
150Gc_rc gc_md4 (const void *in, size_t inlen, void *resbuf); 150Gc_rc MHD_gc_md4 (const void *in, size_t inlen, void *resbuf);
151Gc_rc gc_md5 (const void *in, size_t inlen, void *resbuf); 151Gc_rc MHD_gc_md5 (const void *in, size_t inlen, void *resbuf);
152Gc_rc gc_sha1 (const void *in, size_t inlen, void *resbuf); 152Gc_rc MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf);
153Gc_rc gc_hmac_md5 (const void *key, 153Gc_rc MHD_gc_MHD_hmac_md5 (const void *key,
154 size_t keylen, const void *in, size_t inlen, char *resbuf); 154 size_t keylen, const void *in, size_t inlen, char *resbuf);
155Gc_rc gc_hmac_sha1 (const void *key, 155Gc_rc MHD_gc_MHD_hmac_sha1 (const void *key,
156 size_t keylen, 156 size_t keylen,
157 const void *in, size_t inlen, char *resbuf); 157 const void *in, size_t inlen, char *resbuf);
158 158
@@ -163,7 +163,7 @@ Gc_rc gc_hmac_sha1 (const void *key,
163 counts are 1000-20000). This function "stretches" the key to be 163 counts are 1000-20000). This function "stretches" the key to be
164 exactly dkLen bytes long. GC_OK is returned on success, otherwise 164 exactly dkLen bytes long. GC_OK is returned on success, otherwise
165 an Gc_rc error code is returned. */ 165 an Gc_rc error code is returned. */
166Gc_rc gc_pbkdf2_sha1 (const char *P, 166Gc_rc MHD_gc_pbkdf2_sha1 (const char *P,
167 size_t Plen, 167 size_t Plen,
168 const char *S, 168 const char *S,
169 size_t Slen, unsigned int c, char *DK, size_t dkLen); 169 size_t Slen, unsigned int c, char *DK, size_t dkLen);
@@ -285,7 +285,7 @@ Gc_rc gc_pbkdf2_sha1 (const char *P,
285 requirement, what entropy quality it require, and call the proper API. 285 requirement, what entropy quality it require, and call the proper API.
286 Meeting the implied semantic properties should be the job for gnulib. 286 Meeting the implied semantic properties should be the job for gnulib.
287 287
288 >> Perhaps gc_dev_random and gc_dev_urandom? 288 >> Perhaps MHD_gc_dev_random and MHD_gc_dev_urandom?
289 > 289 >
290 > To some extent. I'd rather insulate the user from the details of 290 > To some extent. I'd rather insulate the user from the details of
291 > where the random numbers come from. On the other hand we need to 291 > where the random numbers come from. On the other hand we need to
diff --git a/src/daemon/https/lgl/hmac-md5.c b/src/daemon/https/lgl/hmac-md5.c
index 1bd56103..fc6902a9 100644
--- a/src/daemon/https/lgl/hmac-md5.c
+++ b/src/daemon/https/lgl/hmac-md5.c
@@ -30,11 +30,11 @@
30#define OPAD 0x5c 30#define OPAD 0x5c
31 31
32int 32int
33hmac_md5 (const void *key, size_t keylen, 33MHD_hmac_md5 (const void *key, size_t keylen,
34 const void *in, size_t inlen, void *resbuf) 34 const void *in, size_t inlen, void *resbuf)
35{ 35{
36 struct md5_ctx inner; 36 struct MHD_md5_ctx inner;
37 struct md5_ctx outer; 37 struct MHD_md5_ctx outer;
38 char optkeybuf[16]; 38 char optkeybuf[16];
39 char block[64]; 39 char block[64];
40 char innerhash[16]; 40 char innerhash[16];
@@ -43,11 +43,11 @@ hmac_md5 (const void *key, size_t keylen,
43 43
44 if (keylen > 64) 44 if (keylen > 64)
45 { 45 {
46 struct md5_ctx keyhash; 46 struct MHD_md5_ctx keyhash;
47 47
48 md5_init_ctx (&keyhash); 48 MHD_md5_init_ctx (&keyhash);
49 md5_process_bytes (key, keylen, &keyhash); 49 MHD_md5_process_bytes (key, keylen, &keyhash);
50 md5_finish_ctx (&keyhash, optkeybuf); 50 MHD_md5_finish_ctx (&keyhash, optkeybuf);
51 51
52 key = optkeybuf; 52 key = optkeybuf;
53 keylen = 16; 53 keylen = 16;
@@ -55,27 +55,27 @@ hmac_md5 (const void *key, size_t keylen,
55 55
56 /* Compute INNERHASH from KEY and IN. */ 56 /* Compute INNERHASH from KEY and IN. */
57 57
58 md5_init_ctx (&inner); 58 MHD_md5_init_ctx (&inner);
59 59
60 memset (block, IPAD, sizeof (block)); 60 memset (block, IPAD, sizeof (block));
61 memxor (block, key, keylen); 61 MHD_memxor (block, key, keylen);
62 62
63 md5_process_block (block, 64, &inner); 63 MHD_md5_process_block (block, 64, &inner);
64 md5_process_bytes (in, inlen, &inner); 64 MHD_md5_process_bytes (in, inlen, &inner);
65 65
66 md5_finish_ctx (&inner, innerhash); 66 MHD_md5_finish_ctx (&inner, innerhash);
67 67
68 /* Compute result from KEY and INNERHASH. */ 68 /* Compute result from KEY and INNERHASH. */
69 69
70 md5_init_ctx (&outer); 70 MHD_md5_init_ctx (&outer);
71 71
72 memset (block, OPAD, sizeof (block)); 72 memset (block, OPAD, sizeof (block));
73 memxor (block, key, keylen); 73 MHD_memxor (block, key, keylen);
74 74
75 md5_process_block (block, 64, &outer); 75 MHD_md5_process_block (block, 64, &outer);
76 md5_process_bytes (innerhash, 16, &outer); 76 MHD_md5_process_bytes (innerhash, 16, &outer);
77 77
78 md5_finish_ctx (&outer, resbuf); 78 MHD_md5_finish_ctx (&outer, resbuf);
79 79
80 return 0; 80 return 0;
81} 81}
diff --git a/src/daemon/https/lgl/hmac-sha1.c b/src/daemon/https/lgl/hmac-sha1.c
index e634ad9c..5d341cb4 100644
--- a/src/daemon/https/lgl/hmac-sha1.c
+++ b/src/daemon/https/lgl/hmac-sha1.c
@@ -30,11 +30,11 @@
30#define OPAD 0x5c 30#define OPAD 0x5c
31 31
32int 32int
33hmac_sha1 (const void *key, size_t keylen, 33MHD_hmac_sha1 (const void *key, size_t keylen,
34 const void *in, size_t inlen, void *resbuf) 34 const void *in, size_t inlen, void *resbuf)
35{ 35{
36 struct sha1_ctx inner; 36 struct MHD_sha1_ctx inner;
37 struct sha1_ctx outer; 37 struct MHD_sha1_ctx outer;
38 char optkeybuf[20]; 38 char optkeybuf[20];
39 char block[64]; 39 char block[64];
40 char innerhash[20]; 40 char innerhash[20];
@@ -43,11 +43,11 @@ hmac_sha1 (const void *key, size_t keylen,
43 43
44 if (keylen > 64) 44 if (keylen > 64)
45 { 45 {
46 struct sha1_ctx keyhash; 46 struct MHD_sha1_ctx keyhash;
47 47
48 sha1_init_ctx (&keyhash); 48 MHD_sha1_init_ctx (&keyhash);
49 sha1_process_bytes (key, keylen, &keyhash); 49 MHD_sha1_process_bytes (key, keylen, &keyhash);
50 sha1_finish_ctx (&keyhash, optkeybuf); 50 MHD_sha1_finish_ctx (&keyhash, optkeybuf);
51 51
52 key = optkeybuf; 52 key = optkeybuf;
53 keylen = 20; 53 keylen = 20;
@@ -55,27 +55,27 @@ hmac_sha1 (const void *key, size_t keylen,
55 55
56 /* Compute INNERHASH from KEY and IN. */ 56 /* Compute INNERHASH from KEY and IN. */
57 57
58 sha1_init_ctx (&inner); 58 MHD_sha1_init_ctx (&inner);
59 59
60 memset (block, IPAD, sizeof (block)); 60 memset (block, IPAD, sizeof (block));
61 memxor (block, key, keylen); 61 MHD_memxor (block, key, keylen);
62 62
63 sha1_process_block (block, 64, &inner); 63 MHD_sha1_process_block (block, 64, &inner);
64 sha1_process_bytes (in, inlen, &inner); 64 MHD_sha1_process_bytes (in, inlen, &inner);
65 65
66 sha1_finish_ctx (&inner, innerhash); 66 MHD_sha1_finish_ctx (&inner, innerhash);
67 67
68 /* Compute result from KEY and INNERHASH. */ 68 /* Compute result from KEY and INNERHASH. */
69 69
70 sha1_init_ctx (&outer); 70 MHD_sha1_init_ctx (&outer);
71 71
72 memset (block, OPAD, sizeof (block)); 72 memset (block, OPAD, sizeof (block));
73 memxor (block, key, keylen); 73 MHD_memxor (block, key, keylen);
74 74
75 sha1_process_block (block, 64, &outer); 75 MHD_sha1_process_block (block, 64, &outer);
76 sha1_process_bytes (innerhash, 20, &outer); 76 MHD_sha1_process_bytes (innerhash, 20, &outer);
77 77
78 sha1_finish_ctx (&outer, resbuf); 78 MHD_sha1_finish_ctx (&outer, resbuf);
79 79
80 return 0; 80 return 0;
81} 81}
diff --git a/src/daemon/https/lgl/hmac.h b/src/daemon/https/lgl/hmac.h
index 78bcbb16..29764056 100644
--- a/src/daemon/https/lgl/hmac.h
+++ b/src/daemon/https/lgl/hmac.h
@@ -27,7 +27,7 @@
27 KEYLEN bytes, writing the output to pre-allocated 16 byte minimum 27 KEYLEN bytes, writing the output to pre-allocated 16 byte minimum
28 RESBUF buffer. Return 0 on success. */ 28 RESBUF buffer. Return 0 on success. */
29int 29int
30hmac_md5 (const void *key, size_t keylen, 30MHD_hmac_md5 (const void *key, size_t keylen,
31 const void *buffer, size_t buflen, void *resbuf); 31 const void *buffer, size_t buflen, void *resbuf);
32 32
33/* Compute Hashed Message Authentication Code with SHA-1, over BUFFER 33/* Compute Hashed Message Authentication Code with SHA-1, over BUFFER
@@ -35,7 +35,7 @@ hmac_md5 (const void *key, size_t keylen,
35 output to pre-allocated 20 byte minimum RESBUF buffer. Return 0 on 35 output to pre-allocated 20 byte minimum RESBUF buffer. Return 0 on
36 success. */ 36 success. */
37int 37int
38hmac_sha1 (const void *key, size_t keylen, 38MHD_hmac_sha1 (const void *key, size_t keylen,
39 const void *in, size_t inlen, void *resbuf); 39 const void *in, size_t inlen, void *resbuf);
40 40
41#endif /* HMAC_H */ 41#endif /* HMAC_H */
diff --git a/src/daemon/https/lgl/md5.c b/src/daemon/https/lgl/md5.c
index 51502d6e..bc1fccbc 100644
--- a/src/daemon/https/lgl/md5.c
+++ b/src/daemon/https/lgl/md5.c
@@ -40,13 +40,13 @@
40# endif 40# endif
41/* We need to keep the namespace clean so define the MD5 function 41/* We need to keep the namespace clean so define the MD5 function
42 protected using leading __ . */ 42 protected using leading __ . */
43# define md5_init_ctx __md5_init_ctx 43# define MHD_md5_init_ctx __MHD_md5_init_ctx
44# define md5_process_block __md5_process_block 44# define MHD_md5_process_block __MHD_md5_process_block
45# define md5_process_bytes __md5_process_bytes 45# define MHD_md5_process_bytes __MHD_md5_process_bytes
46# define md5_finish_ctx __md5_finish_ctx 46# define MHD_md5_finish_ctx __MHD_md5_finish_ctx
47# define md5_read_ctx __md5_read_ctx 47# define MHD_md5_read_ctx __MHD_md5_read_ctx
48# define md5_stream __md5_stream 48# define MHD_md5_stream __MHD_md5_stream
49# define md5_buffer __md5_buffer 49# define MHD_md5_buffer __MHD_md5_buffer
50#endif 50#endif
51 51
52#ifdef WORDS_BIGENDIAN 52#ifdef WORDS_BIGENDIAN
@@ -69,7 +69,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
69/* Initialize structure containing state of computation. 69/* Initialize structure containing state of computation.
70 (RFC 1321, 3.3: Step 3) */ 70 (RFC 1321, 3.3: Step 3) */
71void 71void
72md5_init_ctx (struct md5_ctx *ctx) 72MHD_md5_init_ctx (struct MHD_md5_ctx *ctx)
73{ 73{
74 ctx->A = 0x67452301; 74 ctx->A = 0x67452301;
75 ctx->B = 0xefcdab89; 75 ctx->B = 0xefcdab89;
@@ -86,7 +86,7 @@ md5_init_ctx (struct md5_ctx *ctx)
86 IMPORTANT: On some systems it is required that RESBUF is correctly 86 IMPORTANT: On some systems it is required that RESBUF is correctly
87 aligned for a 32-bit value. */ 87 aligned for a 32-bit value. */
88void * 88void *
89md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) 89MHD_md5_read_ctx (const struct MHD_md5_ctx *ctx, void *resbuf)
90{ 90{
91 ((uint32_t *) resbuf)[0] = SWAP (ctx->A); 91 ((uint32_t *) resbuf)[0] = SWAP (ctx->A);
92 ((uint32_t *) resbuf)[1] = SWAP (ctx->B); 92 ((uint32_t *) resbuf)[1] = SWAP (ctx->B);
@@ -102,7 +102,7 @@ md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
102 IMPORTANT: On some systems it is required that RESBUF is correctly 102 IMPORTANT: On some systems it is required that RESBUF is correctly
103 aligned for a 32-bit value. */ 103 aligned for a 32-bit value. */
104void * 104void *
105md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) 105MHD_md5_finish_ctx (struct MHD_md5_ctx *ctx, void *resbuf)
106{ 106{
107 /* Take yet unprocessed bytes into account. */ 107 /* Take yet unprocessed bytes into account. */
108 uint32_t bytes = ctx->buflen; 108 uint32_t bytes = ctx->buflen;
@@ -120,23 +120,23 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
120 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); 120 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
121 121
122 /* Process last bytes. */ 122 /* Process last bytes. */
123 md5_process_block (ctx->buffer, size * 4, ctx); 123 MHD_md5_process_block (ctx->buffer, size * 4, ctx);
124 124
125 return md5_read_ctx (ctx, resbuf); 125 return MHD_md5_read_ctx (ctx, resbuf);
126} 126}
127 127
128/* Compute MD5 message digest for bytes read from STREAM. The 128/* Compute MD5 message digest for bytes read from STREAM. The
129 resulting message digest number will be written into the 16 bytes 129 resulting message digest number will be written into the 16 bytes
130 beginning at RESBLOCK. */ 130 beginning at RESBLOCK. */
131int 131int
132md5_stream (FILE * stream, void *resblock) 132MHD_md5_stream (FILE * stream, void *resblock)
133{ 133{
134 struct md5_ctx ctx; 134 struct MHD_md5_ctx ctx;
135 char buffer[BLOCKSIZE + 72]; 135 char buffer[BLOCKSIZE + 72];
136 size_t sum; 136 size_t sum;
137 137
138 /* Initialize the computation context. */ 138 /* Initialize the computation context. */
139 md5_init_ctx (&ctx); 139 MHD_md5_init_ctx (&ctx);
140 140
141 /* Iterate over full file contents. */ 141 /* Iterate over full file contents. */
142 while (1) 142 while (1)
@@ -177,17 +177,17 @@ md5_stream (FILE * stream, void *resblock)
177 /* Process buffer with BLOCKSIZE bytes. Note that 177 /* Process buffer with BLOCKSIZE bytes. Note that
178 BLOCKSIZE % 64 == 0 178 BLOCKSIZE % 64 == 0
179 */ 179 */
180 md5_process_block (buffer, BLOCKSIZE, &ctx); 180 MHD_md5_process_block (buffer, BLOCKSIZE, &ctx);
181 } 181 }
182 182
183process_partial_block: 183process_partial_block:
184 184
185 /* Process any remaining bytes. */ 185 /* Process any remaining bytes. */
186 if (sum > 0) 186 if (sum > 0)
187 md5_process_bytes (buffer, sum, &ctx); 187 MHD_md5_process_bytes (buffer, sum, &ctx);
188 188
189 /* Construct result in desired memory. */ 189 /* Construct result in desired memory. */
190 md5_finish_ctx (&ctx, resblock); 190 MHD_md5_finish_ctx (&ctx, resblock);
191 return 0; 191 return 0;
192} 192}
193 193
@@ -196,23 +196,23 @@ process_partial_block:
196 output yields to the wanted ASCII representation of the message 196 output yields to the wanted ASCII representation of the message
197 digest. */ 197 digest. */
198void * 198void *
199md5_buffer (const char *buffer, size_t len, void *resblock) 199MHD_md5_buffer (const char *buffer, size_t len, void *resblock)
200{ 200{
201 struct md5_ctx ctx; 201 struct MHD_md5_ctx ctx;
202 202
203 /* Initialize the computation context. */ 203 /* Initialize the computation context. */
204 md5_init_ctx (&ctx); 204 MHD_md5_init_ctx (&ctx);
205 205
206 /* Process whole buffer but last len % 64 bytes. */ 206 /* Process whole buffer but last len % 64 bytes. */
207 md5_process_bytes (buffer, len, &ctx); 207 MHD_md5_process_bytes (buffer, len, &ctx);
208 208
209 /* Put result in desired memory area. */ 209 /* Put result in desired memory area. */
210 return md5_finish_ctx (&ctx, resblock); 210 return MHD_md5_finish_ctx (&ctx, resblock);
211} 211}
212 212
213 213
214void 214void
215md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) 215MHD_md5_process_bytes (const void *buffer, size_t len, struct MHD_md5_ctx *ctx)
216{ 216{
217 /* When we already have some bits in our internal buffer concatenate 217 /* When we already have some bits in our internal buffer concatenate
218 both inputs first. */ 218 both inputs first. */
@@ -226,7 +226,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
226 226
227 if (ctx->buflen > 64) 227 if (ctx->buflen > 64)
228 { 228 {
229 md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); 229 MHD_md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
230 230
231 ctx->buflen &= 63; 231 ctx->buflen &= 63;
232 /* The regions in the following copy operation cannot overlap. */ 232 /* The regions in the following copy operation cannot overlap. */
@@ -248,14 +248,14 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
248 if (UNALIGNED_P (buffer)) 248 if (UNALIGNED_P (buffer))
249 while (len > 64) 249 while (len > 64)
250 { 250 {
251 md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); 251 MHD_md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
252 buffer = (const char *) buffer + 64; 252 buffer = (const char *) buffer + 64;
253 len -= 64; 253 len -= 64;
254 } 254 }
255 else 255 else
256#endif 256#endif
257 { 257 {
258 md5_process_block (buffer, len & ~63, ctx); 258 MHD_md5_process_block (buffer, len & ~63, ctx);
259 buffer = (const char *) buffer + (len & ~63); 259 buffer = (const char *) buffer + (len & ~63);
260 len &= 63; 260 len &= 63;
261 } 261 }
@@ -270,7 +270,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
270 left_over += len; 270 left_over += len;
271 if (left_over >= 64) 271 if (left_over >= 64)
272 { 272 {
273 md5_process_block (ctx->buffer, 64, ctx); 273 MHD_md5_process_block (ctx->buffer, 64, ctx);
274 left_over -= 64; 274 left_over -= 64;
275 memcpy (ctx->buffer, &ctx->buffer[16], left_over); 275 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
276 } 276 }
@@ -292,7 +292,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
292 It is assumed that LEN % 64 == 0. */ 292 It is assumed that LEN % 64 == 0. */
293 293
294void 294void
295md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) 295MHD_md5_process_block (const void *buffer, size_t len, struct MHD_md5_ctx *ctx)
296{ 296{
297 uint32_t correct_words[16]; 297 uint32_t correct_words[16];
298 const uint32_t *words = buffer; 298 const uint32_t *words = buffer;
diff --git a/src/daemon/https/lgl/md5.h b/src/daemon/https/lgl/md5.h
index a03f1e8a..80793b66 100644
--- a/src/daemon/https/lgl/md5.h
+++ b/src/daemon/https/lgl/md5.h
@@ -45,17 +45,17 @@
45#endif 45#endif
46 46
47#ifndef _LIBC 47#ifndef _LIBC
48# define __md5_buffer md5_buffer 48# define __MHD_md5_buffer MHD_md5_buffer
49# define __md5_finish_ctx md5_finish_ctx 49# define __MHD_md5_finish_ctx MHD_md5_finish_ctx
50# define __md5_init_ctx md5_init_ctx 50# define __MHD_md5_init_ctx MHD_md5_init_ctx
51# define __md5_process_block md5_process_block 51# define __MHD_md5_process_block MHD_md5_process_block
52# define __md5_process_bytes md5_process_bytes 52# define __MHD_md5_process_bytes MHD_md5_process_bytes
53# define __md5_read_ctx md5_read_ctx 53# define __MHD_md5_read_ctx MHD_md5_read_ctx
54# define __md5_stream md5_stream 54# define __MHD_md5_stream MHD_md5_stream
55#endif 55#endif
56 56
57/* Structure to save state of computation between the single steps. */ 57/* Structure to save state of computation between the single steps. */
58struct md5_ctx 58struct MHD_md5_ctx
59{ 59{
60 uint32_t A; 60 uint32_t A;
61 uint32_t B; 61 uint32_t B;
@@ -69,28 +69,28 @@ struct md5_ctx
69 69
70/* 70/*
71 * The following three functions are build up the low level used in 71 * The following three functions are build up the low level used in
72 * the functions `md5_stream' and `md5_buffer'. 72 * the functions `MHD_md5_stream' and `MHD_md5_buffer'.
73 */ 73 */
74 74
75/* Initialize structure containing state of computation. 75/* Initialize structure containing state of computation.
76 (RFC 1321, 3.3: Step 3) */ 76 (RFC 1321, 3.3: Step 3) */
77extern void 77extern void
78__md5_init_ctx (struct md5_ctx *ctx) 78__MHD_md5_init_ctx (struct MHD_md5_ctx *ctx)
79 __THROW; 79 __THROW;
80 80
81/* Starting with the result of former calls of this function (or the 81/* Starting with the result of former calls of this function (or the
82 initialization function update the context for the next LEN bytes 82 initialization function update the context for the next LEN bytes
83 starting at BUFFER. 83 starting at BUFFER.
84 It is necessary that LEN is a multiple of 64!!! */ 84 It is necessary that LEN is a multiple of 64!!! */
85 extern void __md5_process_block (const void *buffer, size_t len, 85 extern void __MHD_md5_process_block (const void *buffer, size_t len,
86 struct md5_ctx *ctx) __THROW; 86 struct MHD_md5_ctx *ctx) __THROW;
87 87
88/* Starting with the result of former calls of this function (or the 88/* Starting with the result of former calls of this function (or the
89 initialization function update the context for the next LEN bytes 89 initialization function update the context for the next LEN bytes
90 starting at BUFFER. 90 starting at BUFFER.
91 It is NOT required that LEN is a multiple of 64. */ 91 It is NOT required that LEN is a multiple of 64. */
92 extern void __md5_process_bytes (const void *buffer, size_t len, 92 extern void __MHD_md5_process_bytes (const void *buffer, size_t len,
93 struct md5_ctx *ctx) __THROW; 93 struct MHD_md5_ctx *ctx) __THROW;
94 94
95/* Process the remaining bytes in the buffer and put result from CTX 95/* Process the remaining bytes in the buffer and put result from CTX
96 in first 16 bytes following RESBUF. The result is always in little 96 in first 16 bytes following RESBUF. The result is always in little
@@ -99,7 +99,7 @@ __md5_init_ctx (struct md5_ctx *ctx)
99 99
100 IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit 100 IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
101 boundary. */ 101 boundary. */
102 extern void *__md5_finish_ctx (struct md5_ctx *ctx, 102 extern void *__MHD_md5_finish_ctx (struct MHD_md5_ctx *ctx,
103 void *resbuf) __THROW; 103 void *resbuf) __THROW;
104 104
105 105
@@ -109,20 +109,20 @@ __md5_init_ctx (struct md5_ctx *ctx)
109 109
110 IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit 110 IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
111 boundary. */ 111 boundary. */
112 extern void *__md5_read_ctx (const struct md5_ctx *ctx, 112 extern void *__MHD_md5_read_ctx (const struct MHD_md5_ctx *ctx,
113 void *resbuf) __THROW; 113 void *resbuf) __THROW;
114 114
115 115
116/* Compute MD5 message digest for bytes read from STREAM. The 116/* Compute MD5 message digest for bytes read from STREAM. The
117 resulting message digest number will be written into the 16 bytes 117 resulting message digest number will be written into the 16 bytes
118 beginning at RESBLOCK. */ 118 beginning at RESBLOCK. */
119 extern int __md5_stream (FILE * stream, void *resblock) __THROW; 119 extern int __MHD_md5_stream (FILE * stream, void *resblock) __THROW;
120 120
121/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The 121/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
122 result is always in little endian byte order, so that a byte-wise 122 result is always in little endian byte order, so that a byte-wise
123 output yields to the wanted ASCII representation of the message 123 output yields to the wanted ASCII representation of the message
124 digest. */ 124 digest. */
125 extern void *__md5_buffer (const char *buffer, size_t len, 125 extern void *__MHD_md5_buffer (const char *buffer, size_t len,
126 void *resblock) __THROW; 126 void *resblock) __THROW;
127 127
128#endif /* md5.h */ 128#endif /* md5.h */
diff --git a/src/daemon/https/lgl/memmem.c b/src/daemon/https/lgl/memmem.c
index 9a0e67d2..08e54742 100644
--- a/src/daemon/https/lgl/memmem.c
+++ b/src/daemon/https/lgl/memmem.c
@@ -26,11 +26,11 @@
26# define __builtin_expect(expr, val) (expr) 26# define __builtin_expect(expr, val) (expr)
27#endif 27#endif
28 28
29#undef memmem 29#undef MHD_memmem
30 30
31/* Return the first occurrence of NEEDLE in HAYSTACK. */ 31/* Return the first occurrence of NEEDLE in HAYSTACK. */
32void * 32void *
33memmem (haystack, haystack_len, needle, needle_len) 33MHD_memmem (haystack, haystack_len, needle, needle_len)
34 const void *haystack; 34 const void *haystack;
35 size_t haystack_len; 35 size_t haystack_len;
36 const void *needle; 36 const void *needle;
diff --git a/src/daemon/https/lgl/memxor.c b/src/daemon/https/lgl/memxor.c
index dabada9f..a1921494 100644
--- a/src/daemon/https/lgl/memxor.c
+++ b/src/daemon/https/lgl/memxor.c
@@ -1,4 +1,4 @@
1/* memxor.c -- perform binary exclusive OR operation of two memory blocks. 1/* MHD_memxor.c -- perform binary exclusive OR operation of two memory blocks.
2 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 2 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
@@ -15,7 +15,7 @@
15 along with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 17
18/* Written by Simon Josefsson. The interface was inspired by memxor 18/* Written by Simon Josefsson. The interface was inspired by MHD_memxor
19 in Niels Möller's Nettle. */ 19 in Niels Möller's Nettle. */
20 20
21#include "MHD_config.h" 21#include "MHD_config.h"
@@ -23,7 +23,7 @@
23#include "memxor.h" 23#include "memxor.h"
24 24
25void * 25void *
26memxor (void *restrict dest, const void *restrict src, size_t n) 26MHD_memxor (void *restrict dest, const void *restrict src, size_t n)
27{ 27{
28 char const *s = src; 28 char const *s = src;
29 char *d = dest; 29 char *d = dest;
diff --git a/src/daemon/https/lgl/memxor.h b/src/daemon/https/lgl/memxor.h
index 4f85f2d7..47e6b3fa 100644
--- a/src/daemon/https/lgl/memxor.h
+++ b/src/daemon/https/lgl/memxor.h
@@ -1,4 +1,4 @@
1/* memxor.h -- perform binary exclusive OR operation on memory blocks. 1/* MHD_memxor.h -- perform binary exclusive OR operation on memory blocks.
2 Copyright (C) 2005 Free Software Foundation, Inc. 2 Copyright (C) 2005 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
@@ -15,7 +15,7 @@
15 along with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 17
18/* Written by Simon Josefsson. The interface was inspired by memxor 18/* Written by Simon Josefsson. The interface was inspired by MHD_memxor
19 in Niels Möller's Nettle. */ 19 in Niels Möller's Nettle. */
20 20
21#ifndef MEMXOR_H 21#ifndef MEMXOR_H
@@ -26,6 +26,6 @@
26/* Compute binary exclusive OR of memory areas DEST and SRC, putting 26/* Compute binary exclusive OR of memory areas DEST and SRC, putting
27 the result in DEST, of length N bytes. Returns a pointer to 27 the result in DEST, of length N bytes. Returns a pointer to
28 DEST. */ 28 DEST. */
29void *memxor (void *restrict dest, const void *restrict src, size_t n); 29void *MHD_memxor (void *restrict dest, const void *restrict src, size_t n);
30 30
31#endif /* MEMXOR_H */ 31#endif /* MEMXOR_H */
diff --git a/src/daemon/https/lgl/sha1.c b/src/daemon/https/lgl/sha1.c
index 501abba1..c336cc4e 100644
--- a/src/daemon/https/lgl/sha1.c
+++ b/src/daemon/https/lgl/sha1.c
@@ -53,9 +53,9 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
53 53
54/* Take a pointer to a 160 bit block of data (five 32 bit ints) and 54/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
55 initialize it to the start constants of the SHA1 algorithm. This 55 initialize it to the start constants of the SHA1 algorithm. This
56 must be called before using hash in the call to sha1_hash. */ 56 must be called before using hash in the call to MHD_sha1_hash. */
57void 57void
58sha1_init_ctx (struct sha1_ctx *ctx) 58MHD_sha1_init_ctx (struct MHD_sha1_ctx *ctx)
59{ 59{
60 ctx->A = 0x67452301; 60 ctx->A = 0x67452301;
61 ctx->B = 0xefcdab89; 61 ctx->B = 0xefcdab89;
@@ -73,7 +73,7 @@ sha1_init_ctx (struct sha1_ctx *ctx)
73 IMPORTANT: On some systems it is required that RESBUF is correctly 73 IMPORTANT: On some systems it is required that RESBUF is correctly
74 aligned for a 32-bit value. */ 74 aligned for a 32-bit value. */
75void * 75void *
76sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf) 76MHD_sha1_read_ctx (const struct MHD_sha1_ctx *ctx, void *resbuf)
77{ 77{
78 ((uint32_t *) resbuf)[0] = SWAP (ctx->A); 78 ((uint32_t *) resbuf)[0] = SWAP (ctx->A);
79 ((uint32_t *) resbuf)[1] = SWAP (ctx->B); 79 ((uint32_t *) resbuf)[1] = SWAP (ctx->B);
@@ -90,7 +90,7 @@ sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
90 IMPORTANT: On some systems it is required that RESBUF is correctly 90 IMPORTANT: On some systems it is required that RESBUF is correctly
91 aligned for a 32-bit value. */ 91 aligned for a 32-bit value. */
92void * 92void *
93sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf) 93MHD_sha1_finish_ctx (struct MHD_sha1_ctx *ctx, void *resbuf)
94{ 94{
95 /* Take yet unprocessed bytes into account. */ 95 /* Take yet unprocessed bytes into account. */
96 uint32_t bytes = ctx->buflen; 96 uint32_t bytes = ctx->buflen;
@@ -108,23 +108,23 @@ sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
108 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); 108 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
109 109
110 /* Process last bytes. */ 110 /* Process last bytes. */
111 sha1_process_block (ctx->buffer, size * 4, ctx); 111 MHD_sha1_process_block (ctx->buffer, size * 4, ctx);
112 112
113 return sha1_read_ctx (ctx, resbuf); 113 return MHD_sha1_read_ctx (ctx, resbuf);
114} 114}
115 115
116/* Compute SHA1 message digest for bytes read from STREAM. The 116/* Compute SHA1 message digest for bytes read from STREAM. The
117 resulting message digest number will be written into the 16 bytes 117 resulting message digest number will be written into the 16 bytes
118 beginning at RESBLOCK. */ 118 beginning at RESBLOCK. */
119int 119int
120sha1_stream (FILE * stream, void *resblock) 120MHD_sha1_stream (FILE * stream, void *resblock)
121{ 121{
122 struct sha1_ctx ctx; 122 struct MHD_sha1_ctx ctx;
123 char buffer[BLOCKSIZE + 72]; 123 char buffer[BLOCKSIZE + 72];
124 size_t sum; 124 size_t sum;
125 125
126 /* Initialize the computation context. */ 126 /* Initialize the computation context. */
127 sha1_init_ctx (&ctx); 127 MHD_sha1_init_ctx (&ctx);
128 128
129 /* Iterate over full file contents. */ 129 /* Iterate over full file contents. */
130 while (1) 130 while (1)
@@ -165,17 +165,17 @@ sha1_stream (FILE * stream, void *resblock)
165 /* Process buffer with BLOCKSIZE bytes. Note that 165 /* Process buffer with BLOCKSIZE bytes. Note that
166 BLOCKSIZE % 64 == 0 166 BLOCKSIZE % 64 == 0
167 */ 167 */
168 sha1_process_block (buffer, BLOCKSIZE, &ctx); 168 MHD_sha1_process_block (buffer, BLOCKSIZE, &ctx);
169 } 169 }
170 170
171process_partial_block:; 171process_partial_block:;
172 172
173 /* Process any remaining bytes. */ 173 /* Process any remaining bytes. */
174 if (sum > 0) 174 if (sum > 0)
175 sha1_process_bytes (buffer, sum, &ctx); 175 MHD_sha1_process_bytes (buffer, sum, &ctx);
176 176
177 /* Construct result in desired memory. */ 177 /* Construct result in desired memory. */
178 sha1_finish_ctx (&ctx, resblock); 178 MHD_sha1_finish_ctx (&ctx, resblock);
179 return 0; 179 return 0;
180} 180}
181 181
@@ -184,22 +184,22 @@ process_partial_block:;
184 output yields to the wanted ASCII representation of the message 184 output yields to the wanted ASCII representation of the message
185 digest. */ 185 digest. */
186void * 186void *
187sha1_buffer (const char *buffer, size_t len, void *resblock) 187MHD_sha1_buffer (const char *buffer, size_t len, void *resblock)
188{ 188{
189 struct sha1_ctx ctx; 189 struct MHD_sha1_ctx ctx;
190 190
191 /* Initialize the computation context. */ 191 /* Initialize the computation context. */
192 sha1_init_ctx (&ctx); 192 MHD_sha1_init_ctx (&ctx);
193 193
194 /* Process whole buffer but last len % 64 bytes. */ 194 /* Process whole buffer but last len % 64 bytes. */
195 sha1_process_bytes (buffer, len, &ctx); 195 MHD_sha1_process_bytes (buffer, len, &ctx);
196 196
197 /* Put result in desired memory area. */ 197 /* Put result in desired memory area. */
198 return sha1_finish_ctx (&ctx, resblock); 198 return MHD_sha1_finish_ctx (&ctx, resblock);
199} 199}
200 200
201void 201void
202sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) 202MHD_sha1_process_bytes (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx)
203{ 203{
204 /* When we already have some bits in our internal buffer concatenate 204 /* When we already have some bits in our internal buffer concatenate
205 both inputs first. */ 205 both inputs first. */
@@ -213,7 +213,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
213 213
214 if (ctx->buflen > 64) 214 if (ctx->buflen > 64)
215 { 215 {
216 sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx); 216 MHD_sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
217 217
218 ctx->buflen &= 63; 218 ctx->buflen &= 63;
219 /* The regions in the following copy operation cannot overlap. */ 219 /* The regions in the following copy operation cannot overlap. */
@@ -235,14 +235,14 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
235 if (UNALIGNED_P (buffer)) 235 if (UNALIGNED_P (buffer))
236 while (len > 64) 236 while (len > 64)
237 { 237 {
238 sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); 238 MHD_sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
239 buffer = (const char *) buffer + 64; 239 buffer = (const char *) buffer + 64;
240 len -= 64; 240 len -= 64;
241 } 241 }
242 else 242 else
243#endif 243#endif
244 { 244 {
245 sha1_process_block (buffer, len & ~63, ctx); 245 MHD_sha1_process_block (buffer, len & ~63, ctx);
246 buffer = (const char *) buffer + (len & ~63); 246 buffer = (const char *) buffer + (len & ~63);
247 len &= 63; 247 len &= 63;
248 } 248 }
@@ -257,7 +257,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
257 left_over += len; 257 left_over += len;
258 if (left_over >= 64) 258 if (left_over >= 64)
259 { 259 {
260 sha1_process_block (ctx->buffer, 64, ctx); 260 MHD_sha1_process_block (ctx->buffer, 64, ctx);
261 left_over -= 64; 261 left_over -= 64;
262 memcpy (ctx->buffer, &ctx->buffer[16], left_over); 262 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
263 } 263 }
@@ -284,7 +284,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
284 Most of this code comes from GnuPG's cipher/sha1.c. */ 284 Most of this code comes from GnuPG's cipher/sha1.c. */
285 285
286void 286void
287sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) 287MHD_sha1_process_block (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx)
288{ 288{
289 const uint32_t *words = buffer; 289 const uint32_t *words = buffer;
290 size_t nwords = len / sizeof (uint32_t); 290 size_t nwords = len / sizeof (uint32_t);
diff --git a/src/daemon/https/lgl/sha1.h b/src/daemon/https/lgl/sha1.h
index 7bfd376c..382d96cf 100644
--- a/src/daemon/https/lgl/sha1.h
+++ b/src/daemon/https/lgl/sha1.h
@@ -23,7 +23,7 @@
23# include <stdint.h> 23# include <stdint.h>
24 24
25/* Structure to save state of computation between the single steps. */ 25/* Structure to save state of computation between the single steps. */
26struct sha1_ctx 26struct MHD_sha1_ctx
27{ 27{
28 uint32_t A; 28 uint32_t A;
29 uint32_t B; 29 uint32_t B;
@@ -38,21 +38,21 @@ struct sha1_ctx
38 38
39 39
40/* Initialize structure containing state of computation. */ 40/* Initialize structure containing state of computation. */
41extern void sha1_init_ctx (struct sha1_ctx *ctx); 41extern void MHD_sha1_init_ctx (struct MHD_sha1_ctx *ctx);
42 42
43/* Starting with the result of former calls of this function (or the 43/* Starting with the result of former calls of this function (or the
44 initialization function update the context for the next LEN bytes 44 initialization function update the context for the next LEN bytes
45 starting at BUFFER. 45 starting at BUFFER.
46 It is necessary that LEN is a multiple of 64!!! */ 46 It is necessary that LEN is a multiple of 64!!! */
47extern void sha1_process_block (const void *buffer, size_t len, 47extern void MHD_sha1_process_block (const void *buffer, size_t len,
48 struct sha1_ctx *ctx); 48 struct MHD_sha1_ctx *ctx);
49 49
50/* Starting with the result of former calls of this function (or the 50/* Starting with the result of former calls of this function (or the
51 initialization function update the context for the next LEN bytes 51 initialization function update the context for the next LEN bytes
52 starting at BUFFER. 52 starting at BUFFER.
53 It is NOT required that LEN is a multiple of 64. */ 53 It is NOT required that LEN is a multiple of 64. */
54extern void sha1_process_bytes (const void *buffer, size_t len, 54extern void MHD_sha1_process_bytes (const void *buffer, size_t len,
55 struct sha1_ctx *ctx); 55 struct MHD_sha1_ctx *ctx);
56 56
57/* Process the remaining bytes in the buffer and put result from CTX 57/* Process the remaining bytes in the buffer and put result from CTX
58 in first 20 bytes following RESBUF. The result is always in little 58 in first 20 bytes following RESBUF. The result is always in little
@@ -61,7 +61,7 @@ extern void sha1_process_bytes (const void *buffer, size_t len,
61 61
62 IMPORTANT: On some systems it is required that RESBUF be correctly 62 IMPORTANT: On some systems it is required that RESBUF be correctly
63 aligned for a 32 bits value. */ 63 aligned for a 32 bits value. */
64extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); 64extern void *MHD_sha1_finish_ctx (struct MHD_sha1_ctx *ctx, void *resbuf);
65 65
66 66
67/* Put result from CTX in first 20 bytes following RESBUF. The result is 67/* Put result from CTX in first 20 bytes following RESBUF. The result is
@@ -70,18 +70,18 @@ extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
70 70
71 IMPORTANT: On some systems it is required that RESBUF is correctly 71 IMPORTANT: On some systems it is required that RESBUF is correctly
72 aligned for a 32 bits value. */ 72 aligned for a 32 bits value. */
73extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf); 73extern void *MHD_sha1_read_ctx (const struct MHD_sha1_ctx *ctx, void *resbuf);
74 74
75 75
76/* Compute SHA1 message digest for bytes read from STREAM. The 76/* Compute SHA1 message digest for bytes read from STREAM. The
77 resulting message digest number will be written into the 20 bytes 77 resulting message digest number will be written into the 20 bytes
78 beginning at RESBLOCK. */ 78 beginning at RESBLOCK. */
79extern int sha1_stream (FILE * stream, void *resblock); 79extern int MHD_sha1_stream (FILE * stream, void *resblock);
80 80
81/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The 81/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
82 result is always in little endian byte order, so that a byte-wise 82 result is always in little endian byte order, so that a byte-wise
83 output yields to the wanted ASCII representation of the message 83 output yields to the wanted ASCII representation of the message
84 digest. */ 84 digest. */
85extern void *sha1_buffer (const char *buffer, size_t len, void *resblock); 85extern void *MHD_sha1_buffer (const char *buffer, size_t len, void *resblock);
86 86
87#endif 87#endif
diff --git a/src/daemon/https/lgl/time_r.c b/src/daemon/https/lgl/time_r.c
deleted file mode 100644
index 025cadca..00000000
--- a/src/daemon/https/lgl/time_r.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/* Reentrant time functions like localtime_r.
2
3 Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19/* Written by Paul Eggert. */
20
21#include "MHD_config.h"
22
23#include <time.h>
24
25#include <string.h>
26
27static struct tm *
28copy_tm_result (struct tm *dest, struct tm const *src)
29{
30 if (!src)
31 return 0;
32 *dest = *src;
33 return dest;
34}
35
36struct tm *
37gmtime_r (time_t const *restrict t, struct tm *restrict tp)
38{
39 return copy_tm_result (tp, gmtime (t));
40}
41
42struct tm *
43localtime_r (time_t const *restrict t, struct tm *restrict tp)
44{
45 return copy_tm_result (tp, localtime (t));
46}
diff --git a/src/daemon/https/minitasn1/coding.c b/src/daemon/https/minitasn1/coding.c
index cc29a003..0f223b04 100644
--- a/src/daemon/https/minitasn1/coding.c
+++ b/src/daemon/https/minitasn1/coding.c
@@ -37,7 +37,7 @@
37#define MAX_TAG_LEN 16 37#define MAX_TAG_LEN 16
38 38
39/******************************************************/ 39/******************************************************/
40/* Function : _asn1_error_description_value_not_found */ 40/* Function : MHD__asn1_error_description_value_not_found */
41/* Description: creates the ErrorDescription string */ 41/* Description: creates the ErrorDescription string */
42/* for the ASN1_VALUE_NOT_FOUND error. */ 42/* for the ASN1_VALUE_NOT_FOUND error. */
43/* Parameters: */ 43/* Parameters: */
@@ -46,7 +46,7 @@
46/* Return: */ 46/* Return: */
47/******************************************************/ 47/******************************************************/
48void 48void
49_asn1_error_description_value_not_found (node_asn * node, 49MHD__asn1_error_description_value_not_found (node_asn * node,
50 char *ErrorDescription) 50 char *ErrorDescription)
51{ 51{
52 52
@@ -54,14 +54,14 @@ _asn1_error_description_value_not_found (node_asn * node,
54 return; 54 return;
55 55
56 Estrcpy (ErrorDescription, ":: value of element '"); 56 Estrcpy (ErrorDescription, ":: value of element '");
57 _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription), 57 MHD__asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
58 MAX_ERROR_DESCRIPTION_SIZE - 40); 58 MAX_ERROR_DESCRIPTION_SIZE - 40);
59 Estrcat (ErrorDescription, "' not found"); 59 Estrcat (ErrorDescription, "' not found");
60 60
61} 61}
62 62
63/** 63/**
64 * asn1_length_der: 64 * MHD__asn1_length_der:
65 * @len: value to convert. 65 * @len: value to convert.
66 * @ans: string returned. 66 * @ans: string returned.
67 * @ans_len: number of meaningful bytes of ANS (ans[0]..ans[ans_len-1]). 67 * @ans_len: number of meaningful bytes of ANS (ans[0]..ans[ans_len-1]).
@@ -70,7 +70,7 @@ _asn1_error_description_value_not_found (node_asn * node,
70 * The @ans buffer is pre-allocated and must have room for the output. 70 * The @ans buffer is pre-allocated and must have room for the output.
71 **/ 71 **/
72void 72void
73asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len) 73MHD__asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
74{ 74{
75 int k; 75 int k;
76 unsigned char temp[SIZEOF_UNSIGNED_LONG_INT]; 76 unsigned char temp[SIZEOF_UNSIGNED_LONG_INT];
@@ -102,7 +102,7 @@ asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
102} 102}
103 103
104/******************************************************/ 104/******************************************************/
105/* Function : _asn1_tag_der */ 105/* Function : MHD__asn1_tag_der */
106/* Description: creates the DER coding for the CLASS */ 106/* Description: creates the DER coding for the CLASS */
107/* and TAG parameters. */ 107/* and TAG parameters. */
108/* Parameters: */ 108/* Parameters: */
@@ -114,7 +114,7 @@ asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
114/* Return: */ 114/* Return: */
115/******************************************************/ 115/******************************************************/
116void 116void
117_asn1_tag_der (unsigned char class, unsigned int tag_value, 117MHD__asn1_tag_der (unsigned char class, unsigned int tag_value,
118 unsigned char *ans, int *ans_len) 118 unsigned char *ans, int *ans_len)
119{ 119{
120 int k; 120 int k;
@@ -144,7 +144,7 @@ _asn1_tag_der (unsigned char class, unsigned int tag_value,
144} 144}
145 145
146/** 146/**
147 * asn1_octet_der: 147 * MHD__asn1_octet_der:
148 * @str: OCTET string. 148 * @str: OCTET string.
149 * @str_len: STR length (str[0]..str[str_len-1]). 149 * @str_len: STR length (str[0]..str[str_len-1]).
150 * @der: string returned. 150 * @der: string returned.
@@ -153,20 +153,20 @@ _asn1_tag_der (unsigned char class, unsigned int tag_value,
153 * Creates the DER coding for an OCTET type (length included). 153 * Creates the DER coding for an OCTET type (length included).
154 **/ 154 **/
155void 155void
156asn1_octet_der (const unsigned char *str, int str_len, 156MHD__asn1_octet_der (const unsigned char *str, int str_len,
157 unsigned char *der, int *der_len) 157 unsigned char *der, int *der_len)
158{ 158{
159 int len_len; 159 int len_len;
160 160
161 if (der == NULL || str_len < 0) 161 if (der == NULL || str_len < 0)
162 return; 162 return;
163 asn1_length_der (str_len, der, &len_len); 163 MHD__asn1_length_der (str_len, der, &len_len);
164 memcpy (der + len_len, str, str_len); 164 memcpy (der + len_len, str, str_len);
165 *der_len = str_len + len_len; 165 *der_len = str_len + len_len;
166} 166}
167 167
168/******************************************************/ 168/******************************************************/
169/* Function : _asn1_time_der */ 169/* Function : MHD__asn1_time_der */
170/* Description: creates the DER coding for a TIME */ 170/* Description: creates the DER coding for a TIME */
171/* type (length included). */ 171/* type (length included). */
172/* Parameters: */ 172/* Parameters: */
@@ -179,15 +179,15 @@ asn1_octet_der (const unsigned char *str, int str_len,
179/* ASN1_MEM_ERROR when DER isn't big enough */ 179/* ASN1_MEM_ERROR when DER isn't big enough */
180/* ASN1_SUCCESS otherwise */ 180/* ASN1_SUCCESS otherwise */
181/******************************************************/ 181/******************************************************/
182asn1_retCode 182MHD__asn1_retCode
183_asn1_time_der (unsigned char *str, unsigned char *der, int *der_len) 183MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
184{ 184{
185 int len_len; 185 int len_len;
186 int max_len; 186 int max_len;
187 187
188 max_len = *der_len; 188 max_len = *der_len;
189 189
190 asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len); 190 MHD__asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len);
191 191
192 if ((len_len + (int) strlen (str)) <= max_len) 192 if ((len_len + (int) strlen (str)) <= max_len)
193 memcpy (der + len_len, str, strlen (str)); 193 memcpy (der + len_len, str, strlen (str));
@@ -202,13 +202,13 @@ _asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
202 202
203/* 203/*
204void 204void
205_asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str) 205MHD__asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
206{ 206{
207 int len_len,str_len; 207 int len_len,str_len;
208 char temp[20]; 208 char temp[20];
209 209
210 if(str==NULL) return; 210 if(str==NULL) return;
211 str_len=asn1_get_length_der(der,*der_len,&len_len); 211 str_len=MHD__asn1_get_length_der(der,*der_len,&len_len);
212 if (str_len<0) return; 212 if (str_len<0) return;
213 memcpy(temp,der+len_len,str_len); 213 memcpy(temp,der+len_len,str_len);
214 *der_len=str_len+len_len; 214 *der_len=str_len+len_len;
@@ -237,7 +237,7 @@ _asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
237*/ 237*/
238 238
239/******************************************************/ 239/******************************************************/
240/* Function : _asn1_objectid_der */ 240/* Function : MHD__asn1_objectid_der */
241/* Description: creates the DER coding for an */ 241/* Description: creates the DER coding for an */
242/* OBJECT IDENTIFIER type (length included). */ 242/* OBJECT IDENTIFIER type (length included). */
243/* Parameters: */ 243/* Parameters: */
@@ -250,8 +250,8 @@ _asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
250/* ASN1_MEM_ERROR when DER isn't big enough */ 250/* ASN1_MEM_ERROR when DER isn't big enough */
251/* ASN1_SUCCESS otherwise */ 251/* ASN1_SUCCESS otherwise */
252/******************************************************/ 252/******************************************************/
253asn1_retCode 253MHD__asn1_retCode
254_asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) 254MHD__asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
255{ 255{
256 int len_len, counter, k, first, max_len; 256 int len_len, counter, k, first, max_len;
257 char *temp, *n_end, *n_start; 257 char *temp, *n_end, *n_start;
@@ -260,7 +260,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
260 260
261 max_len = *der_len; 261 max_len = *der_len;
262 262
263 temp = (char *) _asn1_alloca (strlen (str) + 2); 263 temp = (char *) MHD__asn1_alloca (strlen (str) + 2);
264 if (temp == NULL) 264 if (temp == NULL)
265 return ASN1_MEM_ALLOC_ERROR; 265 return ASN1_MEM_ALLOC_ERROR;
266 266
@@ -304,15 +304,15 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
304 n_start = n_end + 1; 304 n_start = n_end + 1;
305 } 305 }
306 306
307 asn1_length_der (*der_len, NULL, &len_len); 307 MHD__asn1_length_der (*der_len, NULL, &len_len);
308 if (max_len >= (*der_len + len_len)) 308 if (max_len >= (*der_len + len_len))
309 { 309 {
310 memmove (der + len_len, der, *der_len); 310 memmove (der + len_len, der, *der_len);
311 asn1_length_der (*der_len, der, &len_len); 311 MHD__asn1_length_der (*der_len, der, &len_len);
312 } 312 }
313 *der_len += len_len; 313 *der_len += len_len;
314 314
315 _asn1_afree (temp); 315 MHD__asn1_afree (temp);
316 316
317 if (max_len < (*der_len)) 317 if (max_len < (*der_len))
318 return ASN1_MEM_ERROR; 318 return ASN1_MEM_ERROR;
@@ -324,7 +324,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
324const char bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 }; 324const char bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 };
325 325
326/** 326/**
327 * asn1_bit_der: 327 * MHD__asn1_bit_der:
328 * @str: BIT string. 328 * @str: BIT string.
329 * @bit_len: number of meaningful bits in STR. 329 * @bit_len: number of meaningful bits in STR.
330 * @der: string returned. 330 * @der: string returned.
@@ -335,7 +335,7 @@ const char bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 };
335 * included). 335 * included).
336 **/ 336 **/
337void 337void
338asn1_bit_der (const unsigned char *str, int bit_len, 338MHD__asn1_bit_der (const unsigned char *str, int bit_len,
339 unsigned char *der, int *der_len) 339 unsigned char *der, int *der_len)
340{ 340{
341 int len_len, len_byte, len_pad; 341 int len_len, len_byte, len_pad;
@@ -348,7 +348,7 @@ asn1_bit_der (const unsigned char *str, int bit_len,
348 len_pad = 0; 348 len_pad = 0;
349 else 349 else
350 len_byte++; 350 len_byte++;
351 asn1_length_der (len_byte + 1, der, &len_len); 351 MHD__asn1_length_der (len_byte + 1, der, &len_len);
352 der[len_len] = len_pad; 352 der[len_len] = len_pad;
353 memcpy (der + len_len + 1, str, len_byte); 353 memcpy (der + len_len + 1, str, len_byte);
354 der[len_len + len_byte] &= bit_mask[len_pad]; 354 der[len_len + len_byte] &= bit_mask[len_pad];
@@ -357,7 +357,7 @@ asn1_bit_der (const unsigned char *str, int bit_len,
357 357
358 358
359/******************************************************/ 359/******************************************************/
360/* Function : _asn1_complete_explicit_tag */ 360/* Function : MHD__asn1_complete_explicit_tag */
361/* Description: add the length coding to the EXPLICIT */ 361/* Description: add the length coding to the EXPLICIT */
362/* tags. */ 362/* tags. */
363/* Parameters: */ 363/* Parameters: */
@@ -370,8 +370,8 @@ asn1_bit_der (const unsigned char *str, int bit_len,
370/* ASN1_MEM_ERROR if der vector isn't big enough, */ 370/* ASN1_MEM_ERROR if der vector isn't big enough, */
371/* otherwise ASN1_SUCCESS. */ 371/* otherwise ASN1_SUCCESS. */
372/******************************************************/ 372/******************************************************/
373asn1_retCode 373MHD__asn1_retCode
374_asn1_complete_explicit_tag (node_asn * node, unsigned char *der, 374MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
375 int *counter, int *max_len) 375 int *counter, int *max_len)
376{ 376{
377 node_asn *p; 377 node_asn *p;
@@ -397,8 +397,8 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
397 if (p->type & CONST_EXPLICIT) 397 if (p->type & CONST_EXPLICIT)
398 { 398 {
399 len2 = strtol (p->name, NULL, 10); 399 len2 = strtol (p->name, NULL, 10);
400 _asn1_set_name (p, NULL); 400 MHD__asn1_set_name (p, NULL);
401 asn1_length_der (*counter - len2, temp, &len3); 401 MHD__asn1_length_der (*counter - len2, temp, &len3);
402 if (len3 <= (*max_len)) 402 if (len3 <= (*max_len))
403 { 403 {
404 memmove (der + len2 + len3, der + len2, 404 memmove (der + len2 + len3, der + len2,
@@ -429,7 +429,7 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
429 429
430 430
431/******************************************************/ 431/******************************************************/
432/* Function : _asn1_insert_tag_der */ 432/* Function : MHD__asn1_insert_tag_der */
433/* Description: creates the DER coding of tags of one */ 433/* Description: creates the DER coding of tags of one */
434/* NODE. */ 434/* NODE. */
435/* Parameters: */ 435/* Parameters: */
@@ -443,8 +443,8 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
443/* ASN1_MEM_ERROR if der vector isn't big enough, */ 443/* ASN1_MEM_ERROR if der vector isn't big enough, */
444/* otherwise ASN1_SUCCESS. */ 444/* otherwise ASN1_SUCCESS. */
445/******************************************************/ 445/******************************************************/
446asn1_retCode 446MHD__asn1_retCode
447_asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, 447MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
448 int *max_len) 448 int *max_len)
449{ 449{
450 node_asn *p; 450 node_asn *p;
@@ -474,10 +474,10 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
474 if (p->type & CONST_EXPLICIT) 474 if (p->type & CONST_EXPLICIT)
475 { 475 {
476 if (is_tag_implicit) 476 if (is_tag_implicit)
477 _asn1_tag_der (class_implicit, tag_implicit, tag_der, 477 MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der,
478 &tag_len); 478 &tag_len);
479 else 479 else
480 _asn1_tag_der (class | ASN1_CLASS_STRUCTURED, 480 MHD__asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
481 strtoul (p->value, NULL, 10), tag_der, 481 strtoul (p->value, NULL, 10), tag_der,
482 &tag_len); 482 &tag_len);
483 483
@@ -486,8 +486,8 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
486 memcpy (der + *counter, tag_der, tag_len); 486 memcpy (der + *counter, tag_der, tag_len);
487 *counter += tag_len; 487 *counter += tag_len;
488 488
489 _asn1_ltostr (*counter, temp); 489 MHD__asn1_ltostr (*counter, temp);
490 _asn1_set_name (p, temp); 490 MHD__asn1_set_name (p, temp);
491 491
492 is_tag_implicit = 0; 492 is_tag_implicit = 0;
493 } 493 }
@@ -512,62 +512,62 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
512 512
513 if (is_tag_implicit) 513 if (is_tag_implicit)
514 { 514 {
515 _asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len); 515 MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len);
516 } 516 }
517 else 517 else
518 { 518 {
519 switch (type_field (node->type)) 519 switch (type_field (node->type))
520 { 520 {
521 case TYPE_NULL: 521 case TYPE_NULL:
522 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der, 522 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der,
523 &tag_len); 523 &tag_len);
524 break; 524 break;
525 case TYPE_BOOLEAN: 525 case TYPE_BOOLEAN:
526 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der, 526 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der,
527 &tag_len); 527 &tag_len);
528 break; 528 break;
529 case TYPE_INTEGER: 529 case TYPE_INTEGER:
530 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der, 530 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der,
531 &tag_len); 531 &tag_len);
532 break; 532 break;
533 case TYPE_ENUMERATED: 533 case TYPE_ENUMERATED:
534 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, tag_der, 534 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, tag_der,
535 &tag_len); 535 &tag_len);
536 break; 536 break;
537 case TYPE_OBJECT_ID: 537 case TYPE_OBJECT_ID:
538 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der, 538 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der,
539 &tag_len); 539 &tag_len);
540 break; 540 break;
541 case TYPE_TIME: 541 case TYPE_TIME:
542 if (node->type & CONST_UTC) 542 if (node->type & CONST_UTC)
543 { 543 {
544 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, tag_der, 544 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, tag_der,
545 &tag_len); 545 &tag_len);
546 } 546 }
547 else 547 else
548 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime, 548 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime,
549 tag_der, &tag_len); 549 tag_der, &tag_len);
550 break; 550 break;
551 case TYPE_OCTET_STRING: 551 case TYPE_OCTET_STRING:
552 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, tag_der, 552 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, tag_der,
553 &tag_len); 553 &tag_len);
554 break; 554 break;
555 case TYPE_GENERALSTRING: 555 case TYPE_GENERALSTRING:
556 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING, 556 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING,
557 tag_der, &tag_len); 557 tag_der, &tag_len);
558 break; 558 break;
559 case TYPE_BIT_STRING: 559 case TYPE_BIT_STRING:
560 _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, tag_der, 560 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, tag_der,
561 &tag_len); 561 &tag_len);
562 break; 562 break;
563 case TYPE_SEQUENCE: 563 case TYPE_SEQUENCE:
564 case TYPE_SEQUENCE_OF: 564 case TYPE_SEQUENCE_OF:
565 _asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, 565 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
566 ASN1_TAG_SEQUENCE, tag_der, &tag_len); 566 ASN1_TAG_SEQUENCE, tag_der, &tag_len);
567 break; 567 break;
568 case TYPE_SET: 568 case TYPE_SET:
569 case TYPE_SET_OF: 569 case TYPE_SET_OF:
570 _asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, 570 MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
571 ASN1_TAG_SET, tag_der, &tag_len); 571 ASN1_TAG_SET, tag_der, &tag_len);
572 break; 572 break;
573 case TYPE_TAG: 573 case TYPE_TAG:
@@ -596,7 +596,7 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
596} 596}
597 597
598/******************************************************/ 598/******************************************************/
599/* Function : _asn1_ordering_set */ 599/* Function : MHD__asn1_ordering_set */
600/* Description: puts the elements of a SET type in */ 600/* Description: puts the elements of a SET type in */
601/* the correct order according to DER rules. */ 601/* the correct order according to DER rules. */
602/* Parameters: */ 602/* Parameters: */
@@ -605,7 +605,7 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
605/* Return: */ 605/* Return: */
606/******************************************************/ 606/******************************************************/
607void 607void
608_asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) 608MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
609{ 609{
610 struct vet 610 struct vet
611 { 611 {
@@ -637,7 +637,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
637 first = last = NULL; 637 first = last = NULL;
638 while (p) 638 while (p)
639 { 639 {
640 p_vet = (struct vet *) _asn1_alloca (sizeof (struct vet)); 640 p_vet = (struct vet *) MHD__asn1_alloca (sizeof (struct vet));
641 if (p_vet == NULL) 641 if (p_vet == NULL)
642 return; 642 return;
643 643
@@ -650,7 +650,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
650 last = p_vet; 650 last = p_vet;
651 651
652 /* tag value calculation */ 652 /* tag value calculation */
653 if (asn1_get_tag_der 653 if (MHD__asn1_get_tag_der
654 (der + counter, der_len - counter, &class, &len2, 654 (der + counter, der_len - counter, &class, &len2,
655 &tag) != ASN1_SUCCESS) 655 &tag) != ASN1_SUCCESS)
656 return; 656 return;
@@ -658,7 +658,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
658 counter += len2; 658 counter += len2;
659 659
660 /* extraction and length */ 660 /* extraction and length */
661 len2 = asn1_get_length_der (der + counter, der_len - counter, &len); 661 len2 = MHD__asn1_get_length_der (der + counter, der_len - counter, &len);
662 if (len2 < 0) 662 if (len2 < 0)
663 return; 663 return;
664 counter += len + len2; 664 counter += len + len2;
@@ -678,7 +678,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
678 if (p_vet->value > p2_vet->value) 678 if (p_vet->value > p2_vet->value)
679 { 679 {
680 /* change position */ 680 /* change position */
681 temp = (unsigned char *) _asn1_alloca (p_vet->end - counter); 681 temp = (unsigned char *) MHD__asn1_alloca (p_vet->end - counter);
682 if (temp == NULL) 682 if (temp == NULL)
683 return; 683 return;
684 684
@@ -687,7 +687,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
687 p2_vet->end - p_vet->end); 687 p2_vet->end - p_vet->end);
688 memcpy (der + counter + p2_vet->end - p_vet->end, temp, 688 memcpy (der + counter + p2_vet->end - p_vet->end, temp,
689 p_vet->end - counter); 689 p_vet->end - counter);
690 _asn1_afree (temp); 690 MHD__asn1_afree (temp);
691 691
692 tag = p_vet->value; 692 tag = p_vet->value;
693 p_vet->value = p2_vet->value; 693 p_vet->value = p2_vet->value;
@@ -705,13 +705,13 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
705 p_vet->prev->next = NULL; 705 p_vet->prev->next = NULL;
706 else 706 else
707 first = NULL; 707 first = NULL;
708 _asn1_afree (p_vet); 708 MHD__asn1_afree (p_vet);
709 p_vet = first; 709 p_vet = first;
710 } 710 }
711} 711}
712 712
713/******************************************************/ 713/******************************************************/
714/* Function : _asn1_ordering_set_of */ 714/* Function : MHD__asn1_ordering_set_of */
715/* Description: puts the elements of a SET OF type in */ 715/* Description: puts the elements of a SET OF type in */
716/* the correct order according to DER rules. */ 716/* the correct order according to DER rules. */
717/* Parameters: */ 717/* Parameters: */
@@ -720,7 +720,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
720/* Return: */ 720/* Return: */
721/******************************************************/ 721/******************************************************/
722void 722void
723_asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) 723MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
724{ 724{
725 struct vet 725 struct vet
726 { 726 {
@@ -751,7 +751,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
751 first = last = NULL; 751 first = last = NULL;
752 while (p) 752 while (p)
753 { 753 {
754 p_vet = (struct vet *) _asn1_alloca (sizeof (struct vet)); 754 p_vet = (struct vet *) MHD__asn1_alloca (sizeof (struct vet));
755 if (p_vet == NULL) 755 if (p_vet == NULL)
756 return; 756 return;
757 757
@@ -767,13 +767,13 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
767 if (der_len - counter > 0) 767 if (der_len - counter > 0)
768 { 768 {
769 769
770 if (asn1_get_tag_der 770 if (MHD__asn1_get_tag_der
771 (der + counter, der_len - counter, &class, &len, 771 (der + counter, der_len - counter, &class, &len,
772 NULL) != ASN1_SUCCESS) 772 NULL) != ASN1_SUCCESS)
773 return; 773 return;
774 counter += len; 774 counter += len;
775 775
776 len2 = asn1_get_length_der (der + counter, der_len - counter, &len); 776 len2 = MHD__asn1_get_length_der (der + counter, der_len - counter, &len);
777 if (len2 < 0) 777 if (len2 < 0)
778 return; 778 return;
779 counter += len + len2; 779 counter += len + len2;
@@ -816,7 +816,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
816 if (change == 1) 816 if (change == 1)
817 { 817 {
818 /* change position */ 818 /* change position */
819 temp = (unsigned char *) _asn1_alloca (p_vet->end - counter); 819 temp = (unsigned char *) MHD__asn1_alloca (p_vet->end - counter);
820 if (temp == NULL) 820 if (temp == NULL)
821 return; 821 return;
822 822
@@ -825,7 +825,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
825 (p2_vet->end) - (p_vet->end)); 825 (p2_vet->end) - (p_vet->end));
826 memcpy (der + counter + (p2_vet->end) - (p_vet->end), temp, 826 memcpy (der + counter + (p2_vet->end) - (p_vet->end), temp,
827 (p_vet->end) - counter); 827 (p_vet->end) - counter);
828 _asn1_afree (temp); 828 MHD__asn1_afree (temp);
829 829
830 p_vet->end = counter + (p2_vet->end - p_vet->end); 830 p_vet->end = counter + (p2_vet->end - p_vet->end);
831 } 831 }
@@ -839,13 +839,13 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
839 p_vet->prev->next = NULL; 839 p_vet->prev->next = NULL;
840 else 840 else
841 first = NULL; 841 first = NULL;
842 _asn1_afree (p_vet); 842 MHD__asn1_afree (p_vet);
843 p_vet = first; 843 p_vet = first;
844 } 844 }
845} 845}
846 846
847/** 847/**
848 * asn1_der_coding - Creates the DER encoding for the NAME structure 848 * MHD__asn1_der_coding - Creates the DER encoding for the NAME structure
849 * @element: pointer to an ASN1 element 849 * @element: pointer to an ASN1 element
850 * @name: the name of the structure you want to encode (it must be 850 * @name: the name of the structure you want to encode (it must be
851 * inside *POINTER). 851 * inside *POINTER).
@@ -871,17 +871,17 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
871 * LEN will contain the length needed. 871 * LEN will contain the length needed.
872 * 872 *
873 **/ 873 **/
874asn1_retCode 874MHD__asn1_retCode
875asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, 875MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
876 char *ErrorDescription) 876 char *ErrorDescription)
877{ 877{
878 node_asn *node, *p, *p2; 878 node_asn *node, *p, *p2;
879 char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1]; 879 char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
880 int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old; 880 int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
881 asn1_retCode err; 881 MHD__asn1_retCode err;
882 unsigned char *der = ider; 882 unsigned char *der = ider;
883 883
884 node = asn1_find_node (element, name); 884 node = MHD__asn1_find_node (element, name);
885 if (node == NULL) 885 if (node == NULL)
886 return ASN1_ELEMENT_NOT_FOUND; 886 return ASN1_ELEMENT_NOT_FOUND;
887 887
@@ -889,7 +889,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
889 * That is because in some point we modify the 889 * That is because in some point we modify the
890 * structure, and I don't know why! --nmav 890 * structure, and I don't know why! --nmav
891 */ 891 */
892 node = _asn1_copy_structure3 (node); 892 node = MHD__asn1_copy_structure3 (node);
893 if (node == NULL) 893 if (node == NULL)
894 return ASN1_ELEMENT_NOT_FOUND; 894 return ASN1_ELEMENT_NOT_FOUND;
895 895
@@ -905,7 +905,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
905 max_len_old = max_len; 905 max_len_old = max_len;
906 if (move != UP) 906 if (move != UP)
907 { 907 {
908 err = _asn1_insert_tag_der (p, der, &counter, &max_len); 908 err = MHD__asn1_insert_tag_der (p, der, &counter, &max_len);
909 if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR) 909 if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
910 goto error; 910 goto error;
911 } 911 }
@@ -928,7 +928,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
928 { 928 {
929 if (p->value == NULL) 929 if (p->value == NULL)
930 { 930 {
931 _asn1_error_description_value_not_found (p, 931 MHD__asn1_error_description_value_not_found (p,
932 ErrorDescription); 932 ErrorDescription);
933 err = ASN1_VALUE_NOT_FOUND; 933 err = ASN1_VALUE_NOT_FOUND;
934 goto error; 934 goto error;
@@ -958,12 +958,12 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
958 { 958 {
959 if (p->value == NULL) 959 if (p->value == NULL)
960 { 960 {
961 _asn1_error_description_value_not_found (p, 961 MHD__asn1_error_description_value_not_found (p,
962 ErrorDescription); 962 ErrorDescription);
963 err = ASN1_VALUE_NOT_FOUND; 963 err = ASN1_VALUE_NOT_FOUND;
964 goto error; 964 goto error;
965 } 965 }
966 len2 = asn1_get_length_der (p->value, p->value_len, &len3); 966 len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
967 if (len2 < 0) 967 if (len2 < 0)
968 { 968 {
969 err = ASN1_DER_ERROR; 969 err = ASN1_DER_ERROR;
@@ -986,13 +986,13 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
986 { 986 {
987 if (p->value == NULL) 987 if (p->value == NULL)
988 { 988 {
989 _asn1_error_description_value_not_found (p, 989 MHD__asn1_error_description_value_not_found (p,
990 ErrorDescription); 990 ErrorDescription);
991 err = ASN1_VALUE_NOT_FOUND; 991 err = ASN1_VALUE_NOT_FOUND;
992 goto error; 992 goto error;
993 } 993 }
994 len2 = max_len; 994 len2 = max_len;
995 err = _asn1_objectid_der (p->value, der + counter, &len2); 995 err = MHD__asn1_objectid_der (p->value, der + counter, &len2);
996 if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR) 996 if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
997 goto error; 997 goto error;
998 998
@@ -1004,12 +1004,12 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1004 case TYPE_TIME: 1004 case TYPE_TIME:
1005 if (p->value == NULL) 1005 if (p->value == NULL)
1006 { 1006 {
1007 _asn1_error_description_value_not_found (p, ErrorDescription); 1007 MHD__asn1_error_description_value_not_found (p, ErrorDescription);
1008 err = ASN1_VALUE_NOT_FOUND; 1008 err = ASN1_VALUE_NOT_FOUND;
1009 goto error; 1009 goto error;
1010 } 1010 }
1011 len2 = max_len; 1011 len2 = max_len;
1012 err = _asn1_time_der (p->value, der + counter, &len2); 1012 err = MHD__asn1_time_der (p->value, der + counter, &len2);
1013 if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR) 1013 if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
1014 goto error; 1014 goto error;
1015 1015
@@ -1020,11 +1020,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1020 case TYPE_OCTET_STRING: 1020 case TYPE_OCTET_STRING:
1021 if (p->value == NULL) 1021 if (p->value == NULL)
1022 { 1022 {
1023 _asn1_error_description_value_not_found (p, ErrorDescription); 1023 MHD__asn1_error_description_value_not_found (p, ErrorDescription);
1024 err = ASN1_VALUE_NOT_FOUND; 1024 err = ASN1_VALUE_NOT_FOUND;
1025 goto error; 1025 goto error;
1026 } 1026 }
1027 len2 = asn1_get_length_der (p->value, p->value_len, &len3); 1027 len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
1028 if (len2 < 0) 1028 if (len2 < 0)
1029 { 1029 {
1030 err = ASN1_DER_ERROR; 1030 err = ASN1_DER_ERROR;
@@ -1039,11 +1039,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1039 case TYPE_GENERALSTRING: 1039 case TYPE_GENERALSTRING:
1040 if (p->value == NULL) 1040 if (p->value == NULL)
1041 { 1041 {
1042 _asn1_error_description_value_not_found (p, ErrorDescription); 1042 MHD__asn1_error_description_value_not_found (p, ErrorDescription);
1043 err = ASN1_VALUE_NOT_FOUND; 1043 err = ASN1_VALUE_NOT_FOUND;
1044 goto error; 1044 goto error;
1045 } 1045 }
1046 len2 = asn1_get_length_der (p->value, p->value_len, &len3); 1046 len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
1047 if (len2 < 0) 1047 if (len2 < 0)
1048 { 1048 {
1049 err = ASN1_DER_ERROR; 1049 err = ASN1_DER_ERROR;
@@ -1058,11 +1058,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1058 case TYPE_BIT_STRING: 1058 case TYPE_BIT_STRING:
1059 if (p->value == NULL) 1059 if (p->value == NULL)
1060 { 1060 {
1061 _asn1_error_description_value_not_found (p, ErrorDescription); 1061 MHD__asn1_error_description_value_not_found (p, ErrorDescription);
1062 err = ASN1_VALUE_NOT_FOUND; 1062 err = ASN1_VALUE_NOT_FOUND;
1063 goto error; 1063 goto error;
1064 } 1064 }
1065 len2 = asn1_get_length_der (p->value, p->value_len, &len3); 1065 len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
1066 if (len2 < 0) 1066 if (len2 < 0)
1067 { 1067 {
1068 err = ASN1_DER_ERROR; 1068 err = ASN1_DER_ERROR;
@@ -1078,10 +1078,10 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1078 case TYPE_SET: 1078 case TYPE_SET:
1079 if (move != UP) 1079 if (move != UP)
1080 { 1080 {
1081 _asn1_ltostr (counter, temp); 1081 MHD__asn1_ltostr (counter, temp);
1082 tlen = strlen (temp); 1082 tlen = strlen (temp);
1083 if (tlen > 0) 1083 if (tlen > 0)
1084 _asn1_set_value (p, temp, tlen + 1); 1084 MHD__asn1_set_value (p, temp, tlen + 1);
1085 if (p->down == NULL) 1085 if (p->down == NULL)
1086 { 1086 {
1087 move = UP; 1087 move = UP;
@@ -1105,10 +1105,10 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1105 else 1105 else
1106 { /* move==UP */ 1106 { /* move==UP */
1107 len2 = strtol (p->value, NULL, 10); 1107 len2 = strtol (p->value, NULL, 10);
1108 _asn1_set_value (p, NULL, 0); 1108 MHD__asn1_set_value (p, NULL, 0);
1109 if ((type_field (p->type) == TYPE_SET) && (max_len >= 0)) 1109 if ((type_field (p->type) == TYPE_SET) && (max_len >= 0))
1110 _asn1_ordering_set (der + len2, max_len - len2, p); 1110 MHD__asn1_ordering_set (der + len2, max_len - len2, p);
1111 asn1_length_der (counter - len2, temp, &len3); 1111 MHD__asn1_length_der (counter - len2, temp, &len3);
1112 max_len -= len3; 1112 max_len -= len3;
1113 if (max_len >= 0) 1113 if (max_len >= 0)
1114 { 1114 {
@@ -1123,11 +1123,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1123 case TYPE_SET_OF: 1123 case TYPE_SET_OF:
1124 if (move != UP) 1124 if (move != UP)
1125 { 1125 {
1126 _asn1_ltostr (counter, temp); 1126 MHD__asn1_ltostr (counter, temp);
1127 tlen = strlen (temp); 1127 tlen = strlen (temp);
1128 1128
1129 if (tlen > 0) 1129 if (tlen > 0)
1130 _asn1_set_value (p, temp, tlen + 1); 1130 MHD__asn1_set_value (p, temp, tlen + 1);
1131 p = p->down; 1131 p = p->down;
1132 while ((type_field (p->type) == TYPE_TAG) 1132 while ((type_field (p->type) == TYPE_TAG)
1133 || (type_field (p->type) == TYPE_SIZE)) 1133 || (type_field (p->type) == TYPE_SIZE))
@@ -1139,19 +1139,19 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1139 continue; 1139 continue;
1140 } 1140 }
1141 else 1141 else
1142 p = _asn1_find_up (p); 1142 p = MHD__asn1_find_up (p);
1143 move = UP; 1143 move = UP;
1144 } 1144 }
1145 if (move == UP) 1145 if (move == UP)
1146 { 1146 {
1147 len2 = strtol (p->value, NULL, 10); 1147 len2 = strtol (p->value, NULL, 10);
1148 _asn1_set_value (p, NULL, 0); 1148 MHD__asn1_set_value (p, NULL, 0);
1149 if ((type_field (p->type) == TYPE_SET_OF) 1149 if ((type_field (p->type) == TYPE_SET_OF)
1150 && (max_len - len2 > 0)) 1150 && (max_len - len2 > 0))
1151 { 1151 {
1152 _asn1_ordering_set_of (der + len2, max_len - len2, p); 1152 MHD__asn1_ordering_set_of (der + len2, max_len - len2, p);
1153 } 1153 }
1154 asn1_length_der (counter - len2, temp, &len3); 1154 MHD__asn1_length_der (counter - len2, temp, &len3);
1155 max_len -= len3; 1155 max_len -= len3;
1156 if (max_len >= 0) 1156 if (max_len >= 0)
1157 { 1157 {
@@ -1165,11 +1165,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1165 case TYPE_ANY: 1165 case TYPE_ANY:
1166 if (p->value == NULL) 1166 if (p->value == NULL)
1167 { 1167 {
1168 _asn1_error_description_value_not_found (p, ErrorDescription); 1168 MHD__asn1_error_description_value_not_found (p, ErrorDescription);
1169 err = ASN1_VALUE_NOT_FOUND; 1169 err = ASN1_VALUE_NOT_FOUND;
1170 goto error; 1170 goto error;
1171 } 1171 }
1172 len2 = asn1_get_length_der (p->value, p->value_len, &len3); 1172 len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
1173 if (len2 < 0) 1173 if (len2 < 0)
1174 { 1174 {
1175 err = ASN1_DER_ERROR; 1175 err = ASN1_DER_ERROR;
@@ -1188,7 +1188,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1188 1188
1189 if ((move != DOWN) && (counter != counter_old)) 1189 if ((move != DOWN) && (counter != counter_old))
1190 { 1190 {
1191 err = _asn1_complete_explicit_tag (p, der, &counter, &max_len); 1191 err = MHD__asn1_complete_explicit_tag (p, der, &counter, &max_len);
1192 if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR) 1192 if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
1193 goto error; 1193 goto error;
1194 } 1194 }
@@ -1211,7 +1211,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1211 move = UP; 1211 move = UP;
1212 } 1212 }
1213 if (move == UP) 1213 if (move == UP)
1214 p = _asn1_find_up (p); 1214 p = MHD__asn1_find_up (p);
1215 } 1215 }
1216 1216
1217 *len = counter; 1217 *len = counter;
@@ -1225,6 +1225,6 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
1225 err = ASN1_SUCCESS; 1225 err = ASN1_SUCCESS;
1226 1226
1227error: 1227error:
1228 asn1_delete_structure (&node); 1228 MHD__asn1_delete_structure (&node);
1229 return err; 1229 return err;
1230} 1230}
diff --git a/src/daemon/https/minitasn1/decoding.c b/src/daemon/https/minitasn1/decoding.c
index 7174ce1f..27586b5e 100644
--- a/src/daemon/https/minitasn1/decoding.c
+++ b/src/daemon/https/minitasn1/decoding.c
@@ -35,18 +35,18 @@
35 35
36 36
37void 37void
38_asn1_error_description_tag_error (node_asn * node, char *ErrorDescription) 38MHD__asn1_error_description_tag_error (node_asn * node, char *ErrorDescription)
39{ 39{
40 40
41 Estrcpy (ErrorDescription, ":: tag error near element '"); 41 Estrcpy (ErrorDescription, ":: tag error near element '");
42 _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription), 42 MHD__asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
43 MAX_ERROR_DESCRIPTION_SIZE - 40); 43 MAX_ERROR_DESCRIPTION_SIZE - 40);
44 Estrcat (ErrorDescription, "'"); 44 Estrcat (ErrorDescription, "'");
45 45
46} 46}
47 47
48/** 48/**
49 * asn1_get_length_der: 49 * MHD__asn1_get_length_der:
50 * @der: DER data to decode. 50 * @der: DER data to decode.
51 * @der_len: Length of DER data to decode. 51 * @der_len: Length of DER data to decode.
52 * @len: Output variable containing the length of the DER length field. 52 * @len: Output variable containing the length of the DER length field.
@@ -57,7 +57,7 @@ _asn1_error_description_tag_error (node_asn * node, char *ErrorDescription)
57 * length, or -2 when the value was too big. 57 * length, or -2 when the value was too big.
58 **/ 58 **/
59signed long 59signed long
60asn1_get_length_der (const unsigned char *der, int der_len, int *len) 60MHD__asn1_get_length_der (const unsigned char *der, int der_len, int *len)
61{ 61{
62 unsigned long ans; 62 unsigned long ans;
63 int k, punt; 63 int k, punt;
@@ -104,7 +104,7 @@ asn1_get_length_der (const unsigned char *der, int der_len, int *len)
104 104
105 105
106/** 106/**
107 * asn1_get_tag_der: 107 * MHD__asn1_get_tag_der:
108 * @der: DER data to decode. 108 * @der: DER data to decode.
109 * @der_len: Length of DER data to decode. 109 * @der_len: Length of DER data to decode.
110 * @cls: Output variable containing decoded class. 110 * @cls: Output variable containing decoded class.
@@ -116,7 +116,7 @@ asn1_get_length_der (const unsigned char *der, int der_len, int *len)
116 * Return value: Returns ASN1_SUCCESS on success, or an error. 116 * Return value: Returns ASN1_SUCCESS on success, or an error.
117 **/ 117 **/
118int 118int
119asn1_get_tag_der (const unsigned char *der, int der_len, 119MHD__asn1_get_tag_der (const unsigned char *der, int der_len,
120 unsigned char *cls, int *len, unsigned long *tag) 120 unsigned char *cls, int *len, unsigned long *tag)
121{ 121{
122 int punt, ris; 122 int punt, ris;
@@ -164,7 +164,7 @@ asn1_get_tag_der (const unsigned char *der, int der_len,
164 164
165 165
166/** 166/**
167 * asn1_get_octet_der: 167 * MHD__asn1_get_octet_der:
168 * @der: DER data to decode containing the OCTET SEQUENCE. 168 * @der: DER data to decode containing the OCTET SEQUENCE.
169 * @der_len: Length of DER data to decode. 169 * @der_len: Length of DER data to decode.
170 * @ret_len: Output variable containing the length of the DER data. 170 * @ret_len: Output variable containing the length of the DER data.
@@ -177,7 +177,7 @@ asn1_get_tag_der (const unsigned char *der, int der_len,
177 * Return value: Returns ASN1_SUCCESS on success, or an error. 177 * Return value: Returns ASN1_SUCCESS on success, or an error.
178 **/ 178 **/
179int 179int
180asn1_get_octet_der (const unsigned char *der, int der_len, 180MHD__asn1_get_octet_der (const unsigned char *der, int der_len,
181 int *ret_len, unsigned char *str, int str_size, 181 int *ret_len, unsigned char *str, int str_size,
182 int *str_len) 182 int *str_len)
183{ 183{
@@ -187,7 +187,7 @@ asn1_get_octet_der (const unsigned char *der, int der_len,
187 return ASN1_GENERIC_ERROR; 187 return ASN1_GENERIC_ERROR;
188 188
189 /* if(str==NULL) return ASN1_SUCCESS; */ 189 /* if(str==NULL) return ASN1_SUCCESS; */
190 *str_len = asn1_get_length_der (der, der_len, &len_len); 190 *str_len = MHD__asn1_get_length_der (der, der_len, &len_len);
191 191
192 if (*str_len < 0) 192 if (*str_len < 0)
193 return ASN1_DER_ERROR; 193 return ASN1_DER_ERROR;
@@ -208,14 +208,14 @@ asn1_get_octet_der (const unsigned char *der, int der_len,
208/* Returns ASN1_SUCCESS on success or an error code on error. 208/* Returns ASN1_SUCCESS on success or an error code on error.
209 */ 209 */
210int 210int
211_asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len, 211MHD__asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len,
212 char *str, int str_size) 212 char *str, int str_size)
213{ 213{
214 int len_len, str_len; 214 int len_len, str_len;
215 215
216 if (der_len <= 0 || str == NULL) 216 if (der_len <= 0 || str == NULL)
217 return ASN1_DER_ERROR; 217 return ASN1_DER_ERROR;
218 str_len = asn1_get_length_der (der, der_len, &len_len); 218 str_len = MHD__asn1_get_length_der (der, der_len, &len_len);
219 if (str_len < 0 || str_size < str_len) 219 if (str_len < 0 || str_size < str_len)
220 return ASN1_DER_ERROR; 220 return ASN1_DER_ERROR;
221 memcpy (str, der + len_len, str_len); 221 memcpy (str, der + len_len, str_len);
@@ -228,7 +228,7 @@ _asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len,
228 228
229 229
230void 230void
231_asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len, 231MHD__asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
232 char *str, int str_size) 232 char *str, int str_size)
233{ 233{
234 int len_len, len, k; 234 int len_len, len, k;
@@ -241,7 +241,7 @@ _asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
241 241
242 if (str == NULL || der_len <= 0) 242 if (str == NULL || der_len <= 0)
243 return; 243 return;
244 len = asn1_get_length_der (der, der_len, &len_len); 244 len = MHD__asn1_get_length_der (der, der_len, &len_len);
245 245
246 if (len < 0 || len > der_len || len_len > der_len) 246 if (len < 0 || len > der_len || len_len > der_len)
247 return; 247 return;
@@ -249,9 +249,9 @@ _asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
249 val1 = der[len_len] / 40; 249 val1 = der[len_len] / 40;
250 val = der[len_len] - val1 * 40; 250 val = der[len_len] - val1 * 40;
251 251
252 _asn1_str_cpy (str, str_size, _asn1_ltostr (val1, temp)); 252 MHD__asn1_str_cpy (str, str_size, MHD__asn1_ltostr (val1, temp));
253 _asn1_str_cat (str, str_size, "."); 253 MHD__asn1_str_cat (str, str_size, ".");
254 _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp)); 254 MHD__asn1_str_cat (str, str_size, MHD__asn1_ltostr (val, temp));
255 255
256 val = 0; 256 val = 0;
257 for (k = 1; k < len; k++) 257 for (k = 1; k < len; k++)
@@ -260,8 +260,8 @@ _asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
260 val |= der[len_len + k] & 0x7F; 260 val |= der[len_len + k] & 0x7F;
261 if (!(der[len_len + k] & 0x80)) 261 if (!(der[len_len + k] & 0x80))
262 { 262 {
263 _asn1_str_cat (str, str_size, "."); 263 MHD__asn1_str_cat (str, str_size, ".");
264 _asn1_str_cat (str, str_size, _asn1_ltostr (val, temp)); 264 MHD__asn1_str_cat (str, str_size, MHD__asn1_ltostr (val, temp));
265 val = 0; 265 val = 0;
266 } 266 }
267 } 267 }
@@ -272,7 +272,7 @@ _asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
272 272
273 273
274/** 274/**
275 * asn1_get_bit_der: 275 * MHD__asn1_get_bit_der:
276 * @der: DER data to decode containing the BIT SEQUENCE. 276 * @der: DER data to decode containing the BIT SEQUENCE.
277 * @der_len: Length of DER data to decode. 277 * @der_len: Length of DER data to decode.
278 * @ret_len: Output variable containing the length of the DER data. 278 * @ret_len: Output variable containing the length of the DER data.
@@ -285,7 +285,7 @@ _asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
285 * Return value: Return ASN1_SUCCESS on success, or an error. 285 * Return value: Return ASN1_SUCCESS on success, or an error.
286 **/ 286 **/
287int 287int
288asn1_get_bit_der (const unsigned char *der, int der_len, 288MHD__asn1_get_bit_der (const unsigned char *der, int der_len,
289 int *ret_len, unsigned char *str, int str_size, 289 int *ret_len, unsigned char *str, int str_size,
290 int *bit_len) 290 int *bit_len)
291{ 291{
@@ -293,7 +293,7 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
293 293
294 if (der_len <= 0) 294 if (der_len <= 0)
295 return ASN1_GENERIC_ERROR; 295 return ASN1_GENERIC_ERROR;
296 len_byte = asn1_get_length_der (der, der_len, &len_len) - 1; 296 len_byte = MHD__asn1_get_length_der (der, der_len, &len_len) - 1;
297 if (len_byte < 0) 297 if (len_byte < 0)
298 return ASN1_DER_ERROR; 298 return ASN1_DER_ERROR;
299 299
@@ -314,7 +314,7 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
314 314
315 315
316int 316int
317_asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len, 317MHD__asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len,
318 int *ret_len) 318 int *ret_len)
319{ 319{
320 node_asn *p; 320 node_asn *p;
@@ -345,7 +345,7 @@ _asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len,
345 345
346 if (p->type & CONST_EXPLICIT) 346 if (p->type & CONST_EXPLICIT)
347 { 347 {
348 if (asn1_get_tag_der 348 if (MHD__asn1_get_tag_der
349 (der + counter, der_len - counter, &class, &len2, 349 (der + counter, der_len - counter, &class, &len2,
350 &tag) != ASN1_SUCCESS) 350 &tag) != ASN1_SUCCESS)
351 return ASN1_DER_ERROR; 351 return ASN1_DER_ERROR;
@@ -353,7 +353,7 @@ _asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len,
353 return ASN1_DER_ERROR; 353 return ASN1_DER_ERROR;
354 counter += len2; 354 counter += len2;
355 len3 = 355 len3 =
356 asn1_get_length_der (der + counter, der_len - counter, 356 MHD__asn1_get_length_der (der + counter, der_len - counter,
357 &len2); 357 &len2);
358 if (len3 < 0) 358 if (len3 < 0)
359 return ASN1_DER_ERROR; 359 return ASN1_DER_ERROR;
@@ -393,7 +393,7 @@ _asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len,
393 393
394 if (is_tag_implicit) 394 if (is_tag_implicit)
395 { 395 {
396 if (asn1_get_tag_der 396 if (MHD__asn1_get_tag_der
397 (der + counter, der_len - counter, &class, &len2, 397 (der + counter, der_len - counter, &class, &len2,
398 &tag) != ASN1_SUCCESS) 398 &tag) != ASN1_SUCCESS)
399 return ASN1_DER_ERROR; 399 return ASN1_DER_ERROR;
@@ -421,7 +421,7 @@ _asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len,
421 return ASN1_SUCCESS; 421 return ASN1_SUCCESS;
422 } 422 }
423 423
424 if (asn1_get_tag_der 424 if (MHD__asn1_get_tag_der
425 (der + counter, der_len - counter, &class, &len2, 425 (der + counter, der_len - counter, &class, &len2,
426 &tag) != ASN1_SUCCESS) 426 &tag) != ASN1_SUCCESS)
427 return ASN1_DER_ERROR; 427 return ASN1_DER_ERROR;
@@ -507,7 +507,7 @@ _asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len,
507 507
508 508
509int 509int
510_asn1_delete_not_used (node_asn * node) 510MHD__asn1_delete_not_used (node_asn * node)
511{ 511{
512 node_asn *p, *p2; 512 node_asn *p, *p2;
513 513
@@ -522,11 +522,11 @@ _asn1_delete_not_used (node_asn * node)
522 p2 = NULL; 522 p2 = NULL;
523 if (p != node) 523 if (p != node)
524 { 524 {
525 p2 = _asn1_find_left (p); 525 p2 = MHD__asn1_find_left (p);
526 if (!p2) 526 if (!p2)
527 p2 = _asn1_find_up (p); 527 p2 = MHD__asn1_find_up (p);
528 } 528 }
529 asn1_delete_structure (&p); 529 MHD__asn1_delete_structure (&p);
530 p = p2; 530 p = p2;
531 } 531 }
532 532
@@ -547,7 +547,7 @@ _asn1_delete_not_used (node_asn * node)
547 { 547 {
548 while (1) 548 while (1)
549 { 549 {
550 p = _asn1_find_up (p); 550 p = MHD__asn1_find_up (p);
551 if (p == node) 551 if (p == node)
552 { 552 {
553 p = NULL; 553 p = NULL;
@@ -566,8 +566,8 @@ _asn1_delete_not_used (node_asn * node)
566} 566}
567 567
568 568
569asn1_retCode 569MHD__asn1_retCode
570_asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) 570MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len)
571{ 571{
572 int len2, len3, counter, counter2, counter_end, tot_len, indefinite; 572 int len2, len3, counter, counter2, counter_end, tot_len, indefinite;
573 unsigned char *temp, *temp2; 573 unsigned char *temp, *temp2;
@@ -577,7 +577,7 @@ _asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len)
577 if (*(der - 1) & ASN1_CLASS_STRUCTURED) 577 if (*(der - 1) & ASN1_CLASS_STRUCTURED)
578 { 578 {
579 tot_len = 0; 579 tot_len = 0;
580 indefinite = asn1_get_length_der (der, *len, &len3); 580 indefinite = MHD__asn1_get_length_der (der, *len, &len3);
581 if (indefinite < -1) 581 if (indefinite < -1)
582 return ASN1_DER_ERROR; 582 return ASN1_DER_ERROR;
583 583
@@ -606,7 +606,7 @@ _asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len)
606 606
607 counter++; 607 counter++;
608 608
609 len2 = asn1_get_length_der (der + counter, *len - counter, &len3); 609 len2 = MHD__asn1_get_length_der (der + counter, *len - counter, &len3);
610 if (len2 <= 0) 610 if (len2 <= 0)
611 return ASN1_DER_ERROR; 611 return ASN1_DER_ERROR;
612 612
@@ -617,20 +617,20 @@ _asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len)
617 /* copy */ 617 /* copy */
618 if (node) 618 if (node)
619 { 619 {
620 asn1_length_der (tot_len, NULL, &len2); 620 MHD__asn1_length_der (tot_len, NULL, &len2);
621 temp = _asn1_alloca (len2 + tot_len); 621 temp = MHD__asn1_alloca (len2 + tot_len);
622 if (temp == NULL) 622 if (temp == NULL)
623 { 623 {
624 return ASN1_MEM_ALLOC_ERROR; 624 return ASN1_MEM_ALLOC_ERROR;
625 } 625 }
626 626
627 asn1_length_der (tot_len, temp, &len2); 627 MHD__asn1_length_der (tot_len, temp, &len2);
628 tot_len += len2; 628 tot_len += len2;
629 temp2 = temp + len2; 629 temp2 = temp + len2;
630 len2 = asn1_get_length_der (der, *len, &len3); 630 len2 = MHD__asn1_get_length_der (der, *len, &len3);
631 if (len2 < -1) 631 if (len2 < -1)
632 { 632 {
633 _asn1_afree (temp); 633 MHD__asn1_afree (temp);
634 return ASN1_DER_ERROR; 634 return ASN1_DER_ERROR;
635 } 635 }
636 counter2 = len3 + 1; 636 counter2 = len3 + 1;
@@ -643,10 +643,10 @@ _asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len)
643 while (counter2 < counter_end) 643 while (counter2 < counter_end)
644 { 644 {
645 len2 = 645 len2 =
646 asn1_get_length_der (der + counter2, *len - counter, &len3); 646 MHD__asn1_get_length_der (der + counter2, *len - counter, &len3);
647 if (len2 < -1) 647 if (len2 < -1)
648 { 648 {
649 _asn1_afree (temp); 649 MHD__asn1_afree (temp);
650 return ASN1_DER_ERROR; 650 return ASN1_DER_ERROR;
651 } 651 }
652 652
@@ -658,19 +658,19 @@ _asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len)
658 counter2 += len2 + len3 + 1; 658 counter2 += len2 + len3 + 1;
659 } 659 }
660 660
661 _asn1_set_value (node, temp, tot_len); 661 MHD__asn1_set_value (node, temp, tot_len);
662 _asn1_afree (temp); 662 MHD__asn1_afree (temp);
663 } 663 }
664 } 664 }
665 else 665 else
666 { /* NOT STRUCTURED */ 666 { /* NOT STRUCTURED */
667 len2 = asn1_get_length_der (der, *len, &len3); 667 len2 = MHD__asn1_get_length_der (der, *len, &len3);
668 if (len2 < 0) 668 if (len2 < 0)
669 return ASN1_DER_ERROR; 669 return ASN1_DER_ERROR;
670 if (len3 + len2 > *len) 670 if (len3 + len2 > *len)
671 return ASN1_DER_ERROR; 671 return ASN1_DER_ERROR;
672 if (node) 672 if (node)
673 _asn1_set_value (node, der, len3 + len2); 673 MHD__asn1_set_value (node, der, len3 + len2);
674 counter = len3 + len2; 674 counter = len3 + len2;
675 } 675 }
676 676
@@ -680,8 +680,8 @@ _asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len)
680} 680}
681 681
682 682
683asn1_retCode 683MHD__asn1_retCode
684_asn1_get_indefinite_length_string (const unsigned char *der, int *len) 684MHD__asn1_get_indefinite_length_string (const unsigned char *der, int *len)
685{ 685{
686 int len2, len3, counter, indefinite; 686 int len2, len3, counter, indefinite;
687 unsigned long tag; 687 unsigned long tag;
@@ -704,14 +704,14 @@ _asn1_get_indefinite_length_string (const unsigned char *der, int *len)
704 continue; 704 continue;
705 } 705 }
706 706
707 if (asn1_get_tag_der 707 if (MHD__asn1_get_tag_der
708 (der + counter, *len - counter, &class, &len2, 708 (der + counter, *len - counter, &class, &len2,
709 &tag) != ASN1_SUCCESS) 709 &tag) != ASN1_SUCCESS)
710 return ASN1_DER_ERROR; 710 return ASN1_DER_ERROR;
711 if (counter + len2 > *len) 711 if (counter + len2 > *len)
712 return ASN1_DER_ERROR; 712 return ASN1_DER_ERROR;
713 counter += len2; 713 counter += len2;
714 len2 = asn1_get_length_der (der + counter, *len - counter, &len3); 714 len2 = MHD__asn1_get_length_der (der + counter, *len - counter, &len3);
715 if (len2 < -1) 715 if (len2 < -1)
716 return ASN1_DER_ERROR; 716 return ASN1_DER_ERROR;
717 if (len2 == -1) 717 if (len2 == -1)
@@ -732,7 +732,7 @@ _asn1_get_indefinite_length_string (const unsigned char *der, int *len)
732 732
733 733
734/** 734/**
735 * asn1_der_decoding - Fill the structure *ELEMENT with values of a DER encoding string. 735 * MHD__asn1_der_decoding - Fill the structure *ELEMENT with values of a DER encoding string.
736 * @element: pointer to an ASN1 structure. 736 * @element: pointer to an ASN1 structure.
737 * @ider: vector that contains the DER encoding. 737 * @ider: vector that contains the DER encoding.
738 * @len: number of bytes of *@ider: @ider[0]..@ider[len-1]. 738 * @len: number of bytes of *@ider: @ider[0]..@ider[len-1].
@@ -755,8 +755,8 @@ _asn1_get_indefinite_length_string (const unsigned char *der, int *len)
755 * the structure NAME. *ELEMENT deleted. 755 * the structure NAME. *ELEMENT deleted.
756 **/ 756 **/
757 757
758asn1_retCode 758MHD__asn1_retCode
759asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, 759MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
760 char *errorDescription) 760 char *errorDescription)
761{ 761{
762 node_asn *node, *p, *p2, *p3; 762 node_asn *node, *p, *p2, *p3;
@@ -774,7 +774,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
774 774
775 if (node->type & CONST_OPTION) 775 if (node->type & CONST_OPTION)
776 { 776 {
777 asn1_delete_structure (element); 777 MHD__asn1_delete_structure (element);
778 return ASN1_GENERIC_ERROR; 778 return ASN1_GENERIC_ERROR;
779 } 779 }
780 780
@@ -788,7 +788,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
788 { 788 {
789 if (p->type & CONST_SET) 789 if (p->type & CONST_SET)
790 { 790 {
791 p2 = _asn1_find_up (p); 791 p2 = MHD__asn1_find_up (p);
792 len2 = strtol (p2->value, NULL, 10); 792 len2 = strtol (p2->value, NULL, 10);
793 if (len2 == -1) 793 if (len2 == -1)
794 { 794 {
@@ -808,7 +808,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
808 } 808 }
809 else if (counter > len2) 809 else if (counter > len2)
810 { 810 {
811 asn1_delete_structure (element); 811 MHD__asn1_delete_structure (element);
812 return ASN1_DER_ERROR; 812 return ASN1_DER_ERROR;
813 } 813 }
814 p2 = p2->down; 814 p2 = p2->down;
@@ -818,7 +818,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
818 { 818 {
819 if (type_field (p2->type) != TYPE_CHOICE) 819 if (type_field (p2->type) != TYPE_CHOICE)
820 ris = 820 ris =
821 _asn1_extract_tag_der (p2, der + counter, 821 MHD__asn1_extract_tag_der (p2, der + counter,
822 len - counter, &len2); 822 len - counter, &len2);
823 else 823 else
824 { 824 {
@@ -826,7 +826,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
826 while (p3) 826 while (p3)
827 { 827 {
828 ris = 828 ris =
829 _asn1_extract_tag_der (p3, der + counter, 829 MHD__asn1_extract_tag_der (p3, der + counter,
830 len - counter, &len2); 830 len - counter, &len2);
831 if (ris == ASN1_SUCCESS) 831 if (ris == ASN1_SUCCESS)
832 break; 832 break;
@@ -844,14 +844,14 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
844 } 844 }
845 if (p2 == NULL) 845 if (p2 == NULL)
846 { 846 {
847 asn1_delete_structure (element); 847 MHD__asn1_delete_structure (element);
848 return ASN1_DER_ERROR; 848 return ASN1_DER_ERROR;
849 } 849 }
850 } 850 }
851 851
852 if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) 852 if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
853 { 853 {
854 p2 = _asn1_find_up (p); 854 p2 = MHD__asn1_find_up (p);
855 len2 = strtol (p2->value, NULL, 10); 855 len2 = strtol (p2->value, NULL, 10);
856 if (counter == len2) 856 if (counter == len2)
857 { 857 {
@@ -864,7 +864,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
864 move = UP; 864 move = UP;
865 865
866 if (p->type & CONST_OPTION) 866 if (p->type & CONST_OPTION)
867 asn1_delete_structure (&p); 867 MHD__asn1_delete_structure (&p);
868 868
869 p = p2; 869 p = p2;
870 continue; 870 continue;
@@ -877,7 +877,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
877 { 877 {
878 if (counter < len) 878 if (counter < len)
879 ris = 879 ris =
880 _asn1_extract_tag_der (p->down, der + counter, 880 MHD__asn1_extract_tag_der (p->down, der + counter,
881 len - counter, &len2); 881 len - counter, &len2);
882 else 882 else
883 ris = ASN1_DER_ERROR; 883 ris = ASN1_DER_ERROR;
@@ -886,19 +886,19 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
886 while (p->down->right) 886 while (p->down->right)
887 { 887 {
888 p2 = p->down->right; 888 p2 = p->down->right;
889 asn1_delete_structure (&p2); 889 MHD__asn1_delete_structure (&p2);
890 } 890 }
891 break; 891 break;
892 } 892 }
893 else if (ris == ASN1_ERROR_TYPE_ANY) 893 else if (ris == ASN1_ERROR_TYPE_ANY)
894 { 894 {
895 asn1_delete_structure (element); 895 MHD__asn1_delete_structure (element);
896 return ASN1_ERROR_TYPE_ANY; 896 return ASN1_ERROR_TYPE_ANY;
897 } 897 }
898 else 898 else
899 { 899 {
900 p2 = p->down; 900 p2 = p->down;
901 asn1_delete_structure (&p2); 901 MHD__asn1_delete_structure (&p2);
902 } 902 }
903 } 903 }
904 904
@@ -906,7 +906,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
906 { 906 {
907 if (!(p->type & CONST_OPTION)) 907 if (!(p->type & CONST_OPTION))
908 { 908 {
909 asn1_delete_structure (element); 909 MHD__asn1_delete_structure (element);
910 return ASN1_DER_ERROR; 910 return ASN1_DER_ERROR;
911 } 911 }
912 } 912 }
@@ -916,7 +916,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
916 916
917 if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) 917 if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
918 { 918 {
919 p2 = _asn1_find_up (p); 919 p2 = MHD__asn1_find_up (p);
920 len2 = strtol (p2->value, NULL, 10); 920 len2 = strtol (p2->value, NULL, 10);
921 if ((len2 != -1) && (counter > len2)) 921 if ((len2 != -1) && (counter > len2))
922 ris = ASN1_TAG_ERROR; 922 ris = ASN1_TAG_ERROR;
@@ -924,7 +924,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
924 924
925 if (ris == ASN1_SUCCESS) 925 if (ris == ASN1_SUCCESS)
926 ris = 926 ris =
927 _asn1_extract_tag_der (p, der + counter, len - counter, &len2); 927 MHD__asn1_extract_tag_der (p, der + counter, len - counter, &len2);
928 if (ris != ASN1_SUCCESS) 928 if (ris != ASN1_SUCCESS)
929 { 929 {
930 if (p->type & CONST_OPTION) 930 if (p->type & CONST_OPTION)
@@ -934,15 +934,15 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
934 } 934 }
935 else if (p->type & CONST_DEFAULT) 935 else if (p->type & CONST_DEFAULT)
936 { 936 {
937 _asn1_set_value (p, NULL, 0); 937 MHD__asn1_set_value (p, NULL, 0);
938 move = RIGHT; 938 move = RIGHT;
939 } 939 }
940 else 940 else
941 { 941 {
942 if (errorDescription != NULL) 942 if (errorDescription != NULL)
943 _asn1_error_description_tag_error (p, errorDescription); 943 MHD__asn1_error_description_tag_error (p, errorDescription);
944 944
945 asn1_delete_structure (element); 945 MHD__asn1_delete_structure (element);
946 return ASN1_TAG_ERROR; 946 return ASN1_TAG_ERROR;
947 } 947 }
948 } 948 }
@@ -957,7 +957,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
957 case TYPE_NULL: 957 case TYPE_NULL:
958 if (der[counter]) 958 if (der[counter])
959 { 959 {
960 asn1_delete_structure (element); 960 MHD__asn1_delete_structure (element);
961 return ASN1_DER_ERROR; 961 return ASN1_DER_ERROR;
962 } 962 }
963 counter++; 963 counter++;
@@ -966,54 +966,54 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
966 case TYPE_BOOLEAN: 966 case TYPE_BOOLEAN:
967 if (der[counter++] != 1) 967 if (der[counter++] != 1)
968 { 968 {
969 asn1_delete_structure (element); 969 MHD__asn1_delete_structure (element);
970 return ASN1_DER_ERROR; 970 return ASN1_DER_ERROR;
971 } 971 }
972 if (der[counter++] == 0) 972 if (der[counter++] == 0)
973 _asn1_set_value (p, "F", 1); 973 MHD__asn1_set_value (p, "F", 1);
974 else 974 else
975 _asn1_set_value (p, "T", 1); 975 MHD__asn1_set_value (p, "T", 1);
976 move = RIGHT; 976 move = RIGHT;
977 break; 977 break;
978 case TYPE_INTEGER: 978 case TYPE_INTEGER:
979 case TYPE_ENUMERATED: 979 case TYPE_ENUMERATED:
980 len2 = 980 len2 =
981 asn1_get_length_der (der + counter, len - counter, &len3); 981 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
982 if (len2 < 0) 982 if (len2 < 0)
983 return ASN1_DER_ERROR; 983 return ASN1_DER_ERROR;
984 if (len2 + len3 > len - counter) 984 if (len2 + len3 > len - counter)
985 return ASN1_DER_ERROR; 985 return ASN1_DER_ERROR;
986 _asn1_set_value (p, der + counter, len3 + len2); 986 MHD__asn1_set_value (p, der + counter, len3 + len2);
987 counter += len3 + len2; 987 counter += len3 + len2;
988 move = RIGHT; 988 move = RIGHT;
989 break; 989 break;
990 case TYPE_OBJECT_ID: 990 case TYPE_OBJECT_ID:
991 _asn1_get_objectid_der (der + counter, len - counter, &len2, 991 MHD__asn1_get_objectid_der (der + counter, len - counter, &len2,
992 temp, sizeof (temp)); 992 temp, sizeof (temp));
993 tlen = strlen (temp); 993 tlen = strlen (temp);
994 if (tlen > 0) 994 if (tlen > 0)
995 _asn1_set_value (p, temp, tlen + 1); 995 MHD__asn1_set_value (p, temp, tlen + 1);
996 counter += len2; 996 counter += len2;
997 move = RIGHT; 997 move = RIGHT;
998 break; 998 break;
999 case TYPE_TIME: 999 case TYPE_TIME:
1000 result = 1000 result =
1001 _asn1_get_time_der (der + counter, len - counter, &len2, temp, 1001 MHD__asn1_get_time_der (der + counter, len - counter, &len2, temp,
1002 sizeof (temp) - 1); 1002 sizeof (temp) - 1);
1003 if (result != ASN1_SUCCESS) 1003 if (result != ASN1_SUCCESS)
1004 { 1004 {
1005 asn1_delete_structure (element); 1005 MHD__asn1_delete_structure (element);
1006 return result; 1006 return result;
1007 } 1007 }
1008 tlen = strlen (temp); 1008 tlen = strlen (temp);
1009 if (tlen > 0) 1009 if (tlen > 0)
1010 _asn1_set_value (p, temp, tlen + 1); 1010 MHD__asn1_set_value (p, temp, tlen + 1);
1011 counter += len2; 1011 counter += len2;
1012 move = RIGHT; 1012 move = RIGHT;
1013 break; 1013 break;
1014 case TYPE_OCTET_STRING: 1014 case TYPE_OCTET_STRING:
1015 len3 = len - counter; 1015 len3 = len - counter;
1016 ris = _asn1_get_octet_string (der + counter, p, &len3); 1016 ris = MHD__asn1_get_octet_string (der + counter, p, &len3);
1017 if (ris != ASN1_SUCCESS) 1017 if (ris != ASN1_SUCCESS)
1018 return ris; 1018 return ris;
1019 counter += len3; 1019 counter += len3;
@@ -1021,23 +1021,23 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1021 break; 1021 break;
1022 case TYPE_GENERALSTRING: 1022 case TYPE_GENERALSTRING:
1023 len2 = 1023 len2 =
1024 asn1_get_length_der (der + counter, len - counter, &len3); 1024 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
1025 if (len2 < 0) 1025 if (len2 < 0)
1026 return ASN1_DER_ERROR; 1026 return ASN1_DER_ERROR;
1027 if (len3 + len2 > len - counter) 1027 if (len3 + len2 > len - counter)
1028 return ASN1_DER_ERROR; 1028 return ASN1_DER_ERROR;
1029 _asn1_set_value (p, der + counter, len3 + len2); 1029 MHD__asn1_set_value (p, der + counter, len3 + len2);
1030 counter += len3 + len2; 1030 counter += len3 + len2;
1031 move = RIGHT; 1031 move = RIGHT;
1032 break; 1032 break;
1033 case TYPE_BIT_STRING: 1033 case TYPE_BIT_STRING:
1034 len2 = 1034 len2 =
1035 asn1_get_length_der (der + counter, len - counter, &len3); 1035 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
1036 if (len2 < 0) 1036 if (len2 < 0)
1037 return ASN1_DER_ERROR; 1037 return ASN1_DER_ERROR;
1038 if (len3 + len2 > len - counter) 1038 if (len3 + len2 > len - counter)
1039 return ASN1_DER_ERROR; 1039 return ASN1_DER_ERROR;
1040 _asn1_set_value (p, der + counter, len3 + len2); 1040 MHD__asn1_set_value (p, der + counter, len3 + len2);
1041 counter += len3 + len2; 1041 counter += len3 + len2;
1042 move = RIGHT; 1042 move = RIGHT;
1043 break; 1043 break;
@@ -1046,14 +1046,14 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1046 if (move == UP) 1046 if (move == UP)
1047 { 1047 {
1048 len2 = strtol (p->value, NULL, 10); 1048 len2 = strtol (p->value, NULL, 10);
1049 _asn1_set_value (p, NULL, 0); 1049 MHD__asn1_set_value (p, NULL, 0);
1050 if (len2 == -1) 1050 if (len2 == -1)
1051 { /* indefinite length method */ 1051 { /* indefinite length method */
1052 if (len - counter + 1 > 0) 1052 if (len - counter + 1 > 0)
1053 { 1053 {
1054 if ((der[counter]) || der[counter + 1]) 1054 if ((der[counter]) || der[counter + 1])
1055 { 1055 {
1056 asn1_delete_structure (element); 1056 MHD__asn1_delete_structure (element);
1057 return ASN1_DER_ERROR; 1057 return ASN1_DER_ERROR;
1058 } 1058 }
1059 } 1059 }
@@ -1065,7 +1065,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1065 { /* definite length method */ 1065 { /* definite length method */
1066 if (len2 != counter) 1066 if (len2 != counter)
1067 { 1067 {
1068 asn1_delete_structure (element); 1068 MHD__asn1_delete_structure (element);
1069 return ASN1_DER_ERROR; 1069 return ASN1_DER_ERROR;
1070 } 1070 }
1071 } 1071 }
@@ -1074,16 +1074,16 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1074 else 1074 else
1075 { /* move==DOWN || move==RIGHT */ 1075 { /* move==DOWN || move==RIGHT */
1076 len3 = 1076 len3 =
1077 asn1_get_length_der (der + counter, len - counter, &len2); 1077 MHD__asn1_get_length_der (der + counter, len - counter, &len2);
1078 if (len3 < -1) 1078 if (len3 < -1)
1079 return ASN1_DER_ERROR; 1079 return ASN1_DER_ERROR;
1080 counter += len2; 1080 counter += len2;
1081 if (len3 > 0) 1081 if (len3 > 0)
1082 { 1082 {
1083 _asn1_ltostr (counter + len3, temp); 1083 MHD__asn1_ltostr (counter + len3, temp);
1084 tlen = strlen (temp); 1084 tlen = strlen (temp);
1085 if (tlen > 0) 1085 if (tlen > 0)
1086 _asn1_set_value (p, temp, tlen + 1); 1086 MHD__asn1_set_value (p, temp, tlen + 1);
1087 move = DOWN; 1087 move = DOWN;
1088 } 1088 }
1089 else if (len3 == 0) 1089 else if (len3 == 0)
@@ -1094,7 +1094,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1094 if (type_field (p2->type) != TYPE_TAG) 1094 if (type_field (p2->type) != TYPE_TAG)
1095 { 1095 {
1096 p3 = p2->right; 1096 p3 = p2->right;
1097 asn1_delete_structure (&p2); 1097 MHD__asn1_delete_structure (&p2);
1098 p2 = p3; 1098 p2 = p3;
1099 } 1099 }
1100 else 1100 else
@@ -1104,7 +1104,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1104 } 1104 }
1105 else 1105 else
1106 { /* indefinite length method */ 1106 { /* indefinite length method */
1107 _asn1_set_value (p, "-1", 3); 1107 MHD__asn1_set_value (p, "-1", 3);
1108 move = DOWN; 1108 move = DOWN;
1109 } 1109 }
1110 } 1110 }
@@ -1120,31 +1120,31 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1120 return ASN1_DER_ERROR; 1120 return ASN1_DER_ERROR;
1121 if ((der[counter]) || der[counter + 1]) 1121 if ((der[counter]) || der[counter + 1])
1122 { 1122 {
1123 _asn1_append_sequence_set (p); 1123 MHD__asn1_append_sequence_set (p);
1124 p = p->down; 1124 p = p->down;
1125 while (p->right) 1125 while (p->right)
1126 p = p->right; 1126 p = p->right;
1127 move = RIGHT; 1127 move = RIGHT;
1128 continue; 1128 continue;
1129 } 1129 }
1130 _asn1_set_value (p, NULL, 0); 1130 MHD__asn1_set_value (p, NULL, 0);
1131 counter += 2; 1131 counter += 2;
1132 } 1132 }
1133 else 1133 else
1134 { /* definite length method */ 1134 { /* definite length method */
1135 if (len2 > counter) 1135 if (len2 > counter)
1136 { 1136 {
1137 _asn1_append_sequence_set (p); 1137 MHD__asn1_append_sequence_set (p);
1138 p = p->down; 1138 p = p->down;
1139 while (p->right) 1139 while (p->right)
1140 p = p->right; 1140 p = p->right;
1141 move = RIGHT; 1141 move = RIGHT;
1142 continue; 1142 continue;
1143 } 1143 }
1144 _asn1_set_value (p, NULL, 0); 1144 MHD__asn1_set_value (p, NULL, 0);
1145 if (len2 != counter) 1145 if (len2 != counter)
1146 { 1146 {
1147 asn1_delete_structure (element); 1147 MHD__asn1_delete_structure (element);
1148 return ASN1_DER_ERROR; 1148 return ASN1_DER_ERROR;
1149 } 1149 }
1150 } 1150 }
@@ -1152,7 +1152,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1152 else 1152 else
1153 { /* move==DOWN || move==RIGHT */ 1153 { /* move==DOWN || move==RIGHT */
1154 len3 = 1154 len3 =
1155 asn1_get_length_der (der + counter, len - counter, &len2); 1155 MHD__asn1_get_length_der (der + counter, len - counter, &len2);
1156 if (len3 < -1) 1156 if (len3 < -1)
1157 return ASN1_DER_ERROR; 1157 return ASN1_DER_ERROR;
1158 counter += len2; 1158 counter += len2;
@@ -1160,36 +1160,36 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1160 { 1160 {
1161 if (len3 > 0) 1161 if (len3 > 0)
1162 { /* definite length method */ 1162 { /* definite length method */
1163 _asn1_ltostr (counter + len3, temp); 1163 MHD__asn1_ltostr (counter + len3, temp);
1164 tlen = strlen (temp); 1164 tlen = strlen (temp);
1165 1165
1166 if (tlen > 0) 1166 if (tlen > 0)
1167 _asn1_set_value (p, temp, tlen + 1); 1167 MHD__asn1_set_value (p, temp, tlen + 1);
1168 } 1168 }
1169 else 1169 else
1170 { /* indefinite length method */ 1170 { /* indefinite length method */
1171 _asn1_set_value (p, "-1", 3); 1171 MHD__asn1_set_value (p, "-1", 3);
1172 } 1172 }
1173 p2 = p->down; 1173 p2 = p->down;
1174 while ((type_field (p2->type) == TYPE_TAG) 1174 while ((type_field (p2->type) == TYPE_TAG)
1175 || (type_field (p2->type) == TYPE_SIZE)) 1175 || (type_field (p2->type) == TYPE_SIZE))
1176 p2 = p2->right; 1176 p2 = p2->right;
1177 if (p2->right == NULL) 1177 if (p2->right == NULL)
1178 _asn1_append_sequence_set (p); 1178 MHD__asn1_append_sequence_set (p);
1179 p = p2; 1179 p = p2;
1180 } 1180 }
1181 } 1181 }
1182 move = RIGHT; 1182 move = RIGHT;
1183 break; 1183 break;
1184 case TYPE_ANY: 1184 case TYPE_ANY:
1185 if (asn1_get_tag_der 1185 if (MHD__asn1_get_tag_der
1186 (der + counter, len - counter, &class, &len2, 1186 (der + counter, len - counter, &class, &len2,
1187 &tag) != ASN1_SUCCESS) 1187 &tag) != ASN1_SUCCESS)
1188 return ASN1_DER_ERROR; 1188 return ASN1_DER_ERROR;
1189 if (counter + len2 > len) 1189 if (counter + len2 > len)
1190 return ASN1_DER_ERROR; 1190 return ASN1_DER_ERROR;
1191 len4 = 1191 len4 =
1192 asn1_get_length_der (der + counter + len2, 1192 MHD__asn1_get_length_der (der + counter + len2,
1193 len - counter - len2, &len3); 1193 len - counter - len2, &len3);
1194 if (len4 < -1) 1194 if (len4 < -1)
1195 return ASN1_DER_ERROR; 1195 return ASN1_DER_ERROR;
@@ -1198,17 +1198,17 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1198 if (len4 != -1) 1198 if (len4 != -1)
1199 { 1199 {
1200 len2 += len4; 1200 len2 += len4;
1201 asn1_length_der (len2 + len3, NULL, &len4); 1201 MHD__asn1_length_der (len2 + len3, NULL, &len4);
1202 temp2 = (unsigned char *) _asn1_alloca (len2 + len3 + len4); 1202 temp2 = (unsigned char *) MHD__asn1_alloca (len2 + len3 + len4);
1203 if (temp2 == NULL) 1203 if (temp2 == NULL)
1204 { 1204 {
1205 asn1_delete_structure (element); 1205 MHD__asn1_delete_structure (element);
1206 return ASN1_MEM_ALLOC_ERROR; 1206 return ASN1_MEM_ALLOC_ERROR;
1207 } 1207 }
1208 1208
1209 asn1_octet_der (der + counter, len2 + len3, temp2, &len4); 1209 MHD__asn1_octet_der (der + counter, len2 + len3, temp2, &len4);
1210 _asn1_set_value (p, temp2, len4); 1210 MHD__asn1_set_value (p, temp2, len4);
1211 _asn1_afree (temp2); 1211 MHD__asn1_afree (temp2);
1212 counter += len2 + len3; 1212 counter += len2 + len3;
1213 } 1213 }
1214 else 1214 else
@@ -1221,23 +1221,23 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1221 1221
1222 len2 = len - counter; 1222 len2 = len - counter;
1223 ris = 1223 ris =
1224 _asn1_get_indefinite_length_string (der + counter, &len2); 1224 MHD__asn1_get_indefinite_length_string (der + counter, &len2);
1225 if (ris != ASN1_SUCCESS) 1225 if (ris != ASN1_SUCCESS)
1226 { 1226 {
1227 asn1_delete_structure (element); 1227 MHD__asn1_delete_structure (element);
1228 return ris; 1228 return ris;
1229 } 1229 }
1230 asn1_length_der (len2, NULL, &len4); 1230 MHD__asn1_length_der (len2, NULL, &len4);
1231 temp2 = (unsigned char *) _asn1_alloca (len2 + len4); 1231 temp2 = (unsigned char *) MHD__asn1_alloca (len2 + len4);
1232 if (temp2 == NULL) 1232 if (temp2 == NULL)
1233 { 1233 {
1234 asn1_delete_structure (element); 1234 MHD__asn1_delete_structure (element);
1235 return ASN1_MEM_ALLOC_ERROR; 1235 return ASN1_MEM_ALLOC_ERROR;
1236 } 1236 }
1237 1237
1238 asn1_octet_der (der + counter, len2, temp2, &len4); 1238 MHD__asn1_octet_der (der + counter, len2, temp2, &len4);
1239 _asn1_set_value (p, temp2, len4); 1239 MHD__asn1_set_value (p, temp2, len4);
1240 _asn1_afree (temp2); 1240 MHD__asn1_afree (temp2);
1241 counter += len2; 1241 counter += len2;
1242 1242
1243 /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with 1243 /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
@@ -1250,7 +1250,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1250 } 1250 }
1251 else 1251 else
1252 { 1252 {
1253 asn1_delete_structure (element); 1253 MHD__asn1_delete_structure (element);
1254 return ASN1_DER_ERROR; 1254 return ASN1_DER_ERROR;
1255 } 1255 }
1256 } 1256 }
@@ -1281,14 +1281,14 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1281 move = UP; 1281 move = UP;
1282 } 1282 }
1283 if (move == UP) 1283 if (move == UP)
1284 p = _asn1_find_up (p); 1284 p = MHD__asn1_find_up (p);
1285 } 1285 }
1286 1286
1287 _asn1_delete_not_used (*element); 1287 MHD__asn1_delete_not_used (*element);
1288 1288
1289 if (counter != len) 1289 if (counter != len)
1290 { 1290 {
1291 asn1_delete_structure (element); 1291 MHD__asn1_delete_structure (element);
1292 return ASN1_DER_ERROR; 1292 return ASN1_DER_ERROR;
1293 } 1293 }
1294 1294
@@ -1302,7 +1302,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1302#define EXIT 4 1302#define EXIT 4
1303 1303
1304/** 1304/**
1305 * asn1_der_decoding_element - Fill the element named ELEMENTNAME of the structure STRUCTURE with values of a DER encoding string. 1305 * MHD__asn1_der_decoding_element - Fill the element named ELEMENTNAME of the structure STRUCTURE with values of a DER encoding string.
1306 * @structure: pointer to an ASN1 structure 1306 * @structure: pointer to an ASN1 structure
1307 * @elementName: name of the element to fill 1307 * @elementName: name of the element to fill
1308 * @ider: vector that contains the DER encoding of the whole structure. 1308 * @ider: vector that contains the DER encoding of the whole structure.
@@ -1328,8 +1328,8 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
1328 * the structure STRUCTURE. *ELEMENT deleted. 1328 * the structure STRUCTURE. *ELEMENT deleted.
1329 * 1329 *
1330 **/ 1330 **/
1331asn1_retCode 1331MHD__asn1_retCode
1332asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, 1332MHD__asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1333 const void *ider, int len, char *errorDescription) 1333 const void *ider, int len, char *errorDescription)
1334{ 1334{
1335 node_asn *node, *p, *p2, *p3, *nodeFound = ASN1_TYPE_EMPTY; 1335 node_asn *node, *p, *p2, *p3, *nodeFound = ASN1_TYPE_EMPTY;
@@ -1348,13 +1348,13 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1348 1348
1349 if (elementName == NULL) 1349 if (elementName == NULL)
1350 { 1350 {
1351 asn1_delete_structure (structure); 1351 MHD__asn1_delete_structure (structure);
1352 return ASN1_ELEMENT_NOT_FOUND; 1352 return ASN1_ELEMENT_NOT_FOUND;
1353 } 1353 }
1354 1354
1355 if (node->type & CONST_OPTION) 1355 if (node->type & CONST_OPTION)
1356 { 1356 {
1357 asn1_delete_structure (structure); 1357 MHD__asn1_delete_structure (structure);
1358 return ASN1_GENERIC_ERROR; 1358 return ASN1_GENERIC_ERROR;
1359 } 1359 }
1360 1360
@@ -1365,7 +1365,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1365 strcpy (currentName, (*structure)->name); 1365 strcpy (currentName, (*structure)->name);
1366 else 1366 else
1367 { 1367 {
1368 asn1_delete_structure (structure); 1368 MHD__asn1_delete_structure (structure);
1369 return ASN1_MEM_ERROR; 1369 return ASN1_MEM_ERROR;
1370 } 1370 }
1371 if (!(strcmp (currentName, elementName))) 1371 if (!(strcmp (currentName, elementName)))
@@ -1404,7 +1404,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1404 { 1404 {
1405 if (p->type & CONST_SET) 1405 if (p->type & CONST_SET)
1406 { 1406 {
1407 p2 = _asn1_find_up (p); 1407 p2 = MHD__asn1_find_up (p);
1408 len2 = strtol (p2->value, NULL, 10); 1408 len2 = strtol (p2->value, NULL, 10);
1409 if (counter == len2) 1409 if (counter == len2)
1410 { 1410 {
@@ -1414,7 +1414,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1414 } 1414 }
1415 else if (counter > len2) 1415 else if (counter > len2)
1416 { 1416 {
1417 asn1_delete_structure (structure); 1417 MHD__asn1_delete_structure (structure);
1418 return ASN1_DER_ERROR; 1418 return ASN1_DER_ERROR;
1419 } 1419 }
1420 p2 = p2->down; 1420 p2 = p2->down;
@@ -1424,7 +1424,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1424 { 1424 {
1425 if (type_field (p2->type) != TYPE_CHOICE) 1425 if (type_field (p2->type) != TYPE_CHOICE)
1426 ris = 1426 ris =
1427 _asn1_extract_tag_der (p2, der + counter, 1427 MHD__asn1_extract_tag_der (p2, der + counter,
1428 len - counter, &len2); 1428 len - counter, &len2);
1429 else 1429 else
1430 { 1430 {
@@ -1432,7 +1432,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1432 while (p3) 1432 while (p3)
1433 { 1433 {
1434 ris = 1434 ris =
1435 _asn1_extract_tag_der (p3, der + counter, 1435 MHD__asn1_extract_tag_der (p3, der + counter,
1436 len - counter, &len2); 1436 len - counter, &len2);
1437 if (ris == ASN1_SUCCESS) 1437 if (ris == ASN1_SUCCESS)
1438 break; 1438 break;
@@ -1450,14 +1450,14 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1450 } 1450 }
1451 if (p2 == NULL) 1451 if (p2 == NULL)
1452 { 1452 {
1453 asn1_delete_structure (structure); 1453 MHD__asn1_delete_structure (structure);
1454 return ASN1_DER_ERROR; 1454 return ASN1_DER_ERROR;
1455 } 1455 }
1456 } 1456 }
1457 1457
1458 if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) 1458 if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
1459 { 1459 {
1460 p2 = _asn1_find_up (p); 1460 p2 = MHD__asn1_find_up (p);
1461 len2 = strtol (p2->value, NULL, 10); 1461 len2 = strtol (p2->value, NULL, 10);
1462 if (counter == len2) 1462 if (counter == len2)
1463 { 1463 {
@@ -1470,7 +1470,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1470 move = UP; 1470 move = UP;
1471 1471
1472 if (p->type & CONST_OPTION) 1472 if (p->type & CONST_OPTION)
1473 asn1_delete_structure (&p); 1473 MHD__asn1_delete_structure (&p);
1474 1474
1475 p = p2; 1475 p = p2;
1476 continue; 1476 continue;
@@ -1483,7 +1483,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1483 { 1483 {
1484 if (counter < len) 1484 if (counter < len)
1485 ris = 1485 ris =
1486 _asn1_extract_tag_der (p->down, der + counter, 1486 MHD__asn1_extract_tag_der (p->down, der + counter,
1487 len - counter, &len2); 1487 len - counter, &len2);
1488 else 1488 else
1489 ris = ASN1_DER_ERROR; 1489 ris = ASN1_DER_ERROR;
@@ -1492,19 +1492,19 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1492 while (p->down->right) 1492 while (p->down->right)
1493 { 1493 {
1494 p2 = p->down->right; 1494 p2 = p->down->right;
1495 asn1_delete_structure (&p2); 1495 MHD__asn1_delete_structure (&p2);
1496 } 1496 }
1497 break; 1497 break;
1498 } 1498 }
1499 else if (ris == ASN1_ERROR_TYPE_ANY) 1499 else if (ris == ASN1_ERROR_TYPE_ANY)
1500 { 1500 {
1501 asn1_delete_structure (structure); 1501 MHD__asn1_delete_structure (structure);
1502 return ASN1_ERROR_TYPE_ANY; 1502 return ASN1_ERROR_TYPE_ANY;
1503 } 1503 }
1504 else 1504 else
1505 { 1505 {
1506 p2 = p->down; 1506 p2 = p->down;
1507 asn1_delete_structure (&p2); 1507 MHD__asn1_delete_structure (&p2);
1508 } 1508 }
1509 } 1509 }
1510 1510
@@ -1512,7 +1512,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1512 { 1512 {
1513 if (!(p->type & CONST_OPTION)) 1513 if (!(p->type & CONST_OPTION))
1514 { 1514 {
1515 asn1_delete_structure (structure); 1515 MHD__asn1_delete_structure (structure);
1516 return ASN1_DER_ERROR; 1516 return ASN1_DER_ERROR;
1517 } 1517 }
1518 } 1518 }
@@ -1522,7 +1522,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1522 1522
1523 if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) 1523 if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT))
1524 { 1524 {
1525 p2 = _asn1_find_up (p); 1525 p2 = MHD__asn1_find_up (p);
1526 len2 = strtol (p2->value, NULL, 10); 1526 len2 = strtol (p2->value, NULL, 10);
1527 if (counter > len2) 1527 if (counter > len2)
1528 ris = ASN1_TAG_ERROR; 1528 ris = ASN1_TAG_ERROR;
@@ -1530,7 +1530,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1530 1530
1531 if (ris == ASN1_SUCCESS) 1531 if (ris == ASN1_SUCCESS)
1532 ris = 1532 ris =
1533 _asn1_extract_tag_der (p, der + counter, len - counter, &len2); 1533 MHD__asn1_extract_tag_der (p, der + counter, len - counter, &len2);
1534 if (ris != ASN1_SUCCESS) 1534 if (ris != ASN1_SUCCESS)
1535 { 1535 {
1536 if (p->type & CONST_OPTION) 1536 if (p->type & CONST_OPTION)
@@ -1540,15 +1540,15 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1540 } 1540 }
1541 else if (p->type & CONST_DEFAULT) 1541 else if (p->type & CONST_DEFAULT)
1542 { 1542 {
1543 _asn1_set_value (p, NULL, 0); 1543 MHD__asn1_set_value (p, NULL, 0);
1544 move = RIGHT; 1544 move = RIGHT;
1545 } 1545 }
1546 else 1546 else
1547 { 1547 {
1548 if (errorDescription != NULL) 1548 if (errorDescription != NULL)
1549 _asn1_error_description_tag_error (p, errorDescription); 1549 MHD__asn1_error_description_tag_error (p, errorDescription);
1550 1550
1551 asn1_delete_structure (structure); 1551 MHD__asn1_delete_structure (structure);
1552 return ASN1_TAG_ERROR; 1552 return ASN1_TAG_ERROR;
1553 } 1553 }
1554 } 1554 }
@@ -1563,7 +1563,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1563 case TYPE_NULL: 1563 case TYPE_NULL:
1564 if (der[counter]) 1564 if (der[counter])
1565 { 1565 {
1566 asn1_delete_structure (structure); 1566 MHD__asn1_delete_structure (structure);
1567 return ASN1_DER_ERROR; 1567 return ASN1_DER_ERROR;
1568 } 1568 }
1569 1569
@@ -1576,16 +1576,16 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1576 case TYPE_BOOLEAN: 1576 case TYPE_BOOLEAN:
1577 if (der[counter++] != 1) 1577 if (der[counter++] != 1)
1578 { 1578 {
1579 asn1_delete_structure (structure); 1579 MHD__asn1_delete_structure (structure);
1580 return ASN1_DER_ERROR; 1580 return ASN1_DER_ERROR;
1581 } 1581 }
1582 1582
1583 if (state == FOUND) 1583 if (state == FOUND)
1584 { 1584 {
1585 if (der[counter++] == 0) 1585 if (der[counter++] == 0)
1586 _asn1_set_value (p, "F", 1); 1586 MHD__asn1_set_value (p, "F", 1);
1587 else 1587 else
1588 _asn1_set_value (p, "T", 1); 1588 MHD__asn1_set_value (p, "T", 1);
1589 1589
1590 if (p == nodeFound) 1590 if (p == nodeFound)
1591 state = EXIT; 1591 state = EXIT;
@@ -1599,14 +1599,14 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1599 case TYPE_INTEGER: 1599 case TYPE_INTEGER:
1600 case TYPE_ENUMERATED: 1600 case TYPE_ENUMERATED:
1601 len2 = 1601 len2 =
1602 asn1_get_length_der (der + counter, len - counter, &len3); 1602 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
1603 if (len2 < 0) 1603 if (len2 < 0)
1604 return ASN1_DER_ERROR; 1604 return ASN1_DER_ERROR;
1605 if (state == FOUND) 1605 if (state == FOUND)
1606 { 1606 {
1607 if (len3 + len2 > len - counter) 1607 if (len3 + len2 > len - counter)
1608 return ASN1_DER_ERROR; 1608 return ASN1_DER_ERROR;
1609 _asn1_set_value (p, der + counter, len3 + len2); 1609 MHD__asn1_set_value (p, der + counter, len3 + len2);
1610 1610
1611 if (p == nodeFound) 1611 if (p == nodeFound)
1612 state = EXIT; 1612 state = EXIT;
@@ -1617,12 +1617,12 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1617 case TYPE_OBJECT_ID: 1617 case TYPE_OBJECT_ID:
1618 if (state == FOUND) 1618 if (state == FOUND)
1619 { 1619 {
1620 _asn1_get_objectid_der (der + counter, len - counter, &len2, 1620 MHD__asn1_get_objectid_der (der + counter, len - counter, &len2,
1621 temp, sizeof (temp)); 1621 temp, sizeof (temp));
1622 tlen = strlen (temp); 1622 tlen = strlen (temp);
1623 1623
1624 if (tlen > 0) 1624 if (tlen > 0)
1625 _asn1_set_value (p, temp, tlen + 1); 1625 MHD__asn1_set_value (p, temp, tlen + 1);
1626 1626
1627 if (p == nodeFound) 1627 if (p == nodeFound)
1628 state = EXIT; 1628 state = EXIT;
@@ -1630,7 +1630,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1630 else 1630 else
1631 { 1631 {
1632 len2 = 1632 len2 =
1633 asn1_get_length_der (der + counter, len - counter, &len3); 1633 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
1634 if (len2 < 0) 1634 if (len2 < 0)
1635 return ASN1_DER_ERROR; 1635 return ASN1_DER_ERROR;
1636 len2 += len3; 1636 len2 += len3;
@@ -1643,17 +1643,17 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1643 if (state == FOUND) 1643 if (state == FOUND)
1644 { 1644 {
1645 result = 1645 result =
1646 _asn1_get_time_der (der + counter, len - counter, &len2, 1646 MHD__asn1_get_time_der (der + counter, len - counter, &len2,
1647 temp, sizeof (temp) - 1); 1647 temp, sizeof (temp) - 1);
1648 if (result != ASN1_SUCCESS) 1648 if (result != ASN1_SUCCESS)
1649 { 1649 {
1650 asn1_delete_structure (structure); 1650 MHD__asn1_delete_structure (structure);
1651 return result; 1651 return result;
1652 } 1652 }
1653 1653
1654 tlen = strlen (temp); 1654 tlen = strlen (temp);
1655 if (tlen > 0) 1655 if (tlen > 0)
1656 _asn1_set_value (p, temp, tlen + 1); 1656 MHD__asn1_set_value (p, temp, tlen + 1);
1657 1657
1658 if (p == nodeFound) 1658 if (p == nodeFound)
1659 state = EXIT; 1659 state = EXIT;
@@ -1661,7 +1661,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1661 else 1661 else
1662 { 1662 {
1663 len2 = 1663 len2 =
1664 asn1_get_length_der (der + counter, len - counter, &len3); 1664 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
1665 if (len2 < 0) 1665 if (len2 < 0)
1666 return ASN1_DER_ERROR; 1666 return ASN1_DER_ERROR;
1667 len2 += len3; 1667 len2 += len3;
@@ -1674,12 +1674,12 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1674 len3 = len - counter; 1674 len3 = len - counter;
1675 if (state == FOUND) 1675 if (state == FOUND)
1676 { 1676 {
1677 ris = _asn1_get_octet_string (der + counter, p, &len3); 1677 ris = MHD__asn1_get_octet_string (der + counter, p, &len3);
1678 if (p == nodeFound) 1678 if (p == nodeFound)
1679 state = EXIT; 1679 state = EXIT;
1680 } 1680 }
1681 else 1681 else
1682 ris = _asn1_get_octet_string (der + counter, NULL, &len3); 1682 ris = MHD__asn1_get_octet_string (der + counter, NULL, &len3);
1683 1683
1684 if (ris != ASN1_SUCCESS) 1684 if (ris != ASN1_SUCCESS)
1685 return ris; 1685 return ris;
@@ -1688,14 +1688,14 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1688 break; 1688 break;
1689 case TYPE_GENERALSTRING: 1689 case TYPE_GENERALSTRING:
1690 len2 = 1690 len2 =
1691 asn1_get_length_der (der + counter, len - counter, &len3); 1691 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
1692 if (len2 < 0) 1692 if (len2 < 0)
1693 return ASN1_DER_ERROR; 1693 return ASN1_DER_ERROR;
1694 if (state == FOUND) 1694 if (state == FOUND)
1695 { 1695 {
1696 if (len3 + len2 > len - counter) 1696 if (len3 + len2 > len - counter)
1697 return ASN1_DER_ERROR; 1697 return ASN1_DER_ERROR;
1698 _asn1_set_value (p, der + counter, len3 + len2); 1698 MHD__asn1_set_value (p, der + counter, len3 + len2);
1699 1699
1700 if (p == nodeFound) 1700 if (p == nodeFound)
1701 state = EXIT; 1701 state = EXIT;
@@ -1705,14 +1705,14 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1705 break; 1705 break;
1706 case TYPE_BIT_STRING: 1706 case TYPE_BIT_STRING:
1707 len2 = 1707 len2 =
1708 asn1_get_length_der (der + counter, len - counter, &len3); 1708 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
1709 if (len2 < 0) 1709 if (len2 < 0)
1710 return ASN1_DER_ERROR; 1710 return ASN1_DER_ERROR;
1711 if (state == FOUND) 1711 if (state == FOUND)
1712 { 1712 {
1713 if (len3 + len2 > len - counter) 1713 if (len3 + len2 > len - counter)
1714 return ASN1_DER_ERROR; 1714 return ASN1_DER_ERROR;
1715 _asn1_set_value (p, der + counter, len3 + len2); 1715 MHD__asn1_set_value (p, der + counter, len3 + len2);
1716 1716
1717 if (p == nodeFound) 1717 if (p == nodeFound)
1718 state = EXIT; 1718 state = EXIT;
@@ -1725,12 +1725,12 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1725 if (move == UP) 1725 if (move == UP)
1726 { 1726 {
1727 len2 = strtol (p->value, NULL, 10); 1727 len2 = strtol (p->value, NULL, 10);
1728 _asn1_set_value (p, NULL, 0); 1728 MHD__asn1_set_value (p, NULL, 0);
1729 if (len2 == -1) 1729 if (len2 == -1)
1730 { /* indefinite length method */ 1730 { /* indefinite length method */
1731 if ((der[counter]) || der[counter + 1]) 1731 if ((der[counter]) || der[counter + 1])
1732 { 1732 {
1733 asn1_delete_structure (structure); 1733 MHD__asn1_delete_structure (structure);
1734 return ASN1_DER_ERROR; 1734 return ASN1_DER_ERROR;
1735 } 1735 }
1736 counter += 2; 1736 counter += 2;
@@ -1739,7 +1739,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1739 { /* definite length method */ 1739 { /* definite length method */
1740 if (len2 != counter) 1740 if (len2 != counter)
1741 { 1741 {
1742 asn1_delete_structure (structure); 1742 MHD__asn1_delete_structure (structure);
1743 return ASN1_DER_ERROR; 1743 return ASN1_DER_ERROR;
1744 } 1744 }
1745 } 1745 }
@@ -1752,7 +1752,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1752 if (state == OTHER_BRANCH) 1752 if (state == OTHER_BRANCH)
1753 { 1753 {
1754 len3 = 1754 len3 =
1755 asn1_get_length_der (der + counter, len - counter, 1755 MHD__asn1_get_length_der (der + counter, len - counter,
1756 &len2); 1756 &len2);
1757 if (len3 < 0) 1757 if (len3 < 0)
1758 return ASN1_DER_ERROR; 1758 return ASN1_DER_ERROR;
@@ -1762,18 +1762,18 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1762 else 1762 else
1763 { /* state==SAME_BRANCH or state==FOUND */ 1763 { /* state==SAME_BRANCH or state==FOUND */
1764 len3 = 1764 len3 =
1765 asn1_get_length_der (der + counter, len - counter, 1765 MHD__asn1_get_length_der (der + counter, len - counter,
1766 &len2); 1766 &len2);
1767 if (len3 < 0) 1767 if (len3 < 0)
1768 return ASN1_DER_ERROR; 1768 return ASN1_DER_ERROR;
1769 counter += len2; 1769 counter += len2;
1770 if (len3 > 0) 1770 if (len3 > 0)
1771 { 1771 {
1772 _asn1_ltostr (counter + len3, temp); 1772 MHD__asn1_ltostr (counter + len3, temp);
1773 tlen = strlen (temp); 1773 tlen = strlen (temp);
1774 1774
1775 if (tlen > 0) 1775 if (tlen > 0)
1776 _asn1_set_value (p, temp, tlen + 1); 1776 MHD__asn1_set_value (p, temp, tlen + 1);
1777 move = DOWN; 1777 move = DOWN;
1778 } 1778 }
1779 else if (len3 == 0) 1779 else if (len3 == 0)
@@ -1784,7 +1784,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1784 if (type_field (p2->type) != TYPE_TAG) 1784 if (type_field (p2->type) != TYPE_TAG)
1785 { 1785 {
1786 p3 = p2->right; 1786 p3 = p2->right;
1787 asn1_delete_structure (&p2); 1787 MHD__asn1_delete_structure (&p2);
1788 p2 = p3; 1788 p2 = p3;
1789 } 1789 }
1790 else 1790 else
@@ -1794,7 +1794,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1794 } 1794 }
1795 else 1795 else
1796 { /* indefinite length method */ 1796 { /* indefinite length method */
1797 _asn1_set_value (p, "-1", 3); 1797 MHD__asn1_set_value (p, "-1", 3);
1798 move = DOWN; 1798 move = DOWN;
1799 } 1799 }
1800 } 1800 }
@@ -1807,17 +1807,17 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1807 len2 = strtol (p->value, NULL, 10); 1807 len2 = strtol (p->value, NULL, 10);
1808 if (len2 > counter) 1808 if (len2 > counter)
1809 { 1809 {
1810 _asn1_append_sequence_set (p); 1810 MHD__asn1_append_sequence_set (p);
1811 p = p->down; 1811 p = p->down;
1812 while (p->right) 1812 while (p->right)
1813 p = p->right; 1813 p = p->right;
1814 move = RIGHT; 1814 move = RIGHT;
1815 continue; 1815 continue;
1816 } 1816 }
1817 _asn1_set_value (p, NULL, 0); 1817 MHD__asn1_set_value (p, NULL, 0);
1818 if (len2 != counter) 1818 if (len2 != counter)
1819 { 1819 {
1820 asn1_delete_structure (structure); 1820 MHD__asn1_delete_structure (structure);
1821 return ASN1_DER_ERROR; 1821 return ASN1_DER_ERROR;
1822 } 1822 }
1823 1823
@@ -1829,7 +1829,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1829 if (state == OTHER_BRANCH) 1829 if (state == OTHER_BRANCH)
1830 { 1830 {
1831 len3 = 1831 len3 =
1832 asn1_get_length_der (der + counter, len - counter, 1832 MHD__asn1_get_length_der (der + counter, len - counter,
1833 &len2); 1833 &len2);
1834 if (len3 < 0) 1834 if (len3 < 0)
1835 return ASN1_DER_ERROR; 1835 return ASN1_DER_ERROR;
@@ -1839,24 +1839,24 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1839 else 1839 else
1840 { /* state==FOUND or state==SAME_BRANCH */ 1840 { /* state==FOUND or state==SAME_BRANCH */
1841 len3 = 1841 len3 =
1842 asn1_get_length_der (der + counter, len - counter, 1842 MHD__asn1_get_length_der (der + counter, len - counter,
1843 &len2); 1843 &len2);
1844 if (len3 < 0) 1844 if (len3 < 0)
1845 return ASN1_DER_ERROR; 1845 return ASN1_DER_ERROR;
1846 counter += len2; 1846 counter += len2;
1847 if (len3) 1847 if (len3)
1848 { 1848 {
1849 _asn1_ltostr (counter + len3, temp); 1849 MHD__asn1_ltostr (counter + len3, temp);
1850 tlen = strlen (temp); 1850 tlen = strlen (temp);
1851 1851
1852 if (tlen > 0) 1852 if (tlen > 0)
1853 _asn1_set_value (p, temp, tlen + 1); 1853 MHD__asn1_set_value (p, temp, tlen + 1);
1854 p2 = p->down; 1854 p2 = p->down;
1855 while ((type_field (p2->type) == TYPE_TAG) 1855 while ((type_field (p2->type) == TYPE_TAG)
1856 || (type_field (p2->type) == TYPE_SIZE)) 1856 || (type_field (p2->type) == TYPE_SIZE))
1857 p2 = p2->right; 1857 p2 = p2->right;
1858 if (p2->right == NULL) 1858 if (p2->right == NULL)
1859 _asn1_append_sequence_set (p); 1859 MHD__asn1_append_sequence_set (p);
1860 p = p2; 1860 p = p2;
1861 state = FOUND; 1861 state = FOUND;
1862 } 1862 }
@@ -1865,7 +1865,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1865 1865
1866 break; 1866 break;
1867 case TYPE_ANY: 1867 case TYPE_ANY:
1868 if (asn1_get_tag_der 1868 if (MHD__asn1_get_tag_der
1869 (der + counter, len - counter, &class, &len2, 1869 (der + counter, len - counter, &class, &len2,
1870 &tag) != ASN1_SUCCESS) 1870 &tag) != ASN1_SUCCESS)
1871 return ASN1_DER_ERROR; 1871 return ASN1_DER_ERROR;
@@ -1873,7 +1873,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1873 return ASN1_DER_ERROR; 1873 return ASN1_DER_ERROR;
1874 1874
1875 len4 = 1875 len4 =
1876 asn1_get_length_der (der + counter + len2, 1876 MHD__asn1_get_length_der (der + counter + len2,
1877 len - counter - len2, &len3); 1877 len - counter - len2, &len3);
1878 if (len4 < -1) 1878 if (len4 < -1)
1879 return ASN1_DER_ERROR; 1879 return ASN1_DER_ERROR;
@@ -1883,19 +1883,19 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1883 len2 += len4; 1883 len2 += len4;
1884 if (state == FOUND) 1884 if (state == FOUND)
1885 { 1885 {
1886 asn1_length_der (len2 + len3, NULL, &len4); 1886 MHD__asn1_length_der (len2 + len3, NULL, &len4);
1887 temp2 = 1887 temp2 =
1888 (unsigned char *) _asn1_alloca (len2 + len3 + len4); 1888 (unsigned char *) MHD__asn1_alloca (len2 + len3 + len4);
1889 if (temp2 == NULL) 1889 if (temp2 == NULL)
1890 { 1890 {
1891 asn1_delete_structure (structure); 1891 MHD__asn1_delete_structure (structure);
1892 return ASN1_MEM_ALLOC_ERROR; 1892 return ASN1_MEM_ALLOC_ERROR;
1893 } 1893 }
1894 1894
1895 asn1_octet_der (der + counter, len2 + len3, temp2, 1895 MHD__asn1_octet_der (der + counter, len2 + len3, temp2,
1896 &len4); 1896 &len4);
1897 _asn1_set_value (p, temp2, len4); 1897 MHD__asn1_set_value (p, temp2, len4);
1898 _asn1_afree (temp2); 1898 MHD__asn1_afree (temp2);
1899 1899
1900 if (p == nodeFound) 1900 if (p == nodeFound)
1901 state = EXIT; 1901 state = EXIT;
@@ -1912,26 +1912,26 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1912 1912
1913 len2 = len - counter; 1913 len2 = len - counter;
1914 ris = 1914 ris =
1915 _asn1_get_indefinite_length_string (der + counter, &len2); 1915 MHD__asn1_get_indefinite_length_string (der + counter, &len2);
1916 if (ris != ASN1_SUCCESS) 1916 if (ris != ASN1_SUCCESS)
1917 { 1917 {
1918 asn1_delete_structure (structure); 1918 MHD__asn1_delete_structure (structure);
1919 return ris; 1919 return ris;
1920 } 1920 }
1921 1921
1922 if (state == FOUND) 1922 if (state == FOUND)
1923 { 1923 {
1924 asn1_length_der (len2, NULL, &len4); 1924 MHD__asn1_length_der (len2, NULL, &len4);
1925 temp2 = (unsigned char *) _asn1_alloca (len2 + len4); 1925 temp2 = (unsigned char *) MHD__asn1_alloca (len2 + len4);
1926 if (temp2 == NULL) 1926 if (temp2 == NULL)
1927 { 1927 {
1928 asn1_delete_structure (structure); 1928 MHD__asn1_delete_structure (structure);
1929 return ASN1_MEM_ALLOC_ERROR; 1929 return ASN1_MEM_ALLOC_ERROR;
1930 } 1930 }
1931 1931
1932 asn1_octet_der (der + counter, len2, temp2, &len4); 1932 MHD__asn1_octet_der (der + counter, len2, temp2, &len4);
1933 _asn1_set_value (p, temp2, len4); 1933 MHD__asn1_set_value (p, temp2, len4);
1934 _asn1_afree (temp2); 1934 MHD__asn1_afree (temp2);
1935 1935
1936 if (p == nodeFound) 1936 if (p == nodeFound)
1937 state = EXIT; 1937 state = EXIT;
@@ -1949,7 +1949,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1949 } 1949 }
1950 else 1950 else
1951 { 1951 {
1952 asn1_delete_structure (structure); 1952 MHD__asn1_delete_structure (structure);
1953 return ASN1_DER_ERROR; 1953 return ASN1_DER_ERROR;
1954 } 1954 }
1955 } 1955 }
@@ -1983,7 +1983,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
1983 } 1983 }
1984 else 1984 else
1985 { 1985 {
1986 asn1_delete_structure (structure); 1986 MHD__asn1_delete_structure (structure);
1987 return ASN1_MEM_ERROR; 1987 return ASN1_MEM_ERROR;
1988 } 1988 }
1989 if (!(strcmp (currentName, elementName))) 1989 if (!(strcmp (currentName, elementName)))
@@ -2026,7 +2026,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
2026 strcat (currentName, p->name); 2026 strcat (currentName, p->name);
2027 else 2027 else
2028 { 2028 {
2029 asn1_delete_structure (structure); 2029 MHD__asn1_delete_structure (structure);
2030 return ASN1_MEM_ERROR; 2030 return ASN1_MEM_ERROR;
2031 } 2031 }
2032 2032
@@ -2049,7 +2049,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
2049 2049
2050 if (move == UP) 2050 if (move == UP)
2051 { 2051 {
2052 p = _asn1_find_up (p); 2052 p = MHD__asn1_find_up (p);
2053 2053
2054 if (state != FOUND) 2054 if (state != FOUND)
2055 { 2055 {
@@ -2077,11 +2077,11 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
2077 } 2077 }
2078 } 2078 }
2079 2079
2080 _asn1_delete_not_used (*structure); 2080 MHD__asn1_delete_not_used (*structure);
2081 2081
2082 if (counter > len) 2082 if (counter > len)
2083 { 2083 {
2084 asn1_delete_structure (structure); 2084 MHD__asn1_delete_structure (structure);
2085 return ASN1_DER_ERROR; 2085 return ASN1_DER_ERROR;
2086 } 2086 }
2087 2087
@@ -2091,7 +2091,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
2091 2091
2092 2092
2093/** 2093/**
2094 * asn1_der_decoding_startEnd - Find the start and end point of an element in a DER encoding string. 2094 * MHD__asn1_der_decoding_startEnd - Find the start and end point of an element in a DER encoding string.
2095 * @element: pointer to an ASN1 element 2095 * @element: pointer to an ASN1 element
2096 * @ider: vector that contains the DER encoding. 2096 * @ider: vector that contains the DER encoding.
2097 * @len: number of bytes of *@ider: @ider[0]..@ider[len-1] 2097 * @len: number of bytes of *@ider: @ider[0]..@ider[len-1]
@@ -2103,7 +2103,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
2103 * 2103 *
2104 * Find the start and end point of an element in a DER encoding 2104 * Find the start and end point of an element in a DER encoding
2105 * string. I mean that if you have a der encoding and you have 2105 * string. I mean that if you have a der encoding and you have
2106 * already used the function "asn1_der_decoding" to fill a structure, 2106 * already used the function "MHD__asn1_der_decoding" to fill a structure,
2107 * it may happen that you want to find the piece of string concerning 2107 * it may happen that you want to find the piece of string concerning
2108 * an element of the structure. 2108 * an element of the structure.
2109 * 2109 *
@@ -2120,8 +2120,8 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
2120 * the structure ELEMENT. 2120 * the structure ELEMENT.
2121 * 2121 *
2122 **/ 2122 **/
2123asn1_retCode 2123MHD__asn1_retCode
2124asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, 2124MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2125 const char *name_element, int *start, int *end) 2125 const char *name_element, int *start, int *end)
2126{ 2126{
2127 node_asn *node, *node_to_find, *p, *p2, *p3; 2127 node_asn *node, *node_to_find, *p, *p2, *p3;
@@ -2136,7 +2136,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2136 if (node == ASN1_TYPE_EMPTY) 2136 if (node == ASN1_TYPE_EMPTY)
2137 return ASN1_ELEMENT_NOT_FOUND; 2137 return ASN1_ELEMENT_NOT_FOUND;
2138 2138
2139 node_to_find = asn1_find_node (node, name_element); 2139 node_to_find = MHD__asn1_find_node (node, name_element);
2140 2140
2141 if (node_to_find == NULL) 2141 if (node_to_find == NULL)
2142 return ASN1_ELEMENT_NOT_FOUND; 2142 return ASN1_ELEMENT_NOT_FOUND;
@@ -2162,7 +2162,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2162 { 2162 {
2163 if (p->type & CONST_SET) 2163 if (p->type & CONST_SET)
2164 { 2164 {
2165 p2 = _asn1_find_up (p); 2165 p2 = MHD__asn1_find_up (p);
2166 len2 = strtol (p2->value, NULL, 10); 2166 len2 = strtol (p2->value, NULL, 10);
2167 if (len2 == -1) 2167 if (len2 == -1)
2168 { 2168 {
@@ -2189,13 +2189,13 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2189 { /* CONTROLLARE */ 2189 { /* CONTROLLARE */
2190 if (type_field (p2->type) != TYPE_CHOICE) 2190 if (type_field (p2->type) != TYPE_CHOICE)
2191 ris = 2191 ris =
2192 _asn1_extract_tag_der (p2, der + counter, 2192 MHD__asn1_extract_tag_der (p2, der + counter,
2193 len - counter, &len2); 2193 len - counter, &len2);
2194 else 2194 else
2195 { 2195 {
2196 p3 = p2->down; 2196 p3 = p2->down;
2197 ris = 2197 ris =
2198 _asn1_extract_tag_der (p3, der + counter, 2198 MHD__asn1_extract_tag_der (p3, der + counter,
2199 len - counter, &len2); 2199 len - counter, &len2);
2200 } 2200 }
2201 if (ris == ASN1_SUCCESS) 2201 if (ris == ASN1_SUCCESS)
@@ -2218,7 +2218,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2218 { 2218 {
2219 p = p->down; 2219 p = p->down;
2220 ris = 2220 ris =
2221 _asn1_extract_tag_der (p, der + counter, len - counter, 2221 MHD__asn1_extract_tag_der (p, der + counter, len - counter,
2222 &len2); 2222 &len2);
2223 if (p == node_to_find) 2223 if (p == node_to_find)
2224 *start = counter; 2224 *start = counter;
@@ -2226,7 +2226,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2226 2226
2227 if (ris == ASN1_SUCCESS) 2227 if (ris == ASN1_SUCCESS)
2228 ris = 2228 ris =
2229 _asn1_extract_tag_der (p, der + counter, len - counter, &len2); 2229 MHD__asn1_extract_tag_der (p, der + counter, len - counter, &len2);
2230 if (ris != ASN1_SUCCESS) 2230 if (ris != ASN1_SUCCESS)
2231 { 2231 {
2232 if (p->type & CONST_OPTION) 2232 if (p->type & CONST_OPTION)
@@ -2266,7 +2266,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2266 case TYPE_INTEGER: 2266 case TYPE_INTEGER:
2267 case TYPE_ENUMERATED: 2267 case TYPE_ENUMERATED:
2268 len2 = 2268 len2 =
2269 asn1_get_length_der (der + counter, len - counter, &len3); 2269 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
2270 if (len2 < 0) 2270 if (len2 < 0)
2271 return ASN1_DER_ERROR; 2271 return ASN1_DER_ERROR;
2272 counter += len3 + len2; 2272 counter += len3 + len2;
@@ -2274,7 +2274,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2274 break; 2274 break;
2275 case TYPE_OBJECT_ID: 2275 case TYPE_OBJECT_ID:
2276 len2 = 2276 len2 =
2277 asn1_get_length_der (der + counter, len - counter, &len3); 2277 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
2278 if (len2 < 0) 2278 if (len2 < 0)
2279 return ASN1_DER_ERROR; 2279 return ASN1_DER_ERROR;
2280 counter += len2 + len3; 2280 counter += len2 + len3;
@@ -2282,7 +2282,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2282 break; 2282 break;
2283 case TYPE_TIME: 2283 case TYPE_TIME:
2284 len2 = 2284 len2 =
2285 asn1_get_length_der (der + counter, len - counter, &len3); 2285 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
2286 if (len2 < 0) 2286 if (len2 < 0)
2287 return ASN1_DER_ERROR; 2287 return ASN1_DER_ERROR;
2288 counter += len2 + len3; 2288 counter += len2 + len3;
@@ -2290,7 +2290,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2290 break; 2290 break;
2291 case TYPE_OCTET_STRING: 2291 case TYPE_OCTET_STRING:
2292 len3 = len - counter; 2292 len3 = len - counter;
2293 ris = _asn1_get_octet_string (der + counter, NULL, &len3); 2293 ris = MHD__asn1_get_octet_string (der + counter, NULL, &len3);
2294 if (ris != ASN1_SUCCESS) 2294 if (ris != ASN1_SUCCESS)
2295 return ris; 2295 return ris;
2296 counter += len3; 2296 counter += len3;
@@ -2298,7 +2298,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2298 break; 2298 break;
2299 case TYPE_GENERALSTRING: 2299 case TYPE_GENERALSTRING:
2300 len2 = 2300 len2 =
2301 asn1_get_length_der (der + counter, len - counter, &len3); 2301 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
2302 if (len2 < 0) 2302 if (len2 < 0)
2303 return ASN1_DER_ERROR; 2303 return ASN1_DER_ERROR;
2304 counter += len3 + len2; 2304 counter += len3 + len2;
@@ -2306,7 +2306,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2306 break; 2306 break;
2307 case TYPE_BIT_STRING: 2307 case TYPE_BIT_STRING:
2308 len2 = 2308 len2 =
2309 asn1_get_length_der (der + counter, len - counter, &len3); 2309 MHD__asn1_get_length_der (der + counter, len - counter, &len3);
2310 if (len2 < 0) 2310 if (len2 < 0)
2311 return ASN1_DER_ERROR; 2311 return ASN1_DER_ERROR;
2312 counter += len3 + len2; 2312 counter += len3 + len2;
@@ -2317,7 +2317,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2317 if (move != UP) 2317 if (move != UP)
2318 { 2318 {
2319 len3 = 2319 len3 =
2320 asn1_get_length_der (der + counter, len - counter, &len2); 2320 MHD__asn1_get_length_der (der + counter, len - counter, &len2);
2321 if (len3 < -1) 2321 if (len3 < -1)
2322 return ASN1_DER_ERROR; 2322 return ASN1_DER_ERROR;
2323 counter += len2; 2323 counter += len2;
@@ -2338,7 +2338,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2338 if (move != UP) 2338 if (move != UP)
2339 { 2339 {
2340 len3 = 2340 len3 =
2341 asn1_get_length_der (der + counter, len - counter, &len2); 2341 MHD__asn1_get_length_der (der + counter, len - counter, &len2);
2342 if (len3 < -1) 2342 if (len3 < -1)
2343 return ASN1_DER_ERROR; 2343 return ASN1_DER_ERROR;
2344 counter += len2; 2344 counter += len2;
@@ -2361,7 +2361,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2361 move = RIGHT; 2361 move = RIGHT;
2362 break; 2362 break;
2363 case TYPE_ANY: 2363 case TYPE_ANY:
2364 if (asn1_get_tag_der 2364 if (MHD__asn1_get_tag_der
2365 (der + counter, len - counter, &class, &len2, 2365 (der + counter, len - counter, &class, &len2,
2366 &tag) != ASN1_SUCCESS) 2366 &tag) != ASN1_SUCCESS)
2367 return ASN1_DER_ERROR; 2367 return ASN1_DER_ERROR;
@@ -2369,7 +2369,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2369 return ASN1_DER_ERROR; 2369 return ASN1_DER_ERROR;
2370 2370
2371 len4 = 2371 len4 =
2372 asn1_get_length_der (der + counter + len2, 2372 MHD__asn1_get_length_der (der + counter + len2,
2373 len - counter - len2, &len3); 2373 len - counter - len2, &len3);
2374 if (len4 < -1) 2374 if (len4 < -1)
2375 return ASN1_DER_ERROR; 2375 return ASN1_DER_ERROR;
@@ -2388,7 +2388,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2388 2388
2389 len2 = len - counter; 2389 len2 = len - counter;
2390 ris = 2390 ris =
2391 _asn1_get_indefinite_length_string (der + counter, &len2); 2391 MHD__asn1_get_indefinite_length_string (der + counter, &len2);
2392 if (ris != ASN1_SUCCESS) 2392 if (ris != ASN1_SUCCESS)
2393 return ris; 2393 return ris;
2394 counter += len2; 2394 counter += len2;
@@ -2435,7 +2435,7 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2435 move = UP; 2435 move = UP;
2436 } 2436 }
2437 if (move == UP) 2437 if (move == UP)
2438 p = _asn1_find_up (p); 2438 p = MHD__asn1_find_up (p);
2439 } 2439 }
2440 2440
2441 return ASN1_ELEMENT_NOT_FOUND; 2441 return ASN1_ELEMENT_NOT_FOUND;
@@ -2443,12 +2443,12 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2443 2443
2444 2444
2445/** 2445/**
2446 * asn1_expand_any_defined_by - Expand "ANY DEFINED BY" fields in structure. 2446 * MHD__asn1_expand_any_defined_by - Expand "ANY DEFINED BY" fields in structure.
2447 * @definitions: ASN1 definitions 2447 * @definitions: ASN1 definitions
2448 * @element: pointer to an ASN1 structure 2448 * @element: pointer to an ASN1 structure
2449 * 2449 *
2450 * Expands every "ANY DEFINED BY" element of a structure created from 2450 * Expands every "ANY DEFINED BY" element of a structure created from
2451 * a DER decoding process (asn1_der_decoding function). The element ANY 2451 * a DER decoding process (MHD__asn1_der_decoding function). The element ANY
2452 * must be defined by an OBJECT IDENTIFIER. The type used to expand 2452 * must be defined by an OBJECT IDENTIFIER. The type used to expand
2453 * the element ANY is the first one following the definition of 2453 * the element ANY is the first one following the definition of
2454 * the actual value of the OBJECT IDENTIFIER. 2454 * the actual value of the OBJECT IDENTIFIER.
@@ -2464,12 +2464,12 @@ asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len,
2464 * other errors: Result of der decoding process. 2464 * other errors: Result of der decoding process.
2465 **/ 2465 **/
2466 2466
2467asn1_retCode 2467MHD__asn1_retCode
2468asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element) 2468MHD__asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2469{ 2469{
2470 char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1], 2470 char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1],
2471 value[MAX_NAME_SIZE]; 2471 value[MAX_NAME_SIZE];
2472 asn1_retCode retCode = ASN1_SUCCESS, result; 2472 MHD__asn1_retCode retCode = ASN1_SUCCESS, result;
2473 int len, len2, len3; 2473 int len, len2, len3;
2474 ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY; 2474 ASN1_TYPE p, p2, p3, aux = ASN1_TYPE_EMPTY;
2475 char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; 2475 char errorDescription[MAX_ERROR_DESCRIPTION_SIZE];
@@ -2500,7 +2500,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2500 break; 2500 break;
2501 } 2501 }
2502 2502
2503 p3 = _asn1_find_up (p); 2503 p3 = MHD__asn1_find_up (p);
2504 2504
2505 if (!p3) 2505 if (!p3)
2506 { 2506 {
@@ -2520,8 +2520,8 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2520 (p3->value == NULL)) 2520 (p3->value == NULL))
2521 { 2521 {
2522 2522
2523 p3 = _asn1_find_up (p); 2523 p3 = MHD__asn1_find_up (p);
2524 p3 = _asn1_find_up (p3); 2524 p3 = MHD__asn1_find_up (p3);
2525 2525
2526 if (!p3) 2526 if (!p3)
2527 { 2527 {
@@ -2558,7 +2558,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2558 2558
2559 len = MAX_NAME_SIZE; 2559 len = MAX_NAME_SIZE;
2560 result = 2560 result =
2561 asn1_read_value (definitions, name, value, &len); 2561 MHD__asn1_read_value (definitions, name, value, &len);
2562 2562
2563 if ((result == ASN1_SUCCESS) 2563 if ((result == ASN1_SUCCESS)
2564 && (!strcmp (p3->value, value))) 2564 && (!strcmp (p3->value, value)))
@@ -2574,27 +2574,27 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2574 strcat (name, p2->name); 2574 strcat (name, p2->name);
2575 2575
2576 result = 2576 result =
2577 asn1_create_element (definitions, name, &aux); 2577 MHD__asn1_create_element (definitions, name, &aux);
2578 if (result == ASN1_SUCCESS) 2578 if (result == ASN1_SUCCESS)
2579 { 2579 {
2580 _asn1_set_name (aux, p->name); 2580 MHD__asn1_set_name (aux, p->name);
2581 len2 = 2581 len2 =
2582 asn1_get_length_der (p->value, 2582 MHD__asn1_get_length_der (p->value,
2583 p->value_len, &len3); 2583 p->value_len, &len3);
2584 if (len2 < 0) 2584 if (len2 < 0)
2585 return ASN1_DER_ERROR; 2585 return ASN1_DER_ERROR;
2586 2586
2587 result = 2587 result =
2588 asn1_der_decoding (&aux, p->value + len3, 2588 MHD__asn1_der_decoding (&aux, p->value + len3,
2589 len2, 2589 len2,
2590 errorDescription); 2590 errorDescription);
2591 if (result == ASN1_SUCCESS) 2591 if (result == ASN1_SUCCESS)
2592 { 2592 {
2593 2593
2594 _asn1_set_right (aux, p->right); 2594 MHD__asn1_set_right (aux, p->right);
2595 _asn1_set_right (p, aux); 2595 MHD__asn1_set_right (p, aux);
2596 2596
2597 result = asn1_delete_structure (&p); 2597 result = MHD__asn1_delete_structure (&p);
2598 if (result == ASN1_SUCCESS) 2598 if (result == ASN1_SUCCESS)
2599 { 2599 {
2600 p = aux; 2600 p = aux;
@@ -2602,20 +2602,20 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2602 break; 2602 break;
2603 } 2603 }
2604 else 2604 else
2605 { /* error with asn1_delete_structure */ 2605 { /* error with MHD__asn1_delete_structure */
2606 asn1_delete_structure (&aux); 2606 MHD__asn1_delete_structure (&aux);
2607 retCode = result; 2607 retCode = result;
2608 break; 2608 break;
2609 } 2609 }
2610 } 2610 }
2611 else 2611 else
2612 { /* error with asn1_der_decoding */ 2612 { /* error with MHD__asn1_der_decoding */
2613 retCode = result; 2613 retCode = result;
2614 break; 2614 break;
2615 } 2615 }
2616 } 2616 }
2617 else 2617 else
2618 { /* error with asn1_create_element */ 2618 { /* error with MHD__asn1_create_element */
2619 retCode = result; 2619 retCode = result;
2620 break; 2620 break;
2621 } 2621 }
@@ -2658,7 +2658,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2658 { 2658 {
2659 while (1) 2659 while (1)
2660 { 2660 {
2661 p = _asn1_find_up (p); 2661 p = MHD__asn1_find_up (p);
2662 if (p == *element) 2662 if (p == *element)
2663 { 2663 {
2664 p = NULL; 2664 p = NULL;
@@ -2679,7 +2679,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2679 2679
2680 2680
2681/** 2681/**
2682 * asn1_expand_octet_string - Expand "OCTET STRING" fields in structure. 2682 * MHD__asn1_expand_octet_string - Expand "OCTET STRING" fields in structure.
2683 * @definitions: ASN1 definitions 2683 * @definitions: ASN1 definitions
2684 * @element: pointer to an ASN1 structure 2684 * @element: pointer to an ASN1 structure
2685 * @octetName: name of the OCTECT STRING field to expand. 2685 * @octetName: name of the OCTECT STRING field to expand.
@@ -2687,7 +2687,7 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2687 * the type for expansion. 2687 * the type for expansion.
2688 * 2688 *
2689 * Expands an "OCTET STRING" element of a structure created from a 2689 * Expands an "OCTET STRING" element of a structure created from a
2690 * DER decoding process (asn1_der_decoding function). The type used 2690 * DER decoding process (MHD__asn1_der_decoding function). The type used
2691 * for expansion is the first one following the definition of the 2691 * for expansion is the first one following the definition of the
2692 * actual value of the OBJECT IDENTIFIER indicated by OBJECTNAME. 2692 * actual value of the OBJECT IDENTIFIER indicated by OBJECTNAME.
2693 * 2693 *
@@ -2702,12 +2702,12 @@ asn1_expand_any_defined_by (ASN1_TYPE definitions, ASN1_TYPE * element)
2702 * 2702 *
2703 * other errors: result of der decoding process. 2703 * other errors: result of der decoding process.
2704 **/ 2704 **/
2705asn1_retCode 2705MHD__asn1_retCode
2706asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element, 2706MHD__asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
2707 const char *octetName, const char *objectName) 2707 const char *octetName, const char *objectName)
2708{ 2708{
2709 char name[2 * MAX_NAME_SIZE + 1], value[MAX_NAME_SIZE]; 2709 char name[2 * MAX_NAME_SIZE + 1], value[MAX_NAME_SIZE];
2710 asn1_retCode retCode = ASN1_SUCCESS, result; 2710 MHD__asn1_retCode retCode = ASN1_SUCCESS, result;
2711 int len, len2, len3; 2711 int len, len2, len3;
2712 ASN1_TYPE p2, aux = ASN1_TYPE_EMPTY; 2712 ASN1_TYPE p2, aux = ASN1_TYPE_EMPTY;
2713 ASN1_TYPE octetNode = ASN1_TYPE_EMPTY, objectNode = ASN1_TYPE_EMPTY; 2713 ASN1_TYPE octetNode = ASN1_TYPE_EMPTY, objectNode = ASN1_TYPE_EMPTY;
@@ -2716,7 +2716,7 @@ asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
2716 if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY)) 2716 if ((definitions == ASN1_TYPE_EMPTY) || (*element == ASN1_TYPE_EMPTY))
2717 return ASN1_ELEMENT_NOT_FOUND; 2717 return ASN1_ELEMENT_NOT_FOUND;
2718 2718
2719 octetNode = asn1_find_node (*element, octetName); 2719 octetNode = MHD__asn1_find_node (*element, octetName);
2720 if (octetNode == ASN1_TYPE_EMPTY) 2720 if (octetNode == ASN1_TYPE_EMPTY)
2721 return ASN1_ELEMENT_NOT_FOUND; 2721 return ASN1_ELEMENT_NOT_FOUND;
2722 if (type_field (octetNode->type) != TYPE_OCTET_STRING) 2722 if (type_field (octetNode->type) != TYPE_OCTET_STRING)
@@ -2724,7 +2724,7 @@ asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
2724 if (octetNode->value == NULL) 2724 if (octetNode->value == NULL)
2725 return ASN1_VALUE_NOT_FOUND; 2725 return ASN1_VALUE_NOT_FOUND;
2726 2726
2727 objectNode = asn1_find_node (*element, objectName); 2727 objectNode = MHD__asn1_find_node (*element, objectName);
2728 if (objectNode == ASN1_TYPE_EMPTY) 2728 if (objectNode == ASN1_TYPE_EMPTY)
2729 return ASN1_ELEMENT_NOT_FOUND; 2729 return ASN1_ELEMENT_NOT_FOUND;
2730 2730
@@ -2747,7 +2747,7 @@ asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
2747 strcat (name, p2->name); 2747 strcat (name, p2->name);
2748 2748
2749 len = sizeof (value); 2749 len = sizeof (value);
2750 result = asn1_read_value (definitions, name, value, &len); 2750 result = MHD__asn1_read_value (definitions, name, value, &len);
2751 2751
2752 if ((result == ASN1_SUCCESS) 2752 if ((result == ASN1_SUCCESS)
2753 && (!strcmp (objectNode->value, value))) 2753 && (!strcmp (objectNode->value, value)))
@@ -2764,46 +2764,46 @@ asn1_expand_octet_string (ASN1_TYPE definitions, ASN1_TYPE * element,
2764 strcat (name, "."); 2764 strcat (name, ".");
2765 strcat (name, p2->name); 2765 strcat (name, p2->name);
2766 2766
2767 result = asn1_create_element (definitions, name, &aux); 2767 result = MHD__asn1_create_element (definitions, name, &aux);
2768 if (result == ASN1_SUCCESS) 2768 if (result == ASN1_SUCCESS)
2769 { 2769 {
2770 _asn1_set_name (aux, octetNode->name); 2770 MHD__asn1_set_name (aux, octetNode->name);
2771 len2 = 2771 len2 =
2772 asn1_get_length_der (octetNode->value, 2772 MHD__asn1_get_length_der (octetNode->value,
2773 octetNode->value_len, &len3); 2773 octetNode->value_len, &len3);
2774 if (len2 < 0) 2774 if (len2 < 0)
2775 return ASN1_DER_ERROR; 2775 return ASN1_DER_ERROR;
2776 2776
2777 result = 2777 result =
2778 asn1_der_decoding (&aux, octetNode->value + len3, 2778 MHD__asn1_der_decoding (&aux, octetNode->value + len3,
2779 len2, errorDescription); 2779 len2, errorDescription);
2780 if (result == ASN1_SUCCESS) 2780 if (result == ASN1_SUCCESS)
2781 { 2781 {
2782 2782
2783 _asn1_set_right (aux, octetNode->right); 2783 MHD__asn1_set_right (aux, octetNode->right);
2784 _asn1_set_right (octetNode, aux); 2784 MHD__asn1_set_right (octetNode, aux);
2785 2785
2786 result = asn1_delete_structure (&octetNode); 2786 result = MHD__asn1_delete_structure (&octetNode);
2787 if (result == ASN1_SUCCESS) 2787 if (result == ASN1_SUCCESS)
2788 { 2788 {
2789 aux = ASN1_TYPE_EMPTY; 2789 aux = ASN1_TYPE_EMPTY;
2790 break; 2790 break;
2791 } 2791 }
2792 else 2792 else
2793 { /* error with asn1_delete_structure */ 2793 { /* error with MHD__asn1_delete_structure */
2794 asn1_delete_structure (&aux); 2794 MHD__asn1_delete_structure (&aux);
2795 retCode = result; 2795 retCode = result;
2796 break; 2796 break;
2797 } 2797 }
2798 } 2798 }
2799 else 2799 else
2800 { /* error with asn1_der_decoding */ 2800 { /* error with MHD__asn1_der_decoding */
2801 retCode = result; 2801 retCode = result;
2802 break; 2802 break;
2803 } 2803 }
2804 } 2804 }
2805 else 2805 else
2806 { /* error with asn1_create_element */ 2806 { /* error with MHD__asn1_create_element */
2807 retCode = result; 2807 retCode = result;
2808 break; 2808 break;
2809 } 2809 }
diff --git a/src/daemon/https/minitasn1/element.c b/src/daemon/https/minitasn1/element.c
index 5bfb1ed0..dfaa05b2 100644
--- a/src/daemon/https/minitasn1/element.c
+++ b/src/daemon/https/minitasn1/element.c
@@ -34,7 +34,7 @@
34#include "structure.h" 34#include "structure.h"
35 35
36void 36void
37_asn1_hierarchical_name (node_asn * node, char *name, int name_size) 37MHD__asn1_hierarchical_name (node_asn * node, char *name, int name_size)
38{ 38{
39 node_asn *p; 39 node_asn *p;
40 char tmp_name[64]; 40 char tmp_name[64];
@@ -47,21 +47,21 @@ _asn1_hierarchical_name (node_asn * node, char *name, int name_size)
47 { 47 {
48 if (p->name != NULL) 48 if (p->name != NULL)
49 { 49 {
50 _asn1_str_cpy (tmp_name, sizeof (tmp_name), name), 50 MHD__asn1_str_cpy (tmp_name, sizeof (tmp_name), name),
51 _asn1_str_cpy (name, name_size, p->name); 51 MHD__asn1_str_cpy (name, name_size, p->name);
52 _asn1_str_cat (name, name_size, "."); 52 MHD__asn1_str_cat (name, name_size, ".");
53 _asn1_str_cat (name, name_size, tmp_name); 53 MHD__asn1_str_cat (name, name_size, tmp_name);
54 } 54 }
55 p = _asn1_find_up (p); 55 p = MHD__asn1_find_up (p);
56 } 56 }
57 57
58 if (name[0] == 0) 58 if (name[0] == 0)
59 _asn1_str_cpy (name, name_size, "ROOT"); 59 MHD__asn1_str_cpy (name, name_size, "ROOT");
60} 60}
61 61
62 62
63/******************************************************************/ 63/******************************************************************/
64/* Function : _asn1_convert_integer */ 64/* Function : MHD__asn1_convert_integer */
65/* Description: converts an integer from a null terminated string */ 65/* Description: converts an integer from a null terminated string */
66/* to der decoding. The convertion from a null */ 66/* to der decoding. The convertion from a null */
67/* terminated string to an integer is made with */ 67/* terminated string to an integer is made with */
@@ -74,8 +74,8 @@ _asn1_hierarchical_name (node_asn * node, char *name, int name_size)
74/* len: number of significant byte of value_out. */ 74/* len: number of significant byte of value_out. */
75/* Return: ASN1_MEM_ERROR or ASN1_SUCCESS */ 75/* Return: ASN1_MEM_ERROR or ASN1_SUCCESS */
76/******************************************************************/ 76/******************************************************************/
77asn1_retCode 77MHD__asn1_retCode
78_asn1_convert_integer (const char *value, unsigned char *value_out, 78MHD__asn1_convert_integer (const char *value, unsigned char *value_out,
79 int value_out_size, int *len) 79 int value_out_size, int *len)
80{ 80{
81 char negative; 81 char negative;
@@ -117,10 +117,10 @@ _asn1_convert_integer (const char *value, unsigned char *value_out,
117 117
118 118
119#ifdef LIBTASN1_DEBUG_INTEGER 119#ifdef LIBTASN1_DEBUG_INTEGER
120 _libtasn1_log ("_asn1_convert_integer: valueIn=%s, lenOut=%d", value, *len); 120 MHD__libtasn1_log ("MHD__asn1_convert_integer: valueIn=%s, lenOut=%d", value, *len);
121 for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++) 121 for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
122 _libtasn1_log (", vOut[%d]=%d", k, value_out[k]); 122 MHD__libtasn1_log (", vOut[%d]=%d", k, value_out[k]);
123 _libtasn1_log ("\n"); 123 MHD__libtasn1_log ("\n");
124#endif 124#endif
125 125
126 126
@@ -129,7 +129,7 @@ _asn1_convert_integer (const char *value, unsigned char *value_out,
129 129
130 130
131int 131int
132_asn1_append_sequence_set (node_asn * node) 132MHD__asn1_append_sequence_set (node_asn * node)
133{ 133{
134 node_asn *p, *p2; 134 node_asn *p, *p2;
135 char temp[10]; 135 char temp[10];
@@ -142,21 +142,21 @@ _asn1_append_sequence_set (node_asn * node)
142 while ((type_field (p->type) == TYPE_TAG) 142 while ((type_field (p->type) == TYPE_TAG)
143 || (type_field (p->type) == TYPE_SIZE)) 143 || (type_field (p->type) == TYPE_SIZE))
144 p = p->right; 144 p = p->right;
145 p2 = _asn1_copy_structure3 (p); 145 p2 = MHD__asn1_copy_structure3 (p);
146 while (p->right) 146 while (p->right)
147 p = p->right; 147 p = p->right;
148 _asn1_set_right (p, p2); 148 MHD__asn1_set_right (p, p2);
149 149
150 if (p->name == NULL) 150 if (p->name == NULL)
151 _asn1_str_cpy (temp, sizeof (temp), "?1"); 151 MHD__asn1_str_cpy (temp, sizeof (temp), "?1");
152 else 152 else
153 { 153 {
154 n = strtol (p->name + 1, NULL, 0); 154 n = strtol (p->name + 1, NULL, 0);
155 n++; 155 n++;
156 temp[0] = '?'; 156 temp[0] = '?';
157 _asn1_ltostr (n, temp + 1); 157 MHD__asn1_ltostr (n, temp + 1);
158 } 158 }
159 _asn1_set_name (p2, temp); 159 MHD__asn1_set_name (p2, temp);
160 /* p2->type |= CONST_OPTION; */ 160 /* p2->type |= CONST_OPTION; */
161 161
162 return ASN1_SUCCESS; 162 return ASN1_SUCCESS;
@@ -164,7 +164,7 @@ _asn1_append_sequence_set (node_asn * node)
164 164
165 165
166/** 166/**
167 * asn1_write_value - Set the value of one element inside a structure. 167 * MHD__asn1_write_value - Set the value of one element inside a structure.
168 * @node_root: pointer to a structure 168 * @node_root: pointer to a structure
169 * @name: the name of the element inside the structure that you want to set. 169 * @name: the name of the element inside the structure that you want to set.
170 * @ivalue: vector used to specify the value to set. If len is >0, 170 * @ivalue: vector used to specify the value to set. If len is >0,
@@ -178,7 +178,7 @@ _asn1_append_sequence_set (node_asn * node)
178 * If an element is OPTIONAL and you want to delete it, you must use 178 * If an element is OPTIONAL and you want to delete it, you must use
179 * the value=NULL and len=0. Using "pkix.asn": 179 * the value=NULL and len=0. Using "pkix.asn":
180 * 180 *
181 * result=asn1_write_value(cert, "tbsCertificate.issuerUniqueID", 181 * result=MHD__asn1_write_value(cert, "tbsCertificate.issuerUniqueID",
182 * NULL, 0); 182 * NULL, 0);
183 * 183 *
184 * Description for each type: 184 * Description for each type:
@@ -244,7 +244,7 @@ _asn1_append_sequence_set (node_asn * node)
244 * the alternatives with a null terminated string. LEN != 0. Using 244 * the alternatives with a null terminated string. LEN != 0. Using
245 * "pkix.asn"\: 245 * "pkix.asn"\:
246 * 246 *
247 * result=asn1_write_value(cert, 247 * result=MHD__asn1_write_value(cert,
248 * "certificate1.tbsCertificate.subject", "rdnSequence", 248 * "certificate1.tbsCertificate.subject", "rdnSequence",
249 * 1); 249 * 1);
250 * 250 *
@@ -257,12 +257,12 @@ _asn1_append_sequence_set (node_asn * node)
257 * 257 *
258 * Using "pkix.asn"\: 258 * Using "pkix.asn"\:
259 * 259 *
260 * result=asn1_write_value(cert, 260 * result=MHD__asn1_write_value(cert,
261 * "certificate1.tbsCertificate.subject.rdnSequence", "NEW", 1); 261 * "certificate1.tbsCertificate.subject.rdnSequence", "NEW", 1);
262 * 262 *
263 * SET OF: the same as SEQUENCE OF. Using "pkix.asn": 263 * SET OF: the same as SEQUENCE OF. Using "pkix.asn":
264 * 264 *
265 * result=asn1_write_value(cert, 265 * result=MHD__asn1_write_value(cert,
266 * "tbsCertificate.subject.rdnSequence.?LAST", "NEW", 1); 266 * "tbsCertificate.subject.rdnSequence.?LAST", "NEW", 1);
267 * 267 *
268 * Returns: 268 * Returns:
@@ -274,8 +274,8 @@ _asn1_append_sequence_set (node_asn * node)
274 * ASN1_VALUE_NOT_VALID: VALUE has a wrong format. 274 * ASN1_VALUE_NOT_VALID: VALUE has a wrong format.
275 * 275 *
276 **/ 276 **/
277asn1_retCode 277MHD__asn1_retCode
278asn1_write_value (ASN1_TYPE node_root, const char *name, 278MHD__asn1_write_value (ASN1_TYPE node_root, const char *name,
279 const void *ivalue, int len) 279 const void *ivalue, int len)
280{ 280{
281 node_asn *node, *p, *p2; 281 node_asn *node, *p, *p2;
@@ -283,13 +283,13 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
283 int len2, k, k2, negative; 283 int len2, k, k2, negative;
284 const unsigned char *value = ivalue; 284 const unsigned char *value = ivalue;
285 285
286 node = asn1_find_node (node_root, name); 286 node = MHD__asn1_find_node (node_root, name);
287 if (node == NULL) 287 if (node == NULL)
288 return ASN1_ELEMENT_NOT_FOUND; 288 return ASN1_ELEMENT_NOT_FOUND;
289 289
290 if ((node->type & CONST_OPTION) && (value == NULL) && (len == 0)) 290 if ((node->type & CONST_OPTION) && (value == NULL) && (len == 0))
291 { 291 {
292 asn1_delete_structure (&node); 292 MHD__asn1_delete_structure (&node);
293 return ASN1_SUCCESS; 293 return ASN1_SUCCESS;
294 } 294 }
295 295
@@ -302,7 +302,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
302 p = p->right; 302 p = p->right;
303 303
304 while (p->right) 304 while (p->right)
305 asn1_delete_structure (&p->right); 305 MHD__asn1_delete_structure (&p->right);
306 306
307 return ASN1_SUCCESS; 307 return ASN1_SUCCESS;
308 } 308 }
@@ -318,12 +318,12 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
318 while (type_field (p->type) != TYPE_DEFAULT) 318 while (type_field (p->type) != TYPE_DEFAULT)
319 p = p->right; 319 p = p->right;
320 if (p->type & CONST_TRUE) 320 if (p->type & CONST_TRUE)
321 _asn1_set_value (node, NULL, 0); 321 MHD__asn1_set_value (node, NULL, 0);
322 else 322 else
323 _asn1_set_value (node, "T", 1); 323 MHD__asn1_set_value (node, "T", 1);
324 } 324 }
325 else 325 else
326 _asn1_set_value (node, "T", 1); 326 MHD__asn1_set_value (node, "T", 1);
327 } 327 }
328 else if (!strcmp (value, "FALSE")) 328 else if (!strcmp (value, "FALSE"))
329 { 329 {
@@ -333,12 +333,12 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
333 while (type_field (p->type) != TYPE_DEFAULT) 333 while (type_field (p->type) != TYPE_DEFAULT)
334 p = p->right; 334 p = p->right;
335 if (p->type & CONST_FALSE) 335 if (p->type & CONST_FALSE)
336 _asn1_set_value (node, NULL, 0); 336 MHD__asn1_set_value (node, NULL, 0);
337 else 337 else
338 _asn1_set_value (node, "F", 1); 338 MHD__asn1_set_value (node, "F", 1);
339 } 339 }
340 else 340 else
341 _asn1_set_value (node, "F", 1); 341 MHD__asn1_set_value (node, "F", 1);
342 } 342 }
343 else 343 else
344 return ASN1_VALUE_NOT_VALID; 344 return ASN1_VALUE_NOT_VALID;
@@ -350,11 +350,11 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
350 if ((isdigit (value[0])) || (value[0] == '-')) 350 if ((isdigit (value[0])) || (value[0] == '-'))
351 { 351 {
352 value_temp = 352 value_temp =
353 (unsigned char *) _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); 353 (unsigned char *) MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
354 if (value_temp == NULL) 354 if (value_temp == NULL)
355 return ASN1_MEM_ALLOC_ERROR; 355 return ASN1_MEM_ALLOC_ERROR;
356 356
357 _asn1_convert_integer (value, value_temp, 357 MHD__asn1_convert_integer (value, value_temp,
358 SIZEOF_UNSIGNED_LONG_INT, &len); 358 SIZEOF_UNSIGNED_LONG_INT, &len);
359 } 359 }
360 else 360 else
@@ -370,11 +370,11 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
370 { 370 {
371 value_temp = 371 value_temp =
372 (unsigned char *) 372 (unsigned char *)
373 _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); 373 MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
374 if (value_temp == NULL) 374 if (value_temp == NULL)
375 return ASN1_MEM_ALLOC_ERROR; 375 return ASN1_MEM_ALLOC_ERROR;
376 376
377 _asn1_convert_integer (p->value, 377 MHD__asn1_convert_integer (p->value,
378 value_temp, 378 value_temp,
379 SIZEOF_UNSIGNED_LONG_INT, 379 SIZEOF_UNSIGNED_LONG_INT,
380 &len); 380 &len);
@@ -389,7 +389,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
389 } 389 }
390 else 390 else
391 { /* len != 0 */ 391 { /* len != 0 */
392 value_temp = (unsigned char *) _asn1_alloca (len); 392 value_temp = (unsigned char *) MHD__asn1_alloca (len);
393 if (value_temp == NULL) 393 if (value_temp == NULL)
394 return ASN1_MEM_ALLOC_ERROR; 394 return ASN1_MEM_ALLOC_ERROR;
395 memcpy (value_temp, value, len); 395 memcpy (value_temp, value, len);
@@ -403,7 +403,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
403 403
404 if (negative && (type_field (node->type) == TYPE_ENUMERATED)) 404 if (negative && (type_field (node->type) == TYPE_ENUMERATED))
405 { 405 {
406 _asn1_afree (value_temp); 406 MHD__asn1_afree (value_temp);
407 return ASN1_VALUE_NOT_VALID; 407 return ASN1_VALUE_NOT_VALID;
408 } 408 }
409 409
@@ -417,18 +417,18 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
417 (!negative && (value_temp[k] & 0x80))) 417 (!negative && (value_temp[k] & 0x80)))
418 k--; 418 k--;
419 419
420 asn1_length_der (len - k, NULL, &len2); 420 MHD__asn1_length_der (len - k, NULL, &len2);
421 temp = (unsigned char *) _asn1_alloca (len - k + len2); 421 temp = (unsigned char *) MHD__asn1_alloca (len - k + len2);
422 if (temp == NULL) 422 if (temp == NULL)
423 { 423 {
424 _asn1_afree (value_temp); 424 MHD__asn1_afree (value_temp);
425 return ASN1_MEM_ALLOC_ERROR; 425 return ASN1_MEM_ALLOC_ERROR;
426 } 426 }
427 427
428 asn1_octet_der (value_temp + k, len - k, temp, &len2); 428 MHD__asn1_octet_der (value_temp + k, len - k, temp, &len2);
429 _asn1_set_value (node, temp, len2); 429 MHD__asn1_set_value (node, temp, len2);
430 430
431 _asn1_afree (temp); 431 MHD__asn1_afree (temp);
432 432
433 433
434 if (node->type & CONST_DEFAULT) 434 if (node->type & CONST_DEFAULT)
@@ -439,21 +439,21 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
439 if ((isdigit (p->value[0])) || (p->value[0] == '-')) 439 if ((isdigit (p->value[0])) || (p->value[0] == '-'))
440 { 440 {
441 default_temp = 441 default_temp =
442 (unsigned char *) _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); 442 (unsigned char *) MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
443 if (default_temp == NULL) 443 if (default_temp == NULL)
444 { 444 {
445 _asn1_afree (value_temp); 445 MHD__asn1_afree (value_temp);
446 return ASN1_MEM_ALLOC_ERROR; 446 return ASN1_MEM_ALLOC_ERROR;
447 } 447 }
448 448
449 _asn1_convert_integer (p->value, default_temp, 449 MHD__asn1_convert_integer (p->value, default_temp,
450 SIZEOF_UNSIGNED_LONG_INT, &len2); 450 SIZEOF_UNSIGNED_LONG_INT, &len2);
451 } 451 }
452 else 452 else
453 { /* is an identifier like v1 */ 453 { /* is an identifier like v1 */
454 if (!(node->type & CONST_LIST)) 454 if (!(node->type & CONST_LIST))
455 { 455 {
456 _asn1_afree (value_temp); 456 MHD__asn1_afree (value_temp);
457 return ASN1_VALUE_NOT_VALID; 457 return ASN1_VALUE_NOT_VALID;
458 } 458 }
459 p2 = node->down; 459 p2 = node->down;
@@ -465,14 +465,14 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
465 { 465 {
466 default_temp = 466 default_temp =
467 (unsigned char *) 467 (unsigned char *)
468 _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); 468 MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
469 if (default_temp == NULL) 469 if (default_temp == NULL)
470 { 470 {
471 _asn1_afree (value_temp); 471 MHD__asn1_afree (value_temp);
472 return ASN1_MEM_ALLOC_ERROR; 472 return ASN1_MEM_ALLOC_ERROR;
473 } 473 }
474 474
475 _asn1_convert_integer (p2->value, 475 MHD__asn1_convert_integer (p2->value,
476 default_temp, 476 default_temp,
477 SIZEOF_UNSIGNED_LONG_INT, 477 SIZEOF_UNSIGNED_LONG_INT,
478 &len2); 478 &len2);
@@ -483,7 +483,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
483 } 483 }
484 if (p2 == NULL) 484 if (p2 == NULL)
485 { 485 {
486 _asn1_afree (value_temp); 486 MHD__asn1_afree (value_temp);
487 return ASN1_VALUE_NOT_VALID; 487 return ASN1_VALUE_NOT_VALID;
488 } 488 }
489 } 489 }
@@ -497,11 +497,11 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
497 break; 497 break;
498 } 498 }
499 if (k2 == len2) 499 if (k2 == len2)
500 _asn1_set_value (node, NULL, 0); 500 MHD__asn1_set_value (node, NULL, 0);
501 } 501 }
502 _asn1_afree (default_temp); 502 MHD__asn1_afree (default_temp);
503 } 503 }
504 _asn1_afree (value_temp); 504 MHD__asn1_afree (value_temp);
505 break; 505 break;
506 case TYPE_OBJECT_ID: 506 case TYPE_OBJECT_ID:
507 for (k = 0; k < strlen (value); k++) 507 for (k = 0; k < strlen (value); k++)
@@ -514,11 +514,11 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
514 p = p->right; 514 p = p->right;
515 if (!strcmp (value, p->value)) 515 if (!strcmp (value, p->value))
516 { 516 {
517 _asn1_set_value (node, NULL, 0); 517 MHD__asn1_set_value (node, NULL, 0);
518 break; 518 break;
519 } 519 }
520 } 520 }
521 _asn1_set_value (node, value, strlen (value) + 1); 521 MHD__asn1_set_value (node, value, strlen (value) + 1);
522 break; 522 break;
523 case TYPE_TIME: 523 case TYPE_TIME:
524 if (node->type & CONST_UTC) 524 if (node->type & CONST_UTC)
@@ -558,49 +558,49 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
558 default: 558 default:
559 return ASN1_VALUE_NOT_FOUND; 559 return ASN1_VALUE_NOT_FOUND;
560 } 560 }
561 _asn1_set_value (node, value, strlen (value) + 1); 561 MHD__asn1_set_value (node, value, strlen (value) + 1);
562 } 562 }
563 else 563 else
564 { /* GENERALIZED TIME */ 564 { /* GENERALIZED TIME */
565 if (value) 565 if (value)
566 _asn1_set_value (node, value, strlen (value) + 1); 566 MHD__asn1_set_value (node, value, strlen (value) + 1);
567 } 567 }
568 break; 568 break;
569 case TYPE_OCTET_STRING: 569 case TYPE_OCTET_STRING:
570 if (len == 0) 570 if (len == 0)
571 len = strlen (value); 571 len = strlen (value);
572 asn1_length_der (len, NULL, &len2); 572 MHD__asn1_length_der (len, NULL, &len2);
573 temp = (unsigned char *) _asn1_alloca (len + len2); 573 temp = (unsigned char *) MHD__asn1_alloca (len + len2);
574 if (temp == NULL) 574 if (temp == NULL)
575 return ASN1_MEM_ALLOC_ERROR; 575 return ASN1_MEM_ALLOC_ERROR;
576 576
577 asn1_octet_der (value, len, temp, &len2); 577 MHD__asn1_octet_der (value, len, temp, &len2);
578 _asn1_set_value (node, temp, len2); 578 MHD__asn1_set_value (node, temp, len2);
579 _asn1_afree (temp); 579 MHD__asn1_afree (temp);
580 break; 580 break;
581 case TYPE_GENERALSTRING: 581 case TYPE_GENERALSTRING:
582 if (len == 0) 582 if (len == 0)
583 len = strlen (value); 583 len = strlen (value);
584 asn1_length_der (len, NULL, &len2); 584 MHD__asn1_length_der (len, NULL, &len2);
585 temp = (unsigned char *) _asn1_alloca (len + len2); 585 temp = (unsigned char *) MHD__asn1_alloca (len + len2);
586 if (temp == NULL) 586 if (temp == NULL)
587 return ASN1_MEM_ALLOC_ERROR; 587 return ASN1_MEM_ALLOC_ERROR;
588 588
589 asn1_octet_der (value, len, temp, &len2); 589 MHD__asn1_octet_der (value, len, temp, &len2);
590 _asn1_set_value (node, temp, len2); 590 MHD__asn1_set_value (node, temp, len2);
591 _asn1_afree (temp); 591 MHD__asn1_afree (temp);
592 break; 592 break;
593 case TYPE_BIT_STRING: 593 case TYPE_BIT_STRING:
594 if (len == 0) 594 if (len == 0)
595 len = strlen (value); 595 len = strlen (value);
596 asn1_length_der ((len >> 3) + 2, NULL, &len2); 596 MHD__asn1_length_der ((len >> 3) + 2, NULL, &len2);
597 temp = (unsigned char *) _asn1_alloca ((len >> 3) + 2 + len2); 597 temp = (unsigned char *) MHD__asn1_alloca ((len >> 3) + 2 + len2);
598 if (temp == NULL) 598 if (temp == NULL)
599 return ASN1_MEM_ALLOC_ERROR; 599 return ASN1_MEM_ALLOC_ERROR;
600 600
601 asn1_bit_der (value, len, temp, &len2); 601 MHD__asn1_bit_der (value, len, temp, &len2);
602 _asn1_set_value (node, temp, len2); 602 MHD__asn1_set_value (node, temp, len2);
603 _asn1_afree (temp); 603 MHD__asn1_afree (temp);
604 break; 604 break;
605 case TYPE_CHOICE: 605 case TYPE_CHOICE:
606 p = node->down; 606 p = node->down;
@@ -613,7 +613,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
613 { 613 {
614 if (p2 != p) 614 if (p2 != p)
615 { 615 {
616 asn1_delete_structure (&p2); 616 MHD__asn1_delete_structure (&p2);
617 p2 = node->down; 617 p2 = node->down;
618 } 618 }
619 else 619 else
@@ -627,20 +627,20 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
627 return ASN1_ELEMENT_NOT_FOUND; 627 return ASN1_ELEMENT_NOT_FOUND;
628 break; 628 break;
629 case TYPE_ANY: 629 case TYPE_ANY:
630 asn1_length_der (len, NULL, &len2); 630 MHD__asn1_length_der (len, NULL, &len2);
631 temp = (unsigned char *) _asn1_alloca (len + len2); 631 temp = (unsigned char *) MHD__asn1_alloca (len + len2);
632 if (temp == NULL) 632 if (temp == NULL)
633 return ASN1_MEM_ALLOC_ERROR; 633 return ASN1_MEM_ALLOC_ERROR;
634 634
635 asn1_octet_der (value, len, temp, &len2); 635 MHD__asn1_octet_der (value, len, temp, &len2);
636 _asn1_set_value (node, temp, len2); 636 MHD__asn1_set_value (node, temp, len2);
637 _asn1_afree (temp); 637 MHD__asn1_afree (temp);
638 break; 638 break;
639 case TYPE_SEQUENCE_OF: 639 case TYPE_SEQUENCE_OF:
640 case TYPE_SET_OF: 640 case TYPE_SET_OF:
641 if (strcmp (value, "NEW")) 641 if (strcmp (value, "NEW"))
642 return ASN1_VALUE_NOT_VALID; 642 return ASN1_VALUE_NOT_VALID;
643 _asn1_append_sequence_set (node); 643 MHD__asn1_append_sequence_set (node);
644 break; 644 break;
645 default: 645 default:
646 return ASN1_ELEMENT_NOT_FOUND; 646 return ASN1_ELEMENT_NOT_FOUND;
@@ -678,7 +678,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
678 } 678 }
679 679
680/** 680/**
681 * asn1_read_value - Returns the value of one element inside a structure 681 * MHD__asn1_read_value - Returns the value of one element inside a structure
682 * @root: pointer to a structure. 682 * @root: pointer to a structure.
683 * @name: the name of the element inside a structure that you want to read. 683 * @name: the name of the element inside a structure that you want to read.
684 * @ivalue: vector that will contain the element's content, must be a 684 * @ivalue: vector that will contain the element's content, must be a
@@ -743,15 +743,15 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
743 * In this case LEN will contain the number of bytes needed. 743 * In this case LEN will contain the number of bytes needed.
744 * 744 *
745 **/ 745 **/
746asn1_retCode 746MHD__asn1_retCode
747asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) 747MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
748{ 748{
749 node_asn *node, *p, *p2; 749 node_asn *node, *p, *p2;
750 int len2, len3; 750 int len2, len3;
751 int value_size = *len; 751 int value_size = *len;
752 unsigned char *value = ivalue; 752 unsigned char *value = ivalue;
753 753
754 node = asn1_find_node (root, name); 754 node = MHD__asn1_find_node (root, name);
755 if (node == NULL) 755 if (node == NULL)
756 return ASN1_ELEMENT_NOT_FOUND; 756 return ASN1_ELEMENT_NOT_FOUND;
757 757
@@ -800,7 +800,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
800 if ((isdigit (p->value[0])) || (p->value[0] == '-') 800 if ((isdigit (p->value[0])) || (p->value[0] == '-')
801 || (p->value[0] == '+')) 801 || (p->value[0] == '+'))
802 { 802 {
803 if (_asn1_convert_integer 803 if (MHD__asn1_convert_integer
804 (p->value, value, value_size, len) != ASN1_SUCCESS) 804 (p->value, value, value_size, len) != ASN1_SUCCESS)
805 return ASN1_MEM_ERROR; 805 return ASN1_MEM_ERROR;
806 } 806 }
@@ -813,7 +813,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
813 { 813 {
814 if ((p2->name) && (!strcmp (p2->name, p->value))) 814 if ((p2->name) && (!strcmp (p2->name, p->value)))
815 { 815 {
816 if (_asn1_convert_integer 816 if (MHD__asn1_convert_integer
817 (p2->value, value, value_size, 817 (p2->value, value, value_size,
818 len) != ASN1_SUCCESS) 818 len) != ASN1_SUCCESS)
819 return ASN1_MEM_ERROR; 819 return ASN1_MEM_ERROR;
@@ -827,7 +827,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
827 else 827 else
828 { 828 {
829 len2 = -1; 829 len2 = -1;
830 if (asn1_get_octet_der 830 if (MHD__asn1_get_octet_der
831 (node->value, node->value_len, &len2, value, value_size, 831 (node->value, node->value_len, &len2, value, value_size,
832 len) != ASN1_SUCCESS) 832 len) != ASN1_SUCCESS)
833 return ASN1_MEM_ERROR; 833 return ASN1_MEM_ERROR;
@@ -869,21 +869,21 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
869 break; 869 break;
870 case TYPE_OCTET_STRING: 870 case TYPE_OCTET_STRING:
871 len2 = -1; 871 len2 = -1;
872 if (asn1_get_octet_der 872 if (MHD__asn1_get_octet_der
873 (node->value, node->value_len, &len2, value, value_size, 873 (node->value, node->value_len, &len2, value, value_size,
874 len) != ASN1_SUCCESS) 874 len) != ASN1_SUCCESS)
875 return ASN1_MEM_ERROR; 875 return ASN1_MEM_ERROR;
876 break; 876 break;
877 case TYPE_GENERALSTRING: 877 case TYPE_GENERALSTRING:
878 len2 = -1; 878 len2 = -1;
879 if (asn1_get_octet_der 879 if (MHD__asn1_get_octet_der
880 (node->value, node->value_len, &len2, value, value_size, 880 (node->value, node->value_len, &len2, value, value_size,
881 len) != ASN1_SUCCESS) 881 len) != ASN1_SUCCESS)
882 return ASN1_MEM_ERROR; 882 return ASN1_MEM_ERROR;
883 break; 883 break;
884 case TYPE_BIT_STRING: 884 case TYPE_BIT_STRING:
885 len2 = -1; 885 len2 = -1;
886 if (asn1_get_bit_der 886 if (MHD__asn1_get_bit_der
887 (node->value, node->value_len, &len2, value, value_size, 887 (node->value, node->value_len, &len2, value, value_size,
888 len) != ASN1_SUCCESS) 888 len) != ASN1_SUCCESS)
889 return ASN1_MEM_ERROR; 889 return ASN1_MEM_ERROR;
@@ -893,7 +893,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
893 break; 893 break;
894 case TYPE_ANY: 894 case TYPE_ANY:
895 len3 = -1; 895 len3 = -1;
896 len2 = asn1_get_length_der (node->value, node->value_len, &len3); 896 len2 = MHD__asn1_get_length_der (node->value, node->value_len, &len3);
897 if (len2 < 0) 897 if (len2 < 0)
898 return ASN1_DER_ERROR; 898 return ASN1_DER_ERROR;
899 PUT_VALUE (value, value_size, node->value + len3, len2); 899 PUT_VALUE (value, value_size, node->value + len3, len2);
@@ -907,7 +907,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
907 907
908 908
909/** 909/**
910 * asn1_read_tag - Returns the TAG of one element inside a structure 910 * MHD__asn1_read_tag - Returns the TAG of one element inside a structure
911 * @root: pointer to a structure 911 * @root: pointer to a structure
912 * @name: the name of the element inside a structure. 912 * @name: the name of the element inside a structure.
913 * @tagValue: variable that will contain the TAG value. 913 * @tagValue: variable that will contain the TAG value.
@@ -925,13 +925,13 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
925 * ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element. 925 * ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element.
926 * 926 *
927 **/ 927 **/
928asn1_retCode 928MHD__asn1_retCode
929asn1_read_tag (node_asn * root, const char *name, int *tagValue, 929MHD__asn1_read_tag (node_asn * root, const char *name, int *tagValue,
930 int *classValue) 930 int *classValue)
931{ 931{
932 node_asn *node, *p, *pTag; 932 node_asn *node, *p, *pTag;
933 933
934 node = asn1_find_node (root, name); 934 node = MHD__asn1_find_node (root, name);
935 if (node == NULL) 935 if (node == NULL)
936 return ASN1_ELEMENT_NOT_FOUND; 936 return ASN1_ELEMENT_NOT_FOUND;
937 937
diff --git a/src/daemon/https/minitasn1/element.h b/src/daemon/https/minitasn1/element.h
index b6341e8a..eea9839a 100644
--- a/src/daemon/https/minitasn1/element.h
+++ b/src/daemon/https/minitasn1/element.h
@@ -3,12 +3,12 @@
3#define _ELEMENT_H 3#define _ELEMENT_H
4 4
5 5
6asn1_retCode _asn1_append_sequence_set (node_asn * node); 6MHD__asn1_retCode MHD__asn1_append_sequence_set (node_asn * node);
7 7
8asn1_retCode _asn1_convert_integer (const char *value, 8MHD__asn1_retCode MHD__asn1_convert_integer (const char *value,
9 unsigned char *value_out, 9 unsigned char *value_out,
10 int value_out_size, int *len); 10 int value_out_size, int *len);
11 11
12void _asn1_hierarchical_name (node_asn * node, char *name, int name_size); 12void MHD__asn1_hierarchical_name (node_asn * node, char *name, int name_size);
13 13
14#endif 14#endif
diff --git a/src/daemon/https/minitasn1/errors.c b/src/daemon/https/minitasn1/errors.c
index 544b3f01..72b61938 100644
--- a/src/daemon/https/minitasn1/errors.c
+++ b/src/daemon/https/minitasn1/errors.c
@@ -30,14 +30,14 @@
30#define LIBTASN1_ERROR_ENTRY(name) \ 30#define LIBTASN1_ERROR_ENTRY(name) \
31 { #name, name } 31 { #name, name }
32 32
33struct libtasn1_error_entry 33struct MHD__libtasn1_error_entry
34{ 34{
35 const char *name; 35 const char *name;
36 int number; 36 int number;
37}; 37};
38typedef struct libtasn1_error_entry libtasn1_error_entry; 38typedef struct MHD__libtasn1_error_entry MHD__libtasn1_error_entry;
39 39
40static const libtasn1_error_entry error_algorithms[] = { 40static const MHD__libtasn1_error_entry error_algorithms[] = {
41 LIBTASN1_ERROR_ENTRY (ASN1_SUCCESS), 41 LIBTASN1_ERROR_ENTRY (ASN1_SUCCESS),
42 LIBTASN1_ERROR_ENTRY (ASN1_FILE_NOT_FOUND), 42 LIBTASN1_ERROR_ENTRY (ASN1_FILE_NOT_FOUND),
43 LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_FOUND), 43 LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_FOUND),
@@ -60,7 +60,7 @@ static const libtasn1_error_entry error_algorithms[] = {
60}; 60};
61 61
62#define LIBTASN1_ERROR_LOOP(b) \ 62#define LIBTASN1_ERROR_LOOP(b) \
63 const libtasn1_error_entry *p; \ 63 const MHD__libtasn1_error_entry *p; \
64 for(p = error_algorithms; p->name != NULL; p++) { b ; } 64 for(p = error_algorithms; p->name != NULL; p++) { b ; }
65 65
66#define LIBTASN1_ERROR_ALG_LOOP(a) \ 66#define LIBTASN1_ERROR_ALG_LOOP(a) \
@@ -69,14 +69,14 @@ static const libtasn1_error_entry error_algorithms[] = {
69 69
70 70
71/** 71/**
72 * libtasn1_perror - prints a string to stderr with a description of an error 72 * MHD__libtasn1_perror - prints a string to stderr with a description of an error
73 * @error: is an error returned by a libtasn1 function. 73 * @error: is an error returned by a libtasn1 function.
74 * 74 *
75 * This function is like perror(). The only difference is that it 75 * This function is like perror(). The only difference is that it
76 * accepts an error returned by a libtasn1 function. 76 * accepts an error returned by a libtasn1 function.
77 **/ 77 **/
78void 78void
79libtasn1_perror (asn1_retCode error) 79MHD__libtasn1_perror (MHD__asn1_retCode error)
80{ 80{
81 const char *ret = NULL; 81 const char *ret = NULL;
82 82
@@ -89,7 +89,7 @@ libtasn1_perror (asn1_retCode error)
89 89
90 90
91/** 91/**
92 * libtasn1_strerror - Returns a string with a description of an error 92 * MHD__libtasn1_strerror - Returns a string with a description of an error
93 * @error: is an error returned by a libtasn1 function. 93 * @error: is an error returned by a libtasn1 function.
94 * 94 *
95 * This function is similar to strerror(). The only difference is 95 * This function is similar to strerror(). The only difference is
@@ -99,7 +99,7 @@ libtasn1_perror (asn1_retCode error)
99 * code. 99 * code.
100 **/ 100 **/
101const char * 101const char *
102libtasn1_strerror (asn1_retCode error) 102MHD__libtasn1_strerror (MHD__asn1_retCode error)
103{ 103{
104 const char *ret = NULL; 104 const char *ret = NULL;
105 105
@@ -113,7 +113,7 @@ libtasn1_strerror (asn1_retCode error)
113 */ 113 */
114#ifdef LIBTASN1_DEBUG 114#ifdef LIBTASN1_DEBUG
115void 115void
116_libtasn1_log (const char *fmt, ...) 116MHD__libtasn1_log (const char *fmt, ...)
117{ 117{
118 va_list args; 118 va_list args;
119 char str[MAX_LOG_SIZE]; 119 char str[MAX_LOG_SIZE];
@@ -128,7 +128,7 @@ _libtasn1_log (const char *fmt, ...)
128} 128}
129#else /* not DEBUG */ 129#else /* not DEBUG */
130void 130void
131_libtasn1_log (const char *fmt, ...) 131MHD__libtasn1_log (const char *fmt, ...)
132{ 132{
133 return; 133 return;
134} 134}
diff --git a/src/daemon/https/minitasn1/errors.h b/src/daemon/https/minitasn1/errors.h
index 05faa321..cb5536ba 100644
--- a/src/daemon/https/minitasn1/errors.h
+++ b/src/daemon/https/minitasn1/errors.h
@@ -25,6 +25,6 @@
25 25
26#include "int.h" 26#include "int.h"
27 27
28void _libtasn1_log (const char *fmt, ...); 28void MHD__libtasn1_log (const char *fmt, ...);
29 29
30#endif /* ERRORS_H */ 30#endif /* ERRORS_H */
diff --git a/src/daemon/https/minitasn1/gstr.c b/src/daemon/https/minitasn1/gstr.c
index 0430ee1a..7068db51 100644
--- a/src/daemon/https/minitasn1/gstr.c
+++ b/src/daemon/https/minitasn1/gstr.c
@@ -29,7 +29,7 @@
29 * They should be used only with null terminated strings. 29 * They should be used only with null terminated strings.
30 */ 30 */
31void 31void
32_asn1_str_cat (char *dest, size_t dest_tot_size, const char *src) 32MHD__asn1_str_cat (char *dest, size_t dest_tot_size, const char *src)
33{ 33{
34 size_t str_size = strlen (src); 34 size_t str_size = strlen (src);
35 size_t dest_size = strlen (dest); 35 size_t dest_size = strlen (dest);
@@ -49,7 +49,7 @@ _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src)
49} 49}
50 50
51void 51void
52_asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src) 52MHD__asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src)
53{ 53{
54 size_t str_size = strlen (src); 54 size_t str_size = strlen (src);
55 55
diff --git a/src/daemon/https/minitasn1/gstr.h b/src/daemon/https/minitasn1/gstr.h
index 360c6d88..e0cda357 100644
--- a/src/daemon/https/minitasn1/gstr.h
+++ b/src/daemon/https/minitasn1/gstr.h
@@ -1,5 +1,5 @@
1void _asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src); 1void MHD__asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src);
2void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src); 2void MHD__asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
3 3
4#define Estrcpy(x,y) _asn1_str_cpy(x,MAX_ERROR_DESCRIPTION_SIZE,y) 4#define Estrcpy(x,y) MHD__asn1_str_cpy(x,MAX_ERROR_DESCRIPTION_SIZE,y)
5#define Estrcat(x,y) _asn1_str_cat(x,MAX_ERROR_DESCRIPTION_SIZE,y) 5#define Estrcat(x,y) MHD__asn1_str_cat(x,MAX_ERROR_DESCRIPTION_SIZE,y)
diff --git a/src/daemon/https/minitasn1/libtasn1.h b/src/daemon/https/minitasn1/libtasn1.h
index 58862e63..b9cfe610 100644
--- a/src/daemon/https/minitasn1/libtasn1.h
+++ b/src/daemon/https/minitasn1/libtasn1.h
@@ -43,7 +43,7 @@ extern "C"
43 /* (null character included) */ 43 /* (null character included) */
44 44
45 45
46 typedef int asn1_retCode; /* type returned by libtasn1 functions */ 46 typedef int MHD__asn1_retCode; /* type returned by libtasn1 functions */
47 47
48 /*****************************************/ 48 /*****************************************/
49 /* Errors returned by libtasn1 functions */ 49 /* Errors returned by libtasn1 functions */
@@ -68,7 +68,7 @@ extern "C"
68#define ASN1_ELEMENT_NOT_EMPTY 17 68#define ASN1_ELEMENT_NOT_EMPTY 17
69 69
70/*************************************/ 70/*************************************/
71/* Constants used in asn1_visit_tree */ 71/* Constants used in MHD__asn1_visit_tree */
72/*************************************/ 72/*************************************/
73#define ASN1_PRINT_NAME 1 73#define ASN1_PRINT_NAME 1
74#define ASN1_PRINT_NAME_TYPE 2 74#define ASN1_PRINT_NAME_TYPE 2
@@ -76,7 +76,7 @@ extern "C"
76#define ASN1_PRINT_ALL 4 76#define ASN1_PRINT_ALL 4
77 77
78/*****************************************/ 78/*****************************************/
79/* Constants returned by asn1_read_tag */ 79/* Constants returned by MHD__asn1_read_tag */
80/*****************************************/ 80/*****************************************/
81#define ASN1_CLASS_UNIVERSAL 0x00 /* old: 1 */ 81#define ASN1_CLASS_UNIVERSAL 0x00 /* old: 1 */
82#define ASN1_CLASS_APPLICATION 0x40 /* old: 2 */ 82#define ASN1_CLASS_APPLICATION 0x40 /* old: 2 */
@@ -85,7 +85,7 @@ extern "C"
85#define ASN1_CLASS_STRUCTURED 0x20 85#define ASN1_CLASS_STRUCTURED 0x20
86 86
87/*****************************************/ 87/*****************************************/
88/* Constants returned by asn1_read_tag */ 88/* Constants returned by MHD__asn1_read_tag */
89/*****************************************/ 89/*****************************************/
90#define ASN1_TAG_BOOLEAN 0x01 90#define ASN1_TAG_BOOLEAN 0x01
91#define ASN1_TAG_INTEGER 0x02 91#define ASN1_TAG_INTEGER 0x02
@@ -137,106 +137,106 @@ extern "C"
137 /* Functions definitions */ 137 /* Functions definitions */
138 /***********************************/ 138 /***********************************/
139 139
140 asn1_retCode asn1_parser2tree (const char *file_name, 140 MHD__asn1_retCode MHD__asn1_parser2tree (const char *file_name,
141 ASN1_TYPE * definitions, 141 ASN1_TYPE * definitions,
142 char *errorDescription); 142 char *errorDescription);
143 143
144 asn1_retCode asn1_parser2array (const char *inputFileName, 144 MHD__asn1_retCode MHD__asn1_parser2array (const char *inputFileName,
145 const char *outputFileName, 145 const char *outputFileName,
146 const char *vectorName, 146 const char *vectorName,
147 char *errorDescription); 147 char *errorDescription);
148 148
149 asn1_retCode asn1_array2tree (const ASN1_ARRAY_TYPE * array, 149 MHD__asn1_retCode MHD__asn1_array2tree (const ASN1_ARRAY_TYPE * array,
150 ASN1_TYPE * definitions, 150 ASN1_TYPE * definitions,
151 char *errorDescription); 151 char *errorDescription);
152 152
153 void asn1_print_structure (FILE * out, ASN1_TYPE structure, 153 void MHD__asn1_print_structure (FILE * out, ASN1_TYPE structure,
154 const char *name, int mode); 154 const char *name, int mode);
155 155
156 asn1_retCode asn1_create_element (ASN1_TYPE definitions, 156 MHD__asn1_retCode MHD__asn1_create_element (ASN1_TYPE definitions,
157 const char *source_name, 157 const char *source_name,
158 ASN1_TYPE * element); 158 ASN1_TYPE * element);
159 159
160 asn1_retCode asn1_delete_structure (ASN1_TYPE * structure); 160 MHD__asn1_retCode MHD__asn1_delete_structure (ASN1_TYPE * structure);
161 161
162 asn1_retCode asn1_delete_element (ASN1_TYPE structure, 162 MHD__asn1_retCode MHD__asn1_delete_element (ASN1_TYPE structure,
163 const char *element_name); 163 const char *element_name);
164 164
165 asn1_retCode asn1_write_value (ASN1_TYPE node_root, const char *name, 165 MHD__asn1_retCode MHD__asn1_write_value (ASN1_TYPE node_root, const char *name,
166 const void *ivalue, int len); 166 const void *ivalue, int len);
167 167
168 asn1_retCode asn1_read_value (ASN1_TYPE root, const char *name, 168 MHD__asn1_retCode MHD__asn1_read_value (ASN1_TYPE root, const char *name,
169 void *ivalue, int *len); 169 void *ivalue, int *len);
170 170
171 asn1_retCode asn1_number_of_elements (ASN1_TYPE element, const char *name, 171 MHD__asn1_retCode MHD__asn1_number_of_elements (ASN1_TYPE element, const char *name,
172 int *num); 172 int *num);
173 173
174 asn1_retCode asn1_der_coding (ASN1_TYPE element, const char *name, 174 MHD__asn1_retCode MHD__asn1_der_coding (ASN1_TYPE element, const char *name,
175 void *ider, int *len, char *ErrorDescription); 175 void *ider, int *len, char *ErrorDescription);
176 176
177 asn1_retCode asn1_der_decoding (ASN1_TYPE * element, const void *ider, 177 MHD__asn1_retCode MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider,
178 int len, char *errorDescription); 178 int len, char *errorDescription);
179 179
180 asn1_retCode asn1_der_decoding_element (ASN1_TYPE * structure, 180 MHD__asn1_retCode MHD__asn1_der_decoding_element (ASN1_TYPE * structure,
181 const char *elementName, 181 const char *elementName,
182 const void *ider, int len, 182 const void *ider, int len,
183 char *errorDescription); 183 char *errorDescription);
184 184
185 asn1_retCode asn1_der_decoding_startEnd (ASN1_TYPE element, 185 MHD__asn1_retCode MHD__asn1_der_decoding_startEnd (ASN1_TYPE element,
186 const void *ider, int len, 186 const void *ider, int len,
187 const char *name_element, 187 const char *name_element,
188 int *start, int *end); 188 int *start, int *end);
189 189
190 asn1_retCode asn1_expand_any_defined_by (ASN1_TYPE definitions, 190 MHD__asn1_retCode MHD__asn1_expand_any_defined_by (ASN1_TYPE definitions,
191 ASN1_TYPE * element); 191 ASN1_TYPE * element);
192 192
193 asn1_retCode asn1_expand_octet_string (ASN1_TYPE definitions, 193 MHD__asn1_retCode MHD__asn1_expand_octet_string (ASN1_TYPE definitions,
194 ASN1_TYPE * element, 194 ASN1_TYPE * element,
195 const char *octetName, 195 const char *octetName,
196 const char *objectName); 196 const char *objectName);
197 197
198 asn1_retCode asn1_read_tag (node_asn * root, const char *name, 198 MHD__asn1_retCode MHD__asn1_read_tag (node_asn * root, const char *name,
199 int *tagValue, int *classValue); 199 int *tagValue, int *classValue);
200 200
201 const char *asn1_find_structure_from_oid (ASN1_TYPE definitions, 201 const char *MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions,
202 const char *oidValue); 202 const char *oidValue);
203 203
204 const char *asn1_check_version (const char *req_version); 204 const char *MHD__asn1_check_version (const char *req_version);
205 205
206 const char *libtasn1_strerror (asn1_retCode error); 206 const char *MHD__libtasn1_strerror (MHD__asn1_retCode error);
207 207
208 void libtasn1_perror (asn1_retCode error); 208 void MHD__libtasn1_perror (MHD__asn1_retCode error);
209 209
210 /* DER utility functions. */ 210 /* DER utility functions. */
211 211
212 int asn1_get_tag_der (const unsigned char *der, int der_len, 212 int MHD__asn1_get_tag_der (const unsigned char *der, int der_len,
213 unsigned char *cls, int *len, unsigned long *tag); 213 unsigned char *cls, int *len, unsigned long *tag);
214 214
215 void asn1_octet_der (const unsigned char *str, int str_len, 215 void MHD__asn1_octet_der (const unsigned char *str, int str_len,
216 unsigned char *der, int *der_len); 216 unsigned char *der, int *der_len);
217 217
218 asn1_retCode asn1_get_octet_der (const unsigned char *der, int der_len, 218 MHD__asn1_retCode MHD__asn1_get_octet_der (const unsigned char *der, int der_len,
219 int *ret_len, unsigned char *str, 219 int *ret_len, unsigned char *str,
220 int str_size, int *str_len); 220 int str_size, int *str_len);
221 221
222 void asn1_bit_der (const unsigned char *str, int bit_len, 222 void MHD__asn1_bit_der (const unsigned char *str, int bit_len,
223 unsigned char *der, int *der_len); 223 unsigned char *der, int *der_len);
224 224
225 asn1_retCode asn1_get_bit_der (const unsigned char *der, int der_len, 225 MHD__asn1_retCode MHD__asn1_get_bit_der (const unsigned char *der, int der_len,
226 int *ret_len, unsigned char *str, 226 int *ret_len, unsigned char *str,
227 int str_size, int *bit_len); 227 int str_size, int *bit_len);
228 228
229 signed long asn1_get_length_der (const unsigned char *der, int der_len, 229 signed long MHD__asn1_get_length_der (const unsigned char *der, int der_len,
230 int *len); 230 int *len);
231 231
232 void asn1_length_der (unsigned long int len, unsigned char *ans, 232 void MHD__asn1_length_der (unsigned long int len, unsigned char *ans,
233 int *ans_len); 233 int *ans_len);
234 234
235 /* Other utility functions. */ 235 /* Other utility functions. */
236 236
237 ASN1_TYPE asn1_find_node (ASN1_TYPE pointer, const char *name); 237 ASN1_TYPE MHD__asn1_find_node (ASN1_TYPE pointer, const char *name);
238 238
239 asn1_retCode asn1_copy_node (ASN1_TYPE dst, const char *dst_name, 239 MHD__asn1_retCode MHD__asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
240 ASN1_TYPE src, const char *src_name); 240 ASN1_TYPE src, const char *src_name);
241 241
242#ifdef __cplusplus 242#ifdef __cplusplus
diff --git a/src/daemon/https/minitasn1/mem.h b/src/daemon/https/minitasn1/mem.h
index 3a5c7aa9..76139df0 100644
--- a/src/daemon/https/minitasn1/mem.h
+++ b/src/daemon/https/minitasn1/mem.h
@@ -1,7 +1,7 @@
1#ifndef MEM_H 1#ifndef MEM_H
2# define MEM_H 2# define MEM_H
3 3
4/* Use _asn1_afree() when calling alloca, or 4/* Use MHD__asn1_afree() when calling alloca, or
5 * memory leaks may occur in systems which do not 5 * memory leaks may occur in systems which do not
6 * support alloca. 6 * support alloca.
7 */ 7 */
@@ -9,17 +9,17 @@
9# ifdef HAVE_ALLOCA_H 9# ifdef HAVE_ALLOCA_H
10# include <alloca.h> 10# include <alloca.h>
11# endif 11# endif
12# define _asn1_alloca alloca 12# define MHD__asn1_alloca alloca
13# define _asn1_afree(x) 13# define MHD__asn1_afree(x)
14#else 14#else
15# define _asn1_alloca _asn1_malloc 15# define MHD__asn1_alloca MHD__asn1_malloc
16# define _asn1_afree _asn1_free 16# define MHD__asn1_afree MHD__asn1_free
17#endif /* HAVE_ALLOCA */ 17#endif /* HAVE_ALLOCA */
18 18
19#define _asn1_malloc malloc 19#define MHD__asn1_malloc malloc
20#define _asn1_free free 20#define MHD__asn1_free free
21#define _asn1_calloc calloc 21#define MHD__asn1_calloc calloc
22#define _asn1_realloc realloc 22#define MHD__asn1_realloc realloc
23#define _asn1_strdup strdup 23#define MHD__asn1_strdup strdup
24 24
25#endif /* MEM_H */ 25#endif /* MEM_H */
diff --git a/src/daemon/https/minitasn1/parser_aux.c b/src/daemon/https/minitasn1/parser_aux.c
index dcaee0a9..2ec54cbf 100644
--- a/src/daemon/https/minitasn1/parser_aux.c
+++ b/src/daemon/https/minitasn1/parser_aux.c
@@ -27,7 +27,7 @@
27#include "structure.h" 27#include "structure.h"
28#include "element.h" 28#include "element.h"
29 29
30char _asn1_identifierMissing[MAX_NAME_SIZE + 1]; /* identifier name not found */ 30char MHD__asn1_identifierMissing[MAX_NAME_SIZE + 1]; /* identifier name not found */
31 31
32/***********************************************/ 32/***********************************************/
33/* Type: list_type */ 33/* Type: list_type */
@@ -45,7 +45,7 @@ typedef struct list_struct
45list_type *firstElement = NULL; 45list_type *firstElement = NULL;
46 46
47/******************************************************/ 47/******************************************************/
48/* Function : _asn1_add_node */ 48/* Function : MHD__asn1_add_node */
49/* Description: creates a new NODE_ASN element and */ 49/* Description: creates a new NODE_ASN element and */
50/* puts it in the list pointed by firstElement. */ 50/* puts it in the list pointed by firstElement. */
51/* Parameters: */ 51/* Parameters: */
@@ -54,19 +54,19 @@ list_type *firstElement = NULL;
54/* Return: pointer to the new element. */ 54/* Return: pointer to the new element. */
55/******************************************************/ 55/******************************************************/
56node_asn * 56node_asn *
57_asn1_add_node (unsigned int type) 57MHD__asn1_add_node (unsigned int type)
58{ 58{
59 list_type *listElement; 59 list_type *listElement;
60 node_asn *punt; 60 node_asn *punt;
61 61
62 punt = (node_asn *) _asn1_calloc (1, sizeof (node_asn)); 62 punt = (node_asn *) MHD__asn1_calloc (1, sizeof (node_asn));
63 if (punt == NULL) 63 if (punt == NULL)
64 return NULL; 64 return NULL;
65 65
66 listElement = (list_type *) _asn1_malloc (sizeof (list_type)); 66 listElement = (list_type *) MHD__asn1_malloc (sizeof (list_type));
67 if (listElement == NULL) 67 if (listElement == NULL)
68 { 68 {
69 _asn1_free (punt); 69 MHD__asn1_free (punt);
70 return NULL; 70 return NULL;
71 } 71 }
72 72
@@ -80,7 +80,7 @@ _asn1_add_node (unsigned int type)
80} 80}
81 81
82/** 82/**
83 * asn1_find_node: 83 * MHD__asn1_find_node:
84 * @pointer: NODE_ASN element pointer. 84 * @pointer: NODE_ASN element pointer.
85 * @name: null terminated string with the element's name to find. 85 * @name: null terminated string with the element's name to find.
86 * 86 *
@@ -92,7 +92,7 @@ _asn1_add_node (unsigned int type)
92 * Return value: the searching result. NULL if not found. 92 * Return value: the searching result. NULL if not found.
93 **/ 93 **/
94ASN1_TYPE 94ASN1_TYPE
95asn1_find_node (ASN1_TYPE pointer, const char *name) 95MHD__asn1_find_node (ASN1_TYPE pointer, const char *name)
96{ 96{
97 node_asn *p; 97 node_asn *p;
98 char *n_end, n[MAX_NAME_SIZE + 1]; 98 char *n_end, n[MAX_NAME_SIZE + 1];
@@ -119,7 +119,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
119 } 119 }
120 else 120 else
121 { 121 {
122 _asn1_str_cpy (n, sizeof (n), n_start); 122 MHD__asn1_str_cpy (n, sizeof (n), n_start);
123 n_start = NULL; 123 n_start = NULL;
124 } 124 }
125 125
@@ -152,7 +152,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
152 } 152 }
153 else 153 else
154 { 154 {
155 _asn1_str_cpy (n, sizeof (n), n_start); 155 MHD__asn1_str_cpy (n, sizeof (n), n_start);
156 n_start = NULL; 156 n_start = NULL;
157 } 157 }
158 158
@@ -189,7 +189,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
189 189
190 190
191/******************************************************************/ 191/******************************************************************/
192/* Function : _asn1_set_value */ 192/* Function : MHD__asn1_set_value */
193/* Description: sets the field VALUE in a NODE_ASN element. The */ 193/* Description: sets the field VALUE in a NODE_ASN element. The */
194/* previous value (if exist) will be lost */ 194/* previous value (if exist) will be lost */
195/* Parameters: */ 195/* Parameters: */
@@ -199,7 +199,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
199/* Return: pointer to the NODE_ASN element. */ 199/* Return: pointer to the NODE_ASN element. */
200/******************************************************************/ 200/******************************************************************/
201node_asn * 201node_asn *
202_asn1_set_value (node_asn * node, const void *_value, unsigned int len) 202MHD__asn1_set_value (node_asn * node, const void *_value, unsigned int len)
203{ 203{
204 const unsigned char *value = _value; 204 const unsigned char *value = _value;
205 205
@@ -207,13 +207,13 @@ _asn1_set_value (node_asn * node, const void *_value, unsigned int len)
207 return node; 207 return node;
208 if (node->value) 208 if (node->value)
209 { 209 {
210 _asn1_free (node->value); 210 MHD__asn1_free (node->value);
211 node->value = NULL; 211 node->value = NULL;
212 node->value_len = 0; 212 node->value_len = 0;
213 } 213 }
214 if (!len) 214 if (!len)
215 return node; 215 return node;
216 node->value = (unsigned char *) _asn1_malloc (len); 216 node->value = (unsigned char *) MHD__asn1_malloc (len);
217 if (node->value == NULL) 217 if (node->value == NULL)
218 return NULL; 218 return NULL;
219 node->value_len = len; 219 node->value_len = len;
@@ -223,7 +223,7 @@ _asn1_set_value (node_asn * node, const void *_value, unsigned int len)
223} 223}
224 224
225/******************************************************************/ 225/******************************************************************/
226/* Function : _asn1_set_name */ 226/* Function : MHD__asn1_set_name */
227/* Description: sets the field NAME in a NODE_ASN element. The */ 227/* Description: sets the field NAME in a NODE_ASN element. The */
228/* previous value (if exist) will be lost */ 228/* previous value (if exist) will be lost */
229/* Parameters: */ 229/* Parameters: */
@@ -233,14 +233,14 @@ _asn1_set_value (node_asn * node, const void *_value, unsigned int len)
233/* Return: pointer to the NODE_ASN element. */ 233/* Return: pointer to the NODE_ASN element. */
234/******************************************************************/ 234/******************************************************************/
235node_asn * 235node_asn *
236_asn1_set_name (node_asn * node, const char *name) 236MHD__asn1_set_name (node_asn * node, const char *name)
237{ 237{
238 if (node == NULL) 238 if (node == NULL)
239 return node; 239 return node;
240 240
241 if (node->name) 241 if (node->name)
242 { 242 {
243 _asn1_free (node->name); 243 MHD__asn1_free (node->name);
244 node->name = NULL; 244 node->name = NULL;
245 } 245 }
246 246
@@ -249,7 +249,7 @@ _asn1_set_name (node_asn * node, const char *name)
249 249
250 if (strlen (name)) 250 if (strlen (name))
251 { 251 {
252 node->name = (char *) _asn1_strdup (name); 252 node->name = (char *) MHD__asn1_strdup (name);
253 if (node->name == NULL) 253 if (node->name == NULL)
254 return NULL; 254 return NULL;
255 } 255 }
@@ -259,7 +259,7 @@ _asn1_set_name (node_asn * node, const char *name)
259} 259}
260 260
261/******************************************************************/ 261/******************************************************************/
262/* Function : _asn1_set_right */ 262/* Function : MHD__asn1_set_right */
263/* Description: sets the field RIGHT in a NODE_ASN element. */ 263/* Description: sets the field RIGHT in a NODE_ASN element. */
264/* Parameters: */ 264/* Parameters: */
265/* node: element pointer. */ 265/* node: element pointer. */
@@ -268,7 +268,7 @@ _asn1_set_name (node_asn * node, const char *name)
268/* Return: pointer to *NODE. */ 268/* Return: pointer to *NODE. */
269/******************************************************************/ 269/******************************************************************/
270node_asn * 270node_asn *
271_asn1_set_right (node_asn * node, node_asn * right) 271MHD__asn1_set_right (node_asn * node, node_asn * right)
272{ 272{
273 if (node == NULL) 273 if (node == NULL)
274 return node; 274 return node;
@@ -279,7 +279,7 @@ _asn1_set_right (node_asn * node, node_asn * right)
279} 279}
280 280
281/******************************************************************/ 281/******************************************************************/
282/* Function : _asn1_get_right */ 282/* Function : MHD__asn1_get_right */
283/* Description: returns the element pointed by the RIGHT field of */ 283/* Description: returns the element pointed by the RIGHT field of */
284/* a NODE_ASN element. */ 284/* a NODE_ASN element. */
285/* Parameters: */ 285/* Parameters: */
@@ -287,7 +287,7 @@ _asn1_set_right (node_asn * node, node_asn * right)
287/* Return: field RIGHT of NODE. */ 287/* Return: field RIGHT of NODE. */
288/******************************************************************/ 288/******************************************************************/
289node_asn * 289node_asn *
290_asn1_get_right (node_asn * node) 290MHD__asn1_get_right (node_asn * node)
291{ 291{
292 if (node == NULL) 292 if (node == NULL)
293 return NULL; 293 return NULL;
@@ -295,14 +295,14 @@ _asn1_get_right (node_asn * node)
295} 295}
296 296
297/******************************************************************/ 297/******************************************************************/
298/* Function : _asn1_get_last_right */ 298/* Function : MHD__asn1_get_last_right */
299/* Description: return the last element along the right chain. */ 299/* Description: return the last element along the right chain. */
300/* Parameters: */ 300/* Parameters: */
301/* node: starting element pointer. */ 301/* node: starting element pointer. */
302/* Return: pointer to the last element along the right chain. */ 302/* Return: pointer to the last element along the right chain. */
303/******************************************************************/ 303/******************************************************************/
304node_asn * 304node_asn *
305_asn1_get_last_right (node_asn * node) 305MHD__asn1_get_last_right (node_asn * node)
306{ 306{
307 node_asn *p; 307 node_asn *p;
308 308
@@ -315,7 +315,7 @@ _asn1_get_last_right (node_asn * node)
315} 315}
316 316
317/******************************************************************/ 317/******************************************************************/
318/* Function : _asn1_set_down */ 318/* Function : MHD__asn1_set_down */
319/* Description: sets the field DOWN in a NODE_ASN element. */ 319/* Description: sets the field DOWN in a NODE_ASN element. */
320/* Parameters: */ 320/* Parameters: */
321/* node: element pointer. */ 321/* node: element pointer. */
@@ -324,7 +324,7 @@ _asn1_get_last_right (node_asn * node)
324/* Return: pointer to *NODE. */ 324/* Return: pointer to *NODE. */
325/******************************************************************/ 325/******************************************************************/
326node_asn * 326node_asn *
327_asn1_set_down (node_asn * node, node_asn * down) 327MHD__asn1_set_down (node_asn * node, node_asn * down)
328{ 328{
329 if (node == NULL) 329 if (node == NULL)
330 return node; 330 return node;
@@ -335,7 +335,7 @@ _asn1_set_down (node_asn * node, node_asn * down)
335} 335}
336 336
337/******************************************************************/ 337/******************************************************************/
338/* Function : _asn1_get_down */ 338/* Function : MHD__asn1_get_down */
339/* Description: returns the element pointed by the DOWN field of */ 339/* Description: returns the element pointed by the DOWN field of */
340/* a NODE_ASN element. */ 340/* a NODE_ASN element. */
341/* Parameters: */ 341/* Parameters: */
@@ -343,7 +343,7 @@ _asn1_set_down (node_asn * node, node_asn * down)
343/* Return: field DOWN of NODE. */ 343/* Return: field DOWN of NODE. */
344/******************************************************************/ 344/******************************************************************/
345node_asn * 345node_asn *
346_asn1_get_down (node_asn * node) 346MHD__asn1_get_down (node_asn * node)
347{ 347{
348 if (node == NULL) 348 if (node == NULL)
349 return NULL; 349 return NULL;
@@ -351,14 +351,14 @@ _asn1_get_down (node_asn * node)
351} 351}
352 352
353/******************************************************************/ 353/******************************************************************/
354/* Function : _asn1_get_name */ 354/* Function : MHD__asn1_get_name */
355/* Description: returns the name of a NODE_ASN element. */ 355/* Description: returns the name of a NODE_ASN element. */
356/* Parameters: */ 356/* Parameters: */
357/* node: NODE_ASN element pointer. */ 357/* node: NODE_ASN element pointer. */
358/* Return: a null terminated string. */ 358/* Return: a null terminated string. */
359/******************************************************************/ 359/******************************************************************/
360char * 360char *
361_asn1_get_name (node_asn * node) 361MHD__asn1_get_name (node_asn * node)
362{ 362{
363 if (node == NULL) 363 if (node == NULL)
364 return NULL; 364 return NULL;
@@ -366,7 +366,7 @@ _asn1_get_name (node_asn * node)
366} 366}
367 367
368/******************************************************************/ 368/******************************************************************/
369/* Function : _asn1_mod_type */ 369/* Function : MHD__asn1_mod_type */
370/* Description: change the field TYPE of an NODE_ASN element. */ 370/* Description: change the field TYPE of an NODE_ASN element. */
371/* The new value is the old one | (bitwise or) the */ 371/* The new value is the old one | (bitwise or) the */
372/* paramener VALUE. */ 372/* paramener VALUE. */
@@ -377,7 +377,7 @@ _asn1_get_name (node_asn * node)
377/* Return: NODE pointer. */ 377/* Return: NODE pointer. */
378/******************************************************************/ 378/******************************************************************/
379node_asn * 379node_asn *
380_asn1_mod_type (node_asn * node, unsigned int value) 380MHD__asn1_mod_type (node_asn * node, unsigned int value)
381{ 381{
382 if (node == NULL) 382 if (node == NULL)
383 return node; 383 return node;
@@ -387,34 +387,34 @@ _asn1_mod_type (node_asn * node, unsigned int value)
387 387
388 388
389/******************************************************************/ 389/******************************************************************/
390/* Function : _asn1_remove_node */ 390/* Function : MHD__asn1_remove_node */
391/* Description: gets free the memory allocated for an NODE_ASN */ 391/* Description: gets free the memory allocated for an NODE_ASN */
392/* element (not the elements pointed by it). */ 392/* element (not the elements pointed by it). */
393/* Parameters: */ 393/* Parameters: */
394/* node: NODE_ASN element pointer. */ 394/* node: NODE_ASN element pointer. */
395/******************************************************************/ 395/******************************************************************/
396void 396void
397_asn1_remove_node (node_asn * node) 397MHD__asn1_remove_node (node_asn * node)
398{ 398{
399 if (node == NULL) 399 if (node == NULL)
400 return; 400 return;
401 401
402 if (node->name != NULL) 402 if (node->name != NULL)
403 _asn1_free (node->name); 403 MHD__asn1_free (node->name);
404 if (node->value != NULL) 404 if (node->value != NULL)
405 _asn1_free (node->value); 405 MHD__asn1_free (node->value);
406 _asn1_free (node); 406 MHD__asn1_free (node);
407} 407}
408 408
409/******************************************************************/ 409/******************************************************************/
410/* Function : _asn1_find_up */ 410/* Function : MHD__asn1_find_up */
411/* Description: return the father of the NODE_ASN element. */ 411/* Description: return the father of the NODE_ASN element. */
412/* Parameters: */ 412/* Parameters: */
413/* node: NODE_ASN element pointer. */ 413/* node: NODE_ASN element pointer. */
414/* Return: Null if not found. */ 414/* Return: Null if not found. */
415/******************************************************************/ 415/******************************************************************/
416node_asn * 416node_asn *
417_asn1_find_up (node_asn * node) 417MHD__asn1_find_up (node_asn * node)
418{ 418{
419 node_asn *p; 419 node_asn *p;
420 420
@@ -430,12 +430,12 @@ _asn1_find_up (node_asn * node)
430} 430}
431 431
432/******************************************************************/ 432/******************************************************************/
433/* Function : _asn1_delete_list */ 433/* Function : MHD__asn1_delete_list */
434/* Description: deletes the list elements (not the elements */ 434/* Description: deletes the list elements (not the elements */
435/* pointed by them). */ 435/* pointed by them). */
436/******************************************************************/ 436/******************************************************************/
437void 437void
438_asn1_delete_list (void) 438MHD__asn1_delete_list (void)
439{ 439{
440 list_type *listElement; 440 list_type *listElement;
441 441
@@ -443,17 +443,17 @@ _asn1_delete_list (void)
443 { 443 {
444 listElement = firstElement; 444 listElement = firstElement;
445 firstElement = firstElement->next; 445 firstElement = firstElement->next;
446 _asn1_free (listElement); 446 MHD__asn1_free (listElement);
447 } 447 }
448} 448}
449 449
450/******************************************************************/ 450/******************************************************************/
451/* Function : _asn1_delete_list_and nodes */ 451/* Function : MHD__asn1_delete_list_and nodes */
452/* Description: deletes the list elements and the elements */ 452/* Description: deletes the list elements and the elements */
453/* pointed by them. */ 453/* pointed by them. */
454/******************************************************************/ 454/******************************************************************/
455void 455void
456_asn1_delete_list_and_nodes (void) 456MHD__asn1_delete_list_and_nodes (void)
457{ 457{
458 list_type *listElement; 458 list_type *listElement;
459 459
@@ -461,14 +461,14 @@ _asn1_delete_list_and_nodes (void)
461 { 461 {
462 listElement = firstElement; 462 listElement = firstElement;
463 firstElement = firstElement->next; 463 firstElement = firstElement->next;
464 _asn1_remove_node (listElement->node); 464 MHD__asn1_remove_node (listElement->node);
465 _asn1_free (listElement); 465 MHD__asn1_free (listElement);
466 } 466 }
467} 467}
468 468
469 469
470char * 470char *
471_asn1_ltostr (long v, char *str) 471MHD__asn1_ltostr (long v, char *str)
472{ 472{
473 long d, r; 473 long d, r;
474 char temp[20]; 474 char temp[20];
@@ -502,7 +502,7 @@ _asn1_ltostr (long v, char *str)
502 502
503 503
504/******************************************************************/ 504/******************************************************************/
505/* Function : _asn1_change_integer_value */ 505/* Function : MHD__asn1_change_integer_value */
506/* Description: converts into DER coding the value assign to an */ 506/* Description: converts into DER coding the value assign to an */
507/* INTEGER constant. */ 507/* INTEGER constant. */
508/* Parameters: */ 508/* Parameters: */
@@ -511,8 +511,8 @@ _asn1_ltostr (long v, char *str)
511/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */ 511/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
512/* otherwise ASN1_SUCCESS */ 512/* otherwise ASN1_SUCCESS */
513/******************************************************************/ 513/******************************************************************/
514asn1_retCode 514MHD__asn1_retCode
515_asn1_change_integer_value (ASN1_TYPE node) 515MHD__asn1_change_integer_value (ASN1_TYPE node)
516{ 516{
517 node_asn *p; 517 node_asn *p;
518 unsigned char val[SIZEOF_UNSIGNED_LONG_INT]; 518 unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
@@ -529,9 +529,9 @@ _asn1_change_integer_value (ASN1_TYPE node)
529 { 529 {
530 if (p->value) 530 if (p->value)
531 { 531 {
532 _asn1_convert_integer (p->value, val, sizeof (val), &len); 532 MHD__asn1_convert_integer (p->value, val, sizeof (val), &len);
533 asn1_octet_der (val, len, val2, &len); 533 MHD__asn1_octet_der (val, len, val2, &len);
534 _asn1_set_value (p, val2, len); 534 MHD__asn1_set_value (p, val2, len);
535 } 535 }
536 } 536 }
537 537
@@ -549,7 +549,7 @@ _asn1_change_integer_value (ASN1_TYPE node)
549 { 549 {
550 while (1) 550 while (1)
551 { 551 {
552 p = _asn1_find_up (p); 552 p = MHD__asn1_find_up (p);
553 if (p == node) 553 if (p == node)
554 { 554 {
555 p = NULL; 555 p = NULL;
@@ -570,7 +570,7 @@ _asn1_change_integer_value (ASN1_TYPE node)
570 570
571 571
572/******************************************************************/ 572/******************************************************************/
573/* Function : _asn1_expand_object_id */ 573/* Function : MHD__asn1_expand_object_id */
574/* Description: expand the IDs of an OBJECT IDENTIFIER constant. */ 574/* Description: expand the IDs of an OBJECT IDENTIFIER constant. */
575/* Parameters: */ 575/* Parameters: */
576/* node: root of an ASN1 element. */ 576/* node: root of an ASN1 element. */
@@ -578,8 +578,8 @@ _asn1_change_integer_value (ASN1_TYPE node)
578/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */ 578/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
579/* otherwise ASN1_SUCCESS */ 579/* otherwise ASN1_SUCCESS */
580/******************************************************************/ 580/******************************************************************/
581asn1_retCode 581MHD__asn1_retCode
582_asn1_expand_object_id (ASN1_TYPE node) 582MHD__asn1_expand_object_id (ASN1_TYPE node)
583{ 583{
584 node_asn *p, *p2, *p3, *p4, *p5; 584 node_asn *p, *p2, *p3, *p4, *p5;
585 char name_root[MAX_NAME_SIZE], name2[2 * MAX_NAME_SIZE + 1]; 585 char name_root[MAX_NAME_SIZE], name2[2 * MAX_NAME_SIZE + 1];
@@ -588,7 +588,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
588 if (node == NULL) 588 if (node == NULL)
589 return ASN1_ELEMENT_NOT_FOUND; 589 return ASN1_ELEMENT_NOT_FOUND;
590 590
591 _asn1_str_cpy (name_root, sizeof (name_root), node->name); 591 MHD__asn1_str_cpy (name_root, sizeof (name_root), node->name);
592 592
593 p = node; 593 p = node;
594 move = DOWN; 594 move = DOWN;
@@ -605,35 +605,35 @@ _asn1_expand_object_id (ASN1_TYPE node)
605 { 605 {
606 if (p2->value && !isdigit (p2->value[0])) 606 if (p2->value && !isdigit (p2->value[0]))
607 { 607 {
608 _asn1_str_cpy (name2, sizeof (name2), name_root); 608 MHD__asn1_str_cpy (name2, sizeof (name2), name_root);
609 _asn1_str_cat (name2, sizeof (name2), "."); 609 MHD__asn1_str_cat (name2, sizeof (name2), ".");
610 _asn1_str_cat (name2, sizeof (name2), p2->value); 610 MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
611 p3 = asn1_find_node (node, name2); 611 p3 = MHD__asn1_find_node (node, name2);
612 if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || 612 if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
613 !(p3->type & CONST_ASSIGN)) 613 !(p3->type & CONST_ASSIGN))
614 return ASN1_ELEMENT_NOT_FOUND; 614 return ASN1_ELEMENT_NOT_FOUND;
615 _asn1_set_down (p, p2->right); 615 MHD__asn1_set_down (p, p2->right);
616 _asn1_remove_node (p2); 616 MHD__asn1_remove_node (p2);
617 p2 = p; 617 p2 = p;
618 p4 = p3->down; 618 p4 = p3->down;
619 while (p4) 619 while (p4)
620 { 620 {
621 if (type_field (p4->type) == TYPE_CONSTANT) 621 if (type_field (p4->type) == TYPE_CONSTANT)
622 { 622 {
623 p5 = _asn1_add_node_only (TYPE_CONSTANT); 623 p5 = MHD__asn1_add_node_only (TYPE_CONSTANT);
624 _asn1_set_name (p5, p4->name); 624 MHD__asn1_set_name (p5, p4->name);
625 tlen = strlen (p4->value); 625 tlen = strlen (p4->value);
626 if (tlen > 0) 626 if (tlen > 0)
627 _asn1_set_value (p5, p4->value, tlen + 1); 627 MHD__asn1_set_value (p5, p4->value, tlen + 1);
628 if (p2 == p) 628 if (p2 == p)
629 { 629 {
630 _asn1_set_right (p5, p->down); 630 MHD__asn1_set_right (p5, p->down);
631 _asn1_set_down (p, p5); 631 MHD__asn1_set_down (p, p5);
632 } 632 }
633 else 633 else
634 { 634 {
635 _asn1_set_right (p5, p2->right); 635 MHD__asn1_set_right (p5, p2->right);
636 _asn1_set_right (p2, p5); 636 MHD__asn1_set_right (p2, p5);
637 } 637 }
638 p2 = p5; 638 p2 = p5;
639 } 639 }
@@ -671,7 +671,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
671 move = UP; 671 move = UP;
672 } 672 }
673 if (move == UP) 673 if (move == UP)
674 p = _asn1_find_up (p); 674 p = MHD__asn1_find_up (p);
675 } 675 }
676 676
677 677
@@ -691,10 +691,10 @@ _asn1_expand_object_id (ASN1_TYPE node)
691 p2 = p->down; 691 p2 = p->down;
692 if (p2 && (type_field (p2->type) == TYPE_DEFAULT)) 692 if (p2 && (type_field (p2->type) == TYPE_DEFAULT))
693 { 693 {
694 _asn1_str_cpy (name2, sizeof (name2), name_root); 694 MHD__asn1_str_cpy (name2, sizeof (name2), name_root);
695 _asn1_str_cat (name2, sizeof (name2), "."); 695 MHD__asn1_str_cat (name2, sizeof (name2), ".");
696 _asn1_str_cat (name2, sizeof (name2), p2->value); 696 MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
697 p3 = asn1_find_node (node, name2); 697 p3 = MHD__asn1_find_node (node, name2);
698 if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || 698 if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
699 !(p3->type & CONST_ASSIGN)) 699 !(p3->type & CONST_ASSIGN))
700 return ASN1_ELEMENT_NOT_FOUND; 700 return ASN1_ELEMENT_NOT_FOUND;
@@ -705,14 +705,14 @@ _asn1_expand_object_id (ASN1_TYPE node)
705 if (type_field (p4->type) == TYPE_CONSTANT) 705 if (type_field (p4->type) == TYPE_CONSTANT)
706 { 706 {
707 if (name2[0]) 707 if (name2[0])
708 _asn1_str_cat (name2, sizeof (name2), "."); 708 MHD__asn1_str_cat (name2, sizeof (name2), ".");
709 _asn1_str_cat (name2, sizeof (name2), p4->value); 709 MHD__asn1_str_cat (name2, sizeof (name2), p4->value);
710 } 710 }
711 p4 = p4->right; 711 p4 = p4->right;
712 } 712 }
713 tlen = strlen (name2); 713 tlen = strlen (name2);
714 if (tlen > 0) 714 if (tlen > 0)
715 _asn1_set_value (p2, name2, tlen + 1); 715 MHD__asn1_set_value (p2, name2, tlen + 1);
716 } 716 }
717 } 717 }
718 move = DOWN; 718 move = DOWN;
@@ -742,7 +742,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
742 move = UP; 742 move = UP;
743 } 743 }
744 if (move == UP) 744 if (move == UP)
745 p = _asn1_find_up (p); 745 p = MHD__asn1_find_up (p);
746 } 746 }
747 747
748 return ASN1_SUCCESS; 748 return ASN1_SUCCESS;
@@ -750,7 +750,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
750 750
751 751
752/******************************************************************/ 752/******************************************************************/
753/* Function : _asn1_type_set_config */ 753/* Function : MHD__asn1_type_set_config */
754/* Description: sets the CONST_SET and CONST_NOT_USED properties */ 754/* Description: sets the CONST_SET and CONST_NOT_USED properties */
755/* in the fields of the SET elements. */ 755/* in the fields of the SET elements. */
756/* Parameters: */ 756/* Parameters: */
@@ -759,8 +759,8 @@ _asn1_expand_object_id (ASN1_TYPE node)
759/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */ 759/* ASN1_ELEMENT_NOT_FOUND if NODE is NULL, */
760/* otherwise ASN1_SUCCESS */ 760/* otherwise ASN1_SUCCESS */
761/******************************************************************/ 761/******************************************************************/
762asn1_retCode 762MHD__asn1_retCode
763_asn1_type_set_config (ASN1_TYPE node) 763MHD__asn1_type_set_config (ASN1_TYPE node)
764{ 764{
765 node_asn *p, *p2; 765 node_asn *p, *p2;
766 int move; 766 int move;
@@ -812,7 +812,7 @@ _asn1_type_set_config (ASN1_TYPE node)
812 move = UP; 812 move = UP;
813 } 813 }
814 if (move == UP) 814 if (move == UP)
815 p = _asn1_find_up (p); 815 p = MHD__asn1_find_up (p);
816 } 816 }
817 817
818 return ASN1_SUCCESS; 818 return ASN1_SUCCESS;
@@ -820,10 +820,10 @@ _asn1_type_set_config (ASN1_TYPE node)
820 820
821 821
822/******************************************************************/ 822/******************************************************************/
823/* Function : _asn1_check_identifier */ 823/* Function : MHD__asn1_check_identifier */
824/* Description: checks the definitions of all the identifiers */ 824/* Description: checks the definitions of all the identifiers */
825/* and the first element of an OBJECT_ID (e.g. {pkix 0 4}). */ 825/* and the first element of an OBJECT_ID (e.g. {pkix 0 4}). */
826/* The _asn1_identifierMissing global variable is filled if */ 826/* The MHD__asn1_identifierMissing global variable is filled if */
827/* necessary. */ 827/* necessary. */
828/* Parameters: */ 828/* Parameters: */
829/* node: root of an ASN1 element. */ 829/* node: root of an ASN1 element. */
@@ -832,8 +832,8 @@ _asn1_type_set_config (ASN1_TYPE node)
832/* ASN1_IDENTIFIER_NOT_FOUND if an identifier is not defined, */ 832/* ASN1_IDENTIFIER_NOT_FOUND if an identifier is not defined, */
833/* otherwise ASN1_SUCCESS */ 833/* otherwise ASN1_SUCCESS */
834/******************************************************************/ 834/******************************************************************/
835asn1_retCode 835MHD__asn1_retCode
836_asn1_check_identifier (ASN1_TYPE node) 836MHD__asn1_check_identifier (ASN1_TYPE node)
837{ 837{
838 node_asn *p, *p2; 838 node_asn *p, *p2;
839 char name2[MAX_NAME_SIZE * 2 + 2]; 839 char name2[MAX_NAME_SIZE * 2 + 2];
@@ -846,13 +846,13 @@ _asn1_check_identifier (ASN1_TYPE node)
846 { 846 {
847 if (type_field (p->type) == TYPE_IDENTIFIER) 847 if (type_field (p->type) == TYPE_IDENTIFIER)
848 { 848 {
849 _asn1_str_cpy (name2, sizeof (name2), node->name); 849 MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
850 _asn1_str_cat (name2, sizeof (name2), "."); 850 MHD__asn1_str_cat (name2, sizeof (name2), ".");
851 _asn1_str_cat (name2, sizeof (name2), p->value); 851 MHD__asn1_str_cat (name2, sizeof (name2), p->value);
852 p2 = asn1_find_node (node, name2); 852 p2 = MHD__asn1_find_node (node, name2);
853 if (p2 == NULL) 853 if (p2 == NULL)
854 { 854 {
855 strcpy (_asn1_identifierMissing, p->value); 855 strcpy (MHD__asn1_identifierMissing, p->value);
856 return ASN1_IDENTIFIER_NOT_FOUND; 856 return ASN1_IDENTIFIER_NOT_FOUND;
857 } 857 }
858 } 858 }
@@ -862,16 +862,16 @@ _asn1_check_identifier (ASN1_TYPE node)
862 p2 = p->down; 862 p2 = p->down;
863 if (p2 && (type_field (p2->type) == TYPE_DEFAULT)) 863 if (p2 && (type_field (p2->type) == TYPE_DEFAULT))
864 { 864 {
865 _asn1_str_cpy (name2, sizeof (name2), node->name); 865 MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
866 _asn1_str_cat (name2, sizeof (name2), "."); 866 MHD__asn1_str_cat (name2, sizeof (name2), ".");
867 _asn1_str_cat (name2, sizeof (name2), p2->value); 867 MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
868 strcpy (_asn1_identifierMissing, p2->value); 868 strcpy (MHD__asn1_identifierMissing, p2->value);
869 p2 = asn1_find_node (node, name2); 869 p2 = MHD__asn1_find_node (node, name2);
870 if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) || 870 if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
871 !(p2->type & CONST_ASSIGN)) 871 !(p2->type & CONST_ASSIGN))
872 return ASN1_IDENTIFIER_NOT_FOUND; 872 return ASN1_IDENTIFIER_NOT_FOUND;
873 else 873 else
874 _asn1_identifierMissing[0] = 0; 874 MHD__asn1_identifierMissing[0] = 0;
875 } 875 }
876 } 876 }
877 else if ((type_field (p->type) == TYPE_OBJECT_ID) && 877 else if ((type_field (p->type) == TYPE_OBJECT_ID) &&
@@ -882,16 +882,16 @@ _asn1_check_identifier (ASN1_TYPE node)
882 { 882 {
883 if (p2->value && !isdigit (p2->value[0])) 883 if (p2->value && !isdigit (p2->value[0]))
884 { 884 {
885 _asn1_str_cpy (name2, sizeof (name2), node->name); 885 MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
886 _asn1_str_cat (name2, sizeof (name2), "."); 886 MHD__asn1_str_cat (name2, sizeof (name2), ".");
887 _asn1_str_cat (name2, sizeof (name2), p2->value); 887 MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
888 strcpy (_asn1_identifierMissing, p2->value); 888 strcpy (MHD__asn1_identifierMissing, p2->value);
889 p2 = asn1_find_node (node, name2); 889 p2 = MHD__asn1_find_node (node, name2);
890 if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) || 890 if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
891 !(p2->type & CONST_ASSIGN)) 891 !(p2->type & CONST_ASSIGN))
892 return ASN1_IDENTIFIER_NOT_FOUND; 892 return ASN1_IDENTIFIER_NOT_FOUND;
893 else 893 else
894 _asn1_identifierMissing[0] = 0; 894 MHD__asn1_identifierMissing[0] = 0;
895 } 895 }
896 } 896 }
897 } 897 }
@@ -906,7 +906,7 @@ _asn1_check_identifier (ASN1_TYPE node)
906 { 906 {
907 while (1) 907 while (1)
908 { 908 {
909 p = _asn1_find_up (p); 909 p = MHD__asn1_find_up (p);
910 if (p == node) 910 if (p == node)
911 { 911 {
912 p = NULL; 912 p = NULL;
@@ -926,7 +926,7 @@ _asn1_check_identifier (ASN1_TYPE node)
926 926
927 927
928/******************************************************************/ 928/******************************************************************/
929/* Function : _asn1_set_default_tag */ 929/* Function : MHD__asn1_set_default_tag */
930/* Description: sets the default IMPLICIT or EXPLICIT property in */ 930/* Description: sets the default IMPLICIT or EXPLICIT property in */
931/* the tagged elements that don't have this declaration. */ 931/* the tagged elements that don't have this declaration. */
932/* Parameters: */ 932/* Parameters: */
@@ -936,8 +936,8 @@ _asn1_check_identifier (ASN1_TYPE node)
936/* a DEFINITIONS element, */ 936/* a DEFINITIONS element, */
937/* otherwise ASN1_SUCCESS */ 937/* otherwise ASN1_SUCCESS */
938/******************************************************************/ 938/******************************************************************/
939asn1_retCode 939MHD__asn1_retCode
940_asn1_set_default_tag (ASN1_TYPE node) 940MHD__asn1_set_default_tag (ASN1_TYPE node)
941{ 941{
942 node_asn *p; 942 node_asn *p;
943 943
@@ -966,7 +966,7 @@ _asn1_set_default_tag (ASN1_TYPE node)
966 { 966 {
967 while (1) 967 while (1)
968 { 968 {
969 p = _asn1_find_up (p); 969 p = MHD__asn1_find_up (p);
970 if (p == node) 970 if (p == node)
971 { 971 {
972 p = NULL; 972 p = NULL;
@@ -1027,7 +1027,7 @@ parse_version_string (const char *s, int *major, int *minor, int *micro)
1027} 1027}
1028 1028
1029/** 1029/**
1030 * asn1_check_version - check for library version 1030 * MHD__asn1_check_version - check for library version
1031 * @req_version: Required version number, or NULL. 1031 * @req_version: Required version number, or NULL.
1032 * 1032 *
1033 * Check that the the version of the library is at minimum the 1033 * Check that the the version of the library is at minimum the
@@ -1041,7 +1041,7 @@ parse_version_string (const char *s, int *major, int *minor, int *micro)
1041 * run-time library does not meet the required version number. 1041 * run-time library does not meet the required version number.
1042 */ 1042 */
1043const char * 1043const char *
1044asn1_check_version (const char *req_version) 1044MHD__asn1_check_version (const char *req_version)
1045{ 1045{
1046 const char *ver = LIBTASN1_VERSION; 1046 const char *ver = LIBTASN1_VERSION;
1047 int my_major, my_minor, my_micro; 1047 int my_major, my_minor, my_micro;
diff --git a/src/daemon/https/minitasn1/parser_aux.h b/src/daemon/https/minitasn1/parser_aux.h
index 4f7d3f1b..88b505bb 100644
--- a/src/daemon/https/minitasn1/parser_aux.h
+++ b/src/daemon/https/minitasn1/parser_aux.h
@@ -6,45 +6,45 @@
6/***************************************/ 6/***************************************/
7/* Functions used by ASN.1 parser */ 7/* Functions used by ASN.1 parser */
8/***************************************/ 8/***************************************/
9node_asn *_asn1_add_node (unsigned int type); 9node_asn *MHD__asn1_add_node (unsigned int type);
10 10
11node_asn *_asn1_set_value (node_asn * node, const void *value, 11node_asn *MHD__asn1_set_value (node_asn * node, const void *value,
12 unsigned int len); 12 unsigned int len);
13 13
14node_asn *_asn1_set_name (node_asn * node, const char *name); 14node_asn *MHD__asn1_set_name (node_asn * node, const char *name);
15 15
16node_asn *_asn1_set_right (node_asn * node, node_asn * right); 16node_asn *MHD__asn1_set_right (node_asn * node, node_asn * right);
17 17
18node_asn *_asn1_get_right (node_asn * node); 18node_asn *MHD__asn1_get_right (node_asn * node);
19 19
20node_asn *_asn1_get_last_right (node_asn * node); 20node_asn *MHD__asn1_get_last_right (node_asn * node);
21 21
22node_asn *_asn1_set_down (node_asn * node, node_asn * down); 22node_asn *MHD__asn1_set_down (node_asn * node, node_asn * down);
23 23
24char *_asn1_get_name (node_asn * node); 24char *MHD__asn1_get_name (node_asn * node);
25 25
26node_asn *_asn1_get_down (node_asn * node); 26node_asn *MHD__asn1_get_down (node_asn * node);
27 27
28node_asn *_asn1_mod_type (node_asn * node, unsigned int value); 28node_asn *MHD__asn1_mod_type (node_asn * node, unsigned int value);
29 29
30void _asn1_remove_node (node_asn * node); 30void MHD__asn1_remove_node (node_asn * node);
31 31
32void _asn1_delete_list (void); 32void MHD__asn1_delete_list (void);
33 33
34void _asn1_delete_list_and_nodes (void); 34void MHD__asn1_delete_list_and_nodes (void);
35 35
36char *_asn1_ltostr (long v, char *str); 36char *MHD__asn1_ltostr (long v, char *str);
37 37
38node_asn *_asn1_find_up (node_asn * node); 38node_asn *MHD__asn1_find_up (node_asn * node);
39 39
40asn1_retCode _asn1_change_integer_value (ASN1_TYPE node); 40MHD__asn1_retCode MHD__asn1_change_integer_value (ASN1_TYPE node);
41 41
42asn1_retCode _asn1_expand_object_id (ASN1_TYPE node); 42MHD__asn1_retCode MHD__asn1_expand_object_id (ASN1_TYPE node);
43 43
44asn1_retCode _asn1_type_set_config (ASN1_TYPE node); 44MHD__asn1_retCode MHD__asn1_type_set_config (ASN1_TYPE node);
45 45
46asn1_retCode _asn1_check_identifier (ASN1_TYPE node); 46MHD__asn1_retCode MHD__asn1_check_identifier (ASN1_TYPE node);
47 47
48asn1_retCode _asn1_set_default_tag (ASN1_TYPE node); 48MHD__asn1_retCode MHD__asn1_set_default_tag (ASN1_TYPE node);
49 49
50#endif 50#endif
diff --git a/src/daemon/https/minitasn1/structure.c b/src/daemon/https/minitasn1/structure.c
index 264793c1..af5fdf75 100644
--- a/src/daemon/https/minitasn1/structure.c
+++ b/src/daemon/https/minitasn1/structure.c
@@ -35,11 +35,11 @@
35#include <gstr.h> 35#include <gstr.h>
36 36
37 37
38extern char _asn1_identifierMissing[]; 38extern char MHD__asn1_identifierMissing[];
39 39
40 40
41/******************************************************/ 41/******************************************************/
42/* Function : _asn1_add_node_only */ 42/* Function : MHD__asn1_add_node_only */
43/* Description: creates a new NODE_ASN element. */ 43/* Description: creates a new NODE_ASN element. */
44/* Parameters: */ 44/* Parameters: */
45/* type: type of the new element (see TYPE_ */ 45/* type: type of the new element (see TYPE_ */
@@ -47,11 +47,11 @@ extern char _asn1_identifierMissing[];
47/* Return: pointer to the new element. */ 47/* Return: pointer to the new element. */
48/******************************************************/ 48/******************************************************/
49node_asn * 49node_asn *
50_asn1_add_node_only (unsigned int type) 50MHD__asn1_add_node_only (unsigned int type)
51{ 51{
52 node_asn *punt; 52 node_asn *punt;
53 53
54 punt = (node_asn *) _asn1_calloc (1, sizeof (node_asn)); 54 punt = (node_asn *) MHD__asn1_calloc (1, sizeof (node_asn));
55 if (punt == NULL) 55 if (punt == NULL)
56 return NULL; 56 return NULL;
57 57
@@ -62,7 +62,7 @@ _asn1_add_node_only (unsigned int type)
62 62
63 63
64/******************************************************************/ 64/******************************************************************/
65/* Function : _asn1_find_left */ 65/* Function : MHD__asn1_find_left */
66/* Description: returns the NODE_ASN element with RIGHT field that*/ 66/* Description: returns the NODE_ASN element with RIGHT field that*/
67/* points the element NODE. */ 67/* points the element NODE. */
68/* Parameters: */ 68/* Parameters: */
@@ -70,7 +70,7 @@ _asn1_add_node_only (unsigned int type)
70/* Return: NULL if not found. */ 70/* Return: NULL if not found. */
71/******************************************************************/ 71/******************************************************************/
72node_asn * 72node_asn *
73_asn1_find_left (node_asn * node) 73MHD__asn1_find_left (node_asn * node)
74{ 74{
75 if ((node == NULL) || (node->left == NULL) || (node->left->down == node)) 75 if ((node == NULL) || (node->left == NULL) || (node->left->down == node))
76 return NULL; 76 return NULL;
@@ -79,8 +79,8 @@ _asn1_find_left (node_asn * node)
79} 79}
80 80
81 81
82asn1_retCode 82MHD__asn1_retCode
83_asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name, 83MHD__asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
84 char *vector_name) 84 char *vector_name)
85{ 85{
86 FILE *file; 86 FILE *file;
@@ -136,7 +136,7 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
136 { 136 {
137 while (1) 137 while (1)
138 { 138 {
139 p = _asn1_find_up (p); 139 p = MHD__asn1_find_up (p);
140 if (p == pointer) 140 if (p == pointer)
141 { 141 {
142 p = NULL; 142 p = NULL;
@@ -160,14 +160,14 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
160 160
161 161
162/** 162/**
163 * asn1_array2tree - Creates the structures needed to manage the ASN1 definitions. 163 * MHD__asn1_array2tree - Creates the structures needed to manage the ASN1 definitions.
164 * @array: specify the array that contains ASN.1 declarations 164 * @array: specify the array that contains ASN.1 declarations
165 * @definitions: return the pointer to the structure created by 165 * @definitions: return the pointer to the structure created by
166 * *ARRAY ASN.1 declarations 166 * *ARRAY ASN.1 declarations
167 * @errorDescription: return the error description. 167 * @errorDescription: return the error description.
168 * 168 *
169 * Creates the structures needed to manage the ASN.1 definitions. 169 * Creates the structures needed to manage the ASN.1 definitions.
170 * @array is a vector created by asn1_parser2array(). 170 * @array is a vector created by MHD__asn1_parser2array().
171 * 171 *
172 * Returns: 172 * Returns:
173 * 173 *
@@ -180,14 +180,14 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
180 * 180 *
181 * ASN1_ARRAY_ERROR: The array pointed by @array is wrong. 181 * ASN1_ARRAY_ERROR: The array pointed by @array is wrong.
182 **/ 182 **/
183asn1_retCode 183MHD__asn1_retCode
184asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions, 184MHD__asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
185 char *errorDescription) 185 char *errorDescription)
186{ 186{
187 node_asn *p, *p_last = NULL; 187 node_asn *p, *p_last = NULL;
188 unsigned long k; 188 unsigned long k;
189 int move; 189 int move;
190 asn1_retCode result; 190 MHD__asn1_retCode result;
191 191
192 192
193 if (*definitions != ASN1_TYPE_EMPTY) 193 if (*definitions != ASN1_TYPE_EMPTY)
@@ -198,19 +198,19 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
198 k = 0; 198 k = 0;
199 while (array[k].value || array[k].type || array[k].name) 199 while (array[k].value || array[k].type || array[k].name)
200 { 200 {
201 p = _asn1_add_node (array[k].type & (~CONST_DOWN)); 201 p = MHD__asn1_add_node (array[k].type & (~CONST_DOWN));
202 if (array[k].name) 202 if (array[k].name)
203 _asn1_set_name (p, array[k].name); 203 MHD__asn1_set_name (p, array[k].name);
204 if (array[k].value) 204 if (array[k].value)
205 _asn1_set_value (p, array[k].value, strlen (array[k].value) + 1); 205 MHD__asn1_set_value (p, array[k].value, strlen (array[k].value) + 1);
206 206
207 if (*definitions == NULL) 207 if (*definitions == NULL)
208 *definitions = p; 208 *definitions = p;
209 209
210 if (move == DOWN) 210 if (move == DOWN)
211 _asn1_set_down (p_last, p); 211 MHD__asn1_set_down (p_last, p);
212 else if (move == RIGHT) 212 else if (move == RIGHT)
213 _asn1_set_right (p_last, p); 213 MHD__asn1_set_right (p_last, p);
214 214
215 p_last = p; 215 p_last = p;
216 216
@@ -225,7 +225,7 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
225 if (p_last == *definitions) 225 if (p_last == *definitions)
226 break; 226 break;
227 227
228 p_last = _asn1_find_up (p_last); 228 p_last = MHD__asn1_find_up (p_last);
229 229
230 if (p_last == NULL) 230 if (p_last == NULL)
231 break; 231 break;
@@ -243,11 +243,11 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
243 243
244 if (p_last == *definitions) 244 if (p_last == *definitions)
245 { 245 {
246 result = _asn1_check_identifier (*definitions); 246 result = MHD__asn1_check_identifier (*definitions);
247 if (result == ASN1_SUCCESS) 247 if (result == ASN1_SUCCESS)
248 { 248 {
249 _asn1_change_integer_value (*definitions); 249 MHD__asn1_change_integer_value (*definitions);
250 _asn1_expand_object_id (*definitions); 250 MHD__asn1_expand_object_id (*definitions);
251 } 251 }
252 } 252 }
253 else 253 else
@@ -260,7 +260,7 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
260 if (result == ASN1_IDENTIFIER_NOT_FOUND) 260 if (result == ASN1_IDENTIFIER_NOT_FOUND)
261 { 261 {
262 Estrcpy (errorDescription, ":: identifier '"); 262 Estrcpy (errorDescription, ":: identifier '");
263 Estrcat (errorDescription, _asn1_identifierMissing); 263 Estrcat (errorDescription, MHD__asn1_identifierMissing);
264 Estrcat (errorDescription, "' not found"); 264 Estrcat (errorDescription, "' not found");
265 } 265 }
266 else 266 else
@@ -269,17 +269,17 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
269 269
270 if (result != ASN1_SUCCESS) 270 if (result != ASN1_SUCCESS)
271 { 271 {
272 _asn1_delete_list_and_nodes (); 272 MHD__asn1_delete_list_and_nodes ();
273 *definitions = ASN1_TYPE_EMPTY; 273 *definitions = ASN1_TYPE_EMPTY;
274 } 274 }
275 else 275 else
276 _asn1_delete_list (); 276 MHD__asn1_delete_list ();
277 277
278 return result; 278 return result;
279} 279}
280 280
281/** 281/**
282 * asn1_delete_structure - Deletes the structure pointed by *ROOT. 282 * MHD__asn1_delete_structure - Deletes the structure pointed by *ROOT.
283 * @structure: pointer to the structure that you want to delete. 283 * @structure: pointer to the structure that you want to delete.
284 * 284 *
285 * Deletes the structure *@structure. At the end, *@structure is set 285 * Deletes the structure *@structure. At the end, *@structure is set
@@ -292,8 +292,8 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
292 * ASN1_ELEMENT_NOT_FOUND: *@structure was ASN1_TYPE_EMPTY. 292 * ASN1_ELEMENT_NOT_FOUND: *@structure was ASN1_TYPE_EMPTY.
293 * 293 *
294 **/ 294 **/
295asn1_retCode 295MHD__asn1_retCode
296asn1_delete_structure (ASN1_TYPE * structure) 296MHD__asn1_delete_structure (ASN1_TYPE * structure)
297{ 297{
298 node_asn *p, *p2, *p3; 298 node_asn *p, *p2, *p3;
299 299
@@ -312,19 +312,19 @@ asn1_delete_structure (ASN1_TYPE * structure)
312 p2 = p->right; 312 p2 = p->right;
313 if (p != *structure) 313 if (p != *structure)
314 { 314 {
315 p3 = _asn1_find_up (p); 315 p3 = MHD__asn1_find_up (p);
316 _asn1_set_down (p3, p2); 316 MHD__asn1_set_down (p3, p2);
317 _asn1_remove_node (p); 317 MHD__asn1_remove_node (p);
318 p = p3; 318 p = p3;
319 } 319 }
320 else 320 else
321 { /* p==root */ 321 { /* p==root */
322 p3 = _asn1_find_left (p); 322 p3 = MHD__asn1_find_left (p);
323 if (!p3) 323 if (!p3)
324 { 324 {
325 p3 = _asn1_find_up (p); 325 p3 = MHD__asn1_find_up (p);
326 if (p3) 326 if (p3)
327 _asn1_set_down (p3, p2); 327 MHD__asn1_set_down (p3, p2);
328 else 328 else
329 { 329 {
330 if (p->right) 330 if (p->right)
@@ -332,8 +332,8 @@ asn1_delete_structure (ASN1_TYPE * structure)
332 } 332 }
333 } 333 }
334 else 334 else
335 _asn1_set_right (p3, p2); 335 MHD__asn1_set_right (p3, p2);
336 _asn1_remove_node (p); 336 MHD__asn1_remove_node (p);
337 p = NULL; 337 p = NULL;
338 } 338 }
339 } 339 }
@@ -346,7 +346,7 @@ asn1_delete_structure (ASN1_TYPE * structure)
346 346
347 347
348/** 348/**
349 * asn1_delete_element - Deletes the element of a structure. 349 * MHD__asn1_delete_element - Deletes the element of a structure.
350 * @structure: pointer to the structure that contains the element you 350 * @structure: pointer to the structure that contains the element you
351 * want to delete. 351 * want to delete.
352 * @element_name: element's name you want to delete. 352 * @element_name: element's name you want to delete.
@@ -360,34 +360,34 @@ asn1_delete_structure (ASN1_TYPE * structure)
360 * ASN1_ELEMENT_NOT_FOUND: The name element was not found. 360 * ASN1_ELEMENT_NOT_FOUND: The name element was not found.
361 * 361 *
362 **/ 362 **/
363asn1_retCode 363MHD__asn1_retCode
364asn1_delete_element (ASN1_TYPE structure, const char *element_name) 364MHD__asn1_delete_element (ASN1_TYPE structure, const char *element_name)
365{ 365{
366 node_asn *p2, *p3, *source_node; 366 node_asn *p2, *p3, *source_node;
367 367
368 source_node = asn1_find_node (structure, element_name); 368 source_node = MHD__asn1_find_node (structure, element_name);
369 369
370 if (source_node == ASN1_TYPE_EMPTY) 370 if (source_node == ASN1_TYPE_EMPTY)
371 return ASN1_ELEMENT_NOT_FOUND; 371 return ASN1_ELEMENT_NOT_FOUND;
372 372
373 p2 = source_node->right; 373 p2 = source_node->right;
374 p3 = _asn1_find_left (source_node); 374 p3 = MHD__asn1_find_left (source_node);
375 if (!p3) 375 if (!p3)
376 { 376 {
377 p3 = _asn1_find_up (source_node); 377 p3 = MHD__asn1_find_up (source_node);
378 if (p3) 378 if (p3)
379 _asn1_set_down (p3, p2); 379 MHD__asn1_set_down (p3, p2);
380 else if (source_node->right) 380 else if (source_node->right)
381 source_node->right->left = NULL; 381 source_node->right->left = NULL;
382 } 382 }
383 else 383 else
384 _asn1_set_right (p3, p2); 384 MHD__asn1_set_right (p3, p2);
385 385
386 return asn1_delete_structure (&source_node); 386 return MHD__asn1_delete_structure (&source_node);
387} 387}
388 388
389node_asn * 389node_asn *
390_asn1_copy_structure3 (node_asn * source_node) 390MHD__asn1_copy_structure3 (node_asn * source_node)
391{ 391{
392 node_asn *dest_node, *p_s, *p_d, *p_d_prev; 392 node_asn *dest_node, *p_s, *p_d, *p_d_prev;
393 int move; 393 int move;
@@ -395,7 +395,7 @@ _asn1_copy_structure3 (node_asn * source_node)
395 if (source_node == NULL) 395 if (source_node == NULL)
396 return NULL; 396 return NULL;
397 397
398 dest_node = _asn1_add_node_only (source_node->type); 398 dest_node = MHD__asn1_add_node_only (source_node->type);
399 399
400 p_s = source_node; 400 p_s = source_node;
401 p_d = dest_node; 401 p_d = dest_node;
@@ -407,9 +407,9 @@ _asn1_copy_structure3 (node_asn * source_node)
407 if (move != UP) 407 if (move != UP)
408 { 408 {
409 if (p_s->name) 409 if (p_s->name)
410 _asn1_set_name (p_d, p_s->name); 410 MHD__asn1_set_name (p_d, p_s->name);
411 if (p_s->value) 411 if (p_s->value)
412 _asn1_set_value (p_d, p_s->value, p_s->value_len); 412 MHD__asn1_set_value (p_d, p_s->value, p_s->value_len);
413 move = DOWN; 413 move = DOWN;
414 } 414 }
415 else 415 else
@@ -421,8 +421,8 @@ _asn1_copy_structure3 (node_asn * source_node)
421 { 421 {
422 p_s = p_s->down; 422 p_s = p_s->down;
423 p_d_prev = p_d; 423 p_d_prev = p_d;
424 p_d = _asn1_add_node_only (p_s->type); 424 p_d = MHD__asn1_add_node_only (p_s->type);
425 _asn1_set_down (p_d_prev, p_d); 425 MHD__asn1_set_down (p_d_prev, p_d);
426 } 426 }
427 else 427 else
428 move = RIGHT; 428 move = RIGHT;
@@ -437,16 +437,16 @@ _asn1_copy_structure3 (node_asn * source_node)
437 { 437 {
438 p_s = p_s->right; 438 p_s = p_s->right;
439 p_d_prev = p_d; 439 p_d_prev = p_d;
440 p_d = _asn1_add_node_only (p_s->type); 440 p_d = MHD__asn1_add_node_only (p_s->type);
441 _asn1_set_right (p_d_prev, p_d); 441 MHD__asn1_set_right (p_d_prev, p_d);
442 } 442 }
443 else 443 else
444 move = UP; 444 move = UP;
445 } 445 }
446 if (move == UP) 446 if (move == UP)
447 { 447 {
448 p_s = _asn1_find_up (p_s); 448 p_s = MHD__asn1_find_up (p_s);
449 p_d = _asn1_find_up (p_d); 449 p_d = MHD__asn1_find_up (p_d);
450 } 450 }
451 } 451 }
452 while (p_s != source_node); 452 while (p_s != source_node);
@@ -456,19 +456,19 @@ _asn1_copy_structure3 (node_asn * source_node)
456 456
457 457
458node_asn * 458node_asn *
459_asn1_copy_structure2 (node_asn * root, const char *source_name) 459MHD__asn1_copy_structure2 (node_asn * root, const char *source_name)
460{ 460{
461 node_asn *source_node; 461 node_asn *source_node;
462 462
463 source_node = asn1_find_node (root, source_name); 463 source_node = MHD__asn1_find_node (root, source_name);
464 464
465 return _asn1_copy_structure3 (source_node); 465 return MHD__asn1_copy_structure3 (source_node);
466 466
467} 467}
468 468
469 469
470asn1_retCode 470MHD__asn1_retCode
471_asn1_type_choice_config (node_asn * node) 471MHD__asn1_type_choice_config (node_asn * node)
472{ 472{
473 node_asn *p, *p2, *p3, *p4; 473 node_asn *p, *p2, *p3, *p4;
474 int move, tlen; 474 int move, tlen;
@@ -491,19 +491,19 @@ _asn1_type_choice_config (node_asn * node)
491 if (type_field (p2->type) != TYPE_TAG) 491 if (type_field (p2->type) != TYPE_TAG)
492 { 492 {
493 p2->type |= CONST_TAG; 493 p2->type |= CONST_TAG;
494 p3 = _asn1_find_left (p2); 494 p3 = MHD__asn1_find_left (p2);
495 while (p3) 495 while (p3)
496 { 496 {
497 if (type_field (p3->type) == TYPE_TAG) 497 if (type_field (p3->type) == TYPE_TAG)
498 { 498 {
499 p4 = _asn1_add_node_only (p3->type); 499 p4 = MHD__asn1_add_node_only (p3->type);
500 tlen = strlen (p3->value); 500 tlen = strlen (p3->value);
501 if (tlen > 0) 501 if (tlen > 0)
502 _asn1_set_value (p4, p3->value, tlen + 1); 502 MHD__asn1_set_value (p4, p3->value, tlen + 1);
503 _asn1_set_right (p4, p2->down); 503 MHD__asn1_set_right (p4, p2->down);
504 _asn1_set_down (p2, p4); 504 MHD__asn1_set_down (p2, p4);
505 } 505 }
506 p3 = _asn1_find_left (p3); 506 p3 = MHD__asn1_find_left (p3);
507 } 507 }
508 } 508 }
509 p2 = p2->right; 509 p2 = p2->right;
@@ -514,7 +514,7 @@ _asn1_type_choice_config (node_asn * node)
514 { 514 {
515 p3 = p2->right; 515 p3 = p2->right;
516 if (type_field (p2->type) == TYPE_TAG) 516 if (type_field (p2->type) == TYPE_TAG)
517 asn1_delete_structure (&p2); 517 MHD__asn1_delete_structure (&p2);
518 p2 = p3; 518 p2 = p3;
519 } 519 }
520 } 520 }
@@ -545,15 +545,15 @@ _asn1_type_choice_config (node_asn * node)
545 move = UP; 545 move = UP;
546 } 546 }
547 if (move == UP) 547 if (move == UP)
548 p = _asn1_find_up (p); 548 p = MHD__asn1_find_up (p);
549 } 549 }
550 550
551 return ASN1_SUCCESS; 551 return ASN1_SUCCESS;
552} 552}
553 553
554 554
555asn1_retCode 555MHD__asn1_retCode
556_asn1_expand_identifier (node_asn ** node, node_asn * root) 556MHD__asn1_expand_identifier (node_asn ** node, node_asn * root)
557{ 557{
558 node_asn *p, *p2, *p3; 558 node_asn *p, *p2, *p3;
559 char name2[MAX_NAME_SIZE + 2]; 559 char name2[MAX_NAME_SIZE + 2];
@@ -571,15 +571,15 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
571 { 571 {
572 if (type_field (p->type) == TYPE_IDENTIFIER) 572 if (type_field (p->type) == TYPE_IDENTIFIER)
573 { 573 {
574 _asn1_str_cpy (name2, sizeof (name2), root->name); 574 MHD__asn1_str_cpy (name2, sizeof (name2), root->name);
575 _asn1_str_cat (name2, sizeof (name2), "."); 575 MHD__asn1_str_cat (name2, sizeof (name2), ".");
576 _asn1_str_cat (name2, sizeof (name2), p->value); 576 MHD__asn1_str_cat (name2, sizeof (name2), p->value);
577 p2 = _asn1_copy_structure2 (root, name2); 577 p2 = MHD__asn1_copy_structure2 (root, name2);
578 if (p2 == NULL) 578 if (p2 == NULL)
579 { 579 {
580 return ASN1_IDENTIFIER_NOT_FOUND; 580 return ASN1_IDENTIFIER_NOT_FOUND;
581 } 581 }
582 _asn1_set_name (p2, p->name); 582 MHD__asn1_set_name (p2, p->name);
583 p2->right = p->right; 583 p2->right = p->right;
584 p2->left = p->left; 584 p2->left = p->left;
585 if (p->right) 585 if (p->right)
@@ -589,18 +589,18 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
589 { 589 {
590 while (p3->right) 590 while (p3->right)
591 p3 = p3->right; 591 p3 = p3->right;
592 _asn1_set_right (p3, p2->down); 592 MHD__asn1_set_right (p3, p2->down);
593 _asn1_set_down (p2, p->down); 593 MHD__asn1_set_down (p2, p->down);
594 } 594 }
595 595
596 p3 = _asn1_find_left (p); 596 p3 = MHD__asn1_find_left (p);
597 if (p3) 597 if (p3)
598 _asn1_set_right (p3, p2); 598 MHD__asn1_set_right (p3, p2);
599 else 599 else
600 { 600 {
601 p3 = _asn1_find_up (p); 601 p3 = MHD__asn1_find_up (p);
602 if (p3) 602 if (p3)
603 _asn1_set_down (p3, p2); 603 MHD__asn1_set_down (p3, p2);
604 else 604 else
605 { 605 {
606 p2->left = NULL; 606 p2->left = NULL;
@@ -622,7 +622,7 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
622 622
623 if (p == *node) 623 if (p == *node)
624 *node = p2; 624 *node = p2;
625 _asn1_remove_node (p); 625 MHD__asn1_remove_node (p);
626 p = p2; 626 p = p2;
627 move = DOWN; 627 move = DOWN;
628 continue; 628 continue;
@@ -654,7 +654,7 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
654 move = UP; 654 move = UP;
655 } 655 }
656 if (move == UP) 656 if (move == UP)
657 p = _asn1_find_up (p); 657 p = MHD__asn1_find_up (p);
658 } 658 }
659 659
660 return ASN1_SUCCESS; 660 return ASN1_SUCCESS;
@@ -662,7 +662,7 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
662 662
663 663
664/** 664/**
665 * asn1_create_element - Creates a structure of type SOURCE_NAME. 665 * MHD__asn1_create_element - Creates a structure of type SOURCE_NAME.
666 * @definitions: pointer to the structure returned by "parser_asn1" function 666 * @definitions: pointer to the structure returned by "parser_asn1" function
667 * @source_name: the name of the type of the new structure (must be 667 * @source_name: the name of the type of the new structure (must be
668 * inside p_structure). 668 * inside p_structure).
@@ -671,7 +671,7 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
671 * Creates a structure of type @source_name. Example using 671 * Creates a structure of type @source_name. Example using
672 * "pkix.asn": 672 * "pkix.asn":
673 * 673 *
674 * rc = asn1_create_structure(cert_def, "PKIX1.Certificate", 674 * rc = MHD__asn1_create_structure(cert_def, "PKIX1.Certificate",
675 * certptr); 675 * certptr);
676 * 676 *
677 * Returns: 677 * Returns:
@@ -680,22 +680,22 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
680 * 680 *
681 * ASN1_ELEMENT_NOT_FOUND: SOURCE_NAME isn't known 681 * ASN1_ELEMENT_NOT_FOUND: SOURCE_NAME isn't known
682 **/ 682 **/
683asn1_retCode 683MHD__asn1_retCode
684asn1_create_element (ASN1_TYPE definitions, const char *source_name, 684MHD__asn1_create_element (ASN1_TYPE definitions, const char *source_name,
685 ASN1_TYPE * element) 685 ASN1_TYPE * element)
686{ 686{
687 node_asn *dest_node; 687 node_asn *dest_node;
688 int res; 688 int res;
689 689
690 dest_node = _asn1_copy_structure2 (definitions, source_name); 690 dest_node = MHD__asn1_copy_structure2 (definitions, source_name);
691 691
692 if (dest_node == NULL) 692 if (dest_node == NULL)
693 return ASN1_ELEMENT_NOT_FOUND; 693 return ASN1_ELEMENT_NOT_FOUND;
694 694
695 _asn1_set_name (dest_node, ""); 695 MHD__asn1_set_name (dest_node, "");
696 696
697 res = _asn1_expand_identifier (&dest_node, definitions); 697 res = MHD__asn1_expand_identifier (&dest_node, definitions);
698 _asn1_type_choice_config (dest_node); 698 MHD__asn1_type_choice_config (dest_node);
699 699
700 *element = dest_node; 700 *element = dest_node;
701 701
@@ -704,7 +704,7 @@ asn1_create_element (ASN1_TYPE definitions, const char *source_name,
704 704
705 705
706/** 706/**
707 * asn1_print_structure - Prints on the standard output the structure's tree 707 * MHD__asn1_print_structure - Prints on the standard output the structure's tree
708 * @out: pointer to the output file (e.g. stdout). 708 * @out: pointer to the output file (e.g. stdout).
709 * @structure: pointer to the structure that you want to visit. 709 * @structure: pointer to the structure that you want to visit.
710 * @name: an element of the structure 710 * @name: an element of the structure
@@ -716,7 +716,7 @@ asn1_create_element (ASN1_TYPE definitions, const char *source_name,
716 * from the @name element inside the structure @structure. 716 * from the @name element inside the structure @structure.
717 **/ 717 **/
718void 718void
719asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name, 719MHD__asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
720 int mode) 720 int mode)
721{ 721{
722 node_asn *p, *root; 722 node_asn *p, *root;
@@ -725,7 +725,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
725 if (out == NULL) 725 if (out == NULL)
726 return; 726 return;
727 727
728 root = asn1_find_node (structure, name); 728 root = MHD__asn1_find_node (structure, name);
729 729
730 if (root == NULL) 730 if (root == NULL)
731 return; 731 return;
@@ -872,7 +872,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
872 if (p->value) 872 if (p->value)
873 { 873 {
874 len2 = -1; 874 len2 = -1;
875 len = asn1_get_length_der (p->value, p->value_len, &len2); 875 len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
876 fprintf (out, " value:0x"); 876 fprintf (out, " value:0x");
877 if (len > 0) 877 if (len > 0)
878 for (k = 0; k < len; k++) 878 for (k = 0; k < len; k++)
@@ -883,7 +883,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
883 if (p->value) 883 if (p->value)
884 { 884 {
885 len2 = -1; 885 len2 = -1;
886 len = asn1_get_length_der (p->value, p->value_len, &len2); 886 len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
887 fprintf (out, " value:0x"); 887 fprintf (out, " value:0x");
888 if (len > 0) 888 if (len > 0)
889 for (k = 0; k < len; k++) 889 for (k = 0; k < len; k++)
@@ -907,7 +907,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
907 if (p->value) 907 if (p->value)
908 { 908 {
909 len2 = -1; 909 len2 = -1;
910 len = asn1_get_length_der (p->value, p->value_len, &len2); 910 len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
911 if (len > 0) 911 if (len > 0)
912 { 912 {
913 fprintf (out, " value(%i):", 913 fprintf (out, " value(%i):",
@@ -921,7 +921,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
921 if (p->value) 921 if (p->value)
922 { 922 {
923 len2 = -1; 923 len2 = -1;
924 len = asn1_get_length_der (p->value, p->value_len, &len2); 924 len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
925 fprintf (out, " value:"); 925 fprintf (out, " value:");
926 if (len > 0) 926 if (len > 0)
927 for (k = 0; k < len; k++) 927 for (k = 0; k < len; k++)
@@ -932,7 +932,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
932 if (p->value) 932 if (p->value)
933 { 933 {
934 len2 = -1; 934 len2 = -1;
935 len = asn1_get_length_der (p->value, p->value_len, &len2); 935 len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
936 fprintf (out, " value:"); 936 fprintf (out, " value:");
937 if (len > 0) 937 if (len > 0)
938 for (k = 0; k < len; k++) 938 for (k = 0; k < len; k++)
@@ -947,7 +947,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
947 if (p->value) 947 if (p->value)
948 { 948 {
949 len3 = -1; 949 len3 = -1;
950 len2 = asn1_get_length_der (p->value, p->value_len, &len3); 950 len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
951 fprintf (out, " value:"); 951 fprintf (out, " value:");
952 if (len2 > 0) 952 if (len2 > 0)
953 for (k = 0; k < len2; k++) 953 for (k = 0; k < len2; k++)
@@ -1048,7 +1048,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
1048 { 1048 {
1049 while (1) 1049 while (1)
1050 { 1050 {
1051 p = _asn1_find_up (p); 1051 p = MHD__asn1_find_up (p);
1052 if (p == root) 1052 if (p == root)
1053 { 1053 {
1054 p = NULL; 1054 p = NULL;
@@ -1068,7 +1068,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
1068 1068
1069 1069
1070/** 1070/**
1071 * asn1_number_of_elements - Counts the number of elements of a structure. 1071 * MHD__asn1_number_of_elements - Counts the number of elements of a structure.
1072 * @element: pointer to the root of an ASN1 structure. 1072 * @element: pointer to the root of an ASN1 structure.
1073 * @name: the name of a sub-structure of ROOT. 1073 * @name: the name of a sub-structure of ROOT.
1074 * @num: pointer to an integer where the result will be stored 1074 * @num: pointer to an integer where the result will be stored
@@ -1085,8 +1085,8 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
1085 * ASN1_GENERIC_ERROR: Pointer num equal to NULL. 1085 * ASN1_GENERIC_ERROR: Pointer num equal to NULL.
1086 * 1086 *
1087 **/ 1087 **/
1088asn1_retCode 1088MHD__asn1_retCode
1089asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num) 1089MHD__asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
1090{ 1090{
1091 node_asn *node, *p; 1091 node_asn *node, *p;
1092 1092
@@ -1095,7 +1095,7 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
1095 1095
1096 *num = 0; 1096 *num = 0;
1097 1097
1098 node = asn1_find_node (element, name); 1098 node = MHD__asn1_find_node (element, name);
1099 if (node == NULL) 1099 if (node == NULL)
1100 return ASN1_ELEMENT_NOT_FOUND; 1100 return ASN1_ELEMENT_NOT_FOUND;
1101 1101
@@ -1113,7 +1113,7 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
1113 1113
1114 1114
1115/** 1115/**
1116 * asn1_find_structure_from_oid - Locate structure defined by a specific OID. 1116 * MHD__asn1_find_structure_from_oid - Locate structure defined by a specific OID.
1117 * @definitions: ASN1 definitions 1117 * @definitions: ASN1 definitions
1118 * @oidValue: value of the OID to search (e.g. "1.2.3.4"). 1118 * @oidValue: value of the OID to search (e.g. "1.2.3.4").
1119 * 1119 *
@@ -1125,13 +1125,13 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
1125 * 1125 *
1126 **/ 1126 **/
1127const char * 1127const char *
1128asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue) 1128MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
1129{ 1129{
1130 char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1]; 1130 char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1];
1131 char value[MAX_NAME_SIZE]; 1131 char value[MAX_NAME_SIZE];
1132 ASN1_TYPE p; 1132 ASN1_TYPE p;
1133 int len; 1133 int len;
1134 asn1_retCode result; 1134 MHD__asn1_retCode result;
1135 1135
1136 if ((definitions == ASN1_TYPE_EMPTY) || (oidValue == NULL)) 1136 if ((definitions == ASN1_TYPE_EMPTY) || (oidValue == NULL))
1137 return NULL; /* ASN1_ELEMENT_NOT_FOUND; */ 1137 return NULL; /* ASN1_ELEMENT_NOT_FOUND; */
@@ -1151,7 +1151,7 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
1151 strcat (name, p->name); 1151 strcat (name, p->name);
1152 1152
1153 len = MAX_NAME_SIZE; 1153 len = MAX_NAME_SIZE;
1154 result = asn1_read_value (definitions, name, value, &len); 1154 result = MHD__asn1_read_value (definitions, name, value, &len);
1155 1155
1156 if ((result == ASN1_SUCCESS) && (!strcmp (oidValue, value))) 1156 if ((result == ASN1_SUCCESS) && (!strcmp (oidValue, value)))
1157 { 1157 {
@@ -1169,7 +1169,7 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
1169} 1169}
1170 1170
1171/** 1171/**
1172 * asn1_copy_node: 1172 * MHD__asn1_copy_node:
1173 * @dst: Destination ASN1_TYPE node. 1173 * @dst: Destination ASN1_TYPE node.
1174 * @dst_name: Field name in destination node. 1174 * @dst_name: Field name in destination node.
1175 * @src: Source ASN1_TYPE node. 1175 * @src: Source ASN1_TYPE node.
@@ -1179,8 +1179,8 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
1179 * 1179 *
1180 * Return value: Return ASN1_SUCCESS on success. 1180 * Return value: Return ASN1_SUCCESS on success.
1181 **/ 1181 **/
1182asn1_retCode 1182MHD__asn1_retCode
1183asn1_copy_node (ASN1_TYPE dst, const char *dst_name, 1183MHD__asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
1184 ASN1_TYPE src, const char *src_name) 1184 ASN1_TYPE src, const char *src_name)
1185{ 1185{
1186/* FIXME: rewrite using copy_structure(). 1186/* FIXME: rewrite using copy_structure().
@@ -1191,31 +1191,31 @@ asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
1191 void *data = NULL; 1191 void *data = NULL;
1192 int size = 0; 1192 int size = 0;
1193 1193
1194 result = asn1_der_coding (src, src_name, NULL, &size, NULL); 1194 result = MHD__asn1_der_coding (src, src_name, NULL, &size, NULL);
1195 if (result != ASN1_MEM_ERROR) 1195 if (result != ASN1_MEM_ERROR)
1196 return result; 1196 return result;
1197 1197
1198 data = _asn1_malloc (size); 1198 data = MHD__asn1_malloc (size);
1199 if (data == NULL) 1199 if (data == NULL)
1200 return ASN1_MEM_ERROR; 1200 return ASN1_MEM_ERROR;
1201 1201
1202 result = asn1_der_coding (src, src_name, data, &size, NULL); 1202 result = MHD__asn1_der_coding (src, src_name, data, &size, NULL);
1203 if (result != ASN1_SUCCESS) 1203 if (result != ASN1_SUCCESS)
1204 { 1204 {
1205 _asn1_free (data); 1205 MHD__asn1_free (data);
1206 return result; 1206 return result;
1207 } 1207 }
1208 1208
1209 dst_node = asn1_find_node (dst, dst_name); 1209 dst_node = MHD__asn1_find_node (dst, dst_name);
1210 if (dst_node == NULL) 1210 if (dst_node == NULL)
1211 { 1211 {
1212 _asn1_free (data); 1212 MHD__asn1_free (data);
1213 return ASN1_ELEMENT_NOT_FOUND; 1213 return ASN1_ELEMENT_NOT_FOUND;
1214 } 1214 }
1215 1215
1216 result = asn1_der_decoding (&dst_node, data, size, NULL); 1216 result = MHD__asn1_der_decoding (&dst_node, data, size, NULL);
1217 1217
1218 _asn1_free (data); 1218 MHD__asn1_free (data);
1219 1219
1220 return result; 1220 return result;
1221} 1221}
diff --git a/src/daemon/https/minitasn1/structure.h b/src/daemon/https/minitasn1/structure.h
index 9fdb3343..e7941639 100644
--- a/src/daemon/https/minitasn1/structure.h
+++ b/src/daemon/https/minitasn1/structure.h
@@ -8,16 +8,16 @@
8#ifndef _STRUCTURE_H 8#ifndef _STRUCTURE_H
9#define _STRUCTURE_H 9#define _STRUCTURE_H
10 10
11asn1_retCode _asn1_create_static_structure (node_asn * pointer, 11MHD__asn1_retCode MHD__asn1_create_static_structure (node_asn * pointer,
12 char *output_file_name, 12 char *output_file_name,
13 char *vector_name); 13 char *vector_name);
14 14
15node_asn *_asn1_copy_structure3 (node_asn * source_node); 15node_asn *MHD__asn1_copy_structure3 (node_asn * source_node);
16 16
17node_asn *_asn1_copy_structure2 (node_asn * root, const char *source_name); 17node_asn *MHD__asn1_copy_structure2 (node_asn * root, const char *source_name);
18 18
19node_asn *_asn1_add_node_only (unsigned int type); 19node_asn *MHD__asn1_add_node_only (unsigned int type);
20 20
21node_asn *_asn1_find_left (node_asn * node); 21node_asn *MHD__asn1_find_left (node_asn * node);
22 22
23#endif 23#endif
diff --git a/src/daemon/https/tls/auth_anon.c b/src/daemon/https/tls/auth_anon.c
index d20e55cf..1d6922cc 100644
--- a/src/daemon/https/tls/auth_anon.c
+++ b/src/daemon/https/tls/auth_anon.c
@@ -40,52 +40,52 @@
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 mhd_gtls_gen_anon_server_kx (mhd_gtls_session_t, opaque **); 43static int MHD_gtls_gen_anon_server_kx (MHD_gtls_session_t, opaque **);
44static int mhd_gtls_proc_anon_client_kx (mhd_gtls_session_t, opaque *, 44static int MHD_gtls_proc_anon_client_kx (MHD_gtls_session_t, opaque *,
45 size_t); 45 size_t);
46static int mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t, opaque *, 46static int MHD_gtls_proc_anon_server_kx (MHD_gtls_session_t, opaque *,
47 size_t); 47 size_t);
48 48
49const mhd_gtls_mod_auth_st mhd_gtls_anon_auth_struct = { 49const MHD_gtls_mod_auth_st MHD_gtls_anon_auth_struct = {
50 "ANON", 50 "ANON",
51 NULL, 51 NULL,
52 NULL, 52 NULL,
53 mhd_gtls_gen_anon_server_kx, 53 MHD_gtls_gen_anon_server_kx,
54 mhd_gtls_gen_dh_common_client_kx, /* this can be shared */ 54 MHD_gtls_gen_dh_common_client_kx, /* this can be shared */
55 NULL, 55 NULL,
56 NULL, 56 NULL,
57 57
58 NULL, 58 NULL,
59 NULL, /* certificate */ 59 NULL, /* certificate */
60 mhd_gtls_proc_anon_server_kx, 60 MHD_gtls_proc_anon_server_kx,
61 mhd_gtls_proc_anon_client_kx, 61 MHD_gtls_proc_anon_client_kx,
62 NULL, 62 NULL,
63 NULL 63 NULL
64}; 64};
65 65
66static int 66static int
67mhd_gtls_gen_anon_server_kx (mhd_gtls_session_t session, opaque ** data) 67MHD_gtls_gen_anon_server_kx (MHD_gtls_session_t session, opaque ** data)
68{ 68{
69 mpi_t g, p; 69 mpi_t g, p;
70 const mpi_t *mpis; 70 const mpi_t *mpis;
71 int ret; 71 int ret;
72 mhd_gtls_dh_params_t dh_params; 72 MHD_gtls_dh_params_t dh_params;
73 mhd_gtls_anon_server_credentials_t cred; 73 MHD_gtls_anon_server_credentials_t cred;
74 74
75 cred = (mhd_gtls_anon_server_credentials_t) 75 cred = (MHD_gtls_anon_server_credentials_t)
76 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL); 76 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
77 if (cred == NULL) 77 if (cred == NULL)
78 { 78 {
79 gnutls_assert (); 79 MHD_gnutls_assert ();
80 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 80 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
81 } 81 }
82 82
83 dh_params = 83 dh_params =
84 mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session); 84 MHD_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
85 mpis = mhd_gtls_dh_params_to_mpi (dh_params); 85 mpis = MHD_gtls_dh_params_to_mpi (dh_params);
86 if (mpis == NULL) 86 if (mpis == NULL)
87 { 87 {
88 gnutls_assert (); 88 MHD_gnutls_assert ();
89 return GNUTLS_E_NO_TEMPORARY_DH_PARAMS; 89 return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
90 } 90 }
91 91
@@ -93,19 +93,19 @@ mhd_gtls_gen_anon_server_kx (mhd_gtls_session_t session, opaque ** data)
93 g = mpis[1]; 93 g = mpis[1];
94 94
95 if ((ret = 95 if ((ret =
96 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON, 96 MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
97 sizeof (anon_auth_info_st), 1)) < 0) 97 sizeof (anon_auth_info_st), 1)) < 0)
98 { 98 {
99 gnutls_assert (); 99 MHD_gnutls_assert ();
100 return ret; 100 return ret;
101 } 101 }
102 102
103 mhd_gtls_dh_set_group (session, g, p); 103 MHD_gtls_dh_set_group (session, g, p);
104 104
105 ret = mhd_gtls_dh_common_print_server_kx (session, g, p, data, 0); 105 ret = MHD_gtls_dh_common_print_server_kx (session, g, p, data, 0);
106 if (ret < 0) 106 if (ret < 0)
107 { 107 {
108 gnutls_assert (); 108 MHD_gnutls_assert ();
109 } 109 }
110 110
111 return ret; 111 return ret;
@@ -113,46 +113,46 @@ mhd_gtls_gen_anon_server_kx (mhd_gtls_session_t session, opaque ** data)
113 113
114 114
115static int 115static int
116mhd_gtls_proc_anon_client_kx (mhd_gtls_session_t session, opaque * data, 116MHD_gtls_proc_anon_client_kx (MHD_gtls_session_t session, opaque * data,
117 size_t _data_size) 117 size_t _data_size)
118{ 118{
119 mhd_gtls_anon_server_credentials_t cred; 119 MHD_gtls_anon_server_credentials_t cred;
120 int bits; 120 int bits;
121 int ret; 121 int ret;
122 mpi_t p, g; 122 mpi_t p, g;
123 mhd_gtls_dh_params_t dh_params; 123 MHD_gtls_dh_params_t dh_params;
124 const mpi_t *mpis; 124 const mpi_t *mpis;
125 125
126 bits = mhd_gtls_dh_get_allowed_prime_bits (session); 126 bits = MHD_gtls_dh_get_allowed_prime_bits (session);
127 127
128 cred = (mhd_gtls_anon_server_credentials_t) 128 cred = (MHD_gtls_anon_server_credentials_t)
129 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL); 129 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
130 if (cred == NULL) 130 if (cred == NULL)
131 { 131 {
132 gnutls_assert (); 132 MHD_gnutls_assert ();
133 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 133 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
134 } 134 }
135 135
136 dh_params = 136 dh_params =
137 mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session); 137 MHD_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
138 mpis = mhd_gtls_dh_params_to_mpi (dh_params); 138 mpis = MHD_gtls_dh_params_to_mpi (dh_params);
139 if (mpis == NULL) 139 if (mpis == NULL)
140 { 140 {
141 gnutls_assert (); 141 MHD_gnutls_assert ();
142 return GNUTLS_E_NO_TEMPORARY_DH_PARAMS; 142 return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
143 } 143 }
144 144
145 p = mpis[0]; 145 p = mpis[0];
146 g = mpis[1]; 146 g = mpis[1];
147 147
148 ret = mhd_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p); 148 ret = MHD_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
149 149
150 return ret; 150 return ret;
151 151
152} 152}
153 153
154int 154int
155mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t session, opaque * data, 155MHD_gtls_proc_anon_server_kx (MHD_gtls_session_t session, opaque * data,
156 size_t _data_size) 156 size_t _data_size)
157{ 157{
158 158
@@ -160,17 +160,17 @@ mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t session, opaque * data,
160 160
161 /* set auth_info */ 161 /* set auth_info */
162 if ((ret = 162 if ((ret =
163 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON, 163 MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
164 sizeof (anon_auth_info_st), 1)) < 0) 164 sizeof (anon_auth_info_st), 1)) < 0)
165 { 165 {
166 gnutls_assert (); 166 MHD_gnutls_assert ();
167 return ret; 167 return ret;
168 } 168 }
169 169
170 ret = mhd_gtls_proc_dh_common_server_kx (session, data, _data_size, 0); 170 ret = MHD_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
171 if (ret < 0) 171 if (ret < 0)
172 { 172 {
173 gnutls_assert (); 173 MHD_gnutls_assert ();
174 return ret; 174 return ret;
175 } 175 }
176 176
diff --git a/src/daemon/https/tls/auth_anon.h b/src/daemon/https/tls/auth_anon.h
index ca5f3bfb..4602ab23 100644
--- a/src/daemon/https/tls/auth_anon.h
+++ b/src/daemon/https/tls/auth_anon.h
@@ -22,27 +22,27 @@
22 * 22 *
23 */ 23 */
24 24
25/* this is not to be included by gnutls_anon.c */ 25/* this is not to be included by MHD_gnutls_anon.c */
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 mhd_gtls_anon_server_credentials_st 29typedef struct MHD_gtls_anon_server_credentials_st
30{ 30{
31 mhd_gtls_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 MHD_gnutls_params_function *params_func;
36} mhd_anon_server_credentials_st; 36} mhd_anon_server_credentials_st;
37 37
38typedef struct mhd_gtls_anon_client_credentials_st 38typedef struct MHD_gtls_anon_client_credentials_st
39{ 39{
40 int dummy; 40 int dummy;
41} mhd_anon_client_credentials_st; 41} mhd_anon_client_credentials_st;
42 42
43typedef struct mhd_gtls_anon_auth_info_st 43typedef struct MHD_gtls_anon_auth_info_st
44{ 44{
45 mhd_gtls_dh_info_st dh; 45 MHD_gtls_dh_info_st dh;
46} *mhd_anon_auth_info_t; 46} *mhd_anon_auth_info_t;
47 47
48typedef struct mhd_gtls_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 7f0369ca..f3bbeba9 100644
--- a/src/daemon/https/tls/auth_cert.c
+++ b/src/daemon/https/tls/auth_cert.c
@@ -45,17 +45,17 @@
45#include <gnutls_x509.h> 45#include <gnutls_x509.h>
46#include "debug.h" 46#include "debug.h"
47 47
48static gnutls_cert *alloc_and_load_x509_certs (gnutls_x509_crt_t * certs, 48static MHD_gnutls_cert *alloc_and_load_x509_certs (MHD_gnutls_x509_crt_t * certs,
49 unsigned); 49 unsigned);
50static gnutls_privkey *alloc_and_load_x509_key (gnutls_x509_privkey_t key); 50static MHD_gnutls_privkey *alloc_and_load_x509_key (MHD_gnutls_x509_privkey_t key);
51 51
52 52
53/* Copies data from a internal certificate struct (gnutls_cert) to 53/* Copies data from a internal certificate struct (MHD_gnutls_cert) to
54 * exported certificate struct (cert_auth_info_t) 54 * exported certificate struct (cert_auth_info_t)
55 */ 55 */
56static int 56static int
57_gnutls_copy_certificate_auth_info (cert_auth_info_t info, 57MHD__gnutls_copy_certificate_auth_info (cert_auth_info_t info,
58 gnutls_cert * cert, int ncerts) 58 MHD_gnutls_cert * cert, int ncerts)
59{ 59{
60 /* Copy peer's information to auth_info_t 60 /* Copy peer's information to auth_info_t
61 */ 61 */
@@ -69,10 +69,10 @@ _gnutls_copy_certificate_auth_info (cert_auth_info_t info,
69 } 69 }
70 70
71 info->raw_certificate_list = 71 info->raw_certificate_list =
72 gnutls_calloc (1, sizeof (gnutls_datum_t) * ncerts); 72 MHD_gnutls_calloc (1, sizeof (MHD_gnutls_datum_t) * ncerts);
73 if (info->raw_certificate_list == NULL) 73 if (info->raw_certificate_list == NULL)
74 { 74 {
75 gnutls_assert (); 75 MHD_gnutls_assert ();
76 return GNUTLS_E_MEMORY_ERROR; 76 return GNUTLS_E_MEMORY_ERROR;
77 } 77 }
78 78
@@ -81,11 +81,11 @@ _gnutls_copy_certificate_auth_info (cert_auth_info_t info,
81 if (cert->raw.size > 0) 81 if (cert->raw.size > 0)
82 { 82 {
83 ret = 83 ret =
84 _gnutls_set_datum (&info->raw_certificate_list[i], 84 MHD__gnutls_set_datum (&info->raw_certificate_list[i],
85 cert[i].raw.data, cert[i].raw.size); 85 cert[i].raw.data, cert[i].raw.size);
86 if (ret < 0) 86 if (ret < 0)
87 { 87 {
88 gnutls_assert (); 88 MHD_gnutls_assert ();
89 goto clear; 89 goto clear;
90 } 90 }
91 } 91 }
@@ -97,9 +97,9 @@ _gnutls_copy_certificate_auth_info (cert_auth_info_t info,
97clear: 97clear:
98 98
99 for (j = 0; j < i; j++) 99 for (j = 0; j < i; j++)
100 _gnutls_free_datum (&info->raw_certificate_list[j]); 100 MHD__gnutls_free_datum (&info->raw_certificate_list[j]);
101 101
102 gnutls_free (info->raw_certificate_list); 102 MHD_gnutls_free (info->raw_certificate_list);
103 info->raw_certificate_list = NULL; 103 info->raw_certificate_list = NULL;
104 104
105 return ret; 105 return ret;
@@ -112,7 +112,7 @@ clear:
112 * -1 otherwise. 112 * -1 otherwise.
113 */ 113 */
114inline static int 114inline static int
115_gnutls_check_pk_algo_in_list (const enum MHD_GNUTLS_PublicKeyAlgorithm 115MHD__gnutls_check_pk_algo_in_list (const enum MHD_GNUTLS_PublicKeyAlgorithm
116 *pk_algos, int pk_algos_length, 116 *pk_algos, int pk_algos_length,
117 enum MHD_GNUTLS_PublicKeyAlgorithm 117 enum MHD_GNUTLS_PublicKeyAlgorithm
118 algo_to_check) 118 algo_to_check)
@@ -133,39 +133,39 @@ _gnutls_check_pk_algo_in_list (const enum MHD_GNUTLS_PublicKeyAlgorithm
133 * specified in cert. 133 * specified in cert.
134 */ 134 */
135static int 135static int
136_gnutls_cert_get_issuer_dn (gnutls_cert * cert, gnutls_datum_t * odn) 136MHD__gnutls_cert_get_issuer_dn (MHD_gnutls_cert * cert, MHD_gnutls_datum_t * odn)
137{ 137{
138 ASN1_TYPE dn; 138 ASN1_TYPE dn;
139 int len, result; 139 int len, result;
140 int start, end; 140 int start, end;
141 141
142 if ((result = asn1_create_element 142 if ((result = MHD__asn1_create_element
143 (_gnutls_get_pkix (), "PKIX1.Certificate", &dn)) != ASN1_SUCCESS) 143 (MHD__gnutls_get_pkix (), "PKIX1.Certificate", &dn)) != ASN1_SUCCESS)
144 { 144 {
145 gnutls_assert (); 145 MHD_gnutls_assert ();
146 return mhd_gtls_asn2err (result); 146 return MHD_gtls_asn2err (result);
147 } 147 }
148 148
149 result = asn1_der_decoding (&dn, cert->raw.data, cert->raw.size, NULL); 149 result = MHD__asn1_der_decoding (&dn, cert->raw.data, cert->raw.size, NULL);
150 if (result != ASN1_SUCCESS) 150 if (result != ASN1_SUCCESS)
151 { 151 {
152 /* couldn't decode DER */ 152 /* couldn't decode DER */
153 gnutls_assert (); 153 MHD_gnutls_assert ();
154 asn1_delete_structure (&dn); 154 MHD__asn1_delete_structure (&dn);
155 return mhd_gtls_asn2err (result); 155 return MHD_gtls_asn2err (result);
156 } 156 }
157 157
158 result = asn1_der_decoding_startEnd (dn, cert->raw.data, cert->raw.size, 158 result = MHD__asn1_der_decoding_startEnd (dn, cert->raw.data, cert->raw.size,
159 "tbsCertificate.issuer", &start, &end); 159 "tbsCertificate.issuer", &start, &end);
160 160
161 if (result != ASN1_SUCCESS) 161 if (result != ASN1_SUCCESS)
162 { 162 {
163 /* couldn't decode DER */ 163 /* couldn't decode DER */
164 gnutls_assert (); 164 MHD_gnutls_assert ();
165 asn1_delete_structure (&dn); 165 MHD__asn1_delete_structure (&dn);
166 return mhd_gtls_asn2err (result); 166 return MHD_gtls_asn2err (result);
167 } 167 }
168 asn1_delete_structure (&dn); 168 MHD__asn1_delete_structure (&dn);
169 169
170 len = end - start + 1; 170 len = end - start + 1;
171 171
@@ -183,13 +183,13 @@ _gnutls_cert_get_issuer_dn (gnutls_cert * cert, gnutls_datum_t * odn)
183 * CAs and sign algorithms supported by the peer server. 183 * CAs and sign algorithms supported by the peer server.
184 */ 184 */
185static int 185static int
186_find_x509_cert (const mhd_gtls_cert_credentials_t cred, 186_find_x509_cert (const MHD_gtls_cert_credentials_t cred,
187 opaque * _data, size_t _data_size, 187 opaque * _data, size_t _data_size,
188 const enum MHD_GNUTLS_PublicKeyAlgorithm *pk_algos, 188 const enum MHD_GNUTLS_PublicKeyAlgorithm *pk_algos,
189 int pk_algos_length, int *indx) 189 int pk_algos_length, int *indx)
190{ 190{
191 unsigned size; 191 unsigned size;
192 gnutls_datum_t odn; 192 MHD_gnutls_datum_t odn;
193 opaque *data = _data; 193 opaque *data = _data;
194 ssize_t data_size = _data_size; 194 ssize_t data_size = _data_size;
195 unsigned i, j; 195 unsigned i, j;
@@ -201,7 +201,7 @@ _find_x509_cert (const mhd_gtls_cert_credentials_t cred,
201 { 201 {
202 202
203 DECR_LENGTH_RET (data_size, 2, 0); 203 DECR_LENGTH_RET (data_size, 2, 0);
204 size = mhd_gtls_read_uint16 (data); 204 size = MHD_gtls_read_uint16 (data);
205 DECR_LENGTH_RET (data_size, size, 0); 205 DECR_LENGTH_RET (data_size, size, 0);
206 data += 2; 206 data += 2;
207 207
@@ -210,10 +210,10 @@ _find_x509_cert (const mhd_gtls_cert_credentials_t cred,
210 for (j = 0; j < cred->cert_list_length[i]; j++) 210 for (j = 0; j < cred->cert_list_length[i]; j++)
211 { 211 {
212 if ((result = 212 if ((result =
213 _gnutls_cert_get_issuer_dn (&cred->cert_list[i][j], 213 MHD__gnutls_cert_get_issuer_dn (&cred->cert_list[i][j],
214 &odn)) < 0) 214 &odn)) < 0)
215 { 215 {
216 gnutls_assert (); 216 MHD_gnutls_assert ();
217 return result; 217 return result;
218 } 218 }
219 219
@@ -227,7 +227,7 @@ _find_x509_cert (const mhd_gtls_cert_credentials_t cred,
227 cert_pk = cred->cert_list[i][0].subject_pk_algorithm; 227 cert_pk = cred->cert_list[i][0].subject_pk_algorithm;
228 228
229 if ((memcmp (odn.data, data, size) == 0) && 229 if ((memcmp (odn.data, data, size) == 0) &&
230 (_gnutls_check_pk_algo_in_list 230 (MHD__gnutls_check_pk_algo_in_list
231 (pk_algos, pk_algos_length, cert_pk) == 0)) 231 (pk_algos, pk_algos_length, cert_pk) == 0))
232 { 232 {
233 *indx = i; 233 *indx = i;
@@ -255,7 +255,7 @@ _find_x509_cert (const mhd_gtls_cert_credentials_t cred,
255 * certificate request packet. 255 * certificate request packet.
256 */ 256 */
257static int 257static int
258get_issuers_num (mhd_gtls_session_t session, opaque * data, ssize_t data_size) 258get_issuers_num (MHD_gtls_session_t session, opaque * data, ssize_t data_size)
259{ 259{
260 int issuers_dn_len = 0, result; 260 int issuers_dn_len = 0, result;
261 unsigned size; 261 unsigned size;
@@ -275,7 +275,7 @@ get_issuers_num (mhd_gtls_session_t session, opaque * data, ssize_t data_size)
275 */ 275 */
276 result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 276 result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
277 DECR_LENGTH_COM (data_size, 2, goto error); 277 DECR_LENGTH_COM (data_size, 2, goto error);
278 size = mhd_gtls_read_uint16 (data); 278 size = MHD_gtls_read_uint16 (data);
279 279
280 result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 280 result = GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
281 DECR_LENGTH_COM (data_size, size, goto error); 281 DECR_LENGTH_COM (data_size, size, goto error);
@@ -304,14 +304,14 @@ error:
304 * packet. 304 * packet.
305 */ 305 */
306static int 306static int
307get_issuers (mhd_gtls_session_t session, 307get_issuers (MHD_gtls_session_t session,
308 gnutls_datum_t * issuers_dn, int issuers_len, 308 MHD_gnutls_datum_t * issuers_dn, int issuers_len,
309 opaque * data, size_t data_size) 309 opaque * data, size_t data_size)
310{ 310{
311 int i; 311 int i;
312 unsigned size; 312 unsigned size;
313 313
314 if (gnutls_certificate_type_get (session) != MHD_GNUTLS_CRT_X509) 314 if (MHD_gnutls_certificate_type_get (session) != MHD_GNUTLS_CRT_X509)
315 return 0; 315 return 0;
316 316
317 /* put the requested DNs to req_dn, only in case 317 /* put the requested DNs to req_dn, only in case
@@ -328,7 +328,7 @@ get_issuers (mhd_gtls_session_t session,
328 */ 328 */
329 data_size -= 2; 329 data_size -= 2;
330 330
331 size = mhd_gtls_read_uint16 (data); 331 size = MHD_gtls_read_uint16 (data);
332 332
333 data += 2; 333 data += 2;
334 334
@@ -345,26 +345,26 @@ get_issuers (mhd_gtls_session_t session,
345/* Calls the client get callback. 345/* Calls the client get callback.
346 */ 346 */
347static int 347static int
348call_get_cert_callback (mhd_gtls_session_t session, 348call_get_cert_callback (MHD_gtls_session_t session,
349 gnutls_datum_t * issuers_dn, 349 MHD_gnutls_datum_t * issuers_dn,
350 int issuers_dn_length, 350 int issuers_dn_length,
351 enum MHD_GNUTLS_PublicKeyAlgorithm *pk_algos, 351 enum MHD_GNUTLS_PublicKeyAlgorithm *pk_algos,
352 int pk_algos_length) 352 int pk_algos_length)
353{ 353{
354 unsigned i; 354 unsigned i;
355 gnutls_cert *local_certs = NULL; 355 MHD_gnutls_cert *local_certs = NULL;
356 gnutls_privkey *local_key = NULL; 356 MHD_gnutls_privkey *local_key = NULL;
357 gnutls_retr_st st; 357 MHD_gnutls_retr_st st;
358 int ret; 358 int ret;
359 enum MHD_GNUTLS_CertificateType type = 359 enum MHD_GNUTLS_CertificateType type =
360 gnutls_certificate_type_get (session); 360 MHD_gnutls_certificate_type_get (session);
361 mhd_gtls_cert_credentials_t cred; 361 MHD_gtls_cert_credentials_t cred;
362 362
363 cred = (mhd_gtls_cert_credentials_t) 363 cred = (MHD_gtls_cert_credentials_t)
364 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 364 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
365 if (cred == NULL) 365 if (cred == NULL)
366 { 366 {
367 gnutls_assert (); 367 MHD_gnutls_assert ();
368 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 368 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
369 } 369 }
370 370
@@ -384,7 +384,7 @@ call_get_cert_callback (mhd_gtls_session_t session,
384 384
385 if (ret < 0) 385 if (ret < 0)
386 { 386 {
387 gnutls_assert (); 387 MHD_gnutls_assert ();
388 return GNUTLS_E_INTERNAL_ERROR; 388 return GNUTLS_E_INTERNAL_ERROR;
389 } 389 }
390 390
@@ -393,7 +393,7 @@ call_get_cert_callback (mhd_gtls_session_t session,
393 393
394 if (type != st.type) 394 if (type != st.type)
395 { 395 {
396 gnutls_assert (); 396 MHD_gnutls_assert ();
397 ret = GNUTLS_E_INVALID_REQUEST; 397 ret = GNUTLS_E_INVALID_REQUEST;
398 goto cleanup; 398 goto cleanup;
399 } 399 }
@@ -407,12 +407,12 @@ call_get_cert_callback (mhd_gtls_session_t session,
407 } 407 }
408 else 408 else
409 { /* PGP */ 409 { /* PGP */
410 gnutls_assert (); 410 MHD_gnutls_assert ();
411 ret = GNUTLS_E_INVALID_REQUEST; 411 ret = GNUTLS_E_INVALID_REQUEST;
412 goto cleanup; 412 goto cleanup;
413 } 413 }
414 414
415 mhd_gtls_selected_certs_set (session, local_certs, 415 MHD_gtls_selected_certs_set (session, local_certs,
416 (local_certs != NULL) ? st.ncerts : 0, 416 (local_certs != NULL) ? st.ncerts : 0,
417 local_key, 1); 417 local_key, 1);
418 418
@@ -426,10 +426,10 @@ cleanup:
426 { 426 {
427 for (i = 0; i < st.ncerts; i++) 427 for (i = 0; i < st.ncerts; i++)
428 { 428 {
429 gnutls_x509_crt_deinit (st.cert.x509[i]); 429 MHD_gnutls_x509_crt_deinit (st.cert.x509[i]);
430 } 430 }
431 gnutls_free (st.cert.x509); 431 MHD_gnutls_free (st.cert.x509);
432 gnutls_x509_privkey_deinit (st.key.x509); 432 MHD_gnutls_x509_privkey_deinit (st.key.x509);
433 } 433 }
434 } 434 }
435 return ret; 435 return ret;
@@ -443,24 +443,24 @@ cleanup:
443 * algorithm (only in automatic mode). 443 * algorithm (only in automatic mode).
444 */ 444 */
445static int 445static int
446_select_client_cert (mhd_gtls_session_t session, 446_select_client_cert (MHD_gtls_session_t session,
447 opaque * _data, size_t _data_size, 447 opaque * _data, size_t _data_size,
448 enum MHD_GNUTLS_PublicKeyAlgorithm *pk_algos, 448 enum MHD_GNUTLS_PublicKeyAlgorithm *pk_algos,
449 int pk_algos_length) 449 int pk_algos_length)
450{ 450{
451 int result; 451 int result;
452 int indx = -1; 452 int indx = -1;
453 mhd_gtls_cert_credentials_t cred; 453 MHD_gtls_cert_credentials_t cred;
454 opaque *data = _data; 454 opaque *data = _data;
455 ssize_t data_size = _data_size; 455 ssize_t data_size = _data_size;
456 int issuers_dn_length; 456 int issuers_dn_length;
457 gnutls_datum_t *issuers_dn = NULL; 457 MHD_gnutls_datum_t *issuers_dn = NULL;
458 458
459 cred = (mhd_gtls_cert_credentials_t) 459 cred = (MHD_gtls_cert_credentials_t)
460 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 460 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
461 if (cred == NULL) 461 if (cred == NULL)
462 { 462 {
463 gnutls_assert (); 463 MHD_gnutls_assert ();
464 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 464 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
465 } 465 }
466 466
@@ -476,17 +476,17 @@ _select_client_cert (mhd_gtls_session_t session,
476 issuers_dn_length = get_issuers_num (session, data, data_size); 476 issuers_dn_length = get_issuers_num (session, data, data_size);
477 if (issuers_dn_length < 0) 477 if (issuers_dn_length < 0)
478 { 478 {
479 gnutls_assert (); 479 MHD_gnutls_assert ();
480 return issuers_dn_length; 480 return issuers_dn_length;
481 } 481 }
482 482
483 if (issuers_dn_length > 0) 483 if (issuers_dn_length > 0)
484 { 484 {
485 issuers_dn = 485 issuers_dn =
486 gnutls_malloc (sizeof (gnutls_datum_t) * issuers_dn_length); 486 MHD_gnutls_malloc (sizeof (MHD_gnutls_datum_t) * issuers_dn_length);
487 if (issuers_dn == NULL) 487 if (issuers_dn == NULL)
488 { 488 {
489 gnutls_assert (); 489 MHD_gnutls_assert ();
490 return GNUTLS_E_MEMORY_ERROR; 490 return GNUTLS_E_MEMORY_ERROR;
491 } 491 }
492 492
@@ -495,7 +495,7 @@ _select_client_cert (mhd_gtls_session_t session,
495 data, data_size); 495 data, data_size);
496 if (result < 0) 496 if (result < 0)
497 { 497 {
498 gnutls_assert (); 498 MHD_gnutls_assert ();
499 goto cleanup; 499 goto cleanup;
500 } 500 }
501 } 501 }
@@ -519,27 +519,27 @@ _select_client_cert (mhd_gtls_session_t session,
519 pk_algos, pk_algos_length, &indx); 519 pk_algos, pk_algos_length, &indx);
520 if (result < 0) 520 if (result < 0)
521 { 521 {
522 gnutls_assert (); 522 MHD_gnutls_assert ();
523 return result; 523 return result;
524 } 524 }
525 525
526 if (indx >= 0) 526 if (indx >= 0)
527 { 527 {
528 mhd_gtls_selected_certs_set (session, 528 MHD_gtls_selected_certs_set (session,
529 &cred->cert_list[indx][0], 529 &cred->cert_list[indx][0],
530 cred->cert_list_length[indx], 530 cred->cert_list_length[indx],
531 &cred->pkey[indx], 0); 531 &cred->pkey[indx], 0);
532 } 532 }
533 else 533 else
534 { 534 {
535 mhd_gtls_selected_certs_set (session, NULL, 0, NULL, 0); 535 MHD_gtls_selected_certs_set (session, NULL, 0, NULL, 0);
536 } 536 }
537 537
538 result = 0; 538 result = 0;
539 } 539 }
540 540
541cleanup: 541cleanup:
542 gnutls_free (issuers_dn); 542 MHD_gnutls_free (issuers_dn);
543 return result; 543 return result;
544 544
545} 545}
@@ -548,21 +548,21 @@ cleanup:
548 */ 548 */
549 549
550int 550int
551mhd_gtls_gen_x509_crt (mhd_gtls_session_t session, opaque ** data) 551MHD_gtls_gen_x509_crt (MHD_gtls_session_t session, opaque ** data)
552{ 552{
553 int ret, i; 553 int ret, i;
554 opaque *pdata; 554 opaque *pdata;
555 gnutls_cert *apr_cert_list; 555 MHD_gnutls_cert *apr_cert_list;
556 gnutls_privkey *apr_pkey; 556 MHD_gnutls_privkey *apr_pkey;
557 int apr_cert_list_length; 557 int apr_cert_list_length;
558 558
559 /* find the appropriate certificate 559 /* find the appropriate certificate
560 */ 560 */
561 if ((ret = 561 if ((ret =
562 mhd_gtls_get_selected_cert (session, &apr_cert_list, 562 MHD_gtls_get_selected_cert (session, &apr_cert_list,
563 &apr_cert_list_length, &apr_pkey)) < 0) 563 &apr_cert_list_length, &apr_pkey)) < 0)
564 { 564 {
565 gnutls_assert (); 565 MHD_gnutls_assert ();
566 return ret; 566 return ret;
567 } 567 }
568 568
@@ -583,19 +583,19 @@ mhd_gtls_gen_x509_crt (mhd_gtls_session_t session, opaque ** data)
583 * the one produced here ) 583 * the one produced here )
584 */ 584 */
585 585
586 (*data) = gnutls_malloc (ret); 586 (*data) = MHD_gnutls_malloc (ret);
587 pdata = (*data); 587 pdata = (*data);
588 588
589 if (pdata == NULL) 589 if (pdata == NULL)
590 { 590 {
591 gnutls_assert (); 591 MHD_gnutls_assert ();
592 return GNUTLS_E_MEMORY_ERROR; 592 return GNUTLS_E_MEMORY_ERROR;
593 } 593 }
594 mhd_gtls_write_uint24 (ret - 3, pdata); 594 MHD_gtls_write_uint24 (ret - 3, pdata);
595 pdata += 3; 595 pdata += 3;
596 for (i = 0; i < apr_cert_list_length; i++) 596 for (i = 0; i < apr_cert_list_length; i++)
597 { 597 {
598 mhd_gtls_write_datum24 (pdata, apr_cert_list[i].raw); 598 MHD_gtls_write_datum24 (pdata, apr_cert_list[i].raw);
599 pdata += (3 + apr_cert_list[i].raw.size); 599 pdata += (3 + apr_cert_list[i].raw.size);
600 } 600 }
601 601
@@ -603,30 +603,30 @@ mhd_gtls_gen_x509_crt (mhd_gtls_session_t session, opaque ** data)
603} 603}
604 604
605int 605int
606mhd_gtls_gen_cert_client_certificate (mhd_gtls_session_t session, 606MHD_gtls_gen_cert_client_certificate (MHD_gtls_session_t session,
607 opaque ** data) 607 opaque ** data)
608{ 608{
609 switch (session->security_parameters.cert_type) 609 switch (session->security_parameters.cert_type)
610 { 610 {
611 case MHD_GNUTLS_CRT_X509: 611 case MHD_GNUTLS_CRT_X509:
612 return mhd_gtls_gen_x509_crt (session, data); 612 return MHD_gtls_gen_x509_crt (session, data);
613 613
614 default: 614 default:
615 gnutls_assert (); 615 MHD_gnutls_assert ();
616 return GNUTLS_E_INTERNAL_ERROR; 616 return GNUTLS_E_INTERNAL_ERROR;
617 } 617 }
618} 618}
619 619
620int 620int
621mhd_gtls_gen_cert_server_certificate (mhd_gtls_session_t session, 621MHD_gtls_gen_cert_server_certificate (MHD_gtls_session_t session,
622 opaque ** data) 622 opaque ** data)
623{ 623{
624 switch (session->security_parameters.cert_type) 624 switch (session->security_parameters.cert_type)
625 { 625 {
626 case MHD_GNUTLS_CRT_X509: 626 case MHD_GNUTLS_CRT_X509:
627 return mhd_gtls_gen_x509_crt (session, data); 627 return MHD_gtls_gen_x509_crt (session, data);
628 default: 628 default:
629 gnutls_assert (); 629 MHD_gnutls_assert ();
630 return GNUTLS_E_INTERNAL_ERROR; 630 return GNUTLS_E_INTERNAL_ERROR;
631 } 631 }
632} 632}
@@ -634,49 +634,49 @@ mhd_gtls_gen_cert_server_certificate (mhd_gtls_session_t session,
634/* Process server certificate 634/* Process server certificate
635 */ 635 */
636 636
637#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) mhd_gtls_gcert_deinit(&peer_certificate_list[x]) 637#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) MHD_gtls_gcert_deinit(&peer_certificate_list[x])
638int 638int
639mhd_gtls_proc_x509_server_certificate (mhd_gtls_session_t session, 639MHD_gtls_proc_x509_server_certificate (MHD_gtls_session_t session,
640 opaque * data, size_t data_size) 640 opaque * data, size_t data_size)
641{ 641{
642 int size, len, ret; 642 int size, len, ret;
643 opaque *p = data; 643 opaque *p = data;
644 cert_auth_info_t info; 644 cert_auth_info_t info;
645 mhd_gtls_cert_credentials_t cred; 645 MHD_gtls_cert_credentials_t cred;
646 ssize_t dsize = data_size; 646 ssize_t dsize = data_size;
647 int i, j, x; 647 int i, j, x;
648 gnutls_cert *peer_certificate_list; 648 MHD_gnutls_cert *peer_certificate_list;
649 int peer_certificate_list_size = 0; 649 int peer_certificate_list_size = 0;
650 gnutls_datum_t tmp; 650 MHD_gnutls_datum_t tmp;
651 651
652 cred = (mhd_gtls_cert_credentials_t) 652 cred = (MHD_gtls_cert_credentials_t)
653 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 653 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
654 if (cred == NULL) 654 if (cred == NULL)
655 { 655 {
656 gnutls_assert (); 656 MHD_gnutls_assert ();
657 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 657 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
658 } 658 }
659 659
660 660
661 if ((ret = 661 if ((ret =
662 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 662 MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
663 sizeof (cert_auth_info_st), 1)) < 0) 663 sizeof (cert_auth_info_st), 1)) < 0)
664 { 664 {
665 gnutls_assert (); 665 MHD_gnutls_assert ();
666 return ret; 666 return ret;
667 } 667 }
668 668
669 info = mhd_gtls_get_auth_info (session); 669 info = MHD_gtls_get_auth_info (session);
670 670
671 if (data == NULL || data_size == 0) 671 if (data == NULL || data_size == 0)
672 { 672 {
673 gnutls_assert (); 673 MHD_gnutls_assert ();
674 /* no certificate was sent */ 674 /* no certificate was sent */
675 return GNUTLS_E_NO_CERTIFICATE_FOUND; 675 return GNUTLS_E_NO_CERTIFICATE_FOUND;
676 } 676 }
677 677
678 DECR_LEN (dsize, 3); 678 DECR_LEN (dsize, 3);
679 size = mhd_gtls_read_uint24 (p); 679 size = MHD_gtls_read_uint24 (p);
680 p += 3; 680 p += 3;
681 681
682 /* some implementations send 0B 00 00 06 00 00 03 00 00 00 682 /* some implementations send 0B 00 00 06 00 00 03 00 00 00
@@ -684,7 +684,7 @@ mhd_gtls_proc_x509_server_certificate (mhd_gtls_session_t session,
684 */ 684 */
685 if (size == 0 || size == 3) 685 if (size == 0 || size == 3)
686 { 686 {
687 gnutls_assert (); 687 MHD_gnutls_assert ();
688 /* no certificate was sent */ 688 /* no certificate was sent */
689 return GNUTLS_E_NO_CERTIFICATE_FOUND; 689 return GNUTLS_E_NO_CERTIFICATE_FOUND;
690 } 690 }
@@ -693,7 +693,7 @@ mhd_gtls_proc_x509_server_certificate (mhd_gtls_session_t session,
693 while (i > 0) 693 while (i > 0)
694 { 694 {
695 DECR_LEN (dsize, 3); 695 DECR_LEN (dsize, 3);
696 len = mhd_gtls_read_uint24 (p); 696 len = MHD_gtls_read_uint24 (p);
697 p += 3; 697 p += 3;
698 DECR_LEN (dsize, len); 698 DECR_LEN (dsize, len);
699 peer_certificate_list_size++; 699 peer_certificate_list_size++;
@@ -703,7 +703,7 @@ mhd_gtls_proc_x509_server_certificate (mhd_gtls_session_t session,
703 703
704 if (peer_certificate_list_size == 0) 704 if (peer_certificate_list_size == 0)
705 { 705 {
706 gnutls_assert (); 706 MHD_gnutls_assert ();
707 return GNUTLS_E_NO_CERTIFICATE_FOUND; 707 return GNUTLS_E_NO_CERTIFICATE_FOUND;
708 } 708 }
709 709
@@ -712,14 +712,14 @@ mhd_gtls_proc_x509_server_certificate (mhd_gtls_session_t session,
712 */ 712 */
713 713
714 peer_certificate_list = 714 peer_certificate_list =
715 gnutls_malloc (sizeof (gnutls_cert) * (peer_certificate_list_size)); 715 MHD_gnutls_malloc (sizeof (MHD_gnutls_cert) * (peer_certificate_list_size));
716 716
717 if (peer_certificate_list == NULL) 717 if (peer_certificate_list == NULL)
718 { 718 {
719 gnutls_assert (); 719 MHD_gnutls_assert ();
720 return GNUTLS_E_MEMORY_ERROR; 720 return GNUTLS_E_MEMORY_ERROR;
721 } 721 }
722 memset (peer_certificate_list, 0, sizeof (gnutls_cert) * 722 memset (peer_certificate_list, 0, sizeof (MHD_gnutls_cert) *
723 peer_certificate_list_size); 723 peer_certificate_list_size);
724 724
725 p = data + 3; 725 p = data + 3;
@@ -731,18 +731,18 @@ mhd_gtls_proc_x509_server_certificate (mhd_gtls_session_t session,
731 731
732 for (j = 0; j < peer_certificate_list_size; j++) 732 for (j = 0; j < peer_certificate_list_size; j++)
733 { 733 {
734 len = mhd_gtls_read_uint24 (p); 734 len = MHD_gtls_read_uint24 (p);
735 p += 3; 735 p += 3;
736 736
737 tmp.size = len; 737 tmp.size = len;
738 tmp.data = p; 738 tmp.data = p;
739 739
740 if ((ret = 740 if ((ret =
741 mhd_gtls_x509_raw_cert_to_gcert (&peer_certificate_list 741 MHD_gtls_x509_raw_cert_to_gcert (&peer_certificate_list
742 [j], &tmp, 742 [j], &tmp,
743 CERT_ONLY_EXTENSIONS)) < 0) 743 CERT_ONLY_EXTENSIONS)) < 0)
744 { 744 {
745 gnutls_assert (); 745 MHD_gnutls_assert ();
746 goto cleanup; 746 goto cleanup;
747 } 747 }
748 748
@@ -751,19 +751,19 @@ mhd_gtls_proc_x509_server_certificate (mhd_gtls_session_t session,
751 751
752 752
753 if ((ret = 753 if ((ret =
754 _gnutls_copy_certificate_auth_info (info, 754 MHD__gnutls_copy_certificate_auth_info (info,
755 peer_certificate_list, 755 peer_certificate_list,
756 peer_certificate_list_size)) < 0) 756 peer_certificate_list_size)) < 0)
757 { 757 {
758 gnutls_assert (); 758 MHD_gnutls_assert ();
759 goto cleanup; 759 goto cleanup;
760 } 760 }
761 761
762 if ((ret = 762 if ((ret =
763 _gnutls_check_key_usage (&peer_certificate_list[0], 763 MHD__gnutls_check_key_usage (&peer_certificate_list[0],
764 gnutls_kx_get (session))) < 0) 764 MHD_gnutls_kx_get (session))) < 0)
765 { 765 {
766 gnutls_assert (); 766 MHD_gnutls_assert ();
767 goto cleanup; 767 goto cleanup;
768 } 768 }
769 769
@@ -771,23 +771,23 @@ mhd_gtls_proc_x509_server_certificate (mhd_gtls_session_t session,
771 771
772cleanup: 772cleanup:
773 CLEAR_CERTS; 773 CLEAR_CERTS;
774 gnutls_free (peer_certificate_list); 774 MHD_gnutls_free (peer_certificate_list);
775 return ret; 775 return ret;
776 776
777} 777}
778 778
779#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) mhd_gtls_gcert_deinit(&peer_certificate_list[x]) 779#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) MHD_gtls_gcert_deinit(&peer_certificate_list[x])
780 780
781int 781int
782mhd_gtls_proc_cert_server_certificate (mhd_gtls_session_t session, 782MHD_gtls_proc_cert_server_certificate (MHD_gtls_session_t session,
783 opaque * data, size_t data_size) 783 opaque * data, size_t data_size)
784{ 784{
785 switch (session->security_parameters.cert_type) 785 switch (session->security_parameters.cert_type)
786 { 786 {
787 case MHD_GNUTLS_CRT_X509: 787 case MHD_GNUTLS_CRT_X509:
788 return mhd_gtls_proc_x509_server_certificate (session, data, data_size); 788 return MHD_gtls_proc_x509_server_certificate (session, data, data_size);
789 default: 789 default:
790 gnutls_assert (); 790 MHD_gnutls_assert ();
791 return GNUTLS_E_INTERNAL_ERROR; 791 return GNUTLS_E_INTERNAL_ERROR;
792 } 792 }
793} 793}
@@ -802,7 +802,7 @@ typedef enum CertificateSigType
802 * if true; 802 * if true;
803 */ 803 */
804inline static int 804inline static int
805_gnutls_check_supported_sign_algo (CertificateSigType algo) 805MHD__gnutls_check_supported_sign_algo (CertificateSigType algo)
806{ 806{
807 switch (algo) 807 switch (algo)
808 { 808 {
@@ -814,31 +814,31 @@ _gnutls_check_supported_sign_algo (CertificateSigType algo)
814} 814}
815 815
816int 816int
817mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data, 817MHD_gtls_proc_cert_cert_req (MHD_gtls_session_t session, opaque * data,
818 size_t data_size) 818 size_t data_size)
819{ 819{
820 int size, ret; 820 int size, ret;
821 opaque *p; 821 opaque *p;
822 mhd_gtls_cert_credentials_t cred; 822 MHD_gtls_cert_credentials_t cred;
823 ssize_t dsize; 823 ssize_t dsize;
824 int i, j; 824 int i, j;
825 enum MHD_GNUTLS_PublicKeyAlgorithm pk_algos[MAX_SIGN_ALGOS]; 825 enum MHD_GNUTLS_PublicKeyAlgorithm pk_algos[MAX_SIGN_ALGOS];
826 int pk_algos_length; 826 int pk_algos_length;
827 enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); 827 enum MHD_GNUTLS_Protocol ver = MHD__gnutls_protocol_get_version (session);
828 828
829 cred = (mhd_gtls_cert_credentials_t) 829 cred = (MHD_gtls_cert_credentials_t)
830 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 830 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
831 if (cred == NULL) 831 if (cred == NULL)
832 { 832 {
833 gnutls_assert (); 833 MHD_gnutls_assert ();
834 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 834 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
835 } 835 }
836 836
837 if ((ret = 837 if ((ret =
838 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 838 MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
839 sizeof (cert_auth_info_st), 0)) < 0) 839 sizeof (cert_auth_info_st), 0)) < 0)
840 { 840 {
841 gnutls_assert (); 841 MHD_gnutls_assert ();
842 return ret; 842 return ret;
843 } 843 }
844 844
@@ -854,7 +854,7 @@ mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data,
854 for (i = 0; i < size; i++, p++) 854 for (i = 0; i < size; i++, p++)
855 { 855 {
856 DECR_LEN (dsize, 1); 856 DECR_LEN (dsize, 1);
857 if ((ret = _gnutls_check_supported_sign_algo (*p)) > 0) 857 if ((ret = MHD__gnutls_check_supported_sign_algo (*p)) > 0)
858 { 858 {
859 if (j < MAX_SIGN_ALGOS) 859 if (j < MAX_SIGN_ALGOS)
860 { 860 {
@@ -866,7 +866,7 @@ mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data,
866 866
867 if (pk_algos_length == 0) 867 if (pk_algos_length == 0)
868 { 868 {
869 gnutls_assert (); 869 MHD_gnutls_assert ();
870 return GNUTLS_E_UNKNOWN_PK_ALGORITHM; 870 return GNUTLS_E_UNKNOWN_PK_ALGORITHM;
871 } 871 }
872 872
@@ -885,7 +885,7 @@ mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data,
885 885
886 /* read the certificate authorities */ 886 /* read the certificate authorities */
887 DECR_LEN (dsize, 2); 887 DECR_LEN (dsize, 2);
888 size = mhd_gtls_read_uint16 (p); 888 size = MHD_gtls_read_uint16 (p);
889 p += 2; 889 p += 2;
890 890
891 DECR_LEN (dsize, size); 891 DECR_LEN (dsize, size);
@@ -896,7 +896,7 @@ mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data,
896 if ((ret = 896 if ((ret =
897 _select_client_cert (session, p, size, pk_algos, pk_algos_length)) < 0) 897 _select_client_cert (session, p, size, pk_algos, pk_algos_length)) < 0)
898 { 898 {
899 gnutls_assert (); 899 MHD_gnutls_assert ();
900 return ret; 900 return ret;
901 } 901 }
902 902
@@ -909,34 +909,34 @@ mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data,
909} 909}
910 910
911int 911int
912mhd_gtls_gen_cert_client_cert_vrfy (mhd_gtls_session_t session, 912MHD_gtls_gen_cert_client_cert_vrfy (MHD_gtls_session_t session,
913 opaque ** data) 913 opaque ** data)
914{ 914{
915 int ret; 915 int ret;
916 gnutls_cert *apr_cert_list; 916 MHD_gnutls_cert *apr_cert_list;
917 gnutls_privkey *apr_pkey; 917 MHD_gnutls_privkey *apr_pkey;
918 int apr_cert_list_length, size; 918 int apr_cert_list_length, size;
919 gnutls_datum_t signature; 919 MHD_gnutls_datum_t signature;
920 920
921 *data = NULL; 921 *data = NULL;
922 922
923 /* find the appropriate certificate */ 923 /* find the appropriate certificate */
924 if ((ret = 924 if ((ret =
925 mhd_gtls_get_selected_cert (session, &apr_cert_list, 925 MHD_gtls_get_selected_cert (session, &apr_cert_list,
926 &apr_cert_list_length, &apr_pkey)) < 0) 926 &apr_cert_list_length, &apr_pkey)) < 0)
927 { 927 {
928 gnutls_assert (); 928 MHD_gnutls_assert ();
929 return ret; 929 return ret;
930 } 930 }
931 931
932 if (apr_cert_list_length > 0) 932 if (apr_cert_list_length > 0)
933 { 933 {
934 if ((ret = 934 if ((ret =
935 mhd_gtls_tls_sign_hdata (session, 935 MHD_gtls_tls_sign_hdata (session,
936 &apr_cert_list[0], 936 &apr_cert_list[0],
937 apr_pkey, &signature)) < 0) 937 apr_pkey, &signature)) < 0)
938 { 938 {
939 gnutls_assert (); 939 MHD_gnutls_assert ();
940 return ret; 940 return ret;
941 } 941 }
942 } 942 }
@@ -945,42 +945,42 @@ mhd_gtls_gen_cert_client_cert_vrfy (mhd_gtls_session_t session,
945 return 0; 945 return 0;
946 } 946 }
947 947
948 *data = gnutls_malloc (signature.size + 2); 948 *data = MHD_gnutls_malloc (signature.size + 2);
949 if (*data == NULL) 949 if (*data == NULL)
950 { 950 {
951 _gnutls_free_datum (&signature); 951 MHD__gnutls_free_datum (&signature);
952 return GNUTLS_E_MEMORY_ERROR; 952 return GNUTLS_E_MEMORY_ERROR;
953 } 953 }
954 size = signature.size; 954 size = signature.size;
955 mhd_gtls_write_uint16 (size, *data); 955 MHD_gtls_write_uint16 (size, *data);
956 956
957 memcpy (&(*data)[2], signature.data, size); 957 memcpy (&(*data)[2], signature.data, size);
958 958
959 _gnutls_free_datum (&signature); 959 MHD__gnutls_free_datum (&signature);
960 960
961 return size + 2; 961 return size + 2;
962} 962}
963 963
964int 964int
965mhd_gtls_proc_cert_client_cert_vrfy (mhd_gtls_session_t session, 965MHD_gtls_proc_cert_client_cert_vrfy (MHD_gtls_session_t session,
966 opaque * data, size_t data_size) 966 opaque * data, size_t data_size)
967{ 967{
968 int size, ret; 968 int size, ret;
969 ssize_t dsize = data_size; 969 ssize_t dsize = data_size;
970 opaque *pdata = data; 970 opaque *pdata = data;
971 gnutls_datum_t sig; 971 MHD_gnutls_datum_t sig;
972 cert_auth_info_t info = mhd_gtls_get_auth_info (session); 972 cert_auth_info_t info = MHD_gtls_get_auth_info (session);
973 gnutls_cert peer_cert; 973 MHD_gnutls_cert peer_cert;
974 974
975 if (info == NULL || info->ncerts == 0) 975 if (info == NULL || info->ncerts == 0)
976 { 976 {
977 gnutls_assert (); 977 MHD_gnutls_assert ();
978 /* we need this in order to get peer's certificate */ 978 /* we need this in order to get peer's certificate */
979 return GNUTLS_E_INTERNAL_ERROR; 979 return GNUTLS_E_INTERNAL_ERROR;
980 } 980 }
981 981
982 DECR_LEN (dsize, 2); 982 DECR_LEN (dsize, 2);
983 size = mhd_gtls_read_uint16 (pdata); 983 size = MHD_gtls_read_uint16 (pdata);
984 pdata += 2; 984 pdata += 2;
985 985
986 DECR_LEN (dsize, size); 986 DECR_LEN (dsize, size);
@@ -988,47 +988,47 @@ mhd_gtls_proc_cert_client_cert_vrfy (mhd_gtls_session_t session,
988 sig.data = pdata; 988 sig.data = pdata;
989 sig.size = size; 989 sig.size = size;
990 990
991 ret = mhd_gtls_raw_cert_to_gcert (&peer_cert, 991 ret = MHD_gtls_raw_cert_to_gcert (&peer_cert,
992 session->security_parameters.cert_type, 992 session->security_parameters.cert_type,
993 &info->raw_certificate_list[0], 993 &info->raw_certificate_list[0],
994 CERT_NO_COPY); 994 CERT_NO_COPY);
995 995
996 if (ret < 0) 996 if (ret < 0)
997 { 997 {
998 gnutls_assert (); 998 MHD_gnutls_assert ();
999 return ret; 999 return ret;
1000 } 1000 }
1001 1001
1002 if ((ret = mhd_gtls_verify_sig_hdata (session, &peer_cert, &sig)) < 0) 1002 if ((ret = MHD_gtls_verify_sig_hdata (session, &peer_cert, &sig)) < 0)
1003 { 1003 {
1004 gnutls_assert (); 1004 MHD_gnutls_assert ();
1005 mhd_gtls_gcert_deinit (&peer_cert); 1005 MHD_gtls_gcert_deinit (&peer_cert);
1006 return ret; 1006 return ret;
1007 } 1007 }
1008 mhd_gtls_gcert_deinit (&peer_cert); 1008 MHD_gtls_gcert_deinit (&peer_cert);
1009 1009
1010 return 0; 1010 return 0;
1011} 1011}
1012 1012
1013#define CERTTYPE_SIZE 3 1013#define CERTTYPE_SIZE 3
1014int 1014int
1015mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t session, opaque ** data) 1015MHD_gtls_gen_cert_server_cert_req (MHD_gtls_session_t session, opaque ** data)
1016{ 1016{
1017 mhd_gtls_cert_credentials_t cred; 1017 MHD_gtls_cert_credentials_t cred;
1018 int size; 1018 int size;
1019 opaque *pdata; 1019 opaque *pdata;
1020 enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); 1020 enum MHD_GNUTLS_Protocol ver = MHD__gnutls_protocol_get_version (session);
1021 1021
1022 /* Now we need to generate the RDN sequence. This is 1022 /* Now we need to generate the RDN sequence. This is
1023 * already in the CERTIFICATE_CRED structure, to improve 1023 * already in the CERTIFICATE_CRED structure, to improve
1024 * performance. 1024 * performance.
1025 */ 1025 */
1026 1026
1027 cred = (mhd_gtls_cert_credentials_t) 1027 cred = (MHD_gtls_cert_credentials_t)
1028 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 1028 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
1029 if (cred == NULL) 1029 if (cred == NULL)
1030 { 1030 {
1031 gnutls_assert (); 1031 MHD_gnutls_assert ();
1032 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 1032 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
1033 } 1033 }
1034 1034
@@ -1044,12 +1044,12 @@ mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t session, opaque ** data)
1044 functions (see below). */ 1044 functions (see below). */
1045 size += 1; 1045 size += 1;
1046 1046
1047 (*data) = gnutls_malloc (size); 1047 (*data) = MHD_gnutls_malloc (size);
1048 pdata = (*data); 1048 pdata = (*data);
1049 1049
1050 if (pdata == NULL) 1050 if (pdata == NULL)
1051 { 1051 {
1052 gnutls_assert (); 1052 MHD_gnutls_assert ();
1053 return GNUTLS_E_MEMORY_ERROR; 1053 return GNUTLS_E_MEMORY_ERROR;
1054 } 1054 }
1055 1055
@@ -1069,12 +1069,12 @@ mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t session, opaque ** data)
1069 if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_X509 && 1069 if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_X509 &&
1070 session->internals.ignore_rdn_sequence == 0) 1070 session->internals.ignore_rdn_sequence == 0)
1071 { 1071 {
1072 mhd_gtls_write_datum16 (pdata, cred->x509_rdn_sequence); 1072 MHD_gtls_write_datum16 (pdata, cred->x509_rdn_sequence);
1073 /* pdata += cred->x509_rdn_sequence.size + 2; */ 1073 /* pdata += cred->x509_rdn_sequence.size + 2; */
1074 } 1074 }
1075 else 1075 else
1076 { 1076 {
1077 mhd_gtls_write_uint16 (0, pdata); 1077 MHD_gtls_write_uint16 (0, pdata);
1078 /* pdata+=2; */ 1078 /* pdata+=2; */
1079 } 1079 }
1080 1080
@@ -1090,10 +1090,10 @@ mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t session, opaque ** data)
1090 * 1090 *
1091 */ 1091 */
1092int 1092int
1093mhd_gtls_get_selected_cert (mhd_gtls_session_t session, 1093MHD_gtls_get_selected_cert (MHD_gtls_session_t session,
1094 gnutls_cert ** apr_cert_list, 1094 MHD_gnutls_cert ** apr_cert_list,
1095 int *apr_cert_list_length, 1095 int *apr_cert_list_length,
1096 gnutls_privkey ** apr_pkey) 1096 MHD_gnutls_privkey ** apr_pkey)
1097{ 1097{
1098 if (session->security_parameters.entity == GNUTLS_SERVER) 1098 if (session->security_parameters.entity == GNUTLS_SERVER)
1099 { 1099 {
@@ -1107,7 +1107,7 @@ mhd_gtls_get_selected_cert (mhd_gtls_session_t session,
1107 1107
1108 if (*apr_cert_list_length == 0 || *apr_cert_list == NULL) 1108 if (*apr_cert_list_length == 0 || *apr_cert_list == NULL)
1109 { 1109 {
1110 gnutls_assert (); 1110 MHD_gnutls_assert ();
1111 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 1111 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
1112 } 1112 }
1113 1113
@@ -1128,70 +1128,70 @@ mhd_gtls_get_selected_cert (mhd_gtls_session_t session,
1128 return 0; 1128 return 0;
1129} 1129}
1130 1130
1131/* converts the given x509 certificate to gnutls_cert* and allocates 1131/* converts the given x509 certificate to MHD_gnutls_cert* and allocates
1132 * space for them. 1132 * space for them.
1133 */ 1133 */
1134static gnutls_cert * 1134static MHD_gnutls_cert *
1135alloc_and_load_x509_certs (gnutls_x509_crt_t * certs, unsigned ncerts) 1135alloc_and_load_x509_certs (MHD_gnutls_x509_crt_t * certs, unsigned ncerts)
1136{ 1136{
1137 gnutls_cert *local_certs; 1137 MHD_gnutls_cert *local_certs;
1138 int ret = 0; 1138 int ret = 0;
1139 unsigned i, j; 1139 unsigned i, j;
1140 1140
1141 if (certs == NULL) 1141 if (certs == NULL)
1142 return NULL; 1142 return NULL;
1143 1143
1144 local_certs = gnutls_malloc (sizeof (gnutls_cert) * ncerts); 1144 local_certs = MHD_gnutls_malloc (sizeof (MHD_gnutls_cert) * ncerts);
1145 if (local_certs == NULL) 1145 if (local_certs == NULL)
1146 { 1146 {
1147 gnutls_assert (); 1147 MHD_gnutls_assert ();
1148 return NULL; 1148 return NULL;
1149 } 1149 }
1150 1150
1151 for (i = 0; i < ncerts; i++) 1151 for (i = 0; i < ncerts; i++)
1152 { 1152 {
1153 ret = mhd_gtls_x509_crt_to_gcert (&local_certs[i], certs[i], 0); 1153 ret = MHD_gtls_x509_crt_to_gcert (&local_certs[i], certs[i], 0);
1154 if (ret < 0) 1154 if (ret < 0)
1155 break; 1155 break;
1156 } 1156 }
1157 1157
1158 if (ret < 0) 1158 if (ret < 0)
1159 { 1159 {
1160 gnutls_assert (); 1160 MHD_gnutls_assert ();
1161 for (j = 0; j < i; j++) 1161 for (j = 0; j < i; j++)
1162 { 1162 {
1163 mhd_gtls_gcert_deinit (&local_certs[j]); 1163 MHD_gtls_gcert_deinit (&local_certs[j]);
1164 } 1164 }
1165 gnutls_free (local_certs); 1165 MHD_gnutls_free (local_certs);
1166 return NULL; 1166 return NULL;
1167 } 1167 }
1168 1168
1169 return local_certs; 1169 return local_certs;
1170} 1170}
1171 1171
1172/* converts the given x509 key to gnutls_privkey* and allocates 1172/* converts the given x509 key to MHD_gnutls_privkey* and allocates
1173 * space for it. 1173 * space for it.
1174 */ 1174 */
1175static gnutls_privkey * 1175static MHD_gnutls_privkey *
1176alloc_and_load_x509_key (gnutls_x509_privkey_t key) 1176alloc_and_load_x509_key (MHD_gnutls_x509_privkey_t key)
1177{ 1177{
1178 gnutls_privkey *local_key; 1178 MHD_gnutls_privkey *local_key;
1179 int ret = 0; 1179 int ret = 0;
1180 1180
1181 if (key == NULL) 1181 if (key == NULL)
1182 return NULL; 1182 return NULL;
1183 1183
1184 local_key = gnutls_malloc (sizeof (gnutls_privkey)); 1184 local_key = MHD_gnutls_malloc (sizeof (MHD_gnutls_privkey));
1185 if (local_key == NULL) 1185 if (local_key == NULL)
1186 { 1186 {
1187 gnutls_assert (); 1187 MHD_gnutls_assert ();
1188 return NULL; 1188 return NULL;
1189 } 1189 }
1190 1190
1191 ret = _gnutls_x509_privkey_to_gkey (local_key, key); 1191 ret = MHD__gnutls_x509_privkey_to_gkey (local_key, key);
1192 if (ret < 0) 1192 if (ret < 0)
1193 { 1193 {
1194 gnutls_assert (); 1194 MHD_gnutls_assert ();
1195 return NULL; 1195 return NULL;
1196 } 1196 }
1197 1197
@@ -1199,7 +1199,7 @@ alloc_and_load_x509_key (gnutls_x509_privkey_t key)
1199} 1199}
1200 1200
1201void 1201void
1202mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session) 1202MHD_gtls_selected_certs_deinit (MHD_gtls_session_t session)
1203{ 1203{
1204 if (session->internals.selected_need_free != 0) 1204 if (session->internals.selected_need_free != 0)
1205 { 1205 {
@@ -1207,16 +1207,16 @@ mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session)
1207 1207
1208 for (i = 0; i < session->internals.selected_cert_list_length; i++) 1208 for (i = 0; i < session->internals.selected_cert_list_length; i++)
1209 { 1209 {
1210 mhd_gtls_gcert_deinit (&session->internals.selected_cert_list[i]); 1210 MHD_gtls_gcert_deinit (&session->internals.selected_cert_list[i]);
1211 } 1211 }
1212 gnutls_free (session->internals.selected_cert_list); 1212 MHD_gnutls_free (session->internals.selected_cert_list);
1213 session->internals.selected_cert_list = NULL; 1213 session->internals.selected_cert_list = NULL;
1214 session->internals.selected_cert_list_length = 0; 1214 session->internals.selected_cert_list_length = 0;
1215 1215
1216 mhd_gtls_gkey_deinit (session->internals.selected_key); 1216 MHD_gtls_gkey_deinit (session->internals.selected_key);
1217 if (session->internals.selected_key) 1217 if (session->internals.selected_key)
1218 { 1218 {
1219 gnutls_free (session->internals.selected_key); 1219 MHD_gnutls_free (session->internals.selected_key);
1220 session->internals.selected_key = NULL; 1220 session->internals.selected_key = NULL;
1221 } 1221 }
1222 } 1222 }
@@ -1225,11 +1225,11 @@ mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session)
1225} 1225}
1226 1226
1227void 1227void
1228mhd_gtls_selected_certs_set (mhd_gtls_session_t session, 1228MHD_gtls_selected_certs_set (MHD_gtls_session_t session,
1229 gnutls_cert * certs, int ncerts, 1229 MHD_gnutls_cert * certs, int ncerts,
1230 gnutls_privkey * key, int need_free) 1230 MHD_gnutls_privkey * key, int need_free)
1231{ 1231{
1232 mhd_gtls_selected_certs_deinit (session); 1232 MHD_gtls_selected_certs_deinit (session);
1233 1233
1234 session->internals.selected_cert_list = certs; 1234 session->internals.selected_cert_list = certs;
1235 session->internals.selected_cert_list_length = ncerts; 1235 session->internals.selected_cert_list_length = ncerts;
@@ -1250,19 +1250,19 @@ mhd_gtls_selected_certs_set (mhd_gtls_session_t session,
1250 * 1250 *
1251 */ 1251 */
1252int 1252int
1253mhd_gtls_server_select_cert (mhd_gtls_session_t session, 1253MHD_gtls_server_select_cert (MHD_gtls_session_t session,
1254 enum MHD_GNUTLS_PublicKeyAlgorithm 1254 enum MHD_GNUTLS_PublicKeyAlgorithm
1255 requested_algo) 1255 requested_algo)
1256{ 1256{
1257 unsigned i; 1257 unsigned i;
1258 int idx, ret; 1258 int idx, ret;
1259 mhd_gtls_cert_credentials_t cred; 1259 MHD_gtls_cert_credentials_t cred;
1260 1260
1261 cred = (mhd_gtls_cert_credentials_t) 1261 cred = (MHD_gtls_cert_credentials_t)
1262 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 1262 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
1263 if (cred == NULL) 1263 if (cred == NULL)
1264 { 1264 {
1265 gnutls_assert (); 1265 MHD_gnutls_assert ();
1266 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 1266 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
1267 } 1267 }
1268 1268
@@ -1301,7 +1301,7 @@ mhd_gtls_server_select_cert (mhd_gtls_session_t session,
1301 */ 1301 */
1302 if (idx >= 0 && ret == 0) 1302 if (idx >= 0 && ret == 0)
1303 { 1303 {
1304 mhd_gtls_selected_certs_set (session, 1304 MHD_gtls_selected_certs_set (session,
1305 &cred->cert_list[idx][0], 1305 &cred->cert_list[idx][0],
1306 cred->cert_list_length[idx], 1306 cred->cert_list_length[idx],
1307 &cred->pkey[idx], 0); 1307 &cred->pkey[idx], 0);
@@ -1313,11 +1313,11 @@ mhd_gtls_server_select_cert (mhd_gtls_session_t session,
1313 return ret; 1313 return ret;
1314} 1314}
1315 1315
1316/* Frees the mhd_gtls_rsa_info_st structure. 1316/* Frees the MHD_gtls_rsa_info_st structure.
1317 */ 1317 */
1318void 1318void
1319mhd_gtls_free_rsa_info (rsa_info_st * rsa) 1319MHD_gtls_free_rsa_info (rsa_info_st * rsa)
1320{ 1320{
1321 _gnutls_free_datum (&rsa->modulus); 1321 MHD__gnutls_free_datum (&rsa->modulus);
1322 _gnutls_free_datum (&rsa->exponent); 1322 MHD__gnutls_free_datum (&rsa->exponent);
1323} 1323}
diff --git a/src/daemon/https/tls/auth_cert.h b/src/daemon/https/tls/auth_cert.h
index 9df2bd0d..aabfac76 100644
--- a/src/daemon/https/tls/auth_cert.h
+++ b/src/daemon/https/tls/auth_cert.h
@@ -34,16 +34,16 @@
34 * support a server that has multiple certificates 34 * support a server that has multiple certificates
35 */ 35 */
36 36
37typedef struct mhd_gtls_certificate_credentials_st 37typedef struct MHD_gtls_certificate_credentials_st
38{ 38{
39 mhd_gtls_dh_params_t dh_params; 39 MHD_gtls_dh_params_t dh_params;
40 mhd_gtls_rsa_params_t rsa_params; 40 MHD_gtls_rsa_params_t rsa_params;
41 /* this callback is used to retrieve the DH or RSA 41 /* this callback is used to retrieve the DH or RSA
42 * parameters. 42 * parameters.
43 */ 43 */
44 gnutls_params_function *params_func; 44 MHD_gnutls_params_function *params_func;
45 45
46 gnutls_cert **cert_list; 46 MHD_gnutls_cert **cert_list;
47 /* contains a list of a list of certificates. 47 /* contains a list of a list of certificates.
48 * eg (X509): [0] certificate1, certificate11, certificate111 48 * eg (X509): [0] certificate1, certificate11, certificate111
49 * (if more than one, one certificate certifies the one before) 49 * (if more than one, one certificate certifies the one before)
@@ -57,7 +57,7 @@ typedef struct mhd_gtls_certificate_credentials_st
57 * This is the same with the number of pkeys. 57 * This is the same with the number of pkeys.
58 */ 58 */
59 59
60 gnutls_privkey *pkey; 60 MHD_gnutls_privkey *pkey;
61 /* private keys. It contains ncerts private 61 /* private keys. It contains ncerts private
62 * keys. pkey[i] corresponds to certificate in 62 * keys. pkey[i] corresponds to certificate in
63 * cert_list[i][0]. 63 * cert_list[i][0].
@@ -66,19 +66,19 @@ typedef struct mhd_gtls_certificate_credentials_st
66 /* OpenPGP specific stuff */ 66 /* OpenPGP specific stuff */
67 67
68#ifndef KEYRING_HACK 68#ifndef KEYRING_HACK
69 gnutls_openpgp_keyring_t keyring; 69 MHD_gnutls_openpgp_keyring_t keyring;
70#else 70#else
71 gnutls_datum_t keyring; 71 MHD_gnutls_datum_t keyring;
72 int keyring_format; 72 int keyring_format;
73#endif 73#endif
74 74
75 /* X509 specific stuff */ 75 /* X509 specific stuff */
76 76
77 gnutls_x509_crt_t *x509_ca_list; 77 MHD_gnutls_x509_crt_t *x509_ca_list;
78 unsigned x509_ncas; /* number of CAs in the ca_list 78 unsigned x509_ncas; /* number of CAs in the ca_list
79 */ 79 */
80 80
81 gnutls_x509_crl_t *x509_crl_list; 81 MHD_gnutls_x509_crl_t *x509_crl_list;
82 unsigned x509_ncrls; /* number of CRLs in the crl_list 82 unsigned x509_ncrls; /* number of CRLs in the crl_list
83 */ 83 */
84 84
@@ -93,19 +93,19 @@ typedef struct mhd_gtls_certificate_credentials_st
93 * This is better than 93 * This is better than
94 * generating on every handshake. 94 * generating on every handshake.
95 */ 95 */
96 gnutls_datum_t x509_rdn_sequence; 96 MHD_gnutls_datum_t x509_rdn_sequence;
97 97
98 gnutls_certificate_client_retrieve_function *client_get_cert_callback; 98 MHD_gnutls_certificate_client_retrieve_function *client_get_cert_callback;
99 gnutls_certificate_server_retrieve_function *server_get_cert_callback; 99 MHD_gnutls_certificate_server_retrieve_function *server_get_cert_callback;
100} mhd_gtls_cert_credentials_st; 100} MHD_gtls_cert_credentials_st;
101 101
102typedef struct mhd_gtls_rsa_info_st 102typedef struct MHD_gtls_rsa_info_st
103{ 103{
104 gnutls_datum_t modulus; 104 MHD_gnutls_datum_t modulus;
105 gnutls_datum_t exponent; 105 MHD_gnutls_datum_t exponent;
106} rsa_info_st; 106} rsa_info_st;
107 107
108typedef struct mhd_gtls_cert_auth_info_st 108typedef struct MHD_gtls_cert_auth_info_st
109{ 109{
110 int certificate_requested; /* if the peer requested certificate 110 int certificate_requested; /* if the peer requested certificate
111 * this is non zero; 111 * this is non zero;
@@ -114,46 +114,46 @@ typedef struct mhd_gtls_cert_auth_info_st
114 /* These (dh/rsa) are just copies from the credentials_t structure. 114 /* These (dh/rsa) are just copies from the credentials_t structure.
115 * They must be freed. 115 * They must be freed.
116 */ 116 */
117 mhd_gtls_dh_info_st dh; 117 MHD_gtls_dh_info_st dh;
118 rsa_info_st rsa_export; 118 rsa_info_st rsa_export;
119 119
120 gnutls_datum_t *raw_certificate_list; /* holds the raw certificate of the 120 MHD_gnutls_datum_t *raw_certificate_list; /* holds the raw certificate of the
121 * peer. 121 * peer.
122 */ 122 */
123 unsigned int ncerts; /* holds the size of the list above */ 123 unsigned int ncerts; /* holds the size of the list above */
124} *cert_auth_info_t; 124} *cert_auth_info_t;
125 125
126typedef struct mhd_gtls_cert_auth_info_st cert_auth_info_st; 126typedef struct MHD_gtls_cert_auth_info_st cert_auth_info_st;
127 127
128void mhd_gtls_free_rsa_info (rsa_info_st * rsa); 128void MHD_gtls_free_rsa_info (rsa_info_st * rsa);
129 129
130/* AUTH X509 functions */ 130/* AUTH X509 functions */
131int mhd_gtls_gen_cert_server_certificate (mhd_gtls_session_t, opaque **); 131int MHD_gtls_gen_cert_server_certificate (MHD_gtls_session_t, opaque **);
132int mhd_gtls_gen_cert_client_certificate (mhd_gtls_session_t, opaque **); 132int MHD_gtls_gen_cert_client_certificate (MHD_gtls_session_t, opaque **);
133int mhd_gtls_gen_cert_client_cert_vrfy (mhd_gtls_session_t, opaque **); 133int MHD_gtls_gen_cert_client_cert_vrfy (MHD_gtls_session_t, opaque **);
134int mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t, opaque **); 134int MHD_gtls_gen_cert_server_cert_req (MHD_gtls_session_t, opaque **);
135int mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t, opaque *, size_t); 135int MHD_gtls_proc_cert_cert_req (MHD_gtls_session_t, opaque *, size_t);
136int mhd_gtls_proc_cert_client_cert_vrfy (mhd_gtls_session_t, opaque *, 136int MHD_gtls_proc_cert_client_cert_vrfy (MHD_gtls_session_t, opaque *,
137 size_t); 137 size_t);
138int mhd_gtls_proc_cert_server_certificate (mhd_gtls_session_t, opaque *, 138int MHD_gtls_proc_cert_server_certificate (MHD_gtls_session_t, opaque *,
139 size_t); 139 size_t);
140int mhd_gtls_get_selected_cert (mhd_gtls_session_t session, 140int MHD_gtls_get_selected_cert (MHD_gtls_session_t session,
141 gnutls_cert ** apr_cert_list, 141 MHD_gnutls_cert ** apr_cert_list,
142 int *apr_cert_list_length, 142 int *apr_cert_list_length,
143 gnutls_privkey ** apr_pkey); 143 MHD_gnutls_privkey ** apr_pkey);
144 144
145int mhd_gtls_server_select_cert (struct MHD_gtls_session_int *, 145int MHD_gtls_server_select_cert (struct MHD_gtls_session_int *,
146 enum MHD_GNUTLS_PublicKeyAlgorithm); 146 enum MHD_GNUTLS_PublicKeyAlgorithm);
147void mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session); 147void MHD_gtls_selected_certs_deinit (MHD_gtls_session_t session);
148void mhd_gtls_selected_certs_set (mhd_gtls_session_t session, 148void MHD_gtls_selected_certs_set (MHD_gtls_session_t session,
149 gnutls_cert * certs, int ncerts, 149 MHD_gnutls_cert * certs, int ncerts,
150 gnutls_privkey * key, int need_free); 150 MHD_gnutls_privkey * key, int need_free);
151 151
152#define _gnutls_proc_cert_client_certificate mhd_gtls_proc_cert_server_certificate 152#define MHD__gnutls_proc_cert_client_certificate MHD_gtls_proc_cert_server_certificate
153 153
154mhd_gtls_rsa_params_t 154MHD_gtls_rsa_params_t
155mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params, 155MHD_gtls_certificate_get_rsa_params (MHD_gtls_rsa_params_t rsa_params,
156 gnutls_params_function * func, 156 MHD_gnutls_params_function * func,
157 mhd_gtls_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 4d471045..8fc6e391 100644
--- a/src/daemon/https/tls/auth_dh_common.c
+++ b/src/daemon/https/tls/auth_dh_common.c
@@ -39,19 +39,19 @@
39#include <auth_dh_common.h> 39#include <auth_dh_common.h>
40#include <gnutls_algorithms.h> 40#include <gnutls_algorithms.h>
41 41
42/* Frees the mhd_gtls_dh_info_st structure. 42/* Frees the MHD_gtls_dh_info_st structure.
43 */ 43 */
44void 44void
45mhd_gtls_free_dh_info (mhd_gtls_dh_info_st * dh) 45MHD_gtls_free_dh_info (MHD_gtls_dh_info_st * dh)
46{ 46{
47 dh->secret_bits = 0; 47 dh->secret_bits = 0;
48 _gnutls_free_datum (&dh->prime); 48 MHD__gnutls_free_datum (&dh->prime);
49 _gnutls_free_datum (&dh->generator); 49 MHD__gnutls_free_datum (&dh->generator);
50 _gnutls_free_datum (&dh->public_key); 50 MHD__gnutls_free_datum (&dh->public_key);
51} 51}
52 52
53int 53int
54mhd_gtls_proc_dh_common_client_kx (mhd_gtls_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,33 +62,33 @@ mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
62 62
63 63
64 DECR_LEN (data_size, 2); 64 DECR_LEN (data_size, 2);
65 n_Y = mhd_gtls_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 (mhd_gtls_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 MHD_gnutls_assert ();
72 return GNUTLS_E_MPI_SCAN_FAILED; 72 return GNUTLS_E_MPI_SCAN_FAILED;
73 } 73 }
74 74
75 mhd_gtls_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 mhd_gtls_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 {
82 gnutls_assert (); 82 MHD_gnutls_assert ();
83 return GNUTLS_E_MEMORY_ERROR; 83 return GNUTLS_E_MEMORY_ERROR;
84 } 84 }
85 85
86 mhd_gtls_mpi_release (&session->key->client_Y); 86 MHD_gtls_mpi_release (&session->key->client_Y);
87 mhd_gtls_mpi_release (&session->key->dh_secret); 87 MHD_gtls_mpi_release (&session->key->dh_secret);
88 88
89 ret = mhd_gtls_mpi_dprint (&session->key->key, session->key->KEY); 89 ret = MHD_gtls_mpi_dprint (&session->key->key, session->key->KEY);
90 90
91 mhd_gtls_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 @@ mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
99} 99}
100 100
101int 101int
102mhd_gtls_gen_dh_common_client_kx (mhd_gtls_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,69 +107,69 @@ mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t session, opaque ** data)
107 107
108 *data = NULL; 108 *data = NULL;
109 109
110 X = mhd_gtls_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 {
114 gnutls_assert (); 114 MHD_gnutls_assert ();
115 ret = GNUTLS_E_MEMORY_ERROR; 115 ret = GNUTLS_E_MEMORY_ERROR;
116 goto error; 116 goto error;
117 } 117 }
118 118
119 mhd_gtls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x)); 119 MHD_gtls_dh_set_secret_bits (session, MHD__gnutls_mpi_get_nbits (x));
120 120
121 mhd_gtls_mpi_print (NULL, &n_X, X); 121 MHD_gtls_mpi_print (NULL, &n_X, X);
122 (*data) = gnutls_malloc (n_X + 2); 122 (*data) = MHD_gnutls_malloc (n_X + 2);
123 if (*data == NULL) 123 if (*data == NULL)
124 { 124 {
125 ret = GNUTLS_E_MEMORY_ERROR; 125 ret = GNUTLS_E_MEMORY_ERROR;
126 goto error; 126 goto error;
127 } 127 }
128 128
129 mhd_gtls_mpi_print (&(*data)[2], &n_X, X); 129 MHD_gtls_mpi_print (&(*data)[2], &n_X, X);
130 mhd_gtls_mpi_release (&X); 130 MHD_gtls_mpi_release (&X);
131 131
132 mhd_gtls_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 mhd_gtls_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 mhd_gtls_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 MHD_gnutls_assert ();
142 ret = GNUTLS_E_MEMORY_ERROR; 142 ret = GNUTLS_E_MEMORY_ERROR;
143 goto error; 143 goto error;
144 } 144 }
145 145
146 /* THESE SHOULD BE DISCARDED */ 146 /* THESE SHOULD BE DISCARDED */
147 mhd_gtls_mpi_release (&session->key->client_Y); 147 MHD_gtls_mpi_release (&session->key->client_Y);
148 mhd_gtls_mpi_release (&session->key->client_p); 148 MHD_gtls_mpi_release (&session->key->client_p);
149 mhd_gtls_mpi_release (&session->key->client_g); 149 MHD_gtls_mpi_release (&session->key->client_g);
150 150
151 ret = mhd_gtls_mpi_dprint (&session->key->key, session->key->KEY); 151 ret = MHD_gtls_mpi_dprint (&session->key->key, session->key->KEY);
152 152
153 mhd_gtls_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 {
157 gnutls_assert (); 157 MHD_gnutls_assert ();
158 goto error; 158 goto error;
159 } 159 }
160 160
161 return n_X + 2; 161 return n_X + 2;
162 162
163error: 163error:
164 mhd_gtls_mpi_release (&x); 164 MHD_gtls_mpi_release (&x);
165 mhd_gtls_mpi_release (&X); 165 MHD_gtls_mpi_release (&X);
166 gnutls_free (*data); 166 MHD_gnutls_free (*data);
167 *data = NULL; 167 *data = NULL;
168 return ret; 168 return ret;
169} 169}
170 170
171int 171int
172mhd_gtls_proc_dh_common_server_kx (mhd_gtls_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 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_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 = mhd_gtls_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 = mhd_gtls_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 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_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 = mhd_gtls_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 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_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 = mhd_gtls_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,41 +218,41 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_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 (mhd_gtls_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 MHD_gnutls_assert ();
224 return GNUTLS_E_MPI_SCAN_FAILED; 224 return GNUTLS_E_MPI_SCAN_FAILED;
225 } 225 }
226 226
227 if (mhd_gtls_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 MHD_gnutls_assert ();
230 return GNUTLS_E_MPI_SCAN_FAILED; 230 return GNUTLS_E_MPI_SCAN_FAILED;
231 } 231 }
232 if (mhd_gtls_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 MHD_gnutls_assert ();
235 return GNUTLS_E_MPI_SCAN_FAILED; 235 return GNUTLS_E_MPI_SCAN_FAILED;
236 } 236 }
237 237
238 bits = mhd_gtls_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 MHD_gnutls_assert ();
242 return bits; 242 return bits;
243 } 243 }
244 244
245 if (_gnutls_mpi_get_nbits (session->key->client_p) < (size_t) bits) 245 if (MHD__gnutls_mpi_get_nbits (session->key->client_p) < (size_t) bits)
246 { 246 {
247 /* the prime used by the peer is not acceptable 247 /* the prime used by the peer is not acceptable
248 */ 248 */
249 gnutls_assert (); 249 MHD_gnutls_assert ();
250 return GNUTLS_E_DH_PRIME_UNACCEPTABLE; 250 return GNUTLS_E_DH_PRIME_UNACCEPTABLE;
251 } 251 }
252 252
253 mhd_gtls_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 mhd_gtls_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 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_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
267mhd_gtls_dh_common_print_server_kx (mhd_gtls_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,28 +272,28 @@ mhd_gtls_dh_common_print_server_kx (mhd_gtls_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 = mhd_gtls_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 MHD_gnutls_assert ();
279 return GNUTLS_E_MEMORY_ERROR; 279 return GNUTLS_E_MEMORY_ERROR;
280 } 280 }
281 281
282 session->key->dh_secret = x; 282 session->key->dh_secret = x;
283 mhd_gtls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x)); 283 MHD_gtls_dh_set_secret_bits (session, MHD__gnutls_mpi_get_nbits (x));
284 284
285 mhd_gtls_mpi_print (NULL, &n_g, g); 285 MHD_gtls_mpi_print (NULL, &n_g, g);
286 mhd_gtls_mpi_print (NULL, &n_p, p); 286 MHD_gtls_mpi_print (NULL, &n_p, p);
287 mhd_gtls_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)
291 data_size += 2; 291 data_size += 2;
292 292
293 (*data) = gnutls_malloc (data_size); 293 (*data) = MHD_gnutls_malloc (data_size);
294 if (*data == NULL) 294 if (*data == NULL)
295 { 295 {
296 mhd_gtls_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 @@ mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t session,
302 302
303 if (psk != 0) 303 if (psk != 0)
304 { 304 {
305 mhd_gtls_write_uint16 (0, &pdata[pos]); 305 MHD_gtls_write_uint16 (0, &pdata[pos]);
306 pos += 2; 306 pos += 2;
307 } 307 }
308 308
309 mhd_gtls_mpi_print (&pdata[pos + 2], &n_p, p); 309 MHD_gtls_mpi_print (&pdata[pos + 2], &n_p, p);
310 mhd_gtls_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 mhd_gtls_mpi_print (&pdata[pos + 2], &n_g, g); 314 MHD_gtls_mpi_print (&pdata[pos + 2], &n_g, g);
315 mhd_gtls_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 mhd_gtls_mpi_print (&pdata[pos + 2], &n_X, X); 319 MHD_gtls_mpi_print (&pdata[pos + 2], &n_X, X);
320 mhd_gtls_mpi_release (&X); 320 MHD_gtls_mpi_release (&X);
321 321
322 mhd_gtls_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 c6129958..f09ce6dc 100644
--- a/src/daemon/https/tls/auth_dh_common.h
+++ b/src/daemon/https/tls/auth_dh_common.h
@@ -29,19 +29,19 @@ typedef struct
29{ 29{
30 int secret_bits; 30 int secret_bits;
31 31
32 gnutls_datum_t prime; 32 MHD_gnutls_datum_t prime;
33 gnutls_datum_t generator; 33 MHD_gnutls_datum_t generator;
34 gnutls_datum_t public_key; 34 MHD_gnutls_datum_t public_key;
35} mhd_gtls_dh_info_st; 35} MHD_gtls_dh_info_st;
36 36
37void mhd_gtls_free_dh_info (mhd_gtls_dh_info_st * dh); 37void MHD_gtls_free_dh_info (MHD_gtls_dh_info_st * dh);
38int mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t, opaque **); 38int MHD_gtls_gen_dh_common_client_kx (MHD_gtls_session_t, opaque **);
39int mhd_gtls_proc_dh_common_client_kx (mhd_gtls_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 mhd_gtls_dh_common_print_server_kx (mhd_gtls_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 mhd_gtls_proc_dh_common_server_kx (mhd_gtls_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 43aedf0b..fa535e55 100644
--- a/src/daemon/https/tls/auth_dhe.c
+++ b/src/daemon/https/tls/auth_dhe.c
@@ -39,103 +39,103 @@
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 (mhd_gtls_session_t, opaque **); 42static int gen_dhe_server_kx (MHD_gtls_session_t, opaque **);
43static int proc_dhe_server_kx (mhd_gtls_session_t, opaque *, size_t); 43static int proc_dhe_server_kx (MHD_gtls_session_t, opaque *, size_t);
44static int proc_dhe_client_kx (mhd_gtls_session_t, opaque *, size_t); 44static int proc_dhe_client_kx (MHD_gtls_session_t, opaque *, size_t);
45 45
46const mhd_gtls_mod_auth_st mhd_gtls_dhe_rsa_auth_struct = { 46const MHD_gtls_mod_auth_st MHD_gtls_dhe_rsa_auth_struct = {
47 "DHE_RSA", 47 "DHE_RSA",
48 mhd_gtls_gen_cert_server_certificate, 48 MHD_gtls_gen_cert_server_certificate,
49 mhd_gtls_gen_cert_client_certificate, 49 MHD_gtls_gen_cert_client_certificate,
50 gen_dhe_server_kx, 50 gen_dhe_server_kx,
51 mhd_gtls_gen_dh_common_client_kx, 51 MHD_gtls_gen_dh_common_client_kx,
52 mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */ 52 MHD_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
53 mhd_gtls_gen_cert_server_cert_req, /* server cert request */ 53 MHD_gtls_gen_cert_server_cert_req, /* server cert request */
54 54
55 mhd_gtls_proc_cert_server_certificate, 55 MHD_gtls_proc_cert_server_certificate,
56 _gnutls_proc_cert_client_certificate, 56 MHD__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 mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ 59 MHD_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
60 mhd_gtls_proc_cert_cert_req /* proc server cert request */ 60 MHD_gtls_proc_cert_cert_req /* proc server cert request */
61}; 61};
62 62
63const mhd_gtls_mod_auth_st mhd_gtls_dhe_dss_auth_struct = { 63const MHD_gtls_mod_auth_st MHD_gtls_dhe_dss_auth_struct = {
64 "DHE_DSS", 64 "DHE_DSS",
65 mhd_gtls_gen_cert_server_certificate, 65 MHD_gtls_gen_cert_server_certificate,
66 mhd_gtls_gen_cert_client_certificate, 66 MHD_gtls_gen_cert_client_certificate,
67 gen_dhe_server_kx, 67 gen_dhe_server_kx,
68 mhd_gtls_gen_dh_common_client_kx, 68 MHD_gtls_gen_dh_common_client_kx,
69 mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */ 69 MHD_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
70 mhd_gtls_gen_cert_server_cert_req, /* server cert request */ 70 MHD_gtls_gen_cert_server_cert_req, /* server cert request */
71 71
72 mhd_gtls_proc_cert_server_certificate, 72 MHD_gtls_proc_cert_server_certificate,
73 _gnutls_proc_cert_client_certificate, 73 MHD__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 mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ 76 MHD_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
77 mhd_gtls_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 (mhd_gtls_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;
86 int ret = 0, data_size; 86 int ret = 0, data_size;
87 int bits; 87 int bits;
88 gnutls_cert *apr_cert_list; 88 MHD_gnutls_cert *apr_cert_list;
89 gnutls_privkey *apr_pkey; 89 MHD_gnutls_privkey *apr_pkey;
90 int apr_cert_list_length; 90 int apr_cert_list_length;
91 gnutls_datum_t signature, ddata; 91 MHD_gnutls_datum_t signature, ddata;
92 mhd_gtls_cert_credentials_t cred; 92 MHD_gtls_cert_credentials_t cred;
93 mhd_gtls_dh_params_t dh_params; 93 MHD_gtls_dh_params_t dh_params;
94 94
95 cred = (mhd_gtls_cert_credentials_t) 95 cred = (MHD_gtls_cert_credentials_t)
96 mhd_gtls_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 MHD_gnutls_assert ();
100 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 100 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
101 } 101 }
102 102
103 bits = mhd_gtls_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 mhd_gtls_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 MHD_gnutls_assert ();
111 return ret; 111 return ret;
112 } 112 }
113 113
114 dh_params = 114 dh_params =
115 mhd_gtls_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 = mhd_gtls_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 MHD_gnutls_assert ();
120 return GNUTLS_E_NO_TEMPORARY_DH_PARAMS; 120 return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
121 } 121 }
122 122
123 p = mpis[0]; 123 p = mpis[0];
124 g = mpis[1]; 124 g = mpis[1];
125 125
126 if ((ret = mhd_gtls_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 MHD_gnutls_assert ();
130 return ret; 130 return ret;
131 } 131 }
132 132
133 mhd_gtls_dh_set_group (session, g, p); 133 MHD_gtls_dh_set_group (session, g, p);
134 134
135 ret = mhd_gtls_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 MHD_gnutls_assert ();
139 return ret; 139 return ret;
140 } 140 }
141 data_size = ret; 141 data_size = ret;
@@ -148,58 +148,58 @@ gen_dhe_server_kx (mhd_gtls_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 mhd_gtls_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 MHD_gnutls_assert ();
155 gnutls_free (*data); 155 MHD_gnutls_free (*data);
156 return ret; 156 return ret;
157 } 157 }
158 } 158 }
159 else 159 else
160 { 160 {
161 gnutls_assert (); 161 MHD_gnutls_assert ();
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 = mhd_gtls_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 MHD__gnutls_free_datum (&signature);
169 gnutls_assert (); 169 MHD_gnutls_assert ();
170 return GNUTLS_E_MEMORY_ERROR; 170 return GNUTLS_E_MEMORY_ERROR;
171 } 171 }
172 172
173 mhd_gtls_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 MHD__gnutls_free_datum (&signature);
177 177
178 return data_size; 178 return data_size;
179} 179}
180 180
181static int 181static int
182proc_dhe_server_kx (mhd_gtls_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 MHD_gnutls_datum_t vparams, signature;
187 int ret; 187 int ret;
188 cert_auth_info_t info = mhd_gtls_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 MHD_gnutls_cert peer_cert;
191 191
192 if (info == NULL || info->ncerts == 0) 192 if (info == NULL || info->ncerts == 0)
193 { 193 {
194 gnutls_assert (); 194 MHD_gnutls_assert ();
195 /* we need this in order to get peer's certificate */ 195 /* we need this in order to get peer's certificate */
196 return GNUTLS_E_INTERNAL_ERROR; 196 return GNUTLS_E_INTERNAL_ERROR;
197 } 197 }
198 198
199 ret = mhd_gtls_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 MHD_gnutls_assert ();
203 return ret; 203 return ret;
204 } 204 }
205 205
@@ -209,29 +209,29 @@ proc_dhe_server_kx (mhd_gtls_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 = mhd_gtls_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 mhd_gtls_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)
223 { 223 {
224 gnutls_assert (); 224 MHD_gnutls_assert ();
225 return ret; 225 return ret;
226 } 226 }
227 227
228 ret = 228 ret =
229 mhd_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature); 229 MHD_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
230 230
231 mhd_gtls_gcert_deinit (&peer_cert); 231 MHD_gtls_gcert_deinit (&peer_cert);
232 if (ret < 0) 232 if (ret < 0)
233 { 233 {
234 gnutls_assert (); 234 MHD_gnutls_assert ();
235 return ret; 235 return ret;
236 } 236 }
237 237
@@ -241,36 +241,36 @@ proc_dhe_server_kx (mhd_gtls_session_t session, opaque * data,
241 241
242 242
243static int 243static int
244proc_dhe_client_kx (mhd_gtls_session_t session, opaque * data, 244proc_dhe_client_kx (MHD_gtls_session_t session, opaque * data,
245 size_t _data_size) 245 size_t _data_size)
246{ 246{
247 mhd_gtls_cert_credentials_t cred; 247 MHD_gtls_cert_credentials_t cred;
248 int ret; 248 int ret;
249 mpi_t p, g; 249 mpi_t p, g;
250 const mpi_t *mpis; 250 const mpi_t *mpis;
251 mhd_gtls_dh_params_t dh_params; 251 MHD_gtls_dh_params_t dh_params;
252 252
253 cred = (mhd_gtls_cert_credentials_t) 253 cred = (MHD_gtls_cert_credentials_t)
254 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 254 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
255 if (cred == NULL) 255 if (cred == NULL)
256 { 256 {
257 gnutls_assert (); 257 MHD_gnutls_assert ();
258 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 258 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
259 } 259 }
260 260
261 dh_params = 261 dh_params =
262 mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session); 262 MHD_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
263 mpis = mhd_gtls_dh_params_to_mpi (dh_params); 263 mpis = MHD_gtls_dh_params_to_mpi (dh_params);
264 if (mpis == NULL) 264 if (mpis == NULL)
265 { 265 {
266 gnutls_assert (); 266 MHD_gnutls_assert ();
267 return GNUTLS_E_NO_TEMPORARY_DH_PARAMS; 267 return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
268 } 268 }
269 269
270 p = mpis[0]; 270 p = mpis[0];
271 g = mpis[1]; 271 g = mpis[1];
272 272
273 ret = mhd_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p); 273 ret = MHD_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
274 274
275 return ret; 275 return ret;
276 276
diff --git a/src/daemon/https/tls/auth_rsa.c b/src/daemon/https/tls/auth_rsa.c
index b3833814..7a66eae6 100644
--- a/src/daemon/https/tls/auth_rsa.c
+++ b/src/daemon/https/tls/auth_rsa.c
@@ -42,85 +42,85 @@
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 (mhd_gtls_session_t, opaque **); 45int MHD__gnutls_gen_rsa_client_kx (MHD_gtls_session_t, opaque **);
46int _gnutls_proc_rsa_client_kx (mhd_gtls_session_t, opaque *, size_t); 46int MHD__gnutls_proc_rsa_client_kx (MHD_gtls_session_t, opaque *, size_t);
47 47
48const mhd_gtls_mod_auth_st mhd_gtls_rsa_auth_struct = { 48const MHD_gtls_mod_auth_st MHD_gtls_rsa_auth_struct = {
49 "RSA", 49 "RSA",
50 mhd_gtls_gen_cert_server_certificate, 50 MHD_gtls_gen_cert_server_certificate,
51 mhd_gtls_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 MHD__gnutls_gen_rsa_client_kx,
54 mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */ 54 MHD_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
55 mhd_gtls_gen_cert_server_cert_req, /* server cert request */ 55 MHD_gtls_gen_cert_server_cert_req, /* server cert request */
56 56
57 mhd_gtls_proc_cert_server_certificate, 57 MHD_gtls_proc_cert_server_certificate,
58 _gnutls_proc_cert_client_certificate, 58 MHD__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 MHD__gnutls_proc_rsa_client_kx, /* proc client kx */
61 mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ 61 MHD_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
62 mhd_gtls_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 (mhd_gtls_session_t session, 68MHD__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{
72 int ret; 72 int ret;
73 cert_auth_info_t info; 73 cert_auth_info_t info;
74 gnutls_cert peer_cert; 74 MHD_gnutls_cert peer_cert;
75 int i; 75 int i;
76 76
77 /* normal non export case */ 77 /* normal non export case */
78 78
79 info = mhd_gtls_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 {
83 gnutls_assert (); 83 MHD_gnutls_assert ();
84 return GNUTLS_E_INTERNAL_ERROR; 84 return GNUTLS_E_INTERNAL_ERROR;
85 } 85 }
86 86
87 ret = 87 ret =
88 mhd_gtls_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);
92 92
93 if (ret < 0) 93 if (ret < 0)
94 { 94 {
95 gnutls_assert (); 95 MHD_gnutls_assert ();
96 return ret; 96 return ret;
97 } 97 }
98 98
99 99
100 /* EXPORT case: */ 100 /* EXPORT case: */
101 if (mhd_gtls_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 && MHD__gnutls_mpi_get_nbits (peer_cert.params[0]) > 512)
105 { 105 {
106 106
107 mhd_gtls_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 {
111 gnutls_assert (); 111 MHD_gnutls_assert ();
112 return GNUTLS_E_INTERNAL_ERROR; 112 return GNUTLS_E_INTERNAL_ERROR;
113 } 113 }
114 114
115 if (*params_len < 2) 115 if (*params_len < 2)
116 { 116 {
117 gnutls_assert (); 117 MHD_gnutls_assert ();
118 return GNUTLS_E_INTERNAL_ERROR; 118 return GNUTLS_E_INTERNAL_ERROR;
119 } 119 }
120 *params_len = 2; 120 *params_len = 2;
121 for (i = 0; i < *params_len; i++) 121 for (i = 0; i < *params_len; i++)
122 { 122 {
123 params[i] = _gnutls_mpi_copy (session->key->rsa[i]); 123 params[i] = MHD__gnutls_mpi_copy (session->key->rsa[i]);
124 } 124 }
125 125
126 return 0; 126 return 0;
@@ -130,16 +130,16 @@ _gnutls_get_public_rsa_params (mhd_gtls_session_t session,
130 130
131 if (*params_len < peer_cert.params_size) 131 if (*params_len < peer_cert.params_size)
132 { 132 {
133 gnutls_assert (); 133 MHD_gnutls_assert ();
134 return GNUTLS_E_INTERNAL_ERROR; 134 return GNUTLS_E_INTERNAL_ERROR;
135 } 135 }
136 *params_len = peer_cert.params_size; 136 *params_len = peer_cert.params_size;
137 137
138 for (i = 0; i < *params_len; i++) 138 for (i = 0; i < *params_len; i++)
139 { 139 {
140 params[i] = _gnutls_mpi_copy (peer_cert.params[i]); 140 params[i] = MHD__gnutls_mpi_copy (peer_cert.params[i]);
141 } 141 }
142 mhd_gtls_gcert_deinit (&peer_cert); 142 MHD_gtls_gcert_deinit (&peer_cert);
143 143
144 return 0; 144 return 0;
145} 145}
@@ -147,43 +147,43 @@ _gnutls_get_public_rsa_params (mhd_gtls_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 (mhd_gtls_session_t session, 150MHD__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 mhd_gtls_cert_credentials_t cred; 154 MHD_gtls_cert_credentials_t cred;
155 mhd_gtls_rsa_params_t rsa_params; 155 MHD_gtls_rsa_params_t rsa_params;
156 156
157 cred = (mhd_gtls_cert_credentials_t) 157 cred = (MHD_gtls_cert_credentials_t)
158 mhd_gtls_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 MHD_gnutls_assert ();
162 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 162 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
163 } 163 }
164 164
165 if (session->internals.selected_cert_list == NULL) 165 if (session->internals.selected_cert_list == NULL)
166 { 166 {
167 gnutls_assert (); 167 MHD_gnutls_assert ();
168 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 168 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
169 } 169 }
170 170
171 bits = 171 bits =
172 _gnutls_mpi_get_nbits (session->internals.selected_cert_list[0]. 172 MHD__gnutls_mpi_get_nbits (session->internals.selected_cert_list[0].
173 params[0]); 173 params[0]);
174 174
175 if (mhd_gtls_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 mhd_gtls_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)
185 { 185 {
186 gnutls_assert (); 186 MHD_gnutls_assert ();
187 return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS; 187 return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS;
188 } 188 }
189 189
@@ -206,18 +206,18 @@ _gnutls_get_private_rsa_params (mhd_gtls_session_t session,
206} 206}
207 207
208int 208int
209_gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data, 209MHD__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 MHD_gnutls_datum_t plaintext;
213 gnutls_datum_t ciphertext; 213 MHD_gnutls_datum_t ciphertext;
214 int ret, dsize; 214 int ret, dsize;
215 mpi_t *params; 215 mpi_t *params;
216 int params_len; 216 int params_len;
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 (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) 220 if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
221 { 221 {
222 /* SSL 3.0 222 /* SSL 3.0
223 */ 223 */
@@ -230,24 +230,24 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_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 = mhd_gtls_read_uint16 (data); 233 dsize = MHD_gtls_read_uint16 (data);
234 234
235 if (dsize != data_size) 235 if (dsize != data_size)
236 { 236 {
237 gnutls_assert (); 237 MHD_gnutls_assert ();
238 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 238 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
239 } 239 }
240 ciphertext.size = dsize; 240 ciphertext.size = dsize;
241 } 241 }
242 242
243 ret = _gnutls_get_private_rsa_params (session, &params, &params_len); 243 ret = MHD__gnutls_get_private_rsa_params (session, &params, &params_len);
244 if (ret < 0) 244 if (ret < 0)
245 { 245 {
246 gnutls_assert (); 246 MHD_gnutls_assert ();
247 return ret; 247 return ret;
248 } 248 }
249 249
250 ret = mhd_gtls_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 {
@@ -255,8 +255,8 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
255 * the peer. Just use a random key. (in order to avoid 255 * the peer. Just use a random key. (in order to avoid
256 * attack against pkcs-1 formating). 256 * attack against pkcs-1 formating).
257 */ 257 */
258 gnutls_assert (); 258 MHD_gnutls_assert ();
259 _gnutls_x509_log ("auth_rsa: Possible PKCS #1 format attack\n"); 259 MHD__gnutls_x509_log ("auth_rsa: Possible PKCS #1 format attack\n");
260 randomize_key = 1; 260 randomize_key = 1;
261 } 261 }
262 else 262 else
@@ -264,8 +264,8 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
264 /* If the secret was properly formatted, then 264 /* If the secret was properly formatted, then
265 * check the version number. 265 * check the version number.
266 */ 266 */
267 if (_gnutls_get_adv_version_major (session) != plaintext.data[0] 267 if (MHD__gnutls_get_adv_version_major (session) != plaintext.data[0]
268 || _gnutls_get_adv_version_minor (session) != plaintext.data[1]) 268 || MHD__gnutls_get_adv_version_minor (session) != plaintext.data[1])
269 { 269 {
270 /* No error is returned here, if the version number check 270 /* No error is returned here, if the version number check
271 * fails. We proceed normally. 271 * fails. We proceed normally.
@@ -273,8 +273,8 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
273 * "Attacking RSA-based sessions in SSL/TLS" by Vlastimil Klima, 273 * "Attacking RSA-based sessions in SSL/TLS" by Vlastimil Klima,
274 * Ondej Pokorny and Tomas Rosa. 274 * Ondej Pokorny and Tomas Rosa.
275 */ 275 */
276 gnutls_assert (); 276 MHD_gnutls_assert ();
277 _gnutls_x509_log 277 MHD__gnutls_x509_log
278 ("auth_rsa: Possible PKCS #1 version check format attack\n"); 278 ("auth_rsa: Possible PKCS #1 version check format attack\n");
279 } 279 }
280 } 280 }
@@ -282,18 +282,18 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
282 if (randomize_key != 0) 282 if (randomize_key != 0)
283 { 283 {
284 session->key->key.size = TLS_MASTER_SIZE; 284 session->key->key.size = TLS_MASTER_SIZE;
285 session->key->key.data = gnutls_malloc (session->key->key.size); 285 session->key->key.data = MHD_gnutls_malloc (session->key->key.size);
286 if (session->key->key.data == NULL) 286 if (session->key->key.data == NULL)
287 { 287 {
288 gnutls_assert (); 288 MHD_gnutls_assert ();
289 return GNUTLS_E_MEMORY_ERROR; 289 return GNUTLS_E_MEMORY_ERROR;
290 } 290 }
291 291
292 /* we do not need strong random numbers here. 292 /* we do not need strong random numbers here.
293 */ 293 */
294 if (gc_nonce (session->key->key.data, session->key->key.size) != GC_OK) 294 if (MHD_gc_nonce (session->key->key.data, session->key->key.size) != GC_OK)
295 { 295 {
296 gnutls_assert (); 296 MHD_gnutls_assert ();
297 return GNUTLS_E_RANDOM_FAILED; 297 return GNUTLS_E_RANDOM_FAILED;
298 } 298 }
299 299
@@ -307,8 +307,8 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
307 /* This is here to avoid the version check attack 307 /* This is here to avoid the version check attack
308 * discussed above. 308 * discussed above.
309 */ 309 */
310 session->key->key.data[0] = _gnutls_get_adv_version_major (session); 310 session->key->key.data[0] = MHD__gnutls_get_adv_version_major (session);
311 session->key->key.data[1] = _gnutls_get_adv_version_minor (session); 311 session->key->key.data[1] = MHD__gnutls_get_adv_version_minor (session);
312 312
313 return 0; 313 return 0;
314} 314}
@@ -318,46 +318,53 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_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 (mhd_gtls_session_t session, opaque ** data) 321MHD__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;
324 gnutls_datum_t sdata; /* data to send */ 324 MHD_gnutls_datum_t sdata; /* data to send */
325 mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; 325 mpi_t params[MAX_PUBLIC_PARAMS_SIZE];
326 int params_len = MAX_PUBLIC_PARAMS_SIZE; 326 int params_len = MAX_PUBLIC_PARAMS_SIZE;
327 int ret, i; 327 int ret, i;
328 enum MHD_GNUTLS_Protocol ver; 328 enum MHD_GNUTLS_Protocol ver;
329 329
330 if (session->key == NULL)
331 {
332 MHD_gnutls_assert ();
333 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
334 }
335
336 auth = session->key->auth_info;
330 if (auth == NULL) 337 if (auth == NULL)
331 { 338 {
332 /* this shouldn't have happened. The proc_certificate 339 /* this shouldn't have happened. The proc_certificate
333 * function should have detected that. 340 * function should have detected that.
334 */ 341 */
335 gnutls_assert (); 342 MHD_gnutls_assert ();
336 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 343 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
337 } 344 }
338 345
339 session->key->key.size = TLS_MASTER_SIZE; 346 session->key->key.size = TLS_MASTER_SIZE;
340 session->key->key.data = gnutls_secure_malloc (session->key->key.size); 347 session->key->key.data = MHD_gnutls_secure_malloc (session->key->key.size);
341 348
342 if (session->key->key.data == NULL) 349 if (session->key->key.data == NULL)
343 { 350 {
344 gnutls_assert (); 351 MHD_gnutls_assert ();
345 return GNUTLS_E_MEMORY_ERROR; 352 return GNUTLS_E_MEMORY_ERROR;
346 } 353 }
347 354
348 if (gc_pseudo_random (session->key->key.data, 355 if (MHD_gc_pseudo_random (session->key->key.data,
349 session->key->key.size) != GC_OK) 356 session->key->key.size) != GC_OK)
350 { 357 {
351 gnutls_assert (); 358 MHD_gnutls_assert ();
352 return GNUTLS_E_RANDOM_FAILED; 359 return GNUTLS_E_RANDOM_FAILED;
353 } 360 }
354 361
355 ver = mhd_gtls_get_adv_version (session); 362 ver = MHD_gtls_get_adv_version (session);
356 363
357 if (session->internals.rsa_pms_version[0] == 0) 364 if (session->internals.rsa_pms_version[0] == 0)
358 { 365 {
359 session->key->key.data[0] = mhd_gtls_version_get_major (ver); 366 session->key->key.data[0] = MHD_gtls_version_get_major (ver);
360 session->key->key.data[1] = mhd_gtls_version_get_minor (ver); 367 session->key->key.data[1] = MHD_gtls_version_get_minor (ver);
361 } 368 }
362 else 369 else
363 { /* use the version provided */ 370 { /* use the version provided */
@@ -368,24 +375,24 @@ _gnutls_gen_rsa_client_kx (mhd_gtls_session_t session, opaque ** data)
368 /* move RSA parameters to key (session). 375 /* move RSA parameters to key (session).
369 */ 376 */
370 if ((ret = 377 if ((ret =
371 _gnutls_get_public_rsa_params (session, params, &params_len)) < 0) 378 MHD__gnutls_get_public_rsa_params (session, params, &params_len)) < 0)
372 { 379 {
373 gnutls_assert (); 380 MHD_gnutls_assert ();
374 return ret; 381 return ret;
375 } 382 }
376 383
377 if ((ret = 384 if ((ret =
378 mhd_gtls_pkcs1_rsa_encrypt (&sdata, &session->key->key, 385 MHD_gtls_pkcs1_rsa_encrypt (&sdata, &session->key->key,
379 params, params_len, 2)) < 0) 386 params, params_len, 2)) < 0)
380 { 387 {
381 gnutls_assert (); 388 MHD_gnutls_assert ();
382 return ret; 389 return ret;
383 } 390 }
384 391
385 for (i = 0; i < params_len; i++) 392 for (i = 0; i < params_len; i++)
386 mhd_gtls_mpi_release (&params[i]); 393 MHD_gtls_mpi_release (&params[i]);
387 394
388 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) 395 if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
389 { 396 {
390 /* SSL 3.0 */ 397 /* SSL 3.0 */
391 *data = sdata.data; 398 *data = sdata.data;
@@ -393,15 +400,15 @@ _gnutls_gen_rsa_client_kx (mhd_gtls_session_t session, opaque ** data)
393 } 400 }
394 else 401 else
395 { /* TLS 1 */ 402 { /* TLS 1 */
396 *data = gnutls_malloc (sdata.size + 2); 403 *data = MHD_gnutls_malloc (sdata.size + 2);
397 if (*data == NULL) 404 if (*data == NULL)
398 { 405 {
399 _gnutls_free_datum (&sdata); 406 MHD__gnutls_free_datum (&sdata);
400 return GNUTLS_E_MEMORY_ERROR; 407 return GNUTLS_E_MEMORY_ERROR;
401 } 408 }
402 mhd_gtls_write_datum16 (*data, sdata); 409 MHD_gtls_write_datum16 (*data, sdata);
403 ret = sdata.size + 2; 410 ret = sdata.size + 2;
404 _gnutls_free_datum (&sdata); 411 MHD__gnutls_free_datum (&sdata);
405 return ret; 412 return ret;
406 } 413 }
407 414
diff --git a/src/daemon/https/tls/auth_rsa_export.c b/src/daemon/https/tls/auth_rsa_export.c
index 5442c8ba..9269f704 100644
--- a/src/daemon/https/tls/auth_rsa_export.c
+++ b/src/daemon/https/tls/auth_rsa_export.c
@@ -43,105 +43,105 @@
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 (mhd_gtls_session_t, opaque **); 46int MHD__gnutls_gen_rsa_client_kx (MHD_gtls_session_t, opaque **);
47int _gnutls_proc_rsa_client_kx (mhd_gtls_session_t, opaque *, size_t); 47int MHD__gnutls_proc_rsa_client_kx (MHD_gtls_session_t, opaque *, size_t);
48static int gen_rsa_export_server_kx (mhd_gtls_session_t, opaque **); 48static int gen_rsa_export_server_kx (MHD_gtls_session_t, opaque **);
49static int proc_rsa_export_server_kx (mhd_gtls_session_t, opaque *, size_t); 49static int proc_rsa_export_server_kx (MHD_gtls_session_t, opaque *, size_t);
50 50
51const mhd_gtls_mod_auth_st rsa_export_auth_struct = { 51const MHD_gtls_mod_auth_st rsa_export_auth_struct = {
52 "RSA EXPORT", 52 "RSA EXPORT",
53 mhd_gtls_gen_cert_server_certificate, 53 MHD_gtls_gen_cert_server_certificate,
54 mhd_gtls_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 MHD__gnutls_gen_rsa_client_kx,
57 mhd_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */ 57 MHD_gtls_gen_cert_client_cert_vrfy, /* gen client cert vrfy */
58 mhd_gtls_gen_cert_server_cert_req, /* server cert request */ 58 MHD_gtls_gen_cert_server_cert_req, /* server cert request */
59 59
60 mhd_gtls_proc_cert_server_certificate, 60 MHD_gtls_proc_cert_server_certificate,
61 _gnutls_proc_cert_client_certificate, 61 MHD__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 MHD__gnutls_proc_rsa_client_kx, /* proc client kx */
64 mhd_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ 64 MHD_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */
65 mhd_gtls_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 (mhd_gtls_session_t session, opaque ** data) 69gen_rsa_export_server_kx (MHD_gtls_session_t session, opaque ** data)
70{ 70{
71 mhd_gtls_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;
75 int ret = 0, data_size; 75 int ret = 0, data_size;
76 gnutls_cert *apr_cert_list; 76 MHD_gnutls_cert *apr_cert_list;
77 gnutls_privkey *apr_pkey; 77 MHD_gnutls_privkey *apr_pkey;
78 int apr_cert_list_length; 78 int apr_cert_list_length;
79 gnutls_datum_t signature, ddata; 79 MHD_gnutls_datum_t signature, ddata;
80 mhd_gtls_cert_credentials_t cred; 80 MHD_gtls_cert_credentials_t cred;
81 81
82 cred = (mhd_gtls_cert_credentials_t) 82 cred = (MHD_gtls_cert_credentials_t)
83 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 83 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
84 if (cred == NULL) 84 if (cred == NULL)
85 { 85 {
86 gnutls_assert (); 86 MHD_gnutls_assert ();
87 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 87 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
88 } 88 }
89 89
90 /* find the appropriate certificate */ 90 /* find the appropriate certificate */
91 if ((ret = 91 if ((ret =
92 mhd_gtls_get_selected_cert (session, &apr_cert_list, 92 MHD_gtls_get_selected_cert (session, &apr_cert_list,
93 &apr_cert_list_length, &apr_pkey)) < 0) 93 &apr_cert_list_length, &apr_pkey)) < 0)
94 { 94 {
95 gnutls_assert (); 95 MHD_gnutls_assert ();
96 return ret; 96 return ret;
97 } 97 }
98 98
99 /* abort sending this message if we have a certificate 99 /* abort sending this message if we have a certificate
100 * of 512 bits or less. 100 * of 512 bits or less.
101 */ 101 */
102 if (apr_pkey && _gnutls_mpi_get_nbits (apr_pkey->params[0]) <= 512) 102 if (apr_pkey && MHD__gnutls_mpi_get_nbits (apr_pkey->params[0]) <= 512)
103 { 103 {
104 gnutls_assert (); 104 MHD_gnutls_assert ();
105 return GNUTLS_E_INT_RET_0; 105 return GNUTLS_E_INT_RET_0;
106 } 106 }
107 107
108 rsa_params = 108 rsa_params =
109 mhd_gtls_certificate_get_rsa_params (cred->rsa_params, cred->params_func, 109 MHD_gtls_certificate_get_rsa_params (cred->rsa_params, cred->params_func,
110 session); 110 session);
111 rsa_mpis = _gnutls_rsa_params_to_mpi (rsa_params); 111 rsa_mpis = MHD__gnutls_rsa_params_to_mpi (rsa_params);
112 if (rsa_mpis == NULL) 112 if (rsa_mpis == NULL)
113 { 113 {
114 gnutls_assert (); 114 MHD_gnutls_assert ();
115 return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS; 115 return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS;
116 } 116 }
117 117
118 if ((ret = mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 118 if ((ret = MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
119 sizeof (cert_auth_info_st), 0)) < 0) 119 sizeof (cert_auth_info_st), 0)) < 0)
120 { 120 {
121 gnutls_assert (); 121 MHD_gnutls_assert ();
122 return ret; 122 return ret;
123 } 123 }
124 124
125 mhd_gtls_rsa_export_set_pubkey (session, rsa_mpis[1], rsa_mpis[0]); 125 MHD_gtls_rsa_export_set_pubkey (session, rsa_mpis[1], rsa_mpis[0]);
126 126
127 mhd_gtls_mpi_print (NULL, &n_m, rsa_mpis[0]); 127 MHD_gtls_mpi_print (NULL, &n_m, rsa_mpis[0]);
128 mhd_gtls_mpi_print (NULL, &n_e, rsa_mpis[1]); 128 MHD_gtls_mpi_print (NULL, &n_e, rsa_mpis[1]);
129 129
130 (*data) = gnutls_malloc (n_e + n_m + 4); 130 (*data) = MHD_gnutls_malloc (n_e + n_m + 4);
131 if (*data == NULL) 131 if (*data == NULL)
132 { 132 {
133 return GNUTLS_E_MEMORY_ERROR; 133 return GNUTLS_E_MEMORY_ERROR;
134 } 134 }
135 135
136 data_m = &(*data)[0]; 136 data_m = &(*data)[0];
137 mhd_gtls_mpi_print (&data_m[2], &n_m, rsa_mpis[0]); 137 MHD_gtls_mpi_print (&data_m[2], &n_m, rsa_mpis[0]);
138 138
139 mhd_gtls_write_uint16 (n_m, data_m); 139 MHD_gtls_write_uint16 (n_m, data_m);
140 140
141 data_e = &data_m[2 + n_m]; 141 data_e = &data_m[2 + n_m];
142 mhd_gtls_mpi_print (&data_e[2], &n_e, rsa_mpis[1]); 142 MHD_gtls_mpi_print (&data_e[2], &n_e, rsa_mpis[1]);
143 143
144 mhd_gtls_write_uint16 (n_e, data_e); 144 MHD_gtls_write_uint16 (n_e, data_e);
145 145
146 data_size = n_m + n_e + 4; 146 data_size = n_m + n_e + 4;
147 147
@@ -154,33 +154,33 @@ gen_rsa_export_server_kx (mhd_gtls_session_t session, opaque ** data)
154 if (apr_cert_list_length > 0) 154 if (apr_cert_list_length > 0)
155 { 155 {
156 if ((ret = 156 if ((ret =
157 mhd_gtls_tls_sign_params (session, &apr_cert_list[0], 157 MHD_gtls_tls_sign_params (session, &apr_cert_list[0],
158 apr_pkey, &ddata, &signature)) < 0) 158 apr_pkey, &ddata, &signature)) < 0)
159 { 159 {
160 gnutls_assert (); 160 MHD_gnutls_assert ();
161 gnutls_free (*data); 161 MHD_gnutls_free (*data);
162 *data = NULL; 162 *data = NULL;
163 return ret; 163 return ret;
164 } 164 }
165 } 165 }
166 else 166 else
167 { 167 {
168 gnutls_assert (); 168 MHD_gnutls_assert ();
169 return data_size; /* do not put a signature - ILLEGAL! */ 169 return data_size; /* do not put a signature - ILLEGAL! */
170 } 170 }
171 171
172 *data = mhd_gtls_realloc_fast (*data, data_size + signature.size + 2); 172 *data = MHD_gtls_realloc_fast (*data, data_size + signature.size + 2);
173 if (*data == NULL) 173 if (*data == NULL)
174 { 174 {
175 _gnutls_free_datum (&signature); 175 MHD__gnutls_free_datum (&signature);
176 gnutls_assert (); 176 MHD_gnutls_assert ();
177 return GNUTLS_E_MEMORY_ERROR; 177 return GNUTLS_E_MEMORY_ERROR;
178 } 178 }
179 179
180 mhd_gtls_write_datum16 (&((*data)[data_size]), signature); 180 MHD_gtls_write_datum16 (&((*data)[data_size]), signature);
181 data_size += signature.size + 2; 181 data_size += signature.size + 2;
182 182
183 _gnutls_free_datum (&signature); 183 MHD__gnutls_free_datum (&signature);
184 184
185 return data_size; 185 return data_size;
186} 186}
@@ -188,49 +188,49 @@ gen_rsa_export_server_kx (mhd_gtls_session_t session, opaque ** data)
188/* if the peer's certificate is of 512 bits or less, returns non zero. 188/* if the peer's certificate is of 512 bits or less, returns non zero.
189 */ 189 */
190int 190int
191_gnutls_peers_cert_less_512 (mhd_gtls_session_t session) 191MHD__gnutls_peers_cert_less_512 (MHD_gtls_session_t session)
192{ 192{
193 gnutls_cert peer_cert; 193 MHD_gnutls_cert peer_cert;
194 int ret; 194 int ret;
195 cert_auth_info_t info = mhd_gtls_get_auth_info (session); 195 cert_auth_info_t info = MHD_gtls_get_auth_info (session);
196 196
197 if (info == NULL || info->ncerts == 0) 197 if (info == NULL || info->ncerts == 0)
198 { 198 {
199 gnutls_assert (); 199 MHD_gnutls_assert ();
200 /* we need this in order to get peer's certificate */ 200 /* we need this in order to get peer's certificate */
201 return 0; 201 return 0;
202 } 202 }
203 203
204 if ((ret = 204 if ((ret =
205 mhd_gtls_raw_cert_to_gcert (&peer_cert, 205 MHD_gtls_raw_cert_to_gcert (&peer_cert,
206 session->security_parameters.cert_type, 206 session->security_parameters.cert_type,
207 &info->raw_certificate_list[0], 207 &info->raw_certificate_list[0],
208 CERT_NO_COPY)) < 0) 208 CERT_NO_COPY)) < 0)
209 { 209 {
210 gnutls_assert (); 210 MHD_gnutls_assert ();
211 return 0; 211 return 0;
212 } 212 }
213 213
214 if (peer_cert.subject_pk_algorithm != MHD_GNUTLS_PK_RSA) 214 if (peer_cert.subject_pk_algorithm != MHD_GNUTLS_PK_RSA)
215 { 215 {
216 gnutls_assert (); 216 MHD_gnutls_assert ();
217 mhd_gtls_gcert_deinit (&peer_cert); 217 MHD_gtls_gcert_deinit (&peer_cert);
218 return 0; 218 return 0;
219 } 219 }
220 220
221 if (_gnutls_mpi_get_nbits (peer_cert.params[0]) <= 512) 221 if (MHD__gnutls_mpi_get_nbits (peer_cert.params[0]) <= 512)
222 { 222 {
223 mhd_gtls_gcert_deinit (&peer_cert); 223 MHD_gtls_gcert_deinit (&peer_cert);
224 return 1; 224 return 1;
225 } 225 }
226 226
227 mhd_gtls_gcert_deinit (&peer_cert); 227 MHD_gtls_gcert_deinit (&peer_cert);
228 228
229 return 0; 229 return 0;
230} 230}
231 231
232static int 232static int
233proc_rsa_export_server_kx (mhd_gtls_session_t session, 233proc_rsa_export_server_kx (MHD_gtls_session_t session,
234 opaque * data, size_t _data_size) 234 opaque * data, size_t _data_size)
235{ 235{
236 uint16_t n_m, n_e; 236 uint16_t n_m, n_e;
@@ -238,16 +238,16 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
238 uint8_t *data_m; 238 uint8_t *data_m;
239 uint8_t *data_e; 239 uint8_t *data_e;
240 int i, sigsize; 240 int i, sigsize;
241 gnutls_datum_t vparams, signature; 241 MHD_gnutls_datum_t vparams, signature;
242 int ret; 242 int ret;
243 ssize_t data_size = _data_size; 243 ssize_t data_size = _data_size;
244 cert_auth_info_t info; 244 cert_auth_info_t info;
245 gnutls_cert peer_cert; 245 MHD_gnutls_cert peer_cert;
246 246
247 info = mhd_gtls_get_auth_info (session); 247 info = MHD_gtls_get_auth_info (session);
248 if (info == NULL || info->ncerts == 0) 248 if (info == NULL || info->ncerts == 0)
249 { 249 {
250 gnutls_assert (); 250 MHD_gnutls_assert ();
251 /* we need this in order to get peer's certificate */ 251 /* we need this in order to get peer's certificate */
252 return GNUTLS_E_INTERNAL_ERROR; 252 return GNUTLS_E_INTERNAL_ERROR;
253 } 253 }
@@ -256,7 +256,7 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
256 i = 0; 256 i = 0;
257 257
258 DECR_LEN (data_size, 2); 258 DECR_LEN (data_size, 2);
259 n_m = mhd_gtls_read_uint16 (&data[i]); 259 n_m = MHD_gtls_read_uint16 (&data[i]);
260 i += 2; 260 i += 2;
261 261
262 DECR_LEN (data_size, n_m); 262 DECR_LEN (data_size, n_m);
@@ -264,7 +264,7 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
264 i += n_m; 264 i += n_m;
265 265
266 DECR_LEN (data_size, 2); 266 DECR_LEN (data_size, 2);
267 n_e = mhd_gtls_read_uint16 (&data[i]); 267 n_e = MHD_gtls_read_uint16 (&data[i]);
268 i += 2; 268 i += 2;
269 269
270 DECR_LEN (data_size, n_e); 270 DECR_LEN (data_size, n_e);
@@ -274,19 +274,19 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
274 _n_e = n_e; 274 _n_e = n_e;
275 _n_m = n_m; 275 _n_m = n_m;
276 276
277 if (mhd_gtls_mpi_scan_nz (&session->key->rsa[0], data_m, &_n_m) != 0) 277 if (MHD_gtls_mpi_scan_nz (&session->key->rsa[0], data_m, &_n_m) != 0)
278 { 278 {
279 gnutls_assert (); 279 MHD_gnutls_assert ();
280 return GNUTLS_E_MPI_SCAN_FAILED; 280 return GNUTLS_E_MPI_SCAN_FAILED;
281 } 281 }
282 282
283 if (mhd_gtls_mpi_scan_nz (&session->key->rsa[1], data_e, &_n_e) != 0) 283 if (MHD_gtls_mpi_scan_nz (&session->key->rsa[1], data_e, &_n_e) != 0)
284 { 284 {
285 gnutls_assert (); 285 MHD_gnutls_assert ();
286 return GNUTLS_E_MPI_SCAN_FAILED; 286 return GNUTLS_E_MPI_SCAN_FAILED;
287 } 287 }
288 288
289 mhd_gtls_rsa_export_set_pubkey (session, session->key->rsa[1], 289 MHD_gtls_rsa_export_set_pubkey (session, session->key->rsa[1],
290 session->key->rsa[0]); 290 session->key->rsa[0]);
291 291
292 /* VERIFY SIGNATURE */ 292 /* VERIFY SIGNATURE */
@@ -295,29 +295,29 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
295 vparams.data = data; 295 vparams.data = data;
296 296
297 DECR_LEN (data_size, 2); 297 DECR_LEN (data_size, 2);
298 sigsize = mhd_gtls_read_uint16 (&data[vparams.size]); 298 sigsize = MHD_gtls_read_uint16 (&data[vparams.size]);
299 299
300 DECR_LEN (data_size, sigsize); 300 DECR_LEN (data_size, sigsize);
301 signature.data = &data[vparams.size + 2]; 301 signature.data = &data[vparams.size + 2];
302 signature.size = sigsize; 302 signature.size = sigsize;
303 303
304 if ((ret = 304 if ((ret =
305 mhd_gtls_raw_cert_to_gcert (&peer_cert, 305 MHD_gtls_raw_cert_to_gcert (&peer_cert,
306 session->security_parameters.cert_type, 306 session->security_parameters.cert_type,
307 &info->raw_certificate_list[0], 307 &info->raw_certificate_list[0],
308 CERT_NO_COPY)) < 0) 308 CERT_NO_COPY)) < 0)
309 { 309 {
310 gnutls_assert (); 310 MHD_gnutls_assert ();
311 return ret; 311 return ret;
312 } 312 }
313 313
314 ret = 314 ret =
315 mhd_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature); 315 MHD_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
316 316
317 mhd_gtls_gcert_deinit (&peer_cert); 317 MHD_gtls_gcert_deinit (&peer_cert);
318 if (ret < 0) 318 if (ret < 0)
319 { 319 {
320 gnutls_assert (); 320 MHD_gnutls_assert ();
321 } 321 }
322 322
323 return ret; 323 return ret;
diff --git a/src/daemon/https/tls/debug.c b/src/daemon/https/tls/debug.c
index 14c7b494..21cd945f 100644
--- a/src/daemon/https/tls/debug.c
+++ b/src/daemon/https/tls/debug.c
@@ -32,26 +32,26 @@
32 32
33 33
34void 34void
35_gnutls_print_state (mhd_gtls_session_t session) 35MHD__gnutls_print_state (MHD_gtls_session_t session)
36{ 36{
37 37
38 _gnutls_debug_log ("GNUTLS State:\n"); 38 MHD__gnutls_debug_log ("GNUTLS State:\n");
39 _gnutls_debug_log ("Connection End: %d\n", 39 MHD__gnutls_debug_log ("Connection End: %d\n",
40 session->security_parameters.entity); 40 session->security_parameters.entity);
41 _gnutls_debug_log ("Cipher Algorithm: %d\n", 41 MHD__gnutls_debug_log ("Cipher Algorithm: %d\n",
42 session->security_parameters.read_bulk_cipher_algorithm); 42 session->security_parameters.read_bulk_cipher_algorithm);
43 _gnutls_debug_log ("MAC algorithm: %d\n", 43 MHD__gnutls_debug_log ("MAC algorithm: %d\n",
44 session->security_parameters.read_mac_algorithm); 44 session->security_parameters.read_mac_algorithm);
45 _gnutls_debug_log ("Compression Algorithm: %d\n", 45 MHD__gnutls_debug_log ("Compression Algorithm: %d\n",
46 session->security_parameters.read_compression_algorithm); 46 session->security_parameters.read_compression_algorithm);
47 _gnutls_debug_log ("\n"); 47 MHD__gnutls_debug_log ("\n");
48 48
49} 49}
50 50
51#endif 51#endif
52 52
53const char * 53const char *
54_gnutls_packet2str (content_type_t packet) 54MHD__gnutls_packet2str (content_type_t packet)
55{ 55{
56 switch (packet) 56 switch (packet)
57 { 57 {
@@ -72,7 +72,7 @@ _gnutls_packet2str (content_type_t packet)
72} 72}
73 73
74const char * 74const char *
75_gnutls_handshake2str (gnutls_handshake_description_t handshake) 75MHD__gnutls_handshake2str (MHD_gnutls_handshake_description_t handshake)
76{ 76{
77 77
78 switch (handshake) 78 switch (handshake)
@@ -117,12 +117,12 @@ _gnutls_handshake2str (gnutls_handshake_description_t handshake)
117} 117}
118 118
119void 119void
120_gnutls_dump_mpi (const char *prefix, mpi_t a) 120MHD__gnutls_dump_mpi (const char *prefix, mpi_t a)
121{ 121{
122 opaque buf[1024]; 122 opaque buf[1024];
123 size_t n = sizeof buf; 123 size_t n = sizeof buf;
124 124
125 if (gcry_mpi_print (GCRYMPI_FMT_HEX, buf, n, &n, a)) 125 if (gcry_mpi_print (GCRYMPI_FMT_HEX, buf, n, &n, a))
126 strcpy (buf, "[can't print value]"); /* Flawfinder: ignore */ 126 strcpy (buf, "[can't print value]"); /* Flawfinder: ignore */
127 _gnutls_hard_log ("MPI: length: %d\n\t%s%s\n", (n - 1) / 2, prefix, buf); 127 MHD__gnutls_hard_log ("MPI: length: %d\n\t%s%s\n", (n - 1) / 2, prefix, buf);
128} 128}
diff --git a/src/daemon/https/tls/debug.h b/src/daemon/https/tls/debug.h
index ccaf0f17..637beca8 100644
--- a/src/daemon/https/tls/debug.h
+++ b/src/daemon/https/tls/debug.h
@@ -23,8 +23,8 @@
23 */ 23 */
24 24
25#ifdef DEBUG 25#ifdef DEBUG
26void _gnutls_print_state (mhd_gtls_session_t session); 26void MHD__gnutls_print_state (MHD_gtls_session_t session);
27#endif 27#endif
28const char *_gnutls_packet2str (content_type_t packet); 28const char *MHD__gnutls_packet2str (content_type_t packet);
29const char *_gnutls_handshake2str (gnutls_handshake_description_t handshake); 29const char *MHD__gnutls_handshake2str (MHD_gnutls_handshake_description_t handshake);
30void _gnutls_dump_mpi (const char *prefix, mpi_t a); 30void MHD__gnutls_dump_mpi (const char *prefix, mpi_t a);
diff --git a/src/daemon/https/tls/ext_cert_type.c b/src/daemon/https/tls/ext_cert_type.c
index 9e00120c..4feeb18f 100644
--- a/src/daemon/https/tls/ext_cert_type.c
+++ b/src/daemon/https/tls/ext_cert_type.c
@@ -33,12 +33,12 @@
33#include "gnutls_state.h" 33#include "gnutls_state.h"
34#include "gnutls_num.h" 34#include "gnutls_num.h"
35 35
36inline static int _gnutls_num2cert_type (int num); 36inline static int MHD__gnutls_num2cert_type (int num);
37inline static int _gnutls_cert_type2num (int record_size); 37inline static int MHD__gnutls_cert_type2num (int record_size);
38 38
39/* 39/*
40 * In case of a server: if a CERT_TYPE extension type is received then it stores 40 * In case of a server: if a CERT_TYPE extension type is received then it stores
41 * into the session security parameters the new value. The server may use gnutls_session_certificate_type_get(), 41 * into the session security parameters the new value. The server may use MHD_gnutls_session_certificate_type_get(),
42 * to access it. 42 * to access it.
43 * 43 *
44 * In case of a client: If a cert_types have been specified then we send the extension. 44 * In case of a client: If a cert_types have been specified then we send the extension.
@@ -46,7 +46,7 @@ inline static int _gnutls_cert_type2num (int record_size);
46 */ 46 */
47 47
48int 48int
49mhd_gtls_cert_type_recv_params (mhd_gtls_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;
@@ -59,27 +59,27 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
59 { 59 {
60 if (data_size != 1) 60 if (data_size != 1)
61 { 61 {
62 gnutls_assert (); 62 MHD_gnutls_assert ();
63 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 63 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
64 } 64 }
65 65
66 new_type = _gnutls_num2cert_type (data[0]); 66 new_type = MHD__gnutls_num2cert_type (data[0]);
67 67
68 if (new_type < 0) 68 if (new_type < 0)
69 { 69 {
70 gnutls_assert (); 70 MHD_gnutls_assert ();
71 return new_type; 71 return new_type;
72 } 72 }
73 73
74 /* Check if we support this cert_type */ 74 /* Check if we support this cert_type */
75 if ((ret = 75 if ((ret =
76 mhd_gtls_session_cert_type_supported (session, new_type)) < 0) 76 MHD_gtls_session_cert_type_supported (session, new_type)) < 0)
77 { 77 {
78 gnutls_assert (); 78 MHD_gnutls_assert ();
79 return ret; 79 return ret;
80 } 80 }
81 81
82 _gnutls_session_cert_type_set (session, new_type); 82 MHD__gnutls_session_cert_type_set (session, new_type);
83 } 83 }
84 } 84 }
85 else 85 else
@@ -96,17 +96,17 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
96 96
97 for (i = 0; i < len; i++) 97 for (i = 0; i < len; i++)
98 { 98 {
99 new_type = _gnutls_num2cert_type (data[i + 1]); 99 new_type = MHD__gnutls_num2cert_type (data[i + 1]);
100 100
101 if (new_type < 0) 101 if (new_type < 0)
102 continue; 102 continue;
103 103
104 /* Check if we support this cert_type */ 104 /* Check if we support this cert_type */
105 if ((ret = 105 if ((ret =
106 mhd_gtls_session_cert_type_supported (session, 106 MHD_gtls_session_cert_type_supported (session,
107 new_type)) < 0) 107 new_type)) < 0)
108 { 108 {
109 gnutls_assert (); 109 MHD_gnutls_assert ();
110 continue; 110 continue;
111 } 111 }
112 else 112 else
@@ -116,14 +116,14 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
116 116
117 if (new_type < 0) 117 if (new_type < 0)
118 { 118 {
119 gnutls_assert (); 119 MHD_gnutls_assert ();
120 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; 120 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
121 } 121 }
122 122
123 if ((ret = 123 if ((ret =
124 mhd_gtls_session_cert_type_supported (session, new_type)) < 0) 124 MHD_gtls_session_cert_type_supported (session, new_type)) < 0)
125 { 125 {
126 gnutls_assert (); 126 MHD_gnutls_assert ();
127 /* The peer has requested unsupported certificate 127 /* The peer has requested unsupported certificate
128 * types. Instead of failing, procceed normally. 128 * types. Instead of failing, procceed normally.
129 * (the ciphersuite selection would fail, or a 129 * (the ciphersuite selection would fail, or a
@@ -132,7 +132,7 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
132 return 0; 132 return 0;
133 } 133 }
134 134
135 _gnutls_session_cert_type_set (session, new_type); 135 MHD__gnutls_session_cert_type_set (session, new_type);
136 } 136 }
137 137
138 138
@@ -144,7 +144,7 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
144/* returns data_size or a negative number on failure 144/* returns data_size or a negative number on failure
145 */ 145 */
146int 146int
147mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data, 147MHD_gtls_cert_type_send_params (MHD_gtls_session_t session, opaque * data,
148 size_t data_size) 148 size_t data_size)
149{ 149{
150 unsigned len, i; 150 unsigned len, i;
@@ -171,7 +171,7 @@ mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
171 171
172 if (data_size < len + 1) 172 if (data_size < len + 1)
173 { 173 {
174 gnutls_assert (); 174 MHD_gnutls_assert ();
175 return GNUTLS_E_SHORT_MEMORY_BUFFER; 175 return GNUTLS_E_SHORT_MEMORY_BUFFER;
176 } 176 }
177 177
@@ -182,7 +182,7 @@ mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
182 for (i = 0; i < len; i++) 182 for (i = 0; i < len; i++)
183 { 183 {
184 data[i + 1] = 184 data[i + 1] =
185 _gnutls_cert_type2num (session->internals. 185 MHD__gnutls_cert_type2num (session->internals.
186 priorities.cert_type.priority[i]); 186 priorities.cert_type.priority[i]);
187 } 187 }
188 return len + 1; 188 return len + 1;
@@ -197,12 +197,12 @@ mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
197 len = 1; 197 len = 1;
198 if (data_size < len) 198 if (data_size < len)
199 { 199 {
200 gnutls_assert (); 200 MHD_gnutls_assert ();
201 return GNUTLS_E_SHORT_MEMORY_BUFFER; 201 return GNUTLS_E_SHORT_MEMORY_BUFFER;
202 } 202 }
203 203
204 data[0] = 204 data[0] =
205 _gnutls_cert_type2num (session->security_parameters.cert_type); 205 MHD__gnutls_cert_type2num (session->security_parameters.cert_type);
206 return len; 206 return len;
207 } 207 }
208 208
@@ -216,7 +216,7 @@ mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
216 * extensions draft. 216 * extensions draft.
217 */ 217 */
218inline static int 218inline static int
219_gnutls_num2cert_type (int num) 219MHD__gnutls_num2cert_type (int num)
220{ 220{
221 switch (num) 221 switch (num)
222 { 222 {
@@ -231,7 +231,7 @@ _gnutls_num2cert_type (int num)
231 * extensions draft. 231 * extensions draft.
232 */ 232 */
233inline static int 233inline static int
234_gnutls_cert_type2num (int cert_type) 234MHD__gnutls_cert_type2num (int cert_type)
235{ 235{
236 switch (cert_type) 236 switch (cert_type)
237 { 237 {
diff --git a/src/daemon/https/tls/ext_cert_type.h b/src/daemon/https/tls/ext_cert_type.h
index cd9b0acc..f80f7ba8 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 mhd_gtls_cert_type_recv_params (mhd_gtls_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 mhd_gtls_cert_type_send_params (mhd_gtls_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_max_record.c b/src/daemon/https/tls/ext_max_record.c
index 1b5f2be2..421a1739 100644
--- a/src/daemon/https/tls/ext_max_record.c
+++ b/src/daemon/https/tls/ext_max_record.c
@@ -32,7 +32,7 @@
32 32
33/* 33/*
34 * In case of a server: if a MAX_RECORD_SIZE extension type is received then it stores 34 * In case of a server: if a MAX_RECORD_SIZE extension type is received then it stores
35 * into the session the new value. The server may use gnutls_get_max_record_size(), 35 * into the session the new value. The server may use MHD_gnutls_get_max_record_size(),
36 * in order to access it. 36 * in order to access it.
37 * 37 *
38 * In case of a client: If a different max record size (than the default) has 38 * In case of a client: If a different max record size (than the default) has
@@ -41,7 +41,7 @@
41 */ 41 */
42 42
43int 43int
44mhd_gtls_max_record_recv_params (mhd_gtls_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,11 +53,11 @@ mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
53 { 53 {
54 DECR_LEN (data_size, 1); 54 DECR_LEN (data_size, 1);
55 55
56 new_size = mhd_gtls_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 {
60 gnutls_assert (); 60 MHD_gnutls_assert ();
61 return new_size; 61 return new_size;
62 } 62 }
63 63
@@ -73,16 +73,16 @@ mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
73 73
74 if (data_size != 1) 74 if (data_size != 1)
75 { 75 {
76 gnutls_assert (); 76 MHD_gnutls_assert ();
77 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 77 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
78 } 78 }
79 79
80 new_size = mhd_gtls_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)
84 { 84 {
85 gnutls_assert (); 85 MHD_gnutls_assert ();
86 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; 86 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
87 } 87 }
88 else 88 else
@@ -102,7 +102,7 @@ mhd_gtls_max_record_recv_params (mhd_gtls_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
105mhd_gtls_max_record_send_params (mhd_gtls_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;
@@ -116,12 +116,12 @@ mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
116 len = 1; 116 len = 1;
117 if (data_size < len) 117 if (data_size < len)
118 { 118 {
119 gnutls_assert (); 119 MHD_gnutls_assert ();
120 return GNUTLS_E_SHORT_MEMORY_BUFFER; 120 return GNUTLS_E_SHORT_MEMORY_BUFFER;
121 } 121 }
122 122
123 data[0] = 123 data[0] =
124 (uint8_t) mhd_gtls_mre_record2num (session->internals. 124 (uint8_t) MHD_gtls_mre_record2num (session->internals.
125 proposed_record_size); 125 proposed_record_size);
126 return len; 126 return len;
127 } 127 }
@@ -137,13 +137,13 @@ mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
137 len = 1; 137 len = 1;
138 if (data_size < len) 138 if (data_size < len)
139 { 139 {
140 gnutls_assert (); 140 MHD_gnutls_assert ();
141 return GNUTLS_E_SHORT_MEMORY_BUFFER; 141 return GNUTLS_E_SHORT_MEMORY_BUFFER;
142 } 142 }
143 143
144 data[0] = 144 data[0] =
145 (uint8_t) 145 (uint8_t)
146 mhd_gtls_mre_record2num 146 MHD_gtls_mre_record2num
147 (session->security_parameters.max_record_recv_size); 147 (session->security_parameters.max_record_recv_size);
148 return len; 148 return len;
149 } 149 }
@@ -158,7 +158,7 @@ mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
158 * extensions draft. 158 * extensions draft.
159 */ 159 */
160int 160int
161mhd_gtls_mre_num2record (int num) 161MHD_gtls_mre_num2record (int num)
162{ 162{
163 switch (num) 163 switch (num)
164 { 164 {
@@ -179,7 +179,7 @@ mhd_gtls_mre_num2record (int num)
179 * extensions draft. 179 * extensions draft.
180 */ 180 */
181int 181int
182mhd_gtls_mre_record2num (uint16_t record_size) 182MHD_gtls_mre_record2num (uint16_t record_size)
183{ 183{
184 switch (record_size) 184 switch (record_size)
185 { 185 {
diff --git a/src/daemon/https/tls/ext_max_record.h b/src/daemon/https/tls/ext_max_record.h
index 361470a9..14686253 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 mhd_gtls_mre_num2record (int num); 28int MHD_gtls_mre_num2record (int num);
29int mhd_gtls_mre_record2num (uint16_t record_size); 29int MHD_gtls_mre_record2num (uint16_t record_size);
30int mhd_gtls_max_record_recv_params (mhd_gtls_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 mhd_gtls_max_record_send_params (mhd_gtls_session_t session, 32int MHD_gtls_max_record_send_params (MHD_gtls_session_t session,
33 opaque * data, size_t); 33 opaque * data, size_t);
diff --git a/src/daemon/https/tls/ext_oprfi.c b/src/daemon/https/tls/ext_oprfi.c
index b2dad0ff..09ef51cd 100644
--- a/src/daemon/https/tls/ext_oprfi.c
+++ b/src/daemon/https/tls/ext_oprfi.c
@@ -34,7 +34,7 @@
34#include <gnutls_num.h> 34#include <gnutls_num.h>
35 35
36static int 36static int
37oprfi_recv_server (mhd_gtls_session_t session, 37oprfi_recv_server (MHD_gtls_session_t session,
38 const opaque * data, size_t _data_size) 38 const opaque * data, size_t _data_size)
39{ 39{
40 ssize_t data_size = _data_size; 40 ssize_t data_size = _data_size;
@@ -42,26 +42,26 @@ oprfi_recv_server (mhd_gtls_session_t session,
42 42
43 if (!session->security_parameters.extensions.oprfi_cb) 43 if (!session->security_parameters.extensions.oprfi_cb)
44 { 44 {
45 gnutls_assert (); 45 MHD_gnutls_assert ();
46 return 0; 46 return 0;
47 } 47 }
48 48
49 DECR_LEN (data_size, 2); 49 DECR_LEN (data_size, 2);
50 len = mhd_gtls_read_uint16 (data); 50 len = MHD_gtls_read_uint16 (data);
51 data += 2; 51 data += 2;
52 52
53 if (len != data_size) 53 if (len != data_size)
54 { 54 {
55 gnutls_assert (); 55 MHD_gnutls_assert ();
56 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 56 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
57 } 57 }
58 58
59 /* Store incoming data. */ 59 /* Store incoming data. */
60 session->security_parameters.extensions.oprfi_client_len = len; 60 session->security_parameters.extensions.oprfi_client_len = len;
61 session->security_parameters.extensions.oprfi_client = gnutls_malloc (len); 61 session->security_parameters.extensions.oprfi_client = MHD_gnutls_malloc (len);
62 if (!session->security_parameters.extensions.oprfi_client) 62 if (!session->security_parameters.extensions.oprfi_client)
63 { 63 {
64 gnutls_assert (); 64 MHD_gnutls_assert ();
65 return GNUTLS_E_MEMORY_ERROR; 65 return GNUTLS_E_MEMORY_ERROR;
66 } 66 }
67 memcpy (session->security_parameters.extensions.oprfi_client, data, len); 67 memcpy (session->security_parameters.extensions.oprfi_client, data, len);
@@ -70,7 +70,7 @@ oprfi_recv_server (mhd_gtls_session_t session,
70} 70}
71 71
72static int 72static int
73oprfi_recv_client (mhd_gtls_session_t session, 73oprfi_recv_client (MHD_gtls_session_t session,
74 const opaque * data, size_t _data_size) 74 const opaque * data, size_t _data_size)
75{ 75{
76 ssize_t data_size = _data_size; 76 ssize_t data_size = _data_size;
@@ -78,32 +78,32 @@ oprfi_recv_client (mhd_gtls_session_t session,
78 78
79 if (session->security_parameters.extensions.oprfi_client == NULL) 79 if (session->security_parameters.extensions.oprfi_client == NULL)
80 { 80 {
81 gnutls_assert (); 81 MHD_gnutls_assert ();
82 return 0; 82 return 0;
83 } 83 }
84 84
85 DECR_LEN (data_size, 2); 85 DECR_LEN (data_size, 2);
86 len = mhd_gtls_read_uint16 (data); 86 len = MHD_gtls_read_uint16 (data);
87 data += 2; 87 data += 2;
88 88
89 if (len != data_size) 89 if (len != data_size)
90 { 90 {
91 gnutls_assert (); 91 MHD_gnutls_assert ();
92 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 92 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
93 } 93 }
94 94
95 if (len != session->security_parameters.extensions.oprfi_client_len) 95 if (len != session->security_parameters.extensions.oprfi_client_len)
96 { 96 {
97 gnutls_assert (); 97 MHD_gnutls_assert ();
98 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; 98 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
99 } 99 }
100 100
101 /* Store incoming data. */ 101 /* Store incoming data. */
102 session->security_parameters.extensions.oprfi_server_len = len; 102 session->security_parameters.extensions.oprfi_server_len = len;
103 session->security_parameters.extensions.oprfi_server = gnutls_malloc (len); 103 session->security_parameters.extensions.oprfi_server = MHD_gnutls_malloc (len);
104 if (!session->security_parameters.extensions.oprfi_server) 104 if (!session->security_parameters.extensions.oprfi_server)
105 { 105 {
106 gnutls_assert (); 106 MHD_gnutls_assert ();
107 return GNUTLS_E_MEMORY_ERROR; 107 return GNUTLS_E_MEMORY_ERROR;
108 } 108 }
109 memcpy (session->security_parameters.extensions.oprfi_server, data, len); 109 memcpy (session->security_parameters.extensions.oprfi_server, data, len);
@@ -112,7 +112,7 @@ oprfi_recv_client (mhd_gtls_session_t session,
112} 112}
113 113
114int 114int
115mhd_gtls_oprfi_recv_params (mhd_gtls_session_t session, 115MHD_gtls_oprfi_recv_params (MHD_gtls_session_t session,
116 const opaque * data, size_t data_size) 116 const opaque * data, size_t data_size)
117{ 117{
118#if MHD_DEBUG_TLS 118#if MHD_DEBUG_TLS
@@ -124,7 +124,7 @@ mhd_gtls_oprfi_recv_params (mhd_gtls_session_t session,
124} 124}
125 125
126static int 126static int
127oprfi_send_client (mhd_gtls_session_t session, opaque * data, 127oprfi_send_client (MHD_gtls_session_t session, opaque * data,
128 size_t _data_size) 128 size_t _data_size)
129{ 129{
130 opaque *p = data; 130 opaque *p = data;
@@ -135,7 +135,7 @@ oprfi_send_client (mhd_gtls_session_t session, opaque * data,
135 return 0; 135 return 0;
136 136
137 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER); 137 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
138 mhd_gtls_write_uint16 (oprf_size, p); 138 MHD_gtls_write_uint16 (oprf_size, p);
139 p += 2; 139 p += 2;
140 140
141 DECR_LENGTH_RET (data_size, oprf_size, GNUTLS_E_SHORT_MEMORY_BUFFER); 141 DECR_LENGTH_RET (data_size, oprf_size, GNUTLS_E_SHORT_MEMORY_BUFFER);
@@ -146,7 +146,7 @@ oprfi_send_client (mhd_gtls_session_t session, opaque * data,
146} 146}
147 147
148static int 148static int
149oprfi_send_server (mhd_gtls_session_t session, opaque * data, 149oprfi_send_server (MHD_gtls_session_t session, opaque * data,
150 size_t _data_size) 150 size_t _data_size)
151{ 151{
152 opaque *p = data; 152 opaque *p = data;
@@ -161,10 +161,10 @@ oprfi_send_server (mhd_gtls_session_t session, opaque * data,
161 session->security_parameters.extensions.oprfi_server_len = 161 session->security_parameters.extensions.oprfi_server_len =
162 session->security_parameters.extensions.oprfi_client_len; 162 session->security_parameters.extensions.oprfi_client_len;
163 session->security_parameters.extensions.oprfi_server = 163 session->security_parameters.extensions.oprfi_server =
164 gnutls_malloc (session->security_parameters.extensions.oprfi_server_len); 164 MHD_gnutls_malloc (session->security_parameters.extensions.oprfi_server_len);
165 if (!session->security_parameters.extensions.oprfi_server) 165 if (!session->security_parameters.extensions.oprfi_server)
166 { 166 {
167 gnutls_assert (); 167 MHD_gnutls_assert ();
168 return GNUTLS_E_MEMORY_ERROR; 168 return GNUTLS_E_MEMORY_ERROR;
169 } 169 }
170 170
@@ -176,13 +176,13 @@ oprfi_send_server (mhd_gtls_session_t session, opaque * data,
176 session->security_parameters.extensions.oprfi_server); 176 session->security_parameters.extensions.oprfi_server);
177 if (ret < 0) 177 if (ret < 0)
178 { 178 {
179 gnutls_assert (); 179 MHD_gnutls_assert ();
180 gnutls_free (session->security_parameters.extensions.oprfi_server); 180 MHD_gnutls_free (session->security_parameters.extensions.oprfi_server);
181 return ret; 181 return ret;
182 } 182 }
183 183
184 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER); 184 DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
185 mhd_gtls_write_uint16 (session->security_parameters. 185 MHD_gtls_write_uint16 (session->security_parameters.
186 extensions.oprfi_server_len, p); 186 extensions.oprfi_server_len, p);
187 p += 2; 187 p += 2;
188 188
@@ -197,7 +197,7 @@ oprfi_send_server (mhd_gtls_session_t session, opaque * data,
197} 197}
198 198
199int 199int
200mhd_gtls_oprfi_send_params (mhd_gtls_session_t session, 200MHD_gtls_oprfi_send_params (MHD_gtls_session_t session,
201 opaque * data, size_t data_size) 201 opaque * data, size_t data_size)
202{ 202{
203#if MHD_DEBUG_TLS 203#if MHD_DEBUG_TLS
@@ -210,7 +210,7 @@ mhd_gtls_oprfi_send_params (mhd_gtls_session_t session,
210 210
211/** 211/**
212 * MHD_gtls_oprfi_enable_client: 212 * MHD_gtls_oprfi_enable_client:
213 * @session: is a #mhd_gtls_session_t structure. 213 * @session: is a #MHD_gtls_session_t structure.
214 * @len: length of Opaque PRF data to use in client. 214 * @len: length of Opaque PRF data to use in client.
215 * @data: Opaque PRF data to use in client. 215 * @data: Opaque PRF data to use in client.
216 * 216 *
@@ -222,7 +222,7 @@ mhd_gtls_oprfi_send_params (mhd_gtls_session_t session,
222 * may de-allocate it immediately after calling this function. 222 * may de-allocate it immediately after calling this function.
223 **/ 223 **/
224void 224void
225MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session, 225MHD_gtls_oprfi_enable_client (MHD_gtls_session_t session,
226 size_t len, unsigned char *data) 226 size_t len, unsigned char *data)
227{ 227{
228 session->security_parameters.extensions.oprfi_client_len = len; 228 session->security_parameters.extensions.oprfi_client_len = len;
@@ -231,7 +231,7 @@ MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
231 231
232/** 232/**
233 * MHD_gtls_oprfi_enable_server: 233 * MHD_gtls_oprfi_enable_server:
234 * @session: is a #mhd_gtls_session_t structure. 234 * @session: is a #MHD_gtls_session_t structure.
235 * @cb: function pointer to Opaque PRF extension server callback. 235 * @cb: function pointer to Opaque PRF extension server callback.
236 * @userdata: hook passed to callback function for passing application state. 236 * @userdata: hook passed to callback function for passing application state.
237 * 237 *
@@ -240,7 +240,7 @@ MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
240 * provided callback @cb will be invoked. The callback must have the 240 * provided callback @cb will be invoked. The callback must have the
241 * following prototype: 241 * following prototype:
242 * 242 *
243 * int callback (mhd_gtls_session_t session, void *userdata, 243 * int callback (MHD_gtls_session_t session, void *userdata,
244 * size_t oprfi_len, const unsigned char *in_oprfi, 244 * size_t oprfi_len, const unsigned char *in_oprfi,
245 * unsigned char *out_oprfi); 245 * unsigned char *out_oprfi);
246 * 246 *
@@ -250,8 +250,8 @@ MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
250 * handshake will be aborted. 250 * handshake will be aborted.
251 **/ 251 **/
252void 252void
253MHD_gtls_oprfi_enable_server (mhd_gtls_session_t session, 253MHD_gtls_oprfi_enable_server (MHD_gtls_session_t session,
254 gnutls_oprfi_callback_func cb, void *userdata) 254 MHD_gnutls_oprfi_callback_func cb, void *userdata)
255{ 255{
256 session->security_parameters.extensions.oprfi_cb = cb; 256 session->security_parameters.extensions.oprfi_cb = cb;
257 session->security_parameters.extensions.oprfi_userdata = userdata; 257 session->security_parameters.extensions.oprfi_userdata = userdata;
diff --git a/src/daemon/https/tls/ext_oprfi.h b/src/daemon/https/tls/ext_oprfi.h
index defb672b..a3265499 100644
--- a/src/daemon/https/tls/ext_oprfi.h
+++ b/src/daemon/https/tls/ext_oprfi.h
@@ -24,8 +24,8 @@
24 24
25#include <gnutls_int.h> 25#include <gnutls_int.h>
26 26
27int mhd_gtls_oprfi_recv_params (mhd_gtls_session_t state, 27int MHD_gtls_oprfi_recv_params (MHD_gtls_session_t state,
28 const opaque * data, size_t data_size); 28 const opaque * data, size_t data_size);
29 29
30int mhd_gtls_oprfi_send_params (mhd_gtls_session_t state, 30int MHD_gtls_oprfi_send_params (MHD_gtls_session_t state,
31 opaque * data, size_t data_size); 31 opaque * data, 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 64ef0b06..9878fe62 100644
--- a/src/daemon/https/tls/ext_server_name.c
+++ b/src/daemon/https/tls/ext_server_name.c
@@ -30,7 +30,7 @@
30 30
31/* 31/*
32 * In case of a server: if a NAME_DNS extension type is received then it stores 32 * In case of a server: if a NAME_DNS extension type is received then it stores
33 * into the session the value of NAME_DNS. The server may use gnutls_ext_get_server_name(), 33 * into the session the value of NAME_DNS. The server may use MHD_gnutls_ext_get_server_name(),
34 * in order to access it. 34 * in order to access it.
35 * 35 *
36 * In case of a client: If a proper NAME_DNS extension type is found in the session then 36 * In case of a client: If a proper NAME_DNS extension type is found in the session then
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41int 41int
42mhd_gtls_server_name_recv_params (mhd_gtls_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,14 +51,14 @@ mhd_gtls_server_name_recv_params (mhd_gtls_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 = mhd_gtls_read_uint16 (data); 54 len = MHD_gtls_read_uint16 (data);
55 55
56 if (len != data_size) 56 if (len != data_size)
57 { 57 {
58 /* This is unexpected packet length, but 58 /* This is unexpected packet length, but
59 * just ignore it, for now. 59 * just ignore it, for now.
60 */ 60 */
61 gnutls_assert (); 61 MHD_gnutls_assert ();
62 return 0; 62 return 0;
63 } 63 }
64 64
@@ -71,7 +71,7 @@ mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
71 p++; 71 p++;
72 72
73 DECR_LEN (data_size, 2); 73 DECR_LEN (data_size, 2);
74 len = mhd_gtls_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 @@ mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
96 type = *p; 96 type = *p;
97 p++; 97 p++;
98 98
99 len = mhd_gtls_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 @@ mhd_gtls_server_name_recv_params (mhd_gtls_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
127mhd_gtls_server_name_send_params (mhd_gtls_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 int total_size = 0; 130 int total_size = 0;
@@ -163,7 +163,7 @@ mhd_gtls_server_name_send_params (mhd_gtls_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 mhd_gtls_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 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
191 *p = 0; /* NAME_DNS type */ 191 *p = 0; /* NAME_DNS type */
192 p++; 192 p++;
193 193
194 mhd_gtls_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,
@@ -200,7 +200,7 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
200 p += len; 200 p += len;
201 break; 201 break;
202 default: 202 default:
203 gnutls_assert (); 203 MHD_gnutls_assert ();
204 return GNUTLS_E_INTERNAL_ERROR; 204 return GNUTLS_E_INTERNAL_ERROR;
205 } 205 }
206 } 206 }
@@ -210,8 +210,8 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
210} 210}
211 211
212/** 212/**
213 * MHD_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 #mhd_gtls_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
@@ -219,7 +219,7 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
219 * 219 *
220 * This function will allow you to get the name indication (if any), 220 * This function will allow you to get the name indication (if any),
221 * a client has sent. The name indication may be any of the enumeration 221 * a client has sent. The name indication may be any of the enumeration
222 * gnutls_server_name_type_t. 222 * MHD_gnutls_server_name_type_t.
223 * 223 *
224 * If @type is GNUTLS_NAME_DNS, then this function is to be used by servers 224 * If @type is GNUTLS_NAME_DNS, then this function is to be used by servers
225 * that support virtual hosting, and the data will be a null terminated UTF-8 string. 225 * that support virtual hosting, and the data will be a null terminated UTF-8 string.
@@ -233,7 +233,7 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
233 * 233 *
234 **/ 234 **/
235int 235int
236MHD_gnutls_server_name_get (mhd_gtls_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{
@@ -241,7 +241,7 @@ MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
241#if MHD_DEBUG_TLS 241#if MHD_DEBUG_TLS
242 if (session->security_parameters.entity == GNUTLS_CLIENT) 242 if (session->security_parameters.entity == GNUTLS_CLIENT)
243 { 243 {
244 gnutls_assert (); 244 MHD_gnutls_assert ();
245 return GNUTLS_E_INVALID_REQUEST; 245 return GNUTLS_E_INVALID_REQUEST;
246 } 246 }
247#endif 247#endif
@@ -278,8 +278,8 @@ MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
278} 278}
279 279
280/** 280/**
281 * MHD_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 #mhd_gtls_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,15 +295,15 @@ MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
295 * 295 *
296 **/ 296 **/
297int 297int
298MHD_gnutls_server_name_set (mhd_gtls_session_t session, 298MHD__gnutls_server_name_set (MHD_gtls_session_t session,
299 gnutls_server_name_type_t type, 299 MHD_gnutls_server_name_type_t type,
300 const void *name, size_t name_length) 300 const void *name, size_t name_length)
301{ 301{
302 int server_names; 302 int server_names;
303 303
304 if (session->security_parameters.entity == GNUTLS_SERVER) 304 if (session->security_parameters.entity == GNUTLS_SERVER)
305 { 305 {
306 gnutls_assert (); 306 MHD_gnutls_assert ();
307 return GNUTLS_E_INVALID_REQUEST; 307 return GNUTLS_E_INVALID_REQUEST;
308 } 308 }
309 309
diff --git a/src/daemon/https/tls/ext_server_name.h b/src/daemon/https/tls/ext_server_name.h
index 5de9304f..f74ce191 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 mhd_gtls_server_name_recv_params (mhd_gtls_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 mhd_gtls_server_name_send_params (mhd_gtls_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 6a71aee3..b3ad303d 100644
--- a/src/daemon/https/tls/gnutls_alert.c
+++ b/src/daemon/https/tls/gnutls_alert.c
@@ -29,11 +29,11 @@
29 29
30typedef struct 30typedef struct
31{ 31{
32 gnutls_alert_description_t alert; 32 MHD_gnutls_alert_description_t alert;
33 const char *desc; 33 const char *desc;
34} gnutls_alert_entry; 34} MHD_gnutls_alert_entry;
35 35
36static const gnutls_alert_entry mhd_gtls_sup_alerts[] = { 36static const MHD_gnutls_alert_entry MHD_gtls_sup_alerts[] = {
37 {GNUTLS_A_CLOSE_NOTIFY, "Close notify"}, 37 {GNUTLS_A_CLOSE_NOTIFY, "Close notify"},
38 {GNUTLS_A_UNEXPECTED_MESSAGE, "Unexpected message"}, 38 {GNUTLS_A_UNEXPECTED_MESSAGE, "Unexpected message"},
39 {GNUTLS_A_BAD_RECORD_MAC, "Bad record MAC"}, 39 {GNUTLS_A_BAD_RECORD_MAC, "Bad record MAC"},
@@ -67,23 +67,23 @@ static const gnutls_alert_entry mhd_gtls_sup_alerts[] = {
67}; 67};
68 68
69#define GNUTLS_ALERT_LOOP(b) \ 69#define GNUTLS_ALERT_LOOP(b) \
70 const gnutls_alert_entry *p; \ 70 const MHD_gnutls_alert_entry *p; \
71 for(p = mhd_gtls_sup_alerts; p->desc != NULL; p++) { b ; } 71 for(p = MHD_gtls_sup_alerts; p->desc != NULL; p++) { b ; }
72 72
73#define GNUTLS_ALERT_ID_LOOP(a) \ 73#define GNUTLS_ALERT_ID_LOOP(a) \
74 GNUTLS_ALERT_LOOP( if(p->alert == alert) { a; break; }) 74 GNUTLS_ALERT_LOOP( if(p->alert == alert) { a; break; })
75 75
76 76
77/** 77/**
78 * MHD_gnutls_alert_get_name - Returns a string describing the alert number given 78 * MHD__gnutls_alert_get_name - Returns a string describing the alert number given
79 * @alert: is an alert number #mhd_gtls_session_t structure. 79 * @alert: is an alert number #MHD_gtls_session_t structure.
80 * 80 *
81 * This function will return a string that describes the given alert 81 * This function will return a string that describes the given alert
82 * number or NULL. See gnutls_alert_get(). 82 * number or NULL. See MHD_gnutls_alert_get().
83 * 83 *
84 **/ 84 **/
85const char * 85const char *
86MHD_gnutls_alert_get_name (gnutls_alert_description_t alert) 86MHD__gnutls_alert_get_name (MHD_gnutls_alert_description_t alert)
87{ 87{
88 const char *ret = NULL; 88 const char *ret = NULL;
89 89
@@ -93,8 +93,8 @@ MHD_gnutls_alert_get_name (gnutls_alert_description_t alert)
93} 93}
94 94
95/** 95/**
96 * MHD_gnutls_alert_send - This function sends an alert message to the peer 96 * MHD__gnutls_alert_send - This function sends an alert message to the peer
97 * @session: is a #mhd_gtls_session_t structure. 97 * @session: is a #MHD_gtls_session_t structure.
98 * @level: is the level of the alert 98 * @level: is the level of the alert
99 * @desc: is the alert description 99 * @desc: is the alert description
100 * 100 *
@@ -110,8 +110,8 @@ MHD_gnutls_alert_get_name (gnutls_alert_description_t alert)
110 * 110 *
111 **/ 111 **/
112int 112int
113MHD_gnutls_alert_send (mhd_gtls_session_t session, gnutls_alert_level_t level, 113MHD__gnutls_alert_send (MHD_gtls_session_t session, MHD_gnutls_alert_level_t level,
114 gnutls_alert_description_t desc) 114 MHD_gnutls_alert_description_t desc)
115{ 115{
116 uint8_t data[2]; 116 uint8_t data[2];
117 int ret; 117 int ret;
@@ -120,13 +120,13 @@ MHD_gnutls_alert_send (mhd_gtls_session_t session, gnutls_alert_level_t level,
120 data[0] = (uint8_t) level; 120 data[0] = (uint8_t) level;
121 data[1] = (uint8_t) desc; 121 data[1] = (uint8_t) desc;
122 122
123 name = MHD_gnutls_alert_get_name ((int) data[1]); 123 name = MHD__gnutls_alert_get_name ((int) data[1]);
124 if (name == NULL) 124 if (name == NULL)
125 name = "(unknown)"; 125 name = "(unknown)";
126 _gnutls_record_log ("REC: Sending Alert[%d|%d] - %s\n", data[0], 126 MHD__gnutls_record_log ("REC: Sending Alert[%d|%d] - %s\n", data[0],
127 data[1], name); 127 data[1], name);
128 128
129 if ((ret = mhd_gtls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0) 129 if ((ret = MHD_gtls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0)
130 return 0; 130 return 0;
131 else 131 else
132 return ret; 132 return ret;
@@ -245,8 +245,8 @@ MHD_gtls_error_to_alert (int err, int *level)
245 245
246 246
247/** 247/**
248 * MHD_gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code 248 * MHD__gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code
249 * @session: is a #mhd_gtls_session_t structure. 249 * @session: is a #MHD_gtls_session_t structure.
250 * @err: is an integer 250 * @err: is an integer
251 * 251 *
252 * Sends an alert to the peer depending on the error code returned by a gnutls 252 * Sends an alert to the peer depending on the error code returned by a gnutls
@@ -261,7 +261,7 @@ MHD_gtls_error_to_alert (int err, int *level)
261 * Returns zero on success. 261 * Returns zero on success.
262 */ 262 */
263int 263int
264MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err) 264MHD__gnutls_alert_send_appropriate (MHD_gtls_session_t session, int err)
265{ 265{
266 int alert; 266 int alert;
267 int level; 267 int level;
@@ -272,12 +272,12 @@ MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err)
272 return alert; 272 return alert;
273 } 273 }
274 274
275 return MHD_gnutls_alert_send (session, level, alert); 275 return MHD__gnutls_alert_send (session, level, alert);
276} 276}
277 277
278/** 278/**
279 * gnutls_alert_get - Returns the last alert number received. 279 * MHD_gnutls_alert_get - Returns the last alert number received.
280 * @session: is a #mhd_gtls_session_t structure. 280 * @session: is a #MHD_gtls_session_t structure.
281 * 281 *
282 * This function will return the last alert number received. This 282 * This function will return the last alert number received. This
283 * function should be called if GNUTLS_E_WARNING_ALERT_RECEIVED or 283 * function should be called if GNUTLS_E_WARNING_ALERT_RECEIVED or
@@ -288,8 +288,8 @@ MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err)
288 * If no alert has been received the returned value is undefined. 288 * If no alert has been received the returned value is undefined.
289 * 289 *
290 **/ 290 **/
291gnutls_alert_description_t 291MHD_gnutls_alert_description_t
292gnutls_alert_get (mhd_gtls_session_t session) 292MHD_gnutls_alert_get (MHD_gtls_session_t session)
293{ 293{
294 return session->internals.last_alert; 294 return session->internals.last_alert;
295} 295}
diff --git a/src/daemon/https/tls/gnutls_algorithms.c b/src/daemon/https/tls/gnutls_algorithms.c
index c3daa08b..bef51b19 100644
--- a/src/daemon/https/tls/gnutls_algorithms.c
+++ b/src/daemon/https/tls/gnutls_algorithms.c
@@ -39,9 +39,9 @@ typedef struct
39 enum MHD_GNUTLS_CredentialsType client_type; 39 enum MHD_GNUTLS_CredentialsType client_type;
40 enum MHD_GNUTLS_CredentialsType server_type; /* The type of credentials a server 40 enum MHD_GNUTLS_CredentialsType server_type; /* The type of credentials a server
41 * needs to set */ 41 * needs to set */
42} gnutls_cred_map; 42} MHD_gnutls_cred_map;
43 43
44static const gnutls_cred_map mhd_gtls_cred_mappings[] = { 44static const MHD_gnutls_cred_map MHD_gtls_cred_mappings[] = {
45 {MHD_GNUTLS_KX_ANON_DH, 45 {MHD_GNUTLS_KX_ANON_DH,
46 MHD_GNUTLS_CRD_ANON, 46 MHD_GNUTLS_CRD_ANON,
47 MHD_GNUTLS_CRD_ANON}, 47 MHD_GNUTLS_CRD_ANON},
@@ -72,8 +72,8 @@ static const gnutls_cred_map mhd_gtls_cred_mappings[] = {
72}; 72};
73 73
74#define GNUTLS_KX_MAP_LOOP(b) \ 74#define GNUTLS_KX_MAP_LOOP(b) \
75 const gnutls_cred_map *p; \ 75 const MHD_gnutls_cred_map *p; \
76 for(p = mhd_gtls_cred_mappings; p->algorithm != 0; p++) { b ; } 76 for(p = MHD_gtls_cred_mappings; p->algorithm != 0; p++) { b ; }
77 77
78#define GNUTLS_KX_MAP_ALG_LOOP_SERVER(a) \ 78#define GNUTLS_KX_MAP_ALG_LOOP_SERVER(a) \
79 GNUTLS_KX_MAP_LOOP( if(p->server_type == type) { a; break; }) 79 GNUTLS_KX_MAP_LOOP( if(p->server_type == type) { a; break; })
@@ -93,14 +93,14 @@ typedef struct
93 * This is useful to certificate cipher suites, which check 93 * This is useful to certificate cipher suites, which check
94 * against the certificate key usage bits. 94 * against the certificate key usage bits.
95 */ 95 */
96} gnutls_pk_map; 96} MHD_gnutls_pk_map;
97 97
98/* This table maps the Key exchange algorithms to 98/* This table maps the Key exchange algorithms to
99 * the certificate algorithms. Eg. if we have 99 * the certificate algorithms. Eg. if we have
100 * RSA algorithm in the certificate then we can 100 * RSA algorithm in the certificate then we can
101 * use GNUTLS_KX_RSA or GNUTLS_KX_DHE_RSA. 101 * use GNUTLS_KX_RSA or GNUTLS_KX_DHE_RSA.
102 */ 102 */
103static const gnutls_pk_map mhd_gtls_pk_mappings[] = { 103static const MHD_gnutls_pk_map MHD_gtls_pk_mappings[] = {
104 {MHD_GNUTLS_KX_RSA, 104 {MHD_GNUTLS_KX_RSA,
105 MHD_GNUTLS_PK_RSA, 105 MHD_GNUTLS_PK_RSA,
106 CIPHER_ENCRYPT}, 106 CIPHER_ENCRYPT},
@@ -119,8 +119,8 @@ static const gnutls_pk_map mhd_gtls_pk_mappings[] = {
119}; 119};
120 120
121#define GNUTLS_PK_MAP_LOOP(b) \ 121#define GNUTLS_PK_MAP_LOOP(b) \
122 const gnutls_pk_map *p; \ 122 const MHD_gnutls_pk_map *p; \
123 for(p = mhd_gtls_pk_mappings; p->kx_algorithm != 0; p++) { b } 123 for(p = MHD_gtls_pk_mappings; p->kx_algorithm != 0; p++) { b }
124 124
125#define GNUTLS_PK_MAP_ALG_LOOP(a) \ 125#define GNUTLS_PK_MAP_ALG_LOOP(a) \
126 GNUTLS_PK_MAP_LOOP( if(p->kx_algorithm == kx_algorithm) { a; break; }) 126 GNUTLS_PK_MAP_LOOP( if(p->kx_algorithm == kx_algorithm) { a; break; })
@@ -134,9 +134,9 @@ typedef struct
134 int major; /* defined by the protocol */ 134 int major; /* defined by the protocol */
135 int minor; /* defined by the protocol */ 135 int minor; /* defined by the protocol */
136 int supported; /* 0 not supported, > 0 is supported */ 136 int supported; /* 0 not supported, > 0 is supported */
137} gnutls_version_entry; 137} MHD_gnutls_version_entry;
138 138
139static const gnutls_version_entry mhd_gtls_sup_versions[] = { 139static const MHD_gnutls_version_entry MHD_gtls_sup_versions[] = {
140 {"SSL3.0", 140 {"SSL3.0",
141 MHD_GNUTLS_PROTOCOL_SSL3, 141 MHD_GNUTLS_PROTOCOL_SSL3,
142 3, 142 3,
@@ -165,7 +165,7 @@ static const gnutls_version_entry mhd_gtls_sup_versions[] = {
165}; 165};
166 166
167/* Keep the contents of this struct the same as the previous one. */ 167/* Keep the contents of this struct the same as the previous one. */
168static const enum MHD_GNUTLS_Protocol mhd_gtls_supported_protocols[] = 168static const enum MHD_GNUTLS_Protocol MHD_gtls_supported_protocols[] =
169{ MHD_GNUTLS_PROTOCOL_SSL3, 169{ MHD_GNUTLS_PROTOCOL_SSL3,
170 MHD_GNUTLS_PROTOCOL_TLS1_0, 170 MHD_GNUTLS_PROTOCOL_TLS1_0,
171 MHD_GNUTLS_PROTOCOL_TLS1_1, 171 MHD_GNUTLS_PROTOCOL_TLS1_1,
@@ -174,13 +174,13 @@ static const enum MHD_GNUTLS_Protocol mhd_gtls_supported_protocols[] =
174}; 174};
175 175
176#define GNUTLS_VERSION_LOOP(b) \ 176#define GNUTLS_VERSION_LOOP(b) \
177 const gnutls_version_entry *p; \ 177 const MHD_gnutls_version_entry *p; \
178 for(p = mhd_gtls_sup_versions; p->name != NULL; p++) { b ; } 178 for(p = MHD_gtls_sup_versions; p->name != NULL; p++) { b ; }
179 179
180#define GNUTLS_VERSION_ALG_LOOP(a) \ 180#define GNUTLS_VERSION_ALG_LOOP(a) \
181 GNUTLS_VERSION_LOOP( if(p->id == version) { a; break; }) 181 GNUTLS_VERSION_LOOP( if(p->id == version) { a; break; })
182 182
183struct gnutls_cipher_entry 183struct MHD_gnutls_cipher_entry
184{ 184{
185 const char *name; 185 const char *name;
186 enum MHD_GNUTLS_CipherAlgorithm id; 186 enum MHD_GNUTLS_CipherAlgorithm id;
@@ -190,14 +190,14 @@ struct gnutls_cipher_entry
190 uint16_t iv; 190 uint16_t iv;
191 int export_flag; /* 0 non export */ 191 int export_flag; /* 0 non export */
192}; 192};
193typedef struct gnutls_cipher_entry gnutls_cipher_entry; 193typedef struct MHD_gnutls_cipher_entry MHD_gnutls_cipher_entry;
194 194
195/* Note that all algorithms are in CBC or STREAM modes. 195/* Note that all algorithms are in CBC or STREAM modes.
196 * Do not add any algorithms in other modes (avoid modified algorithms). 196 * Do not add any algorithms in other modes (avoid modified algorithms).
197 * View first: "The order of encryption and authentication for 197 * View first: "The order of encryption and authentication for
198 * protecting communications" by Hugo Krawczyk - CRYPTO 2001 198 * protecting communications" by Hugo Krawczyk - CRYPTO 2001
199 */ 199 */
200static const gnutls_cipher_entry mhd_gtls_algorithms[] = { 200static const MHD_gnutls_cipher_entry MHD_gtls_algorithms[] = {
201 {"AES-256-CBC", 201 {"AES-256-CBC",
202 MHD_GNUTLS_CIPHER_AES_256_CBC, 202 MHD_GNUTLS_CIPHER_AES_256_CBC,
203 16, 203 16,
@@ -272,7 +272,7 @@ static const gnutls_cipher_entry mhd_gtls_algorithms[] = {
272}; 272};
273 273
274/* Keep the contents of this struct the same as the previous one. */ 274/* Keep the contents of this struct the same as the previous one. */
275static const enum MHD_GNUTLS_CipherAlgorithm mhd_gtls_supported_ciphers[] = 275static const enum MHD_GNUTLS_CipherAlgorithm MHD_gtls_supported_ciphers[] =
276{ MHD_GNUTLS_CIPHER_AES_256_CBC, 276{ MHD_GNUTLS_CIPHER_AES_256_CBC,
277 MHD_GNUTLS_CIPHER_AES_128_CBC, 277 MHD_GNUTLS_CIPHER_AES_128_CBC,
278 MHD_GNUTLS_CIPHER_3DES_CBC, 278 MHD_GNUTLS_CIPHER_3DES_CBC,
@@ -289,22 +289,22 @@ static const enum MHD_GNUTLS_CipherAlgorithm mhd_gtls_supported_ciphers[] =
289}; 289};
290 290
291#define GNUTLS_LOOP(b) \ 291#define GNUTLS_LOOP(b) \
292 const gnutls_cipher_entry *p; \ 292 const MHD_gnutls_cipher_entry *p; \
293 for(p = mhd_gtls_algorithms; p->name != NULL; p++) { b ; } 293 for(p = MHD_gtls_algorithms; p->name != NULL; p++) { b ; }
294 294
295#define GNUTLS_ALG_LOOP(a) \ 295#define GNUTLS_ALG_LOOP(a) \
296 GNUTLS_LOOP( if(p->id == algorithm) { a; break; } ) 296 GNUTLS_LOOP( if(p->id == algorithm) { a; break; } )
297 297
298struct gnutls_hash_entry 298struct MHD_gnutls_hash_entry
299{ 299{
300 const char *name; 300 const char *name;
301 const char *oid; 301 const char *oid;
302 enum MHD_GNUTLS_HashAlgorithm id; 302 enum MHD_GNUTLS_HashAlgorithm id;
303 size_t key_size; /* in case of mac */ 303 size_t key_size; /* in case of mac */
304}; 304};
305typedef struct gnutls_hash_entry gnutls_hash_entry; 305typedef struct MHD_gnutls_hash_entry MHD_gnutls_hash_entry;
306 306
307static const gnutls_hash_entry mhd_gtls_hash_algorithms[] = { 307static const MHD_gnutls_hash_entry MHD_gtls_hash_algorithms[] = {
308 {"SHA1", 308 {"SHA1",
309 HASH_OID_SHA1, 309 HASH_OID_SHA1,
310 MHD_GNUTLS_MAC_SHA1, 310 MHD_GNUTLS_MAC_SHA1,
@@ -328,7 +328,7 @@ static const gnutls_hash_entry mhd_gtls_hash_algorithms[] = {
328}; 328};
329 329
330/* Keep the contents of this struct the same as the previous one. */ 330/* Keep the contents of this struct the same as the previous one. */
331static const enum MHD_GNUTLS_HashAlgorithm mhd_gtls_supported_macs[] = 331static const enum MHD_GNUTLS_HashAlgorithm MHD_gtls_supported_macs[] =
332{ MHD_GNUTLS_MAC_SHA1, 332{ MHD_GNUTLS_MAC_SHA1,
333 MHD_GNUTLS_MAC_MD5, 333 MHD_GNUTLS_MAC_MD5,
334 MHD_GNUTLS_MAC_SHA256, 334 MHD_GNUTLS_MAC_SHA256,
@@ -337,8 +337,8 @@ static const enum MHD_GNUTLS_HashAlgorithm mhd_gtls_supported_macs[] =
337}; 337};
338 338
339#define GNUTLS_HASH_LOOP(b) \ 339#define GNUTLS_HASH_LOOP(b) \
340 const gnutls_hash_entry *p; \ 340 const MHD_gnutls_hash_entry *p; \
341 for(p = mhd_gtls_hash_algorithms; p->name != NULL; p++) { b ; } 341 for(p = MHD_gtls_hash_algorithms; p->name != NULL; p++) { b ; }
342 342
343#define GNUTLS_HASH_ALG_LOOP(a) \ 343#define GNUTLS_HASH_ALG_LOOP(a) \
344 GNUTLS_HASH_LOOP( if(p->id == algorithm) { a; break; } ) 344 GNUTLS_HASH_LOOP( if(p->id == algorithm) { a; break; } )
@@ -348,11 +348,11 @@ static const enum MHD_GNUTLS_HashAlgorithm mhd_gtls_supported_macs[] =
348 { #name, name, id, wb, ml, cl} 348 { #name, name, id, wb, ml, cl}
349 349
350#define MAX_COMP_METHODS 5 350#define MAX_COMP_METHODS 5
351const int _gnutls_comp_algorithms_size = MAX_COMP_METHODS; 351const int MHD__gnutls_comp_algorithms_size = MAX_COMP_METHODS;
352 352
353/* the compression entry is defined in gnutls_algorithms.h */ 353/* the compression entry is defined in MHD_gnutls_algorithms.h */
354 354
355gnutls_compression_entry _gnutls_compression_algorithms[MAX_COMP_METHODS] = 355MHD_gnutls_compression_entry MHD__gnutls_compression_algorithms[MAX_COMP_METHODS] =
356 { GNUTLS_COMPRESSION_ENTRY (MHD_GNUTLS_COMP_NULL, 0x00, 0, 0, 0), 356 { GNUTLS_COMPRESSION_ENTRY (MHD_GNUTLS_COMP_NULL, 0x00, 0, 0, 0),
357#ifdef HAVE_LIBZ 357#ifdef HAVE_LIBZ
358 /* draft-ietf-tls-compression-02 */ 358 /* draft-ietf-tls-compression-02 */
@@ -367,7 +367,7 @@ gnutls_compression_entry _gnutls_compression_algorithms[MAX_COMP_METHODS] =
367}; 367};
368 368
369static const enum MHD_GNUTLS_CompressionMethod 369static const enum MHD_GNUTLS_CompressionMethod
370 mhd_gtls_supported_compressions[] = 370 MHD_gtls_supported_compressions[] =
371{ 371{
372#ifdef HAVE_LIBZ 372#ifdef HAVE_LIBZ
373 MHD_GNUTLS_COMP_DEFLATE, 373 MHD_GNUTLS_COMP_DEFLATE,
@@ -377,41 +377,41 @@ static const enum MHD_GNUTLS_CompressionMethod
377}; 377};
378 378
379#define GNUTLS_COMPRESSION_LOOP(b) \ 379#define GNUTLS_COMPRESSION_LOOP(b) \
380 const gnutls_compression_entry *p; \ 380 const MHD_gnutls_compression_entry *p; \
381 for(p = _gnutls_compression_algorithms; p->name != NULL; p++) { b ; } 381 for(p = MHD__gnutls_compression_algorithms; p->name != NULL; p++) { b ; }
382#define GNUTLS_COMPRESSION_ALG_LOOP(a) \ 382#define GNUTLS_COMPRESSION_ALG_LOOP(a) \
383 GNUTLS_COMPRESSION_LOOP( if(p->id == algorithm) { a; break; } ) 383 GNUTLS_COMPRESSION_LOOP( if(p->id == algorithm) { a; break; } )
384#define GNUTLS_COMPRESSION_ALG_LOOP_NUM(a) \ 384#define GNUTLS_COMPRESSION_ALG_LOOP_NUM(a) \
385 GNUTLS_COMPRESSION_LOOP( if(p->num == num) { a; break; } ) 385 GNUTLS_COMPRESSION_LOOP( if(p->num == num) { a; break; } )
386 386
387/* Key Exchange Section */ 387/* Key Exchange Section */
388extern mhd_gtls_mod_auth_st mhd_gtls_rsa_auth_struct; 388extern MHD_gtls_mod_auth_st MHD_gtls_rsa_auth_struct;
389extern mhd_gtls_mod_auth_st rsa_export_auth_struct; 389extern MHD_gtls_mod_auth_st rsa_export_auth_struct;
390extern mhd_gtls_mod_auth_st mhd_gtls_dhe_rsa_auth_struct; 390extern MHD_gtls_mod_auth_st MHD_gtls_dhe_rsa_auth_struct;
391extern mhd_gtls_mod_auth_st mhd_gtls_dhe_dss_auth_struct; 391extern MHD_gtls_mod_auth_st MHD_gtls_dhe_dss_auth_struct;
392extern mhd_gtls_mod_auth_st mhd_gtls_anon_auth_struct; 392extern MHD_gtls_mod_auth_st MHD_gtls_anon_auth_struct;
393extern mhd_gtls_mod_auth_st srp_auth_struct; 393extern MHD_gtls_mod_auth_st srp_auth_struct;
394extern mhd_gtls_mod_auth_st psk_auth_struct; 394extern MHD_gtls_mod_auth_st psk_auth_struct;
395extern mhd_gtls_mod_auth_st dhe_psk_auth_struct; 395extern MHD_gtls_mod_auth_st dhe_psk_auth_struct;
396extern mhd_gtls_mod_auth_st srp_rsa_auth_struct; 396extern MHD_gtls_mod_auth_st srp_rsa_auth_struct;
397extern mhd_gtls_mod_auth_st srp_dss_auth_struct; 397extern MHD_gtls_mod_auth_st srp_dss_auth_struct;
398 398
399typedef struct mhd_gtls_kx_algo_entry 399typedef struct MHD_gtls_kx_algo_entry
400{ 400{
401 const char *name; 401 const char *name;
402 enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm; 402 enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm;
403 mhd_gtls_mod_auth_st *auth_struct; 403 MHD_gtls_mod_auth_st *auth_struct;
404 int needs_dh_params; 404 int needs_dh_params;
405 int needs_rsa_params; 405 int needs_rsa_params;
406} mhd_gtls_kx_algo_entry_t; 406} MHD_gtls_kx_algo_entry_t;
407 407
408static const mhd_gtls_kx_algo_entry_t mhd_gtls_kx_algorithms[] = { 408static const MHD_gtls_kx_algo_entry_t MHD_gtls_kx_algorithms[] = {
409#ifdef ENABLE_ANON 409#ifdef ENABLE_ANON
410 {"ANON-DH", MHD_GNUTLS_KX_ANON_DH, &mhd_gtls_anon_auth_struct, 1, 0}, 410 {"ANON-DH", MHD_GNUTLS_KX_ANON_DH, &MHD_gtls_anon_auth_struct, 1, 0},
411#endif 411#endif
412 {"RSA", 412 {"RSA",
413 MHD_GNUTLS_KX_RSA, 413 MHD_GNUTLS_KX_RSA,
414 &mhd_gtls_rsa_auth_struct, 414 &MHD_gtls_rsa_auth_struct,
415 0, 415 0,
416 0}, 416 0},
417 {"RSA-EXPORT", 417 {"RSA-EXPORT",
@@ -421,12 +421,12 @@ static const mhd_gtls_kx_algo_entry_t mhd_gtls_kx_algorithms[] = {
421 1 /* needs RSA params */ }, 421 1 /* needs RSA params */ },
422 {"DHE-RSA", 422 {"DHE-RSA",
423 MHD_GNUTLS_KX_DHE_RSA, 423 MHD_GNUTLS_KX_DHE_RSA,
424 &mhd_gtls_dhe_rsa_auth_struct, 424 &MHD_gtls_dhe_rsa_auth_struct,
425 1, 425 1,
426 0}, 426 0},
427 {"DHE-DSS", 427 {"DHE-DSS",
428 MHD_GNUTLS_KX_DHE_DSS, 428 MHD_GNUTLS_KX_DHE_DSS,
429 &mhd_gtls_dhe_dss_auth_struct, 429 &MHD_gtls_dhe_dss_auth_struct,
430 1, 430 1,
431 0}, 431 0},
432 432
@@ -448,7 +448,7 @@ static const mhd_gtls_kx_algo_entry_t mhd_gtls_kx_algorithms[] = {
448}; 448};
449 449
450/* Keep the contents of this struct the same as the previous one. */ 450/* Keep the contents of this struct the same as the previous one. */
451static const enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_supported_kxs[] = 451static const enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gtls_supported_kxs[] =
452{ 452{
453#ifdef ENABLE_ANON 453#ifdef ENABLE_ANON
454 MHD_GNUTLS_KX_ANON_DH, 454 MHD_GNUTLS_KX_ANON_DH,
@@ -470,8 +470,8 @@ static const enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_supported_kxs[] =
470}; 470};
471 471
472#define GNUTLS_KX_LOOP(b) \ 472#define GNUTLS_KX_LOOP(b) \
473 const mhd_gtls_kx_algo_entry_t *p; \ 473 const MHD_gtls_kx_algo_entry_t *p; \
474 for(p = mhd_gtls_kx_algorithms; p->name != NULL; p++) { b ; } 474 for(p = MHD_gtls_kx_algorithms; p->name != NULL; p++) { b ; }
475 475
476#define GNUTLS_KX_ALG_LOOP(a) \ 476#define GNUTLS_KX_ALG_LOOP(a) \
477 GNUTLS_KX_LOOP( if(p->algorithm == algorithm) { a; break; } ) 477 GNUTLS_KX_LOOP( if(p->algorithm == algorithm) { a; break; } )
@@ -490,7 +490,7 @@ typedef struct
490 enum MHD_GNUTLS_Protocol version; /* this cipher suite is supported 490 enum MHD_GNUTLS_Protocol version; /* this cipher suite is supported
491 * from 'version' and above; 491 * from 'version' and above;
492 */ 492 */
493} mhd_gtls_cipher_suite_entry; 493} MHD_gtls_cipher_suite_entry;
494 494
495/* RSA with NULL cipher and MD5 MAC 495/* RSA with NULL cipher and MD5 MAC
496 * for test purposes. 496 * for test purposes.
@@ -586,9 +586,9 @@ typedef struct
586#define GNUTLS_DHE_RSA_CAMELLIA_128_CBC_SHA1 { 0x00,0x45 } 586#define GNUTLS_DHE_RSA_CAMELLIA_128_CBC_SHA1 { 0x00,0x45 }
587#define GNUTLS_DHE_RSA_CAMELLIA_256_CBC_SHA1 { 0x00,0x88 } 587#define GNUTLS_DHE_RSA_CAMELLIA_256_CBC_SHA1 { 0x00,0x88 }
588 588
589#define CIPHER_SUITES_COUNT sizeof(mhd_gtls_cs_algorithms)/sizeof(mhd_gtls_cipher_suite_entry)-1 589#define CIPHER_SUITES_COUNT sizeof(MHD_gtls_cs_algorithms)/sizeof(MHD_gtls_cipher_suite_entry)-1
590 590
591static const mhd_gtls_cipher_suite_entry mhd_gtls_cs_algorithms[] = { 591static const MHD_gtls_cipher_suite_entry MHD_gtls_cs_algorithms[] = {
592 /* ANON_DH */ 592 /* ANON_DH */
593 GNUTLS_CIPHER_SUITE_ENTRY (GNUTLS_ANON_DH_ARCFOUR_MD5, 593 GNUTLS_CIPHER_SUITE_ENTRY (GNUTLS_ANON_DH_ARCFOUR_MD5,
594 MHD_GNUTLS_CIPHER_ARCFOUR_128, 594 MHD_GNUTLS_CIPHER_ARCFOUR_128,
@@ -758,8 +758,8 @@ static const mhd_gtls_cipher_suite_entry mhd_gtls_cs_algorithms[] = {
758}; 758};
759 759
760#define GNUTLS_CIPHER_SUITE_LOOP(b) \ 760#define GNUTLS_CIPHER_SUITE_LOOP(b) \
761 const mhd_gtls_cipher_suite_entry *p; \ 761 const MHD_gtls_cipher_suite_entry *p; \
762 for(p = mhd_gtls_cs_algorithms; p->name != NULL; p++) { b ; } 762 for(p = MHD_gtls_cs_algorithms; p->name != NULL; p++) { b ; }
763 763
764#define GNUTLS_CIPHER_SUITE_ALG_LOOP(a) \ 764#define GNUTLS_CIPHER_SUITE_ALG_LOOP(a) \
765 GNUTLS_CIPHER_SUITE_LOOP( if( (p->id.suite[0] == suite->suite[0]) && (p->id.suite[1] == suite->suite[1])) { a; break; } ) 765 GNUTLS_CIPHER_SUITE_LOOP( if( (p->id.suite[0] == suite->suite[0]) && (p->id.suite[1] == suite->suite[1])) { a; break; } )
@@ -767,7 +767,7 @@ static const mhd_gtls_cipher_suite_entry mhd_gtls_cs_algorithms[] = {
767/* Generic Functions */ 767/* Generic Functions */
768 768
769int 769int
770mhd_gtls_mac_priority (mhd_gtls_session_t session, 770MHD_gtls_mac_priority (MHD_gtls_session_t session,
771 enum MHD_GNUTLS_HashAlgorithm algorithm) 771 enum MHD_GNUTLS_HashAlgorithm algorithm)
772{ /* actually returns the priority */ 772{ /* actually returns the priority */
773 unsigned int i; 773 unsigned int i;
@@ -780,14 +780,14 @@ mhd_gtls_mac_priority (mhd_gtls_session_t session,
780} 780}
781 781
782/** 782/**
783 * MHD_gnutls_mac_get_name - Returns a string with the name of the specified mac algorithm 783 * MHD__gnutls_mac_get_name - Returns a string with the name of the specified mac algorithm
784 * @algorithm: is a MAC algorithm 784 * @algorithm: is a MAC algorithm
785 * 785 *
786 * Returns: a string that contains the name of the specified MAC 786 * Returns: a string that contains the name of the specified MAC
787 * algorithm, or %NULL. 787 * algorithm, or %NULL.
788 **/ 788 **/
789const char * 789const char *
790MHD_gnutls_mac_get_name (enum MHD_GNUTLS_HashAlgorithm algorithm) 790MHD__gnutls_mac_get_name (enum MHD_GNUTLS_HashAlgorithm algorithm)
791{ 791{
792 const char *ret = NULL; 792 const char *ret = NULL;
793 793
@@ -817,7 +817,7 @@ MHD_gtls_mac_get_id (const char *name)
817} 817}
818 818
819/** 819/**
820 * MHD_gnutls_mac_get_key_size - Returns the length of the MAC's key size 820 * MHD__gnutls_mac_get_key_size - Returns the length of the MAC's key size
821 * @algorithm: is an encryption algorithm 821 * @algorithm: is an encryption algorithm
822 * 822 *
823 * Returns: length (in bytes) of the given MAC key size, or 0 if the 823 * Returns: length (in bytes) of the given MAC key size, or 0 if the
@@ -825,7 +825,7 @@ MHD_gtls_mac_get_id (const char *name)
825 * 825 *
826 **/ 826 **/
827size_t 827size_t
828MHD_gnutls_mac_get_key_size (enum MHD_GNUTLS_HashAlgorithm algorithm) 828MHD__gnutls_mac_get_key_size (enum MHD_GNUTLS_HashAlgorithm algorithm)
829{ 829{
830 size_t ret = 0; 830 size_t ret = 0;
831 831
@@ -849,11 +849,11 @@ MHD_gnutls_mac_get_key_size (enum MHD_GNUTLS_HashAlgorithm algorithm)
849const enum MHD_GNUTLS_HashAlgorithm * 849const enum MHD_GNUTLS_HashAlgorithm *
850MHD_gtls_mac_list (void) 850MHD_gtls_mac_list (void)
851{ 851{
852 return mhd_gtls_supported_macs; 852 return MHD_gtls_supported_macs;
853} 853}
854 854
855const char * 855const char *
856mhd_gtls_x509_mac_to_oid (enum MHD_GNUTLS_HashAlgorithm algorithm) 856MHD_gtls_x509_mac_to_oid (enum MHD_GNUTLS_HashAlgorithm algorithm)
857{ 857{
858 const char *ret = NULL; 858 const char *ret = NULL;
859 859
@@ -864,7 +864,7 @@ mhd_gtls_x509_mac_to_oid (enum MHD_GNUTLS_HashAlgorithm algorithm)
864} 864}
865 865
866enum MHD_GNUTLS_HashAlgorithm 866enum MHD_GNUTLS_HashAlgorithm
867mhd_gtls_x509_oid2mac_algorithm (const char *oid) 867MHD_gtls_x509_oid2mac_algorithm (const char *oid)
868{ 868{
869 enum MHD_GNUTLS_HashAlgorithm ret = 0; 869 enum MHD_GNUTLS_HashAlgorithm ret = 0;
870 870
@@ -880,7 +880,7 @@ mhd_gtls_x509_oid2mac_algorithm (const char *oid)
880} 880}
881 881
882int 882int
883mhd_gnutls_mac_is_ok (enum MHD_GNUTLS_HashAlgorithm algorithm) 883MHD_gnutls_mac_is_ok (enum MHD_GNUTLS_HashAlgorithm algorithm)
884{ 884{
885 ssize_t ret = -1; 885 ssize_t ret = -1;
886 GNUTLS_HASH_ALG_LOOP (ret = p->id); 886 GNUTLS_HASH_ALG_LOOP (ret = p->id);
@@ -893,7 +893,7 @@ mhd_gnutls_mac_is_ok (enum MHD_GNUTLS_HashAlgorithm algorithm)
893 893
894/* Compression Functions */ 894/* Compression Functions */
895int 895int
896mhd_gtls_compression_priority (mhd_gtls_session_t session, 896MHD_gtls_compression_priority (MHD_gtls_session_t session,
897 enum MHD_GNUTLS_CompressionMethod algorithm) 897 enum MHD_GNUTLS_CompressionMethod algorithm)
898{ /* actually returns the priority */ 898{ /* actually returns the priority */
899 unsigned int i; 899 unsigned int i;
@@ -907,7 +907,7 @@ mhd_gtls_compression_priority (mhd_gtls_session_t session,
907} 907}
908 908
909/** 909/**
910 * MHD_gnutls_compression_get_name - Returns a string with the name of the specified compression algorithm 910 * MHD__gnutls_compression_get_name - Returns a string with the name of the specified compression algorithm
911 * @algorithm: is a Compression algorithm 911 * @algorithm: is a Compression algorithm
912 * 912 *
913 * Returns: a pointer to a string that contains the name of the 913 * Returns: a pointer to a string that contains the name of the
@@ -953,7 +953,7 @@ MHD_gtls_compression_get_id (const char *name)
953 * 953 *
954 * Get a list of compression methods. Note that to be able to use LZO 954 * Get a list of compression methods. Note that to be able to use LZO
955 * compression, you must link to libgnutls-extra and call 955 * compression, you must link to libgnutls-extra and call
956 * gnutls_global_init_extra(). 956 * MHD_gnutls_global_init_extra().
957 * 957 *
958 * Returns: a zero-terminated list of %enum MHD_GNUTLS_CompressionMethod 958 * Returns: a zero-terminated list of %enum MHD_GNUTLS_CompressionMethod
959 * integers indicating the available compression methods. 959 * integers indicating the available compression methods.
@@ -961,12 +961,12 @@ MHD_gtls_compression_get_id (const char *name)
961const enum MHD_GNUTLS_CompressionMethod * 961const enum MHD_GNUTLS_CompressionMethod *
962MHD_gtls_compression_list (void) 962MHD_gtls_compression_list (void)
963{ 963{
964 return mhd_gtls_supported_compressions; 964 return MHD_gtls_supported_compressions;
965} 965}
966 966
967/* return the tls number of the specified algorithm */ 967/* return the tls number of the specified algorithm */
968int 968int
969mhd_gtls_compression_get_num (enum MHD_GNUTLS_CompressionMethod algorithm) 969MHD_gtls_compression_get_num (enum MHD_GNUTLS_CompressionMethod algorithm)
970{ 970{
971 int ret = -1; 971 int ret = -1;
972 972
@@ -977,7 +977,7 @@ mhd_gtls_compression_get_num (enum MHD_GNUTLS_CompressionMethod algorithm)
977} 977}
978 978
979int 979int
980mhd_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod algorithm) 980MHD_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod algorithm)
981{ 981{
982 int ret = -1; 982 int ret = -1;
983 /* avoid prefix */ 983 /* avoid prefix */
@@ -986,7 +986,7 @@ mhd_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod algorithm)
986} 986}
987 987
988int 988int
989mhd_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod 989MHD_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod
990 algorithm) 990 algorithm)
991{ 991{
992 int ret = -1; 992 int ret = -1;
@@ -996,7 +996,7 @@ mhd_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod
996} 996}
997 997
998int 998int
999mhd_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod 999MHD_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod
1000 algorithm) 1000 algorithm)
1001{ 1001{
1002 int ret = -1; 1002 int ret = -1;
@@ -1009,7 +1009,7 @@ mhd_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod
1009 * method num 1009 * method num
1010 */ 1010 */
1011enum MHD_GNUTLS_CompressionMethod 1011enum MHD_GNUTLS_CompressionMethod
1012mhd_gtls_compression_get_id (int num) 1012MHD_gtls_compression_get_id_from_int (int num)
1013{ 1013{
1014 enum MHD_GNUTLS_CompressionMethod ret = -1; 1014 enum MHD_GNUTLS_CompressionMethod ret = -1;
1015 1015
@@ -1020,7 +1020,7 @@ mhd_gtls_compression_get_id (int num)
1020} 1020}
1021 1021
1022int 1022int
1023mhd_gtls_compression_is_ok (enum MHD_GNUTLS_CompressionMethod algorithm) 1023MHD_gtls_compression_is_ok (enum MHD_GNUTLS_CompressionMethod algorithm)
1024{ 1024{
1025 ssize_t ret = -1; 1025 ssize_t ret = -1;
1026 GNUTLS_COMPRESSION_ALG_LOOP (ret = p->id); 1026 GNUTLS_COMPRESSION_ALG_LOOP (ret = p->id);
@@ -1033,7 +1033,7 @@ mhd_gtls_compression_is_ok (enum MHD_GNUTLS_CompressionMethod algorithm)
1033 1033
1034/* CIPHER functions */ 1034/* CIPHER functions */
1035int 1035int
1036mhd_gtls_cipher_get_block_size (enum MHD_GNUTLS_CipherAlgorithm algorithm) 1036MHD_gtls_cipher_get_block_size (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1037{ 1037{
1038 size_t ret = 0; 1038 size_t ret = 0;
1039 GNUTLS_ALG_LOOP (ret = p->blocksize); 1039 GNUTLS_ALG_LOOP (ret = p->blocksize);
@@ -1043,7 +1043,7 @@ mhd_gtls_cipher_get_block_size (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1043 1043
1044/* returns the priority */ 1044/* returns the priority */
1045int 1045int
1046mhd_gtls_cipher_priority (mhd_gtls_session_t session, 1046MHD_gtls_cipher_priority (MHD_gtls_session_t session,
1047 enum MHD_GNUTLS_CipherAlgorithm algorithm) 1047 enum MHD_GNUTLS_CipherAlgorithm algorithm)
1048{ 1048{
1049 unsigned int i; 1049 unsigned int i;
@@ -1056,7 +1056,7 @@ mhd_gtls_cipher_priority (mhd_gtls_session_t session,
1056} 1056}
1057 1057
1058int 1058int
1059mhd_gtls_cipher_is_block (enum MHD_GNUTLS_CipherAlgorithm algorithm) 1059MHD_gtls_cipher_is_block (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1060{ 1060{
1061 size_t ret = 0; 1061 size_t ret = 0;
1062 1062
@@ -1066,14 +1066,14 @@ mhd_gtls_cipher_is_block (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1066} 1066}
1067 1067
1068/** 1068/**
1069 * MHD_gnutls_cipher_get_key_size - Returns the length of the cipher's key size 1069 * MHD__gnutls_cipher_get_key_size - Returns the length of the cipher's key size
1070 * @algorithm: is an encryption algorithm 1070 * @algorithm: is an encryption algorithm
1071 * 1071 *
1072 * Returns: length (in bytes) of the given cipher's key size, o 0 if 1072 * Returns: length (in bytes) of the given cipher's key size, o 0 if
1073 * the given cipher is invalid. 1073 * the given cipher is invalid.
1074 **/ 1074 **/
1075size_t 1075size_t
1076MHD_gnutls_cipher_get_key_size (enum MHD_GNUTLS_CipherAlgorithm algorithm) 1076MHD__gnutls_cipher_get_key_size (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1077{ /* In bytes */ 1077{ /* In bytes */
1078 size_t ret = 0; 1078 size_t ret = 0;
1079 GNUTLS_ALG_LOOP (ret = p->keysize); 1079 GNUTLS_ALG_LOOP (ret = p->keysize);
@@ -1082,7 +1082,7 @@ MHD_gnutls_cipher_get_key_size (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1082} 1082}
1083 1083
1084int 1084int
1085mhd_gtls_cipher_get_iv_size (enum MHD_GNUTLS_CipherAlgorithm algorithm) 1085MHD_gtls_cipher_get_iv_size (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1086{ /* In bytes */ 1086{ /* In bytes */
1087 size_t ret = 0; 1087 size_t ret = 0;
1088 GNUTLS_ALG_LOOP (ret = p->iv); 1088 GNUTLS_ALG_LOOP (ret = p->iv);
@@ -1091,7 +1091,7 @@ mhd_gtls_cipher_get_iv_size (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1091} 1091}
1092 1092
1093int 1093int
1094mhd_gtls_cipher_get_export_flag (enum MHD_GNUTLS_CipherAlgorithm algorithm) 1094MHD_gtls_cipher_get_export_flag (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1095{ /* In bytes */ 1095{ /* In bytes */
1096 size_t ret = 0; 1096 size_t ret = 0;
1097 GNUTLS_ALG_LOOP (ret = p->export_flag); 1097 GNUTLS_ALG_LOOP (ret = p->export_flag);
@@ -1100,14 +1100,14 @@ mhd_gtls_cipher_get_export_flag (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1100} 1100}
1101 1101
1102/** 1102/**
1103 * MHD_gnutls_cipher_get_name - Returns a string with the name of the specified cipher algorithm 1103 * MHD__gnutls_cipher_get_name - Returns a string with the name of the specified cipher algorithm
1104 * @algorithm: is an encryption algorithm 1104 * @algorithm: is an encryption algorithm
1105 * 1105 *
1106 * Returns: a pointer to a string that contains the name of the 1106 * Returns: a pointer to a string that contains the name of the
1107 * specified cipher, or %NULL. 1107 * specified cipher, or %NULL.
1108 **/ 1108 **/
1109const char * 1109const char *
1110MHD_gnutls_cipher_get_name (enum MHD_GNUTLS_CipherAlgorithm algorithm) 1110MHD__gnutls_cipher_get_name (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1111{ 1111{
1112 const char *ret = NULL; 1112 const char *ret = NULL;
1113 1113
@@ -1153,11 +1153,11 @@ MHD_gtls_cipher_get_id (const char *name)
1153const enum MHD_GNUTLS_CipherAlgorithm * 1153const enum MHD_GNUTLS_CipherAlgorithm *
1154MHD_gtls_cipher_list (void) 1154MHD_gtls_cipher_list (void)
1155{ 1155{
1156 return mhd_gtls_supported_ciphers; 1156 return MHD_gtls_supported_ciphers;
1157} 1157}
1158 1158
1159int 1159int
1160mhd_gtls_cipher_is_ok (enum MHD_GNUTLS_CipherAlgorithm algorithm) 1160MHD_gtls_cipher_is_ok (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1161{ 1161{
1162 ssize_t ret = -1; 1162 ssize_t ret = -1;
1163 GNUTLS_ALG_LOOP (ret = p->id); 1163 GNUTLS_ALG_LOOP (ret = p->id);
@@ -1169,17 +1169,17 @@ mhd_gtls_cipher_is_ok (enum MHD_GNUTLS_CipherAlgorithm algorithm)
1169} 1169}
1170 1170
1171/* Key EXCHANGE functions */ 1171/* Key EXCHANGE functions */
1172mhd_gtls_mod_auth_st * 1172MHD_gtls_mod_auth_st *
1173mhd_gtls_kx_auth_struct (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) 1173MHD_gtls_kx_auth_struct (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1174{ 1174{
1175 mhd_gtls_mod_auth_st *ret = NULL; 1175 MHD_gtls_mod_auth_st *ret = NULL;
1176 GNUTLS_KX_ALG_LOOP (ret = p->auth_struct); 1176 GNUTLS_KX_ALG_LOOP (ret = p->auth_struct);
1177 return ret; 1177 return ret;
1178 1178
1179} 1179}
1180 1180
1181int 1181int
1182mhd_gtls_kx_priority (mhd_gtls_session_t session, 1182MHD_gtls_kx_priority (MHD_gtls_session_t session,
1183 enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) 1183 enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1184{ 1184{
1185 unsigned int i; 1185 unsigned int i;
@@ -1192,14 +1192,14 @@ mhd_gtls_kx_priority (mhd_gtls_session_t session,
1192} 1192}
1193 1193
1194/** 1194/**
1195 * MHD_gnutls_kx_get_name - Returns a string with the name of the specified key exchange algorithm 1195 * MHD__gnutls_kx_get_name - Returns a string with the name of the specified key exchange algorithm
1196 * @algorithm: is a key exchange algorithm 1196 * @algorithm: is a key exchange algorithm
1197 * 1197 *
1198 * Returns: a pointer to a string that contains the name of the 1198 * Returns: a pointer to a string that contains the name of the
1199 * specified key exchange algorithm, or %NULL. 1199 * specified key exchange algorithm, or %NULL.
1200 **/ 1200 **/
1201const char * 1201const char *
1202MHD_gnutls_kx_get_name (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) 1202MHD__gnutls_kx_get_name (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1203{ 1203{
1204 const char *ret = NULL; 1204 const char *ret = NULL;
1205 1205
@@ -1240,11 +1240,11 @@ MHD_gtls_kx_get_id (const char *name)
1240const enum MHD_GNUTLS_KeyExchangeAlgorithm * 1240const enum MHD_GNUTLS_KeyExchangeAlgorithm *
1241MHD_gtls_kx_list (void) 1241MHD_gtls_kx_list (void)
1242{ 1242{
1243 return mhd_gtls_supported_kxs; 1243 return MHD_gtls_supported_kxs;
1244} 1244}
1245 1245
1246int 1246int
1247mhd_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) 1247MHD_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1248{ 1248{
1249 ssize_t ret = -1; 1249 ssize_t ret = -1;
1250 GNUTLS_KX_ALG_LOOP (ret = p->algorithm); 1250 GNUTLS_KX_ALG_LOOP (ret = p->algorithm);
@@ -1256,7 +1256,7 @@ mhd_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1256} 1256}
1257 1257
1258int 1258int
1259mhd_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) 1259MHD_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1260{ 1260{
1261 ssize_t ret = 0; 1261 ssize_t ret = 0;
1262 GNUTLS_KX_ALG_LOOP (ret = p->needs_rsa_params); 1262 GNUTLS_KX_ALG_LOOP (ret = p->needs_rsa_params);
@@ -1264,7 +1264,7 @@ mhd_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1264} 1264}
1265 1265
1266int 1266int
1267mhd_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) 1267MHD_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1268{ 1268{
1269 ssize_t ret = 0; 1269 ssize_t ret = 0;
1270 GNUTLS_KX_ALG_LOOP (ret = p->needs_dh_params); 1270 GNUTLS_KX_ALG_LOOP (ret = p->needs_dh_params);
@@ -1273,14 +1273,14 @@ mhd_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm)
1273 1273
1274/* Version */ 1274/* Version */
1275int 1275int
1276mhd_gtls_version_priority (mhd_gtls_session_t session, 1276MHD_gtls_version_priority (MHD_gtls_session_t session,
1277 enum MHD_GNUTLS_Protocol version) 1277 enum MHD_GNUTLS_Protocol version)
1278{ /* actually returns the priority */ 1278{ /* actually returns the priority */
1279 unsigned int i; 1279 unsigned int i;
1280 1280
1281 if (session->internals.priorities.protocol.priority == NULL) 1281 if (session->internals.priorities.protocol.priority == NULL)
1282 { 1282 {
1283 gnutls_assert (); 1283 MHD_gnutls_assert ();
1284 return -1; 1284 return -1;
1285 } 1285 }
1286 1286
@@ -1293,7 +1293,7 @@ mhd_gtls_version_priority (mhd_gtls_session_t session,
1293} 1293}
1294 1294
1295enum MHD_GNUTLS_Protocol 1295enum MHD_GNUTLS_Protocol
1296mhd_gtls_version_lowest (mhd_gtls_session_t session) 1296MHD_gtls_version_lowest (MHD_gtls_session_t session)
1297{ /* returns the lowest version supported */ 1297{ /* returns the lowest version supported */
1298 unsigned int i, min = 0xff; 1298 unsigned int i, min = 0xff;
1299 1299
@@ -1316,7 +1316,7 @@ mhd_gtls_version_lowest (mhd_gtls_session_t session)
1316} 1316}
1317 1317
1318enum MHD_GNUTLS_Protocol 1318enum MHD_GNUTLS_Protocol
1319mhd_gtls_version_max (mhd_gtls_session_t session) 1319MHD_gtls_version_max (MHD_gtls_session_t session)
1320{ /* returns the maximum version supported */ 1320{ /* returns the maximum version supported */
1321 unsigned int i, max = 0x00; 1321 unsigned int i, max = 0x00;
1322 1322
@@ -1339,14 +1339,14 @@ mhd_gtls_version_max (mhd_gtls_session_t session)
1339} 1339}
1340 1340
1341/** 1341/**
1342 * MHD_gnutls_protocol_get_name - Returns a string with the name of the specified SSL/TLS version 1342 * MHD__gnutls_protocol_get_name - Returns a string with the name of the specified SSL/TLS version
1343 * @version: is a (gnutls) version number 1343 * @version: is a (gnutls) version number
1344 * 1344 *
1345 * Returns: a string that contains the name of the specified TLS 1345 * Returns: a string that contains the name of the specified TLS
1346 * version (e.g., "TLS 1.0"), or %NULL. 1346 * version (e.g., "TLS 1.0"), or %NULL.
1347 **/ 1347 **/
1348const char * 1348const char *
1349MHD_gnutls_protocol_get_name (enum MHD_GNUTLS_Protocol version) 1349MHD__gnutls_protocol_get_name (enum MHD_GNUTLS_Protocol version)
1350{ 1350{
1351 const char *ret = NULL; 1351 const char *ret = NULL;
1352 1352
@@ -1387,11 +1387,11 @@ MHD_gtls_protocol_get_id (const char *name)
1387const enum MHD_GNUTLS_Protocol * 1387const enum MHD_GNUTLS_Protocol *
1388MHD_gtls_protocol_list (void) 1388MHD_gtls_protocol_list (void)
1389{ 1389{
1390 return mhd_gtls_supported_protocols; 1390 return MHD_gtls_supported_protocols;
1391} 1391}
1392 1392
1393int 1393int
1394mhd_gtls_version_get_minor (enum MHD_GNUTLS_Protocol version) 1394MHD_gtls_version_get_minor (enum MHD_GNUTLS_Protocol version)
1395{ 1395{
1396 int ret = -1; 1396 int ret = -1;
1397 1397
@@ -1400,7 +1400,7 @@ mhd_gtls_version_get_minor (enum MHD_GNUTLS_Protocol version)
1400} 1400}
1401 1401
1402enum MHD_GNUTLS_Protocol 1402enum MHD_GNUTLS_Protocol
1403mhd_gtls_version_get (int major, int minor) 1403MHD_gtls_version_get (int major, int minor)
1404{ 1404{
1405 int ret = -1; 1405 int ret = -1;
1406 1406
@@ -1411,7 +1411,7 @@ mhd_gtls_version_get (int major, int minor)
1411} 1411}
1412 1412
1413int 1413int
1414mhd_gtls_version_get_major (enum MHD_GNUTLS_Protocol version) 1414MHD_gtls_version_get_major (enum MHD_GNUTLS_Protocol version)
1415{ 1415{
1416 int ret = -1; 1416 int ret = -1;
1417 1417
@@ -1422,7 +1422,7 @@ mhd_gtls_version_get_major (enum MHD_GNUTLS_Protocol version)
1422/* Version Functions */ 1422/* Version Functions */
1423 1423
1424int 1424int
1425mhd_gtls_version_is_supported (mhd_gtls_session_t session, 1425MHD_gtls_version_is_supported (MHD_gtls_session_t session,
1426 const enum MHD_GNUTLS_Protocol version) 1426 const enum MHD_GNUTLS_Protocol version)
1427{ 1427{
1428 int ret = 0; 1428 int ret = 0;
@@ -1431,7 +1431,7 @@ mhd_gtls_version_is_supported (mhd_gtls_session_t session,
1431 if (ret == 0) 1431 if (ret == 0)
1432 return 0; 1432 return 0;
1433 1433
1434 if (mhd_gtls_version_priority (session, version) < 0) 1434 if (MHD_gtls_version_priority (session, version) < 0)
1435 return 0; /* disabled by the user */ 1435 return 0; /* disabled by the user */
1436 else 1436 else
1437 return 1; 1437 return 1;
@@ -1439,7 +1439,7 @@ mhd_gtls_version_is_supported (mhd_gtls_session_t session,
1439 1439
1440/* Type to KX mappings */ 1440/* Type to KX mappings */
1441enum MHD_GNUTLS_KeyExchangeAlgorithm 1441enum MHD_GNUTLS_KeyExchangeAlgorithm
1442mhd_gtls_map_kx_get_kx (enum MHD_GNUTLS_CredentialsType type, int server) 1442MHD_gtls_map_kx_get_kx (enum MHD_GNUTLS_CredentialsType type, int server)
1443{ 1443{
1444 enum MHD_GNUTLS_KeyExchangeAlgorithm ret = -1; 1444 enum MHD_GNUTLS_KeyExchangeAlgorithm ret = -1;
1445 1445
@@ -1455,7 +1455,7 @@ mhd_gtls_map_kx_get_kx (enum MHD_GNUTLS_CredentialsType type, int server)
1455} 1455}
1456 1456
1457enum MHD_GNUTLS_CredentialsType 1457enum MHD_GNUTLS_CredentialsType
1458mhd_gtls_map_kx_get_cred (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm, 1458MHD_gtls_map_kx_get_cred (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm,
1459 int server) 1459 int server)
1460{ 1460{
1461 enum MHD_GNUTLS_CredentialsType ret = -1; 1461 enum MHD_GNUTLS_CredentialsType ret = -1;
@@ -1475,7 +1475,7 @@ mhd_gtls_map_kx_get_cred (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm,
1475 1475
1476/* Cipher Suite's functions */ 1476/* Cipher Suite's functions */
1477enum MHD_GNUTLS_CipherAlgorithm 1477enum MHD_GNUTLS_CipherAlgorithm
1478mhd_gtls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite) 1478MHD_gtls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite)
1479{ 1479{
1480 int ret = 0; 1480 int ret = 0;
1481 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->block_algorithm); 1481 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->block_algorithm);
@@ -1483,7 +1483,7 @@ mhd_gtls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite)
1483} 1483}
1484 1484
1485enum MHD_GNUTLS_Protocol 1485enum MHD_GNUTLS_Protocol
1486mhd_gtls_cipher_suite_get_version (const cipher_suite_st * suite) 1486MHD_gtls_cipher_suite_get_version (const cipher_suite_st * suite)
1487{ 1487{
1488 int ret = 0; 1488 int ret = 0;
1489 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->version); 1489 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->version);
@@ -1491,7 +1491,7 @@ mhd_gtls_cipher_suite_get_version (const cipher_suite_st * suite)
1491} 1491}
1492 1492
1493enum MHD_GNUTLS_KeyExchangeAlgorithm 1493enum MHD_GNUTLS_KeyExchangeAlgorithm
1494mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st * suite) 1494MHD_gtls_cipher_suite_get_kx_algo (const cipher_suite_st * suite)
1495{ 1495{
1496 int ret = 0; 1496 int ret = 0;
1497 1497
@@ -1501,7 +1501,7 @@ mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st * suite)
1501} 1501}
1502 1502
1503enum MHD_GNUTLS_HashAlgorithm 1503enum MHD_GNUTLS_HashAlgorithm
1504mhd_gtls_cipher_suite_get_mac_algo (const cipher_suite_st * suite) 1504MHD_gtls_cipher_suite_get_mac_algo (const cipher_suite_st * suite)
1505{ /* In bytes */ 1505{ /* In bytes */
1506 int ret = 0; 1506 int ret = 0;
1507 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->mac_algorithm); 1507 GNUTLS_CIPHER_SUITE_ALG_LOOP (ret = p->mac_algorithm);
@@ -1510,7 +1510,7 @@ mhd_gtls_cipher_suite_get_mac_algo (const cipher_suite_st * suite)
1510} 1510}
1511 1511
1512const char * 1512const char *
1513mhd_gtls_cipher_suite_get_name (cipher_suite_st * suite) 1513MHD_gtls_cipher_suite_get_name (cipher_suite_st * suite)
1514{ 1514{
1515 const char *ret = NULL; 1515 const char *ret = NULL;
1516 1516
@@ -1521,7 +1521,7 @@ mhd_gtls_cipher_suite_get_name (cipher_suite_st * suite)
1521} 1521}
1522 1522
1523static inline int 1523static inline int
1524_gnutls_cipher_suite_is_ok (cipher_suite_st * suite) 1524MHD__gnutls_cipher_suite_is_ok (cipher_suite_st * suite)
1525{ 1525{
1526 size_t ret; 1526 size_t ret;
1527 const char *name = NULL; 1527 const char *name = NULL;
@@ -1541,11 +1541,11 @@ _gnutls_cipher_suite_is_ok (cipher_suite_st * suite)
1541 1541
1542#define MAX_ELEM_SIZE 4 1542#define MAX_ELEM_SIZE 4
1543static inline int 1543static inline int
1544_gnutls_partition (mhd_gtls_session_t session, 1544MHD__gnutls_partition (MHD_gtls_session_t session,
1545 void *_base, 1545 void *_base,
1546 size_t nmemb, 1546 size_t nmemb,
1547 size_t size, 1547 size_t size,
1548 int (*compar) (mhd_gtls_session_t, 1548 int (*compar) (MHD_gtls_session_t,
1549 const void *, const void *)) 1549 const void *, const void *))
1550{ 1550{
1551 uint8_t *base = _base; 1551 uint8_t *base = _base;
@@ -1589,11 +1589,11 @@ _gnutls_partition (mhd_gtls_session_t session,
1589} 1589}
1590 1590
1591static void 1591static void
1592_gnutls_qsort (mhd_gtls_session_t session, 1592MHD__gnutls_qsort (MHD_gtls_session_t session,
1593 void *_base, 1593 void *_base,
1594 size_t nmemb, 1594 size_t nmemb,
1595 size_t size, 1595 size_t size,
1596 int (*compar) (mhd_gtls_session_t, const void *, const void *)) 1596 int (*compar) (MHD_gtls_session_t, const void *, const void *))
1597{ 1597{
1598 unsigned int pivot; 1598 unsigned int pivot;
1599 char *base = _base; 1599 char *base = _base;
@@ -1602,19 +1602,19 @@ _gnutls_qsort (mhd_gtls_session_t session,
1602#ifdef DEBUG 1602#ifdef DEBUG
1603 if (size > MAX_ELEM_SIZE) 1603 if (size > MAX_ELEM_SIZE)
1604 { 1604 {
1605 gnutls_assert (); 1605 MHD_gnutls_assert ();
1606 _gnutls_debug_log ("QSORT BUG\n"); 1606 MHD__gnutls_debug_log ("QSORT BUG\n");
1607 exit (1); 1607 exit (1);
1608 } 1608 }
1609#endif 1609#endif
1610 1610
1611 if (snmemb <= 1) 1611 if (snmemb <= 1)
1612 return; 1612 return;
1613 pivot = _gnutls_partition (session, _base, nmemb, size, compar); 1613 pivot = MHD__gnutls_partition (session, _base, nmemb, size, compar);
1614 1614
1615 _gnutls_qsort (session, base, pivot < nmemb ? pivot + 1 1615 MHD__gnutls_qsort (session, base, pivot < nmemb ? pivot + 1
1616 : pivot, size, compar); 1616 : pivot, size, compar);
1617 _gnutls_qsort (session, &base[(pivot + 1) * size], nmemb - pivot - 1, size, 1617 MHD__gnutls_qsort (session, &base[(pivot + 1) * size], nmemb - pivot - 1, size,
1618 compar); 1618 compar);
1619} 1619}
1620 1620
@@ -1622,28 +1622,28 @@ _gnutls_qsort (mhd_gtls_session_t session,
1622 * For use with qsort 1622 * For use with qsort
1623 */ 1623 */
1624static int 1624static int
1625_gnutls_compare_algo (mhd_gtls_session_t session, 1625MHD__gnutls_compare_algo (MHD_gtls_session_t session,
1626 const void *i_A1, const void *i_A2) 1626 const void *i_A1, const void *i_A2)
1627{ 1627{
1628 enum MHD_GNUTLS_KeyExchangeAlgorithm kA1 = 1628 enum MHD_GNUTLS_KeyExchangeAlgorithm kA1 =
1629 mhd_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A1); 1629 MHD_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A1);
1630 enum MHD_GNUTLS_KeyExchangeAlgorithm kA2 = 1630 enum MHD_GNUTLS_KeyExchangeAlgorithm kA2 =
1631 mhd_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A2); 1631 MHD_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A2);
1632 enum MHD_GNUTLS_CipherAlgorithm cA1 = 1632 enum MHD_GNUTLS_CipherAlgorithm cA1 =
1633 mhd_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A1); 1633 MHD_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A1);
1634 enum MHD_GNUTLS_CipherAlgorithm cA2 = 1634 enum MHD_GNUTLS_CipherAlgorithm cA2 =
1635 mhd_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A2); 1635 MHD_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A2);
1636 enum MHD_GNUTLS_HashAlgorithm mA1 = 1636 enum MHD_GNUTLS_HashAlgorithm mA1 =
1637 mhd_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A1); 1637 MHD_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A1);
1638 enum MHD_GNUTLS_HashAlgorithm mA2 = 1638 enum MHD_GNUTLS_HashAlgorithm mA2 =
1639 mhd_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A2); 1639 MHD_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A2);
1640 1640
1641 int p1 = (mhd_gtls_kx_priority (session, kA1) + 1) * 64; 1641 int p1 = (MHD_gtls_kx_priority (session, kA1) + 1) * 64;
1642 int p2 = (mhd_gtls_kx_priority (session, kA2) + 1) * 64; 1642 int p2 = (MHD_gtls_kx_priority (session, kA2) + 1) * 64;
1643 p1 += (mhd_gtls_cipher_priority (session, cA1) + 1) * 8; 1643 p1 += (MHD_gtls_cipher_priority (session, cA1) + 1) * 8;
1644 p2 += (mhd_gtls_cipher_priority (session, cA2) + 1) * 8; 1644 p2 += (MHD_gtls_cipher_priority (session, cA2) + 1) * 8;
1645 p1 += mhd_gtls_mac_priority (session, mA1); 1645 p1 += MHD_gtls_mac_priority (session, mA1);
1646 p2 += mhd_gtls_mac_priority (session, mA2); 1646 p2 += MHD_gtls_mac_priority (session, mA2);
1647 1647
1648 if (p1 > p2) 1648 if (p1 > p2)
1649 { 1649 {
@@ -1661,8 +1661,8 @@ _gnutls_compare_algo (mhd_gtls_session_t session,
1661 1661
1662#ifdef SORT_DEBUG 1662#ifdef SORT_DEBUG
1663static void 1663static void
1664_gnutls_bsort (mhd_gtls_session_t session, void *_base, size_t nmemb, 1664MHD__gnutls_bsort (MHD_gtls_session_t session, void *_base, size_t nmemb,
1665 size_t size, int (*compar) (mhd_gtls_session_t, const void *, 1665 size_t size, int (*compar) (MHD_gtls_session_t, const void *,
1666 const void *)) 1666 const void *))
1667{ 1667{
1668 unsigned int i, j; 1668 unsigned int i, j;
@@ -1685,7 +1685,7 @@ _gnutls_bsort (mhd_gtls_session_t session, void *_base, size_t nmemb,
1685#endif 1685#endif
1686 1686
1687int 1687int
1688mhd_gtls_supported_ciphersuites_sorted (mhd_gtls_session_t session, 1688MHD_gtls_supported_ciphersuites_sorted (MHD_gtls_session_t session,
1689 cipher_suite_st ** ciphers) 1689 cipher_suite_st ** ciphers)
1690{ 1690{
1691 1691
@@ -1694,34 +1694,34 @@ mhd_gtls_supported_ciphersuites_sorted (mhd_gtls_session_t session,
1694#endif 1694#endif
1695 int count; 1695 int count;
1696 1696
1697 count = mhd_gtls_supported_ciphersuites (session, ciphers); 1697 count = MHD_gtls_supported_ciphersuites (session, ciphers);
1698 if (count <= 0) 1698 if (count <= 0)
1699 { 1699 {
1700 gnutls_assert (); 1700 MHD_gnutls_assert ();
1701 return count; 1701 return count;
1702 } 1702 }
1703#ifdef SORT_DEBUG 1703#ifdef SORT_DEBUG
1704 _gnutls_debug_log ("Unsorted: \n"); 1704 MHD__gnutls_debug_log ("Unsorted: \n");
1705 for (i = 0; i < count; i++) 1705 for (i = 0; i < count; i++)
1706 _gnutls_debug_log ("\t%d: %s\n", i, 1706 MHD__gnutls_debug_log ("\t%d: %s\n", i,
1707 mhd_gtls_cipher_suite_get_name ((*ciphers)[i])); 1707 MHD_gtls_cipher_suite_get_name ((*ciphers)[i]));
1708#endif 1708#endif
1709 1709
1710 _gnutls_qsort (session, *ciphers, count, sizeof (cipher_suite_st), 1710 MHD__gnutls_qsort (session, *ciphers, count, sizeof (cipher_suite_st),
1711 _gnutls_compare_algo); 1711 MHD__gnutls_compare_algo);
1712 1712
1713#ifdef SORT_DEBUG 1713#ifdef SORT_DEBUG
1714 _gnutls_debug_log ("Sorted: \n"); 1714 MHD__gnutls_debug_log ("Sorted: \n");
1715 for (i = 0; i < count; i++) 1715 for (i = 0; i < count; i++)
1716 _gnutls_debug_log ("\t%d: %s\n", i, 1716 MHD__gnutls_debug_log ("\t%d: %s\n", i,
1717 mhd_gtls_cipher_suite_get_name ((*ciphers)[i])); 1717 MHD_gtls_cipher_suite_get_name ((*ciphers)[i]));
1718#endif 1718#endif
1719 1719
1720 return count; 1720 return count;
1721} 1721}
1722 1722
1723int 1723int
1724mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session, 1724MHD_gtls_supported_ciphersuites (MHD_gtls_session_t session,
1725 cipher_suite_st ** _ciphers) 1725 cipher_suite_st ** _ciphers)
1726{ 1726{
1727 1727
@@ -1736,22 +1736,22 @@ mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
1736 return 0; 1736 return 0;
1737 } 1737 }
1738 1738
1739 tmp_ciphers = gnutls_alloca (count * sizeof (cipher_suite_st)); 1739 tmp_ciphers = MHD_gnutls_alloca (count * sizeof (cipher_suite_st));
1740 if (tmp_ciphers == NULL) 1740 if (tmp_ciphers == NULL)
1741 return GNUTLS_E_MEMORY_ERROR; 1741 return GNUTLS_E_MEMORY_ERROR;
1742 1742
1743 ciphers = gnutls_malloc (count * sizeof (cipher_suite_st)); 1743 ciphers = MHD_gnutls_malloc (count * sizeof (cipher_suite_st));
1744 if (ciphers == NULL) 1744 if (ciphers == NULL)
1745 { 1745 {
1746 gnutls_afree (tmp_ciphers); 1746 MHD_gnutls_afree (tmp_ciphers);
1747 return GNUTLS_E_MEMORY_ERROR; 1747 return GNUTLS_E_MEMORY_ERROR;
1748 } 1748 }
1749 1749
1750 version = MHD_gnutls_protocol_get_version (session); 1750 version = MHD__gnutls_protocol_get_version (session);
1751 1751
1752 for (i = 0; i < count; i++) 1752 for (i = 0; i < count; i++)
1753 { 1753 {
1754 memcpy (&tmp_ciphers[i], &mhd_gtls_cs_algorithms[i].id, 1754 memcpy (&tmp_ciphers[i], &MHD_gtls_cs_algorithms[i].id,
1755 sizeof (cipher_suite_st)); 1755 sizeof (cipher_suite_st));
1756 } 1756 }
1757 1757
@@ -1766,19 +1766,19 @@ mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
1766 /* remove cipher suites which do not support the 1766 /* remove cipher suites which do not support the
1767 * protocol version used. 1767 * protocol version used.
1768 */ 1768 */
1769 if (mhd_gtls_cipher_suite_get_version (&tmp_ciphers[i]) > version) 1769 if (MHD_gtls_cipher_suite_get_version (&tmp_ciphers[i]) > version)
1770 continue; 1770 continue;
1771 1771
1772 if (mhd_gtls_kx_priority (session, 1772 if (MHD_gtls_kx_priority (session,
1773 mhd_gtls_cipher_suite_get_kx_algo 1773 MHD_gtls_cipher_suite_get_kx_algo
1774 (&tmp_ciphers[i])) < 0) 1774 (&tmp_ciphers[i])) < 0)
1775 continue; 1775 continue;
1776 if (mhd_gtls_mac_priority (session, 1776 if (MHD_gtls_mac_priority (session,
1777 mhd_gtls_cipher_suite_get_mac_algo 1777 MHD_gtls_cipher_suite_get_mac_algo
1778 (&tmp_ciphers[i])) < 0) 1778 (&tmp_ciphers[i])) < 0)
1779 continue; 1779 continue;
1780 if (mhd_gtls_cipher_priority (session, 1780 if (MHD_gtls_cipher_priority (session,
1781 mhd_gtls_cipher_suite_get_cipher_algo 1781 MHD_gtls_cipher_suite_get_cipher_algo
1782 (&tmp_ciphers[i])) < 0) 1782 (&tmp_ciphers[i])) < 0)
1783 continue; 1783 continue;
1784 1784
@@ -1792,27 +1792,27 @@ mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
1792 if (ret_count > 0 && ret_count != count) 1792 if (ret_count > 0 && ret_count != count)
1793 { 1793 {
1794 ciphers = 1794 ciphers =
1795 mhd_gtls_realloc_fast (ciphers, ret_count * sizeof (cipher_suite_st)); 1795 MHD_gtls_realloc_fast (ciphers, ret_count * sizeof (cipher_suite_st));
1796 } 1796 }
1797 else 1797 else
1798 { 1798 {
1799 if (ret_count != count) 1799 if (ret_count != count)
1800 { 1800 {
1801 gnutls_free (ciphers); 1801 MHD_gnutls_free (ciphers);
1802 ciphers = NULL; 1802 ciphers = NULL;
1803 } 1803 }
1804 } 1804 }
1805#endif 1805#endif
1806 1806
1807 gnutls_afree (tmp_ciphers); 1807 MHD_gnutls_afree (tmp_ciphers);
1808 1808
1809 /* This function can no longer return 0 cipher suites. 1809 /* This function can no longer return 0 cipher suites.
1810 * It returns an error code instead. 1810 * It returns an error code instead.
1811 */ 1811 */
1812 if (ret_count == 0) 1812 if (ret_count == 0)
1813 { 1813 {
1814 gnutls_assert (); 1814 MHD_gnutls_assert ();
1815 gnutls_free (ciphers); 1815 MHD_gnutls_free (ciphers);
1816 return GNUTLS_E_NO_CIPHER_SUITES; 1816 return GNUTLS_E_NO_CIPHER_SUITES;
1817 } 1817 }
1818 *_ciphers = ciphers; 1818 *_ciphers = ciphers;
@@ -1827,19 +1827,19 @@ mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
1827 */ 1827 */
1828#define SUPPORTED_COMPRESSION_METHODS session->internals.priorities.compression.num_algorithms 1828#define SUPPORTED_COMPRESSION_METHODS session->internals.priorities.compression.num_algorithms
1829int 1829int
1830mhd_gtls_supported_compression_methods (mhd_gtls_session_t session, 1830MHD_gtls_supported_compression_methods (MHD_gtls_session_t session,
1831 uint8_t ** comp) 1831 uint8_t ** comp)
1832{ 1832{
1833 unsigned int i, j; 1833 unsigned int i, j;
1834 1834
1835 *comp = gnutls_malloc (sizeof (uint8_t) * SUPPORTED_COMPRESSION_METHODS); 1835 *comp = MHD_gnutls_malloc (sizeof (uint8_t) * SUPPORTED_COMPRESSION_METHODS);
1836 if (*comp == NULL) 1836 if (*comp == NULL)
1837 return GNUTLS_E_MEMORY_ERROR; 1837 return GNUTLS_E_MEMORY_ERROR;
1838 1838
1839 for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++) 1839 for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++)
1840 { 1840 {
1841 int tmp = 1841 int tmp =
1842 mhd_gtls_compression_get_num (session->internals.priorities. 1842 MHD_gtls_compression_get_num (session->internals.priorities.
1843 compression.priority[i]); 1843 compression.priority[i]);
1844 1844
1845 /* remove private compression algorithms, if requested. 1845 /* remove private compression algorithms, if requested.
@@ -1847,7 +1847,7 @@ mhd_gtls_supported_compression_methods (mhd_gtls_session_t session,
1847 if (tmp == -1 || (tmp >= MIN_PRIVATE_COMP_ALGO 1847 if (tmp == -1 || (tmp >= MIN_PRIVATE_COMP_ALGO
1848 && session->internals.enable_private == 0)) 1848 && session->internals.enable_private == 0))
1849 { 1849 {
1850 gnutls_assert (); 1850 MHD_gnutls_assert ();
1851 continue; 1851 continue;
1852 } 1852 }
1853 1853
@@ -1857,8 +1857,8 @@ mhd_gtls_supported_compression_methods (mhd_gtls_session_t session,
1857 1857
1858 if (j == 0) 1858 if (j == 0)
1859 { 1859 {
1860 gnutls_assert (); 1860 MHD_gnutls_assert ();
1861 gnutls_free (*comp); 1861 MHD_gnutls_free (*comp);
1862 *comp = NULL; 1862 *comp = NULL;
1863 return GNUTLS_E_NO_COMPRESSION_ALGORITHMS; 1863 return GNUTLS_E_NO_COMPRESSION_ALGORITHMS;
1864 } 1864 }
@@ -1866,14 +1866,14 @@ mhd_gtls_supported_compression_methods (mhd_gtls_session_t session,
1866} 1866}
1867 1867
1868/** 1868/**
1869 * MHD_gnutls_certificate_type_get_name - Returns a string with the name of the specified certificate type 1869 * MHD__gnutls_certificate_type_get_name - Returns a string with the name of the specified certificate type
1870 * @type: is a certificate type 1870 * @type: is a certificate type
1871 * 1871 *
1872 * Returns: a string (or %NULL) that contains the name of the 1872 * Returns: a string (or %NULL) that contains the name of the
1873 * specified certificate type. 1873 * specified certificate type.
1874 **/ 1874 **/
1875const char * 1875const char *
1876MHD_gnutls_certificate_type_get_name (enum MHD_GNUTLS_CertificateType type) 1876MHD__gnutls_certificate_type_get_name (enum MHD_GNUTLS_CertificateType type)
1877{ 1877{
1878 const char *ret = NULL; 1878 const char *ret = NULL;
1879 1879
@@ -1902,7 +1902,7 @@ MHD_gtls_certificate_type_get_id (const char *name)
1902} 1902}
1903 1903
1904static const enum MHD_GNUTLS_CertificateType 1904static const enum MHD_GNUTLS_CertificateType
1905 mhd_gtls_supported_certificate_types[] = 1905 MHD_gtls_supported_certificate_types[] =
1906{ MHD_GNUTLS_CRT_X509, 1906{ MHD_GNUTLS_CRT_X509,
1907 0 1907 0
1908}; 1908};
@@ -1919,14 +1919,14 @@ static const enum MHD_GNUTLS_CertificateType
1919const enum MHD_GNUTLS_CertificateType * 1919const enum MHD_GNUTLS_CertificateType *
1920MHD_gtls_certificate_type_list (void) 1920MHD_gtls_certificate_type_list (void)
1921{ 1921{
1922 return mhd_gtls_supported_certificate_types; 1922 return MHD_gtls_supported_certificate_types;
1923} 1923}
1924 1924
1925/* returns the enum MHD_GNUTLS_PublicKeyAlgorithm which is compatible with 1925/* returns the enum MHD_GNUTLS_PublicKeyAlgorithm which is compatible with
1926 * the given enum MHD_GNUTLS_KeyExchangeAlgorithm. 1926 * the given enum MHD_GNUTLS_KeyExchangeAlgorithm.
1927 */ 1927 */
1928enum MHD_GNUTLS_PublicKeyAlgorithm 1928enum MHD_GNUTLS_PublicKeyAlgorithm
1929mhd_gtls_map_pk_get_pk (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm) 1929MHD_gtls_map_pk_get_pk (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm)
1930{ 1930{
1931 enum MHD_GNUTLS_PublicKeyAlgorithm ret = -1; 1931 enum MHD_GNUTLS_PublicKeyAlgorithm ret = -1;
1932 1932
@@ -1939,7 +1939,7 @@ mhd_gtls_map_pk_get_pk (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm)
1939 * ex. GNUTLS_KX_RSA requires a certificate able to encrypt... so returns CIPHER_ENCRYPT. 1939 * ex. GNUTLS_KX_RSA requires a certificate able to encrypt... so returns CIPHER_ENCRYPT.
1940 */ 1940 */
1941enum encipher_type 1941enum encipher_type
1942mhd_gtls_kx_encipher_type (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm) 1942MHD_gtls_kx_encipher_type (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm)
1943{ 1943{
1944 int ret = CIPHER_IGN; 1944 int ret = CIPHER_IGN;
1945 GNUTLS_PK_MAP_ALG_LOOP (ret = p->encipher_type) return ret; 1945 GNUTLS_PK_MAP_ALG_LOOP (ret = p->encipher_type) return ret;
@@ -1948,17 +1948,17 @@ mhd_gtls_kx_encipher_type (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm)
1948 1948
1949/* signature algorithms; 1949/* signature algorithms;
1950 */ 1950 */
1951struct gnutls_sign_entry 1951struct MHD_gnutls_sign_entry
1952{ 1952{
1953 const char *name; 1953 const char *name;
1954 const char *oid; 1954 const char *oid;
1955 gnutls_sign_algorithm_t id; 1955 MHD_gnutls_sign_algorithm_t id;
1956 enum MHD_GNUTLS_PublicKeyAlgorithm pk; 1956 enum MHD_GNUTLS_PublicKeyAlgorithm pk;
1957 enum MHD_GNUTLS_HashAlgorithm mac; 1957 enum MHD_GNUTLS_HashAlgorithm mac;
1958}; 1958};
1959typedef struct gnutls_sign_entry gnutls_sign_entry; 1959typedef struct MHD_gnutls_sign_entry MHD_gnutls_sign_entry;
1960 1960
1961static const gnutls_sign_entry mhd_gtls_sign_algorithms[] = { 1961static const MHD_gnutls_sign_entry MHD_gtls_sign_algorithms[] = {
1962 {"RSA-SHA", 1962 {"RSA-SHA",
1963 SIG_RSA_SHA1_OID, 1963 SIG_RSA_SHA1_OID,
1964 GNUTLS_SIGN_RSA_SHA1, 1964 GNUTLS_SIGN_RSA_SHA1,
@@ -1993,17 +1993,17 @@ static const gnutls_sign_entry mhd_gtls_sign_algorithms[] = {
1993 1993
1994#define GNUTLS_SIGN_LOOP(b) \ 1994#define GNUTLS_SIGN_LOOP(b) \
1995 do { \ 1995 do { \
1996 const gnutls_sign_entry *p; \ 1996 const MHD_gnutls_sign_entry *p; \
1997 for(p = mhd_gtls_sign_algorithms; p->name != NULL; p++) { b ; } \ 1997 for(p = MHD_gtls_sign_algorithms; p->name != NULL; p++) { b ; } \
1998 } while (0) 1998 } while (0)
1999 1999
2000#define GNUTLS_SIGN_ALG_LOOP(a) \ 2000#define GNUTLS_SIGN_ALG_LOOP(a) \
2001 GNUTLS_SIGN_LOOP( if(p->id && p->id == sign) { a; break; } ) 2001 GNUTLS_SIGN_LOOP( if(p->id && p->id == sign) { a; break; } )
2002 2002
2003gnutls_sign_algorithm_t 2003MHD_gnutls_sign_algorithm_t
2004mhd_gtls_x509_oid2sign_algorithm (const char *oid) 2004MHD_gtls_x509_oid2sign_algorithm (const char *oid)
2005{ 2005{
2006 gnutls_sign_algorithm_t ret = 0; 2006 MHD_gnutls_sign_algorithm_t ret = 0;
2007 2007
2008 GNUTLS_SIGN_LOOP (if (strcmp (oid, p->oid) == 0) 2008 GNUTLS_SIGN_LOOP (if (strcmp (oid, p->oid) == 0)
2009 { 2009 {
@@ -2012,17 +2012,17 @@ mhd_gtls_x509_oid2sign_algorithm (const char *oid)
2012 2012
2013 if (ret == 0) 2013 if (ret == 0)
2014 { 2014 {
2015 _gnutls_x509_log ("Unknown SIGN OID: '%s'\n", oid); 2015 MHD__gnutls_x509_log ("Unknown SIGN OID: '%s'\n", oid);
2016 return GNUTLS_SIGN_UNKNOWN; 2016 return GNUTLS_SIGN_UNKNOWN;
2017 } 2017 }
2018 return ret; 2018 return ret;
2019} 2019}
2020 2020
2021gnutls_sign_algorithm_t 2021MHD_gnutls_sign_algorithm_t
2022mhd_gtls_x509_pk_to_sign (enum MHD_GNUTLS_PublicKeyAlgorithm pk, 2022MHD_gtls_x509_pk_to_sign (enum MHD_GNUTLS_PublicKeyAlgorithm pk,
2023 enum MHD_GNUTLS_HashAlgorithm mac) 2023 enum MHD_GNUTLS_HashAlgorithm mac)
2024{ 2024{
2025 gnutls_sign_algorithm_t ret = 0; 2025 MHD_gnutls_sign_algorithm_t ret = 0;
2026 2026
2027 GNUTLS_SIGN_LOOP (if (pk == p->pk && mac == p->mac) 2027 GNUTLS_SIGN_LOOP (if (pk == p->pk && mac == p->mac)
2028 { 2028 {
@@ -2035,13 +2035,13 @@ mhd_gtls_x509_pk_to_sign (enum MHD_GNUTLS_PublicKeyAlgorithm pk,
2035} 2035}
2036 2036
2037const char * 2037const char *
2038mhd_gtls_x509_sign_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm pk, 2038MHD_gtls_x509_sign_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm pk,
2039 enum MHD_GNUTLS_HashAlgorithm mac) 2039 enum MHD_GNUTLS_HashAlgorithm mac)
2040{ 2040{
2041 gnutls_sign_algorithm_t sign; 2041 MHD_gnutls_sign_algorithm_t sign;
2042 const char *ret = NULL; 2042 const char *ret = NULL;
2043 2043
2044 sign = mhd_gtls_x509_pk_to_sign (pk, mac); 2044 sign = MHD_gtls_x509_pk_to_sign (pk, mac);
2045 if (sign == GNUTLS_SIGN_UNKNOWN) 2045 if (sign == GNUTLS_SIGN_UNKNOWN)
2046 return NULL; 2046 return NULL;
2047 2047
@@ -2051,15 +2051,15 @@ mhd_gtls_x509_sign_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm pk,
2051 2051
2052/* pk algorithms; 2052/* pk algorithms;
2053 */ 2053 */
2054struct gnutls_pk_entry 2054struct MHD_gnutls_pk_entry
2055{ 2055{
2056 const char *name; 2056 const char *name;
2057 const char *oid; 2057 const char *oid;
2058 enum MHD_GNUTLS_PublicKeyAlgorithm id; 2058 enum MHD_GNUTLS_PublicKeyAlgorithm id;
2059}; 2059};
2060typedef struct gnutls_pk_entry gnutls_pk_entry; 2060typedef struct MHD_gnutls_pk_entry MHD_gnutls_pk_entry;
2061 2061
2062static const gnutls_pk_entry mhd_gtls_pk_algorithms[] = { 2062static const MHD_gnutls_pk_entry MHD_gtls_pk_algorithms[] = {
2063 {"RSA", 2063 {"RSA",
2064 PK_PKIX1_RSA_OID, 2064 PK_PKIX1_RSA_OID,
2065 MHD_GNUTLS_PK_RSA}, 2065 MHD_GNUTLS_PK_RSA},
@@ -2075,12 +2075,12 @@ static const gnutls_pk_entry mhd_gtls_pk_algorithms[] = {
2075}; 2075};
2076 2076
2077enum MHD_GNUTLS_PublicKeyAlgorithm 2077enum MHD_GNUTLS_PublicKeyAlgorithm
2078mhd_gtls_x509_oid2pk_algorithm (const char *oid) 2078MHD_gtls_x509_oid2pk_algorithm (const char *oid)
2079{ 2079{
2080 enum MHD_GNUTLS_PublicKeyAlgorithm ret = MHD_GNUTLS_PK_UNKNOWN; 2080 enum MHD_GNUTLS_PublicKeyAlgorithm ret = MHD_GNUTLS_PK_UNKNOWN;
2081 const gnutls_pk_entry *p; 2081 const MHD_gnutls_pk_entry *p;
2082 2082
2083 for (p = mhd_gtls_pk_algorithms; p->name != NULL; p++) 2083 for (p = MHD_gtls_pk_algorithms; p->name != NULL; p++)
2084 if (strcmp (p->oid, oid) == 0) 2084 if (strcmp (p->oid, oid) == 0)
2085 { 2085 {
2086 ret = p->id; 2086 ret = p->id;
@@ -2091,12 +2091,12 @@ mhd_gtls_x509_oid2pk_algorithm (const char *oid)
2091} 2091}
2092 2092
2093const char * 2093const char *
2094mhd_gtls_x509_pk_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm algorithm) 2094MHD_gtls_x509_pk_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm algorithm)
2095{ 2095{
2096 const char *ret = NULL; 2096 const char *ret = NULL;
2097 const gnutls_pk_entry *p; 2097 const MHD_gnutls_pk_entry *p;
2098 2098
2099 for (p = mhd_gtls_pk_algorithms; p->name != NULL; p++) 2099 for (p = MHD_gtls_pk_algorithms; p->name != NULL; p++)
2100 if (p->id == algorithm) 2100 if (p->id == algorithm)
2101 { 2101 {
2102 ret = p->oid; 2102 ret = p->oid;
diff --git a/src/daemon/https/tls/gnutls_algorithms.h b/src/daemon/https/tls/gnutls_algorithms.h
index c98e3c41..c0cb2332 100644
--- a/src/daemon/https/tls/gnutls_algorithms.h
+++ b/src/daemon/https/tls/gnutls_algorithms.h
@@ -28,105 +28,105 @@
28#include "gnutls_auth.h" 28#include "gnutls_auth.h"
29 29
30/* Functions for version handling. */ 30/* Functions for version handling. */
31enum MHD_GNUTLS_Protocol mhd_gtls_version_lowest (mhd_gtls_session_t session); 31enum MHD_GNUTLS_Protocol MHD_gtls_version_lowest (MHD_gtls_session_t session);
32enum MHD_GNUTLS_Protocol mhd_gtls_version_max (mhd_gtls_session_t session); 32enum MHD_GNUTLS_Protocol MHD_gtls_version_max (MHD_gtls_session_t session);
33int mhd_gtls_version_priority (mhd_gtls_session_t session, 33int MHD_gtls_version_priority (MHD_gtls_session_t session,
34 enum MHD_GNUTLS_Protocol version); 34 enum MHD_GNUTLS_Protocol version);
35int mhd_gtls_version_is_supported (mhd_gtls_session_t session, 35int MHD_gtls_version_is_supported (MHD_gtls_session_t session,
36 const enum MHD_GNUTLS_Protocol version); 36 const enum MHD_GNUTLS_Protocol version);
37int mhd_gtls_version_get_major (enum MHD_GNUTLS_Protocol ver); 37int MHD_gtls_version_get_major (enum MHD_GNUTLS_Protocol ver);
38int mhd_gtls_version_get_minor (enum MHD_GNUTLS_Protocol ver); 38int MHD_gtls_version_get_minor (enum MHD_GNUTLS_Protocol ver);
39enum MHD_GNUTLS_Protocol mhd_gtls_version_get (int major, int minor); 39enum MHD_GNUTLS_Protocol MHD_gtls_version_get (int major, int minor);
40 40
41/* Functions for MACs. */ 41/* Functions for MACs. */
42int mhd_gnutls_mac_is_ok (enum MHD_GNUTLS_HashAlgorithm algorithm); 42int MHD_gnutls_mac_is_ok (enum MHD_GNUTLS_HashAlgorithm algorithm);
43enum MHD_GNUTLS_HashAlgorithm mhd_gtls_x509_oid2mac_algorithm (const char 43enum MHD_GNUTLS_HashAlgorithm MHD_gtls_x509_oid2mac_algorithm (const char
44 *oid); 44 *oid);
45const char *mhd_gtls_x509_mac_to_oid (enum MHD_GNUTLS_HashAlgorithm mac); 45const char *MHD_gtls_x509_mac_to_oid (enum MHD_GNUTLS_HashAlgorithm mac);
46 46
47/* Functions for cipher suites. */ 47/* Functions for cipher suites. */
48int mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session, 48int MHD_gtls_supported_ciphersuites (MHD_gtls_session_t session,
49 cipher_suite_st ** ciphers); 49 cipher_suite_st ** ciphers);
50int mhd_gtls_supported_ciphersuites_sorted (mhd_gtls_session_t session, 50int MHD_gtls_supported_ciphersuites_sorted (MHD_gtls_session_t session,
51 cipher_suite_st ** ciphers); 51 cipher_suite_st ** ciphers);
52int mhd_gtls_supported_compression_methods (mhd_gtls_session_t session, 52int MHD_gtls_supported_compression_methods (MHD_gtls_session_t session,
53 uint8_t ** comp); 53 uint8_t ** comp);
54const char *mhd_gtls_cipher_suite_get_name (cipher_suite_st * algorithm); 54const char *MHD_gtls_cipher_suite_get_name (cipher_suite_st * algorithm);
55enum MHD_GNUTLS_CipherAlgorithm mhd_gtls_cipher_suite_get_cipher_algo (const 55enum MHD_GNUTLS_CipherAlgorithm MHD_gtls_cipher_suite_get_cipher_algo (const
56 cipher_suite_st 56 cipher_suite_st
57 * 57 *
58 algorithm); 58 algorithm);
59enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_cipher_suite_get_kx_algo (const 59enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gtls_cipher_suite_get_kx_algo (const
60 cipher_suite_st 60 cipher_suite_st
61 * 61 *
62 algorithm); 62 algorithm);
63enum MHD_GNUTLS_HashAlgorithm mhd_gtls_cipher_suite_get_mac_algo (const 63enum MHD_GNUTLS_HashAlgorithm MHD_gtls_cipher_suite_get_mac_algo (const
64 cipher_suite_st 64 cipher_suite_st
65 * 65 *
66 algorithm); 66 algorithm);
67enum MHD_GNUTLS_Protocol mhd_gtls_cipher_suite_get_version (const 67enum MHD_GNUTLS_Protocol MHD_gtls_cipher_suite_get_version (const
68 cipher_suite_st * 68 cipher_suite_st *
69 algorithm); 69 algorithm);
70cipher_suite_st mhd_gtls_cipher_suite_get_suite_name (cipher_suite_st * 70cipher_suite_st MHD_gtls_cipher_suite_get_suite_name (cipher_suite_st *
71 algorithm); 71 algorithm);
72 72
73/* Functions for ciphers. */ 73/* Functions for ciphers. */
74int mhd_gtls_cipher_get_block_size (enum MHD_GNUTLS_CipherAlgorithm 74int MHD_gtls_cipher_get_block_size (enum MHD_GNUTLS_CipherAlgorithm
75 algorithm); 75 algorithm);
76int mhd_gtls_cipher_is_block (enum MHD_GNUTLS_CipherAlgorithm algorithm); 76int MHD_gtls_cipher_is_block (enum MHD_GNUTLS_CipherAlgorithm algorithm);
77int mhd_gtls_cipher_is_ok (enum MHD_GNUTLS_CipherAlgorithm algorithm); 77int MHD_gtls_cipher_is_ok (enum MHD_GNUTLS_CipherAlgorithm algorithm);
78int mhd_gtls_cipher_get_iv_size (enum MHD_GNUTLS_CipherAlgorithm algorithm); 78int MHD_gtls_cipher_get_iv_size (enum MHD_GNUTLS_CipherAlgorithm algorithm);
79int mhd_gtls_cipher_get_export_flag (enum MHD_GNUTLS_CipherAlgorithm 79int MHD_gtls_cipher_get_export_flag (enum MHD_GNUTLS_CipherAlgorithm
80 algorithm); 80 algorithm);
81 81
82/* Functions for key exchange. */ 82/* Functions for key exchange. */
83int mhd_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm 83int MHD_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm
84 algorithm); 84 algorithm);
85int mhd_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm 85int MHD_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm
86 algorithm); 86 algorithm);
87mhd_gtls_mod_auth_st *mhd_gtls_kx_auth_struct (enum 87MHD_gtls_mod_auth_st *MHD_gtls_kx_auth_struct (enum
88 MHD_GNUTLS_KeyExchangeAlgorithm 88 MHD_GNUTLS_KeyExchangeAlgorithm
89 algorithm); 89 algorithm);
90int mhd_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm); 90int MHD_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm);
91 91
92/* Functions for compression. */ 92/* Functions for compression. */
93int mhd_gtls_compression_is_ok (enum MHD_GNUTLS_CompressionMethod algorithm); 93int MHD_gtls_compression_is_ok (enum MHD_GNUTLS_CompressionMethod algorithm);
94int mhd_gtls_compression_get_num (enum MHD_GNUTLS_CompressionMethod 94int MHD_gtls_compression_get_num (enum MHD_GNUTLS_CompressionMethod
95 algorithm); 95 algorithm);
96enum MHD_GNUTLS_CompressionMethod mhd_gtls_compression_get_id (int num); 96enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get_id_from_int (int num);
97int mhd_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod 97int MHD_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod
98 algorithm); 98 algorithm);
99int mhd_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod 99int MHD_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod
100 algorithm); 100 algorithm);
101int mhd_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod 101int MHD_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod
102 algorithm); 102 algorithm);
103 103
104/* Type to KX mappings. */ 104/* Type to KX mappings. */
105enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_map_kx_get_kx (enum 105enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gtls_map_kx_get_kx (enum
106 MHD_GNUTLS_CredentialsType 106 MHD_GNUTLS_CredentialsType
107 type, 107 type,
108 int server); 108 int server);
109enum MHD_GNUTLS_CredentialsType mhd_gtls_map_kx_get_cred (enum 109enum MHD_GNUTLS_CredentialsType MHD_gtls_map_kx_get_cred (enum
110 MHD_GNUTLS_KeyExchangeAlgorithm 110 MHD_GNUTLS_KeyExchangeAlgorithm
111 algorithm, 111 algorithm,
112 int server); 112 int server);
113 113
114/* KX to PK mapping. */ 114/* KX to PK mapping. */
115enum MHD_GNUTLS_PublicKeyAlgorithm mhd_gtls_map_pk_get_pk (enum 115enum MHD_GNUTLS_PublicKeyAlgorithm MHD_gtls_map_pk_get_pk (enum
116 MHD_GNUTLS_KeyExchangeAlgorithm 116 MHD_GNUTLS_KeyExchangeAlgorithm
117 kx_algorithm); 117 kx_algorithm);
118enum MHD_GNUTLS_PublicKeyAlgorithm mhd_gtls_x509_oid2pk_algorithm (const char 118enum MHD_GNUTLS_PublicKeyAlgorithm MHD_gtls_x509_oid2pk_algorithm (const char
119 *oid); 119 *oid);
120const char *mhd_gtls_x509_pk_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm pk); 120const char *MHD_gtls_x509_pk_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm pk);
121 121
122enum encipher_type 122enum encipher_type
123{ CIPHER_ENCRYPT = 0, CIPHER_SIGN = 1, CIPHER_IGN }; 123{ CIPHER_ENCRYPT = 0, CIPHER_SIGN = 1, CIPHER_IGN };
124 124
125enum encipher_type mhd_gtls_kx_encipher_type (enum 125enum encipher_type MHD_gtls_kx_encipher_type (enum
126 MHD_GNUTLS_KeyExchangeAlgorithm 126 MHD_GNUTLS_KeyExchangeAlgorithm
127 algorithm); 127 algorithm);
128 128
129struct mhd_gtls_compression_entry 129struct MHD_gtls_compression_entry
130{ 130{
131 const char *name; 131 const char *name;
132 enum MHD_GNUTLS_CompressionMethod id; 132 enum MHD_GNUTLS_CompressionMethod id;
@@ -137,26 +137,26 @@ struct mhd_gtls_compression_entry
137 int mem_level; 137 int mem_level;
138 int comp_level; 138 int comp_level;
139}; 139};
140typedef struct mhd_gtls_compression_entry gnutls_compression_entry; 140typedef struct MHD_gtls_compression_entry MHD_gnutls_compression_entry;
141 141
142/* Functions for sign algorithms. */ 142/* Functions for sign algorithms. */
143gnutls_sign_algorithm_t mhd_gtls_x509_oid2sign_algorithm (const char *oid); 143MHD_gnutls_sign_algorithm_t MHD_gtls_x509_oid2sign_algorithm (const char *oid);
144gnutls_sign_algorithm_t mhd_gtls_x509_pk_to_sign (enum 144MHD_gnutls_sign_algorithm_t MHD_gtls_x509_pk_to_sign (enum
145 MHD_GNUTLS_PublicKeyAlgorithm 145 MHD_GNUTLS_PublicKeyAlgorithm
146 pk, 146 pk,
147 enum 147 enum
148 MHD_GNUTLS_HashAlgorithm 148 MHD_GNUTLS_HashAlgorithm
149 mac); 149 mac);
150const char *mhd_gtls_x509_sign_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm, 150const char *MHD_gtls_x509_sign_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm,
151 enum MHD_GNUTLS_HashAlgorithm mac); 151 enum MHD_GNUTLS_HashAlgorithm mac);
152 152
153int mhd_gtls_mac_priority (mhd_gtls_session_t session, 153int MHD_gtls_mac_priority (MHD_gtls_session_t session,
154 enum MHD_GNUTLS_HashAlgorithm algorithm); 154 enum MHD_GNUTLS_HashAlgorithm algorithm);
155int mhd_gtls_cipher_priority (mhd_gtls_session_t session, 155int MHD_gtls_cipher_priority (MHD_gtls_session_t session,
156 enum MHD_GNUTLS_CipherAlgorithm algorithm); 156 enum MHD_GNUTLS_CipherAlgorithm algorithm);
157int mhd_gtls_kx_priority (mhd_gtls_session_t session, 157int MHD_gtls_kx_priority (MHD_gtls_session_t session,
158 enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm); 158 enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm);
159int mhd_gtls_compression_priority (mhd_gtls_session_t session, 159int MHD_gtls_compression_priority (MHD_gtls_session_t session,
160 enum MHD_GNUTLS_CompressionMethod 160 enum MHD_GNUTLS_CompressionMethod
161 algorithm); 161 algorithm);
162 162
diff --git a/src/daemon/https/tls/gnutls_anon_cred.c b/src/daemon/https/tls/gnutls_anon_cred.c
index 3ea9768d..665a0758 100644
--- a/src/daemon/https/tls/gnutls_anon_cred.c
+++ b/src/daemon/https/tls/gnutls_anon_cred.c
@@ -36,23 +36,23 @@
36static const int anon_dummy; 36static const int anon_dummy;
37 37
38/** 38/**
39 * MHD_gnutls_anon_free_server_credentials - Used to free an allocated mhd_gtls_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 #mhd_gtls_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
46MHD_gnutls_anon_free_server_credentials (mhd_gtls_anon_server_credentials_t 46MHD__gnutls_anon_free_server_credentials (MHD_gtls_anon_server_credentials_t
47 sc) 47 sc)
48{ 48{
49 49
50 gnutls_free (sc); 50 MHD_gnutls_free (sc);
51} 51}
52 52
53/** 53/**
54 * MHD_gnutls_anon_allocate_server_credentials - Used to allocate an mhd_gtls_anon_server_credentials_t structure 54 * MHD__gnutls_anon_allocate_server_credentials - Used to allocate an MHD_gtls_anon_server_credentials_t structure
55 * @sc: is a pointer to an #mhd_gtls_anon_server_credentials_t structure. 55 * @sc: is a pointer to an #MHD_gtls_anon_server_credentials_t structure.
56 * 56 *
57 * This structure is complex enough to manipulate directly thus this 57 * This structure is complex enough to manipulate directly thus this
58 * helper function is provided in order to allocate it. 58 * helper function is provided in order to allocate it.
@@ -60,10 +60,10 @@ MHD_gnutls_anon_free_server_credentials (mhd_gtls_anon_server_credentials_t
60 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 60 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
61 **/ 61 **/
62int 62int
63 MHD_gnutls_anon_allocate_server_credentials 63 MHD__gnutls_anon_allocate_server_credentials
64 (mhd_gtls_anon_server_credentials_t * sc) 64 (MHD_gtls_anon_server_credentials_t * sc)
65{ 65{
66 *sc = gnutls_calloc (1, sizeof (mhd_anon_server_credentials_st)); 66 *sc = MHD_gnutls_calloc (1, sizeof (mhd_anon_server_credentials_st));
67 if (*sc == NULL) 67 if (*sc == NULL)
68 return GNUTLS_E_MEMORY_ERROR; 68 return GNUTLS_E_MEMORY_ERROR;
69 69
@@ -72,21 +72,21 @@ int
72 72
73 73
74/** 74/**
75 * MHD_gnutls_anon_free_client_credentials - Used to free an allocated mhd_gtls_anon_client_credentials_t structure 75 * MHD__gnutls_anon_free_client_credentials - Used to free an allocated MHD_gtls_anon_client_credentials_t structure
76 * @sc: is an #mhd_gtls_anon_client_credentials_t structure. 76 * @sc: is an #MHD_gtls_anon_client_credentials_t structure.
77 * 77 *
78 * This structure is complex enough to manipulate directly thus this 78 * This structure is complex enough to manipulate directly thus this
79 * helper function is provided in order to free (deallocate) it. 79 * helper function is provided in order to free (deallocate) it.
80 **/ 80 **/
81void 81void
82MHD_gnutls_anon_free_client_credentials (mhd_gtls_anon_client_credentials_t 82MHD__gnutls_anon_free_client_credentials (MHD_gtls_anon_client_credentials_t
83 sc) 83 sc)
84{ 84{
85} 85}
86 86
87/** 87/**
88 * MHD_gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure 88 * MHD__gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure
89 * @sc: is a pointer to an #mhd_gtls_anon_client_credentials_t structure. 89 * @sc: is a pointer to an #MHD_gtls_anon_client_credentials_t structure.
90 * 90 *
91 * This structure is complex enough to manipulate directly thus 91 * This structure is complex enough to manipulate directly thus
92 * this helper function is provided in order to allocate it. 92 * this helper function is provided in order to allocate it.
@@ -94,8 +94,8 @@ MHD_gnutls_anon_free_client_credentials (mhd_gtls_anon_client_credentials_t
94 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 94 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
95 **/ 95 **/
96int 96int
97 MHD_gnutls_anon_allocate_client_credentials 97 MHD__gnutls_anon_allocate_client_credentials
98 (mhd_gtls_anon_client_credentials_t * sc) 98 (MHD_gtls_anon_client_credentials_t * sc)
99{ 99{
100 /* anon_dummy is only there for *sc not to be null. 100 /* anon_dummy is only there for *sc not to be null.
101 * it is not used at all; 101 * it is not used at all;
@@ -106,8 +106,8 @@ int
106} 106}
107 107
108/** 108/**
109 * MHD_gnutls_anon_set_server_dh_params - This function will set the DH parameters for a server to use 109 * MHD__gnutls_anon_set_server_dh_params - This function will set the DH parameters for a server to use
110 * @res: is a mhd_gtls_anon_server_credentials_t structure 110 * @res: is a MHD_gtls_anon_server_credentials_t structure
111 * @dh_params: is a structure that holds diffie hellman parameters. 111 * @dh_params: is a structure that holds diffie hellman parameters.
112 * 112 *
113 * This function will set the diffie hellman parameters for an 113 * This function will set the diffie hellman parameters for an
@@ -115,15 +115,15 @@ int
115 * Anonymous Diffie Hellman cipher suites. 115 * Anonymous Diffie Hellman cipher suites.
116 **/ 116 **/
117void 117void
118MHD_gnutls_anon_set_server_dh_params (mhd_gtls_anon_server_credentials_t res, 118MHD__gnutls_anon_set_server_dh_params (MHD_gtls_anon_server_credentials_t res,
119 mhd_gtls_dh_params_t dh_params) 119 MHD_gtls_dh_params_t dh_params)
120{ 120{
121 res->dh_params = dh_params; 121 res->dh_params = dh_params;
122} 122}
123 123
124/** 124/**
125 * MHD_gnutls_anon_set_server_params_function - This function will set the DH parameters callback 125 * MHD__gnutls_anon_set_server_params_function - This function will set the DH parameters callback
126 * @res: is a mhd_gtls_cert_credentials_t structure 126 * @res: is a MHD_gtls_cert_credentials_t structure
127 * @func: is the function to be called 127 * @func: is the function to be called
128 * 128 *
129 * This function will set a callback in order for the server to get 129 * This function will set a callback in order for the server to get
@@ -131,9 +131,9 @@ MHD_gnutls_anon_set_server_dh_params (mhd_gtls_anon_server_credentials_t res,
131 * callback should return zero on success. 131 * callback should return zero on success.
132 **/ 132 **/
133void 133void
134MHD_gnutls_anon_set_server_params_function (mhd_gtls_anon_server_credentials_t 134MHD__gnutls_anon_set_server_params_function (MHD_gtls_anon_server_credentials_t
135 res, 135 res,
136 gnutls_params_function * func) 136 MHD_gnutls_params_function * func)
137{ 137{
138 res->params_func = func; 138 res->params_func = func;
139} 139}
diff --git a/src/daemon/https/tls/gnutls_asn1_tab.c b/src/daemon/https/tls/gnutls_asn1_tab.c
index b2139578..9b511521 100644
--- a/src/daemon/https/tls/gnutls_asn1_tab.c
+++ b/src/daemon/https/tls/gnutls_asn1_tab.c
@@ -4,7 +4,7 @@
4 4
5#include <libtasn1.h> 5#include <libtasn1.h>
6 6
7const ASN1_ARRAY_TYPE gnutls_asn1_tab[] = { 7const ASN1_ARRAY_TYPE MHD_gnutlsMHD__asn1_tab[] = {
8 {"GNUTLS", 536872976, 0}, 8 {"GNUTLS", 536872976, 0},
9 {0, 1073741836, 0}, 9 {0, 1073741836, 0},
10 {"RSAPublicKey", 1610612741, 0}, 10 {"RSAPublicKey", 1610612741, 0},
diff --git a/src/daemon/https/tls/gnutls_auth.c b/src/daemon/https/tls/gnutls_auth.c
index 1b805c10..b1e1abe7 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 * MHD_gnutls_credentials_clear - Clears all the credentials previously set 40 * MHD__gnutls_credentials_clear - Clears all the credentials previously set
41 * @session: is a #mhd_gtls_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
47MHD_gnutls_credentials_clear (mhd_gtls_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 */
@@ -53,7 +53,7 @@ MHD_gnutls_credentials_clear (mhd_gtls_session_t session)
53 while (ccred != NULL) 53 while (ccred != NULL)
54 { 54 {
55 ncred = ccred->next; 55 ncred = ccred->next;
56 gnutls_free (ccred); 56 MHD_gnutls_free (ccred);
57 ccred = ncred; 57 ccred = ncred;
58 } 58 }
59 session->key->cred = NULL; 59 session->key->cred = NULL;
@@ -65,8 +65,8 @@ MHD_gnutls_credentials_clear (mhd_gtls_session_t session)
65 * { algorithm, credentials, pointer to next } 65 * { algorithm, credentials, pointer to next }
66 */ 66 */
67/** 67/**
68 * MHD_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 #mhd_gtls_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 @@ MHD_gnutls_credentials_clear (mhd_gtls_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 MHD_gnutls_deinit(). ] 80 * you call MHD__gnutls_deinit(). ]
81 * 81 *
82 * For GNUTLS_CRD_ANON cred should be mhd_gtls_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 mhd_gtls_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 MHD_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 MHD_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 mhd_gtls_cert_credentials_t. 89 * For GNUTLS_CRD_CERTIFICATE cred should be MHD_gtls_cert_credentials_t.
90 * 90 *
91 **/ 91 **/
92int 92int
93MHD_gnutls_credentials_set (mhd_gtls_session_t session, 93MHD__gnutls_credentials_set (MHD_gtls_session_t session,
94 enum MHD_GNUTLS_CredentialsType type, void *cred) 94 enum MHD_GNUTLS_CredentialsType type, void *cred)
95{ 95{
96 auth_cred_st *ccred = NULL, *pcred = NULL; 96 auth_cred_st *ccred = NULL, *pcred = NULL;
@@ -99,7 +99,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session,
99 if (session->key->cred == NULL) 99 if (session->key->cred == NULL)
100 { /* beginning of the list */ 100 { /* beginning of the list */
101 101
102 session->key->cred = gnutls_malloc (sizeof (auth_cred_st)); 102 session->key->cred = MHD_gnutls_malloc (sizeof (auth_cred_st));
103 if (session->key->cred == NULL) 103 if (session->key->cred == NULL)
104 return GNUTLS_E_MEMORY_ERROR; 104 return GNUTLS_E_MEMORY_ERROR;
105 105
@@ -127,7 +127,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session,
127 127
128 if (exists == 0) 128 if (exists == 0)
129 { /* new entry */ 129 { /* new entry */
130 pcred->next = gnutls_malloc (sizeof (auth_cred_st)); 130 pcred->next = MHD_gnutls_malloc (sizeof (auth_cred_st));
131 if (pcred->next == NULL) 131 if (pcred->next == NULL)
132 return GNUTLS_E_MEMORY_ERROR; 132 return GNUTLS_E_MEMORY_ERROR;
133 133
@@ -141,7 +141,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session,
141 } 141 }
142 else 142 else
143 { /* modify existing entry */ 143 { /* modify existing entry */
144 gnutls_free (ccred->credentials); 144 MHD_gnutls_free (ccred->credentials);
145 ccred->credentials = cred; 145 ccred->credentials = cred;
146 } 146 }
147 } 147 }
@@ -151,7 +151,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session,
151 151
152/** 152/**
153 * MHD_gtls_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 #mhd_gtls_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 @@ MHD_gnutls_credentials_set (mhd_gtls_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 **/
163enum MHD_GNUTLS_CredentialsType 163enum MHD_GNUTLS_CredentialsType
164MHD_gtls_auth_get_type (mhd_gtls_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 @@ MHD_gtls_auth_get_type (mhd_gtls_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 mhd_gtls_map_kx_get_cred (mhd_gtls_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 * MHD_gtls_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 #mhd_gtls_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 @@ MHD_gtls_auth_get_type (mhd_gtls_session_t session)
184 * 184 *
185 **/ 185 **/
186enum MHD_GNUTLS_CredentialsType 186enum MHD_GNUTLS_CredentialsType
187MHD_gtls_auth_server_get_type (mhd_gtls_session_t session) 187MHD_gtls_auth_server_get_type (MHD_gtls_session_t session)
188{ 188{
189 return 189 return
190 mhd_gtls_map_kx_get_cred (mhd_gtls_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 * MHD_gtls_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 #mhd_gtls_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 @@ MHD_gtls_auth_server_get_type (mhd_gtls_session_t session)
202 * 202 *
203 **/ 203 **/
204enum MHD_GNUTLS_CredentialsType 204enum MHD_GNUTLS_CredentialsType
205MHD_gtls_auth_client_get_type (mhd_gtls_session_t session) 205MHD_gtls_auth_client_get_type (MHD_gtls_session_t session)
206{ 206{
207 return 207 return
208 mhd_gtls_map_kx_get_cred (mhd_gtls_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 @@ MHD_gtls_auth_client_get_type (mhd_gtls_session_t session)
216 * free that!!! 216 * free that!!!
217 */ 217 */
218const void * 218const void *
219mhd_gtls_get_kx_cred (mhd_gtls_session_t session, 219MHD_gtls_get_kx_cred (MHD_gtls_session_t session,
220 enum MHD_GNUTLS_KeyExchangeAlgorithm algo, int *err) 220 enum MHD_GNUTLS_KeyExchangeAlgorithm 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 mhd_gtls_get_cred (session->key, 224 return MHD_gtls_get_cred (session->key,
225 mhd_gtls_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 *
229mhd_gtls_get_cred (mhd_gtls_key_st key, enum MHD_GNUTLS_CredentialsType type, 229MHD_gtls_get_cred (MHD_gtls_key_st key, enum MHD_GNUTLS_CredentialsType type,
230 int *err) 230 int *err)
231{ 231{
232 const void *retval = NULL; 232 const void *retval = NULL;
@@ -258,10 +258,10 @@ out:
258} 258}
259 259
260/*- 260/*-
261 * mhd_gtls_get_auth_info - Returns a pointer to authentication information. 261 * MHD_gtls_get_auth_info - Returns a pointer to authentication information.
262 * @session: is a #mhd_gtls_session_t structure. 262 * @session: is a #MHD_gtls_session_t structure.
263 * 263 *
264 * This function must be called after a succesful MHD_gnutls_handshake(). 264 * This function must be called after a succesful MHD__gnutls_handshake().
265 * Returns a pointer to authentication information. That information 265 * Returns a pointer to authentication information. That information
266 * is data obtained by the handshake protocol, the key exchange algorithm, 266 * is data obtained by the handshake protocol, the key exchange algorithm,
267 * and the TLS extensions messages. 267 * and the TLS extensions messages.
@@ -271,28 +271,28 @@ out:
271 * In case of GNUTLS_CRD_SRP returns a type of &srp_(server/client)_auth_info_t; 271 * In case of GNUTLS_CRD_SRP returns a type of &srp_(server/client)_auth_info_t;
272 -*/ 272 -*/
273void * 273void *
274mhd_gtls_get_auth_info (mhd_gtls_session_t session) 274MHD_gtls_get_auth_info (MHD_gtls_session_t session)
275{ 275{
276 return session->key->auth_info; 276 return session->key->auth_info;
277} 277}
278 278
279/*- 279/*-
280 * mhd_gtls_free_auth_info - Frees the auth info structure 280 * MHD_gtls_free_auth_info - Frees the auth info structure
281 * @session: is a #mhd_gtls_session_t structure. 281 * @session: is a #MHD_gtls_session_t structure.
282 * 282 *
283 * This function frees the auth info structure and sets it to 283 * This function frees the auth info structure and sets it to
284 * null. It must be called since some structures contain malloced 284 * null. It must be called since some structures contain malloced
285 * elements. 285 * elements.
286 -*/ 286 -*/
287void 287void
288mhd_gtls_free_auth_info (mhd_gtls_session_t session) 288MHD_gtls_free_auth_info (MHD_gtls_session_t session)
289{ 289{
290 mhd_gtls_dh_info_st *dh_info; 290 MHD_gtls_dh_info_st *dh_info;
291 rsa_info_st *rsa_info; 291 rsa_info_st *rsa_info;
292 292
293 if (session == NULL || session->key == NULL) 293 if (session == NULL || session->key == NULL)
294 { 294 {
295 gnutls_assert (); 295 MHD_gnutls_assert ();
296 return; 296 return;
297 } 297 }
298 298
@@ -302,19 +302,19 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session)
302 break; 302 break;
303 case MHD_GNUTLS_CRD_ANON: 303 case MHD_GNUTLS_CRD_ANON:
304 { 304 {
305 mhd_anon_auth_info_t info = mhd_gtls_get_auth_info (session); 305 mhd_anon_auth_info_t info = MHD_gtls_get_auth_info (session);
306 306
307 if (info == NULL) 307 if (info == NULL)
308 break; 308 break;
309 309
310 dh_info = &info->dh; 310 dh_info = &info->dh;
311 mhd_gtls_free_dh_info (dh_info); 311 MHD_gtls_free_dh_info (dh_info);
312 } 312 }
313 break; 313 break;
314 case MHD_GNUTLS_CRD_CERTIFICATE: 314 case MHD_GNUTLS_CRD_CERTIFICATE:
315 { 315 {
316 unsigned int i; 316 unsigned int i;
317 cert_auth_info_t info = mhd_gtls_get_auth_info (session); 317 cert_auth_info_t info = MHD_gtls_get_auth_info (session);
318 318
319 if (info == NULL) 319 if (info == NULL)
320 break; 320 break;
@@ -323,15 +323,15 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session)
323 rsa_info = &info->rsa_export; 323 rsa_info = &info->rsa_export;
324 for (i = 0; i < info->ncerts; i++) 324 for (i = 0; i < info->ncerts; i++)
325 { 325 {
326 _gnutls_free_datum (&info->raw_certificate_list[i]); 326 MHD__gnutls_free_datum (&info->raw_certificate_list[i]);
327 } 327 }
328 328
329 gnutls_free (info->raw_certificate_list); 329 MHD_gnutls_free (info->raw_certificate_list);
330 info->raw_certificate_list = NULL; 330 info->raw_certificate_list = NULL;
331 info->ncerts = 0; 331 info->ncerts = 0;
332 332
333 mhd_gtls_free_dh_info (dh_info); 333 MHD_gtls_free_dh_info (dh_info);
334 mhd_gtls_free_rsa_info (rsa_info); 334 MHD_gtls_free_rsa_info (rsa_info);
335 } 335 }
336 336
337 337
@@ -341,7 +341,7 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session)
341 341
342 } 342 }
343 343
344 gnutls_free (session->key->auth_info); 344 MHD_gnutls_free (session->key->auth_info);
345 session->key->auth_info = NULL; 345 session->key->auth_info = NULL;
346 session->key->auth_info_size = 0; 346 session->key->auth_info_size = 0;
347 session->key->auth_info_type = 0; 347 session->key->auth_info_type = 0;
@@ -354,16 +354,16 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session)
354 * info structure to a different type. 354 * info structure to a different type.
355 */ 355 */
356int 356int
357mhd_gtls_auth_info_set (mhd_gtls_session_t session, 357MHD_gtls_auth_info_set (MHD_gtls_session_t session,
358 enum MHD_GNUTLS_CredentialsType type, int size, 358 enum MHD_GNUTLS_CredentialsType type, int size,
359 int allow_change) 359 int allow_change)
360{ 360{
361 if (session->key->auth_info == NULL) 361 if (session->key->auth_info == NULL)
362 { 362 {
363 session->key->auth_info = gnutls_calloc (1, size); 363 session->key->auth_info = MHD_gnutls_calloc (1, size);
364 if (session->key->auth_info == NULL) 364 if (session->key->auth_info == NULL)
365 { 365 {
366 gnutls_assert (); 366 MHD_gnutls_assert ();
367 return GNUTLS_E_MEMORY_ERROR; 367 return GNUTLS_E_MEMORY_ERROR;
368 } 368 }
369 session->key->auth_info_type = type; 369 session->key->auth_info_type = type;
@@ -382,7 +382,7 @@ mhd_gtls_auth_info_set (mhd_gtls_session_t session,
382 if (MHD_gtls_auth_get_type (session) != 382 if (MHD_gtls_auth_get_type (session) !=
383 session->key->auth_info_type) 383 session->key->auth_info_type)
384 { 384 {
385 gnutls_assert (); 385 MHD_gnutls_assert ();
386 return GNUTLS_E_INVALID_REQUEST; 386 return GNUTLS_E_INVALID_REQUEST;
387 } 387 }
388 } 388 }
@@ -398,12 +398,12 @@ mhd_gtls_auth_info_set (mhd_gtls_session_t session,
398 session->key->auth_info_type) 398 session->key->auth_info_type)
399 { 399 {
400 400
401 mhd_gtls_free_auth_info (session); 401 MHD_gtls_free_auth_info (session);
402 402
403 session->key->auth_info = calloc (1, size); 403 session->key->auth_info = calloc (1, size);
404 if (session->key->auth_info == NULL) 404 if (session->key->auth_info == NULL)
405 { 405 {
406 gnutls_assert (); 406 MHD_gnutls_assert ();
407 return GNUTLS_E_MEMORY_ERROR; 407 return GNUTLS_E_MEMORY_ERROR;
408 } 408 }
409 409
diff --git a/src/daemon/https/tls/gnutls_auth.h b/src/daemon/https/tls/gnutls_auth.h
index a29a1faa..4956268c 100644
--- a/src/daemon/https/tls/gnutls_auth.h
+++ b/src/daemon/https/tls/gnutls_auth.h
@@ -25,27 +25,27 @@
25#ifndef GNUTLS_AUTH_H 25#ifndef GNUTLS_AUTH_H
26#define GNUTLS_AUTH_H 26#define GNUTLS_AUTH_H
27 27
28typedef struct mhd_gtls_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 (*mhd_gtls_gen_server_certificate) (mhd_gtls_session_t, opaque **); 31 int (*MHD_gtls_gen_server_certificate) (MHD_gtls_session_t, opaque **);
32 int (*mhd_gtls_gen_client_certificate) (mhd_gtls_session_t, opaque **); 32 int (*MHD_gtls_gen_client_certificate) (MHD_gtls_session_t, opaque **);
33 int (*mhd_gtls_gen_server_kx) (mhd_gtls_session_t, opaque **); 33 int (*MHD_gtls_gen_server_kx) (MHD_gtls_session_t, opaque **);
34 int (*mhd_gtls_gen_client_kx) (mhd_gtls_session_t, opaque **); /* used in SRP */ 34 int (*MHD_gtls_gen_client_kx) (MHD_gtls_session_t, opaque **); /* used in SRP */
35 int (*mhd_gtls_gen_client_cert_vrfy) (mhd_gtls_session_t, opaque **); 35 int (*MHD_gtls_gen_client_cert_vrfy) (MHD_gtls_session_t, opaque **);
36 int (*mhd_gtls_gen_server_certificate_request) (mhd_gtls_session_t, 36 int (*MHD_gtls_gen_server_certificate_request) (MHD_gtls_session_t,
37 opaque **); 37 opaque **);
38 38
39 int (*mhd_gtls_process_server_certificate) (mhd_gtls_session_t, opaque *, 39 int (*MHD_gtls_process_server_certificate) (MHD_gtls_session_t, opaque *,
40 size_t); 40 size_t);
41 int (*mhd_gtls_process_client_certificate) (mhd_gtls_session_t, opaque *, 41 int (*MHD_gtls_process_client_certificate) (MHD_gtls_session_t, opaque *,
42 size_t); 42 size_t);
43 int (*mhd_gtls_process_server_kx) (mhd_gtls_session_t, opaque *, size_t); 43 int (*MHD_gtls_process_server_kx) (MHD_gtls_session_t, opaque *, size_t);
44 int (*mhd_gtls_process_client_kx) (mhd_gtls_session_t, opaque *, size_t); 44 int (*MHD_gtls_process_client_kx) (MHD_gtls_session_t, opaque *, size_t);
45 int (*mhd_gtls_process_client_cert_vrfy) (mhd_gtls_session_t, opaque *, 45 int (*MHD_gtls_process_client_cert_vrfy) (MHD_gtls_session_t, opaque *,
46 size_t); 46 size_t);
47 int (*mhd_gtls_process_server_certificate_request) (mhd_gtls_session_t, 47 int (*MHD_gtls_process_server_certificate_request) (MHD_gtls_session_t,
48 opaque *, size_t); 48 opaque *, size_t);
49} mhd_gtls_mod_auth_st; 49} MHD_gtls_mod_auth_st;
50 50
51#endif 51#endif
diff --git a/src/daemon/https/tls/gnutls_auth_int.h b/src/daemon/https/tls/gnutls_auth_int.h
index ac821277..425dc8a3 100644
--- a/src/daemon/https/tls/gnutls_auth_int.h
+++ b/src/daemon/https/tls/gnutls_auth_int.h
@@ -22,12 +22,12 @@
22 * 22 *
23 */ 23 */
24 24
25const void *mhd_gtls_get_cred (mhd_gtls_key_st key, 25const void *MHD_gtls_get_cred (MHD_gtls_key_st key,
26 enum MHD_GNUTLS_CredentialsType kx, int *err); 26 enum MHD_GNUTLS_CredentialsType kx, int *err);
27const void *mhd_gtls_get_kx_cred (mhd_gtls_session_t session, 27const void *MHD_gtls_get_kx_cred (MHD_gtls_session_t session,
28 enum MHD_GNUTLS_KeyExchangeAlgorithm algo, 28 enum MHD_GNUTLS_KeyExchangeAlgorithm algo,
29 int *err); 29 int *err);
30void *mhd_gtls_get_auth_info (mhd_gtls_session_t session); 30void *MHD_gtls_get_auth_info (MHD_gtls_session_t session);
31int mhd_gtls_auth_info_set (mhd_gtls_session_t session, 31int MHD_gtls_auth_info_set (MHD_gtls_session_t session,
32 enum MHD_GNUTLS_CredentialsType type, int size, 32 enum MHD_GNUTLS_CredentialsType type, int size,
33 int allow_change); 33 int allow_change);
diff --git a/src/daemon/https/tls/gnutls_buffers.c b/src/daemon/https/tls/gnutls_buffers.c
index 5ea95e5f..0a0f367b 100644
--- a/src/daemon/https/tls/gnutls_buffers.c
+++ b/src/daemon/https/tls/gnutls_buffers.c
@@ -30,20 +30,20 @@
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 MHD_gnutls_record_buffer_put(), MHD_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 mhd_gtls_io_read_buffered(), mhd_gtls_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
42 * long). 42 * long).
43 * (see _gnutls_handshake_send_int(), _gnutls_handshake_recv_int()) 43 * (see MHD__gnutls_handshake_send_int(), MHD__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 mhd_gtls_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 * MHD_gnutls_transport_set_errno: 71 * MHD__gnutls_transport_set_errno:
72 * @session: is a #mhd_gtls_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,24 +77,24 @@
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 * MHD_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 * MHD_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
84 * msvcr71.dll and gnutls is linked to msvcrt.dll). 84 * msvcr71.dll and gnutls is linked to msvcrt.dll).
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 MHD_gnutls_transport_set_global_errno(). 88 * also use MHD__gnutls_transport_set_global_errno().
89 **/ 89 **/
90void 90void
91MHD_gnutls_transport_set_errno (mhd_gtls_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 * MHD_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,8 +102,8 @@ MHD_gnutls_transport_set_errno (mhd_gtls_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 * MHD_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 * MHD_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
109 * msvcr71.dll and gnutls is linked to msvcrt.dll). 109 * msvcr71.dll and gnutls is linked to msvcrt.dll).
@@ -111,10 +111,10 @@ MHD_gnutls_transport_set_errno (mhd_gtls_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 MHD_gnutls_transport_set_errno() may be better. 114 * thread-safe MHD__gnutls_transport_set_errno() may be better.
115 **/ 115 **/
116void 116void
117MHD_gnutls_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 @@ MHD_gnutls_transport_set_global_errno (int err)
123 * HANDSHAKE DATA. 123 * HANDSHAKE DATA.
124 */ 124 */
125int 125int
126mhd_gnutls_record_buffer_put (content_type_t type, 126MHD_gnutls_record_buffer_put (content_type_t type,
127 mhd_gtls_session_t session, opaque * data, 127 MHD_gtls_session_t session, opaque * data,
128 size_t length) 128 size_t length)
129{ 129{
130 mhd_gtls_buffer *buf; 130 MHD_gtls_buffer *buf;
131 131
132 if (length == 0) 132 if (length == 0)
133 return 0; 133 return 0;
@@ -136,30 +136,30 @@ mhd_gnutls_record_buffer_put (content_type_t type,
136 { 136 {
137 case GNUTLS_APPLICATION_DATA: 137 case GNUTLS_APPLICATION_DATA:
138 buf = &session->internals.application_data_buffer; 138 buf = &session->internals.application_data_buffer;
139 _gnutls_buffers_log ("BUF[REC]: Inserted %d bytes of Data(%d)\n", 139 MHD__gnutls_buffers_log ("BUF[REC]: Inserted %d bytes of Data(%d)\n",
140 length, type); 140 length, type);
141 break; 141 break;
142 142
143 case GNUTLS_HANDSHAKE: 143 case GNUTLS_HANDSHAKE:
144 buf = &session->internals.handshake_data_buffer; 144 buf = &session->internals.handshake_data_buffer;
145 _gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data(%d)\n", 145 MHD__gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data(%d)\n",
146 length, type); 146 length, type);
147 break; 147 break;
148 148
149 case GNUTLS_INNER_APPLICATION: 149 case GNUTLS_INNER_APPLICATION:
150 buf = &session->internals.ia_data_buffer; 150 buf = &session->internals.ia_data_buffer;
151 _gnutls_buffers_log ("BUF[IA]: Inserted %d bytes of Data(%d)\n", length, 151 MHD__gnutls_buffers_log ("BUF[IA]: Inserted %d bytes of Data(%d)\n", length,
152 type); 152 type);
153 break; 153 break;
154 154
155 default: 155 default:
156 gnutls_assert (); 156 MHD_gnutls_assert ();
157 return GNUTLS_E_INVALID_REQUEST; 157 return GNUTLS_E_INVALID_REQUEST;
158 } 158 }
159 159
160 if (mhd_gtls_buffer_append (buf, data, length) < 0) 160 if (MHD_gtls_buffer_append (buf, data, length) < 0)
161 { 161 {
162 gnutls_assert (); 162 MHD_gnutls_assert ();
163 return GNUTLS_E_MEMORY_ERROR; 163 return GNUTLS_E_MEMORY_ERROR;
164 } 164 }
165 165
@@ -167,8 +167,8 @@ mhd_gnutls_record_buffer_put (content_type_t type,
167} 167}
168 168
169int 169int
170mhd_gnutls_record_buffer_get_size (content_type_t type, 170MHD_gnutls_record_buffer_get_size (content_type_t type,
171 mhd_gtls_session_t session) 171 MHD_gtls_session_t session)
172{ 172{
173 switch (type) 173 switch (type)
174 { 174 {
@@ -188,7 +188,7 @@ mhd_gnutls_record_buffer_get_size (content_type_t type,
188 188
189/** 189/**
190 * MHD_gtls_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.
191 * @session: is a #mhd_gtls_session_t structure. 191 * @session: is a #MHD_gtls_session_t structure.
192 * 192 *
193 * This function checks if there are any data to receive 193 * This function checks if there are any data to receive
194 * 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.
@@ -198,18 +198,18 @@ mhd_gnutls_record_buffer_get_size (content_type_t type,
198 * to work). 198 * to work).
199 **/ 199 **/
200size_t 200size_t
201MHD_gtls_record_check_pending (mhd_gtls_session_t session) 201MHD_gtls_record_check_pending (MHD_gtls_session_t session)
202{ 202{
203 return mhd_gnutls_record_buffer_get_size (GNUTLS_APPLICATION_DATA, session); 203 return MHD_gnutls_record_buffer_get_size (GNUTLS_APPLICATION_DATA, session);
204} 204}
205 205
206int 206int
207mhd_gtls_record_buffer_get (content_type_t type, mhd_gtls_session_t session, 207MHD_gtls_record_buffer_get (content_type_t type, MHD_gtls_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 {
212 gnutls_assert (); 212 MHD_gnutls_assert ();
213 return GNUTLS_E_INVALID_REQUEST; 213 return GNUTLS_E_INVALID_REQUEST;
214 } 214 }
215 215
@@ -222,7 +222,7 @@ mhd_gtls_record_buffer_get (content_type_t type, mhd_gtls_session_t session,
222 length = session->internals.application_data_buffer.length; 222 length = session->internals.application_data_buffer.length;
223 } 223 }
224 224
225 _gnutls_buffers_log ("BUFFER[REC][AD]: Read %d bytes of Data(%d)\n", 225 MHD__gnutls_buffers_log ("BUFFER[REC][AD]: Read %d bytes of Data(%d)\n",
226 length, type); 226 length, type);
227 227
228 session->internals.application_data_buffer.length -= length; 228 session->internals.application_data_buffer.length -= length;
@@ -245,7 +245,7 @@ mhd_gtls_record_buffer_get (content_type_t type, mhd_gtls_session_t session,
245 length = session->internals.handshake_data_buffer.length; 245 length = session->internals.handshake_data_buffer.length;
246 } 246 }
247 247
248 _gnutls_buffers_log ("BUF[REC][HD]: Read %d bytes of Data(%d)\n", 248 MHD__gnutls_buffers_log ("BUF[REC][HD]: Read %d bytes of Data(%d)\n",
249 length, type); 249 length, type);
250 250
251 session->internals.handshake_data_buffer.length -= length; 251 session->internals.handshake_data_buffer.length -= length;
@@ -262,7 +262,7 @@ mhd_gtls_record_buffer_get (content_type_t type, mhd_gtls_session_t session,
262 if (length > session->internals.ia_data_buffer.length) 262 if (length > session->internals.ia_data_buffer.length)
263 length = session->internals.ia_data_buffer.length; 263 length = session->internals.ia_data_buffer.length;
264 264
265 _gnutls_buffers_log ("BUF[REC][IA]: Read %d bytes of Data(%d)\n", 265 MHD__gnutls_buffers_log ("BUF[REC][IA]: Read %d bytes of Data(%d)\n",
266 length, type); 266 length, type);
267 267
268 session->internals.ia_data_buffer.length -= length; 268 session->internals.ia_data_buffer.length -= length;
@@ -276,7 +276,7 @@ mhd_gtls_record_buffer_get (content_type_t type, mhd_gtls_session_t session,
276 break; 276 break;
277 277
278 default: 278 default:
279 gnutls_assert (); 279 MHD_gnutls_assert ();
280 return GNUTLS_E_INVALID_REQUEST; 280 return GNUTLS_E_INVALID_REQUEST;
281 } 281 }
282 282
@@ -284,19 +284,19 @@ mhd_gtls_record_buffer_get (content_type_t type, mhd_gtls_session_t session,
284} 284}
285 285
286/* This function is like read. But it does not return -1 on error. 286/* This function is like read. But it does not return -1 on error.
287 * It does return gnutls_errno instead. 287 * It does return MHD_gnutls_errno instead.
288 * 288 *
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 (mhd_gtls_session_t session, void *iptr, 292MHD__gnutls_read (MHD_gtls_session_t session, void *iptr,
293 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;
297 char *ptr = iptr; 297 char *ptr = iptr;
298 unsigned j, x, sum = 0; 298 unsigned j, x, sum = 0;
299 gnutls_transport_ptr_t fd = session->internals.transport_recv_ptr; 299 MHD_gnutls_transport_ptr_t fd = session->internals.transport_recv_ptr;
300 300
301 session->internals.direction = 0; 301 session->internals.direction = 0;
302 302
@@ -304,7 +304,7 @@ _gnutls_read (mhd_gtls_session_t session, void *iptr,
304 while (left > 0) 304 while (left > 0)
305 { 305 {
306 session->internals.errnum = 0; 306 session->internals.errnum = 0;
307 if (session->internals._gnutls_pull_func == NULL) 307 if (session->internals.MHD__gnutls_pull_func == NULL)
308 { 308 {
309 i = 309 i =
310 recv (GNUTLS_POINTER_TO_INT (fd), &ptr[sizeOfPtr - left], left, 310 recv (GNUTLS_POINTER_TO_INT (fd), &ptr[sizeOfPtr - left], left,
@@ -332,7 +332,7 @@ _gnutls_read (mhd_gtls_session_t session, void *iptr,
332#endif 332#endif
333 } 333 }
334 else 334 else
335 i = session->internals._gnutls_pull_func (fd, 335 i = session->internals.MHD__gnutls_pull_func (fd,
336 &ptr[sizeOfPtr - left], 336 &ptr[sizeOfPtr - left],
337 left); 337 left);
338 338
@@ -341,7 +341,7 @@ _gnutls_read (mhd_gtls_session_t session, void *iptr,
341 int err = session->internals.errnum ? session->internals.errnum 341 int err = session->internals.errnum ? session->internals.errnum
342 : errno; 342 : errno;
343 343
344 _gnutls_read_log ("READ: %d returned from %d, errno=%d gerrno=%d\n", 344 MHD__gnutls_read_log ("READ: %d returned from %d, errno=%d gerrno=%d\n",
345 i, fd, errno, session->internals.errnum); 345 i, fd, errno, session->internals.errnum);
346 346
347 if (err == EAGAIN || err == EINTR) 347 if (err == EAGAIN || err == EINTR)
@@ -349,12 +349,12 @@ _gnutls_read (mhd_gtls_session_t session, void *iptr,
349 if (sizeOfPtr - left > 0) 349 if (sizeOfPtr - left > 0)
350 { 350 {
351 351
352 _gnutls_read_log ("READ: returning %d bytes from %d\n", 352 MHD__gnutls_read_log ("READ: returning %d bytes from %d\n",
353 sizeOfPtr - left, fd); 353 sizeOfPtr - left, fd);
354 354
355 goto finish; 355 goto finish;
356 } 356 }
357 gnutls_assert (); 357 MHD_gnutls_assert ();
358 358
359 if (err == EAGAIN) 359 if (err == EAGAIN)
360 return GNUTLS_E_AGAIN; 360 return GNUTLS_E_AGAIN;
@@ -362,14 +362,14 @@ _gnutls_read (mhd_gtls_session_t session, void *iptr,
362 } 362 }
363 else 363 else
364 { 364 {
365 gnutls_assert (); 365 MHD_gnutls_assert ();
366 return GNUTLS_E_PULL_ERROR; 366 return GNUTLS_E_PULL_ERROR;
367 } 367 }
368 } 368 }
369 else 369 else
370 { 370 {
371 371
372 _gnutls_read_log ("READ: Got %d bytes from %d\n", i, fd); 372 MHD__gnutls_read_log ("READ: Got %d bytes from %d\n", i, fd);
373 373
374 if (i == 0) 374 if (i == 0)
375 break; /* EOF */ 375 break; /* EOF */
@@ -381,12 +381,12 @@ _gnutls_read (mhd_gtls_session_t session, void *iptr,
381 381
382finish: 382finish:
383 383
384 if (_gnutls_log_level >= 7) 384 if (MHD__gnutls_log_level >= 7)
385 { 385 {
386 char line[128]; 386 char line[128];
387 char tmp[16]; 387 char tmp[16];
388 388
389 _gnutls_read_log ("READ: read %d bytes from %d\n", (sizeOfPtr - left), 389 MHD__gnutls_read_log ("READ: read %d bytes from %d\n", (sizeOfPtr - left),
390 fd); 390 fd);
391 391
392 for (x = 0; x < ((sizeOfPtr - left) / 16) + 1; x++) 392 for (x = 0; x < ((sizeOfPtr - left) / 16) + 1; x++)
@@ -394,17 +394,17 @@ finish:
394 line[0] = 0; 394 line[0] = 0;
395 395
396 sprintf (tmp, "%.4x - ", x); 396 sprintf (tmp, "%.4x - ", x);
397 mhd_gtls_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 mhd_gtls_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 MHD__gnutls_read_log ("%s\n", line);
408 } 408 }
409 } 409 }
410 410
@@ -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
420mhd_gtls_io_clear_peeked_data (mhd_gtls_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;
@@ -425,10 +425,10 @@ mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session)
425 if (session->internals.have_peeked_data == 0 || RCVLOWAT == 0) 425 if (session->internals.have_peeked_data == 0 || RCVLOWAT == 0)
426 return 0; 426 return 0;
427 427
428 peekdata = gnutls_alloca (RCVLOWAT); 428 peekdata = MHD_gnutls_alloca (RCVLOWAT);
429 if (peekdata == NULL) 429 if (peekdata == NULL)
430 { 430 {
431 gnutls_assert (); 431 MHD_gnutls_assert ();
432 return GNUTLS_E_MEMORY_ERROR; 432 return GNUTLS_E_MEMORY_ERROR;
433 } 433 }
434 434
@@ -436,18 +436,18 @@ mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session)
436 sum = 0; 436 sum = 0;
437 do 437 do
438 { /* we need this to finish now */ 438 { /* we need this to finish now */
439 ret = _gnutls_read (session, peekdata, RCVLOWAT - sum, 0); 439 ret = MHD__gnutls_read (session, peekdata, RCVLOWAT - sum, 0);
440 if (ret > 0) 440 if (ret > 0)
441 sum += ret; 441 sum += ret;
442 } 442 }
443 while (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN || sum 443 while (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN || sum
444 < RCVLOWAT); 444 < RCVLOWAT);
445 445
446 gnutls_afree (peekdata); 446 MHD_gnutls_afree (peekdata);
447 447
448 if (ret < 0) 448 if (ret < 0)
449 { 449 {
450 gnutls_assert (); 450 MHD_gnutls_assert ();
451 return ret; 451 return ret;
452 } 452 }
453 453
@@ -457,13 +457,13 @@ mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session)
457} 457}
458 458
459void 459void
460mhd_gtls_io_clear_read_buffer (mhd_gtls_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}
464 464
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 MHD_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 *
@@ -472,7 +472,7 @@ mhd_gtls_io_clear_read_buffer (mhd_gtls_session_t session)
472 * 472 *
473 */ 473 */
474ssize_t 474ssize_t
475mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr, 475MHD_gtls_io_read_buffered (MHD_gtls_session_t session, opaque ** iptr,
476 size_t sizeOfPtr, content_type_t recv_type) 476 size_t sizeOfPtr, content_type_t recv_type)
477{ 477{
478 ssize_t ret = 0, ret2 = 0; 478 ssize_t ret = 0, ret2 = 0;
@@ -486,14 +486,14 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
486 486
487 if (sizeOfPtr > MAX_RECV_SIZE || sizeOfPtr == 0) 487 if (sizeOfPtr > MAX_RECV_SIZE || sizeOfPtr == 0)
488 { 488 {
489 gnutls_assert (); /* internal error */ 489 MHD_gnutls_assert (); /* internal error */
490 return GNUTLS_E_INVALID_REQUEST; 490 return GNUTLS_E_INVALID_REQUEST;
491 } 491 }
492 492
493 /* If an external pull function is used, then do not leave 493 /* If an external pull function is used, then do not leave
494 * any data into the kernel buffer. 494 * any data into the kernel buffer.
495 */ 495 */
496 if (session->internals._gnutls_pull_func != NULL) 496 if (session->internals.MHD__gnutls_pull_func != NULL)
497 { 497 {
498 recvlowat = 0; 498 recvlowat = 0;
499 } 499 }
@@ -536,7 +536,7 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
536 if ((session->internals.record_recv_buffer.length + recvdata) 536 if ((session->internals.record_recv_buffer.length + recvdata)
537 > MAX_RECV_SIZE) 537 > MAX_RECV_SIZE)
538 { 538 {
539 gnutls_assert (); /* internal error */ 539 MHD_gnutls_assert (); /* internal error */
540 return GNUTLS_E_INVALID_REQUEST; 540 return GNUTLS_E_INVALID_REQUEST;
541 } 541 }
542 542
@@ -544,11 +544,11 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
544 */ 544 */
545 alloc_size = recvdata + session->internals.record_recv_buffer.length; 545 alloc_size = recvdata + session->internals.record_recv_buffer.length;
546 session->internals.record_recv_buffer.data = 546 session->internals.record_recv_buffer.data =
547 mhd_gtls_realloc_fast (session->internals.record_recv_buffer.data, 547 MHD_gtls_realloc_fast (session->internals.record_recv_buffer.data,
548 alloc_size); 548 alloc_size);
549 if (session->internals.record_recv_buffer.data == NULL) 549 if (session->internals.record_recv_buffer.data == NULL)
550 { 550 {
551 gnutls_assert (); 551 MHD_gnutls_assert ();
552 return GNUTLS_E_MEMORY_ERROR; 552 return GNUTLS_E_MEMORY_ERROR;
553 } 553 }
554 554
@@ -559,7 +559,7 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
559 /* READ DATA - but leave RCVLOWAT bytes in the kernel buffer. */ 559 /* READ DATA - but leave RCVLOWAT bytes in the kernel buffer. */
560 if (recvdata - recvlowat > 0) 560 if (recvdata - recvlowat > 0)
561 { 561 {
562 ret = _gnutls_read (session, &buf[buf_pos], recvdata - recvlowat, 0); 562 ret = MHD__gnutls_read (session, &buf[buf_pos], recvdata - recvlowat, 0);
563 563
564 /* return immediately if we got an interrupt or eagain 564 /* return immediately if we got an interrupt or eagain
565 * error. 565 * error.
@@ -574,9 +574,9 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
574 */ 574 */
575 if (ret > 0) 575 if (ret > 0)
576 { 576 {
577 _gnutls_read_log ("RB: Have %d bytes into buffer. Adding %d bytes.\n", 577 MHD__gnutls_read_log ("RB: Have %d bytes into buffer. Adding %d bytes.\n",
578 session->internals.record_recv_buffer.length, ret); 578 session->internals.record_recv_buffer.length, ret);
579 _gnutls_read_log ("RB: Requested %d bytes\n", sizeOfPtr); 579 MHD__gnutls_read_log ("RB: Requested %d bytes\n", sizeOfPtr);
580 session->internals.record_recv_buffer.length += ret; 580 session->internals.record_recv_buffer.length += ret;
581 } 581 }
582 582
@@ -589,7 +589,7 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
589 */ 589 */
590 if (ret == (recvdata - recvlowat) && recvlowat > 0) 590 if (ret == (recvdata - recvlowat) && recvlowat > 0)
591 { 591 {
592 ret2 = _gnutls_read (session, &buf[buf_pos], recvlowat, MSG_PEEK); 592 ret2 = MHD__gnutls_read (session, &buf[buf_pos], recvlowat, MSG_PEEK);
593 593
594 if (ret2 < 0 && MHD_gtls_error_is_fatal (ret2) == 0) 594 if (ret2 < 0 && MHD_gtls_error_is_fatal (ret2) == 0)
595 { 595 {
@@ -598,8 +598,8 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
598 598
599 if (ret2 > 0) 599 if (ret2 > 0)
600 { 600 {
601 _gnutls_read_log ("RB-PEEK: Read %d bytes in PEEK MODE.\n", ret2); 601 MHD__gnutls_read_log ("RB-PEEK: Read %d bytes in PEEK MODE.\n", ret2);
602 _gnutls_read_log 602 MHD__gnutls_read_log
603 ("RB-PEEK: Have %d bytes into buffer. Adding %d bytes.\nRB: Requested %d bytes\n", 603 ("RB-PEEK: Have %d bytes into buffer. Adding %d bytes.\nRB: Requested %d bytes\n",
604 session->internals.record_recv_buffer.length, ret2, sizeOfPtr); 604 session->internals.record_recv_buffer.length, ret2, sizeOfPtr);
605 session->internals.have_peeked_data = 1; 605 session->internals.have_peeked_data = 1;
@@ -610,7 +610,7 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
610 610
611 if (ret < 0 || ret2 < 0) 611 if (ret < 0 || ret2 < 0)
612 { 612 {
613 gnutls_assert (); 613 MHD_gnutls_assert ();
614 /* that's because they are initialized to 0 */ 614 /* that's because they are initialized to 0 */
615 return MIN (ret, ret2); 615 return MIN (ret, ret2);
616 } 616 }
@@ -619,13 +619,13 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
619 619
620 if (ret > 0 && ret < recvlowat) 620 if (ret > 0 && ret < recvlowat)
621 { 621 {
622 gnutls_assert (); 622 MHD_gnutls_assert ();
623 return GNUTLS_E_AGAIN; 623 return GNUTLS_E_AGAIN;
624 } 624 }
625 625
626 if (ret == 0) 626 if (ret == 0)
627 { /* EOF */ 627 { /* EOF */
628 gnutls_assert (); 628 MHD_gnutls_assert ();
629 return 0; 629 return 0;
630 } 630 }
631 631
@@ -634,7 +634,7 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
634 if ((ret > 0) && ((size_t) ret < sizeOfPtr)) 634 if ((ret > 0) && ((size_t) ret < sizeOfPtr))
635 { 635 {
636 /* Short Read */ 636 /* Short Read */
637 gnutls_assert (); 637 MHD_gnutls_assert ();
638 return GNUTLS_E_AGAIN; 638 return GNUTLS_E_AGAIN;
639 } 639 }
640 else 640 else
@@ -651,7 +651,7 @@ mhd_gtls_io_read_buffered (mhd_gtls_session_t session, opaque ** iptr,
651#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))
652 652
653inline static int 653inline static int
654_gnutls_buffer_insert (mhd_gtls_buffer * buffer, 654MHD__gnutls_buffer_insert (MHD_gtls_buffer * buffer,
655 const opaque * _data, size_t data_size) 655 const opaque * _data, size_t data_size)
656{ 656{
657 657
@@ -662,7 +662,7 @@ _gnutls_buffer_insert (mhd_gtls_buffer * buffer,
662 */ 662 */
663 if (data_size > buffer->length) 663 if (data_size > buffer->length)
664 { 664 {
665 gnutls_assert (); 665 MHD_gnutls_assert ();
666 /* this shouldn't have happened */ 666 /* this shouldn't have happened */
667 return GNUTLS_E_INTERNAL_ERROR; 667 return GNUTLS_E_INTERNAL_ERROR;
668 } 668 }
@@ -680,9 +680,9 @@ _gnutls_buffer_insert (mhd_gtls_buffer * buffer,
680 680
681 } 681 }
682 682
683 if (mhd_gtls_buffer_append (buffer, _data, data_size) < 0) 683 if (MHD_gtls_buffer_append (buffer, _data, data_size) < 0)
684 { 684 {
685 gnutls_assert (); 685 MHD_gnutls_assert ();
686 return GNUTLS_E_MEMORY_ERROR; 686 return GNUTLS_E_MEMORY_ERROR;
687 } 687 }
688 688
@@ -690,7 +690,7 @@ _gnutls_buffer_insert (mhd_gtls_buffer * buffer,
690} 690}
691 691
692inline static int 692inline static int
693_gnutls_buffer_get (mhd_gtls_buffer * buffer, 693MHD__gnutls_buffer_get (MHD_gtls_buffer * buffer,
694 const opaque ** ptr, size_t * ptr_size) 694 const opaque ** ptr, size_t * ptr_size)
695{ 695{
696 *ptr_size = buffer->length; 696 *ptr_size = buffer->length;
@@ -700,9 +700,9 @@ _gnutls_buffer_get (mhd_gtls_buffer * buffer,
700} 700}
701 701
702/* This function is like write. But it does not return -1 on error. 702/* This function is like write. But it does not return -1 on error.
703 * It does return gnutls_errno instead. 703 * It does return MHD_gnutls_errno instead.
704 * 704 *
705 * In case of E_AGAIN and E_INTERRUPTED errors, you must call gnutls_write_flush(), 705 * In case of E_AGAIN and E_INTERRUPTED errors, you must call MHD_gnutls_write_flush(),
706 * until it returns ok (0). 706 * until it returns ok (0).
707 * 707 *
708 * 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
@@ -711,7 +711,7 @@ _gnutls_buffer_get (mhd_gtls_buffer * buffer,
711 * 711 *
712 */ 712 */
713ssize_t 713ssize_t
714mhd_gtls_io_write_buffered (mhd_gtls_session_t session, 714MHD_gtls_io_write_buffered (MHD_gtls_session_t session,
715 const void *iptr, size_t n) 715 const void *iptr, size_t n)
716{ 716{
717 size_t left; 717 size_t left;
@@ -719,7 +719,7 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
719 ssize_t retval, i; 719 ssize_t retval, i;
720 const opaque *ptr; 720 const opaque *ptr;
721 int ret; 721 int ret;
722 gnutls_transport_ptr_t fd = session->internals.transport_send_ptr; 722 MHD_gnutls_transport_ptr_t fd = session->internals.transport_send_ptr;
723 723
724 /* to know where the procedure was interrupted. 724 /* to know where the procedure was interrupted.
725 */ 725 */
@@ -733,7 +733,7 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
733 */ 733 */
734 if (session->internals.record_send_buffer.length > 0 && iptr != NULL) 734 if (session->internals.record_send_buffer.length > 0 && iptr != NULL)
735 { 735 {
736 gnutls_assert (); 736 MHD_gnutls_assert ();
737 return GNUTLS_E_INVALID_REQUEST; 737 return GNUTLS_E_INVALID_REQUEST;
738 } 738 }
739 739
@@ -742,19 +742,19 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
742 if (iptr == NULL) 742 if (iptr == NULL)
743 { 743 {
744 /* checking is handled above */ 744 /* checking is handled above */
745 ret = _gnutls_buffer_get (&session->internals.record_send_buffer, &ptr, 745 ret = MHD__gnutls_buffer_get (&session->internals.record_send_buffer, &ptr,
746 &n); 746 &n);
747 if (ret < 0) 747 if (ret < 0)
748 { 748 {
749 gnutls_assert (); 749 MHD_gnutls_assert ();
750 return ret; 750 return ret;
751 } 751 }
752 752
753 _gnutls_write_log ("WRITE: Restoring old write. (%d bytes to send)\n", 753 MHD__gnutls_write_log ("WRITE: Restoring old write. (%d bytes to send)\n",
754 n); 754 n);
755 } 755 }
756 756
757 _gnutls_write_log ("WRITE: Will write %d bytes to %d.\n", n, fd); 757 MHD__gnutls_write_log ("WRITE: Will write %d bytes to %d.\n", n, fd);
758 758
759 i = 0; 759 i = 0;
760 left = n; 760 left = n;
@@ -763,7 +763,7 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
763 763
764 session->internals.errnum = 0; 764 session->internals.errnum = 0;
765 765
766 if (session->internals._gnutls_push_func == NULL) 766 if (session->internals.MHD__gnutls_push_func == NULL)
767 { 767 {
768 i = send (GNUTLS_POINTER_TO_INT (fd), &ptr[n - left], left, 0); 768 i = send (GNUTLS_POINTER_TO_INT (fd), &ptr[n - left], left, 0);
769#if HAVE_WINSOCK 769#if HAVE_WINSOCK
@@ -789,7 +789,7 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
789#endif 789#endif
790 } 790 }
791 else 791 else
792 i = session->internals._gnutls_push_func (fd, &ptr[n - left], left); 792 i = session->internals.MHD__gnutls_push_func (fd, &ptr[n - left], left);
793 793
794 if (i == -1) 794 if (i == -1)
795 { 795 {
@@ -801,15 +801,15 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
801 session->internals.record_send_buffer_prev_size += n - left; 801 session->internals.record_send_buffer_prev_size += n - left;
802 802
803 retval = 803 retval =
804 _gnutls_buffer_insert (&session->internals.record_send_buffer, 804 MHD__gnutls_buffer_insert (&session->internals.record_send_buffer,
805 &ptr[n - left], left); 805 &ptr[n - left], left);
806 if (retval < 0) 806 if (retval < 0)
807 { 807 {
808 gnutls_assert (); 808 MHD_gnutls_assert ();
809 return retval; 809 return retval;
810 } 810 }
811 811
812 _gnutls_write_log 812 MHD__gnutls_write_log
813 ("WRITE: Interrupted. Stored %d bytes to buffer. Already sent %d bytes.\n", 813 ("WRITE: Interrupted. Stored %d bytes to buffer. Already sent %d bytes.\n",
814 left, n - left); 814 left, n - left);
815 815
@@ -819,18 +819,18 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
819 } 819 }
820 else 820 else
821 { 821 {
822 gnutls_assert (); 822 MHD_gnutls_assert ();
823 return GNUTLS_E_PUSH_ERROR; 823 return GNUTLS_E_PUSH_ERROR;
824 } 824 }
825 } 825 }
826 left -= i; 826 left -= i;
827 827
828 if (_gnutls_log_level >= 7) 828 if (MHD__gnutls_log_level >= 7)
829 { 829 {
830 char line[128]; 830 char line[128];
831 char tmp[16]; 831 char tmp[16];
832 832
833 _gnutls_write_log 833 MHD__gnutls_write_log
834 ("WRITE: wrote %d bytes to %d. Left %d bytes. Total %d bytes.\n", 834 ("WRITE: wrote %d bytes to %d. Left %d bytes. Total %d bytes.\n",
835 i, fd, left, n); 835 i, fd, left, n);
836 for (x = 0; x < (unsigned) ((i) / 16) + 1; x++) 836 for (x = 0; x < (unsigned) ((i) / 16) + 1; x++)
@@ -841,19 +841,19 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
841 break; 841 break;
842 842
843 sprintf (tmp, "%.4x - ", x); 843 sprintf (tmp, "%.4x - ", x);
844 mhd_gtls_str_cat (line, sizeof (line), tmp); 844 MHD_gtls_str_cat (line, sizeof (line), tmp);
845 845
846 for (j = 0; j < 16; j++) 846 for (j = 0; j < 16; j++)
847 { 847 {
848 if (sum < n - left) 848 if (sum < n - left)
849 { 849 {
850 sprintf (tmp, "%.2x ", ((unsigned char *) ptr)[sum++]); 850 sprintf (tmp, "%.2x ", ((unsigned char *) ptr)[sum++]);
851 mhd_gtls_str_cat (line, sizeof (line), tmp); 851 MHD_gtls_str_cat (line, sizeof (line), tmp);
852 } 852 }
853 else 853 else
854 break; 854 break;
855 } 855 }
856 _gnutls_write_log ("%s\n", line); 856 MHD__gnutls_write_log ("%s\n", line);
857 } 857 }
858 } 858 }
859 } 859 }
@@ -872,15 +872,15 @@ mhd_gtls_io_write_buffered (mhd_gtls_session_t session,
872 * interrupted. 872 * interrupted.
873 */ 873 */
874ssize_t 874ssize_t
875mhd_gtls_io_write_flush (mhd_gtls_session_t session) 875MHD_gtls_io_write_flush (MHD_gtls_session_t session)
876{ 876{
877 ssize_t ret; 877 ssize_t ret;
878 878
879 if (session->internals.record_send_buffer.length == 0) 879 if (session->internals.record_send_buffer.length == 0)
880 return 0; /* done */ 880 return 0; /* done */
881 881
882 ret = mhd_gtls_io_write_buffered (session, NULL, 0); 882 ret = MHD_gtls_io_write_buffered (session, NULL, 0);
883 _gnutls_write_log ("WRITE FLUSH: %d [buffer: %d]\n", ret, 883 MHD__gnutls_write_log ("WRITE FLUSH: %d [buffer: %d]\n", ret,
884 session->internals.record_send_buffer.length); 884 session->internals.record_send_buffer.length);
885 885
886 return ret; 886 return ret;
@@ -891,17 +891,17 @@ mhd_gtls_io_write_flush (mhd_gtls_session_t session)
891 * interrupted. 891 * interrupted.
892 */ 892 */
893ssize_t 893ssize_t
894mhd_gtls_handshake_io_write_flush (mhd_gtls_session_t session) 894MHD_gtls_handshake_io_write_flush (MHD_gtls_session_t session)
895{ 895{
896 ssize_t ret; 896 ssize_t ret;
897 ret = mhd_gtls_handshake_io_send_int (session, 0, 0, NULL, 0); 897 ret = MHD_gtls_handshake_io_send_int (session, 0, 0, NULL, 0);
898 if (ret < 0) 898 if (ret < 0)
899 { 899 {
900 gnutls_assert (); 900 MHD_gnutls_assert ();
901 return ret; 901 return ret;
902 } 902 }
903 903
904 _gnutls_write_log ("HANDSHAKE_FLUSH: written[1] %d bytes\n", ret); 904 MHD__gnutls_write_log ("HANDSHAKE_FLUSH: written[1] %d bytes\n", ret);
905 905
906 if (session->internals.handshake_send_buffer.length == 0) 906 if (session->internals.handshake_send_buffer.length == 0)
907 { 907 {
@@ -916,9 +916,9 @@ mhd_gtls_handshake_io_write_flush (mhd_gtls_session_t session)
916 * protocol. Just makes sure that all data have been sent. 916 * protocol. Just makes sure that all data have been sent.
917 */ 917 */
918ssize_t 918ssize_t
919mhd_gtls_handshake_io_send_int (mhd_gtls_session_t session, 919MHD_gtls_handshake_io_send_int (MHD_gtls_session_t session,
920 content_type_t type, 920 content_type_t type,
921 gnutls_handshake_description_t htype, 921 MHD_gnutls_handshake_description_t htype,
922 const void *iptr, size_t n) 922 const void *iptr, size_t n)
923{ 923{
924 size_t left; 924 size_t left;
@@ -933,12 +933,12 @@ mhd_gtls_handshake_io_send_int (mhd_gtls_session_t session,
933 { 933 {
934 /* resuming previously interrupted write 934 /* resuming previously interrupted write
935 */ 935 */
936 gnutls_assert (); 936 MHD_gnutls_assert ();
937 ret = _gnutls_buffer_get (&session->internals.handshake_send_buffer, 937 ret = MHD__gnutls_buffer_get (&session->internals.handshake_send_buffer,
938 &ptr, &n); 938 &ptr, &n);
939 if (ret < 0) 939 if (ret < 0)
940 { 940 {
941 gnutls_assert (); 941 MHD_gnutls_assert ();
942 return retval; 942 return retval;
943 } 943 }
944 944
@@ -948,7 +948,7 @@ mhd_gtls_handshake_io_send_int (mhd_gtls_session_t session,
948 } 948 }
949 else if (session->internals.handshake_send_buffer.length > 0) 949 else if (session->internals.handshake_send_buffer.length > 0)
950 { 950 {
951 gnutls_assert (); 951 MHD_gnutls_assert ();
952 return GNUTLS_E_INTERNAL_ERROR; 952 return GNUTLS_E_INTERNAL_ERROR;
953 } 953 }
954#ifdef WRITE_DEBUG 954#ifdef WRITE_DEBUG
@@ -956,65 +956,65 @@ mhd_gtls_handshake_io_send_int (mhd_gtls_session_t session,
956 { 956 {
957 size_t sum = 0, x, j; 957 size_t sum = 0, x, j;
958 958
959 _gnutls_write_log ("HWRITE: will write %d bytes to %d.\n", n, 959 MHD__gnutls_write_log ("HWRITE: will write %d bytes to %d.\n", n,
960 gnutls_transport_get_ptr (session)); 960 MHD_gnutls_transport_get_ptr (session));
961 for (x = 0; x < ((n) / 16) + 1; x++) 961 for (x = 0; x < ((n) / 16) + 1; x++)
962 { 962 {
963 if (sum > n) 963 if (sum > n)
964 break; 964 break;
965 965
966 _gnutls_write_log ("%.4x - ", x); 966 MHD__gnutls_write_log ("%.4x - ", x);
967 for (j = 0; j < 16; j++) 967 for (j = 0; j < 16; j++)
968 { 968 {
969 if (sum < n) 969 if (sum < n)
970 { 970 {
971 _gnutls_write_log ("%.2x ", ((unsigned char *) ptr)[sum++]); 971 MHD__gnutls_write_log ("%.2x ", ((unsigned char *) ptr)[sum++]);
972 } 972 }
973 else 973 else
974 break; 974 break;
975 } 975 }
976 _gnutls_write_log ("\n"); 976 MHD__gnutls_write_log ("\n");
977 } 977 }
978 _gnutls_write_log ("\n"); 978 MHD__gnutls_write_log ("\n");
979 } 979 }
980#endif 980#endif
981 981
982 if (n == 0) 982 if (n == 0)
983 { /* if we have no data to send */ 983 { /* if we have no data to send */
984 gnutls_assert (); 984 MHD_gnutls_assert ();
985 return 0; 985 return 0;
986 } 986 }
987 else if (ptr == NULL) 987 else if (ptr == NULL)
988 { 988 {
989 gnutls_assert (); 989 MHD_gnutls_assert ();
990 return GNUTLS_E_INTERNAL_ERROR; 990 return GNUTLS_E_INTERNAL_ERROR;
991 } 991 }
992 992
993 left = n; 993 left = n;
994 while (left > 0) 994 while (left > 0)
995 { 995 {
996 ret = mhd_gtls_send_int (session, type, htype, &ptr[n - left], left); 996 ret = MHD_gtls_send_int (session, type, htype, &ptr[n - left], left);
997 997
998 if (ret <= 0) 998 if (ret <= 0)
999 { 999 {
1000 if (ret == 0) 1000 if (ret == 0)
1001 { 1001 {
1002 gnutls_assert (); 1002 MHD_gnutls_assert ();
1003 ret = GNUTLS_E_INTERNAL_ERROR; 1003 ret = GNUTLS_E_INTERNAL_ERROR;
1004 } 1004 }
1005 1005
1006 if (left > 0 && (ret == GNUTLS_E_INTERRUPTED || ret 1006 if (left > 0 && (ret == GNUTLS_E_INTERRUPTED || ret
1007 == GNUTLS_E_AGAIN)) 1007 == GNUTLS_E_AGAIN))
1008 { 1008 {
1009 gnutls_assert (); 1009 MHD_gnutls_assert ();
1010 1010
1011 retval = 1011 retval =
1012 _gnutls_buffer_insert (&session->internals. 1012 MHD__gnutls_buffer_insert (&session->internals.
1013 handshake_send_buffer, &ptr[n - left], 1013 handshake_send_buffer, &ptr[n - left],
1014 left); 1014 left);
1015 if (retval < 0) 1015 if (retval < 0)
1016 { 1016 {
1017 gnutls_assert (); 1017 MHD_gnutls_assert ();
1018 return retval; 1018 return retval;
1019 } 1019 }
1020 1020
@@ -1030,7 +1030,7 @@ mhd_gtls_handshake_io_send_int (mhd_gtls_session_t session,
1030 session->internals.handshake_send_buffer.length = 0; 1030 session->internals.handshake_send_buffer.length = 0;
1031 } 1031 }
1032 1032
1033 gnutls_assert (); 1033 MHD_gnutls_assert ();
1034 return ret; 1034 return ret;
1035 } 1035 }
1036 left -= ret; 1036 left -= ret;
@@ -1049,9 +1049,9 @@ mhd_gtls_handshake_io_send_int (mhd_gtls_session_t session,
1049 * protocol. Makes sure that we have received all data. 1049 * protocol. Makes sure that we have received all data.
1050 */ 1050 */
1051ssize_t 1051ssize_t
1052mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session, 1052MHD_gtls_handshake_io_recv_int (MHD_gtls_session_t session,
1053 content_type_t type, 1053 content_type_t type,
1054 gnutls_handshake_description_t htype, 1054 MHD_gnutls_handshake_description_t htype,
1055 void *iptr, size_t sizeOfPtr) 1055 void *iptr, size_t sizeOfPtr)
1056{ 1056{
1057 size_t left; 1057 size_t left;
@@ -1064,7 +1064,7 @@ mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session,
1064 1064
1065 if (sizeOfPtr == 0 || iptr == NULL) 1065 if (sizeOfPtr == 0 || iptr == NULL)
1066 { 1066 {
1067 gnutls_assert (); 1067 MHD_gnutls_assert ();
1068 return GNUTLS_E_INVALID_REQUEST; 1068 return GNUTLS_E_INVALID_REQUEST;
1069 } 1069 }
1070 1070
@@ -1075,7 +1075,7 @@ mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session,
1075 { 1075 {
1076 /* if requested less data then return it. 1076 /* if requested less data then return it.
1077 */ 1077 */
1078 gnutls_assert (); 1078 MHD_gnutls_assert ();
1079 memcpy (iptr, session->internals.handshake_recv_buffer.data, 1079 memcpy (iptr, session->internals.handshake_recv_buffer.data,
1080 sizeOfPtr); 1080 sizeOfPtr);
1081 1081
@@ -1087,7 +1087,7 @@ mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session,
1087 1087
1088 return sizeOfPtr; 1088 return sizeOfPtr;
1089 } 1089 }
1090 gnutls_assert (); 1090 MHD_gnutls_assert ();
1091 memcpy (iptr, session->internals.handshake_recv_buffer.data, 1091 memcpy (iptr, session->internals.handshake_recv_buffer.data,
1092 session->internals.handshake_recv_buffer.length); 1092 session->internals.handshake_recv_buffer.length);
1093 1093
@@ -1102,21 +1102,21 @@ mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session,
1102 while (left > 0) 1102 while (left > 0)
1103 { 1103 {
1104 dsize = sizeOfPtr - left; 1104 dsize = sizeOfPtr - left;
1105 i = mhd_gtls_recv_int (session, type, htype, &ptr[dsize], left); 1105 i = MHD_gtls_recv_int (session, type, htype, &ptr[dsize], left);
1106 if (i < 0) 1106 if (i < 0)
1107 { 1107 {
1108 1108
1109 if (dsize > 0 && (i == GNUTLS_E_INTERRUPTED || i == GNUTLS_E_AGAIN)) 1109 if (dsize > 0 && (i == GNUTLS_E_INTERRUPTED || i == GNUTLS_E_AGAIN))
1110 { 1110 {
1111 gnutls_assert (); 1111 MHD_gnutls_assert ();
1112 1112
1113 session->internals.handshake_recv_buffer.data 1113 session->internals.handshake_recv_buffer.data
1114 = 1114 =
1115 mhd_gtls_realloc_fast (session->internals. 1115 MHD_gtls_realloc_fast (session->internals.
1116 handshake_recv_buffer.data, dsize); 1116 handshake_recv_buffer.data, dsize);
1117 if (session->internals.handshake_recv_buffer.data == NULL) 1117 if (session->internals.handshake_recv_buffer.data == NULL)
1118 { 1118 {
1119 gnutls_assert (); 1119 MHD_gnutls_assert ();
1120 return GNUTLS_E_MEMORY_ERROR; 1120 return GNUTLS_E_MEMORY_ERROR;
1121 } 1121 }
1122 1122
@@ -1131,7 +1131,7 @@ mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session,
1131 else 1131 else
1132 session->internals.handshake_recv_buffer.length = 0; 1132 session->internals.handshake_recv_buffer.length = 0;
1133 1133
1134 gnutls_assert (); 1134 MHD_gnutls_assert ();
1135 1135
1136 return i; 1136 return i;
1137 } 1137 }
@@ -1155,7 +1155,7 @@ mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t session,
1155 * and finished messages. 1155 * and finished messages.
1156 */ 1156 */
1157int 1157int
1158mhd_gtls_handshake_buffer_put (mhd_gtls_session_t session, opaque * data, 1158MHD_gtls_handshake_buffer_put (MHD_gtls_session_t session, opaque * data,
1159 size_t length) 1159 size_t length)
1160{ 1160{
1161 1161
@@ -1172,16 +1172,16 @@ mhd_gtls_handshake_buffer_put (mhd_gtls_session_t session, opaque * data,
1172 internals. 1172 internals.
1173 max_handshake_data_buffer_size)) 1173 max_handshake_data_buffer_size))
1174 { 1174 {
1175 gnutls_assert (); 1175 MHD_gnutls_assert ();
1176 return GNUTLS_E_MEMORY_ERROR; 1176 return GNUTLS_E_MEMORY_ERROR;
1177 } 1177 }
1178 1178
1179 _gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data\n", length); 1179 MHD__gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data\n", length);
1180 1180
1181 if (mhd_gtls_buffer_append (&session->internals.handshake_hash_buffer, data, 1181 if (MHD_gtls_buffer_append (&session->internals.handshake_hash_buffer, data,
1182 length) < 0) 1182 length) < 0)
1183 { 1183 {
1184 gnutls_assert (); 1184 MHD_gnutls_assert ();
1185 return GNUTLS_E_MEMORY_ERROR; 1185 return GNUTLS_E_MEMORY_ERROR;
1186 } 1186 }
1187 1187
@@ -1189,7 +1189,7 @@ mhd_gtls_handshake_buffer_put (mhd_gtls_session_t session, opaque * data,
1189} 1189}
1190 1190
1191int 1191int
1192mhd_gtls_handshake_buffer_get_size (mhd_gtls_session_t session) 1192MHD_gtls_handshake_buffer_get_size (MHD_gtls_session_t session)
1193{ 1193{
1194 1194
1195 return session->internals.handshake_hash_buffer.length; 1195 return session->internals.handshake_hash_buffer.length;
@@ -1199,7 +1199,7 @@ mhd_gtls_handshake_buffer_get_size (mhd_gtls_session_t session)
1199 * and returns data from it (peek mode!) 1199 * and returns data from it (peek mode!)
1200 */ 1200 */
1201int 1201int
1202mhd_gtls_handshake_buffer_peek (mhd_gtls_session_t session, opaque * data, 1202MHD_gtls_handshake_buffer_peek (MHD_gtls_session_t session, opaque * data,
1203 size_t length) 1203 size_t length)
1204{ 1204{
1205 if (length > session->internals.handshake_hash_buffer.length) 1205 if (length > session->internals.handshake_hash_buffer.length)
@@ -1207,7 +1207,7 @@ mhd_gtls_handshake_buffer_peek (mhd_gtls_session_t session, opaque * data,
1207 length = session->internals.handshake_hash_buffer.length; 1207 length = session->internals.handshake_hash_buffer.length;
1208 } 1208 }
1209 1209
1210 _gnutls_buffers_log ("BUF[HSK]: Peeked %d bytes of Data\n", length); 1210 MHD__gnutls_buffers_log ("BUF[HSK]: Peeked %d bytes of Data\n", length);
1211 1211
1212 memcpy (data, session->internals.handshake_hash_buffer.data, length); 1212 memcpy (data, session->internals.handshake_hash_buffer.data, length);
1213 return length; 1213 return length;
@@ -1217,13 +1217,13 @@ mhd_gtls_handshake_buffer_peek (mhd_gtls_session_t session, opaque * data,
1217 * and returns data from it (peek mode!) 1217 * and returns data from it (peek mode!)
1218 */ 1218 */
1219int 1219int
1220mhd_gtls_handshake_buffer_get_ptr (mhd_gtls_session_t session, 1220MHD_gtls_handshake_buffer_get_ptr (MHD_gtls_session_t session,
1221 opaque ** data_ptr, size_t * length) 1221 opaque ** data_ptr, size_t * length)
1222{ 1222{
1223 if (length != NULL) 1223 if (length != NULL)
1224 *length = session->internals.handshake_hash_buffer.length; 1224 *length = session->internals.handshake_hash_buffer.length;
1225 1225
1226 _gnutls_buffers_log ("BUF[HSK]: Peeked %d bytes of Data\n", 1226 MHD__gnutls_buffers_log ("BUF[HSK]: Peeked %d bytes of Data\n",
1227 session->internals.handshake_hash_buffer.length); 1227 session->internals.handshake_hash_buffer.length);
1228 1228
1229 if (data_ptr != NULL) 1229 if (data_ptr != NULL)
@@ -1235,10 +1235,10 @@ mhd_gtls_handshake_buffer_get_ptr (mhd_gtls_session_t session,
1235/* Does not free the buffer 1235/* Does not free the buffer
1236 */ 1236 */
1237int 1237int
1238mhd_gtls_handshake_buffer_empty (mhd_gtls_session_t session) 1238MHD_gtls_handshake_buffer_empty (MHD_gtls_session_t session)
1239{ 1239{
1240 1240
1241 _gnutls_buffers_log ("BUF[HSK]: Emptied buffer\n"); 1241 MHD__gnutls_buffers_log ("BUF[HSK]: Emptied buffer\n");
1242 1242
1243 session->internals.handshake_hash_buffer.length = 0; 1243 session->internals.handshake_hash_buffer.length = 0;
1244 1244
@@ -1246,9 +1246,9 @@ mhd_gtls_handshake_buffer_empty (mhd_gtls_session_t session)
1246} 1246}
1247 1247
1248int 1248int
1249mhd_gtls_handshake_buffer_clear (mhd_gtls_session_t session) 1249MHD_gtls_handshake_buffer_clear (MHD_gtls_session_t session)
1250{ 1250{
1251 _gnutls_buffers_log ("BUF[HSK]: Cleared Data from buffer\n"); 1251 MHD__gnutls_buffers_log ("BUF[HSK]: Cleared Data from buffer\n");
1252 mhd_gtls_buffer_clear (&session->internals.handshake_hash_buffer); 1252 MHD_gtls_buffer_clear (&session->internals.handshake_hash_buffer);
1253 return 0; 1253 return 0;
1254} 1254}
diff --git a/src/daemon/https/tls/gnutls_buffers.h b/src/daemon/https/tls/gnutls_buffers.h
index 609c2095..918da673 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 mhd_gnutls_record_buffer_put (content_type_t type, 25int MHD_gnutls_record_buffer_put (content_type_t type,
26 mhd_gtls_session_t session, opaque * data, 26 MHD_gtls_session_t session, opaque * data,
27 size_t length); 27 size_t length);
28int mhd_gnutls_record_buffer_get_size (content_type_t type, 28int MHD_gnutls_record_buffer_get_size (content_type_t type,
29 mhd_gtls_session_t session); 29 MHD_gtls_session_t session);
30int mhd_gtls_record_buffer_get (content_type_t type, 30int MHD_gtls_record_buffer_get (content_type_t type,
31 mhd_gtls_session_t session, opaque * data, 31 MHD_gtls_session_t session, opaque * data,
32 size_t length); 32 size_t length);
33ssize_t mhd_gtls_io_read_buffered (mhd_gtls_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 mhd_gtls_io_clear_read_buffer (mhd_gtls_session_t); 35void MHD_gtls_io_clear_read_buffer (MHD_gtls_session_t);
36int mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session); 36int MHD_gtls_io_clear_peeked_data (MHD_gtls_session_t session);
37 37
38ssize_t mhd_gtls_io_write_buffered (mhd_gtls_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 mhd_gtls_io_write_buffered2 (mhd_gtls_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 mhd_gtls_handshake_buffer_get_size (mhd_gtls_session_t session); 43int MHD_gtls_handshake_buffer_get_size (MHD_gtls_session_t session);
44int mhd_gtls_handshake_buffer_peek (mhd_gtls_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 mhd_gtls_handshake_buffer_put (mhd_gtls_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 mhd_gtls_handshake_buffer_clear (mhd_gtls_session_t session); 48int MHD_gtls_handshake_buffer_clear (MHD_gtls_session_t session);
49int mhd_gtls_handshake_buffer_empty (mhd_gtls_session_t session); 49int MHD_gtls_handshake_buffer_empty (MHD_gtls_session_t session);
50int mhd_gtls_handshake_buffer_get_ptr (mhd_gtls_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 MHD__gnutls_handshake_io_buffer_clear( session) \
54 mhd_gtls_buffer_clear( &session->internals.handshake_send_buffer); \ 54 MHD_gtls_buffer_clear( &session->internals.handshake_send_buffer); \
55 mhd_gtls_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 mhd_gtls_handshake_io_recv_int (mhd_gtls_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, 59 MHD_gnutls_handshake_description_t,
60 void *, size_t); 60 void *, size_t);
61ssize_t mhd_gtls_handshake_io_send_int (mhd_gtls_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 MHD_gnutls_handshake_description_t,
63 const void *, size_t); 63 const void *, size_t);
64ssize_t mhd_gtls_io_write_flush (mhd_gtls_session_t session); 64ssize_t MHD_gtls_io_write_flush (MHD_gtls_session_t session);
65ssize_t mhd_gtls_handshake_io_write_flush (mhd_gtls_session_t session); 65ssize_t MHD_gtls_handshake_io_write_flush (MHD_gtls_session_t session);
66 66
67size_t MHD_gtls_record_check_pending (mhd_gtls_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 17e95e48..45e001d6 100644
--- a/src/daemon/https/tls/gnutls_cert.c
+++ b/src/daemon/https/tls/gnutls_cert.c
@@ -45,8 +45,8 @@
45#include "mpi.h" 45#include "mpi.h"
46 46
47/** 47/**
48 * MHD_gnutls_certificate_free_keys - Used to free all the keys from a mhd_gtls_cert_credentials_t structure 48 * MHD__gnutls_certificate_free_keys - Used to free all the keys from a MHD_gtls_cert_credentials_t structure
49 * @sc: is an #mhd_gtls_cert_credentials_t structure. 49 * @sc: is an #MHD_gtls_cert_credentials_t structure.
50 * 50 *
51 * This function will delete all the keys and the certificates associated 51 * This function will delete all the keys and the certificates associated
52 * with the given credentials. This function must not be called when a 52 * with the given credentials. This function must not be called when a
@@ -54,7 +54,7 @@
54 * 54 *
55 **/ 55 **/
56void 56void
57MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc) 57MHD__gnutls_certificate_free_keys (MHD_gtls_cert_credentials_t sc)
58{ 58{
59 unsigned i, j; 59 unsigned i, j;
60 60
@@ -62,23 +62,23 @@ MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
62 { 62 {
63 for (j = 0; j < sc->cert_list_length[i]; j++) 63 for (j = 0; j < sc->cert_list_length[i]; j++)
64 { 64 {
65 mhd_gtls_gcert_deinit (&sc->cert_list[i][j]); 65 MHD_gtls_gcert_deinit (&sc->cert_list[i][j]);
66 } 66 }
67 gnutls_free (sc->cert_list[i]); 67 MHD_gnutls_free (sc->cert_list[i]);
68 } 68 }
69 69
70 gnutls_free (sc->cert_list_length); 70 MHD_gnutls_free (sc->cert_list_length);
71 sc->cert_list_length = NULL; 71 sc->cert_list_length = NULL;
72 72
73 gnutls_free (sc->cert_list); 73 MHD_gnutls_free (sc->cert_list);
74 sc->cert_list = NULL; 74 sc->cert_list = NULL;
75 75
76 for (i = 0; i < sc->ncerts; i++) 76 for (i = 0; i < sc->ncerts; i++)
77 { 77 {
78 mhd_gtls_gkey_deinit (&sc->pkey[i]); 78 MHD_gtls_gkey_deinit (&sc->pkey[i]);
79 } 79 }
80 80
81 gnutls_free (sc->pkey); 81 MHD_gnutls_free (sc->pkey);
82 sc->pkey = NULL; 82 sc->pkey = NULL;
83 83
84 sc->ncerts = 0; 84 sc->ncerts = 0;
@@ -86,8 +86,8 @@ MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
86} 86}
87 87
88/** 88/**
89 * MHD_gnutls_certificate_free_cas - Used to free all the CAs from a mhd_gtls_cert_credentials_t structure 89 * MHD__gnutls_certificate_free_cas - Used to free all the CAs from a MHD_gtls_cert_credentials_t structure
90 * @sc: is an #mhd_gtls_cert_credentials_t structure. 90 * @sc: is an #MHD_gtls_cert_credentials_t structure.
91 * 91 *
92 * This function will delete all the CAs associated 92 * This function will delete all the CAs associated
93 * with the given credentials. Servers that do not use 93 * with the given credentials. Servers that do not use
@@ -96,25 +96,25 @@ MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
96 * 96 *
97 **/ 97 **/
98void 98void
99MHD_gnutls_certificate_free_cas (mhd_gtls_cert_credentials_t sc) 99MHD__gnutls_certificate_free_cas (MHD_gtls_cert_credentials_t sc)
100{ 100{
101 unsigned j; 101 unsigned j;
102 102
103 for (j = 0; j < sc->x509_ncas; j++) 103 for (j = 0; j < sc->x509_ncas; j++)
104 { 104 {
105 gnutls_x509_crt_deinit (sc->x509_ca_list[j]); 105 MHD_gnutls_x509_crt_deinit (sc->x509_ca_list[j]);
106 } 106 }
107 107
108 sc->x509_ncas = 0; 108 sc->x509_ncas = 0;
109 109
110 gnutls_free (sc->x509_ca_list); 110 MHD_gnutls_free (sc->x509_ca_list);
111 sc->x509_ca_list = NULL; 111 sc->x509_ca_list = NULL;
112 112
113} 113}
114 114
115/** 115/**
116 * MHD_gnutls_certificate_free_ca_names - Used to free all the CA names from a mhd_gtls_cert_credentials_t structure 116 * MHD__gnutls_certificate_free_ca_names - Used to free all the CA names from a MHD_gtls_cert_credentials_t structure
117 * @sc: is an #mhd_gtls_cert_credentials_t structure. 117 * @sc: is an #MHD_gtls_cert_credentials_t structure.
118 * 118 *
119 * This function will delete all the CA name in the 119 * This function will delete all the CA name in the
120 * given credentials. Clients may call this to save some memory 120 * given credentials. Clients may call this to save some memory
@@ -125,13 +125,13 @@ MHD_gnutls_certificate_free_cas (mhd_gtls_cert_credentials_t sc)
125 * 125 *
126 **/ 126 **/
127void 127void
128MHD_gnutls_certificate_free_ca_names (mhd_gtls_cert_credentials_t sc) 128MHD__gnutls_certificate_free_ca_names (MHD_gtls_cert_credentials_t sc)
129{ 129{
130 _gnutls_free_datum (&sc->x509_rdn_sequence); 130 MHD__gnutls_free_datum (&sc->x509_rdn_sequence);
131} 131}
132 132
133/*- 133/*-
134 * mhd_gtls_certificate_get_rsa_params - Returns the RSA parameters pointer 134 * MHD_gtls_certificate_get_rsa_params - Returns the RSA parameters pointer
135 * @rsa_params: holds the RSA parameters or NULL. 135 * @rsa_params: holds the RSA parameters or NULL.
136 * @func: function to retrieve the parameters or NULL. 136 * @func: function to retrieve the parameters or NULL.
137 * @session: The session. 137 * @session: The session.
@@ -139,12 +139,12 @@ MHD_gnutls_certificate_free_ca_names (mhd_gtls_cert_credentials_t sc)
139 * This function will return the rsa parameters pointer. 139 * This function will return the rsa parameters pointer.
140 * 140 *
141 -*/ 141 -*/
142mhd_gtls_rsa_params_t 142MHD_gtls_rsa_params_t
143mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params, 143MHD_gtls_certificate_get_rsa_params (MHD_gtls_rsa_params_t rsa_params,
144 gnutls_params_function * func, 144 MHD_gnutls_params_function * func,
145 mhd_gtls_session_t session) 145 MHD_gtls_session_t session)
146{ 146{
147 gnutls_params_st params; 147 MHD_gnutls_params_st params;
148 int ret; 148 int ret;
149 149
150 if (session->internals.params.rsa_params) 150 if (session->internals.params.rsa_params)
@@ -171,8 +171,8 @@ mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params,
171 171
172 172
173/** 173/**
174 * MHD_gnutls_certificate_free_credentials - Used to free an allocated mhd_gtls_cert_credentials_t structure 174 * MHD__gnutls_certificate_free_credentials - Used to free an allocated MHD_gtls_cert_credentials_t structure
175 * @sc: is an #mhd_gtls_cert_credentials_t structure. 175 * @sc: is an #MHD_gtls_cert_credentials_t structure.
176 * 176 *
177 * This structure is complex enough to manipulate directly thus 177 * This structure is complex enough to manipulate directly thus
178 * this helper function is provided in order to free (deallocate) it. 178 * this helper function is provided in order to free (deallocate) it.
@@ -182,26 +182,26 @@ mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params,
182 * this function). 182 * this function).
183 **/ 183 **/
184void 184void
185MHD_gnutls_certificate_free_credentials (mhd_gtls_cert_credentials_t sc) 185MHD__gnutls_certificate_free_credentials (MHD_gtls_cert_credentials_t sc)
186{ 186{
187 MHD_gnutls_certificate_free_keys (sc); 187 MHD__gnutls_certificate_free_keys (sc);
188 MHD_gnutls_certificate_free_cas (sc); 188 MHD__gnutls_certificate_free_cas (sc);
189 MHD_gnutls_certificate_free_ca_names (sc); 189 MHD__gnutls_certificate_free_ca_names (sc);
190#ifdef ENABLE_PKI 190#ifdef ENABLE_PKI
191 MHD_gnutls_certificate_free_crls (sc); 191 MHD__gnutls_certificate_free_crls (sc);
192#endif 192#endif
193 193
194#ifdef KEYRING_HACK 194#ifdef KEYRING_HACK
195 _gnutls_free_datum (&sc->keyring); 195 MHD__gnutls_free_datum (&sc->keyring);
196#endif 196#endif
197 197
198 gnutls_free (sc); 198 MHD_gnutls_free (sc);
199} 199}
200 200
201 201
202/** 202/**
203 * MHD_gnutls_certificate_allocate_credentials - Used to allocate a mhd_gtls_cert_credentials_t structure 203 * MHD__gnutls_certificate_allocate_credentials - Used to allocate a MHD_gtls_cert_credentials_t structure
204 * @res: is a pointer to an #mhd_gtls_cert_credentials_t structure. 204 * @res: is a pointer to an #MHD_gtls_cert_credentials_t structure.
205 * 205 *
206 * This structure is complex enough to manipulate directly thus this 206 * This structure is complex enough to manipulate directly thus this
207 * helper function is provided in order to allocate it. 207 * helper function is provided in order to allocate it.
@@ -209,10 +209,10 @@ MHD_gnutls_certificate_free_credentials (mhd_gtls_cert_credentials_t sc)
209 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 209 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
210 **/ 210 **/
211int 211int
212MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t * 212MHD__gnutls_certificate_allocate_credentials (MHD_gtls_cert_credentials_t *
213 res) 213 res)
214{ 214{
215 *res = gnutls_calloc (1, sizeof (mhd_gtls_cert_credentials_st)); 215 *res = MHD_gnutls_calloc (1, sizeof (MHD_gtls_cert_credentials_st));
216 216
217 if (*res == NULL) 217 if (*res == NULL)
218 return GNUTLS_E_MEMORY_ERROR; 218 return GNUTLS_E_MEMORY_ERROR;
@@ -231,14 +231,14 @@ MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t *
231 * extensions in order to disable unneded algorithms. 231 * extensions in order to disable unneded algorithms.
232 */ 232 */
233int 233int
234mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session, 234MHD_gtls_selected_cert_supported_kx (MHD_gtls_session_t session,
235 enum MHD_GNUTLS_KeyExchangeAlgorithm 235 enum MHD_GNUTLS_KeyExchangeAlgorithm
236 **alg, int *alg_size) 236 **alg, int *alg_size)
237{ 237{
238 enum MHD_GNUTLS_KeyExchangeAlgorithm kx; 238 enum MHD_GNUTLS_KeyExchangeAlgorithm kx;
239 enum MHD_GNUTLS_PublicKeyAlgorithm pk; 239 enum MHD_GNUTLS_PublicKeyAlgorithm pk;
240 enum MHD_GNUTLS_KeyExchangeAlgorithm kxlist[MAX_ALGOS]; 240 enum MHD_GNUTLS_KeyExchangeAlgorithm kxlist[MAX_ALGOS];
241 gnutls_cert *cert; 241 MHD_gnutls_cert *cert;
242 int i; 242 int i;
243 243
244 if (session->internals.selected_cert_list_length == 0) 244 if (session->internals.selected_cert_list_length == 0)
@@ -253,11 +253,11 @@ mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
253 253
254 for (kx = 0; kx < MAX_ALGOS; kx++) 254 for (kx = 0; kx < MAX_ALGOS; kx++)
255 { 255 {
256 pk = mhd_gtls_map_pk_get_pk (kx); 256 pk = MHD_gtls_map_pk_get_pk (kx);
257 if (pk == cert->subject_pk_algorithm) 257 if (pk == cert->subject_pk_algorithm)
258 { 258 {
259 /* then check key usage */ 259 /* then check key usage */
260 if (_gnutls_check_key_usage (cert, kx) == 0) 260 if (MHD__gnutls_check_key_usage (cert, kx) == 0)
261 { 261 {
262 kxlist[i] = kx; 262 kxlist[i] = kx;
263 i++; 263 i++;
@@ -267,11 +267,11 @@ mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
267 267
268 if (i == 0) 268 if (i == 0)
269 { 269 {
270 gnutls_assert (); 270 MHD_gnutls_assert ();
271 return GNUTLS_E_INVALID_REQUEST; 271 return GNUTLS_E_INVALID_REQUEST;
272 } 272 }
273 273
274 *alg = gnutls_calloc (1, sizeof (enum MHD_GNUTLS_KeyExchangeAlgorithm) * i); 274 *alg = MHD_gnutls_calloc (1, sizeof (enum MHD_GNUTLS_KeyExchangeAlgorithm) * i);
275 if (*alg == NULL) 275 if (*alg == NULL)
276 return GNUTLS_E_MEMORY_ERROR; 276 return GNUTLS_E_MEMORY_ERROR;
277 277
@@ -285,7 +285,7 @@ mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
285 285
286/** 286/**
287 * MHD_gtls_certificate_server_set_request - Used to set whether to request a client certificate 287 * MHD_gtls_certificate_server_set_request - Used to set whether to request a client certificate
288 * @session: is an #mhd_gtls_session_t structure. 288 * @session: is an #MHD_gtls_session_t structure.
289 * @req: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE 289 * @req: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE
290 * 290 *
291 * This function specifies if we (in case of a server) are going 291 * This function specifies if we (in case of a server) are going
@@ -296,28 +296,28 @@ mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
296 * send a certificate. 296 * send a certificate.
297 **/ 297 **/
298void 298void
299MHD_gtls_certificate_server_set_request (mhd_gtls_session_t session, 299MHD_gtls_certificate_server_set_request (MHD_gtls_session_t session,
300 gnutls_certificate_request_t req) 300 MHD_gnutls_certificate_request_t req)
301{ 301{
302 session->internals.send_cert_req = req; 302 session->internals.send_cert_req = req;
303} 303}
304 304
305/** 305/**
306 * MHD_gtls_certificate_client_set_retrieve_function - Used to set a callback to retrieve the certificate 306 * MHD_gtls_certificate_client_set_retrieve_function - Used to set a callback to retrieve the certificate
307 * @cred: is a #mhd_gtls_cert_credentials_t structure. 307 * @cred: is a #MHD_gtls_cert_credentials_t structure.
308 * @func: is the callback function 308 * @func: is the callback function
309 * 309 *
310 * This function sets a callback to be called in order to retrieve the certificate 310 * This function sets a callback to be called in order to retrieve the certificate
311 * to be used in the handshake. 311 * to be used in the handshake.
312 * The callback's function prototype is: 312 * The callback's function prototype is:
313 * int (*callback)(mhd_gtls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs, 313 * int (*callback)(MHD_gtls_session_t, const MHD_gnutls_datum_t* req_ca_dn, int nreqs,
314 * const enum MHD_GNUTLS_PublicKeyAlgorithm* pk_algos, int pk_algos_length, gnutls_retr_st* st); 314 * const enum MHD_GNUTLS_PublicKeyAlgorithm* pk_algos, int pk_algos_length, MHD_gnutls_retr_st* st);
315 * 315 *
316 * @req_ca_cert is only used in X.509 certificates. 316 * @req_ca_cert is only used in X.509 certificates.
317 * Contains a list with the CA names that the server considers trusted. 317 * Contains a list with the CA names that the server considers trusted.
318 * Normally we should send a certificate that is signed 318 * Normally we should send a certificate that is signed
319 * by one of these CAs. These names are DER encoded. To get a more 319 * by one of these CAs. These names are DER encoded. To get a more
320 * meaningful value use the function gnutls_x509_rdn_get(). 320 * meaningful value use the function MHD_gnutls_x509_rdn_get().
321 * 321 *
322 * @pk_algos contains a list with server's acceptable signature algorithms. 322 * @pk_algos contains a list with server's acceptable signature algorithms.
323 * The certificate returned should support the server's given algorithms. 323 * The certificate returned should support the server's given algorithms.
@@ -333,21 +333,21 @@ MHD_gtls_certificate_server_set_request (mhd_gtls_session_t session,
333 * will be terminated. 333 * will be terminated.
334 **/ 334 **/
335void MHD_gtls_certificate_client_set_retrieve_function 335void MHD_gtls_certificate_client_set_retrieve_function
336 (mhd_gtls_cert_credentials_t cred, 336 (MHD_gtls_cert_credentials_t cred,
337 gnutls_certificate_client_retrieve_function * func) 337 MHD_gnutls_certificate_client_retrieve_function * func)
338{ 338{
339 cred->client_get_cert_callback = func; 339 cred->client_get_cert_callback = func;
340} 340}
341 341
342/** 342/**
343 * MHD_gtls_certificate_server_set_retrieve_function - Used to set a callback to retrieve the certificate 343 * MHD_gtls_certificate_server_set_retrieve_function - Used to set a callback to retrieve the certificate
344 * @cred: is a #mhd_gtls_cert_credentials_t structure. 344 * @cred: is a #MHD_gtls_cert_credentials_t structure.
345 * @func: is the callback function 345 * @func: is the callback function
346 * 346 *
347 * This function sets a callback to be called in order to retrieve the certificate 347 * This function sets a callback to be called in order to retrieve the certificate
348 * to be used in the handshake. 348 * to be used in the handshake.
349 * The callback's function prototype is: 349 * The callback's function prototype is:
350 * int (*callback)(mhd_gtls_session_t, gnutls_retr_st* st); 350 * int (*callback)(MHD_gtls_session_t, MHD_gnutls_retr_st* st);
351 * 351 *
352 * @st should contain the certificates and private keys. 352 * @st should contain the certificates and private keys.
353 * 353 *
@@ -359,14 +359,14 @@ void MHD_gtls_certificate_client_set_retrieve_function
359 * will be terminated. 359 * will be terminated.
360 **/ 360 **/
361void MHD_gtls_certificate_server_set_retrieve_function 361void MHD_gtls_certificate_server_set_retrieve_function
362 (mhd_gtls_cert_credentials_t cred, 362 (MHD_gtls_cert_credentials_t cred,
363 gnutls_certificate_server_retrieve_function * func) 363 MHD_gnutls_certificate_server_retrieve_function * func)
364{ 364{
365 cred->server_get_cert_callback = func; 365 cred->server_get_cert_callback = func;
366} 366}
367 367
368/*- 368/*-
369 * _gnutls_x509_extract_certificate_activation_time - This function returns the peer's certificate activation time 369 * MHD__gnutls_x509_extract_certificate_activation_time - This function returns the peer's certificate activation time
370 * @cert: should contain an X.509 DER encoded certificate 370 * @cert: should contain an X.509 DER encoded certificate
371 * 371 *
372 * This function will return the certificate's activation time in UNIX time 372 * This function will return the certificate's activation time in UNIX time
@@ -376,31 +376,31 @@ void MHD_gtls_certificate_server_set_retrieve_function
376 * 376 *
377 -*/ 377 -*/
378static time_t 378static time_t
379_gnutls_x509_get_raw_crt_activation_time (const gnutls_datum_t * cert) 379MHD__gnutls_x509_get_raw_crt_activation_time (const MHD_gnutls_datum_t * cert)
380{ 380{
381 gnutls_x509_crt_t xcert; 381 MHD_gnutls_x509_crt_t xcert;
382 time_t result; 382 time_t result;
383 383
384 result = gnutls_x509_crt_init (&xcert); 384 result = MHD_gnutls_x509_crt_init (&xcert);
385 if (result < 0) 385 if (result < 0)
386 return (time_t) - 1; 386 return (time_t) - 1;
387 387
388 result = gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER); 388 result = MHD_gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER);
389 if (result < 0) 389 if (result < 0)
390 { 390 {
391 gnutls_x509_crt_deinit (xcert); 391 MHD_gnutls_x509_crt_deinit (xcert);
392 return (time_t) - 1; 392 return (time_t) - 1;
393 } 393 }
394 394
395 result = gnutls_x509_crt_get_activation_time (xcert); 395 result = MHD_gnutls_x509_crt_get_activation_time (xcert);
396 396
397 gnutls_x509_crt_deinit (xcert); 397 MHD_gnutls_x509_crt_deinit (xcert);
398 398
399 return result; 399 return result;
400} 400}
401 401
402/*- 402/*-
403 * gnutls_x509_extract_certificate_expiration_time - This function returns the certificate's expiration time 403 * MHD_gnutls_x509_extract_certificate_expiration_time - This function returns the certificate's expiration time
404 * @cert: should contain an X.509 DER encoded certificate 404 * @cert: should contain an X.509 DER encoded certificate
405 * 405 *
406 * This function will return the certificate's expiration time in UNIX 406 * This function will return the certificate's expiration time in UNIX
@@ -410,25 +410,25 @@ _gnutls_x509_get_raw_crt_activation_time (const gnutls_datum_t * cert)
410 * 410 *
411 -*/ 411 -*/
412static time_t 412static time_t
413_gnutls_x509_get_raw_crt_expiration_time (const gnutls_datum_t * cert) 413MHD__gnutls_x509_get_raw_crt_expiration_time (const MHD_gnutls_datum_t * cert)
414{ 414{
415 gnutls_x509_crt_t xcert; 415 MHD_gnutls_x509_crt_t xcert;
416 time_t result; 416 time_t result;
417 417
418 result = gnutls_x509_crt_init (&xcert); 418 result = MHD_gnutls_x509_crt_init (&xcert);
419 if (result < 0) 419 if (result < 0)
420 return (time_t) - 1; 420 return (time_t) - 1;
421 421
422 result = gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER); 422 result = MHD_gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER);
423 if (result < 0) 423 if (result < 0)
424 { 424 {
425 gnutls_x509_crt_deinit (xcert); 425 MHD_gnutls_x509_crt_deinit (xcert);
426 return (time_t) - 1; 426 return (time_t) - 1;
427 } 427 }
428 428
429 result = gnutls_x509_crt_get_expiration_time (xcert); 429 result = MHD_gnutls_x509_crt_get_expiration_time (xcert);
430 430
431 gnutls_x509_crt_deinit (xcert); 431 MHD_gnutls_x509_crt_deinit (xcert);
432 432
433 return result; 433 return result;
434} 434}
@@ -440,34 +440,34 @@ _gnutls_x509_get_raw_crt_expiration_time (const gnutls_datum_t * cert)
440 * 440 *
441 * This function will try to verify the peer's certificate and return 441 * This function will try to verify the peer's certificate and return
442 * its status (trusted, invalid etc.). The value of @status should 442 * its status (trusted, invalid etc.). The value of @status should
443 * be one or more of the gnutls_certificate_status_t enumerated 443 * be one or more of the MHD_gnutls_certificate_status_t enumerated
444 * elements bitwise or'd. To avoid denial of service attacks some 444 * elements bitwise or'd. To avoid denial of service attacks some
445 * default upper limits regarding the certificate key size and chain 445 * default upper limits regarding the certificate key size and chain
446 * size are set. To override them use 446 * size are set. To override them use
447 * MHD_gnutls_certificate_set_verify_limits(). 447 * MHD__gnutls_certificate_set_verify_limits().
448 * 448 *
449 * Note that you must also check the peer's name in order to check if 449 * Note that you must also check the peer's name in order to check if
450 * the verified certificate belongs to the actual peer. 450 * the verified certificate belongs to the actual peer.
451 * 451 *
452 * This is the same as gnutls_x509_crt_list_verify() and uses the 452 * This is the same as MHD_gnutls_x509_crt_list_verify() and uses the
453 * loaded CAs in the credentials as trusted CAs. 453 * loaded CAs in the credentials as trusted CAs.
454 * 454 *
455 * Note that some commonly used X.509 Certificate Authorities are 455 * Note that some commonly used X.509 Certificate Authorities are
456 * still using Version 1 certificates. If you want to accept them, 456 * still using Version 1 certificates. If you want to accept them,
457 * you need to call MHD_gnutls_certificate_set_verify_flags() with, e.g., 457 * you need to call MHD__gnutls_certificate_set_verify_flags() with, e.g.,
458 * %GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT parameter. 458 * %GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT parameter.
459 * 459 *
460 * Returns: a negative error code on error and zero on success. 460 * Returns: a negative error code on error and zero on success.
461 **/ 461 **/
462int 462int
463MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session, 463MHD_gtls_certificate_verify_peers2 (MHD_gtls_session_t session,
464 unsigned int *status) 464 unsigned int *status)
465{ 465{
466 cert_auth_info_t info; 466 cert_auth_info_t info;
467 467
468 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 468 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
469 469
470 info = mhd_gtls_get_auth_info (session); 470 info = MHD_gtls_get_auth_info (session);
471 if (info == NULL) 471 if (info == NULL)
472 { 472 {
473 return GNUTLS_E_NO_CERTIFICATE_FOUND; 473 return GNUTLS_E_NO_CERTIFICATE_FOUND;
@@ -476,10 +476,10 @@ MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session,
476 if (info->raw_certificate_list == NULL || info->ncerts == 0) 476 if (info->raw_certificate_list == NULL || info->ncerts == 0)
477 return GNUTLS_E_NO_CERTIFICATE_FOUND; 477 return GNUTLS_E_NO_CERTIFICATE_FOUND;
478 478
479 switch (gnutls_certificate_type_get (session)) 479 switch (MHD_gnutls_certificate_type_get (session))
480 { 480 {
481 case MHD_GNUTLS_CRT_X509: 481 case MHD_GNUTLS_CRT_X509:
482 return _gnutls_x509_cert_verify_peers (session, status); 482 return MHD__gnutls_x509_cert_verify_peers (session, status);
483 default: 483 default:
484 return GNUTLS_E_INVALID_REQUEST; 484 return GNUTLS_E_INVALID_REQUEST;
485 } 485 }
@@ -495,15 +495,15 @@ MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session,
495 * belongs to the actual peer. 495 * belongs to the actual peer.
496 * 496 *
497 * The return value should be one or more of the 497 * The return value should be one or more of the
498 * gnutls_certificate_status_t enumerated elements bitwise or'd, or a 498 * MHD_gnutls_certificate_status_t enumerated elements bitwise or'd, or a
499 * negative value on error. 499 * negative value on error.
500 * 500 *
501 * This is the same as gnutls_x509_crt_list_verify(). 501 * This is the same as MHD_gnutls_x509_crt_list_verify().
502 * 502 *
503 * Deprecated: Use MHD_gtls_certificate_verify_peers2() instead. 503 * Deprecated: Use MHD_gtls_certificate_verify_peers2() instead.
504 **/ 504 **/
505int 505int
506MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session) 506MHD_gtls_certificate_verify_peers (MHD_gtls_session_t session)
507{ 507{
508 unsigned int status; 508 unsigned int status;
509 int ret; 509 int ret;
@@ -512,7 +512,7 @@ MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session)
512 512
513 if (ret < 0) 513 if (ret < 0)
514 { 514 {
515 gnutls_assert (); 515 MHD_gnutls_assert ();
516 return ret; 516 return ret;
517 } 517 }
518 518
@@ -528,13 +528,13 @@ MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session)
528 * Returns: (time_t)-1 on error. 528 * Returns: (time_t)-1 on error.
529 **/ 529 **/
530time_t 530time_t
531MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session) 531MHD_gtls_certificate_expiration_time_peers (MHD_gtls_session_t session)
532{ 532{
533 cert_auth_info_t info; 533 cert_auth_info_t info;
534 534
535 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 535 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
536 536
537 info = mhd_gtls_get_auth_info (session); 537 info = MHD_gtls_get_auth_info (session);
538 if (info == NULL) 538 if (info == NULL)
539 { 539 {
540 return (time_t) - 1; 540 return (time_t) - 1;
@@ -542,15 +542,15 @@ MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session)
542 542
543 if (info->raw_certificate_list == NULL || info->ncerts == 0) 543 if (info->raw_certificate_list == NULL || info->ncerts == 0)
544 { 544 {
545 gnutls_assert (); 545 MHD_gnutls_assert ();
546 return (time_t) - 1; 546 return (time_t) - 1;
547 } 547 }
548 548
549 switch (gnutls_certificate_type_get (session)) 549 switch (MHD_gnutls_certificate_type_get (session))
550 { 550 {
551 case MHD_GNUTLS_CRT_X509: 551 case MHD_GNUTLS_CRT_X509:
552 return 552 return
553 _gnutls_x509_get_raw_crt_expiration_time (&info->raw_certificate_list 553 MHD__gnutls_x509_get_raw_crt_expiration_time (&info->raw_certificate_list
554 [0]); 554 [0]);
555 default: 555 default:
556 return (time_t) - 1; 556 return (time_t) - 1;
@@ -567,13 +567,13 @@ MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session)
567 * Returns: (time_t)-1 on error. 567 * Returns: (time_t)-1 on error.
568 **/ 568 **/
569time_t 569time_t
570MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session) 570MHD_gtls_certificate_activation_time_peers (MHD_gtls_session_t session)
571{ 571{
572 cert_auth_info_t info; 572 cert_auth_info_t info;
573 573
574 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 574 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
575 575
576 info = mhd_gtls_get_auth_info (session); 576 info = MHD_gtls_get_auth_info (session);
577 if (info == NULL) 577 if (info == NULL)
578 { 578 {
579 return (time_t) - 1; 579 return (time_t) - 1;
@@ -581,15 +581,15 @@ MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session)
581 581
582 if (info->raw_certificate_list == NULL || info->ncerts == 0) 582 if (info->raw_certificate_list == NULL || info->ncerts == 0)
583 { 583 {
584 gnutls_assert (); 584 MHD_gnutls_assert ();
585 return (time_t) - 1; 585 return (time_t) - 1;
586 } 586 }
587 587
588 switch (gnutls_certificate_type_get (session)) 588 switch (MHD_gnutls_certificate_type_get (session))
589 { 589 {
590 case MHD_GNUTLS_CRT_X509: 590 case MHD_GNUTLS_CRT_X509:
591 return 591 return
592 _gnutls_x509_get_raw_crt_activation_time (&info->raw_certificate_list 592 MHD__gnutls_x509_get_raw_crt_activation_time (&info->raw_certificate_list
593 [0]); 593 [0]);
594 default: 594 default:
595 return (time_t) - 1; 595 return (time_t) - 1;
@@ -597,33 +597,33 @@ MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session)
597} 597}
598 598
599int 599int
600mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert, 600MHD_gtls_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
601 enum MHD_GNUTLS_CertificateType type, 601 enum MHD_GNUTLS_CertificateType type,
602 const gnutls_datum_t * raw_cert, 602 const MHD_gnutls_datum_t * raw_cert,
603 int flags /* OR of ConvFlags */ ) 603 int flags /* OR of ConvFlags */ )
604{ 604{
605 switch (type) 605 switch (type)
606 { 606 {
607 case MHD_GNUTLS_CRT_X509: 607 case MHD_GNUTLS_CRT_X509:
608 return mhd_gtls_x509_raw_cert_to_gcert (gcert, raw_cert, flags); 608 return MHD_gtls_x509_raw_cert_to_gcert (gcert, raw_cert, flags);
609 default: 609 default:
610 gnutls_assert (); 610 MHD_gnutls_assert ();
611 return GNUTLS_E_INTERNAL_ERROR; 611 return GNUTLS_E_INTERNAL_ERROR;
612 } 612 }
613} 613}
614 614
615int 615int
616mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key, 616MHD_gtls_raw_privkey_to_gkey (MHD_gnutls_privkey * key,
617 enum MHD_GNUTLS_CertificateType type, 617 enum MHD_GNUTLS_CertificateType type,
618 const gnutls_datum_t * raw_key, 618 const MHD_gnutls_datum_t * raw_key,
619 int key_enc /* DER or PEM */ ) 619 int key_enc /* DER or PEM */ )
620{ 620{
621 switch (type) 621 switch (type)
622 { 622 {
623 case MHD_GNUTLS_CRT_X509: 623 case MHD_GNUTLS_CRT_X509:
624 return _gnutls_x509_raw_privkey_to_gkey (key, raw_key, key_enc); 624 return MHD__gnutls_x509_raw_privkey_to_gkey (key, raw_key, key_enc);
625 default: 625 default:
626 gnutls_assert (); 626 MHD_gnutls_assert ();
627 return GNUTLS_E_INTERNAL_ERROR; 627 return GNUTLS_E_INTERNAL_ERROR;
628 } 628 }
629} 629}
@@ -639,30 +639,30 @@ mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key,
639 * The critical extensions will be catched by the verification functions. 639 * The critical extensions will be catched by the verification functions.
640 */ 640 */
641int 641int
642mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert, 642MHD_gtls_x509_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
643 const gnutls_datum_t * derCert, 643 const MHD_gnutls_datum_t * derCert,
644 int flags /* OR of ConvFlags */ ) 644 int flags /* OR of ConvFlags */ )
645{ 645{
646 int ret; 646 int ret;
647 gnutls_x509_crt_t cert; 647 MHD_gnutls_x509_crt_t cert;
648 648
649 ret = gnutls_x509_crt_init (&cert); 649 ret = MHD_gnutls_x509_crt_init (&cert);
650 if (ret < 0) 650 if (ret < 0)
651 { 651 {
652 gnutls_assert (); 652 MHD_gnutls_assert ();
653 return ret; 653 return ret;
654 } 654 }
655 655
656 ret = gnutls_x509_crt_import (cert, derCert, GNUTLS_X509_FMT_DER); 656 ret = MHD_gnutls_x509_crt_import (cert, derCert, GNUTLS_X509_FMT_DER);
657 if (ret < 0) 657 if (ret < 0)
658 { 658 {
659 gnutls_assert (); 659 MHD_gnutls_assert ();
660 gnutls_x509_crt_deinit (cert); 660 MHD_gnutls_x509_crt_deinit (cert);
661 return ret; 661 return ret;
662 } 662 }
663 663
664 ret = mhd_gtls_x509_crt_to_gcert (gcert, cert, flags); 664 ret = MHD_gtls_x509_crt_to_gcert (gcert, cert, flags);
665 gnutls_x509_crt_deinit (cert); 665 MHD_gnutls_x509_crt_deinit (cert);
666 666
667 return ret; 667 return ret;
668} 668}
@@ -670,12 +670,12 @@ mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
670/* Like above but it accepts a parsed certificate instead. 670/* Like above but it accepts a parsed certificate instead.
671 */ 671 */
672int 672int
673mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert, 673MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert,
674 gnutls_x509_crt_t cert, unsigned int flags) 674 MHD_gnutls_x509_crt_t cert, unsigned int flags)
675{ 675{
676 int ret = 0; 676 int ret = 0;
677 677
678 memset (gcert, 0, sizeof (gnutls_cert)); 678 memset (gcert, 0, sizeof (MHD_gnutls_cert));
679 gcert->cert_type = MHD_GNUTLS_CRT_X509; 679 gcert->cert_type = MHD_GNUTLS_CRT_X509;
680 680
681 if (!(flags & CERT_NO_COPY)) 681 if (!(flags & CERT_NO_COPY))
@@ -687,38 +687,38 @@ mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
687 /* initially allocate a bogus size, just in case the certificate 687 /* initially allocate a bogus size, just in case the certificate
688 * fits in it. That way we minimize the DER encodings performed. 688 * fits in it. That way we minimize the DER encodings performed.
689 */ 689 */
690 der = gnutls_malloc (SMALL_DER); 690 der = MHD_gnutls_malloc (SMALL_DER);
691 if (der == NULL) 691 if (der == NULL)
692 { 692 {
693 gnutls_assert (); 693 MHD_gnutls_assert ();
694 return GNUTLS_E_MEMORY_ERROR; 694 return GNUTLS_E_MEMORY_ERROR;
695 } 695 }
696 696
697 ret = 697 ret =
698 gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der, &der_size); 698 MHD_gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der, &der_size);
699 if (ret < 0 && ret != GNUTLS_E_SHORT_MEMORY_BUFFER) 699 if (ret < 0 && ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
700 { 700 {
701 gnutls_assert (); 701 MHD_gnutls_assert ();
702 gnutls_free (der); 702 MHD_gnutls_free (der);
703 return ret; 703 return ret;
704 } 704 }
705 705
706 if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER) 706 if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER)
707 { 707 {
708 der = gnutls_realloc (der, der_size); 708 der = MHD_gnutls_realloc (der, der_size);
709 if (der == NULL) 709 if (der == NULL)
710 { 710 {
711 gnutls_assert (); 711 MHD_gnutls_assert ();
712 return GNUTLS_E_MEMORY_ERROR; 712 return GNUTLS_E_MEMORY_ERROR;
713 } 713 }
714 714
715 ret = 715 ret =
716 gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der, 716 MHD_gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der,
717 &der_size); 717 &der_size);
718 if (ret < 0) 718 if (ret < 0)
719 { 719 {
720 gnutls_assert (); 720 MHD_gnutls_assert ();
721 gnutls_free (der); 721 MHD_gnutls_free (der);
722 return ret; 722 return ret;
723 } 723 }
724 } 724 }
@@ -733,19 +733,19 @@ mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
733 733
734 if (flags & CERT_ONLY_EXTENSIONS || flags == 0) 734 if (flags & CERT_ONLY_EXTENSIONS || flags == 0)
735 { 735 {
736 gnutls_x509_crt_get_key_usage (cert, &gcert->key_usage, NULL); 736 MHD_gnutls_x509_crt_get_key_usage (cert, &gcert->key_usage, NULL);
737 gcert->version = gnutls_x509_crt_get_version (cert); 737 gcert->version = MHD_gnutls_x509_crt_get_version (cert);
738 } 738 }
739 gcert->subject_pk_algorithm = gnutls_x509_crt_get_pk_algorithm (cert, NULL); 739 gcert->subject_pk_algorithm = MHD_gnutls_x509_crt_get_pk_algorithm (cert, NULL);
740 740
741 if (flags & CERT_ONLY_PUBKEY || flags == 0) 741 if (flags & CERT_ONLY_PUBKEY || flags == 0)
742 { 742 {
743 gcert->params_size = MAX_PUBLIC_PARAMS_SIZE; 743 gcert->params_size = MAX_PUBLIC_PARAMS_SIZE;
744 ret = 744 ret =
745 _gnutls_x509_crt_get_mpis (cert, gcert->params, &gcert->params_size); 745 MHD__gnutls_x509_crt_get_mpis (cert, gcert->params, &gcert->params_size);
746 if (ret < 0) 746 if (ret < 0)
747 { 747 {
748 gnutls_assert (); 748 MHD_gnutls_assert ();
749 return ret; 749 return ret;
750 } 750 }
751 } 751 }
@@ -755,7 +755,7 @@ mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
755} 755}
756 756
757void 757void
758mhd_gtls_gcert_deinit (gnutls_cert * cert) 758MHD_gtls_gcert_deinit (MHD_gnutls_cert * cert)
759{ 759{
760 int i; 760 int i;
761 761
@@ -764,10 +764,10 @@ mhd_gtls_gcert_deinit (gnutls_cert * cert)
764 764
765 for (i = 0; i < cert->params_size; i++) 765 for (i = 0; i < cert->params_size; i++)
766 { 766 {
767 mhd_gtls_mpi_release (&cert->params[i]); 767 MHD_gtls_mpi_release (&cert->params[i]);
768 } 768 }
769 769
770 _gnutls_free_datum (&cert->raw); 770 MHD__gnutls_free_datum (&cert->raw);
771} 771}
772 772
773/** 773/**
@@ -778,20 +778,20 @@ mhd_gtls_gcert_deinit (gnutls_cert * cert)
778 * 778 *
779 * Set the callback function. The function must have this prototype: 779 * Set the callback function. The function must have this prototype:
780 * 780 *
781 * typedef int (*gnutls_sign_func) (mhd_gtls_session_t session, 781 * typedef int (*MHD_gnutls_sign_func) (MHD_gtls_session_t session,
782 * void *userdata, 782 * void *userdata,
783 * enum MHD_GNUTLS_CertificateType cert_type, 783 * enum MHD_GNUTLS_CertificateType cert_type,
784 * const gnutls_datum_t * cert, 784 * const MHD_gnutls_datum_t * cert,
785 * const gnutls_datum_t * hash, 785 * const MHD_gnutls_datum_t * hash,
786 * gnutls_datum_t * signature); 786 * MHD_gnutls_datum_t * signature);
787 * 787 *
788 * The @userdata parameter is passed to the @sign_func verbatim, and 788 * The @userdata parameter is passed to the @sign_func verbatim, and
789 * can be used to store application-specific data needed in the 789 * can be used to store application-specific data needed in the
790 * callback function. See also MHD_gtls_sign_callback_get(). 790 * callback function. See also MHD_gtls_sign_callback_get().
791 **/ 791 **/
792void 792void
793MHD_gtls_sign_callback_set (mhd_gtls_session_t session, 793MHD_gtls_sign_callback_set (MHD_gtls_session_t session,
794 gnutls_sign_func sign_func, void *userdata) 794 MHD_gnutls_sign_func sign_func, void *userdata)
795{ 795{
796 session->internals.sign_func = sign_func; 796 session->internals.sign_func = sign_func;
797 session->internals.sign_func_userdata = userdata; 797 session->internals.sign_func_userdata = userdata;
@@ -807,8 +807,8 @@ MHD_gtls_sign_callback_set (mhd_gtls_session_t session,
807 * Returns: The function pointer set by MHD_gtls_sign_callback_set(), or 807 * Returns: The function pointer set by MHD_gtls_sign_callback_set(), or
808 * if not set, %NULL. 808 * if not set, %NULL.
809 **/ 809 **/
810gnutls_sign_func 810MHD_gnutls_sign_func
811MHD_gtls_sign_callback_get (mhd_gtls_session_t session, void **userdata) 811MHD_gtls_sign_callback_get (MHD_gtls_session_t session, void **userdata)
812{ 812{
813 if (userdata) 813 if (userdata)
814 *userdata = session->internals.sign_func_userdata; 814 *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 129e7e16..b759fca5 100644
--- a/src/daemon/https/tls/gnutls_cert.h
+++ b/src/daemon/https/tls/gnutls_cert.h
@@ -48,7 +48,7 @@
48#define KEY_ENCIPHER_ONLY 1 48#define KEY_ENCIPHER_ONLY 1
49#define KEY_DECIPHER_ONLY 32768 49#define KEY_DECIPHER_ONLY 32768
50 50
51typedef struct gnutls_cert 51typedef struct MHD_gnutls_cert
52{ 52{
53 mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; /* the size of params depends on the public 53 mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; /* the size of params depends on the public
54 * key algorithm 54 * key algorithm
@@ -71,11 +71,11 @@ typedef struct gnutls_cert
71 */ 71 */
72 enum MHD_GNUTLS_CertificateType cert_type; 72 enum MHD_GNUTLS_CertificateType cert_type;
73 73
74 gnutls_datum_t raw; 74 MHD_gnutls_datum_t raw;
75 75
76} gnutls_cert; 76} MHD_gnutls_cert;
77 77
78typedef struct gnutls_privkey_int 78typedef struct MHD_gnutls_privkey_int
79{ 79{
80 mpi_t params[MAX_PRIV_PARAMS_SIZE]; /* the size of params depends on the public 80 mpi_t params[MAX_PRIV_PARAMS_SIZE]; /* the size of params depends on the public
81 * key algorithm 81 * key algorithm
@@ -96,9 +96,9 @@ typedef struct gnutls_privkey_int
96 int params_size; /* holds the number of params */ 96 int params_size; /* holds the number of params */
97 97
98 enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm; 98 enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm;
99} gnutls_privkey; 99} MHD_gnutls_privkey;
100 100
101struct MHD_gtls_session_int; /* because mhd_gtls_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,26 +107,26 @@ typedef enum ConvFlags
107 CERT_ONLY_EXTENSIONS = 16 107 CERT_ONLY_EXTENSIONS = 16
108} ConvFlags; 108} ConvFlags;
109 109
110int mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert, 110int MHD_gtls_x509_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
111 const gnutls_datum_t * derCert, 111 const MHD_gnutls_datum_t * derCert,
112 int flags); 112 int flags);
113int mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert, gnutls_x509_crt_t cert, 113int MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert, MHD_gnutls_x509_crt_t cert,
114 unsigned int flags); 114 unsigned int flags);
115 115
116void mhd_gtls_gkey_deinit (gnutls_privkey * key); 116void MHD_gtls_gkey_deinit (MHD_gnutls_privkey * key);
117void mhd_gtls_gcert_deinit (gnutls_cert * cert); 117void MHD_gtls_gcert_deinit (MHD_gnutls_cert * cert);
118 118
119int mhd_gtls_selected_cert_supported_kx (struct MHD_gtls_session_int *session, 119int MHD_gtls_selected_cert_supported_kx (struct MHD_gtls_session_int *session,
120 enum MHD_GNUTLS_KeyExchangeAlgorithm 120 enum MHD_GNUTLS_KeyExchangeAlgorithm
121 **alg, int *alg_size); 121 **alg, int *alg_size);
122 122
123int mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert, 123int MHD_gtls_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
124 enum MHD_GNUTLS_CertificateType type, 124 enum MHD_GNUTLS_CertificateType type,
125 const gnutls_datum_t * raw_cert, 125 const MHD_gnutls_datum_t * raw_cert,
126 int flags /* OR of ConvFlags */ ); 126 int flags /* OR of ConvFlags */ );
127int mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key, 127int MHD_gtls_raw_privkey_to_gkey (MHD_gnutls_privkey * key,
128 enum MHD_GNUTLS_CertificateType type, 128 enum MHD_GNUTLS_CertificateType type,
129 const gnutls_datum_t * raw_key, 129 const MHD_gnutls_datum_t * raw_key,
130 int key_enc /* DER or PEM */ ); 130 int key_enc /* DER or PEM */ );
131 131
132#endif 132#endif
diff --git a/src/daemon/https/tls/gnutls_cipher.c b/src/daemon/https/tls/gnutls_cipher.c
index 69b62d16..94e87eb3 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 (mhd_gtls_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 (mhd_gtls_session_t session)
52} 52}
53 53
54inline static int 54inline static int
55is_read_comp_null (mhd_gtls_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,13 +68,13 @@ is_read_comp_null (mhd_gtls_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
71mhd_gtls_encrypt (mhd_gtls_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)
75{ 75{
76 gnutls_datum_t plain; 76 MHD_gnutls_datum_t plain;
77 gnutls_datum_t comp; 77 MHD_gnutls_datum_t comp;
78 int ret; 78 int ret;
79 int free_comp = 1; 79 int free_comp = 1;
80 80
@@ -91,31 +91,31 @@ mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
91 /* Here comp is allocated and must be 91 /* Here comp is allocated and must be
92 * freed. 92 * freed.
93 */ 93 */
94 ret = _gnutls_m_plaintext2compressed (session, &comp, &plain); 94 ret = MHD__gnutls_m_plaintext2compressed (session, &comp, &plain);
95 if (ret < 0) 95 if (ret < 0)
96 { 96 {
97 gnutls_assert (); 97 MHD_gnutls_assert ();
98 return ret; 98 return ret;
99 } 99 }
100 } 100 }
101 101
102 ret = mhd_gtls_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
106 if (free_comp) 106 if (free_comp)
107 _gnutls_free_datum (&comp); 107 MHD__gnutls_free_datum (&comp);
108 108
109 if (ret < 0) 109 if (ret < 0)
110 { 110 {
111 gnutls_assert (); 111 MHD_gnutls_assert ();
112 return ret; 112 return ret;
113 } 113 }
114 114
115 115
116 /* copy the headers */ 116 /* copy the headers */
117 memcpy (ciphertext, headers, headers_size); 117 memcpy (ciphertext, headers, headers_size);
118 mhd_gtls_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,12 +124,12 @@ mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
124 * Returns the decrypted data length. 124 * Returns the decrypted data length.
125 */ 125 */
126int 126int
127mhd_gtls_decrypt (mhd_gtls_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{
131 gnutls_datum_t gtxt; 131 MHD_gnutls_datum_t gtxt;
132 gnutls_datum_t gcipher; 132 MHD_gnutls_datum_t gcipher;
133 int ret; 133 int ret;
134 134
135 if (ciphertext_size == 0) 135 if (ciphertext_size == 0)
@@ -139,7 +139,7 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
139 gcipher.data = ciphertext; 139 gcipher.data = ciphertext;
140 140
141 ret = 141 ret =
142 mhd_gtls_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 {
@@ -153,14 +153,14 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
153 } 153 }
154 else 154 else
155 { 155 {
156 gnutls_datum_t gcomp; 156 MHD_gnutls_datum_t gcomp;
157 157
158 /* compression has this malloc overhead. 158 /* compression has this malloc overhead.
159 */ 159 */
160 160
161 gcomp.data = data; 161 gcomp.data = data;
162 gcomp.size = ret; 162 gcomp.size = ret;
163 ret = _gnutls_m_compressed2plaintext (session, &gtxt, &gcomp); 163 ret = MHD__gnutls_m_compressed2plaintext (session, &gtxt, &gcomp);
164 if (ret < 0) 164 if (ret < 0)
165 { 165 {
166 return ret; 166 return ret;
@@ -168,8 +168,8 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
168 168
169 if (gtxt.size > MAX_RECORD_RECV_SIZE) 169 if (gtxt.size > MAX_RECORD_RECV_SIZE)
170 { 170 {
171 gnutls_assert (); 171 MHD_gnutls_assert ();
172 _gnutls_free_datum (&gtxt); 172 MHD__gnutls_free_datum (&gtxt);
173 /* This shouldn't have happen and 173 /* This shouldn't have happen and
174 * is a TLS fatal error. 174 * is a TLS fatal error.
175 */ 175 */
@@ -179,15 +179,15 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
179 /* This check is not really needed */ 179 /* This check is not really needed */
180 if (max_data_size < MAX_RECORD_RECV_SIZE) 180 if (max_data_size < MAX_RECORD_RECV_SIZE)
181 { 181 {
182 gnutls_assert (); 182 MHD_gnutls_assert ();
183 _gnutls_free_datum (&gtxt); 183 MHD__gnutls_free_datum (&gtxt);
184 return GNUTLS_E_INTERNAL_ERROR; 184 return GNUTLS_E_INTERNAL_ERROR;
185 } 185 }
186 186
187 memcpy (data, gtxt.data, gtxt.size); 187 memcpy (data, gtxt.data, gtxt.size);
188 ret = gtxt.size; 188 ret = gtxt.size;
189 189
190 _gnutls_free_datum (&gtxt); 190 MHD__gnutls_free_datum (&gtxt);
191 } 191 }
192 192
193 return ret; 193 return ret;
@@ -204,11 +204,11 @@ mac_init (enum MHD_GNUTLS_HashAlgorithm mac, opaque * secret, int secret_size,
204 204
205 if (ver == MHD_GNUTLS_PROTOCOL_SSL3) 205 if (ver == MHD_GNUTLS_PROTOCOL_SSL3)
206 { /* SSL 3.0 */ 206 { /* SSL 3.0 */
207 td = mhd_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 = mhd_gtls_hmac_init (mac, secret, secret_size); 211 td = MHD_gtls_MHD_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_PROTOCOL_SSL3) 220 if (ver == MHD_GNUTLS_PROTOCOL_SSL3)
221 { /* SSL 3.0 */ 221 { /* SSL 3.0 */
222 mhd_gnutls_mac_deinit_ssl3 (td, res); 222 MHD_gnutls_mac_deinit_ssl3 (td, res);
223 } 223 }
224 else 224 else
225 { 225 {
226 mhd_gnutls_hmac_deinit (td, res); 226 MHD_gnutls_MHD_hmac_deinit (td, res);
227 } 227 }
228} 228}
229 229
230inline static int 230inline static int
231calc_enc_length (mhd_gtls_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{
@@ -244,9 +244,9 @@ calc_enc_length (mhd_gtls_session_t session, int data_size,
244 244
245 break; 245 break;
246 case CIPHER_BLOCK: 246 case CIPHER_BLOCK:
247 if (gc_nonce (&rnd, 1) != GC_OK) 247 if (MHD_gc_nonce (&rnd, 1) != GC_OK)
248 { 248 {
249 gnutls_assert (); 249 MHD_gnutls_assert ();
250 return GNUTLS_E_RANDOM_FAILED; 250 return GNUTLS_E_RANDOM_FAILED;
251 } 251 }
252 252
@@ -276,7 +276,7 @@ calc_enc_length (mhd_gtls_session_t session, int data_size,
276 276
277 break; 277 break;
278 default: 278 default:
279 gnutls_assert (); 279 MHD_gnutls_assert ();
280 return GNUTLS_E_INTERNAL_ERROR; 280 return GNUTLS_E_INTERNAL_ERROR;
281 } 281 }
282 282
@@ -289,9 +289,9 @@ calc_enc_length (mhd_gtls_session_t session, int data_size,
289 * return the actual encrypted data length. 289 * return the actual encrypted data length.
290 */ 290 */
291int 291int
292mhd_gtls_compressed2ciphertext (mhd_gtls_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 MHD_gnutls_datum_t compressed,
295 content_type_t _type, int random_pad) 295 content_type_t _type, int random_pad)
296{ 296{
297 uint8_t MAC[MAX_HASH_SIZE]; 297 uint8_t MAC[MAX_HASH_SIZE];
@@ -302,21 +302,21 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_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 mhd_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 enum MHD_GNUTLS_Protocol ver; 307 enum MHD_GNUTLS_Protocol ver;
308 int blocksize = 308 int blocksize =
309 mhd_gtls_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 mhd_gtls_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 = MHD_gnutls_protocol_get_version (session); 317 ver = MHD__gnutls_protocol_get_version (session);
318 minor = mhd_gtls_version_get_minor (ver); 318 minor = MHD_gtls_version_get_minor (ver);
319 major = mhd_gtls_version_get_major (ver); 319 major = MHD_gtls_version_get_major (ver);
320 320
321 321
322 /* Initialize MAC */ 322 /* Initialize MAC */
@@ -328,26 +328,26 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
328 && session->security_parameters.write_mac_algorithm != 328 && session->security_parameters.write_mac_algorithm !=
329 MHD_GNUTLS_MAC_NULL) 329 MHD_GNUTLS_MAC_NULL)
330 { 330 {
331 gnutls_assert (); 331 MHD_gnutls_assert ();
332 return GNUTLS_E_INTERNAL_ERROR; 332 return GNUTLS_E_INTERNAL_ERROR;
333 } 333 }
334 334
335 c_length = mhd_gtls_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 mhd_gnutls_hash (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 mhd_gnutls_hash (td, &type, 1); 343 MHD_gnutls_hash (td, &type, 1);
344 if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) 344 if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0)
345 { /* TLS 1.0 or higher */ 345 { /* TLS 1.0 or higher */
346 mhd_gnutls_hash (td, &major, 1); 346 MHD_gnutls_hash (td, &major, 1);
347 mhd_gnutls_hash (td, &minor, 1); 347 MHD_gnutls_hash (td, &minor, 1);
348 } 348 }
349 mhd_gnutls_hash (td, &c_length, 2); 349 MHD_gnutls_hash (td, &c_length, 2);
350 mhd_gnutls_hash (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
@@ -359,7 +359,7 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
359 random_pad, block_algo, blocksize); 359 random_pad, block_algo, blocksize);
360 if (length < 0) 360 if (length < 0)
361 { 361 {
362 gnutls_assert (); 362 MHD_gnutls_assert ();
363 return length; 363 return length;
364 } 364 }
365 365
@@ -367,7 +367,7 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
367 */ 367 */
368 if (cipher_size < length) 368 if (cipher_size < length)
369 { 369 {
370 gnutls_assert (); 370 MHD_gnutls_assert ();
371 return GNUTLS_E_MEMORY_ERROR; 371 return GNUTLS_E_MEMORY_ERROR;
372 } 372 }
373 373
@@ -377,9 +377,9 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
377 { 377 {
378 /* copy the random IV. 378 /* copy the random IV.
379 */ 379 */
380 if (gc_nonce (data_ptr, blocksize) != GC_OK) 380 if (MHD_gc_nonce (data_ptr, blocksize) != GC_OK)
381 { 381 {
382 gnutls_assert (); 382 MHD_gnutls_assert ();
383 return GNUTLS_E_RANDOM_FAILED; 383 return GNUTLS_E_RANDOM_FAILED;
384 } 384 }
385 data_ptr += blocksize; 385 data_ptr += blocksize;
@@ -402,11 +402,11 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
402 /* Actual encryption (inplace). 402 /* Actual encryption (inplace).
403 */ 403 */
404 ret = 404 ret =
405 mhd_gtls_cipher_encrypt (session->connection_state.write_cipher_state, 405 MHD_gtls_cipher_encrypt (session->connection_state.write_cipher_state,
406 cipher_data, length); 406 cipher_data, length);
407 if (ret < 0) 407 if (ret < 0)
408 { 408 {
409 gnutls_assert (); 409 MHD_gnutls_assert ();
410 return ret; 410 return ret;
411 } 411 }
412 412
@@ -417,10 +417,10 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
417 * Returns the actual compressed packet size. 417 * Returns the actual compressed packet size.
418 */ 418 */
419int 419int
420mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session, 420MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session,
421 opaque * compress_data, 421 opaque * compress_data,
422 int compress_size, 422 int compress_size,
423 gnutls_datum_t ciphertext, uint8_t type) 423 MHD_gnutls_datum_t ciphertext, uint8_t type)
424{ 424{
425 uint8_t MAC[MAX_HASH_SIZE]; 425 uint8_t MAC[MAX_HASH_SIZE];
426 uint16_t c_length; 426 uint16_t c_length;
@@ -432,15 +432,15 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
432 uint8_t major, minor; 432 uint8_t major, minor;
433 enum MHD_GNUTLS_Protocol ver; 433 enum MHD_GNUTLS_Protocol ver;
434 int hash_size = 434 int hash_size =
435 mhd_gnutls_hash_get_algo_len (session->security_parameters. 435 MHD_gnutls_hash_get_algo_len (session->security_parameters.
436 read_mac_algorithm); 436 read_mac_algorithm);
437 437
438 ver = MHD_gnutls_protocol_get_version (session); 438 ver = MHD__gnutls_protocol_get_version (session);
439 minor = mhd_gtls_version_get_minor (ver); 439 minor = MHD_gtls_version_get_minor (ver);
440 major = mhd_gtls_version_get_major (ver); 440 major = MHD_gtls_version_get_major (ver);
441 441
442 blocksize = 442 blocksize =
443 mhd_gtls_cipher_get_block_size (session->security_parameters. 443 MHD_gtls_cipher_get_block_size (session->security_parameters.
444 read_bulk_cipher_algorithm); 444 read_bulk_cipher_algorithm);
445 445
446 /* initialize MAC 446 /* initialize MAC
@@ -453,23 +453,23 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
453 && session->security_parameters.read_mac_algorithm != 453 && session->security_parameters.read_mac_algorithm !=
454 MHD_GNUTLS_MAC_NULL) 454 MHD_GNUTLS_MAC_NULL)
455 { 455 {
456 gnutls_assert (); 456 MHD_gnutls_assert ();
457 return GNUTLS_E_INTERNAL_ERROR; 457 return GNUTLS_E_INTERNAL_ERROR;
458 } 458 }
459 459
460 460
461 /* actual decryption (inplace) 461 /* actual decryption (inplace)
462 */ 462 */
463 switch (mhd_gtls_cipher_is_block 463 switch (MHD_gtls_cipher_is_block
464 (session->security_parameters.read_bulk_cipher_algorithm)) 464 (session->security_parameters.read_bulk_cipher_algorithm))
465 { 465 {
466 case CIPHER_STREAM: 466 case CIPHER_STREAM:
467 if ((ret = 467 if ((ret =
468 mhd_gtls_cipher_decrypt (session->connection_state. 468 MHD_gtls_cipher_decrypt (session->connection_state.
469 read_cipher_state, ciphertext.data, 469 read_cipher_state, ciphertext.data,
470 ciphertext.size)) < 0) 470 ciphertext.size)) < 0)
471 { 471 {
472 gnutls_assert (); 472 MHD_gnutls_assert ();
473 return ret; 473 return ret;
474 } 474 }
475 475
@@ -479,16 +479,16 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
479 case CIPHER_BLOCK: 479 case CIPHER_BLOCK:
480 if ((ciphertext.size < blocksize) || (ciphertext.size % blocksize != 0)) 480 if ((ciphertext.size < blocksize) || (ciphertext.size % blocksize != 0))
481 { 481 {
482 gnutls_assert (); 482 MHD_gnutls_assert ();
483 return GNUTLS_E_DECRYPTION_FAILED; 483 return GNUTLS_E_DECRYPTION_FAILED;
484 } 484 }
485 485
486 if ((ret = 486 if ((ret =
487 mhd_gtls_cipher_decrypt (session->connection_state. 487 MHD_gtls_cipher_decrypt (session->connection_state.
488 read_cipher_state, ciphertext.data, 488 read_cipher_state, ciphertext.data,
489 ciphertext.size)) < 0) 489 ciphertext.size)) < 0)
490 { 490 {
491 gnutls_assert (); 491 MHD_gnutls_assert ();
492 return ret; 492 return ret;
493 } 493 }
494 494
@@ -501,7 +501,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
501 501
502 if (ciphertext.size == 0) 502 if (ciphertext.size == 0)
503 { 503 {
504 gnutls_assert (); 504 MHD_gnutls_assert ();
505 return GNUTLS_E_DECRYPTION_FAILED; 505 return GNUTLS_E_DECRYPTION_FAILED;
506 } 506 }
507 } 507 }
@@ -512,7 +512,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
512 512
513 if (pad > ciphertext.size - hash_size) 513 if (pad > ciphertext.size - hash_size)
514 { 514 {
515 gnutls_assert (); 515 MHD_gnutls_assert ();
516 /* We do not fail here. We check below for the 516 /* We do not fail here. We check below for the
517 * the pad_failed. If zero means success. 517 * the pad_failed. If zero means success.
518 */ 518 */
@@ -530,33 +530,33 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
530 } 530 }
531 break; 531 break;
532 default: 532 default:
533 gnutls_assert (); 533 MHD_gnutls_assert ();
534 return GNUTLS_E_INTERNAL_ERROR; 534 return GNUTLS_E_INTERNAL_ERROR;
535 } 535 }
536 536
537 if (length < 0) 537 if (length < 0)
538 length = 0; 538 length = 0;
539 c_length = mhd_gtls_conv_uint16 ((uint16_t) length); 539 c_length = MHD_gtls_conv_uint16 ((uint16_t) length);
540 540
541 /* Pass the type, version, length and compressed through 541 /* Pass the type, version, length and compressed through
542 * MAC. 542 * MAC.
543 */ 543 */
544 if (td != GNUTLS_MAC_FAILED) 544 if (td != GNUTLS_MAC_FAILED)
545 { 545 {
546 mhd_gnutls_hash (td, 546 MHD_gnutls_hash (td,
547 UINT64DATA (session->connection_state. 547 UINT64DATA (session->connection_state.
548 read_sequence_number), 8); 548 read_sequence_number), 8);
549 549
550 mhd_gnutls_hash (td, &type, 1); 550 MHD_gnutls_hash (td, &type, 1);
551 if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) 551 if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0)
552 { /* TLS 1.x */ 552 { /* TLS 1.x */
553 mhd_gnutls_hash (td, &major, 1); 553 MHD_gnutls_hash (td, &major, 1);
554 mhd_gnutls_hash (td, &minor, 1); 554 MHD_gnutls_hash (td, &minor, 1);
555 } 555 }
556 mhd_gnutls_hash (td, &c_length, 2); 556 MHD_gnutls_hash (td, &c_length, 2);
557 557
558 if (length > 0) 558 if (length > 0)
559 mhd_gnutls_hash (td, ciphertext.data, length); 559 MHD_gnutls_hash (td, ciphertext.data, length);
560 560
561 mac_deinit (td, MAC, ver); 561 mac_deinit (td, MAC, ver);
562 } 562 }
@@ -571,7 +571,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
571 */ 571 */
572 if (memcmp (MAC, &ciphertext.data[length], hash_size) != 0) 572 if (memcmp (MAC, &ciphertext.data[length], hash_size) != 0)
573 { 573 {
574 gnutls_assert (); 574 MHD_gnutls_assert ();
575 return GNUTLS_E_DECRYPTION_FAILED; 575 return GNUTLS_E_DECRYPTION_FAILED;
576 } 576 }
577 577
@@ -579,7 +579,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
579 */ 579 */
580 if (compress_size < length) 580 if (compress_size < length)
581 { 581 {
582 gnutls_assert (); 582 MHD_gnutls_assert ();
583 return GNUTLS_E_DECOMPRESSION_FAILED; 583 return GNUTLS_E_DECOMPRESSION_FAILED;
584 } 584 }
585 memcpy (compress_data, ciphertext.data, length); 585 memcpy (compress_data, ciphertext.data, length);
diff --git a/src/daemon/https/tls/gnutls_cipher.h b/src/daemon/https/tls/gnutls_cipher.h
index 511ee989..ab86d380 100644
--- a/src/daemon/https/tls/gnutls_cipher.h
+++ b/src/daemon/https/tls/gnutls_cipher.h
@@ -22,19 +22,19 @@
22 * 22 *
23 */ 23 */
24 24
25int mhd_gtls_encrypt (mhd_gtls_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 mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext, 31int MHD_gtls_decrypt (MHD_gtls_session_t session, opaque * ciphertext,
32 size_t ciphertext_size, uint8_t * data, 32 size_t ciphertext_size, uint8_t * data,
33 size_t data_size, content_type_t type); 33 size_t data_size, content_type_t type);
34int mhd_gtls_compressed2ciphertext (mhd_gtls_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 MHD_gnutls_datum_t compressed,
37 content_type_t _type, int random_pad); 37 content_type_t _type, int random_pad);
38int mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session, 38int MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session,
39 opaque * compress_data, int compress_size, 39 opaque * compress_data, int compress_size,
40 gnutls_datum_t ciphertext, uint8_t type); 40 MHD_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 836188aa..fef2c1d9 100644
--- a/src/daemon/https/tls/gnutls_cipher_int.c
+++ b/src/daemon/https/tls/gnutls_cipher_int.c
@@ -28,8 +28,8 @@
28#include <gnutls_datum.h> 28#include <gnutls_datum.h>
29 29
30cipher_hd_t 30cipher_hd_t
31mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher, 31MHD_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
32 const gnutls_datum_t * key, const gnutls_datum_t * iv) 32 const MHD_gnutls_datum_t * key, const MHD_gnutls_datum_t * iv)
33{ 33{
34 cipher_hd_t ret = NULL; 34 cipher_hd_t ret = NULL;
35 int err = GC_INVALID_CIPHER; /* doesn't matter */ 35 int err = GC_INVALID_CIPHER; /* doesn't matter */
@@ -37,40 +37,40 @@ mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
37 switch (cipher) 37 switch (cipher)
38 { 38 {
39 case MHD_GNUTLS_CIPHER_AES_128_CBC: 39 case MHD_GNUTLS_CIPHER_AES_128_CBC:
40 err = gc_cipher_open (GC_AES128, GC_CBC, &ret); 40 err = MHD_gc_cipher_open (GC_AES128, GC_CBC, &ret);
41 break; 41 break;
42 42
43 case MHD_GNUTLS_CIPHER_AES_256_CBC: 43 case MHD_GNUTLS_CIPHER_AES_256_CBC:
44 err = gc_cipher_open (GC_AES256, GC_CBC, &ret); 44 err = MHD_gc_cipher_open (GC_AES256, GC_CBC, &ret);
45 break; 45 break;
46 46
47 case MHD_GNUTLS_CIPHER_3DES_CBC: 47 case MHD_GNUTLS_CIPHER_3DES_CBC:
48 err = gc_cipher_open (GC_3DES, GC_CBC, &ret); 48 err = MHD_gc_cipher_open (GC_3DES, GC_CBC, &ret);
49 break; 49 break;
50 50
51 case MHD_GNUTLS_CIPHER_DES_CBC: 51 case MHD_GNUTLS_CIPHER_DES_CBC:
52 err = gc_cipher_open (GC_DES, GC_CBC, &ret); 52 err = MHD_gc_cipher_open (GC_DES, GC_CBC, &ret);
53 break; 53 break;
54 54
55 case MHD_GNUTLS_CIPHER_ARCFOUR_128: 55 case MHD_GNUTLS_CIPHER_ARCFOUR_128:
56 err = gc_cipher_open (GC_ARCFOUR128, GC_STREAM, &ret); 56 err = MHD_gc_cipher_open (GC_ARCFOUR128, GC_STREAM, &ret);
57 break; 57 break;
58 58
59 case MHD_GNUTLS_CIPHER_ARCFOUR_40: 59 case MHD_GNUTLS_CIPHER_ARCFOUR_40:
60 err = gc_cipher_open (GC_ARCFOUR40, GC_STREAM, &ret); 60 err = MHD_gc_cipher_open (GC_ARCFOUR40, GC_STREAM, &ret);
61 break; 61 break;
62 62
63 case MHD_GNUTLS_CIPHER_RC2_40_CBC: 63 case MHD_GNUTLS_CIPHER_RC2_40_CBC:
64 err = gc_cipher_open (GC_ARCTWO40, GC_CBC, &ret); 64 err = MHD_gc_cipher_open (GC_ARCTWO40, GC_CBC, &ret);
65 break; 65 break;
66 66
67#ifdef ENABLE_CAMELLIA 67#ifdef ENABLE_CAMELLIA
68 case MHD_GNUTLS_CIPHER_CAMELLIA_128_CBC: 68 case MHD_GNUTLS_CIPHER_CAMELLIA_128_CBC:
69 err = gc_cipher_open (GC_CAMELLIA128, GC_CBC, &ret); 69 err = MHD_gc_cipher_open (GC_CAMELLIA128, GC_CBC, &ret);
70 break; 70 break;
71 71
72 case MHD_GNUTLS_CIPHER_CAMELLIA_256_CBC: 72 case MHD_GNUTLS_CIPHER_CAMELLIA_256_CBC:
73 err = gc_cipher_open (GC_CAMELLIA256, GC_CBC, &ret); 73 err = MHD_gc_cipher_open (GC_CAMELLIA256, GC_CBC, &ret);
74 break; 74 break;
75#endif 75#endif
76 76
@@ -80,28 +80,28 @@ mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
80 80
81 if (err == 0) 81 if (err == 0)
82 { 82 {
83 gc_cipher_setkey (ret, key->size, key->data); 83 MHD_gc_cipher_setkey (ret, key->size, key->data);
84 if (iv->data != NULL && iv->size > 0) 84 if (iv->data != NULL && iv->size > 0)
85 gc_cipher_setiv (ret, iv->size, iv->data); 85 MHD_gc_cipher_setiv (ret, iv->size, iv->data);
86 } 86 }
87 else if (cipher != MHD_GNUTLS_CIPHER_NULL) 87 else if (cipher != MHD_GNUTLS_CIPHER_NULL)
88 { 88 {
89 gnutls_assert (); 89 MHD_gnutls_assert ();
90 _gnutls_x509_log ("Crypto cipher[%d] error: %d\n", cipher, err); 90 MHD__gnutls_x509_log ("Crypto cipher[%d] error: %d\n", cipher, err);
91 /* FIXME: gc_strerror */ 91 /* FIXME: MHD_gc_strerror */
92 } 92 }
93 93
94 return ret; 94 return ret;
95} 95}
96 96
97int 97int
98mhd_gtls_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 {
102 if (gc_cipher_encrypt_inline (handle, textlen, text) != 0) 102 if (MHD_gc_cipher_encrypt_inline (handle, textlen, text) != 0)
103 { 103 {
104 gnutls_assert (); 104 MHD_gnutls_assert ();
105 return GNUTLS_E_INTERNAL_ERROR; 105 return GNUTLS_E_INTERNAL_ERROR;
106 } 106 }
107 } 107 }
@@ -109,14 +109,14 @@ mhd_gtls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
109} 109}
110 110
111int 111int
112mhd_gtls_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)
116 { 116 {
117 if (gc_cipher_decrypt_inline (handle, ciphertextlen, ciphertext) != 0) 117 if (MHD_gc_cipher_decrypt_inline (handle, ciphertextlen, ciphertext) != 0)
118 { 118 {
119 gnutls_assert (); 119 MHD_gnutls_assert ();
120 return GNUTLS_E_INTERNAL_ERROR; 120 return GNUTLS_E_INTERNAL_ERROR;
121 } 121 }
122 } 122 }
@@ -124,10 +124,10 @@ mhd_gtls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
124} 124}
125 125
126void 126void
127mhd_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 {
131 gc_cipher_close (handle); 131 MHD_gc_cipher_close (handle);
132 } 132 }
133} 133}
diff --git a/src/daemon/https/tls/gnutls_cipher_int.h b/src/daemon/https/tls/gnutls_cipher_int.h
index 6e2c8269..f00f945f 100644
--- a/src/daemon/https/tls/gnutls_cipher_int.h
+++ b/src/daemon/https/tls/gnutls_cipher_int.h
@@ -25,19 +25,19 @@
25#ifndef GNUTLS_CIPHER_INT 25#ifndef GNUTLS_CIPHER_INT
26# define GNUTLS_CIPHER_INT 26# define GNUTLS_CIPHER_INT
27 27
28#define cipher_hd_t gc_cipher_handle 28#define cipher_hd_t MHD_gc_cipher_handle
29#define GNUTLS_CIPHER_FAILED NULL 29#define GNUTLS_CIPHER_FAILED NULL
30 30
31// TODO gc_cipher_handle -> void * x3 31// TODO MHD_gc_cipher_handle -> void * x3
32void *mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher, 32void *MHD_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
33 const gnutls_datum_t * key, 33 const MHD_gnutls_datum_t * key,
34 const gnutls_datum_t * iv); 34 const MHD_gnutls_datum_t * iv);
35 35
36int mhd_gtls_cipher_encrypt (void *handle, void *text, int textlen); 36int MHD_gtls_cipher_encrypt (void *handle, void *text, int textlen);
37 37
38int mhd_gtls_cipher_decrypt (void *handle, 38int MHD_gtls_cipher_decrypt (void *handle,
39 void *ciphertext, int ciphertextlen); 39 void *ciphertext, int ciphertextlen);
40 40
41void mhd_gnutls_cipher_deinit (void *handle); 41void MHD_gnutls_cipher_deinit (void *handle);
42 42
43#endif /* GNUTLS_CIPHER_INT */ 43#endif /* GNUTLS_CIPHER_INT */
diff --git a/src/daemon/https/tls/gnutls_compress.c b/src/daemon/https/tls/gnutls_compress.c
index 9585fcf2..9552a72a 100644
--- a/src/daemon/https/tls/gnutls_compress.c
+++ b/src/daemon/https/tls/gnutls_compress.c
@@ -34,20 +34,20 @@
34/* These functions allocate the return value internally 34/* These functions allocate the return value internally
35 */ 35 */
36int 36int
37_gnutls_m_plaintext2compressed (mhd_gtls_session_t session, 37MHD__gnutls_m_plaintext2compressed (MHD_gtls_session_t session,
38 gnutls_datum_t * compressed, 38 MHD_gnutls_datum_t * compressed,
39 const gnutls_datum_t * plaintext) 39 const MHD_gnutls_datum_t * plaintext)
40{ 40{
41 int size; 41 int size;
42 opaque *data; 42 opaque *data;
43 43
44 size = 44 size =
45 mhd_gtls_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)
49 { 49 {
50 gnutls_assert (); 50 MHD_gnutls_assert ();
51 return GNUTLS_E_COMPRESSION_FAILED; 51 return GNUTLS_E_COMPRESSION_FAILED;
52 } 52 }
53 compressed->data = data; 53 compressed->data = data;
@@ -57,20 +57,20 @@ _gnutls_m_plaintext2compressed (mhd_gtls_session_t session,
57} 57}
58 58
59int 59int
60_gnutls_m_compressed2plaintext (mhd_gtls_session_t session, 60MHD__gnutls_m_compressed2plaintext (MHD_gtls_session_t session,
61 gnutls_datum_t * plain, 61 MHD_gnutls_datum_t * plain,
62 const gnutls_datum_t * compressed) 62 const MHD_gnutls_datum_t * compressed)
63{ 63{
64 int size; 64 int size;
65 opaque *data; 65 opaque *data;
66 66
67 size = 67 size =
68 mhd_gtls_decompress (session->connection_state.read_compression_state, 68 MHD_gtls_decompress (session->connection_state.read_compression_state,
69 compressed->data, compressed->size, &data, 69 compressed->data, compressed->size, &data,
70 MAX_RECORD_RECV_SIZE); 70 MAX_RECORD_RECV_SIZE);
71 if (size < 0) 71 if (size < 0)
72 { 72 {
73 gnutls_assert (); 73 MHD_gnutls_assert ();
74 return GNUTLS_E_DECOMPRESSION_FAILED; 74 return GNUTLS_E_DECOMPRESSION_FAILED;
75 } 75 }
76 plain->data = data; 76 plain->data = data;
diff --git a/src/daemon/https/tls/gnutls_compress.h b/src/daemon/https/tls/gnutls_compress.h
index 7ccca5c3..c950e95d 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 (mhd_gtls_session_t session, 25int MHD__gnutls_m_plaintext2compressed (MHD_gtls_session_t session,
26 gnutls_datum_t * compressed, 26 MHD_gnutls_datum_t * compressed,
27 const gnutls_datum_t * plaintext); 27 const MHD_gnutls_datum_t * plaintext);
28int _gnutls_m_compressed2plaintext (mhd_gtls_session_t session, 28int MHD__gnutls_m_compressed2plaintext (MHD_gtls_session_t session,
29 gnutls_datum_t * plain, 29 MHD_gnutls_datum_t * plain,
30 const gnutls_datum_t * compressed); 30 const MHD_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 1d272bed..6b97fac4 100644
--- a/src/daemon/https/tls/gnutls_compress_int.c
+++ b/src/daemon/https/tls/gnutls_compress_int.c
@@ -31,14 +31,14 @@
31 * decompress. 31 * decompress.
32 */ 32 */
33comp_hd_t 33comp_hd_t
34mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d) 34MHD_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
35{ 35{
36 comp_hd_t ret; 36 comp_hd_t ret;
37 37
38 ret = gnutls_malloc (sizeof (struct comp_hd_t_STRUCT)); 38 ret = MHD_gnutls_malloc (sizeof (struct comp_hd_t_STRUCT));
39 if (ret == NULL) 39 if (ret == NULL)
40 { 40 {
41 gnutls_assert (); 41 MHD_gnutls_assert ();
42 return NULL; 42 return NULL;
43 } 43 }
44 44
@@ -54,14 +54,14 @@ mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
54 int comp_level; 54 int comp_level;
55 z_stream *zhandle; 55 z_stream *zhandle;
56 56
57 window_bits = mhd_gtls_compression_get_wbits (method); 57 window_bits = MHD_gtls_compression_get_wbits (method);
58 mem_level = mhd_gtls_compression_get_mem_level (method); 58 mem_level = MHD_gtls_compression_get_mem_level (method);
59 comp_level = mhd_gtls_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 = MHD_gnutls_malloc (sizeof (z_stream));
62 if (ret->handle == NULL) 62 if (ret->handle == NULL)
63 { 63 {
64 gnutls_assert (); 64 MHD_gnutls_assert ();
65 goto cleanup_ret; 65 goto cleanup_ret;
66 } 66 }
67 67
@@ -81,8 +81,8 @@ mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
81 } 81 }
82 if (err != Z_OK) 82 if (err != Z_OK)
83 { 83 {
84 gnutls_assert (); 84 MHD_gnutls_assert ();
85 gnutls_free (ret->handle); 85 MHD_gnutls_free (ret->handle);
86 goto cleanup_ret; 86 goto cleanup_ret;
87 } 87 }
88 break; 88 break;
@@ -94,7 +94,7 @@ mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
94 return ret; 94 return ret;
95 95
96cleanup_ret: 96cleanup_ret:
97 gnutls_free (ret); 97 MHD_gnutls_free (ret);
98 return NULL; 98 return NULL;
99} 99}
100 100
@@ -102,7 +102,7 @@ cleanup_ret:
102 * decompress. 102 * decompress.
103 */ 103 */
104void 104void
105mhd_gtls_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 {
@@ -119,8 +119,8 @@ mhd_gtls_comp_deinit (comp_hd_t handle, int d)
119 default: 119 default:
120 break; 120 break;
121 } 121 }
122 gnutls_free (handle->handle); 122 MHD_gnutls_free (handle->handle);
123 gnutls_free (handle); 123 MHD_gnutls_free (handle);
124 124
125 } 125 }
126} 126}
@@ -129,7 +129,7 @@ mhd_gtls_comp_deinit (comp_hd_t handle, int d)
129 */ 129 */
130 130
131int 131int
132mhd_gtls_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{
@@ -139,7 +139,7 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
139 */ 139 */
140 if (handle == NULL) 140 if (handle == NULL)
141 { 141 {
142 gnutls_assert (); 142 MHD_gnutls_assert ();
143 return GNUTLS_E_INTERNAL_ERROR; 143 return GNUTLS_E_INTERNAL_ERROR;
144 } 144 }
145 145
@@ -153,10 +153,10 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
153 z_stream *zhandle; 153 z_stream *zhandle;
154 154
155 size = (plain_size + plain_size) + 10; 155 size = (plain_size + plain_size) + 10;
156 *compressed = gnutls_malloc (size); 156 *compressed = MHD_gnutls_malloc (size);
157 if (*compressed == NULL) 157 if (*compressed == NULL)
158 { 158 {
159 gnutls_assert (); 159 MHD_gnutls_assert ();
160 return GNUTLS_E_MEMORY_ERROR; 160 return GNUTLS_E_MEMORY_ERROR;
161 } 161 }
162 162
@@ -171,8 +171,8 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
171 171
172 if (err != Z_OK || zhandle->avail_in != 0) 172 if (err != Z_OK || zhandle->avail_in != 0)
173 { 173 {
174 gnutls_assert (); 174 MHD_gnutls_assert ();
175 gnutls_free (*compressed); 175 MHD_gnutls_free (*compressed);
176 *compressed = NULL; 176 *compressed = NULL;
177 return GNUTLS_E_COMPRESSION_FAILED; 177 return GNUTLS_E_COMPRESSION_FAILED;
178 } 178 }
@@ -182,18 +182,18 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
182 } 182 }
183#endif 183#endif
184 default: 184 default:
185 gnutls_assert (); 185 MHD_gnutls_assert ();
186 return GNUTLS_E_INTERNAL_ERROR; 186 return GNUTLS_E_INTERNAL_ERROR;
187 } /* switch */ 187 } /* switch */
188 188
189#ifdef COMPRESSION_DEBUG 189#ifdef COMPRESSION_DEBUG
190 _gnutls_debug_log ("Compression ratio: %f\n", 190 MHD__gnutls_debug_log ("Compression ratio: %f\n",
191 (float) ((float) compressed_size / (float) plain_size)); 191 (float) ((float) compressed_size / (float) plain_size));
192#endif 192#endif
193 193
194 if ((size_t) compressed_size > max_comp_size) 194 if ((size_t) compressed_size > max_comp_size)
195 { 195 {
196 gnutls_free (*compressed); 196 MHD_gnutls_free (*compressed);
197 *compressed = NULL; 197 *compressed = NULL;
198 return GNUTLS_E_COMPRESSION_FAILED; 198 return GNUTLS_E_COMPRESSION_FAILED;
199 } 199 }
@@ -204,7 +204,7 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
204 204
205 205
206int 206int
207mhd_gtls_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{
@@ -212,7 +212,7 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
212 212
213 if (compressed_size > max_record_size + EXTRA_COMP_SIZE) 213 if (compressed_size > max_record_size + EXTRA_COMP_SIZE)
214 { 214 {
215 gnutls_assert (); 215 MHD_gnutls_assert ();
216 return GNUTLS_E_DECOMPRESSION_FAILED; 216 return GNUTLS_E_DECOMPRESSION_FAILED;
217 } 217 }
218 218
@@ -221,7 +221,7 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
221 221
222 if (handle == NULL) 222 if (handle == NULL)
223 { 223 {
224 gnutls_assert (); 224 MHD_gnutls_assert ();
225 return GNUTLS_E_INTERNAL_ERROR; 225 return GNUTLS_E_INTERNAL_ERROR;
226 } 226 }
227 227
@@ -247,10 +247,10 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
247 do 247 do
248 { 248 {
249 out_size += 512; 249 out_size += 512;
250 *plain = mhd_gtls_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 MHD_gnutls_assert ();
254 return GNUTLS_E_MEMORY_ERROR; 254 return GNUTLS_E_MEMORY_ERROR;
255 } 255 }
256 256
@@ -268,8 +268,8 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
268 268
269 if (err != Z_OK) 269 if (err != Z_OK)
270 { 270 {
271 gnutls_assert (); 271 MHD_gnutls_assert ();
272 gnutls_free (*plain); 272 MHD_gnutls_free (*plain);
273 *plain = NULL; 273 *plain = NULL;
274 return GNUTLS_E_DECOMPRESSION_FAILED; 274 return GNUTLS_E_DECOMPRESSION_FAILED;
275 } 275 }
@@ -279,14 +279,14 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
279 } 279 }
280#endif 280#endif
281 default: 281 default:
282 gnutls_assert (); 282 MHD_gnutls_assert ();
283 return GNUTLS_E_INTERNAL_ERROR; 283 return GNUTLS_E_INTERNAL_ERROR;
284 } /* switch */ 284 } /* switch */
285 285
286 if ((size_t) plain_size > max_record_size) 286 if ((size_t) plain_size > max_record_size)
287 { 287 {
288 gnutls_assert (); 288 MHD_gnutls_assert ();
289 gnutls_free (*plain); 289 MHD_gnutls_free (*plain);
290 *plain = NULL; 290 *plain = NULL;
291 return GNUTLS_E_DECOMPRESSION_FAILED; 291 return GNUTLS_E_DECOMPRESSION_FAILED;
292 } 292 }
diff --git a/src/daemon/https/tls/gnutls_compress_int.h b/src/daemon/https/tls/gnutls_compress_int.h
index 32edae7a..672cb392 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 enum MHD_GNUTLS_CompressionMethod algo; 37 enum MHD_GNUTLS_CompressionMethod algo;
38} *comp_hd_t; 38} *comp_hd_t;
39 39
40comp_hd_t mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod, int d); 40comp_hd_t MHD_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod, int d);
41void mhd_gtls_comp_deinit (comp_hd_t handle, int d); 41void MHD_gtls_comp_deinit (comp_hd_t handle, int d);
42 42
43int mhd_gtls_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 mhd_gtls_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 9ace3533..e38b720f 100644
--- a/src/daemon/https/tls/gnutls_constate.c
+++ b/src/daemon/https/tls/gnutls_constate.c
@@ -56,7 +56,7 @@ static const int servwrite_length = sizeof (servwrite) - 1;
56 * (session->cipher_specs) 56 * (session->cipher_specs)
57 */ 57 */
58int 58int
59_gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size, 59MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size,
60 int key_size, int export_flag) 60 int key_size, int export_flag)
61{ 61{
62 62
@@ -82,10 +82,10 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
82 if (export_flag == 0) 82 if (export_flag == 0)
83 block_size += 2 * IV_size; 83 block_size += 2 * IV_size;
84 84
85 key_block = gnutls_secure_malloc (block_size); 85 key_block = MHD_gnutls_secure_malloc (block_size);
86 if (key_block == NULL) 86 if (key_block == NULL)
87 { 87 {
88 gnutls_assert (); 88 MHD_gnutls_assert ();
89 return GNUTLS_E_MEMORY_ERROR; 89 return GNUTLS_E_MEMORY_ERROR;
90 } 90 }
91 91
@@ -100,46 +100,46 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
100 if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3) 100 if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3)
101 { /* SSL 3 */ 101 { /* SSL 3 */
102 ret = 102 ret =
103 mhd_gnutls_ssl3_generate_random 103 MHD_gnutls_ssl3_generate_random
104 (session->security_parameters.master_secret, TLS_MASTER_SIZE, rnd, 104 (session->security_parameters.master_secret, TLS_MASTER_SIZE, rnd,
105 2 * TLS_RANDOM_SIZE, block_size, key_block); 105 2 * TLS_RANDOM_SIZE, block_size, key_block);
106 } 106 }
107 else 107 else
108 { /* TLS 1.0 */ 108 { /* TLS 1.0 */
109 ret = 109 ret =
110 mhd_gtls_PRF (session, session->security_parameters.master_secret, 110 MHD_gtls_PRF (session, session->security_parameters.master_secret,
111 TLS_MASTER_SIZE, keyexp, keyexp_length, 111 TLS_MASTER_SIZE, keyexp, keyexp_length,
112 rnd, 2 * TLS_RANDOM_SIZE, block_size, key_block); 112 rnd, 2 * TLS_RANDOM_SIZE, block_size, key_block);
113 } 113 }
114 114
115 if (ret < 0) 115 if (ret < 0)
116 { 116 {
117 gnutls_assert (); 117 MHD_gnutls_assert ();
118 gnutls_free (key_block); 118 MHD_gnutls_free (key_block);
119 return ret; 119 return ret;
120 } 120 }
121 121
122 _gnutls_hard_log ("INT: KEY BLOCK[%d]: %s\n", block_size, 122 MHD__gnutls_hard_log ("INT: KEY BLOCK[%d]: %s\n", block_size,
123 mhd_gtls_bin2hex (key_block, block_size, buf, 123 MHD_gtls_bin2hex (key_block, block_size, buf,
124 sizeof (buf))); 124 sizeof (buf)));
125 125
126 pos = 0; 126 pos = 0;
127 if (hash_size > 0) 127 if (hash_size > 0)
128 { 128 {
129 if (_gnutls_sset_datum 129 if (MHD__gnutls_sset_datum
130 (&session->cipher_specs.client_write_mac_secret, 130 (&session->cipher_specs.client_write_mac_secret,
131 &key_block[pos], hash_size) < 0) 131 &key_block[pos], hash_size) < 0)
132 { 132 {
133 gnutls_free (key_block); 133 MHD_gnutls_free (key_block);
134 return GNUTLS_E_MEMORY_ERROR; 134 return GNUTLS_E_MEMORY_ERROR;
135 } 135 }
136 pos += hash_size; 136 pos += hash_size;
137 137
138 if (_gnutls_sset_datum 138 if (MHD__gnutls_sset_datum
139 (&session->cipher_specs.server_write_mac_secret, 139 (&session->cipher_specs.server_write_mac_secret,
140 &key_block[pos], hash_size) < 0) 140 &key_block[pos], hash_size) < 0)
141 { 141 {
142 gnutls_free (key_block); 142 MHD_gnutls_free (key_block);
143 return GNUTLS_E_MEMORY_ERROR; 143 return GNUTLS_E_MEMORY_ERROR;
144 } 144 }
145 pos += hash_size; 145 pos += hash_size;
@@ -168,20 +168,20 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
168 { /* export */ 168 { /* export */
169 free_keys = 1; 169 free_keys = 1;
170 170
171 client_write_key = gnutls_secure_malloc (EXPORT_FINAL_KEY_SIZE); 171 client_write_key = MHD_gnutls_secure_malloc (EXPORT_FINAL_KEY_SIZE);
172 if (client_write_key == NULL) 172 if (client_write_key == NULL)
173 { 173 {
174 gnutls_assert (); 174 MHD_gnutls_assert ();
175 gnutls_free (key_block); 175 MHD_gnutls_free (key_block);
176 return GNUTLS_E_MEMORY_ERROR; 176 return GNUTLS_E_MEMORY_ERROR;
177 } 177 }
178 178
179 server_write_key = gnutls_secure_malloc (EXPORT_FINAL_KEY_SIZE); 179 server_write_key = MHD_gnutls_secure_malloc (EXPORT_FINAL_KEY_SIZE);
180 if (server_write_key == NULL) 180 if (server_write_key == NULL)
181 { 181 {
182 gnutls_assert (); 182 MHD_gnutls_assert ();
183 gnutls_free (key_block); 183 MHD_gnutls_free (key_block);
184 gnutls_free (client_write_key); 184 MHD_gnutls_free (client_write_key);
185 return GNUTLS_E_MEMORY_ERROR; 185 return GNUTLS_E_MEMORY_ERROR;
186 } 186 }
187 187
@@ -190,7 +190,7 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
190 if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3) 190 if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3)
191 { /* SSL 3 */ 191 { /* SSL 3 */
192 ret = 192 ret =
193 mhd_gnutls_ssl3_hash_md5 (&key_block[pos], 193 MHD_gnutls_ssl3_hash_md5 (&key_block[pos],
194 key_size, rrnd, 194 key_size, rrnd,
195 2 * TLS_RANDOM_SIZE, 195 2 * TLS_RANDOM_SIZE,
196 EXPORT_FINAL_KEY_SIZE, 196 EXPORT_FINAL_KEY_SIZE,
@@ -200,7 +200,7 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
200 else 200 else
201 { /* TLS 1.0 */ 201 { /* TLS 1.0 */
202 ret = 202 ret =
203 mhd_gtls_PRF (session, &key_block[pos], key_size, 203 MHD_gtls_PRF (session, &key_block[pos], key_size,
204 cliwrite, cliwrite_length, 204 cliwrite, cliwrite_length,
205 rrnd, 205 rrnd,
206 2 * TLS_RANDOM_SIZE, 206 2 * TLS_RANDOM_SIZE,
@@ -209,10 +209,10 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
209 209
210 if (ret < 0) 210 if (ret < 0)
211 { 211 {
212 gnutls_assert (); 212 MHD_gnutls_assert ();
213 gnutls_free (key_block); 213 MHD_gnutls_free (key_block);
214 gnutls_free (server_write_key); 214 MHD_gnutls_free (server_write_key);
215 gnutls_free (client_write_key); 215 MHD_gnutls_free (client_write_key);
216 return ret; 216 return ret;
217 } 217 }
218 218
@@ -222,7 +222,7 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
222 if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3) 222 if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3)
223 { /* SSL 3 */ 223 { /* SSL 3 */
224 ret = 224 ret =
225 mhd_gnutls_ssl3_hash_md5 (&key_block[pos], key_size, 225 MHD_gnutls_ssl3_hash_md5 (&key_block[pos], key_size,
226 rnd, 2 * TLS_RANDOM_SIZE, 226 rnd, 2 * TLS_RANDOM_SIZE,
227 EXPORT_FINAL_KEY_SIZE, 227 EXPORT_FINAL_KEY_SIZE,
228 server_write_key); 228 server_write_key);
@@ -230,7 +230,7 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
230 else 230 else
231 { /* TLS 1.0 */ 231 { /* TLS 1.0 */
232 ret = 232 ret =
233 mhd_gtls_PRF (session, &key_block[pos], key_size, 233 MHD_gtls_PRF (session, &key_block[pos], key_size,
234 servwrite, servwrite_length, 234 servwrite, servwrite_length,
235 rrnd, 2 * TLS_RANDOM_SIZE, 235 rrnd, 2 * TLS_RANDOM_SIZE,
236 EXPORT_FINAL_KEY_SIZE, server_write_key); 236 EXPORT_FINAL_KEY_SIZE, server_write_key);
@@ -238,10 +238,10 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
238 238
239 if (ret < 0) 239 if (ret < 0)
240 { 240 {
241 gnutls_assert (); 241 MHD_gnutls_assert ();
242 gnutls_free (key_block); 242 MHD_gnutls_free (key_block);
243 gnutls_free (server_write_key); 243 MHD_gnutls_free (server_write_key);
244 gnutls_free (client_write_key); 244 MHD_gnutls_free (client_write_key);
245 return ret; 245 return ret;
246 } 246 }
247 247
@@ -249,41 +249,41 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
249 pos += key_size; 249 pos += key_size;
250 } 250 }
251 251
252 if (_gnutls_sset_datum 252 if (MHD__gnutls_sset_datum
253 (&session->cipher_specs.client_write_key, 253 (&session->cipher_specs.client_write_key,
254 client_write_key, client_write_key_size) < 0) 254 client_write_key, client_write_key_size) < 0)
255 { 255 {
256 gnutls_free (key_block); 256 MHD_gnutls_free (key_block);
257 gnutls_free (server_write_key); 257 MHD_gnutls_free (server_write_key);
258 gnutls_free (client_write_key); 258 MHD_gnutls_free (client_write_key);
259 return GNUTLS_E_MEMORY_ERROR; 259 return GNUTLS_E_MEMORY_ERROR;
260 } 260 }
261 _gnutls_hard_log ("INT: CLIENT WRITE KEY [%d]: %s\n", 261 MHD__gnutls_hard_log ("INT: CLIENT WRITE KEY [%d]: %s\n",
262 client_write_key_size, 262 client_write_key_size,
263 mhd_gtls_bin2hex (client_write_key, 263 MHD_gtls_bin2hex (client_write_key,
264 client_write_key_size, buf, 264 client_write_key_size, buf,
265 sizeof (buf))); 265 sizeof (buf)));
266 266
267 if (_gnutls_sset_datum 267 if (MHD__gnutls_sset_datum
268 (&session->cipher_specs.server_write_key, 268 (&session->cipher_specs.server_write_key,
269 server_write_key, server_write_key_size) < 0) 269 server_write_key, server_write_key_size) < 0)
270 { 270 {
271 gnutls_free (key_block); 271 MHD_gnutls_free (key_block);
272 gnutls_free (server_write_key); 272 MHD_gnutls_free (server_write_key);
273 gnutls_free (client_write_key); 273 MHD_gnutls_free (client_write_key);
274 return GNUTLS_E_MEMORY_ERROR; 274 return GNUTLS_E_MEMORY_ERROR;
275 } 275 }
276 276
277 _gnutls_hard_log ("INT: SERVER WRITE KEY [%d]: %s\n", 277 MHD__gnutls_hard_log ("INT: SERVER WRITE KEY [%d]: %s\n",
278 server_write_key_size, 278 server_write_key_size,
279 mhd_gtls_bin2hex (server_write_key, 279 MHD_gtls_bin2hex (server_write_key,
280 server_write_key_size, buf, 280 server_write_key_size, buf,
281 sizeof (buf))); 281 sizeof (buf)));
282 282
283 if (free_keys != 0) 283 if (free_keys != 0)
284 { 284 {
285 gnutls_free (server_write_key); 285 MHD_gnutls_free (server_write_key);
286 gnutls_free (client_write_key); 286 MHD_gnutls_free (client_write_key);
287 } 287 }
288 } 288 }
289 289
@@ -292,20 +292,20 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
292 */ 292 */
293 if (IV_size > 0 && export_flag == 0) 293 if (IV_size > 0 && export_flag == 0)
294 { 294 {
295 if (_gnutls_sset_datum 295 if (MHD__gnutls_sset_datum
296 (&session->cipher_specs.client_write_IV, &key_block[pos], 296 (&session->cipher_specs.client_write_IV, &key_block[pos],
297 IV_size) < 0) 297 IV_size) < 0)
298 { 298 {
299 gnutls_free (key_block); 299 MHD_gnutls_free (key_block);
300 return GNUTLS_E_MEMORY_ERROR; 300 return GNUTLS_E_MEMORY_ERROR;
301 } 301 }
302 pos += IV_size; 302 pos += IV_size;
303 303
304 if (_gnutls_sset_datum 304 if (MHD__gnutls_sset_datum
305 (&session->cipher_specs.server_write_IV, &key_block[pos], 305 (&session->cipher_specs.server_write_IV, &key_block[pos],
306 IV_size) < 0) 306 IV_size) < 0)
307 { 307 {
308 gnutls_free (key_block); 308 MHD_gnutls_free (key_block);
309 return GNUTLS_E_MEMORY_ERROR; 309 return GNUTLS_E_MEMORY_ERROR;
310 } 310 }
311 pos += IV_size; 311 pos += IV_size;
@@ -313,69 +313,69 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
313 } 313 }
314 else if (IV_size > 0 && export_flag != 0) 314 else if (IV_size > 0 && export_flag != 0)
315 { 315 {
316 opaque *iv_block = gnutls_alloca (IV_size * 2); 316 opaque *iv_block = MHD_gnutls_alloca (IV_size * 2);
317 if (iv_block == NULL) 317 if (iv_block == NULL)
318 { 318 {
319 gnutls_assert (); 319 MHD_gnutls_assert ();
320 gnutls_free (key_block); 320 MHD_gnutls_free (key_block);
321 return GNUTLS_E_MEMORY_ERROR; 321 return GNUTLS_E_MEMORY_ERROR;
322 } 322 }
323 323
324 if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3) 324 if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3)
325 { /* SSL 3 */ 325 { /* SSL 3 */
326 ret = mhd_gnutls_ssl3_hash_md5 ("", 0, 326 ret = MHD_gnutls_ssl3_hash_md5 ("", 0,
327 rrnd, TLS_RANDOM_SIZE * 2, 327 rrnd, TLS_RANDOM_SIZE * 2,
328 IV_size, iv_block); 328 IV_size, iv_block);
329 329
330 if (ret < 0) 330 if (ret < 0)
331 { 331 {
332 gnutls_assert (); 332 MHD_gnutls_assert ();
333 gnutls_free (key_block); 333 MHD_gnutls_free (key_block);
334 gnutls_afree (iv_block); 334 MHD_gnutls_afree (iv_block);
335 return ret; 335 return ret;
336 } 336 }
337 337
338 ret = mhd_gnutls_ssl3_hash_md5 ("", 0, rnd, 338 ret = MHD_gnutls_ssl3_hash_md5 ("", 0, rnd,
339 TLS_RANDOM_SIZE * 2, 339 TLS_RANDOM_SIZE * 2,
340 IV_size, &iv_block[IV_size]); 340 IV_size, &iv_block[IV_size]);
341 341
342 } 342 }
343 else 343 else
344 { /* TLS 1.0 */ 344 { /* TLS 1.0 */
345 ret = mhd_gtls_PRF (session, "", 0, 345 ret = MHD_gtls_PRF (session, "", 0,
346 ivblock, ivblock_length, rrnd, 346 ivblock, ivblock_length, rrnd,
347 2 * TLS_RANDOM_SIZE, IV_size * 2, iv_block); 347 2 * TLS_RANDOM_SIZE, IV_size * 2, iv_block);
348 } 348 }
349 349
350 if (ret < 0) 350 if (ret < 0)
351 { 351 {
352 gnutls_assert (); 352 MHD_gnutls_assert ();
353 gnutls_afree (iv_block); 353 MHD_gnutls_afree (iv_block);
354 gnutls_free (key_block); 354 MHD_gnutls_free (key_block);
355 return ret; 355 return ret;
356 } 356 }
357 357
358 if (_gnutls_sset_datum 358 if (MHD__gnutls_sset_datum
359 (&session->cipher_specs.client_write_IV, iv_block, IV_size) < 0) 359 (&session->cipher_specs.client_write_IV, iv_block, IV_size) < 0)
360 { 360 {
361 gnutls_afree (iv_block); 361 MHD_gnutls_afree (iv_block);
362 gnutls_free (key_block); 362 MHD_gnutls_free (key_block);
363 return GNUTLS_E_MEMORY_ERROR; 363 return GNUTLS_E_MEMORY_ERROR;
364 } 364 }
365 365
366 if (_gnutls_sset_datum 366 if (MHD__gnutls_sset_datum
367 (&session->cipher_specs.server_write_IV, 367 (&session->cipher_specs.server_write_IV,
368 &iv_block[IV_size], IV_size) < 0) 368 &iv_block[IV_size], IV_size) < 0)
369 { 369 {
370 gnutls_afree (iv_block); 370 MHD_gnutls_afree (iv_block);
371 gnutls_free (key_block); 371 MHD_gnutls_free (key_block);
372 return GNUTLS_E_MEMORY_ERROR; 372 return GNUTLS_E_MEMORY_ERROR;
373 } 373 }
374 374
375 gnutls_afree (iv_block); 375 MHD_gnutls_afree (iv_block);
376 } 376 }
377 377
378 gnutls_free (key_block); 378 MHD_gnutls_free (key_block);
379 379
380 session->cipher_specs.generated_keys = 1; 380 session->cipher_specs.generated_keys = 1;
381 381
@@ -383,7 +383,7 @@ _gnutls_set_keys (mhd_gtls_session_t session, int hash_size, int IV_size,
383} 383}
384 384
385int 385int
386_gnutls_set_read_keys (mhd_gtls_session_t session) 386MHD__gnutls_set_read_keys (MHD_gtls_session_t session)
387{ 387{
388 int hash_size; 388 int hash_size;
389 int IV_size; 389 int IV_size;
@@ -394,17 +394,17 @@ _gnutls_set_read_keys (mhd_gtls_session_t session)
394 mac_algo = session->security_parameters.read_mac_algorithm; 394 mac_algo = session->security_parameters.read_mac_algorithm;
395 algo = session->security_parameters.read_bulk_cipher_algorithm; 395 algo = session->security_parameters.read_bulk_cipher_algorithm;
396 396
397 hash_size = mhd_gnutls_hash_get_algo_len (mac_algo); 397 hash_size = MHD_gnutls_hash_get_algo_len (mac_algo);
398 IV_size = mhd_gtls_cipher_get_iv_size (algo); 398 IV_size = MHD_gtls_cipher_get_iv_size (algo);
399 key_size = MHD_gnutls_cipher_get_key_size (algo); 399 key_size = MHD__gnutls_cipher_get_key_size (algo);
400 export_flag = mhd_gtls_cipher_get_export_flag (algo); 400 export_flag = MHD_gtls_cipher_get_export_flag (algo);
401 401
402 return _gnutls_set_keys (session, hash_size, IV_size, key_size, 402 return MHD__gnutls_set_keys (session, hash_size, IV_size, key_size,
403 export_flag); 403 export_flag);
404} 404}
405 405
406int 406int
407_gnutls_set_write_keys (mhd_gtls_session_t session) 407MHD__gnutls_set_write_keys (MHD_gtls_session_t session)
408{ 408{
409 int hash_size; 409 int hash_size;
410 int IV_size; 410 int IV_size;
@@ -415,12 +415,12 @@ _gnutls_set_write_keys (mhd_gtls_session_t session)
415 mac_algo = session->security_parameters.write_mac_algorithm; 415 mac_algo = session->security_parameters.write_mac_algorithm;
416 algo = session->security_parameters.write_bulk_cipher_algorithm; 416 algo = session->security_parameters.write_bulk_cipher_algorithm;
417 417
418 hash_size = mhd_gnutls_hash_get_algo_len (mac_algo); 418 hash_size = MHD_gnutls_hash_get_algo_len (mac_algo);
419 IV_size = mhd_gtls_cipher_get_iv_size (algo); 419 IV_size = MHD_gtls_cipher_get_iv_size (algo);
420 key_size = MHD_gnutls_cipher_get_key_size (algo); 420 key_size = MHD__gnutls_cipher_get_key_size (algo);
421 export_flag = mhd_gtls_cipher_get_export_flag (algo); 421 export_flag = MHD_gtls_cipher_get_export_flag (algo);
422 422
423 return _gnutls_set_keys (session, hash_size, IV_size, key_size, 423 return MHD__gnutls_set_keys (session, hash_size, IV_size, key_size,
424 export_flag); 424 export_flag);
425} 425}
426 426
@@ -437,12 +437,12 @@ _gnutls_set_write_keys (mhd_gtls_session_t session)
437 dst->max_record_recv_size = src->max_record_recv_size; \ 437 dst->max_record_recv_size = src->max_record_recv_size; \
438 dst->max_record_send_size = src->max_record_send_size; \ 438 dst->max_record_send_size = src->max_record_send_size; \
439 dst->version = src->version; \ 439 dst->version = src->version; \
440 memcpy( &dst->extensions, &src->extensions, sizeof(mhd_gtls_ext_st)); \ 440 memcpy( &dst->extensions, &src->extensions, sizeof(MHD_gtls_ext_st)); \
441 memcpy( &dst->inner_secret, &src->inner_secret, TLS_MASTER_SIZE); 441 memcpy( &dst->inner_secret, &src->inner_secret, TLS_MASTER_SIZE);
442 442
443static void 443static void
444_gnutls_cpy_read_security_parameters (mhd_gtls_security_param_st * 444MHD__gnutls_cpy_read_security_parameters (MHD_gtls_security_param_st *
445 dst, mhd_gtls_security_param_st * src) 445 dst, MHD_gtls_security_param_st * src)
446{ 446{
447 CPY_COMMON; 447 CPY_COMMON;
448 448
@@ -452,8 +452,8 @@ _gnutls_cpy_read_security_parameters (mhd_gtls_security_param_st *
452} 452}
453 453
454static void 454static void
455_gnutls_cpy_write_security_parameters (mhd_gtls_security_param_st * 455MHD__gnutls_cpy_write_security_parameters (MHD_gtls_security_param_st *
456 dst, mhd_gtls_security_param_st * src) 456 dst, MHD_gtls_security_param_st * src)
457{ 457{
458 CPY_COMMON; 458 CPY_COMMON;
459 459
@@ -469,15 +469,15 @@ _gnutls_cpy_write_security_parameters (mhd_gtls_security_param_st *
469 * This is to be called after sending the Change Cipher Spec packet. 469 * This is to be called after sending the Change Cipher Spec packet.
470 */ 470 */
471int 471int
472mhd_gtls_connection_state_init (mhd_gtls_session_t session) 472MHD_gtls_connection_state_init (MHD_gtls_session_t session)
473{ 473{
474 int ret; 474 int ret;
475 475
476/* Setup the master secret 476/* Setup the master secret
477 */ 477 */
478 if ((ret = mhd_gtls_generate_master (session, 0), 0) < 0) 478 if ((ret = MHD_gtls_generate_master (session, 0), 0) < 0)
479 { 479 {
480 gnutls_assert (); 480 MHD_gnutls_assert ();
481 return ret; 481 return ret;
482 } 482 }
483 483
@@ -490,39 +490,39 @@ mhd_gtls_connection_state_init (mhd_gtls_session_t session)
490 * (read encrypted data) 490 * (read encrypted data)
491 */ 491 */
492int 492int
493mhd_gtls_read_connection_state_init (mhd_gtls_session_t session) 493MHD_gtls_read_connection_state_init (MHD_gtls_session_t session)
494{ 494{
495 int mac_size; 495 int mac_size;
496 int rc; 496 int rc;
497 497
498 _gnutls_uint64zero (session->connection_state.read_sequence_number); 498 MHD__gnutls_uint64zero (session->connection_state.read_sequence_number);
499 499
500/* Update internals from CipherSuite selected. 500/* Update internals from CipherSuite selected.
501 * If we are resuming just copy the connection session 501 * If we are resuming just copy the connection session
502 */ 502 */
503 if (session->internals.resumed == RESUME_FALSE) 503 if (session->internals.resumed == RESUME_FALSE)
504 { 504 {
505 rc = mhd_gtls_set_read_cipher (session, 505 rc = MHD_gtls_set_read_cipher (session,
506 mhd_gtls_cipher_suite_get_cipher_algo 506 MHD_gtls_cipher_suite_get_cipher_algo
507 (&session->security_parameters. 507 (&session->security_parameters.
508 current_cipher_suite)); 508 current_cipher_suite));
509 if (rc < 0) 509 if (rc < 0)
510 return rc; 510 return rc;
511 rc = mhd_gtls_set_read_mac (session, 511 rc = MHD_gtls_set_read_mac (session,
512 mhd_gtls_cipher_suite_get_mac_algo 512 MHD_gtls_cipher_suite_get_mac_algo
513 (&session->security_parameters. 513 (&session->security_parameters.
514 current_cipher_suite)); 514 current_cipher_suite));
515 if (rc < 0) 515 if (rc < 0)
516 return rc; 516 return rc;
517 517
518 rc = mhd_gtls_set_kx (session, 518 rc = MHD_gtls_set_kx (session,
519 mhd_gtls_cipher_suite_get_kx_algo 519 MHD_gtls_cipher_suite_get_kx_algo
520 (&session->security_parameters. 520 (&session->security_parameters.
521 current_cipher_suite)); 521 current_cipher_suite));
522 if (rc < 0) 522 if (rc < 0)
523 return rc; 523 return rc;
524 524
525 rc = mhd_gtls_set_read_compression (session, 525 rc = MHD_gtls_set_read_compression (session,
526 session->internals. 526 session->internals.
527 compression_method); 527 compression_method);
528 if (rc < 0) 528 if (rc < 0)
@@ -530,54 +530,54 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
530 } 530 }
531 else 531 else
532 { /* RESUME_TRUE */ 532 { /* RESUME_TRUE */
533 _gnutls_cpy_read_security_parameters (&session->security_parameters, 533 MHD__gnutls_cpy_read_security_parameters (&session->security_parameters,
534 &session->internals. 534 &session->internals.
535 resumed_security_parameters); 535 resumed_security_parameters);
536 } 536 }
537 537
538 538
539 rc = _gnutls_set_read_keys (session); 539 rc = MHD__gnutls_set_read_keys (session);
540 if (rc < 0) 540 if (rc < 0)
541 return rc; 541 return rc;
542 542
543 _gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", 543 MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n",
544 session, 544 session,
545 mhd_gtls_cipher_suite_get_name 545 MHD_gtls_cipher_suite_get_name
546 (&session->security_parameters. 546 (&session->security_parameters.
547 current_cipher_suite)); 547 current_cipher_suite));
548 548
549 if (mhd_gtls_compression_is_ok 549 if (MHD_gtls_compression_is_ok
550 (session->security_parameters.read_compression_algorithm) != 0) 550 (session->security_parameters.read_compression_algorithm) != 0)
551 { 551 {
552 gnutls_assert (); 552 MHD_gnutls_assert ();
553 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 553 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
554 } 554 }
555 555
556 if (mhd_gnutls_mac_is_ok 556 if (MHD_gnutls_mac_is_ok
557 (session->security_parameters.read_mac_algorithm) != 0) 557 (session->security_parameters.read_mac_algorithm) != 0)
558 { 558 {
559 gnutls_assert (); 559 MHD_gnutls_assert ();
560 return GNUTLS_E_INTERNAL_ERROR; 560 return GNUTLS_E_INTERNAL_ERROR;
561 } 561 }
562 562
563 /* Free all the previous keys/ sessions etc. 563 /* Free all the previous keys/ sessions etc.
564 */ 564 */
565 if (session->connection_state.read_mac_secret.data != NULL) 565 if (session->connection_state.read_mac_secret.data != NULL)
566 _gnutls_free_datum (&session->connection_state.read_mac_secret); 566 MHD__gnutls_free_datum (&session->connection_state.read_mac_secret);
567 567
568 if (session->connection_state.read_cipher_state != NULL) 568 if (session->connection_state.read_cipher_state != NULL)
569 mhd_gnutls_cipher_deinit (session->connection_state.read_cipher_state); 569 MHD_gnutls_cipher_deinit (session->connection_state.read_cipher_state);
570 570
571 if (session->connection_state.read_compression_state != NULL) 571 if (session->connection_state.read_compression_state != NULL)
572 mhd_gtls_comp_deinit (session->connection_state.read_compression_state, 572 MHD_gtls_comp_deinit (session->connection_state.read_compression_state,
573 1); 573 1);
574 574
575 575
576 mac_size = 576 mac_size =
577 mhd_gnutls_hash_get_algo_len (session->security_parameters. 577 MHD_gnutls_hash_get_algo_len (session->security_parameters.
578 read_mac_algorithm); 578 read_mac_algorithm);
579 579
580 _gnutls_handshake_log 580 MHD__gnutls_handshake_log
581 ("HSK[%x]: Initializing internal [read] cipher sessions\n", session); 581 ("HSK[%x]: Initializing internal [read] cipher sessions\n", session);
582 582
583 switch (session->security_parameters.entity) 583 switch (session->security_parameters.entity)
@@ -586,7 +586,7 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
586 /* initialize cipher session 586 /* initialize cipher session
587 */ 587 */
588 session->connection_state.read_cipher_state = 588 session->connection_state.read_cipher_state =
589 mhd_gtls_cipher_init (session->security_parameters. 589 MHD_gtls_cipher_init (session->security_parameters.
590 read_bulk_cipher_algorithm, 590 read_bulk_cipher_algorithm,
591 &session->cipher_specs.client_write_key, 591 &session->cipher_specs.client_write_key,
592 &session->cipher_specs.client_write_IV); 592 &session->cipher_specs.client_write_IV);
@@ -594,7 +594,7 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
594 && session->security_parameters.read_bulk_cipher_algorithm != 594 && session->security_parameters.read_bulk_cipher_algorithm !=
595 MHD_GNUTLS_CIPHER_NULL) 595 MHD_GNUTLS_CIPHER_NULL)
596 { 596 {
597 gnutls_assert (); 597 MHD_gnutls_assert ();
598 return GNUTLS_E_INTERNAL_ERROR; 598 return GNUTLS_E_INTERNAL_ERROR;
599 } 599 }
600 600
@@ -603,13 +603,13 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
603 */ 603 */
604 if (mac_size > 0) 604 if (mac_size > 0)
605 { 605 {
606 if (_gnutls_sset_datum (&session->connection_state.read_mac_secret, 606 if (MHD__gnutls_sset_datum (&session->connection_state.read_mac_secret,
607 session->cipher_specs. 607 session->cipher_specs.
608 client_write_mac_secret.data, 608 client_write_mac_secret.data,
609 session->cipher_specs. 609 session->cipher_specs.
610 client_write_mac_secret.size) < 0) 610 client_write_mac_secret.size) < 0)
611 { 611 {
612 gnutls_assert (); 612 MHD_gnutls_assert ();
613 return GNUTLS_E_MEMORY_ERROR; 613 return GNUTLS_E_MEMORY_ERROR;
614 } 614 }
615 615
@@ -619,7 +619,7 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
619#if MHD_DEBUG_TLS 619#if MHD_DEBUG_TLS
620 case GNUTLS_CLIENT: 620 case GNUTLS_CLIENT:
621 session->connection_state.read_cipher_state = 621 session->connection_state.read_cipher_state =
622 mhd_gtls_cipher_init (session->security_parameters. 622 MHD_gtls_cipher_init (session->security_parameters.
623 read_bulk_cipher_algorithm, 623 read_bulk_cipher_algorithm,
624 &session->cipher_specs.server_write_key, 624 &session->cipher_specs.server_write_key,
625 &session->cipher_specs.server_write_IV); 625 &session->cipher_specs.server_write_IV);
@@ -629,7 +629,7 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
629 && session->security_parameters.read_bulk_cipher_algorithm != 629 && session->security_parameters.read_bulk_cipher_algorithm !=
630 MHD_GNUTLS_CIPHER_NULL) 630 MHD_GNUTLS_CIPHER_NULL)
631 { 631 {
632 gnutls_assert (); 632 MHD_gnutls_assert ();
633 return GNUTLS_E_INTERNAL_ERROR; 633 return GNUTLS_E_INTERNAL_ERROR;
634 } 634 }
635 635
@@ -638,13 +638,13 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
638 */ 638 */
639 if (mac_size > 0) 639 if (mac_size > 0)
640 { 640 {
641 if (_gnutls_sset_datum (&session->connection_state.read_mac_secret, 641 if (MHD__gnutls_sset_datum (&session->connection_state.read_mac_secret,
642 session->cipher_specs. 642 session->cipher_specs.
643 server_write_mac_secret.data, 643 server_write_mac_secret.data,
644 session->cipher_specs. 644 session->cipher_specs.
645 server_write_mac_secret.size) < 0) 645 server_write_mac_secret.size) < 0)
646 { 646 {
647 gnutls_assert (); 647 MHD_gnutls_assert ();
648 return GNUTLS_E_MEMORY_ERROR; 648 return GNUTLS_E_MEMORY_ERROR;
649 } 649 }
650 } 650 }
@@ -652,17 +652,17 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
652 break; 652 break;
653#endif 653#endif
654 default: /* this check is useless */ 654 default: /* this check is useless */
655 gnutls_assert (); 655 MHD_gnutls_assert ();
656 return GNUTLS_E_INTERNAL_ERROR; 656 return GNUTLS_E_INTERNAL_ERROR;
657 } 657 }
658 658
659 session->connection_state.read_compression_state = 659 session->connection_state.read_compression_state =
660 mhd_gtls_comp_init (session->security_parameters. 660 MHD_gtls_comp_init (session->security_parameters.
661 read_compression_algorithm, 1); 661 read_compression_algorithm, 1);
662 662
663 if (session->connection_state.read_compression_state == GNUTLS_COMP_FAILED) 663 if (session->connection_state.read_compression_state == GNUTLS_COMP_FAILED)
664 { 664 {
665 gnutls_assert (); 665 MHD_gnutls_assert ();
666 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 666 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
667 } 667 }
668 668
@@ -675,39 +675,39 @@ mhd_gtls_read_connection_state_init (mhd_gtls_session_t session)
675 * (write encrypted data) 675 * (write encrypted data)
676 */ 676 */
677int 677int
678mhd_gtls_write_connection_state_init (mhd_gtls_session_t session) 678MHD_gtls_write_connection_state_init (MHD_gtls_session_t session)
679{ 679{
680 int mac_size; 680 int mac_size;
681 int rc; 681 int rc;
682 682
683 _gnutls_uint64zero (session->connection_state.write_sequence_number); 683 MHD__gnutls_uint64zero (session->connection_state.write_sequence_number);
684 684
685/* Update internals from CipherSuite selected. 685/* Update internals from CipherSuite selected.
686 * If we are resuming just copy the connection session 686 * If we are resuming just copy the connection session
687 */ 687 */
688 if (session->internals.resumed == RESUME_FALSE) 688 if (session->internals.resumed == RESUME_FALSE)
689 { 689 {
690 rc = mhd_gtls_set_write_cipher (session, 690 rc = MHD_gtls_set_write_cipher (session,
691 mhd_gtls_cipher_suite_get_cipher_algo 691 MHD_gtls_cipher_suite_get_cipher_algo
692 (&session->security_parameters. 692 (&session->security_parameters.
693 current_cipher_suite)); 693 current_cipher_suite));
694 if (rc < 0) 694 if (rc < 0)
695 return rc; 695 return rc;
696 rc = mhd_gtls_set_write_mac (session, 696 rc = MHD_gtls_set_write_mac (session,
697 mhd_gtls_cipher_suite_get_mac_algo 697 MHD_gtls_cipher_suite_get_mac_algo
698 (&session->security_parameters. 698 (&session->security_parameters.
699 current_cipher_suite)); 699 current_cipher_suite));
700 if (rc < 0) 700 if (rc < 0)
701 return rc; 701 return rc;
702 702
703 rc = mhd_gtls_set_kx (session, 703 rc = MHD_gtls_set_kx (session,
704 mhd_gtls_cipher_suite_get_kx_algo 704 MHD_gtls_cipher_suite_get_kx_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 = mhd_gtls_set_write_compression (session, 710 rc = MHD_gtls_set_write_compression (session,
711 session->internals. 711 session->internals.
712 compression_method); 712 compression_method);
713 if (rc < 0) 713 if (rc < 0)
@@ -715,31 +715,31 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
715 } 715 }
716 else 716 else
717 { /* RESUME_TRUE */ 717 { /* RESUME_TRUE */
718 _gnutls_cpy_write_security_parameters (&session->security_parameters, 718 MHD__gnutls_cpy_write_security_parameters (&session->security_parameters,
719 &session->internals. 719 &session->internals.
720 resumed_security_parameters); 720 resumed_security_parameters);
721 } 721 }
722 722
723 rc = _gnutls_set_write_keys (session); 723 rc = MHD__gnutls_set_write_keys (session);
724 if (rc < 0) 724 if (rc < 0)
725 return rc; 725 return rc;
726 726
727 _gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session, 727 MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session,
728 mhd_gtls_cipher_suite_get_name 728 MHD_gtls_cipher_suite_get_name
729 (&session->security_parameters. 729 (&session->security_parameters.
730 current_cipher_suite)); 730 current_cipher_suite));
731 731
732 if (mhd_gtls_compression_is_ok 732 if (MHD_gtls_compression_is_ok
733 (session->security_parameters.write_compression_algorithm) != 0) 733 (session->security_parameters.write_compression_algorithm) != 0)
734 { 734 {
735 gnutls_assert (); 735 MHD_gnutls_assert ();
736 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 736 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
737 } 737 }
738 738
739 if (mhd_gnutls_mac_is_ok 739 if (MHD_gnutls_mac_is_ok
740 (session->security_parameters.write_mac_algorithm) != 0) 740 (session->security_parameters.write_mac_algorithm) != 0)
741 { 741 {
742 gnutls_assert (); 742 MHD_gnutls_assert ();
743 return GNUTLS_E_INTERNAL_ERROR; 743 return GNUTLS_E_INTERNAL_ERROR;
744 } 744 }
745 745
@@ -748,20 +748,20 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
748 /* Free all the previous keys/ sessions etc. 748 /* Free all the previous keys/ sessions etc.
749 */ 749 */
750 if (session->connection_state.write_mac_secret.data != NULL) 750 if (session->connection_state.write_mac_secret.data != NULL)
751 _gnutls_free_datum (&session->connection_state.write_mac_secret); 751 MHD__gnutls_free_datum (&session->connection_state.write_mac_secret);
752 752
753 if (session->connection_state.write_cipher_state != NULL) 753 if (session->connection_state.write_cipher_state != NULL)
754 mhd_gnutls_cipher_deinit (session->connection_state.write_cipher_state); 754 MHD_gnutls_cipher_deinit (session->connection_state.write_cipher_state);
755 755
756 if (session->connection_state.write_compression_state != NULL) 756 if (session->connection_state.write_compression_state != NULL)
757 mhd_gtls_comp_deinit (session->connection_state.write_compression_state, 757 MHD_gtls_comp_deinit (session->connection_state.write_compression_state,
758 0); 758 0);
759 759
760 mac_size = 760 mac_size =
761 mhd_gnutls_hash_get_algo_len (session->security_parameters. 761 MHD_gnutls_hash_get_algo_len (session->security_parameters.
762 write_mac_algorithm); 762 write_mac_algorithm);
763 763
764 _gnutls_handshake_log 764 MHD__gnutls_handshake_log
765 ("HSK[%x]: Initializing internal [write] cipher sessions\n", session); 765 ("HSK[%x]: Initializing internal [write] cipher sessions\n", session);
766 766
767 switch (session->security_parameters.entity) 767 switch (session->security_parameters.entity)
@@ -770,7 +770,7 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
770 /* initialize cipher session 770 /* initialize cipher session
771 */ 771 */
772 session->connection_state.write_cipher_state = 772 session->connection_state.write_cipher_state =
773 mhd_gtls_cipher_init (session->security_parameters. 773 MHD_gtls_cipher_init (session->security_parameters.
774 write_bulk_cipher_algorithm, 774 write_bulk_cipher_algorithm,
775 &session->cipher_specs.server_write_key, 775 &session->cipher_specs.server_write_key,
776 &session->cipher_specs.server_write_IV); 776 &session->cipher_specs.server_write_IV);
@@ -780,7 +780,7 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
780 && session->security_parameters.write_bulk_cipher_algorithm != 780 && session->security_parameters.write_bulk_cipher_algorithm !=
781 MHD_GNUTLS_CIPHER_NULL) 781 MHD_GNUTLS_CIPHER_NULL)
782 { 782 {
783 gnutls_assert (); 783 MHD_gnutls_assert ();
784 return GNUTLS_E_INTERNAL_ERROR; 784 return GNUTLS_E_INTERNAL_ERROR;
785 } 785 }
786 786
@@ -790,13 +790,13 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
790 */ 790 */
791 if (mac_size > 0) 791 if (mac_size > 0)
792 { 792 {
793 if (_gnutls_sset_datum (&session->connection_state.write_mac_secret, 793 if (MHD__gnutls_sset_datum (&session->connection_state.write_mac_secret,
794 session->cipher_specs. 794 session->cipher_specs.
795 server_write_mac_secret.data, 795 server_write_mac_secret.data,
796 session->cipher_specs. 796 session->cipher_specs.
797 server_write_mac_secret.size) < 0) 797 server_write_mac_secret.size) < 0)
798 { 798 {
799 gnutls_assert (); 799 MHD_gnutls_assert ();
800 return GNUTLS_E_MEMORY_ERROR; 800 return GNUTLS_E_MEMORY_ERROR;
801 } 801 }
802 802
@@ -807,7 +807,7 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
807#if MHD_DEBUG_TLS 807#if MHD_DEBUG_TLS
808 case GNUTLS_CLIENT: 808 case GNUTLS_CLIENT:
809 session->connection_state.write_cipher_state = 809 session->connection_state.write_cipher_state =
810 mhd_gtls_cipher_init (session->security_parameters. 810 MHD_gtls_cipher_init (session->security_parameters.
811 write_bulk_cipher_algorithm, 811 write_bulk_cipher_algorithm,
812 &session->cipher_specs.client_write_key, 812 &session->cipher_specs.client_write_key,
813 &session->cipher_specs.client_write_IV); 813 &session->cipher_specs.client_write_IV);
@@ -817,7 +817,7 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
817 && session->security_parameters.write_bulk_cipher_algorithm != 817 && session->security_parameters.write_bulk_cipher_algorithm !=
818 MHD_GNUTLS_CIPHER_NULL) 818 MHD_GNUTLS_CIPHER_NULL)
819 { 819 {
820 gnutls_assert (); 820 MHD_gnutls_assert ();
821 return GNUTLS_E_INTERNAL_ERROR; 821 return GNUTLS_E_INTERNAL_ERROR;
822 } 822 }
823 823
@@ -825,13 +825,13 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
825 */ 825 */
826 if (mac_size > 0) 826 if (mac_size > 0)
827 { 827 {
828 if (_gnutls_sset_datum (&session->connection_state.write_mac_secret, 828 if (MHD__gnutls_sset_datum (&session->connection_state.write_mac_secret,
829 session->cipher_specs. 829 session->cipher_specs.
830 client_write_mac_secret.data, 830 client_write_mac_secret.data,
831 session->cipher_specs. 831 session->cipher_specs.
832 client_write_mac_secret.size) < 0) 832 client_write_mac_secret.size) < 0)
833 { 833 {
834 gnutls_assert (); 834 MHD_gnutls_assert ();
835 return GNUTLS_E_MEMORY_ERROR; 835 return GNUTLS_E_MEMORY_ERROR;
836 } 836 }
837 } 837 }
@@ -839,18 +839,18 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
839 break; 839 break;
840#endif 840#endif
841 default: 841 default:
842 gnutls_assert (); 842 MHD_gnutls_assert ();
843 return GNUTLS_E_INTERNAL_ERROR; 843 return GNUTLS_E_INTERNAL_ERROR;
844 } 844 }
845 845
846 846
847 session->connection_state.write_compression_state = 847 session->connection_state.write_compression_state =
848 mhd_gtls_comp_init (session->security_parameters. 848 MHD_gtls_comp_init (session->security_parameters.
849 write_compression_algorithm, 0); 849 write_compression_algorithm, 0);
850 850
851 if (session->connection_state.write_compression_state == GNUTLS_COMP_FAILED) 851 if (session->connection_state.write_compression_state == GNUTLS_COMP_FAILED)
852 { 852 {
853 gnutls_assert (); 853 MHD_gnutls_assert ();
854 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 854 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
855 } 855 }
856 856
@@ -860,15 +860,15 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session)
860/* Sets the specified cipher into the pending session 860/* Sets the specified cipher into the pending session
861 */ 861 */
862int 862int
863mhd_gtls_set_read_cipher (mhd_gtls_session_t session, 863MHD_gtls_set_read_cipher (MHD_gtls_session_t session,
864 enum MHD_GNUTLS_CipherAlgorithm algo) 864 enum MHD_GNUTLS_CipherAlgorithm algo)
865{ 865{
866 866
867 if (mhd_gtls_cipher_is_ok (algo) == 0) 867 if (MHD_gtls_cipher_is_ok (algo) == 0)
868 { 868 {
869 if (mhd_gtls_cipher_priority (session, algo) < 0) 869 if (MHD_gtls_cipher_priority (session, algo) < 0)
870 { 870 {
871 gnutls_assert (); 871 MHD_gnutls_assert ();
872 return GNUTLS_E_UNWANTED_ALGORITHM; 872 return GNUTLS_E_UNWANTED_ALGORITHM;
873 } 873 }
874 874
@@ -877,7 +877,7 @@ mhd_gtls_set_read_cipher (mhd_gtls_session_t session,
877 } 877 }
878 else 878 else
879 { 879 {
880 gnutls_assert (); 880 MHD_gnutls_assert ();
881 return GNUTLS_E_INTERNAL_ERROR; 881 return GNUTLS_E_INTERNAL_ERROR;
882 } 882 }
883 883
@@ -886,15 +886,15 @@ mhd_gtls_set_read_cipher (mhd_gtls_session_t session,
886} 886}
887 887
888int 888int
889mhd_gtls_set_write_cipher (mhd_gtls_session_t session, 889MHD_gtls_set_write_cipher (MHD_gtls_session_t session,
890 enum MHD_GNUTLS_CipherAlgorithm algo) 890 enum MHD_GNUTLS_CipherAlgorithm algo)
891{ 891{
892 892
893 if (mhd_gtls_cipher_is_ok (algo) == 0) 893 if (MHD_gtls_cipher_is_ok (algo) == 0)
894 { 894 {
895 if (mhd_gtls_cipher_priority (session, algo) < 0) 895 if (MHD_gtls_cipher_priority (session, algo) < 0)
896 { 896 {
897 gnutls_assert (); 897 MHD_gnutls_assert ();
898 return GNUTLS_E_UNWANTED_ALGORITHM; 898 return GNUTLS_E_UNWANTED_ALGORITHM;
899 } 899 }
900 900
@@ -903,7 +903,7 @@ mhd_gtls_set_write_cipher (mhd_gtls_session_t session,
903 } 903 }
904 else 904 else
905 { 905 {
906 gnutls_assert (); 906 MHD_gnutls_assert ();
907 return GNUTLS_E_INTERNAL_ERROR; 907 return GNUTLS_E_INTERNAL_ERROR;
908 } 908 }
909 909
@@ -915,17 +915,17 @@ mhd_gtls_set_write_cipher (mhd_gtls_session_t session,
915/* Sets the specified algorithm into pending compression session 915/* Sets the specified algorithm into pending compression session
916 */ 916 */
917int 917int
918mhd_gtls_set_read_compression (mhd_gtls_session_t session, 918MHD_gtls_set_read_compression (MHD_gtls_session_t session,
919 enum MHD_GNUTLS_CompressionMethod algo) 919 enum MHD_GNUTLS_CompressionMethod algo)
920{ 920{
921 921
922 if (mhd_gtls_compression_is_ok (algo) == 0) 922 if (MHD_gtls_compression_is_ok (algo) == 0)
923 { 923 {
924 session->security_parameters.read_compression_algorithm = algo; 924 session->security_parameters.read_compression_algorithm = algo;
925 } 925 }
926 else 926 else
927 { 927 {
928 gnutls_assert (); 928 MHD_gnutls_assert ();
929 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 929 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
930 } 930 }
931 return 0; 931 return 0;
@@ -933,17 +933,17 @@ mhd_gtls_set_read_compression (mhd_gtls_session_t session,
933} 933}
934 934
935int 935int
936mhd_gtls_set_write_compression (mhd_gtls_session_t session, 936MHD_gtls_set_write_compression (MHD_gtls_session_t session,
937 enum MHD_GNUTLS_CompressionMethod algo) 937 enum MHD_GNUTLS_CompressionMethod algo)
938{ 938{
939 939
940 if (mhd_gtls_compression_is_ok (algo) == 0) 940 if (MHD_gtls_compression_is_ok (algo) == 0)
941 { 941 {
942 session->security_parameters.write_compression_algorithm = algo; 942 session->security_parameters.write_compression_algorithm = algo;
943 } 943 }
944 else 944 else
945 { 945 {
946 gnutls_assert (); 946 MHD_gnutls_assert ();
947 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 947 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
948 } 948 }
949 return 0; 949 return 0;
@@ -953,22 +953,22 @@ mhd_gtls_set_write_compression (mhd_gtls_session_t session,
953/* Sets the specified kx algorithm into pending session 953/* Sets the specified kx algorithm into pending session
954 */ 954 */
955int 955int
956mhd_gtls_set_kx (mhd_gtls_session_t session, 956MHD_gtls_set_kx (MHD_gtls_session_t session,
957 enum MHD_GNUTLS_KeyExchangeAlgorithm algo) 957 enum MHD_GNUTLS_KeyExchangeAlgorithm algo)
958{ 958{
959 959
960 if (mhd_gtls_kx_is_ok (algo) == 0) 960 if (MHD_gtls_kx_is_ok (algo) == 0)
961 { 961 {
962 session->security_parameters.kx_algorithm = algo; 962 session->security_parameters.kx_algorithm = algo;
963 } 963 }
964 else 964 else
965 { 965 {
966 gnutls_assert (); 966 MHD_gnutls_assert ();
967 return GNUTLS_E_INTERNAL_ERROR; 967 return GNUTLS_E_INTERNAL_ERROR;
968 } 968 }
969 if (mhd_gtls_kx_priority (session, algo) < 0) 969 if (MHD_gtls_kx_priority (session, algo) < 0)
970 { 970 {
971 gnutls_assert (); 971 MHD_gnutls_assert ();
972 /* we shouldn't get here */ 972 /* we shouldn't get here */
973 return GNUTLS_E_UNWANTED_ALGORITHM; 973 return GNUTLS_E_UNWANTED_ALGORITHM;
974 } 974 }
@@ -979,22 +979,22 @@ mhd_gtls_set_kx (mhd_gtls_session_t session,
979 979
980/* Sets the specified mac algorithm into pending session */ 980/* Sets the specified mac algorithm into pending session */
981int 981int
982mhd_gtls_set_read_mac (mhd_gtls_session_t session, 982MHD_gtls_set_read_mac (MHD_gtls_session_t session,
983 enum MHD_GNUTLS_HashAlgorithm algo) 983 enum MHD_GNUTLS_HashAlgorithm algo)
984{ 984{
985 985
986 if (mhd_gnutls_mac_is_ok (algo) == 0) 986 if (MHD_gnutls_mac_is_ok (algo) == 0)
987 { 987 {
988 session->security_parameters.read_mac_algorithm = algo; 988 session->security_parameters.read_mac_algorithm = algo;
989 } 989 }
990 else 990 else
991 { 991 {
992 gnutls_assert (); 992 MHD_gnutls_assert ();
993 return GNUTLS_E_INTERNAL_ERROR; 993 return GNUTLS_E_INTERNAL_ERROR;
994 } 994 }
995 if (mhd_gtls_mac_priority (session, algo) < 0) 995 if (MHD_gtls_mac_priority (session, algo) < 0)
996 { 996 {
997 gnutls_assert (); 997 MHD_gnutls_assert ();
998 return GNUTLS_E_UNWANTED_ALGORITHM; 998 return GNUTLS_E_UNWANTED_ALGORITHM;
999 } 999 }
1000 1000
@@ -1004,22 +1004,22 @@ mhd_gtls_set_read_mac (mhd_gtls_session_t session,
1004} 1004}
1005 1005
1006int 1006int
1007mhd_gtls_set_write_mac (mhd_gtls_session_t session, 1007MHD_gtls_set_write_mac (MHD_gtls_session_t session,
1008 enum MHD_GNUTLS_HashAlgorithm algo) 1008 enum MHD_GNUTLS_HashAlgorithm algo)
1009{ 1009{
1010 1010
1011 if (mhd_gnutls_mac_is_ok (algo) == 0) 1011 if (MHD_gnutls_mac_is_ok (algo) == 0)
1012 { 1012 {
1013 session->security_parameters.write_mac_algorithm = algo; 1013 session->security_parameters.write_mac_algorithm = algo;
1014 } 1014 }
1015 else 1015 else
1016 { 1016 {
1017 gnutls_assert (); 1017 MHD_gnutls_assert ();
1018 return GNUTLS_E_INTERNAL_ERROR; 1018 return GNUTLS_E_INTERNAL_ERROR;
1019 } 1019 }
1020 if (mhd_gtls_mac_priority (session, algo) < 0) 1020 if (MHD_gtls_mac_priority (session, algo) < 0)
1021 { 1021 {
1022 gnutls_assert (); 1022 MHD_gnutls_assert ();
1023 return GNUTLS_E_UNWANTED_ALGORITHM; 1023 return GNUTLS_E_UNWANTED_ALGORITHM;
1024 } 1024 }
1025 1025
diff --git a/src/daemon/https/tls/gnutls_constate.h b/src/daemon/https/tls/gnutls_constate.h
index 184e7873..59b67249 100644
--- a/src/daemon/https/tls/gnutls_constate.h
+++ b/src/daemon/https/tls/gnutls_constate.h
@@ -22,20 +22,20 @@
22 * 22 *
23 */ 23 */
24 24
25int mhd_gtls_connection_state_init (mhd_gtls_session_t session); 25int MHD_gtls_connection_state_init (MHD_gtls_session_t session);
26int mhd_gtls_read_connection_state_init (mhd_gtls_session_t session); 26int MHD_gtls_read_connection_state_init (MHD_gtls_session_t session);
27int mhd_gtls_write_connection_state_init (mhd_gtls_session_t session); 27int MHD_gtls_write_connection_state_init (MHD_gtls_session_t session);
28int mhd_gtls_set_write_cipher (mhd_gtls_session_t session, 28int MHD_gtls_set_write_cipher (MHD_gtls_session_t session,
29 enum MHD_GNUTLS_CipherAlgorithm algo); 29 enum MHD_GNUTLS_CipherAlgorithm algo);
30int mhd_gtls_set_write_mac (mhd_gtls_session_t session, 30int MHD_gtls_set_write_mac (MHD_gtls_session_t session,
31 enum MHD_GNUTLS_HashAlgorithm algo); 31 enum MHD_GNUTLS_HashAlgorithm algo);
32int mhd_gtls_set_read_cipher (mhd_gtls_session_t session, 32int MHD_gtls_set_read_cipher (MHD_gtls_session_t session,
33 enum MHD_GNUTLS_CipherAlgorithm algo); 33 enum MHD_GNUTLS_CipherAlgorithm algo);
34int mhd_gtls_set_read_mac (mhd_gtls_session_t session, 34int MHD_gtls_set_read_mac (MHD_gtls_session_t session,
35 enum MHD_GNUTLS_HashAlgorithm algo); 35 enum MHD_GNUTLS_HashAlgorithm algo);
36int mhd_gtls_set_read_compression (mhd_gtls_session_t session, 36int MHD_gtls_set_read_compression (MHD_gtls_session_t session,
37 enum MHD_GNUTLS_CompressionMethod algo); 37 enum MHD_GNUTLS_CompressionMethod algo);
38int mhd_gtls_set_write_compression (mhd_gtls_session_t session, 38int MHD_gtls_set_write_compression (MHD_gtls_session_t session,
39 enum MHD_GNUTLS_CompressionMethod algo); 39 enum MHD_GNUTLS_CompressionMethod algo);
40int mhd_gtls_set_kx (mhd_gtls_session_t session, 40int MHD_gtls_set_kx (MHD_gtls_session_t session,
41 enum MHD_GNUTLS_KeyExchangeAlgorithm algo); 41 enum MHD_GNUTLS_KeyExchangeAlgorithm algo);
diff --git a/src/daemon/https/tls/gnutls_datum.c b/src/daemon/https/tls/gnutls_datum.c
index d437ee2c..e9a660a4 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
37mhd_gtls_write_datum16 (opaque * dest, gnutls_datum_t dat) 37MHD_gtls_write_datum16 (opaque * dest, MHD_gnutls_datum_t dat)
38{ 38{
39 mhd_gtls_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
45mhd_gtls_write_datum24 (opaque * dest, gnutls_datum_t dat) 45MHD_gtls_write_datum24 (opaque * dest, MHD_gnutls_datum_t dat)
46{ 46{
47 mhd_gtls_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
53mhd_gtls_write_datum32 (opaque * dest, gnutls_datum_t dat) 53MHD_gtls_write_datum32 (opaque * dest, MHD_gnutls_datum_t dat)
54{ 54{
55 mhd_gtls_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
61mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat) 61MHD_gtls_write_datum8 (opaque * dest, MHD_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,8 +67,8 @@ mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat)
67 67
68 68
69int 69int
70mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data, 70MHD_gtls_set_datum_m (MHD_gnutls_datum_t * dat, const void *data,
71 size_t data_size, gnutls_alloc_function galloc_func) 71 size_t data_size, MHD_gnutls_alloc_function galloc_func)
72{ 72{
73 if (data_size == 0 || data == NULL) 73 if (data_size == 0 || data == NULL)
74 { 74 {
@@ -88,9 +88,9 @@ mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data,
88} 88}
89 89
90int 90int
91mhd_gtls_datum_append_m (gnutls_datum_t * dst, const void *data, 91MHD_gtls_datum_append_m (MHD_gnutls_datum_t * dst, const void *data,
92 size_t data_size, 92 size_t data_size,
93 gnutls_realloc_function grealloc_func) 93 MHD_gnutls_realloc_function grealloc_func)
94{ 94{
95 95
96 dst->data = grealloc_func (dst->data, data_size + dst->size); 96 dst->data = grealloc_func (dst->data, data_size + dst->size);
@@ -104,7 +104,7 @@ mhd_gtls_datum_append_m (gnutls_datum_t * dst, const void *data,
104} 104}
105 105
106void 106void
107mhd_gtls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function gfree_func) 107MHD_gtls_free_datum_m (MHD_gnutls_datum_t * dat, MHD_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 f54e300b..634d527e 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 mhd_gtls_write_datum16 (opaque * dest, gnutls_datum_t dat); 25void MHD_gtls_write_datum16 (opaque * dest, MHD_gnutls_datum_t dat);
26void mhd_gtls_write_datum24 (opaque * dest, gnutls_datum_t dat); 26void MHD_gtls_write_datum24 (opaque * dest, MHD_gnutls_datum_t dat);
27void mhd_gtls_write_datum32 (opaque * dest, gnutls_datum_t dat); 27void MHD_gtls_write_datum32 (opaque * dest, MHD_gnutls_datum_t dat);
28void mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat); 28void MHD_gtls_write_datum8 (opaque * dest, MHD_gnutls_datum_t dat);
29 29
30int mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data, 30int MHD_gtls_set_datum_m (MHD_gnutls_datum_t * dat, const void *data,
31 size_t data_size, gnutls_alloc_function); 31 size_t data_size, MHD_gnutls_alloc_function);
32#define _gnutls_set_datum( x, y, z) mhd_gtls_set_datum_m(x,y,z, gnutls_malloc) 32#define MHD__gnutls_set_datum( x, y, z) MHD_gtls_set_datum_m(x,y,z, MHD_gnutls_malloc)
33#define _gnutls_sset_datum( x, y, z) mhd_gtls_set_datum_m(x,y,z, gnutls_secure_malloc) 33#define MHD__gnutls_sset_datum( x, y, z) MHD_gtls_set_datum_m(x,y,z, MHD_gnutls_secure_malloc)
34 34
35int mhd_gtls_datum_append_m (gnutls_datum_t * dat, const void *data, 35int MHD_gtls_datum_append_m (MHD_gnutls_datum_t * dat, const void *data,
36 size_t data_size, gnutls_realloc_function); 36 size_t data_size, MHD_gnutls_realloc_function);
37#define _gnutls_datum_append(x,y,z) mhd_gtls_datum_append_m(x,y,z, gnutls_realloc) 37#define MHD__gnutls_datum_append(x,y,z) MHD_gtls_datum_append_m(x,y,z, MHD_gnutls_realloc)
38 38
39void mhd_gtls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function); 39void MHD_gtls_free_datum_m (MHD_gnutls_datum_t * dat, MHD_gnutls_free_function);
40#define _gnutls_free_datum(x) mhd_gtls_free_datum_m(x, gnutls_free) 40#define MHD__gnutls_free_datum(x) MHD_gtls_free_datum_m(x, MHD_gnutls_free)
diff --git a/src/daemon/https/tls/gnutls_dh.c b/src/daemon/https/tls/gnutls_dh.c
index 8cd5175d..d9dd4344 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 = mhd_gtls_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 = mhd_gtls_calc_dh_key(Y, x, g, p); 40 key = MHD_gtls_calc_dh_key(Y, x, g, p);
41 mhd_gtls_mpi_release(x); 41 MHD_gtls_mpi_release(x);
42 mhd_gtls_mpi_release(g); 42 MHD_gtls_mpi_release(g);
43*/ 43*/
44 44
45#define MAX_BITS 18000 45#define MAX_BITS 18000
@@ -47,24 +47,24 @@
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
50mhd_gtls_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 = MHD__gnutls_mpi_get_nbits (prime) - 1;
54 /* The size of the secret key is less than 54 /* The size of the secret key is less than
55 * prime/2 55 * prime/2
56 */ 56 */
57 57
58 if (x_size > MAX_BITS || x_size <= 0) 58 if (x_size > MAX_BITS || x_size <= 0)
59 { 59 {
60 gnutls_assert (); 60 MHD_gnutls_assert ();
61 return NULL; 61 return NULL;
62 } 62 }
63 63
64 x = _gnutls_mpi_new (x_size); 64 x = MHD__gnutls_mpi_new (x_size);
65 if (x == NULL) 65 if (x == NULL)
66 { 66 {
67 gnutls_assert (); 67 MHD_gnutls_assert ();
68 if (ret_x) 68 if (ret_x)
69 *ret_x = NULL; 69 *ret_x = NULL;
70 70
@@ -76,55 +76,55 @@ mhd_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
76 */ 76 */
77 do 77 do
78 { 78 {
79 _gnutls_mpi_randomize (x, (x_size / 8) * 8, GCRY_STRONG_RANDOM); 79 MHD__gnutls_mpi_randomize (x, (x_size / 8) * 8, GCRY_STRONG_RANDOM);
80 /* Check whether x is zero. 80 /* Check whether x is zero.
81 */ 81 */
82 } 82 }
83 while (_gnutls_mpi_cmp_ui (x, 0) == 0); 83 while (MHD__gnutls_mpi_cmp_ui (x, 0) == 0);
84 84
85 e = _gnutls_mpi_alloc_like (prime); 85 e = MHD__gnutls_mpi_alloc_like (prime);
86 if (e == NULL) 86 if (e == NULL)
87 { 87 {
88 gnutls_assert (); 88 MHD_gnutls_assert ();
89 if (ret_x) 89 if (ret_x)
90 *ret_x = NULL; 90 *ret_x = NULL;
91 91
92 mhd_gtls_mpi_release (&x); 92 MHD_gtls_mpi_release (&x);
93 return NULL; 93 return NULL;
94 } 94 }
95 95
96 _gnutls_mpi_powm (e, g, x, prime); 96 MHD__gnutls_mpi_powm (e, g, x, prime);
97 97
98 if (ret_x) 98 if (ret_x)
99 *ret_x = x; 99 *ret_x = x;
100 else 100 else
101 mhd_gtls_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
107mhd_gtls_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;
111 111
112 bits = _gnutls_mpi_get_nbits (prime); 112 bits = MHD__gnutls_mpi_get_nbits (prime);
113 if (bits <= 0 || bits > MAX_BITS) 113 if (bits <= 0 || bits > MAX_BITS)
114 { 114 {
115 gnutls_assert (); 115 MHD_gnutls_assert ();
116 return NULL; 116 return NULL;
117 } 117 }
118 118
119 k = _gnutls_mpi_alloc_like (prime); 119 k = MHD__gnutls_mpi_alloc_like (prime);
120 if (k == NULL) 120 if (k == NULL)
121 return NULL; 121 return NULL;
122 _gnutls_mpi_powm (k, f, x, prime); 122 MHD__gnutls_mpi_powm (k, f, x, prime);
123 return k; 123 return k;
124} 124}
125 125
126/*- 126/*-
127 * mhd_gtls_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,12 +132,12 @@ mhd_gtls_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 -*/
135mhd_gtls_dh_params_t 135MHD_gtls_dh_params_t
136mhd_gtls_get_dh_params (mhd_gtls_dh_params_t dh_params, 136MHD_gtls_get_dh_params (MHD_gtls_dh_params_t dh_params,
137 gnutls_params_function * func, 137 MHD_gnutls_params_function * func,
138 mhd_gtls_session_t session) 138 MHD_gtls_session_t session)
139{ 139{
140 gnutls_params_st params; 140 MHD_gnutls_params_st params;
141 int ret; 141 int ret;
142 142
143 /* if cached return the cached */ 143 /* if cached return the cached */
diff --git a/src/daemon/https/tls/gnutls_dh.h b/src/daemon/https/tls/gnutls_dh.h
index 6dec6e64..5d7341fc 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 *mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t); 28const mpi_t *MHD_gtls_dh_params_to_mpi (MHD_gtls_dh_params_t);
29mpi_t mhd_gtls_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 mhd_gtls_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 mhd_gtls_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
33mhd_gtls_dh_params_t 33MHD_gtls_dh_params_t
34mhd_gtls_get_dh_params (mhd_gtls_dh_params_t dh_params, 34MHD_gtls_get_dh_params (MHD_gtls_dh_params_t dh_params,
35 gnutls_params_function * func, 35 MHD_gnutls_params_function * func,
36 mhd_gtls_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 acd08a75..83776c42 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 *
39mhd_gtls_dh_params_to_mpi (mhd_gtls_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 @@ mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t dh_primes)
48} 48}
49 49
50int 50int
51mhd_gtls_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 @@ mhd_gtls_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 mhd_gtls_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
@@ -85,7 +85,7 @@ mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
85 85
86 if (err != 0) 86 if (err != 0)
87 { 87 {
88 gnutls_assert (); 88 MHD_gnutls_assert ();
89 result = GNUTLS_E_INTERNAL_ERROR; 89 result = GNUTLS_E_INTERNAL_ERROR;
90 goto cleanup; 90 goto cleanup;
91 } 91 }
@@ -98,7 +98,7 @@ mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
98 98
99 if (err != 0) 99 if (err != 0)
100 { 100 {
101 gnutls_assert (); 101 MHD_gnutls_assert ();
102 result = GNUTLS_E_INTERNAL_ERROR; 102 result = GNUTLS_E_INTERNAL_ERROR;
103 goto cleanup; 103 goto cleanup;
104 } 104 }
@@ -108,7 +108,7 @@ mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
108 err = gcry_prime_group_generator (&g, prime, factors, NULL); 108 err = gcry_prime_group_generator (&g, prime, factors, NULL);
109 if (err != 0) 109 if (err != 0)
110 { 110 {
111 gnutls_assert (); 111 MHD_gnutls_assert ();
112 result = GNUTLS_E_INTERNAL_ERROR; 112 result = GNUTLS_E_INTERNAL_ERROR;
113 goto cleanup; 113 goto cleanup;
114 } 114 }
@@ -119,17 +119,17 @@ mhd_gtls_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 mhd_gtls_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 mhd_gtls_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 mhd_gtls_mpi_release (&g); 131 MHD_gtls_mpi_release (&g);
132 mhd_gtls_mpi_release (&prime); 132 MHD_gtls_mpi_release (&prime);
133 133
134 return result; 134 return result;
135 135
@@ -139,20 +139,20 @@ cleanup:gcry_prime_release_factors (factors);
139 * generated one. 139 * generated one.
140 */ 140 */
141/** 141/**
142 * MHD_gnutls_dh_params_init - This function will initialize the 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 143 * @dh_params: Is a structure that will hold the prime numbers
144 * 144 *
145 * This function will initialize the DH parameters structure. 145 * This function will initialize the DH parameters structure.
146 * 146 *
147 **/ 147 **/
148int 148int
149MHD_gnutls_dh_params_init (mhd_gtls_dh_params_t * dh_params) 149MHD__gnutls_dh_params_init (MHD_gtls_dh_params_t * dh_params)
150{ 150{
151 151
152 (*dh_params) = gnutls_calloc (1, sizeof (mhd_gtls_dh_params_st)); 152 (*dh_params) = MHD_gnutls_calloc (1, sizeof (MHD_gtls_dh_params_st));
153 if (*dh_params == NULL) 153 if (*dh_params == NULL)
154 { 154 {
155 gnutls_assert (); 155 MHD_gnutls_assert ();
156 return GNUTLS_E_MEMORY_ERROR; 156 return GNUTLS_E_MEMORY_ERROR;
157 } 157 }
158 158
@@ -161,33 +161,33 @@ MHD_gnutls_dh_params_init (mhd_gtls_dh_params_t * dh_params)
161} 161}
162 162
163/** 163/**
164 * MHD_gnutls_dh_params_deinit - This function will deinitialize the DH parameters 164 * MHD__gnutls_dh_params_deinit - This function will deinitialize the DH parameters
165 * @dh_params: Is a structure that holds the prime numbers 165 * @dh_params: Is a structure that holds the prime numbers
166 * 166 *
167 * This function will deinitialize the DH parameters structure. 167 * This function will deinitialize the DH parameters structure.
168 * 168 *
169 **/ 169 **/
170void 170void
171MHD_gnutls_dh_params_deinit (mhd_gtls_dh_params_t dh_params) 171MHD__gnutls_dh_params_deinit (MHD_gtls_dh_params_t dh_params)
172{ 172{
173 if (dh_params == NULL) 173 if (dh_params == NULL)
174 return; 174 return;
175 175
176 mhd_gtls_mpi_release (&dh_params->params[0]); 176 MHD_gtls_mpi_release (&dh_params->params[0]);
177 mhd_gtls_mpi_release (&dh_params->params[1]); 177 MHD_gtls_mpi_release (&dh_params->params[1]);
178 178
179 gnutls_free (dh_params); 179 MHD_gnutls_free (dh_params);
180 180
181} 181}
182 182
183/** 183/**
184 * MHD_gnutls_dh_params_generate2 - This function will generate new DH parameters 184 * MHD__gnutls_dh_params_generate2 - This function will generate new DH parameters
185 * @params: Is the structure that the DH parameters will be stored 185 * @params: Is the structure that the DH parameters will be stored
186 * @bits: is the prime's number of bits 186 * @bits: is the prime's number of bits
187 * 187 *
188 * 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
189 * 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
190 * gnutls_malloc() and will be stored in the appropriate datum. 190 * MHD_gnutls_malloc() and will be stored in the appropriate datum.
191 * This function is normally slow. 191 * This function is normally slow.
192 * 192 *
193 * 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.
@@ -197,16 +197,16 @@ MHD_gnutls_dh_params_deinit (mhd_gtls_dh_params_t dh_params)
197 * 197 *
198 **/ 198 **/
199int 199int
200MHD_gnutls_dh_params_generate2 (mhd_gtls_dh_params_t params, 200MHD__gnutls_dh_params_generate2 (MHD_gtls_dh_params_t params,
201 unsigned int bits) 201 unsigned int bits)
202{ 202{
203 int ret; 203 int ret;
204 204
205 ret = 205 ret =
206 mhd_gtls_dh_generate_prime (&params->params[1], &params->params[0], bits); 206 MHD_gtls_dh_generate_prime (&params->params[1], &params->params[0], bits);
207 if (ret < 0) 207 if (ret < 0)
208 { 208 {
209 gnutls_assert (); 209 MHD_gnutls_assert ();
210 return ret; 210 return ret;
211 } 211 }
212 212
diff --git a/src/daemon/https/tls/gnutls_errors.c b/src/daemon/https/tls/gnutls_errors.c
index c0e42872..51fdb707 100644
--- a/src/daemon/https/tls/gnutls_errors.c
+++ b/src/daemon/https/tls/gnutls_errors.c
@@ -33,21 +33,21 @@
33#define _(String) (String) 33#define _(String) (String)
34#define N_(String) (String) 34#define N_(String) (String)
35 35
36extern LOG_FUNC _gnutls_log_func; 36extern LOG_FUNC MHD__gnutls_log_func;
37 37
38#define ERROR_ENTRY(desc, name, fatal) \ 38#define ERROR_ENTRY(desc, name, fatal) \
39 { desc, #name, name, fatal} 39 { desc, #name, name, fatal}
40 40
41struct gnutls_error_entry 41struct MHD_gnutls_error_entry
42{ 42{
43 const char *desc; 43 const char *desc;
44 const char *_name; 44 const char *_name;
45 int number; 45 int number;
46 int fatal; 46 int fatal;
47}; 47};
48typedef struct gnutls_error_entry gnutls_error_entry; 48typedef struct MHD_gnutls_error_entry MHD_gnutls_error_entry;
49 49
50static const gnutls_error_entry mhd_gtls_error_algorithms[] = { 50static const MHD_gnutls_error_entry MHD_gtls_error_algorithms[] = {
51 /* "Short Description", Error code define, critical (0,1) -- 1 in most cases */ 51 /* "Short Description", Error code define, critical (0,1) -- 1 in most cases */
52 ERROR_ENTRY (N_("Success."), GNUTLS_E_SUCCESS, 0), 52 ERROR_ENTRY (N_("Success."), GNUTLS_E_SUCCESS, 0),
53 ERROR_ENTRY (N_("Could not negotiate a supported cipher suite."), 53 ERROR_ENTRY (N_("Could not negotiate a supported cipher suite."),
@@ -246,8 +246,8 @@ static const gnutls_error_entry mhd_gtls_error_algorithms[] = {
246}; 246};
247 247
248#define GNUTLS_ERROR_LOOP(b) \ 248#define GNUTLS_ERROR_LOOP(b) \
249 const gnutls_error_entry *p; \ 249 const MHD_gnutls_error_entry *p; \
250 for(p = mhd_gtls_error_algorithms; p->desc != NULL; p++) { b ; } 250 for(p = MHD_gtls_error_algorithms; p->desc != NULL; p++) { b ; }
251 251
252#define GNUTLS_ERROR_ALG_LOOP(a) \ 252#define GNUTLS_ERROR_ALG_LOOP(a) \
253 GNUTLS_ERROR_LOOP( if(p->number == error) { a; break; } ) 253 GNUTLS_ERROR_LOOP( if(p->number == error) { a; break; } )
@@ -329,7 +329,7 @@ MHD_gtls_strerror (int error)
329 * given error code. 329 * given error code.
330 */ 330 */
331const char * 331const char *
332_gnutls_strerror (int error) 332MHD__gnutls_strerror (int error)
333{ 333{
334 const char *ret = NULL; 334 const char *ret = NULL;
335 335
@@ -340,7 +340,7 @@ _gnutls_strerror (int error)
340} 340}
341 341
342int 342int
343mhd_gtls_asn2err (int asn_err) 343MHD_gtls_asn2err (int asn_err)
344{ 344{
345 switch (asn_err) 345 switch (asn_err)
346 { 346 {
@@ -382,13 +382,13 @@ mhd_gtls_asn2err (int asn_err)
382 * caller provided function 382 * caller provided function
383 */ 383 */
384void 384void
385mhd_gtls_log (int level, const char *fmt, ...) 385MHD_gtls_log (int level, const char *fmt, ...)
386{ 386{
387 va_list args; 387 va_list args;
388 char str[MAX_LOG_SIZE]; 388 char str[MAX_LOG_SIZE];
389 void (*log_func) (int, const char *) = _gnutls_log_func; 389 void (*log_func) (int, const char *) = MHD__gnutls_log_func;
390 390
391 if (_gnutls_log_func == NULL) 391 if (MHD__gnutls_log_func == NULL)
392 return; 392 return;
393 393
394 va_start (args, fmt); 394 va_start (args, fmt);
@@ -405,7 +405,7 @@ mhd_gtls_log (int level, const char *fmt, ...)
405 * be called. This may affect performance. 405 * be called. This may affect performance.
406 */ 406 */
407void 407void
408_gnutls_null_log (void *x, ...) 408MHD__gnutls_null_log (void *x, ...)
409{ 409{
410 return; 410 return;
411} 411}
diff --git a/src/daemon/https/tls/gnutls_errors.h b/src/daemon/https/tls/gnutls_errors.h
index fcfc4c63..edc89817 100644
--- a/src/daemon/https/tls/gnutls_errors.h
+++ b/src/daemon/https/tls/gnutls_errors.h
@@ -28,46 +28,46 @@
28 28
29#ifdef __FILE__ 29#ifdef __FILE__
30# ifdef __LINE__ 30# ifdef __LINE__
31# define gnutls_assert() _gnutls_debug_log( "ASSERT: %s:%d\n", __FILE__,__LINE__); 31# define MHD_gnutls_assert() MHD__gnutls_debug_log( "ASSERT: %s:%d\n", __FILE__,__LINE__);
32# else 32# else
33# define gnutls_assert() 33# define MHD_gnutls_assert()
34# endif 34# endif
35#else /* __FILE__ not defined */ 35#else /* __FILE__ not defined */
36# define gnutls_assert() 36# define MHD_gnutls_assert()
37#endif 37#endif
38 38
39int mhd_gtls_asn2err (int asn_err); 39int MHD_gtls_asn2err (int asn_err);
40void mhd_gtls_log (int, const char *fmt, ...); 40void MHD_gtls_log (int, const char *fmt, ...);
41 41
42extern int _gnutls_log_level; 42extern int MHD__gnutls_log_level;
43 43
44#ifdef C99_MACROS 44#ifdef C99_MACROS
45#define LEVEL(l, ...) if (_gnutls_log_level >= l || _gnutls_log_level > 9) \ 45#define LEVEL(l, ...) if (MHD__gnutls_log_level >= l || MHD__gnutls_log_level > 9) \
46 mhd_gtls_log( l, __VA_ARGS__) 46 MHD_gtls_log( l, __VA_ARGS__)
47 47
48#define LEVEL_EQ(l, ...) if (_gnutls_log_level == l || _gnutls_log_level > 9) \ 48#define LEVEL_EQ(l, ...) if (MHD__gnutls_log_level == l || MHD__gnutls_log_level > 9) \
49 mhd_gtls_log( l, __VA_ARGS__) 49 MHD_gtls_log( l, __VA_ARGS__)
50 50
51# define _gnutls_debug_log(...) LEVEL(2, __VA_ARGS__) 51# define MHD__gnutls_debug_log(...) LEVEL(2, __VA_ARGS__)
52# define _gnutls_handshake_log(...) LEVEL(3, __VA_ARGS__) 52# define MHD__gnutls_handshake_log(...) LEVEL(3, __VA_ARGS__)
53# define _gnutls_io_log(...) LEVEL_EQ(5, __VA_ARGS__) 53# define MHD__gnutls_io_log(...) LEVEL_EQ(5, __VA_ARGS__)
54# define _gnutls_buffers_log(...) LEVEL_EQ(6, __VA_ARGS__) 54# define MHD__gnutls_buffers_log(...) LEVEL_EQ(6, __VA_ARGS__)
55# define _gnutls_hard_log(...) LEVEL(9, __VA_ARGS__) 55# define MHD__gnutls_hard_log(...) LEVEL(9, __VA_ARGS__)
56# define _gnutls_record_log(...) LEVEL(4, __VA_ARGS__) 56# define MHD__gnutls_record_log(...) LEVEL(4, __VA_ARGS__)
57# define _gnutls_read_log(...) LEVEL_EQ(7, __VA_ARGS__) 57# define MHD__gnutls_read_log(...) LEVEL_EQ(7, __VA_ARGS__)
58# define _gnutls_write_log(...) LEVEL_EQ(7, __VA_ARGS__) 58# define MHD__gnutls_write_log(...) LEVEL_EQ(7, __VA_ARGS__)
59# define _gnutls_x509_log(...) LEVEL(1, __VA_ARGS__) 59# define MHD__gnutls_x509_log(...) LEVEL(1, __VA_ARGS__)
60#else 60#else
61# define _gnutls_debug_log _gnutls_null_log 61# define MHD__gnutls_debug_log MHD__gnutls_null_log
62# define _gnutls_handshake_log _gnutls_null_log 62# define MHD__gnutls_handshake_log MHD__gnutls_null_log
63# define _gnutls_io_log _gnutls_null_log 63# define MHD__gnutls_io_log MHD__gnutls_null_log
64# define _gnutls_buffers_log _gnutls_null_log 64# define MHD__gnutls_buffers_log MHD__gnutls_null_log
65# define _gnutls_hard_log _gnutls_null_log 65# define MHD__gnutls_hard_log MHD__gnutls_null_log
66# define _gnutls_record_log _gnutls_null_log 66# define MHD__gnutls_record_log MHD__gnutls_null_log
67# define _gnutls_read_log _gnutls_null_log 67# define MHD__gnutls_read_log MHD__gnutls_null_log
68# define _gnutls_write_log _gnutls_null_log 68# define MHD__gnutls_write_log MHD__gnutls_null_log
69# define _gnutls_x509_log _gnutls_null_log 69# define MHD__gnutls_x509_log MHD__gnutls_null_log
70 70
71void _gnutls_null_log (void *, ...); 71void MHD__gnutls_null_log (void *, ...);
72 72
73#endif /* C99_MACROS */ 73#endif /* C99_MACROS */
diff --git a/src/daemon/https/tls/gnutls_extensions.c b/src/daemon/https/tls/gnutls_extensions.c
index 4c9286d8..1f9cf7d0 100644
--- a/src/daemon/https/tls/gnutls_extensions.c
+++ b/src/daemon/https/tls/gnutls_extensions.c
@@ -43,39 +43,39 @@
43 43
44 44
45#define MAX_EXT_SIZE 10 45#define MAX_EXT_SIZE 10
46const int mhd_gtls_extensions_size = MAX_EXT_SIZE; 46const int MHD_gtls_extensions_size = MAX_EXT_SIZE;
47 47
48mhd_gtls_extension_entry mhd_gtls_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 mhd_gtls_max_record_recv_params, 51 MHD_gtls_max_record_recv_params,
52 mhd_gtls_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 mhd_gtls_cert_type_recv_params, 55 MHD_gtls_cert_type_recv_params,
56 mhd_gtls_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 mhd_gtls_server_name_recv_params, 59 MHD_gtls_server_name_recv_params,
60 mhd_gtls_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 mhd_gtls_oprfi_recv_params, 64 MHD_gtls_oprfi_recv_params,
65 mhd_gtls_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,
69 EXTENSION_TLS, 69 EXTENSION_TLS,
70 _gnutls_srp_recv_params, 70 MHD__gnutls_srp_recv_params,
71 _gnutls_srp_send_params), 71 MHD__gnutls_srp_send_params),
72#endif 72#endif
73 {0, 0, 0, 0} 73 {0, 0, 0, 0}
74}; 74};
75 75
76#define GNUTLS_EXTENSION_LOOP2(b) \ 76#define GNUTLS_EXTENSION_LOOP2(b) \
77 mhd_gtls_extension_entry *p; \ 77 MHD_gtls_extension_entry *p; \
78 for(p = mhd_gtls_extensions; p->name != NULL; p++) { b ; } 78 for(p = MHD_gtls_extensions; p->name != NULL; p++) { b ; }
79 79
80#define GNUTLS_EXTENSION_LOOP(a) \ 80#define GNUTLS_EXTENSION_LOOP(a) \
81 GNUTLS_EXTENSION_LOOP2( if(p->type == type) { a; break; } ) 81 GNUTLS_EXTENSION_LOOP2( if(p->type == type) { a; break; } )
@@ -83,29 +83,29 @@ mhd_gtls_extension_entry mhd_gtls_extensions[MAX_EXT_SIZE] = {
83 83
84/* EXTENSION functions */ 84/* EXTENSION functions */
85 85
86mhd_gtls_ext_recv_func 86MHD_gtls_ext_recv_func
87mhd_gtls_ext_func_recv (uint16_t type, mhd_gtls_ext_parse_type_t parse_type) 87MHD_gtls_ext_func_recv (uint16_t type, MHD_gtls_ext_parse_type_t parse_type)
88{ 88{
89 mhd_gtls_ext_recv_func ret = NULL; 89 MHD_gtls_ext_recv_func ret = NULL;
90 GNUTLS_EXTENSION_LOOP (if 90 GNUTLS_EXTENSION_LOOP (if
91 (parse_type == EXTENSION_ANY 91 (parse_type == EXTENSION_ANY
92 || p->parse_type == parse_type) ret = 92 || p->parse_type == parse_type) ret =
93 p->gnutls_ext_func_recv); 93 p->MHD_gnutls_ext_func_recv);
94 return ret; 94 return ret;
95 95
96} 96}
97 97
98mhd_gtls_ext_send_func 98MHD_gtls_ext_send_func
99mhd_gtls_ext_func_send (uint16_t type) 99MHD_gtls_ext_func_send (uint16_t type)
100{ 100{
101 mhd_gtls_ext_send_func ret = NULL; 101 MHD_gtls_ext_send_func ret = NULL;
102 GNUTLS_EXTENSION_LOOP (ret = p->gnutls_ext_func_send); 102 GNUTLS_EXTENSION_LOOP (ret = p->MHD_gnutls_ext_func_send);
103 return ret; 103 return ret;
104 104
105} 105}
106 106
107const char * 107const char *
108mhd_gtls_extension_get_name (uint16_t type) 108MHD_gtls_extension_get_name (uint16_t type)
109{ 109{
110 const char *ret = NULL; 110 const char *ret = NULL;
111 111
@@ -119,7 +119,7 @@ mhd_gtls_extension_get_name (uint16_t type)
119 * requested ones. Otherwise it's a fatal error. 119 * requested ones. Otherwise it's a fatal error.
120 */ 120 */
121static int 121static int
122_gnutls_extension_list_check (mhd_gtls_session_t session, uint16_t type) 122MHD__gnutls_extension_list_check (MHD_gtls_session_t session, uint16_t type)
123{ 123{
124#if MHD_DEBUG_TLS 124#if MHD_DEBUG_TLS
125 if (session->security_parameters.entity == GNUTLS_CLIENT) 125 if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -137,15 +137,15 @@ _gnutls_extension_list_check (mhd_gtls_session_t session, uint16_t type)
137} 137}
138 138
139int 139int
140mhd_gtls_parse_extensions (mhd_gtls_session_t session, 140MHD_gtls_parse_extensions (MHD_gtls_session_t session,
141 mhd_gtls_ext_parse_type_t parse_type, 141 MHD_gtls_ext_parse_type_t parse_type,
142 const opaque * data, int data_size) 142 const opaque * data, int data_size)
143{ 143{
144 int next, ret; 144 int next, ret;
145 int pos = 0; 145 int pos = 0;
146 uint16_t type; 146 uint16_t type;
147 const opaque *sdata; 147 const opaque *sdata;
148 mhd_gtls_ext_recv_func ext_recv; 148 MHD_gtls_ext_recv_func ext_recv;
149 uint16_t size; 149 uint16_t size;
150 150
151#if MHD_DEBUG_TLS 151#if MHD_DEBUG_TLS
@@ -153,15 +153,15 @@ mhd_gtls_parse_extensions (mhd_gtls_session_t session,
153 if (session->security_parameters.entity == GNUTLS_CLIENT) 153 if (session->security_parameters.entity == GNUTLS_CLIENT)
154 for (i = 0; i < session->internals.extensions_sent_size; i++) 154 for (i = 0; i < session->internals.extensions_sent_size; i++)
155 { 155 {
156 _gnutls_debug_log ("EXT[%d]: expecting extension '%s'\n", 156 MHD__gnutls_debug_log ("EXT[%d]: expecting extension '%s'\n",
157 session, 157 session,
158 mhd_gtls_extension_get_name 158 MHD_gtls_extension_get_name
159 (session->internals.extensions_sent[i])); 159 (session->internals.extensions_sent[i]));
160 } 160 }
161#endif 161#endif
162 162
163 DECR_LENGTH_RET (data_size, 2, 0); 163 DECR_LENGTH_RET (data_size, 2, 0);
164 next = mhd_gtls_read_uint16 (data); 164 next = MHD_gtls_read_uint16 (data);
165 pos += 2; 165 pos += 2;
166 166
167 DECR_LENGTH_RET (data_size, next, 0); 167 DECR_LENGTH_RET (data_size, next, 0);
@@ -169,32 +169,32 @@ mhd_gtls_parse_extensions (mhd_gtls_session_t session,
169 do 169 do
170 { 170 {
171 DECR_LENGTH_RET (next, 2, 0); 171 DECR_LENGTH_RET (next, 2, 0);
172 type = mhd_gtls_read_uint16 (&data[pos]); 172 type = MHD_gtls_read_uint16 (&data[pos]);
173 pos += 2; 173 pos += 2;
174 174
175 _gnutls_debug_log ("EXT[%x]: Received extension '%s/%d'\n", session, 175 MHD__gnutls_debug_log ("EXT[%x]: Received extension '%s/%d'\n", session,
176 mhd_gtls_extension_get_name (type), type); 176 MHD_gtls_extension_get_name (type), type);
177 177
178 if ((ret = _gnutls_extension_list_check (session, type)) < 0) 178 if ((ret = MHD__gnutls_extension_list_check (session, type)) < 0)
179 { 179 {
180 gnutls_assert (); 180 MHD_gnutls_assert ();
181 return ret; 181 return ret;
182 } 182 }
183 183
184 DECR_LENGTH_RET (next, 2, 0); 184 DECR_LENGTH_RET (next, 2, 0);
185 size = mhd_gtls_read_uint16 (&data[pos]); 185 size = MHD_gtls_read_uint16 (&data[pos]);
186 pos += 2; 186 pos += 2;
187 187
188 DECR_LENGTH_RET (next, size, 0); 188 DECR_LENGTH_RET (next, size, 0);
189 sdata = &data[pos]; 189 sdata = &data[pos];
190 pos += size; 190 pos += size;
191 191
192 ext_recv = mhd_gtls_ext_func_recv (type, parse_type); 192 ext_recv = MHD_gtls_ext_func_recv (type, parse_type);
193 if (ext_recv == NULL) 193 if (ext_recv == NULL)
194 continue; 194 continue;
195 if ((ret = ext_recv (session, sdata, size)) < 0) 195 if ((ret = ext_recv (session, sdata, size)) < 0)
196 { 196 {
197 gnutls_assert (); 197 MHD_gnutls_assert ();
198 return ret; 198 return ret;
199 } 199 }
200 200
@@ -210,7 +210,7 @@ mhd_gtls_parse_extensions (mhd_gtls_session_t session,
210 * extensions are the ones we requested. 210 * extensions are the ones we requested.
211 */ 211 */
212static void 212static void
213_gnutls_extension_list_add (mhd_gtls_session_t session, uint16_t type) 213MHD__gnutls_extension_list_add (MHD_gtls_session_t session, uint16_t type)
214{ 214{
215#if MHD_DEBUG_TLS 215#if MHD_DEBUG_TLS
216 if (session->security_parameters.entity == GNUTLS_CLIENT) 216 if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -223,43 +223,43 @@ _gnutls_extension_list_add (mhd_gtls_session_t session, uint16_t type)
223 } 223 }
224 else 224 else
225 { 225 {
226 _gnutls_debug_log ("extensions: Increase MAX_EXT_TYPES\n"); 226 MHD__gnutls_debug_log ("extensions: Increase MAX_EXT_TYPES\n");
227 } 227 }
228 } 228 }
229#endif 229#endif
230} 230}
231 231
232int 232int
233mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data, 233MHD_gtls_gen_extensions (MHD_gtls_session_t session, opaque * data,
234 size_t data_size) 234 size_t data_size)
235{ 235{
236 int size; 236 int size;
237 uint16_t pos = 0; 237 uint16_t pos = 0;
238 opaque *sdata; 238 opaque *sdata;
239 int sdata_size; 239 int sdata_size;
240 mhd_gtls_ext_send_func ext_send; 240 MHD_gtls_ext_send_func ext_send;
241 mhd_gtls_extension_entry *p; 241 MHD_gtls_extension_entry *p;
242 242
243 if (data_size < 2) 243 if (data_size < 2)
244 { 244 {
245 gnutls_assert (); 245 MHD_gnutls_assert ();
246 return GNUTLS_E_INTERNAL_ERROR; 246 return GNUTLS_E_INTERNAL_ERROR;
247 } 247 }
248 248
249 /* allocate enough data for each extension. 249 /* allocate enough data for each extension.
250 */ 250 */
251 sdata_size = data_size; 251 sdata_size = data_size;
252 sdata = gnutls_malloc (sdata_size); 252 sdata = MHD_gnutls_malloc (sdata_size);
253 if (sdata == NULL) 253 if (sdata == NULL)
254 { 254 {
255 gnutls_assert (); 255 MHD_gnutls_assert ();
256 return GNUTLS_E_MEMORY_ERROR; 256 return GNUTLS_E_MEMORY_ERROR;
257 } 257 }
258 258
259 pos += 2; 259 pos += 2;
260 for (p = mhd_gtls_extensions; p->name != NULL; p++) 260 for (p = MHD_gtls_extensions; p->name != NULL; p++)
261 { 261 {
262 ext_send = mhd_gtls_ext_func_send (p->type); 262 ext_send = MHD_gtls_ext_func_send (p->type);
263 if (ext_send == NULL) 263 if (ext_send == NULL)
264 continue; 264 continue;
265 size = ext_send (session, sdata, sdata_size); 265 size = ext_send (session, sdata, sdata_size);
@@ -267,17 +267,17 @@ mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
267 { 267 {
268 if (data_size < pos + (size_t) size + 4) 268 if (data_size < pos + (size_t) size + 4)
269 { 269 {
270 gnutls_assert (); 270 MHD_gnutls_assert ();
271 gnutls_free (sdata); 271 MHD_gnutls_free (sdata);
272 return GNUTLS_E_INTERNAL_ERROR; 272 return GNUTLS_E_INTERNAL_ERROR;
273 } 273 }
274 274
275 /* write extension type */ 275 /* write extension type */
276 mhd_gtls_write_uint16 (p->type, &data[pos]); 276 MHD_gtls_write_uint16 (p->type, &data[pos]);
277 pos += 2; 277 pos += 2;
278 278
279 /* write size */ 279 /* write size */
280 mhd_gtls_write_uint16 (size, &data[pos]); 280 MHD_gtls_write_uint16 (size, &data[pos]);
281 pos += 2; 281 pos += 2;
282 282
283 memcpy (&data[pos], sdata, size); 283 memcpy (&data[pos], sdata, size);
@@ -285,15 +285,15 @@ mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
285 285
286 /* add this extension to the extension list 286 /* add this extension to the extension list
287 */ 287 */
288 _gnutls_extension_list_add (session, p->type); 288 MHD__gnutls_extension_list_add (session, p->type);
289 289
290 _gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session, 290 MHD__gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session,
291 mhd_gtls_extension_get_name (p->type)); 291 MHD_gtls_extension_get_name (p->type));
292 } 292 }
293 else if (size < 0) 293 else if (size < 0)
294 { 294 {
295 gnutls_assert (); 295 MHD_gnutls_assert ();
296 gnutls_free (sdata); 296 MHD_gnutls_free (sdata);
297 return size; 297 return size;
298 } 298 }
299 } 299 }
@@ -301,14 +301,14 @@ mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
301 size = pos; 301 size = pos;
302 pos -= 2; /* remove the size of the size header! */ 302 pos -= 2; /* remove the size of the size header! */
303 303
304 mhd_gtls_write_uint16 (pos, data); 304 MHD_gtls_write_uint16 (pos, data);
305 305
306 if (size == 2) 306 if (size == 2)
307 { /* empty */ 307 { /* empty */
308 size = 0; 308 size = 0;
309 } 309 }
310 310
311 gnutls_free (sdata); 311 MHD_gnutls_free (sdata);
312 return size; 312 return size;
313 313
314} 314}
diff --git a/src/daemon/https/tls/gnutls_extensions.h b/src/daemon/https/tls/gnutls_extensions.h
index 52604067..9623b39b 100644
--- a/src/daemon/https/tls/gnutls_extensions.h
+++ b/src/daemon/https/tls/gnutls_extensions.h
@@ -24,24 +24,24 @@
24 24
25#include <gnutls_int.h> 25#include <gnutls_int.h>
26 26
27const char *mhd_gtls_extension_get_name (uint16_t type); 27const char *MHD_gtls_extension_get_name (uint16_t type);
28int mhd_gtls_parse_extensions (mhd_gtls_session_t, mhd_gtls_ext_parse_type_t, 28int MHD_gtls_parse_extensions (MHD_gtls_session_t, MHD_gtls_ext_parse_type_t,
29 const opaque *, int); 29 const opaque *, int);
30int mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data, 30int MHD_gtls_gen_extensions (MHD_gtls_session_t session, opaque * data,
31 size_t data_size); 31 size_t data_size);
32 32
33typedef int (*mhd_gtls_ext_recv_func) (mhd_gtls_session_t, const opaque *, size_t); /* recv data */ 33typedef int (*MHD_gtls_ext_recv_func) (MHD_gtls_session_t, const opaque *, size_t); /* recv data */
34typedef int (*mhd_gtls_ext_send_func) (mhd_gtls_session_t, opaque *, size_t); /* send data */ 34typedef int (*MHD_gtls_ext_send_func) (MHD_gtls_session_t, opaque *, size_t); /* send data */
35 35
36mhd_gtls_ext_send_func mhd_gtls_ext_func_send (uint16_t type); 36MHD_gtls_ext_send_func MHD_gtls_ext_func_send (uint16_t type);
37mhd_gtls_ext_recv_func mhd_gtls_ext_func_recv (uint16_t type, 37MHD_gtls_ext_recv_func MHD_gtls_ext_func_recv (uint16_t type,
38 mhd_gtls_ext_parse_type_t); 38 MHD_gtls_ext_parse_type_t);
39 39
40typedef struct 40typedef struct
41{ 41{
42 const char *name; 42 const char *name;
43 uint16_t type; 43 uint16_t type;
44 mhd_gtls_ext_parse_type_t parse_type; 44 MHD_gtls_ext_parse_type_t parse_type;
45 mhd_gtls_ext_recv_func gnutls_ext_func_recv; 45 MHD_gtls_ext_recv_func MHD_gnutls_ext_func_recv;
46 mhd_gtls_ext_send_func gnutls_ext_func_send; 46 MHD_gtls_ext_send_func MHD_gnutls_ext_func_send;
47} mhd_gtls_extension_entry; 47} MHD_gtls_extension_entry;
diff --git a/src/daemon/https/tls/gnutls_global.c b/src/daemon/https/tls/gnutls_global.c
index b252b127..781d12fa 100644
--- a/src/daemon/https/tls/gnutls_global.c
+++ b/src/daemon/https/tls/gnutls_global.c
@@ -44,17 +44,17 @@
44 44
45GCRY_THREAD_OPTION_PTHREAD_IMPL; 45GCRY_THREAD_OPTION_PTHREAD_IMPL;
46 46
47#define gnutls_log_func LOG_FUNC 47#define MHD_gnutls_log_func LOG_FUNC
48 48
49/* created by asn1c */ 49/* created by asn1c */
50extern const ASN1_ARRAY_TYPE gnutls_asn1_tab[]; 50extern const ASN1_ARRAY_TYPE MHD_gnutlsMHD__asn1_tab[];
51extern const ASN1_ARRAY_TYPE pkix_asn1_tab[]; 51extern const ASN1_ARRAY_TYPE MHD_pkix_asn1_tab[];
52 52
53LOG_FUNC _gnutls_log_func; 53LOG_FUNC MHD__gnutls_log_func;
54int _gnutls_log_level = 0; /* default log level */ 54int MHD__gnutls_log_level = 0; /* default log level */
55 55
56ASN1_TYPE _gnutls_pkix1_asn; 56ASN1_TYPE MHD__gnutls_pkix1_asn;
57ASN1_TYPE _gnutls_gnutls_asn; 57ASN1_TYPE MHD__gnutlsMHD__gnutls_asn;
58 58
59/** 59/**
60 * MHD_gtls_global_set_log_function - This function sets the logging function 60 * MHD_gtls_global_set_log_function - This function sets the logging function
@@ -65,13 +65,13 @@ ASN1_TYPE _gnutls_gnutls_asn;
65 * Normally you may not use this function since it is only used 65 * Normally you may not use this function since it is only used
66 * for debugging purposes. 66 * for debugging purposes.
67 * 67 *
68 * gnutls_log_func is of the form, 68 * MHD_gnutls_log_func is of the form,
69 * void (*gnutls_log_func)( int level, const char*); 69 * void (*MHD_gnutls_log_func)( int level, const char*);
70 **/ 70 **/
71void 71void
72MHD_gtls_global_set_log_function (gnutls_log_func log_func) 72MHD_gtls_global_set_log_function (MHD_gnutls_log_func log_func)
73{ 73{
74 _gnutls_log_func = log_func; 74 MHD__gnutls_log_func = log_func;
75} 75}
76 76
77/** 77/**
@@ -89,10 +89,10 @@ MHD_gtls_global_set_log_function (gnutls_log_func log_func)
89void 89void
90MHD_gtls_global_set_log_level (int level) 90MHD_gtls_global_set_log_level (int level)
91{ 91{
92 _gnutls_log_level = level; 92 MHD__gnutls_log_level = level;
93} 93}
94 94
95int _gnutls_is_secure_mem_null (const void *); 95int MHD__gnutls_is_secure_mem_null (const void *);
96 96
97/** 97/**
98 * MHD_gtls_global_set_mem_functions - This function sets the memory allocation functions 98 * MHD_gtls_global_set_mem_functions - This function sets the memory allocation functions
@@ -108,61 +108,61 @@ int _gnutls_is_secure_mem_null (const void *);
108 * This function is provided to set the memory allocation functions to 108 * This function is provided to set the memory allocation functions to
109 * something other than the defaults (ie the gcrypt allocation functions). 109 * something other than the defaults (ie the gcrypt allocation functions).
110 * 110 *
111 * This function must be called before MHD_gnutls_global_init() is called. 111 * This function must be called before MHD__gnutls_global_init() is called.
112 * 112 *
113 **/ 113 **/
114void 114void
115MHD_gtls_global_set_mem_functions (gnutls_alloc_function alloc_func, 115MHD_gtls_global_set_mem_functions (MHD_gnutls_alloc_function alloc_func,
116 gnutls_alloc_function 116 MHD_gnutls_alloc_function
117 secure_alloc_func, 117 secure_alloc_func,
118 gnutls_is_secure_function 118 MHD_gnutls_is_secure_function
119 is_secure_func, 119 is_secure_func,
120 gnutls_realloc_function realloc_func, 120 MHD_gnutls_realloc_function realloc_func,
121 gnutls_free_function free_func) 121 MHD_gnutls_free_function free_func)
122{ 122{
123 gnutls_secure_malloc = secure_alloc_func; 123 MHD_gnutls_secure_malloc = secure_alloc_func;
124 gnutls_malloc = alloc_func; 124 MHD_gnutls_malloc = alloc_func;
125 gnutls_realloc = realloc_func; 125 MHD_gnutls_realloc = realloc_func;
126 gnutls_free = free_func; 126 MHD_gnutls_free = free_func;
127 127
128 if (is_secure_func != NULL) 128 if (is_secure_func != NULL)
129 _gnutls_is_secure_memory = is_secure_func; 129 MHD__gnutls_is_secure_memory = is_secure_func;
130 else 130 else
131 _gnutls_is_secure_memory = _gnutls_is_secure_mem_null; 131 MHD__gnutls_is_secure_memory = MHD__gnutls_is_secure_mem_null;
132 132
133 /* if using the libc's default malloc 133 /* if using the libc's default malloc
134 * use libc's calloc as well. 134 * use libc's calloc as well.
135 */ 135 */
136 if (gnutls_malloc == malloc) 136 if (MHD_gnutls_malloc == malloc)
137 { 137 {
138 gnutls_calloc = calloc; 138 MHD_gnutls_calloc = calloc;
139 } 139 }
140 else 140 else
141 { /* use the included ones */ 141 { /* use the included ones */
142 gnutls_calloc = mhd_gtls_calloc; 142 MHD_gnutls_calloc = MHD_gtls_calloc;
143 } 143 }
144 gnutls_strdup = mhd_gtls_strdup; 144 MHD_gnutls_strdup = MHD_gtls_strdup;
145 145
146} 146}
147 147
148#ifdef DEBUG 148#ifdef DEBUG
149static void 149static void
150_gnutls_gcry_log_handler (void *dummy, int level, 150MHD__gnutls_gcry_log_handler (void *dummy, int level,
151 const char *fmt, va_list list) 151 const char *fmt, va_list list)
152{ 152{
153 mhd_gtls_log (level, fmt, list); 153 MHD_gtls_log (level, fmt, list);
154} 154}
155#endif 155#endif
156 156
157static int _gnutls_init = 0; 157static int MHD__gnutls_init_level = 0;
158 158
159/** 159/**
160 * MHD_gnutls_global_init - This function initializes the global data to defaults. 160 * MHD__gnutls_global_init - This function initializes the global data to defaults.
161 * 161 *
162 * This function initializes the global data to defaults. 162 * This function initializes the global data to defaults.
163 * Every gnutls application has a global data which holds common parameters 163 * Every gnutls application has a global data which holds common parameters
164 * shared by gnutls session structures. 164 * shared by gnutls session structures.
165 * You must call MHD_gnutls_global_deinit() when gnutls usage is no longer needed 165 * You must call MHD__gnutls_global_deinit() when gnutls usage is no longer needed
166 * Returns zero on success. 166 * Returns zero on success.
167 * 167 *
168 * Note that this function will also initialize libgcrypt, if it has not 168 * Note that this function will also initialize libgcrypt, if it has not
@@ -171,8 +171,8 @@ static int _gnutls_init = 0;
171 * want to disable libgcrypt's internal lockings etc. 171 * want to disable libgcrypt's internal lockings etc.
172 * 172 *
173 * This function increment a global counter, so that 173 * This function increment a global counter, so that
174 * MHD_gnutls_global_deinit() only releases resources when it has been 174 * MHD__gnutls_global_deinit() only releases resources when it has been
175 * called as many times as MHD_gnutls_global_init(). This is useful when 175 * called as many times as MHD__gnutls_global_init(). This is useful when
176 * GnuTLS is used by more than one library in an application. This 176 * GnuTLS is used by more than one library in an application. This
177 * function can be called many times, but will only do something the 177 * function can be called many times, but will only do something the
178 * first time. 178 * first time.
@@ -187,13 +187,13 @@ static int _gnutls_init = 0;
187 * 187 *
188 **/ 188 **/
189int 189int
190MHD_gnutls_global_init (void) 190MHD__gnutls_global_init (void)
191{ 191{
192 int result = 0; 192 int result = 0;
193 int res; 193 int res;
194 char c; 194 char c;
195 195
196 if (_gnutls_init++) 196 if (MHD__gnutls_init_level++)
197 return 0; 197 return 0;
198 198
199#if HAVE_WINSOCK 199#if HAVE_WINSOCK
@@ -206,13 +206,13 @@ MHD_gnutls_global_init (void)
206 err = WSAStartup (requested, &data); 206 err = WSAStartup (requested, &data);
207 if (err != 0) 207 if (err != 0)
208 { 208 {
209 _gnutls_debug_log ("WSAStartup failed: %d.\n", err); 209 MHD__gnutls_debug_log ("WSAStartup failed: %d.\n", err);
210 return GNUTLS_E_LIBRARY_VERSION_MISMATCH; 210 return GNUTLS_E_LIBRARY_VERSION_MISMATCH;
211 } 211 }
212 212
213 if (data.wVersion < requested) 213 if (data.wVersion < requested)
214 { 214 {
215 _gnutls_debug_log ("WSAStartup version check failed (%d < %d).\n", 215 MHD__gnutls_debug_log ("WSAStartup version check failed (%d < %d).\n",
216 data.wVersion, requested); 216 data.wVersion, requested);
217 WSACleanup (); 217 WSACleanup ();
218 return GNUTLS_E_LIBRARY_VERSION_MISMATCH; 218 return GNUTLS_E_LIBRARY_VERSION_MISMATCH;
@@ -239,15 +239,15 @@ MHD_gnutls_global_init (void)
239 /* this call initializes libgcrypt */ 239 /* this call initializes libgcrypt */
240 if (gcry_check_version (p) == NULL) 240 if (gcry_check_version (p) == NULL)
241 { 241 {
242 gnutls_assert (); 242 MHD_gnutls_assert ();
243 _gnutls_debug_log ("Checking for libgcrypt failed '%s'\n", p); 243 MHD__gnutls_debug_log ("Checking for libgcrypt failed '%s'\n", p);
244 return GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY; 244 return GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY;
245 } 245 }
246 246
247 /* for gcrypt in order to be able to allocate memory */ 247 /* for gcrypt in order to be able to allocate memory */
248 gcry_set_allocation_handler (gnutls_malloc, gnutls_secure_malloc, 248 gcry_set_allocation_handler (MHD_gnutls_malloc, MHD_gnutls_secure_malloc,
249 _gnutls_is_secure_memory, gnutls_realloc, 249 MHD__gnutls_is_secure_memory, MHD_gnutls_realloc,
250 gnutls_free); 250 MHD_gnutls_free);
251 251
252 /* gcry_control (GCRYCTL_DISABLE_INTERNAL_LOCKING, NULL, 0); */ 252 /* gcry_control (GCRYCTL_DISABLE_INTERNAL_LOCKING, NULL, 0); */
253 253
@@ -257,14 +257,14 @@ MHD_gnutls_global_init (void)
257 /* applications may want to override that, so we only use 257 /* applications may want to override that, so we only use
258 * it in debugging mode. 258 * it in debugging mode.
259 */ 259 */
260 gcry_set_log_handler (_gnutls_gcry_log_handler, NULL); 260 gcry_set_log_handler (MHD__gnutls_gcry_log_handler, NULL);
261#endif 261#endif
262 } 262 }
263 263
264 if (gc_init () != GC_OK) 264 if (MHD_gc_init () != GC_OK)
265 { 265 {
266 gnutls_assert (); 266 MHD_gnutls_assert ();
267 _gnutls_debug_log ("Initializing crypto backend failed\n"); 267 MHD__gnutls_debug_log ("Initializing crypto backend failed\n");
268 return GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY; 268 return GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY;
269 } 269 }
270 270
@@ -276,50 +276,50 @@ MHD_gnutls_global_init (void)
276 * This should not deal with files in the final 276 * This should not deal with files in the final
277 * version. 277 * version.
278 */ 278 */
279 res = asn1_array2tree (pkix_asn1_tab, &_gnutls_pkix1_asn, NULL); 279 res = MHD__asn1_array2tree (MHD_pkix_asn1_tab, &MHD__gnutls_pkix1_asn, NULL);
280 if (res != ASN1_SUCCESS) 280 if (res != ASN1_SUCCESS)
281 { 281 {
282 result = mhd_gtls_asn2err (res); 282 result = MHD_gtls_asn2err (res);
283 return result; 283 return result;
284 } 284 }
285 285
286 res = asn1_array2tree (gnutls_asn1_tab, &_gnutls_gnutls_asn, NULL); 286 res = MHD__asn1_array2tree (MHD_gnutlsMHD__asn1_tab, &MHD__gnutlsMHD__gnutls_asn, NULL);
287 if (res != ASN1_SUCCESS) 287 if (res != ASN1_SUCCESS)
288 { 288 {
289 asn1_delete_structure (&_gnutls_pkix1_asn); 289 MHD__asn1_delete_structure (&MHD__gnutls_pkix1_asn);
290 result = mhd_gtls_asn2err (res); 290 result = MHD_gtls_asn2err (res);
291 return result; 291 return result;
292 } 292 }
293 293
294 /* Initialize the gcrypt (if used random generator) */ 294 /* Initialize the gcrypt (if used random generator) */
295 gc_pseudo_random (&c, 1); 295 MHD_gc_pseudo_random (&c, 1);
296 296
297 return result; 297 return result;
298} 298}
299 299
300/** 300/**
301 * MHD_gnutls_global_deinit - This function deinitializes the global data 301 * MHD__gnutls_global_deinit - This function deinitializes the global data
302 * 302 *
303 * This function deinitializes the global data, that were initialized 303 * This function deinitializes the global data, that were initialized
304 * using MHD_gnutls_global_init(). 304 * using MHD__gnutls_global_init().
305 * 305 *
306 * Note! This function is not thread safe. See the discussion for 306 * Note! This function is not thread safe. See the discussion for
307 * MHD_gnutls_global_init() for more information. 307 * MHD__gnutls_global_init() for more information.
308 * 308 *
309 **/ 309 **/
310void 310void
311MHD_gnutls_global_deinit (void) 311MHD__gnutls_global_deinit (void)
312{ 312{
313 if (_gnutls_init == 1) 313 if (MHD__gnutls_init_level == 1)
314 { 314 {
315#if HAVE_WINSOCK 315#if HAVE_WINSOCK
316 WSACleanup (); 316 WSACleanup ();
317#endif 317#endif
318 asn1_delete_structure (&_gnutls_gnutls_asn); 318 MHD__asn1_delete_structure (&MHD__gnutlsMHD__gnutls_asn);
319 asn1_delete_structure (&_gnutls_pkix1_asn); 319 MHD__asn1_delete_structure (&MHD__gnutls_pkix1_asn);
320 gc_done (); 320 MHD_gc_done ();
321 } 321 }
322 _gnutls_init--; 322 MHD__gnutls_init_level--;
323} 323}
324 324
325/* These functions should be elsewere. Kept here for 325/* These functions should be elsewere. Kept here for
@@ -327,7 +327,7 @@ MHD_gnutls_global_deinit (void)
327 */ 327 */
328 328
329/** 329/**
330 * MHD_gnutls_transport_set_pull_function - This function sets a read like function 330 * MHD__gnutls_transport_set_pull_function - This function sets a read like function
331 * @pull_func: a callback function similar to read() 331 * @pull_func: a callback function similar to read()
332 * @session: gnutls session 332 * @session: gnutls session
333 * 333 *
@@ -337,17 +337,17 @@ MHD_gnutls_global_deinit (void)
337 * probably be ok. 337 * probably be ok.
338 * 338 *
339 * PULL_FUNC is of the form, 339 * PULL_FUNC is of the form,
340 * ssize_t (*mhd_gtls_pull_func)(gnutls_transport_ptr_t, void*, size_t); 340 * ssize_t (*MHD_gtls_pull_func)(MHD_gnutls_transport_ptr_t, void*, size_t);
341 **/ 341 **/
342void 342void
343MHD_gnutls_transport_set_pull_function (mhd_gtls_session_t session, 343MHD__gnutls_transport_set_pull_function (MHD_gtls_session_t session,
344 mhd_gtls_pull_func pull_func) 344 MHD_gtls_pull_func pull_func)
345{ 345{
346 session->internals._gnutls_pull_func = pull_func; 346 session->internals.MHD__gnutls_pull_func = pull_func;
347} 347}
348 348
349/** 349/**
350 * MHD_gnutls_transport_set_push_function - This function sets the function to send data 350 * MHD__gnutls_transport_set_push_function - This function sets the function to send data
351 * @push_func: a callback function similar to write() 351 * @push_func: a callback function similar to write()
352 * @session: gnutls session 352 * @session: gnutls session
353 * 353 *
@@ -358,11 +358,11 @@ MHD_gnutls_transport_set_pull_function (mhd_gtls_session_t session,
358 * specify this function for gnutls to be able to send data. 358 * specify this function for gnutls to be able to send data.
359 * 359 *
360 * PUSH_FUNC is of the form, 360 * PUSH_FUNC is of the form,
361 * ssize_t (*mhd_gtls_push_func)(gnutls_transport_ptr_t, const void*, size_t); 361 * ssize_t (*MHD_gtls_push_func)(MHD_gnutls_transport_ptr_t, const void*, size_t);
362 **/ 362 **/
363void 363void
364MHD_gnutls_transport_set_push_function (mhd_gtls_session_t session, 364MHD__gnutls_transport_set_push_function (MHD_gtls_session_t session,
365 mhd_gtls_push_func push_func) 365 MHD_gtls_push_func push_func)
366{ 366{
367 session->internals._gnutls_push_func = push_func; 367 session->internals.MHD__gnutls_push_func = push_func;
368} 368}
diff --git a/src/daemon/https/tls/gnutls_global.h b/src/daemon/https/tls/gnutls_global.h
index 7ec40882..8cfaf0ca 100644
--- a/src/daemon/https/tls/gnutls_global.h
+++ b/src/daemon/https/tls/gnutls_global.h
@@ -27,19 +27,19 @@
27 27
28#include <libtasn1.h> 28#include <libtasn1.h>
29 29
30/* this mutex is used to synchronize threads attemting call MHD_gnutls_global_init / MHD_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 MHD_gnutls_init_mutex;
32 32
33int gnutls_is_secure_memory (const void *mem); 33int MHD_gnutls_is_secure_memory (const void *mem);
34 34
35extern ASN1_TYPE _gnutls_pkix1_asn; 35extern ASN1_TYPE MHD__gnutls_pkix1_asn;
36extern ASN1_TYPE _gnutls_gnutls_asn; 36extern ASN1_TYPE MHD__gnutlsMHD__gnutls_asn;
37 37
38/* removed const from node_asn* to 38/* removed const from node_asn* to
39 * prevent warnings, since libtasn1 doesn't 39 * prevent warnings, since libtasn1 doesn't
40 * use the const keywork in its functions. 40 * use the const keywork in its functions.
41 */ 41 */
42#define _gnutls_get_gnutls_asn() ((node_asn*) _gnutls_gnutls_asn) 42#define MHD__gnutls_getMHD__gnutls_asn() ((node_asn*) MHD__gnutlsMHD__gnutls_asn)
43#define _gnutls_get_pkix() ((node_asn*) _gnutls_pkix1_asn) 43#define MHD__gnutls_get_pkix() ((node_asn*) MHD__gnutls_pkix1_asn)
44 44
45#endif 45#endif
diff --git a/src/daemon/https/tls/gnutls_handshake.c b/src/daemon/https/tls/gnutls_handshake.c
index e53d6985..31826448 100644
--- a/src/daemon/https/tls/gnutls_handshake.c
+++ b/src/daemon/https/tls/gnutls_handshake.c
@@ -46,12 +46,12 @@
46#include "gnutls_constate.h" 46#include "gnutls_constate.h"
47#include "gnutls_record.h" 47#include "gnutls_record.h"
48#include "gnutls_state.h" 48#include "gnutls_state.h"
49#include "gnutls_rsa_export.h" /* for gnutls_get_rsa_params() */ 49#include "gnutls_rsa_export.h" /* for MHD_gnutls_get_rsa_params() */
50#include "auth_anon.h" /* for mhd_gtls_anon_server_credentials_t */ 50#include "auth_anon.h" /* for MHD_gtls_anon_server_credentials_t */
51#include "gc.h" 51#include "gc.h"
52 52
53#ifdef HANDSHAKE_DEBUG 53#ifdef HANDSHAKE_DEBUG
54#define ERR(x, y) _gnutls_handshake_log( "HSK[%x]: %s (%d)\n", session, x,y) 54#define ERR(x, y) MHD__gnutls_handshake_log( "HSK[%x]: %s (%d)\n", session, x,y)
55#else 55#else
56#define ERR(x, y) 56#define ERR(x, y)
57#endif 57#endif
@@ -59,20 +59,20 @@
59#define TRUE 1 59#define TRUE 1
60#define FALSE 0 60#define FALSE 0
61 61
62static int _gnutls_server_select_comp_method (mhd_gtls_session_t session, 62static int MHD__gnutls_server_select_comp_method (MHD_gtls_session_t session,
63 opaque * data, int datalen); 63 opaque * data, int datalen);
64 64
65 65
66/* Clears the handshake hash buffers and handles. 66/* Clears the handshake hash buffers and handles.
67 */ 67 */
68inline static void 68inline static void
69_gnutls_handshake_hash_buffers_clear (mhd_gtls_session_t session) 69MHD__gnutls_handshake_hash_buffers_clear (MHD_gtls_session_t session)
70{ 70{
71 mhd_gnutls_hash_deinit (session->internals.handshake_mac_handle_md5, NULL); 71 MHD_gnutls_hash_deinit (session->internals.handshake_mac_handle_md5, NULL);
72 mhd_gnutls_hash_deinit (session->internals.handshake_mac_handle_sha, NULL); 72 MHD_gnutls_hash_deinit (session->internals.handshake_mac_handle_sha, NULL);
73 session->internals.handshake_mac_handle_md5 = NULL; 73 session->internals.handshake_mac_handle_md5 = NULL;
74 session->internals.handshake_mac_handle_sha = NULL; 74 session->internals.handshake_mac_handle_sha = NULL;
75 mhd_gtls_handshake_buffer_clear (session); 75 MHD_gtls_handshake_buffer_clear (session);
76} 76}
77 77
78/* this will copy the required values for resuming to 78/* this will copy the required values for resuming to
@@ -80,7 +80,7 @@ _gnutls_handshake_hash_buffers_clear (mhd_gtls_session_t session)
80 * this will keep as less data to security_parameters. 80 * this will keep as less data to security_parameters.
81 */ 81 */
82static void 82static void
83resume_copy_required_values (mhd_gtls_session_t session) 83resume_copy_required_values (MHD_gtls_session_t session)
84{ 84{
85 /* get the new random values */ 85 /* get the new random values */
86 memcpy (session->internals.resumed_security_parameters.server_random, 86 memcpy (session->internals.resumed_security_parameters.server_random,
@@ -105,7 +105,7 @@ resume_copy_required_values (mhd_gtls_session_t session)
105 session->security_parameters.entity = 105 session->security_parameters.entity =
106 session->internals.resumed_security_parameters.entity; 106 session->internals.resumed_security_parameters.entity;
107 107
108 mhd_gtls_set_current_version (session, 108 MHD_gtls_set_current_version (session,
109 session->internals. 109 session->internals.
110 resumed_security_parameters.version); 110 resumed_security_parameters.version);
111 111
@@ -120,13 +120,13 @@ resume_copy_required_values (mhd_gtls_session_t session)
120} 120}
121 121
122void 122void
123mhd_gtls_set_server_random (mhd_gtls_session_t session, uint8_t * rnd) 123MHD_gtls_set_server_random (MHD_gtls_session_t session, uint8_t * rnd)
124{ 124{
125 memcpy (session->security_parameters.server_random, rnd, TLS_RANDOM_SIZE); 125 memcpy (session->security_parameters.server_random, rnd, TLS_RANDOM_SIZE);
126} 126}
127 127
128void 128void
129mhd_gtls_set_client_random (mhd_gtls_session_t session, uint8_t * rnd) 129MHD_gtls_set_client_random (MHD_gtls_session_t session, uint8_t * rnd)
130{ 130{
131 memcpy (session->security_parameters.client_random, rnd, TLS_RANDOM_SIZE); 131 memcpy (session->security_parameters.client_random, rnd, TLS_RANDOM_SIZE);
132} 132}
@@ -136,25 +136,25 @@ mhd_gtls_set_client_random (mhd_gtls_session_t session, uint8_t * rnd)
136#define SSL3_SERVER_MSG "SRVR" 136#define SSL3_SERVER_MSG "SRVR"
137#define SSL_MSG_LEN 4 137#define SSL_MSG_LEN 4
138static int 138static int
139_gnutls_ssl3_finished (mhd_gtls_session_t session, int type, opaque * ret) 139MHD__gnutls_ssl3_finished (MHD_gtls_session_t session, int type, opaque * ret)
140{ 140{
141 const int siz = SSL_MSG_LEN; 141 const int siz = SSL_MSG_LEN;
142 mac_hd_t td_md5; 142 mac_hd_t td_md5;
143 mac_hd_t td_sha; 143 mac_hd_t td_sha;
144 const char *mesg; 144 const char *mesg;
145 145
146 td_md5 = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5); 146 td_md5 = MHD_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
147 if (td_md5 == NULL) 147 if (td_md5 == NULL)
148 { 148 {
149 gnutls_assert (); 149 MHD_gnutls_assert ();
150 return GNUTLS_E_HASH_FAILED; 150 return GNUTLS_E_HASH_FAILED;
151 } 151 }
152 152
153 td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha); 153 td_sha = MHD_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
154 if (td_sha == NULL) 154 if (td_sha == NULL)
155 { 155 {
156 gnutls_assert (); 156 MHD_gnutls_assert ();
157 mhd_gnutls_hash_deinit (td_md5, NULL); 157 MHD_gnutls_hash_deinit (td_md5, NULL);
158 return GNUTLS_E_HASH_FAILED; 158 return GNUTLS_E_HASH_FAILED;
159 } 159 }
160 160
@@ -167,13 +167,13 @@ _gnutls_ssl3_finished (mhd_gtls_session_t session, int type, opaque * ret)
167 mesg = SSL3_CLIENT_MSG; 167 mesg = SSL3_CLIENT_MSG;
168 } 168 }
169 169
170 mhd_gnutls_hash (td_md5, mesg, siz); 170 MHD_gnutls_hash (td_md5, mesg, siz);
171 mhd_gnutls_hash (td_sha, mesg, siz); 171 MHD_gnutls_hash (td_sha, mesg, siz);
172 172
173 mhd_gnutls_mac_deinit_ssl3_handshake (td_md5, ret, 173 MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, ret,
174 session->security_parameters. 174 session->security_parameters.
175 master_secret, TLS_MASTER_SIZE); 175 master_secret, TLS_MASTER_SIZE);
176 mhd_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16], 176 MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16],
177 session->security_parameters. 177 session->security_parameters.
178 master_secret, TLS_MASTER_SIZE); 178 master_secret, TLS_MASTER_SIZE);
179 179
@@ -185,7 +185,7 @@ _gnutls_ssl3_finished (mhd_gtls_session_t session, int type, opaque * ret)
185#define CLIENT_MSG "client finished" 185#define CLIENT_MSG "client finished"
186#define TLS_MSG_LEN 15 186#define TLS_MSG_LEN 15
187static int 187static int
188_gnutls_finished (mhd_gtls_session_t session, int type, void *ret) 188MHD__gnutls_finished (MHD_gtls_session_t session, int type, void *ret)
189{ 189{
190 const int siz = TLS_MSG_LEN; 190 const int siz = TLS_MSG_LEN;
191 opaque concat[36]; 191 opaque concat[36];
@@ -193,37 +193,37 @@ _gnutls_finished (mhd_gtls_session_t session, int type, void *ret)
193 const char *mesg; 193 const char *mesg;
194 mac_hd_t td_md5 = NULL; 194 mac_hd_t td_md5 = NULL;
195 mac_hd_t td_sha; 195 mac_hd_t td_sha;
196 enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); 196 enum MHD_GNUTLS_Protocol ver = MHD__gnutls_protocol_get_version (session);
197 197
198 if (ver < MHD_GNUTLS_PROTOCOL_TLS1_2) 198 if (ver < MHD_GNUTLS_PROTOCOL_TLS1_2)
199 { 199 {
200 td_md5 = 200 td_md5 =
201 mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5); 201 MHD_gnutls_hash_copy (session->internals.handshake_mac_handle_md5);
202 if (td_md5 == NULL) 202 if (td_md5 == NULL)
203 { 203 {
204 gnutls_assert (); 204 MHD_gnutls_assert ();
205 return GNUTLS_E_HASH_FAILED; 205 return GNUTLS_E_HASH_FAILED;
206 } 206 }
207 } 207 }
208 208
209 td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha); 209 td_sha = MHD_gnutls_hash_copy (session->internals.handshake_mac_handle_sha);
210 if (td_sha == NULL) 210 if (td_sha == NULL)
211 { 211 {
212 gnutls_assert (); 212 MHD_gnutls_assert ();
213 if (td_md5 != NULL) 213 if (td_md5 != NULL)
214 mhd_gnutls_hash_deinit (td_md5, NULL); 214 MHD_gnutls_hash_deinit (td_md5, NULL);
215 return GNUTLS_E_HASH_FAILED; 215 return GNUTLS_E_HASH_FAILED;
216 } 216 }
217 217
218 if (ver < MHD_GNUTLS_PROTOCOL_TLS1_2) 218 if (ver < MHD_GNUTLS_PROTOCOL_TLS1_2)
219 { 219 {
220 mhd_gnutls_hash_deinit (td_md5, concat); 220 MHD_gnutls_hash_deinit (td_md5, concat);
221 mhd_gnutls_hash_deinit (td_sha, &concat[16]); 221 MHD_gnutls_hash_deinit (td_sha, &concat[16]);
222 len = 20 + 16; 222 len = 20 + 16;
223 } 223 }
224 else 224 else
225 { 225 {
226 mhd_gnutls_hash_deinit (td_sha, concat); 226 MHD_gnutls_hash_deinit (td_sha, concat);
227 len = 20; 227 len = 20;
228 } 228 }
229 229
@@ -236,7 +236,7 @@ _gnutls_finished (mhd_gtls_session_t session, int type, void *ret)
236 mesg = CLIENT_MSG; 236 mesg = CLIENT_MSG;
237 } 237 }
238 238
239 return mhd_gtls_PRF (session, session->security_parameters.master_secret, 239 return MHD_gtls_PRF (session, session->security_parameters.master_secret,
240 TLS_MASTER_SIZE, mesg, siz, concat, len, 12, ret); 240 TLS_MASTER_SIZE, mesg, siz, concat, len, 12, ret);
241} 241}
242 242
@@ -244,7 +244,7 @@ _gnutls_finished (mhd_gtls_session_t session, int type, void *ret)
244 * and put it to dst. 244 * and put it to dst.
245 */ 245 */
246int 246int
247mhd_gtls_tls_create_random (opaque * dst) 247MHD_gtls_tls_create_random (opaque * dst)
248{ 248{
249 uint32_t tim; 249 uint32_t tim;
250 250
@@ -255,11 +255,11 @@ mhd_gtls_tls_create_random (opaque * dst)
255 255
256 tim = time (NULL); 256 tim = time (NULL);
257 /* generate server random value */ 257 /* generate server random value */
258 mhd_gtls_write_uint32 (tim, dst); 258 MHD_gtls_write_uint32 (tim, dst);
259 259
260 if (gc_nonce (&dst[4], TLS_RANDOM_SIZE - 4) != GC_OK) 260 if (MHD_gc_nonce (&dst[4], TLS_RANDOM_SIZE - 4) != GC_OK)
261 { 261 {
262 gnutls_assert (); 262 MHD_gnutls_assert ();
263 return GNUTLS_E_RANDOM_FAILED; 263 return GNUTLS_E_RANDOM_FAILED;
264 } 264 }
265 265
@@ -269,23 +269,23 @@ mhd_gtls_tls_create_random (opaque * dst)
269/* returns the 0 on success or a negative value. 269/* returns the 0 on success or a negative value.
270 */ 270 */
271int 271int
272mhd_gtls_negotiate_version (mhd_gtls_session_t session, 272MHD_gtls_negotiate_version (MHD_gtls_session_t session,
273 enum MHD_GNUTLS_Protocol adv_version) 273 enum MHD_GNUTLS_Protocol adv_version)
274{ 274{
275 int ret; 275 int ret;
276 276
277 /* if we do not support that version */ 277 /* if we do not support that version */
278 if (mhd_gtls_version_is_supported (session, adv_version) == 0) 278 if (MHD_gtls_version_is_supported (session, adv_version) == 0)
279 { 279 {
280 /* If he requested something we do not support 280 /* If he requested something we do not support
281 * then we send him the highest we support. 281 * then we send him the highest we support.
282 */ 282 */
283 ret = mhd_gtls_version_max (session); 283 ret = MHD_gtls_version_max (session);
284 if (ret == MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN) 284 if (ret == MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN)
285 { 285 {
286 /* this check is not really needed. 286 /* this check is not really needed.
287 */ 287 */
288 gnutls_assert (); 288 MHD_gnutls_assert ();
289 return GNUTLS_E_UNKNOWN_CIPHER_SUITE; 289 return GNUTLS_E_UNKNOWN_CIPHER_SUITE;
290 } 290 }
291 } 291 }
@@ -294,13 +294,13 @@ mhd_gtls_negotiate_version (mhd_gtls_session_t session,
294 ret = adv_version; 294 ret = adv_version;
295 } 295 }
296 296
297 mhd_gtls_set_current_version (session, ret); 297 MHD_gtls_set_current_version (session, ret);
298 298
299 return ret; 299 return ret;
300} 300}
301 301
302int 302int
303mhd_gtls_user_hello_func (mhd_gtls_session_t session, 303MHD_gtls_user_hello_func (MHD_gtls_session_t session,
304 enum MHD_GNUTLS_Protocol adv_version) 304 enum MHD_GNUTLS_Protocol adv_version)
305{ 305{
306 int ret; 306 int ret;
@@ -310,16 +310,16 @@ mhd_gtls_user_hello_func (mhd_gtls_session_t session,
310 ret = session->internals.user_hello_func (session); 310 ret = session->internals.user_hello_func (session);
311 if (ret < 0) 311 if (ret < 0)
312 { 312 {
313 gnutls_assert (); 313 MHD_gnutls_assert ();
314 return ret; 314 return ret;
315 } 315 }
316 /* Here we need to renegotiate the version since the callee might 316 /* Here we need to renegotiate the version since the callee might
317 * have disabled some TLS versions. 317 * have disabled some TLS versions.
318 */ 318 */
319 ret = mhd_gtls_negotiate_version (session, adv_version); 319 ret = MHD_gtls_negotiate_version (session, adv_version);
320 if (ret < 0) 320 if (ret < 0)
321 { 321 {
322 gnutls_assert (); 322 MHD_gnutls_assert ();
323 return ret; 323 return ret;
324 } 324 }
325 } 325 }
@@ -332,7 +332,7 @@ mhd_gtls_user_hello_func (mhd_gtls_session_t session,
332 * since SSL version 2.0 is not supported). 332 * since SSL version 2.0 is not supported).
333 */ 333 */
334static int 334static int
335_gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data, 335MHD__gnutls_read_client_hello (MHD_gtls_session_t session, opaque * data,
336 int datalen) 336 int datalen)
337{ 337{
338 uint8_t session_id_len; 338 uint8_t session_id_len;
@@ -345,28 +345,28 @@ _gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data,
345 345
346 DECR_LEN (len, 2); 346 DECR_LEN (len, 2);
347 347
348 _gnutls_handshake_log ("HSK[%x]: Client's version: %d.%d\n", session, 348 MHD__gnutls_handshake_log ("HSK[%x]: Client's version: %d.%d\n", session,
349 data[pos], data[pos + 1]); 349 data[pos], data[pos + 1]);
350 350
351 adv_version = mhd_gtls_version_get (data[pos], data[pos + 1]); 351 adv_version = MHD_gtls_version_get (data[pos], data[pos + 1]);
352 set_adv_version (session, data[pos], data[pos + 1]); 352 set_adv_version (session, data[pos], data[pos + 1]);
353 pos += 2; 353 pos += 2;
354 354
355 neg_version = mhd_gtls_negotiate_version (session, adv_version); 355 neg_version = MHD_gtls_negotiate_version (session, adv_version);
356 if (neg_version < 0) 356 if (neg_version < 0)
357 { 357 {
358 gnutls_assert (); 358 MHD_gnutls_assert ();
359 return ret; 359 return ret;
360 } 360 }
361 361
362 /* Read client random value. 362 /* Read client random value.
363 */ 363 */
364 DECR_LEN (len, TLS_RANDOM_SIZE); 364 DECR_LEN (len, TLS_RANDOM_SIZE);
365 mhd_gtls_set_client_random (session, &data[pos]); 365 MHD_gtls_set_client_random (session, &data[pos]);
366 pos += TLS_RANDOM_SIZE; 366 pos += TLS_RANDOM_SIZE;
367 367
368 mhd_gtls_tls_create_random (rnd); 368 MHD_gtls_tls_create_random (rnd);
369 mhd_gtls_set_server_random (session, rnd); 369 MHD_gtls_set_server_random (session, rnd);
370 370
371 session->security_parameters.timestamp = time (NULL); 371 session->security_parameters.timestamp = time (NULL);
372 372
@@ -376,7 +376,7 @@ _gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data,
376 /* RESUME SESSION */ 376 /* RESUME SESSION */
377 if (session_id_len > TLS_MAX_SESSION_ID_SIZE) 377 if (session_id_len > TLS_MAX_SESSION_ID_SIZE)
378 { 378 {
379 gnutls_assert (); 379 MHD_gnutls_assert ();
380 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 380 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
381 } 381 }
382 DECR_LEN (len, session_id_len); 382 DECR_LEN (len, session_id_len);
@@ -388,11 +388,11 @@ _gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data,
388 { /* resumed! */ 388 { /* resumed! */
389 resume_copy_required_values (session); 389 resume_copy_required_values (session);
390 session->internals.resumed = RESUME_TRUE; 390 session->internals.resumed = RESUME_TRUE;
391 return mhd_gtls_user_hello_func (session, adv_version); 391 return MHD_gtls_user_hello_func (session, adv_version);
392 } 392 }
393 else 393 else
394 { 394 {
395 mhd_gtls_generate_session_id (session->security_parameters.session_id, 395 MHD_gtls_generate_session_id (session->security_parameters.session_id,
396 &session->security_parameters. 396 &session->security_parameters.
397 session_id_size); 397 session_id_size);
398 398
@@ -402,7 +402,7 @@ _gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data,
402 /* Remember ciphersuites for later 402 /* Remember ciphersuites for later
403 */ 403 */
404 DECR_LEN (len, 2); 404 DECR_LEN (len, 2);
405 suite_size = mhd_gtls_read_uint16 (&data[pos]); 405 suite_size = MHD_gtls_read_uint16 (&data[pos]);
406 pos += 2; 406 pos += 2;
407 407
408 DECR_LEN (len, suite_size); 408 DECR_LEN (len, suite_size);
@@ -422,45 +422,45 @@ _gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data,
422 */ 422 */
423 if (neg_version >= MHD_GNUTLS_PROTOCOL_TLS1_0) 423 if (neg_version >= MHD_GNUTLS_PROTOCOL_TLS1_0)
424 { 424 {
425 ret = mhd_gtls_parse_extensions (session, EXTENSION_APPLICATION, &data[pos], len); /* len is the rest of the parsed length */ 425 ret = MHD_gtls_parse_extensions (session, EXTENSION_APPLICATION, &data[pos], len); /* len is the rest of the parsed length */
426 if (ret < 0) 426 if (ret < 0)
427 { 427 {
428 gnutls_assert (); 428 MHD_gnutls_assert ();
429 return ret; 429 return ret;
430 } 430 }
431 } 431 }
432 432
433 ret = mhd_gtls_user_hello_func (session, adv_version); 433 ret = MHD_gtls_user_hello_func (session, adv_version);
434 if (ret < 0) 434 if (ret < 0)
435 { 435 {
436 gnutls_assert (); 436 MHD_gnutls_assert ();
437 return ret; 437 return ret;
438 } 438 }
439 439
440 if (neg_version >= MHD_GNUTLS_PROTOCOL_TLS1_0) 440 if (neg_version >= MHD_GNUTLS_PROTOCOL_TLS1_0)
441 { 441 {
442 ret = mhd_gtls_parse_extensions (session, EXTENSION_TLS, &data[pos], len); /* len is the rest of the parsed length */ 442 ret = MHD_gtls_parse_extensions (session, EXTENSION_TLS, &data[pos], len); /* len is the rest of the parsed length */
443 if (ret < 0) 443 if (ret < 0)
444 { 444 {
445 gnutls_assert (); 445 MHD_gnutls_assert ();
446 return ret; 446 return ret;
447 } 447 }
448 } 448 }
449 449
450 /* select an appropriate cipher suite 450 /* select an appropriate cipher suite
451 */ 451 */
452 ret = mhd_gtls_server_select_suite (session, suite_ptr, suite_size); 452 ret = MHD_gtls_server_select_suite (session, suite_ptr, suite_size);
453 if (ret < 0) 453 if (ret < 0)
454 { 454 {
455 gnutls_assert (); 455 MHD_gnutls_assert ();
456 return ret; 456 return ret;
457 } 457 }
458 458
459 /* select appropriate compression method */ 459 /* select appropriate compression method */
460 ret = _gnutls_server_select_comp_method (session, comp_ptr, comp_size); 460 ret = MHD__gnutls_server_select_comp_method (session, comp_ptr, comp_size);
461 if (ret < 0) 461 if (ret < 0)
462 { 462 {
463 gnutls_assert (); 463 MHD_gnutls_assert ();
464 return ret; 464 return ret;
465 } 465 }
466 466
@@ -470,7 +470,7 @@ _gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data,
470/* here we hash all pending data. 470/* here we hash all pending data.
471 */ 471 */
472inline static int 472inline static int
473_gnutls_handshake_hash_pending (mhd_gtls_session_t session) 473MHD__gnutls_handshake_hash_pending (MHD_gtls_session_t session)
474{ 474{
475 size_t siz; 475 size_t siz;
476 int ret; 476 int ret;
@@ -479,27 +479,27 @@ _gnutls_handshake_hash_pending (mhd_gtls_session_t session)
479 if (session->internals.handshake_mac_handle_sha == NULL || 479 if (session->internals.handshake_mac_handle_sha == NULL ||
480 session->internals.handshake_mac_handle_md5 == NULL) 480 session->internals.handshake_mac_handle_md5 == NULL)
481 { 481 {
482 gnutls_assert (); 482 MHD_gnutls_assert ();
483 return GNUTLS_E_INTERNAL_ERROR; 483 return GNUTLS_E_INTERNAL_ERROR;
484 } 484 }
485 485
486 /* We check if there are pending data to hash. 486 /* We check if there are pending data to hash.
487 */ 487 */
488 if ((ret = mhd_gtls_handshake_buffer_get_ptr (session, &data, &siz)) < 0) 488 if ((ret = MHD_gtls_handshake_buffer_get_ptr (session, &data, &siz)) < 0)
489 { 489 {
490 gnutls_assert (); 490 MHD_gnutls_assert ();
491 return ret; 491 return ret;
492 } 492 }
493 493
494 if (siz > 0) 494 if (siz > 0)
495 { 495 {
496 mhd_gnutls_hash (session->internals.handshake_mac_handle_sha, data, 496 MHD_gnutls_hash (session->internals.handshake_mac_handle_sha, data,
497 siz); 497 siz);
498 mhd_gnutls_hash (session->internals.handshake_mac_handle_md5, data, 498 MHD_gnutls_hash (session->internals.handshake_mac_handle_md5, data,
499 siz); 499 siz);
500 } 500 }
501 501
502 mhd_gtls_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 (mhd_gtls_session_t session)
510 * we send. 510 * we send.
511 */ 511 */
512static int 512static int
513_gnutls_send_finished (mhd_gtls_session_t session, int again) 513MHD__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;
@@ -523,37 +523,37 @@ _gnutls_send_finished (mhd_gtls_session_t session, int again)
523 /* This is needed in order to hash all the required 523 /* This is needed in order to hash all the required
524 * messages. 524 * messages.
525 */ 525 */
526 if ((ret = _gnutls_handshake_hash_pending (session)) < 0) 526 if ((ret = MHD__gnutls_handshake_hash_pending (session)) < 0)
527 { 527 {
528 gnutls_assert (); 528 MHD_gnutls_assert ();
529 return ret; 529 return ret;
530 } 530 }
531 531
532 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) 532 if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
533 { 533 {
534 ret = 534 ret =
535 _gnutls_ssl3_finished (session, 535 MHD__gnutls_ssl3_finished (session,
536 session->security_parameters.entity, data); 536 session->security_parameters.entity, data);
537 data_size = 36; 537 data_size = 36;
538 } 538 }
539 else 539 else
540 { /* TLS 1.0 */ 540 { /* TLS 1.0 */
541 ret = 541 ret =
542 _gnutls_finished (session, 542 MHD__gnutls_finished (session,
543 session->security_parameters.entity, data); 543 session->security_parameters.entity, data);
544 data_size = 12; 544 data_size = 12;
545 } 545 }
546 546
547 if (ret < 0) 547 if (ret < 0)
548 { 548 {
549 gnutls_assert (); 549 MHD_gnutls_assert ();
550 return ret; 550 return ret;
551 } 551 }
552 552
553 } 553 }
554 554
555 ret = 555 ret =
556 mhd_gtls_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 (mhd_gtls_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 */
565static int 565static int
566_gnutls_recv_finished (mhd_gtls_session_t session) 566MHD__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,17 +571,17 @@ _gnutls_recv_finished (mhd_gtls_session_t session)
571 int vrfysize; 571 int vrfysize;
572 572
573 ret = 573 ret =
574 mhd_gtls_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 {
578 ERR ("recv finished int", ret); 578 ERR ("recv finished int", ret);
579 gnutls_assert (); 579 MHD_gnutls_assert ();
580 return ret; 580 return ret;
581 } 581 }
582 582
583 583
584 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) 584 if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
585 { 585 {
586 data_size = 36; 586 data_size = 36;
587 } 587 }
@@ -592,39 +592,39 @@ _gnutls_recv_finished (mhd_gtls_session_t session)
592 592
593 if (vrfysize != data_size) 593 if (vrfysize != data_size)
594 { 594 {
595 gnutls_assert (); 595 MHD_gnutls_assert ();
596 gnutls_free (vrfy); 596 MHD_gnutls_free (vrfy);
597 return GNUTLS_E_ERROR_IN_FINISHED_PACKET; 597 return GNUTLS_E_ERROR_IN_FINISHED_PACKET;
598 } 598 }
599 599
600 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) 600 if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
601 { 601 {
602 ret = 602 ret =
603 _gnutls_ssl3_finished (session, 603 MHD__gnutls_ssl3_finished (session,
604 (session->security_parameters.entity + 1) % 2, 604 (session->security_parameters.entity + 1) % 2,
605 data); 605 data);
606 } 606 }
607 else 607 else
608 { /* TLS 1.0 */ 608 { /* TLS 1.0 */
609 ret = 609 ret =
610 _gnutls_finished (session, 610 MHD__gnutls_finished (session,
611 (session->security_parameters.entity + 611 (session->security_parameters.entity +
612 1) % 2, data); 612 1) % 2, data);
613 } 613 }
614 614
615 if (ret < 0) 615 if (ret < 0)
616 { 616 {
617 gnutls_assert (); 617 MHD_gnutls_assert ();
618 gnutls_free (vrfy); 618 MHD_gnutls_free (vrfy);
619 return ret; 619 return ret;
620 } 620 }
621 621
622 if (memcmp (vrfy, data, data_size) != 0) 622 if (memcmp (vrfy, data, data_size) != 0)
623 { 623 {
624 gnutls_assert (); 624 MHD_gnutls_assert ();
625 ret = GNUTLS_E_ERROR_IN_FINISHED_PACKET; 625 ret = GNUTLS_E_ERROR_IN_FINISHED_PACKET;
626 } 626 }
627 gnutls_free (vrfy); 627 MHD_gnutls_free (vrfy);
628 628
629 return ret; 629 return ret;
630} 630}
@@ -633,7 +633,7 @@ _gnutls_recv_finished (mhd_gtls_session_t session)
633 * RSA algorithms, PK_DSA if DSS, and PK_ANY for both or PK_NONE for none. 633 * RSA algorithms, PK_DSA if DSS, and PK_ANY for both or PK_NONE for none.
634 */ 634 */
635static int 635static int
636_gnutls_server_find_pk_algos_in_ciphersuites (const opaque * 636MHD__gnutls_server_find_pk_algos_in_ciphersuites (const opaque *
637 data, int datalen) 637 data, int datalen)
638{ 638{
639 int j; 639 int j;
@@ -643,18 +643,18 @@ _gnutls_server_find_pk_algos_in_ciphersuites (const opaque *
643 643
644 if (datalen % 2 != 0) 644 if (datalen % 2 != 0)
645 { 645 {
646 gnutls_assert (); 646 MHD_gnutls_assert ();
647 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 647 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
648 } 648 }
649 649
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 = mhd_gtls_cipher_suite_get_kx_algo (&cs); 653 kx = MHD_gtls_cipher_suite_get_kx_algo (&cs);
654 654
655 if (mhd_gtls_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 = mhd_gtls_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
673mhd_gtls_server_select_suite (mhd_gtls_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;
@@ -680,12 +680,12 @@ mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
680 * supported by the peer. 680 * supported by the peer.
681 */ 681 */
682 682
683 pk_algo = _gnutls_server_find_pk_algos_in_ciphersuites (data, datalen); 683 pk_algo = MHD__gnutls_server_find_pk_algos_in_ciphersuites (data, datalen);
684 684
685 x = mhd_gtls_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 MHD_gnutls_assert ();
689 return x; 689 return x;
690 } 690 }
691 691
@@ -693,11 +693,11 @@ mhd_gtls_server_select_suite (mhd_gtls_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 = mhd_gtls_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 MHD_gnutls_assert ();
700 gnutls_free (ciphers); 700 MHD_gnutls_free (ciphers);
701 if (x < 0) 701 if (x < 0)
702 return x; 702 return x;
703 else 703 else
@@ -710,21 +710,21 @@ mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
710 */ 710 */
711 if (datalen % 2 != 0) 711 if (datalen % 2 != 0)
712 { 712 {
713 gnutls_assert (); 713 MHD_gnutls_assert ();
714 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 714 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
715 } 715 }
716#ifdef HANDSHAKE_DEBUG 716#ifdef HANDSHAKE_DEBUG
717 717
718 _gnutls_handshake_log ("HSK[%x]: Requested cipher suites: \n", session); 718 MHD__gnutls_handshake_log ("HSK[%x]: Requested cipher suites: \n", session);
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", mhd_gtls_cipher_suite_get_name (&cs)); 722 MHD__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 MHD__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 MHD__gnutls_handshake_log ("\t%s\n",
727 mhd_gtls_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
@@ -738,9 +738,9 @@ mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
738 { 738 {
739 memcpy (&cs.suite, &data[j], 2); 739 memcpy (&cs.suite, &data[j], 2);
740 740
741 _gnutls_handshake_log 741 MHD__gnutls_handshake_log
742 ("HSK[%x]: Selected cipher suite: %s\n", session, 742 ("HSK[%x]: Selected cipher suite: %s\n", session,
743 mhd_gtls_cipher_suite_get_name (&cs)); 743 MHD_gtls_cipher_suite_get_name (&cs));
744 memcpy (session->security_parameters.current_cipher_suite.suite, 744 memcpy (session->security_parameters.current_cipher_suite.suite,
745 ciphers[i].suite, 2); 745 ciphers[i].suite, 2);
746 retval = 0; 746 retval = 0;
@@ -750,42 +750,42 @@ mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
750 } 750 }
751 751
752finish: 752finish:
753 gnutls_free (ciphers); 753 MHD_gnutls_free (ciphers);
754 754
755 if (retval != 0) 755 if (retval != 0)
756 { 756 {
757 gnutls_assert (); 757 MHD_gnutls_assert ();
758 return retval; 758 return retval;
759 } 759 }
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 (mhd_gtls_get_kx_cred 763 if (MHD_gtls_get_kx_cred
764 (session, 764 (session,
765 mhd_gtls_cipher_suite_get_kx_algo (&session->security_parameters. 765 MHD_gtls_cipher_suite_get_kx_algo (&session->security_parameters.
766 current_cipher_suite), &err) == NULL 766 current_cipher_suite), &err) == NULL
767 && err != 0) 767 && err != 0)
768 { 768 {
769 gnutls_assert (); 769 MHD_gnutls_assert ();
770 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 770 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
771 } 771 }
772 772
773 773
774 /* set the mhd_gtls_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 mhd_gtls_kx_auth_struct (mhd_gtls_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)
783 { 783 {
784 784
785 _gnutls_handshake_log 785 MHD__gnutls_handshake_log
786 ("HSK[%x]: Cannot find the appropriate handler for the KX algorithm\n", 786 ("HSK[%x]: Cannot find the appropriate handler for the KX algorithm\n",
787 session); 787 session);
788 gnutls_assert (); 788 MHD_gnutls_assert ();
789 return GNUTLS_E_INTERNAL_ERROR; 789 return GNUTLS_E_INTERNAL_ERROR;
790 } 790 }
791 791
@@ -797,16 +797,16 @@ 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 */
799static int 799static int
800_gnutls_server_select_comp_method (mhd_gtls_session_t session, 800MHD__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 = mhd_gtls_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 MHD_gnutls_assert ();
810 return x; 810 return x;
811 } 811 }
812 812
@@ -820,12 +820,12 @@ _gnutls_server_select_comp_method (mhd_gtls_session_t session,
820 if (comps[i] == data[j]) 820 if (comps[i] == data[j])
821 { 821 {
822 enum MHD_GNUTLS_CompressionMethod method = 822 enum MHD_GNUTLS_CompressionMethod method =
823 mhd_gtls_compression_get_id (comps[i]); 823 MHD_gtls_compression_get_id_from_int (comps[i]);
824 824
825 session->internals.compression_method = method; 825 session->internals.compression_method = method;
826 gnutls_free (comps); 826 MHD_gnutls_free (comps);
827 827
828 _gnutls_handshake_log 828 MHD__gnutls_handshake_log
829 ("HSK[%x]: Selected Compression Method: %s\n", session, 829 ("HSK[%x]: Selected Compression Method: %s\n", session,
830 MHD_gtls_compression_get_name (session->internals. 830 MHD_gtls_compression_get_name (session->internals.
831 compression_method)); 831 compression_method));
@@ -839,20 +839,20 @@ _gnutls_server_select_comp_method (mhd_gtls_session_t session,
839 /* we were not able to find a compatible compression 839 /* we were not able to find a compatible compression
840 * algorithm 840 * algorithm
841 */ 841 */
842 gnutls_free (comps); 842 MHD_gnutls_free (comps);
843 gnutls_assert (); 843 MHD_gnutls_assert ();
844 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 844 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
845 845
846} 846}
847 847
848/* This function sends an empty handshake packet. (like hello request). 848/* This function sends an empty handshake packet. (like hello request).
849 * If the previous _gnutls_send_empty_handshake() returned 849 * If the previous MHD__gnutls_send_empty_handshake() returned
850 * GNUTLS_E_AGAIN or GNUTLS_E_INTERRUPTED, then it must be called again 850 * GNUTLS_E_AGAIN or GNUTLS_E_INTERRUPTED, then it must be called again
851 * (until it returns ok), with NULL parameters. 851 * (until it returns ok), with NULL parameters.
852 */ 852 */
853static int 853static int
854_gnutls_send_empty_handshake (mhd_gtls_session_t session, 854MHD__gnutls_send_empty_handshake (MHD_gtls_session_t session,
855 gnutls_handshake_description_t type, int again) 855 MHD_gnutls_handshake_description_t type, int again)
856{ 856{
857 opaque data = 0; 857 opaque data = 0;
858 opaque *ptr; 858 opaque *ptr;
@@ -862,29 +862,29 @@ _gnutls_send_empty_handshake (mhd_gtls_session_t session,
862 else 862 else
863 ptr = NULL; 863 ptr = NULL;
864 864
865 return mhd_gtls_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 (mhd_gtls_session_t session, 871MHD__gnutls_handshake_hash_add_sent (MHD_gtls_session_t session,
872 gnutls_handshake_description_t type, 872 MHD_gnutls_handshake_description_t type,
873 opaque * dataptr, uint32_t datalen) 873 opaque * dataptr, uint32_t datalen)
874{ 874{
875 int ret; 875 int ret;
876 876
877 if ((ret = _gnutls_handshake_hash_pending (session)) < 0) 877 if ((ret = MHD__gnutls_handshake_hash_pending (session)) < 0)
878 { 878 {
879 gnutls_assert (); 879 MHD_gnutls_assert ();
880 return ret; 880 return ret;
881 } 881 }
882 882
883 if (type != GNUTLS_HANDSHAKE_HELLO_REQUEST) 883 if (type != GNUTLS_HANDSHAKE_HELLO_REQUEST)
884 { 884 {
885 mhd_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 mhd_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,14 +893,14 @@ _gnutls_handshake_hash_add_sent (mhd_gtls_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 mhd_gtls_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
901mhd_gtls_send_handshake (mhd_gtls_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 MHD_gnutls_handshake_description_t type)
904{ 904{
905 int ret; 905 int ret;
906 uint8_t *data; 906 uint8_t *data;
@@ -912,28 +912,28 @@ mhd_gtls_send_handshake (mhd_gtls_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 = mhd_gtls_handshake_io_write_flush (session); 915 ret = MHD_gtls_handshake_io_write_flush (session);
916 return ret; 916 return ret;
917 917
918 } 918 }
919 919
920 if (i_data == NULL && i_datasize > 0) 920 if (i_data == NULL && i_datasize > 0)
921 { 921 {
922 gnutls_assert (); 922 MHD_gnutls_assert ();
923 return GNUTLS_E_INVALID_REQUEST; 923 return GNUTLS_E_INVALID_REQUEST;
924 } 924 }
925 925
926 /* first run */ 926 /* first run */
927 datasize = i_datasize + HANDSHAKE_HEADER_SIZE; 927 datasize = i_datasize + HANDSHAKE_HEADER_SIZE;
928 data = gnutls_alloca (datasize); 928 data = MHD_gnutls_alloca (datasize);
929 if (data == NULL) 929 if (data == NULL)
930 { 930 {
931 gnutls_assert (); 931 MHD_gnutls_assert ();
932 return GNUTLS_E_MEMORY_ERROR; 932 return GNUTLS_E_MEMORY_ERROR;
933 } 933 }
934 934
935 data[pos++] = (uint8_t) type; 935 data[pos++] = (uint8_t) type;
936 mhd_gtls_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)
@@ -943,23 +943,23 @@ mhd_gtls_send_handshake (mhd_gtls_session_t session, void *i_data,
943 */ 943 */
944 if (type != GNUTLS_HANDSHAKE_HELLO_REQUEST) 944 if (type != GNUTLS_HANDSHAKE_HELLO_REQUEST)
945 if ((ret = 945 if ((ret =
946 _gnutls_handshake_hash_add_sent (session, type, data, datasize)) < 0) 946 MHD__gnutls_handshake_hash_add_sent (session, type, data, datasize)) < 0)
947 { 947 {
948 gnutls_assert (); 948 MHD_gnutls_assert ();
949 gnutls_afree (data); 949 MHD_gnutls_afree (data);
950 return ret; 950 return ret;
951 } 951 }
952 952
953 session->internals.last_handshake_out = type; 953 session->internals.last_handshake_out = type;
954 954
955 ret = 955 ret =
956 mhd_gtls_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 MHD__gnutls_handshake_log ("HSK[%x]: %s was sent [%ld bytes]\n",
960 session, _gnutls_handshake2str (type), datasize); 960 session, MHD__gnutls_handshake2str (type), datasize);
961 961
962 gnutls_afree (data); 962 MHD_gnutls_afree (data);
963 963
964 return ret; 964 return ret;
965} 965}
@@ -972,9 +972,9 @@ mhd_gtls_send_handshake (mhd_gtls_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 (mhd_gtls_session_t session, 975MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session,
976 gnutls_handshake_description_t type, 976 MHD_gnutls_handshake_description_t type,
977 gnutls_handshake_description_t * recv_type) 977 MHD_gnutls_handshake_description_t * recv_type)
978{ 978{
979 int ret; 979 int ret;
980 uint32_t length32 = 0; 980 uint32_t length32 = 0;
@@ -1006,12 +1006,12 @@ _gnutls_recv_handshake_header (mhd_gtls_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 mhd_gtls_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)
1013 { 1013 {
1014 gnutls_assert (); 1014 MHD_gnutls_assert ();
1015 return ret; 1015 return ret;
1016 } 1016 }
1017 1017
@@ -1019,7 +1019,7 @@ _gnutls_recv_handshake_header (mhd_gtls_session_t session,
1019 */ 1019 */
1020 if (ret != SSL2_HEADERS) 1020 if (ret != SSL2_HEADERS)
1021 { 1021 {
1022 gnutls_assert (); 1022 MHD_gnutls_assert ();
1023 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 1023 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
1024 } 1024 }
1025 session->internals.handshake_header_buffer.header_size = SSL2_HEADERS; 1025 session->internals.handshake_header_buffer.header_size = SSL2_HEADERS;
@@ -1029,7 +1029,7 @@ _gnutls_recv_handshake_header (mhd_gtls_session_t session,
1029 || type != GNUTLS_HANDSHAKE_CLIENT_HELLO) 1029 || type != GNUTLS_HANDSHAKE_CLIENT_HELLO)
1030 { 1030 {
1031 ret = 1031 ret =
1032 mhd_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, 1032 MHD_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
1033 type, 1033 type,
1034 &dataptr 1034 &dataptr
1035 [session->internals. 1035 [session->internals.
@@ -1039,14 +1039,14 @@ _gnutls_recv_handshake_header (mhd_gtls_session_t session,
1039 handshake_header_buffer.header_size); 1039 handshake_header_buffer.header_size);
1040 if (ret <= 0) 1040 if (ret <= 0)
1041 { 1041 {
1042 gnutls_assert (); 1042 MHD_gnutls_assert ();
1043 return (ret < 0) ? ret : GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 1043 return (ret < 0) ? ret : GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
1044 } 1044 }
1045 if ((size_t) ret != 1045 if ((size_t) ret !=
1046 HANDSHAKE_HEADER_SIZE - 1046 HANDSHAKE_HEADER_SIZE -
1047 session->internals.handshake_header_buffer.header_size) 1047 session->internals.handshake_header_buffer.header_size)
1048 { 1048 {
1049 gnutls_assert (); 1049 MHD_gnutls_assert ();
1050 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 1050 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
1051 } 1051 }
1052 *recv_type = dataptr[0]; 1052 *recv_type = dataptr[0];
@@ -1054,11 +1054,11 @@ _gnutls_recv_handshake_header (mhd_gtls_session_t session,
1054 /* we do not use DECR_LEN because we know 1054 /* we do not use DECR_LEN because we know
1055 * that the packet has enough data. 1055 * that the packet has enough data.
1056 */ 1056 */
1057 length32 = mhd_gtls_read_uint24 (&dataptr[1]); 1057 length32 = MHD_gtls_read_uint24 (&dataptr[1]);
1058 handshake_header_size = HANDSHAKE_HEADER_SIZE; 1058 handshake_header_size = HANDSHAKE_HEADER_SIZE;
1059 1059
1060 _gnutls_handshake_log ("HSK[%x]: %s was received [%ld bytes]\n", 1060 MHD__gnutls_handshake_log ("HSK[%x]: %s was received [%ld bytes]\n",
1061 session, _gnutls_handshake2str (dataptr[0]), 1061 session, MHD__gnutls_handshake2str (dataptr[0]),
1062 length32 + HANDSHAKE_HEADER_SIZE); 1062 length32 + HANDSHAKE_HEADER_SIZE);
1063 1063
1064 } 1064 }
@@ -1070,13 +1070,13 @@ _gnutls_recv_handshake_header (mhd_gtls_session_t session,
1070 1070
1071 *recv_type = dataptr[0]; 1071 *recv_type = dataptr[0];
1072 1072
1073 _gnutls_handshake_log ("HSK[%x]: %s(v2) was received [%ld bytes]\n", 1073 MHD__gnutls_handshake_log ("HSK[%x]: %s(v2) was received [%ld bytes]\n",
1074 session, _gnutls_handshake2str (*recv_type), 1074 session, MHD__gnutls_handshake2str (*recv_type),
1075 length32 + handshake_header_size); 1075 length32 + handshake_header_size);
1076 1076
1077 if (*recv_type != GNUTLS_HANDSHAKE_CLIENT_HELLO) 1077 if (*recv_type != GNUTLS_HANDSHAKE_CLIENT_HELLO)
1078 { /* it should be one or nothing */ 1078 { /* it should be one or nothing */
1079 gnutls_assert (); 1079 MHD_gnutls_assert ();
1080 return GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET; 1080 return GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET;
1081 } 1081 }
1082 } 1082 }
@@ -1089,21 +1089,21 @@ _gnutls_recv_handshake_header (mhd_gtls_session_t session,
1089 1089
1090 if (*recv_type != type) 1090 if (*recv_type != type)
1091 { 1091 {
1092 gnutls_assert (); 1092 MHD_gnutls_assert ();
1093 return GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET; 1093 return GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET;
1094 } 1094 }
1095 1095
1096 return length32; 1096 return length32;
1097} 1097}
1098 1098
1099#define _gnutls_handshake_header_buffer_clear( session) session->internals.handshake_header_buffer.header_size = 0 1099#define MHD__gnutls_handshake_header_buffer_clear( session) session->internals.handshake_header_buffer.header_size = 0
1100 1100
1101/* This function will hash the handshake headers and the 1101/* This function will hash the handshake headers and the
1102 * handshake data. 1102 * handshake data.
1103 */ 1103 */
1104static int 1104static int
1105_gnutls_handshake_hash_add_recvd (mhd_gtls_session_t session, 1105MHD__gnutls_handshake_hash_add_recvd (MHD_gtls_session_t session,
1106 gnutls_handshake_description_t recv_type, 1106 MHD_gnutls_handshake_description_t recv_type,
1107 opaque * header, uint16_t header_size, 1107 opaque * header, uint16_t header_size,
1108 opaque * dataptr, uint32_t datalen) 1108 opaque * dataptr, uint32_t datalen)
1109{ 1109{
@@ -1113,9 +1113,9 @@ _gnutls_handshake_hash_add_recvd (mhd_gtls_session_t session,
1113 * and add the one we just received into the handshake_hash_buffer. 1113 * and add the one we just received into the handshake_hash_buffer.
1114 */ 1114 */
1115 1115
1116 if ((ret = _gnutls_handshake_hash_pending (session)) < 0) 1116 if ((ret = MHD__gnutls_handshake_hash_pending (session)) < 0)
1117 { 1117 {
1118 gnutls_assert (); 1118 MHD_gnutls_assert ();
1119 return ret; 1119 return ret;
1120 } 1120 }
1121 1121
@@ -1124,18 +1124,18 @@ _gnutls_handshake_hash_add_recvd (mhd_gtls_session_t session,
1124 { 1124 {
1125 1125
1126 if ((ret = 1126 if ((ret =
1127 mhd_gtls_handshake_buffer_put (session, header, header_size)) < 0) 1127 MHD_gtls_handshake_buffer_put (session, header, header_size)) < 0)
1128 { 1128 {
1129 gnutls_assert (); 1129 MHD_gnutls_assert ();
1130 return ret; 1130 return ret;
1131 } 1131 }
1132 1132
1133 if (datalen > 0) 1133 if (datalen > 0)
1134 { 1134 {
1135 if ((ret = 1135 if ((ret =
1136 mhd_gtls_handshake_buffer_put (session, dataptr, datalen)) < 0) 1136 MHD_gtls_handshake_buffer_put (session, dataptr, datalen)) < 0)
1137 { 1137 {
1138 gnutls_assert (); 1138 MHD_gnutls_assert ();
1139 return ret; 1139 return ret;
1140 } 1140 }
1141 } 1141 }
@@ -1147,19 +1147,19 @@ _gnutls_handshake_hash_add_recvd (mhd_gtls_session_t session,
1147/* This function will receive handshake messages of the given types, 1147/* This function will receive handshake messages of the given types,
1148 * and will pass the message to the right place in order to be processed. 1148 * and will pass the message to the right place in order to be processed.
1149 * E.g. for the SERVER_HELLO message (if it is expected), it will be 1149 * E.g. for the SERVER_HELLO message (if it is expected), it will be
1150 * passed to mhd_gtls_recv_hello(). 1150 * passed to MHD_gtls_recv_hello().
1151 */ 1151 */
1152int 1152int
1153mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data, 1153MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t ** data,
1154 int *datalen, gnutls_handshake_description_t type, 1154 int *datalen, MHD_gnutls_handshake_description_t type,
1155 Optional optional) 1155 Optional optional)
1156{ 1156{
1157 int ret; 1157 int ret;
1158 uint32_t length32 = 0; 1158 uint32_t length32 = 0;
1159 opaque *dataptr = NULL; 1159 opaque *dataptr = NULL;
1160 gnutls_handshake_description_t recv_type; 1160 MHD_gnutls_handshake_description_t recv_type;
1161 1161
1162 ret = _gnutls_recv_handshake_header (session, type, &recv_type); 1162 ret = MHD__gnutls_recv_handshake_header (session, type, &recv_type);
1163 if (ret < 0) 1163 if (ret < 0)
1164 { 1164 {
1165 1165
@@ -1181,16 +1181,16 @@ mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
1181 length32 = ret; 1181 length32 = ret;
1182 1182
1183 if (length32 > 0) 1183 if (length32 > 0)
1184 dataptr = gnutls_malloc (length32); 1184 dataptr = MHD_gnutls_malloc (length32);
1185 else if (recv_type != GNUTLS_HANDSHAKE_SERVER_HELLO_DONE) 1185 else if (recv_type != GNUTLS_HANDSHAKE_SERVER_HELLO_DONE)
1186 { 1186 {
1187 gnutls_assert (); 1187 MHD_gnutls_assert ();
1188 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 1188 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
1189 } 1189 }
1190 1190
1191 if (dataptr == NULL && length32 > 0) 1191 if (dataptr == NULL && length32 > 0)
1192 { 1192 {
1193 gnutls_assert (); 1193 MHD_gnutls_assert ();
1194 return GNUTLS_E_MEMORY_ERROR; 1194 return GNUTLS_E_MEMORY_ERROR;
1195 } 1195 }
1196 1196
@@ -1200,12 +1200,12 @@ mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
1200 if (length32 > 0) 1200 if (length32 > 0)
1201 { 1201 {
1202 ret = 1202 ret =
1203 mhd_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, 1203 MHD_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE,
1204 type, dataptr, length32); 1204 type, dataptr, length32);
1205 if (ret <= 0) 1205 if (ret <= 0)
1206 { 1206 {
1207 gnutls_assert (); 1207 MHD_gnutls_assert ();
1208 gnutls_free (dataptr); 1208 MHD_gnutls_free (dataptr);
1209 return (ret == 0) ? GNUTLS_E_UNEXPECTED_PACKET_LENGTH : ret; 1209 return (ret == 0) ? GNUTLS_E_UNEXPECTED_PACKET_LENGTH : ret;
1210 } 1210 }
1211 } 1211 }
@@ -1214,7 +1214,7 @@ mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
1214 *data = dataptr; 1214 *data = dataptr;
1215 1215
1216 1216
1217 ret = _gnutls_handshake_hash_add_recvd (session, recv_type, 1217 ret = MHD__gnutls_handshake_hash_add_recvd (session, recv_type,
1218 session->internals. 1218 session->internals.
1219 handshake_header_buffer.header, 1219 handshake_header_buffer.header,
1220 session->internals. 1220 session->internals.
@@ -1222,8 +1222,8 @@ mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
1222 dataptr, length32); 1222 dataptr, length32);
1223 if (ret < 0) 1223 if (ret < 0)
1224 { 1224 {
1225 gnutls_assert (); 1225 MHD_gnutls_assert ();
1226 _gnutls_handshake_header_buffer_clear (session); 1226 MHD__gnutls_handshake_header_buffer_clear (session);
1227 return ret; 1227 return ret;
1228 } 1228 }
1229 1229
@@ -1231,16 +1231,16 @@ mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
1231 * have have received above. if we get here the we clear the handshake 1231 * have have received above. if we get here the we clear the handshake
1232 * header we received. 1232 * header we received.
1233 */ 1233 */
1234 _gnutls_handshake_header_buffer_clear (session); 1234 MHD__gnutls_handshake_header_buffer_clear (session);
1235 1235
1236 switch (recv_type) 1236 switch (recv_type)
1237 { 1237 {
1238 case GNUTLS_HANDSHAKE_CLIENT_HELLO: 1238 case GNUTLS_HANDSHAKE_CLIENT_HELLO:
1239 case GNUTLS_HANDSHAKE_SERVER_HELLO: 1239 case GNUTLS_HANDSHAKE_SERVER_HELLO:
1240 ret = mhd_gtls_recv_hello (session, dataptr, length32); 1240 ret = MHD_gtls_recv_hello (session, dataptr, length32);
1241 /* dataptr is freed because the caller does not 1241 /* dataptr is freed because the caller does not
1242 * need it */ 1242 * need it */
1243 gnutls_free (dataptr); 1243 MHD_gnutls_free (dataptr);
1244 if (data != NULL) 1244 if (data != NULL)
1245 *data = NULL; 1245 *data = NULL;
1246 break; 1246 break;
@@ -1260,8 +1260,8 @@ mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
1260 ret = length32; 1260 ret = length32;
1261 break; 1261 break;
1262 default: 1262 default:
1263 gnutls_assert (); 1263 MHD_gnutls_assert ();
1264 gnutls_free (dataptr); 1264 MHD_gnutls_free (dataptr);
1265 if (data != NULL) 1265 if (data != NULL)
1266 *data = NULL; 1266 *data = NULL;
1267 ret = GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET; 1267 ret = GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET;
@@ -1274,7 +1274,7 @@ mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t ** data,
1274 * to the session; 1274 * to the session;
1275 */ 1275 */
1276static int 1276static int
1277_gnutls_client_set_ciphersuite (mhd_gtls_session_t session, opaque suite[2]) 1277MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, opaque suite[2])
1278{ 1278{
1279 uint8_t z; 1279 uint8_t z;
1280 cipher_suite_st *cipher_suites; 1280 cipher_suite_st *cipher_suites;
@@ -1283,10 +1283,10 @@ _gnutls_client_set_ciphersuite (mhd_gtls_session_t session, opaque suite[2])
1283 1283
1284 z = 1; 1284 z = 1;
1285 cipher_suite_num = 1285 cipher_suite_num =
1286 mhd_gtls_supported_ciphersuites (session, &cipher_suites); 1286 MHD_gtls_supported_ciphersuites (session, &cipher_suites);
1287 if (cipher_suite_num < 0) 1287 if (cipher_suite_num < 0)
1288 { 1288 {
1289 gnutls_assert (); 1289 MHD_gnutls_assert ();
1290 return cipher_suite_num; 1290 return cipher_suite_num;
1291 } 1291 }
1292 1292
@@ -1299,18 +1299,18 @@ _gnutls_client_set_ciphersuite (mhd_gtls_session_t session, opaque suite[2])
1299 } 1299 }
1300 } 1300 }
1301 1301
1302 gnutls_free (cipher_suites); 1302 MHD_gnutls_free (cipher_suites);
1303 1303
1304 if (z != 0) 1304 if (z != 0)
1305 { 1305 {
1306 gnutls_assert (); 1306 MHD_gnutls_assert ();
1307 return GNUTLS_E_UNKNOWN_CIPHER_SUITE; 1307 return GNUTLS_E_UNKNOWN_CIPHER_SUITE;
1308 } 1308 }
1309 1309
1310 memcpy (session->security_parameters.current_cipher_suite.suite, suite, 2); 1310 memcpy (session->security_parameters.current_cipher_suite.suite, suite, 2);
1311 1311
1312 _gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session, 1312 MHD__gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session,
1313 mhd_gtls_cipher_suite_get_name 1313 MHD_gtls_cipher_suite_get_name
1314 (&session->security_parameters. 1314 (&session->security_parameters.
1315 current_cipher_suite)); 1315 current_cipher_suite));
1316 1316
@@ -1318,33 +1318,33 @@ _gnutls_client_set_ciphersuite (mhd_gtls_session_t session, opaque suite[2])
1318 /* check if the credentials (username, public key etc.) are ok. 1318 /* check if the credentials (username, public key etc.) are ok.
1319 * Actually checks if they exist. 1319 * Actually checks if they exist.
1320 */ 1320 */
1321 if (mhd_gtls_get_kx_cred 1321 if (MHD_gtls_get_kx_cred
1322 (session, 1322 (session,
1323 mhd_gtls_cipher_suite_get_kx_algo 1323 MHD_gtls_cipher_suite_get_kx_algo
1324 (&session->security_parameters.current_cipher_suite), &err) == NULL 1324 (&session->security_parameters.current_cipher_suite), &err) == NULL
1325 && err != 0) 1325 && err != 0)
1326 { 1326 {
1327 gnutls_assert (); 1327 MHD_gnutls_assert ();
1328 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 1328 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
1329 } 1329 }
1330 1330
1331 1331
1332 /* set the mhd_gtls_mod_auth_st to the appropriate struct 1332 /* set the MHD_gtls_mod_auth_st to the appropriate struct
1333 * according to the KX algorithm. This is needed since all the 1333 * according to the KX algorithm. This is needed since all the
1334 * handshake functions are read from there; 1334 * handshake functions are read from there;
1335 */ 1335 */
1336 session->internals.auth_struct = 1336 session->internals.auth_struct =
1337 mhd_gtls_kx_auth_struct (mhd_gtls_cipher_suite_get_kx_algo 1337 MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo
1338 (&session->security_parameters. 1338 (&session->security_parameters.
1339 current_cipher_suite)); 1339 current_cipher_suite));
1340 1340
1341 if (session->internals.auth_struct == NULL) 1341 if (session->internals.auth_struct == NULL)
1342 { 1342 {
1343 1343
1344 _gnutls_handshake_log 1344 MHD__gnutls_handshake_log
1345 ("HSK[%x]: Cannot find the appropriate handler for the KX algorithm\n", 1345 ("HSK[%x]: Cannot find the appropriate handler for the KX algorithm\n",
1346 session); 1346 session);
1347 gnutls_assert (); 1347 MHD_gnutls_assert ();
1348 return GNUTLS_E_INTERNAL_ERROR; 1348 return GNUTLS_E_INTERNAL_ERROR;
1349 } 1349 }
1350 1350
@@ -1355,18 +1355,18 @@ _gnutls_client_set_ciphersuite (mhd_gtls_session_t session, opaque suite[2])
1355/* This function sets the given comp method to the session. 1355/* This function sets the given comp method to the session.
1356 */ 1356 */
1357static int 1357static int
1358_gnutls_client_set_comp_method (mhd_gtls_session_t session, 1358MHD__gnutls_client_set_comp_method (MHD_gtls_session_t session,
1359 opaque comp_method) 1359 opaque comp_method)
1360{ 1360{
1361 int comp_methods_num; 1361 int comp_methods_num;
1362 uint8_t *compression_methods; 1362 uint8_t *compression_methods;
1363 int i; 1363 int i;
1364 1364
1365 comp_methods_num = mhd_gtls_supported_compression_methods (session, 1365 comp_methods_num = MHD_gtls_supported_compression_methods (session,
1366 &compression_methods); 1366 &compression_methods);
1367 if (comp_methods_num < 0) 1367 if (comp_methods_num < 0)
1368 { 1368 {
1369 gnutls_assert (); 1369 MHD_gnutls_assert ();
1370 return comp_methods_num; 1370 return comp_methods_num;
1371 } 1371 }
1372 1372
@@ -1379,16 +1379,16 @@ _gnutls_client_set_comp_method (mhd_gtls_session_t session,
1379 } 1379 }
1380 } 1380 }
1381 1381
1382 gnutls_free (compression_methods); 1382 MHD_gnutls_free (compression_methods);
1383 1383
1384 if (comp_methods_num != 0) 1384 if (comp_methods_num != 0)
1385 { 1385 {
1386 gnutls_assert (); 1386 MHD_gnutls_assert ();
1387 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 1387 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
1388 } 1388 }
1389 1389
1390 session->internals.compression_method = 1390 session->internals.compression_method =
1391 mhd_gtls_compression_get_id (comp_method); 1391 MHD_gtls_compression_get_id_from_int (comp_method);
1392 1392
1393 1393
1394 return 0; 1394 return 0;
@@ -1399,15 +1399,15 @@ _gnutls_client_set_comp_method (mhd_gtls_session_t session,
1399 * hello. 1399 * hello.
1400 */ 1400 */
1401static int 1401static int
1402_gnutls_client_check_if_resuming (mhd_gtls_session_t session, 1402MHD__gnutls_client_check_if_resuming (MHD_gtls_session_t session,
1403 opaque * session_id, int session_id_len) 1403 opaque * session_id, int session_id_len)
1404{ 1404{
1405 opaque buf[2 * TLS_MAX_SESSION_ID_SIZE + 1]; 1405 opaque buf[2 * TLS_MAX_SESSION_ID_SIZE + 1];
1406 1406
1407 _gnutls_handshake_log ("HSK[%x]: SessionID length: %d\n", session, 1407 MHD__gnutls_handshake_log ("HSK[%x]: SessionID length: %d\n", session,
1408 session_id_len); 1408 session_id_len);
1409 _gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session, 1409 MHD__gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session,
1410 mhd_gtls_bin2hex (session_id, session_id_len, buf, 1410 MHD_gtls_bin2hex (session_id, session_id_len, buf,
1411 sizeof (buf))); 1411 sizeof (buf)));
1412 1412
1413 if (session_id_len > 0 && 1413 if (session_id_len > 0 &&
@@ -1444,7 +1444,7 @@ _gnutls_client_check_if_resuming (mhd_gtls_session_t session,
1444 * session. 1444 * session.
1445 */ 1445 */
1446static int 1446static int
1447_gnutls_read_server_hello (mhd_gtls_session_t session, 1447MHD__gnutls_read_server_hello (MHD_gtls_session_t session,
1448 opaque * data, int datalen) 1448 opaque * data, int datalen)
1449{ 1449{
1450 uint8_t session_id_len = 0; 1450 uint8_t session_id_len = 0;
@@ -1455,29 +1455,29 @@ _gnutls_read_server_hello (mhd_gtls_session_t session,
1455 1455
1456 if (datalen < 38) 1456 if (datalen < 38)
1457 { 1457 {
1458 gnutls_assert (); 1458 MHD_gnutls_assert ();
1459 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 1459 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
1460 } 1460 }
1461 1461
1462 _gnutls_handshake_log ("HSK[%x]: Server's version: %d.%d\n", 1462 MHD__gnutls_handshake_log ("HSK[%x]: Server's version: %d.%d\n",
1463 session, data[pos], data[pos + 1]); 1463 session, data[pos], data[pos + 1]);
1464 1464
1465 DECR_LEN (len, 2); 1465 DECR_LEN (len, 2);
1466 version = mhd_gtls_version_get (data[pos], data[pos + 1]); 1466 version = MHD_gtls_version_get (data[pos], data[pos + 1]);
1467 if (mhd_gtls_version_is_supported (session, version) == 0) 1467 if (MHD_gtls_version_is_supported (session, version) == 0)
1468 { 1468 {
1469 gnutls_assert (); 1469 MHD_gnutls_assert ();
1470 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET; 1470 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;
1471 } 1471 }
1472 else 1472 else
1473 { 1473 {
1474 mhd_gtls_set_current_version (session, version); 1474 MHD_gtls_set_current_version (session, version);
1475 } 1475 }
1476 1476
1477 pos += 2; 1477 pos += 2;
1478 1478
1479 DECR_LEN (len, TLS_RANDOM_SIZE); 1479 DECR_LEN (len, TLS_RANDOM_SIZE);
1480 mhd_gtls_set_server_random (session, &data[pos]); 1480 MHD_gtls_set_server_random (session, &data[pos]);
1481 pos += TLS_RANDOM_SIZE; 1481 pos += TLS_RANDOM_SIZE;
1482 1482
1483 1483
@@ -1488,7 +1488,7 @@ _gnutls_read_server_hello (mhd_gtls_session_t session,
1488 1488
1489 if (len < session_id_len) 1489 if (len < session_id_len)
1490 { 1490 {
1491 gnutls_assert (); 1491 MHD_gnutls_assert ();
1492 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET; 1492 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;
1493 } 1493 }
1494 DECR_LEN (len, session_id_len); 1494 DECR_LEN (len, session_id_len);
@@ -1497,7 +1497,7 @@ _gnutls_read_server_hello (mhd_gtls_session_t session,
1497 /* check if we are resuming and set the appropriate 1497 /* check if we are resuming and set the appropriate
1498 * values; 1498 * values;
1499 */ 1499 */
1500 if (_gnutls_client_check_if_resuming 1500 if (MHD__gnutls_client_check_if_resuming
1501 (session, &data[pos], session_id_len) == 0) 1501 (session, &data[pos], session_id_len) == 0)
1502 return 0; 1502 return 0;
1503 pos += session_id_len; 1503 pos += session_id_len;
@@ -1508,10 +1508,10 @@ _gnutls_read_server_hello (mhd_gtls_session_t session,
1508 */ 1508 */
1509 1509
1510 DECR_LEN (len, 2); 1510 DECR_LEN (len, 2);
1511 ret = _gnutls_client_set_ciphersuite (session, &data[pos]); 1511 ret = MHD__gnutls_client_set_ciphersuite (session, &data[pos]);
1512 if (ret < 0) 1512 if (ret < 0)
1513 { 1513 {
1514 gnutls_assert (); 1514 MHD_gnutls_assert ();
1515 return ret; 1515 return ret;
1516 } 1516 }
1517 pos += 2; 1517 pos += 2;
@@ -1521,10 +1521,10 @@ _gnutls_read_server_hello (mhd_gtls_session_t session,
1521 /* move to compression */ 1521 /* move to compression */
1522 DECR_LEN (len, 1); 1522 DECR_LEN (len, 1);
1523 1523
1524 ret = _gnutls_client_set_comp_method (session, data[pos++]); 1524 ret = MHD__gnutls_client_set_comp_method (session, data[pos++]);
1525 if (ret < 0) 1525 if (ret < 0)
1526 { 1526 {
1527 gnutls_assert (); 1527 MHD_gnutls_assert ();
1528 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM; 1528 return GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM;
1529 } 1529 }
1530 1530
@@ -1532,10 +1532,10 @@ _gnutls_read_server_hello (mhd_gtls_session_t session,
1532 */ 1532 */
1533 if (version >= MHD_GNUTLS_PROTOCOL_TLS1_0) 1533 if (version >= MHD_GNUTLS_PROTOCOL_TLS1_0)
1534 { 1534 {
1535 ret = mhd_gtls_parse_extensions (session, EXTENSION_ANY, &data[pos], len); /* len is the rest of the parsed length */ 1535 ret = MHD_gtls_parse_extensions (session, EXTENSION_ANY, &data[pos], len); /* len is the rest of the parsed length */
1536 if (ret < 0) 1536 if (ret < 0)
1537 { 1537 {
1538 gnutls_assert (); 1538 MHD_gnutls_assert ();
1539 return ret; 1539 return ret;
1540 } 1540 }
1541 } 1541 }
@@ -1547,7 +1547,7 @@ _gnutls_read_server_hello (mhd_gtls_session_t session,
1547 * Needed in client hello messages. Returns the new data length. 1547 * Needed in client hello messages. Returns the new data length.
1548 */ 1548 */
1549static int 1549static int
1550_gnutls_copy_ciphersuites (mhd_gtls_session_t session, 1550MHD__gnutls_copy_ciphersuites (MHD_gtls_session_t session,
1551 opaque * ret_data, size_t ret_data_size) 1551 opaque * ret_data, size_t ret_data_size)
1552{ 1552{
1553 int ret, i; 1553 int ret, i;
@@ -1555,10 +1555,10 @@ _gnutls_copy_ciphersuites (mhd_gtls_session_t session,
1555 uint16_t cipher_num; 1555 uint16_t cipher_num;
1556 int datalen, pos; 1556 int datalen, pos;
1557 1557
1558 ret = mhd_gtls_supported_ciphersuites_sorted (session, &cipher_suites); 1558 ret = MHD_gtls_supported_ciphersuites_sorted (session, &cipher_suites);
1559 if (ret < 0) 1559 if (ret < 0)
1560 { 1560 {
1561 gnutls_assert (); 1561 MHD_gnutls_assert ();
1562 return ret; 1562 return ret;
1563 } 1563 }
1564 1564
@@ -1567,11 +1567,11 @@ _gnutls_copy_ciphersuites (mhd_gtls_session_t session,
1567 * authentication requested (eg SRP). 1567 * authentication requested (eg SRP).
1568 */ 1568 */
1569 ret = 1569 ret =
1570 mhd_gtls_remove_unwanted_ciphersuites (session, &cipher_suites, ret, -1); 1570 MHD_gtls_remove_unwanted_ciphersuites (session, &cipher_suites, ret, -1);
1571 if (ret < 0) 1571 if (ret < 0)
1572 { 1572 {
1573 gnutls_assert (); 1573 MHD_gnutls_assert ();
1574 gnutls_free (cipher_suites); 1574 MHD_gnutls_free (cipher_suites);
1575 return ret; 1575 return ret;
1576 } 1576 }
1577 1577
@@ -1579,8 +1579,8 @@ _gnutls_copy_ciphersuites (mhd_gtls_session_t session,
1579 */ 1579 */
1580 if (ret == 0) 1580 if (ret == 0)
1581 { 1581 {
1582 gnutls_assert (); 1582 MHD_gnutls_assert ();
1583 gnutls_free (cipher_suites); 1583 MHD_gnutls_free (cipher_suites);
1584 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 1584 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
1585 } 1585 }
1586 1586
@@ -1594,11 +1594,11 @@ _gnutls_copy_ciphersuites (mhd_gtls_session_t session,
1594 1594
1595 if ((size_t) datalen > ret_data_size) 1595 if ((size_t) datalen > ret_data_size)
1596 { 1596 {
1597 gnutls_assert (); 1597 MHD_gnutls_assert ();
1598 return GNUTLS_E_INTERNAL_ERROR; 1598 return GNUTLS_E_INTERNAL_ERROR;
1599 } 1599 }
1600 1600
1601 mhd_gtls_write_uint16 (cipher_num, ret_data); 1601 MHD_gtls_write_uint16 (cipher_num, ret_data);
1602 pos += 2; 1602 pos += 2;
1603 1603
1604 for (i = 0; i < (cipher_num / 2); i++) 1604 for (i = 0; i < (cipher_num / 2); i++)
@@ -1606,7 +1606,7 @@ _gnutls_copy_ciphersuites (mhd_gtls_session_t session,
1606 memcpy (&ret_data[pos], cipher_suites[i].suite, 2); 1606 memcpy (&ret_data[pos], cipher_suites[i].suite, 2);
1607 pos += 2; 1607 pos += 2;
1608 } 1608 }
1609 gnutls_free (cipher_suites); 1609 MHD_gnutls_free (cipher_suites);
1610 1610
1611 return datalen; 1611 return datalen;
1612} 1612}
@@ -1615,7 +1615,7 @@ _gnutls_copy_ciphersuites (mhd_gtls_session_t session,
1615 * Needed in hello messages. Returns the new data length. 1615 * Needed in hello messages. Returns the new data length.
1616 */ 1616 */
1617static int 1617static int
1618_gnutls_copy_comp_methods (mhd_gtls_session_t session, 1618MHD__gnutls_copy_comp_methods (MHD_gtls_session_t session,
1619 opaque * ret_data, size_t ret_data_size) 1619 opaque * ret_data, size_t ret_data_size)
1620{ 1620{
1621 int ret, i; 1621 int ret, i;
@@ -1623,10 +1623,10 @@ _gnutls_copy_comp_methods (mhd_gtls_session_t session,
1623 int datalen, pos; 1623 int datalen, pos;
1624 1624
1625 ret = 1625 ret =
1626 mhd_gtls_supported_compression_methods (session, &compression_methods); 1626 MHD_gtls_supported_compression_methods (session, &compression_methods);
1627 if (ret < 0) 1627 if (ret < 0)
1628 { 1628 {
1629 gnutls_assert (); 1629 MHD_gnutls_assert ();
1630 return ret; 1630 return ret;
1631 } 1631 }
1632 1632
@@ -1637,7 +1637,7 @@ _gnutls_copy_comp_methods (mhd_gtls_session_t session,
1637 1637
1638 if ((size_t) datalen > ret_data_size) 1638 if ((size_t) datalen > ret_data_size)
1639 { 1639 {
1640 gnutls_assert (); 1640 MHD_gnutls_assert ();
1641 return GNUTLS_E_INTERNAL_ERROR; 1641 return GNUTLS_E_INTERNAL_ERROR;
1642 } 1642 }
1643 1643
@@ -1648,7 +1648,7 @@ _gnutls_copy_comp_methods (mhd_gtls_session_t session,
1648 ret_data[pos++] = compression_methods[i]; 1648 ret_data[pos++] = compression_methods[i];
1649 } 1649 }
1650 1650
1651 gnutls_free (compression_methods); 1651 MHD_gnutls_free (compression_methods);
1652 1652
1653 return datalen; 1653 return datalen;
1654} 1654}
@@ -1662,7 +1662,7 @@ _gnutls_copy_comp_methods (mhd_gtls_session_t session,
1662/* This function sends the client hello handshake message. 1662/* This function sends the client hello handshake message.
1663 */ 1663 */
1664static int 1664static int
1665_gnutls_send_client_hello (mhd_gtls_session_t session, int again) 1665MHD__gnutls_send_client_hello (MHD_gtls_session_t session, int again)
1666{ 1666{
1667 opaque *data = NULL; 1667 opaque *data = NULL;
1668 int extdatalen; 1668 int extdatalen;
@@ -1689,10 +1689,10 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1689 /* 2 for version, (4 for unix time + 28 for random bytes==TLS_RANDOM_SIZE) 1689 /* 2 for version, (4 for unix time + 28 for random bytes==TLS_RANDOM_SIZE)
1690 */ 1690 */
1691 1691
1692 data = gnutls_malloc (datalen); 1692 data = MHD_gnutls_malloc (datalen);
1693 if (data == NULL) 1693 if (data == NULL)
1694 { 1694 {
1695 gnutls_assert (); 1695 MHD_gnutls_assert ();
1696 return GNUTLS_E_MEMORY_ERROR; 1696 return GNUTLS_E_MEMORY_ERROR;
1697 } 1697 }
1698 1698
@@ -1700,7 +1700,7 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1700 * version number to the previously established. 1700 * version number to the previously established.
1701 */ 1701 */
1702 if (SessionID == NULL) 1702 if (SessionID == NULL)
1703 hver = mhd_gtls_version_max (session); 1703 hver = MHD_gtls_version_max (session);
1704 else 1704 else
1705 { /* we are resuming a session */ 1705 { /* we are resuming a session */
1706 hver = session->internals.resumed_security_parameters.version; 1706 hver = session->internals.resumed_security_parameters.version;
@@ -1708,18 +1708,18 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1708 1708
1709 if (hver == MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN || hver == 0) 1709 if (hver == MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN || hver == 0)
1710 { 1710 {
1711 gnutls_assert (); 1711 MHD_gnutls_assert ();
1712 gnutls_free (data); 1712 MHD_gnutls_free (data);
1713 return GNUTLS_E_INTERNAL_ERROR; 1713 return GNUTLS_E_INTERNAL_ERROR;
1714 } 1714 }
1715 1715
1716 data[pos++] = mhd_gtls_version_get_major (hver); 1716 data[pos++] = MHD_gtls_version_get_major (hver);
1717 data[pos++] = mhd_gtls_version_get_minor (hver); 1717 data[pos++] = MHD_gtls_version_get_minor (hver);
1718 1718
1719 /* Set the version we advertized as maximum 1719 /* Set the version we advertized as maximum
1720 * (RSA uses it). 1720 * (RSA uses it).
1721 */ 1721 */
1722 mhd_gtls_set_adv_version (session, hver); 1722 MHD_gtls_set_adv_version (session, hver);
1723 1723
1724 /* Some old implementations do not interoperate if we send a 1724 /* Some old implementations do not interoperate if we send a
1725 * different version in the record layer. 1725 * different version in the record layer.
@@ -1729,7 +1729,7 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1729 * handshake packet and ignore the one in the packet's record 1729 * handshake packet and ignore the one in the packet's record
1730 * header. 1730 * header.
1731 */ 1731 */
1732 mhd_gtls_set_current_version (session, hver); 1732 MHD_gtls_set_current_version (session, hver);
1733 1733
1734 /* In order to know when this session was initiated. 1734 /* In order to know when this session was initiated.
1735 */ 1735 */
@@ -1737,8 +1737,8 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1737 1737
1738 /* Generate random data 1738 /* Generate random data
1739 */ 1739 */
1740 mhd_gtls_tls_create_random (rnd); 1740 MHD_gtls_tls_create_random (rnd);
1741 mhd_gtls_set_client_random (session, rnd); 1741 MHD_gtls_set_client_random (session, rnd);
1742 1742
1743 memcpy (&data[pos], rnd, TLS_RANDOM_SIZE); 1743 memcpy (&data[pos], rnd, TLS_RANDOM_SIZE);
1744 pos += TLS_RANDOM_SIZE; 1744 pos += TLS_RANDOM_SIZE;
@@ -1756,14 +1756,14 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1756 /* Copy the ciphersuites. 1756 /* Copy the ciphersuites.
1757 */ 1757 */
1758 extdatalen = 1758 extdatalen =
1759 _gnutls_copy_ciphersuites (session, extdata, sizeof (extdata)); 1759 MHD__gnutls_copy_ciphersuites (session, extdata, sizeof (extdata));
1760 if (extdatalen > 0) 1760 if (extdatalen > 0)
1761 { 1761 {
1762 datalen += extdatalen; 1762 datalen += extdatalen;
1763 data = mhd_gtls_realloc_fast (data, datalen); 1763 data = MHD_gtls_realloc_fast (data, datalen);
1764 if (data == NULL) 1764 if (data == NULL)
1765 { 1765 {
1766 gnutls_assert (); 1766 MHD_gnutls_assert ();
1767 return GNUTLS_E_MEMORY_ERROR; 1767 return GNUTLS_E_MEMORY_ERROR;
1768 } 1768 }
1769 1769
@@ -1775,8 +1775,8 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1775 { 1775 {
1776 if (extdatalen == 0) 1776 if (extdatalen == 0)
1777 extdatalen = GNUTLS_E_INTERNAL_ERROR; 1777 extdatalen = GNUTLS_E_INTERNAL_ERROR;
1778 gnutls_free (data); 1778 MHD_gnutls_free (data);
1779 gnutls_assert (); 1779 MHD_gnutls_assert ();
1780 return extdatalen; 1780 return extdatalen;
1781 } 1781 }
1782 1782
@@ -1784,14 +1784,14 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1784 /* Copy the compression methods. 1784 /* Copy the compression methods.
1785 */ 1785 */
1786 extdatalen = 1786 extdatalen =
1787 _gnutls_copy_comp_methods (session, extdata, sizeof (extdata)); 1787 MHD__gnutls_copy_comp_methods (session, extdata, sizeof (extdata));
1788 if (extdatalen > 0) 1788 if (extdatalen > 0)
1789 { 1789 {
1790 datalen += extdatalen; 1790 datalen += extdatalen;
1791 data = mhd_gtls_realloc_fast (data, datalen); 1791 data = MHD_gtls_realloc_fast (data, datalen);
1792 if (data == NULL) 1792 if (data == NULL)
1793 { 1793 {
1794 gnutls_assert (); 1794 MHD_gnutls_assert ();
1795 return GNUTLS_E_MEMORY_ERROR; 1795 return GNUTLS_E_MEMORY_ERROR;
1796 } 1796 }
1797 1797
@@ -1803,8 +1803,8 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1803 { 1803 {
1804 if (extdatalen == 0) 1804 if (extdatalen == 0)
1805 extdatalen = GNUTLS_E_INTERNAL_ERROR; 1805 extdatalen = GNUTLS_E_INTERNAL_ERROR;
1806 gnutls_free (data); 1806 MHD_gnutls_free (data);
1807 gnutls_assert (); 1807 MHD_gnutls_assert ();
1808 return extdatalen; 1808 return extdatalen;
1809 } 1809 }
1810 1810
@@ -1813,15 +1813,15 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1813 if (hver >= MHD_GNUTLS_PROTOCOL_TLS1_0) 1813 if (hver >= MHD_GNUTLS_PROTOCOL_TLS1_0)
1814 { 1814 {
1815 extdatalen = 1815 extdatalen =
1816 mhd_gtls_gen_extensions (session, extdata, sizeof (extdata)); 1816 MHD_gtls_gen_extensions (session, extdata, sizeof (extdata));
1817 1817
1818 if (extdatalen > 0) 1818 if (extdatalen > 0)
1819 { 1819 {
1820 datalen += extdatalen; 1820 datalen += extdatalen;
1821 data = mhd_gtls_realloc_fast (data, datalen); 1821 data = MHD_gtls_realloc_fast (data, datalen);
1822 if (data == NULL) 1822 if (data == NULL)
1823 { 1823 {
1824 gnutls_assert (); 1824 MHD_gnutls_assert ();
1825 return GNUTLS_E_MEMORY_ERROR; 1825 return GNUTLS_E_MEMORY_ERROR;
1826 } 1826 }
1827 1827
@@ -1829,24 +1829,24 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again)
1829 } 1829 }
1830 else if (extdatalen < 0) 1830 else if (extdatalen < 0)
1831 { 1831 {
1832 gnutls_assert (); 1832 MHD_gnutls_assert ();
1833 gnutls_free (data); 1833 MHD_gnutls_free (data);
1834 return extdatalen; 1834 return extdatalen;
1835 } 1835 }
1836 } 1836 }
1837 } 1837 }
1838 1838
1839 ret = 1839 ret =
1840 mhd_gtls_send_handshake (session, data, datalen, 1840 MHD_gtls_send_handshake (session, data, datalen,
1841 GNUTLS_HANDSHAKE_CLIENT_HELLO); 1841 GNUTLS_HANDSHAKE_CLIENT_HELLO);
1842 gnutls_free (data); 1842 MHD_gnutls_free (data);
1843 1843
1844 return ret; 1844 return ret;
1845} 1845}
1846#endif 1846#endif
1847 1847
1848static int 1848static int
1849_gnutls_send_server_hello (mhd_gtls_session_t session, int again) 1849MHD__gnutls_send_server_hello (MHD_gtls_session_t session, int again)
1850{ 1850{
1851 opaque *data = NULL; 1851 opaque *data = NULL;
1852 opaque extdata[MAX_EXT_DATA_LENGTH]; 1852 opaque extdata[MAX_EXT_DATA_LENGTH];
@@ -1865,7 +1865,7 @@ _gnutls_send_server_hello (mhd_gtls_session_t session, int again)
1865 1865
1866#ifdef ENABLE_SRP 1866#ifdef ENABLE_SRP
1867 if (IS_SRP_KX 1867 if (IS_SRP_KX
1868 (mhd_gtls_cipher_suite_get_kx_algo 1868 (MHD_gtls_cipher_suite_get_kx_algo
1869 (&session->security_parameters.current_cipher_suite))) 1869 (&session->security_parameters.current_cipher_suite)))
1870 { 1870 {
1871 /* While resuming we cannot check the username extension since it is 1871 /* While resuming we cannot check the username extension since it is
@@ -1879,12 +1879,12 @@ _gnutls_send_server_hello (mhd_gtls_session_t session, int again)
1879 * SRP username. The draft requires that we send a fatal 1879 * SRP username. The draft requires that we send a fatal
1880 * alert and abort. 1880 * alert and abort.
1881 */ 1881 */
1882 gnutls_assert (); 1882 MHD_gnutls_assert ();
1883 ret = MHD_gnutls_alert_send (session, GNUTLS_AL_FATAL, 1883 ret = MHD__gnutls_alert_send (session, GNUTLS_AL_FATAL,
1884 GNUTLS_A_UNKNOWN_PSK_IDENTITY); 1884 GNUTLS_A_UNKNOWN_PSK_IDENTITY);
1885 if (ret < 0) 1885 if (ret < 0)
1886 { 1886 {
1887 gnutls_assert (); 1887 MHD_gnutls_assert ();
1888 return ret; 1888 return ret;
1889 } 1889 }
1890 1890
@@ -1897,25 +1897,25 @@ _gnutls_send_server_hello (mhd_gtls_session_t session, int again)
1897 { 1897 {
1898 datalen = 2 + session_id_len + 1 + TLS_RANDOM_SIZE + 3; 1898 datalen = 2 + session_id_len + 1 + TLS_RANDOM_SIZE + 3;
1899 extdatalen = 1899 extdatalen =
1900 mhd_gtls_gen_extensions (session, extdata, sizeof (extdata)); 1900 MHD_gtls_gen_extensions (session, extdata, sizeof (extdata));
1901 1901
1902 if (extdatalen < 0) 1902 if (extdatalen < 0)
1903 { 1903 {
1904 gnutls_assert (); 1904 MHD_gnutls_assert ();
1905 return extdatalen; 1905 return extdatalen;
1906 } 1906 }
1907 1907
1908 data = gnutls_alloca (datalen + extdatalen); 1908 data = MHD_gnutls_alloca (datalen + extdatalen);
1909 if (data == NULL) 1909 if (data == NULL)
1910 { 1910 {
1911 gnutls_assert (); 1911 MHD_gnutls_assert ();
1912 return GNUTLS_E_MEMORY_ERROR; 1912 return GNUTLS_E_MEMORY_ERROR;
1913 } 1913 }
1914 1914
1915 data[pos++] = 1915 data[pos++] =
1916 mhd_gtls_version_get_major (session->security_parameters.version); 1916 MHD_gtls_version_get_major (session->security_parameters.version);
1917 data[pos++] = 1917 data[pos++] =
1918 mhd_gtls_version_get_minor (session->security_parameters.version); 1918 MHD_gtls_version_get_minor (session->security_parameters.version);
1919 1919
1920 memcpy (&data[pos], 1920 memcpy (&data[pos],
1921 session->security_parameters.server_random, TLS_RANDOM_SIZE); 1921 session->security_parameters.server_random, TLS_RANDOM_SIZE);
@@ -1928,8 +1928,8 @@ _gnutls_send_server_hello (mhd_gtls_session_t session, int again)
1928 } 1928 }
1929 pos += session_id_len; 1929 pos += session_id_len;
1930 1930
1931 _gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session, 1931 MHD__gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session,
1932 mhd_gtls_bin2hex (SessionID, session_id_len, 1932 MHD_gtls_bin2hex (SessionID, session_id_len,
1933 buf, sizeof (buf))); 1933 buf, sizeof (buf)));
1934 1934
1935 memcpy (&data[pos], 1935 memcpy (&data[pos],
@@ -1937,7 +1937,7 @@ _gnutls_send_server_hello (mhd_gtls_session_t session, int again)
1937 pos += 2; 1937 pos += 2;
1938 1938
1939 comp = 1939 comp =
1940 (uint8_t) mhd_gtls_compression_get_num (session-> 1940 (uint8_t) MHD_gtls_compression_get_num (session->
1941 internals.compression_method); 1941 internals.compression_method);
1942 data[pos++] = comp; 1942 data[pos++] = comp;
1943 1943
@@ -1951,47 +1951,47 @@ _gnutls_send_server_hello (mhd_gtls_session_t session, int again)
1951 } 1951 }
1952 1952
1953 ret = 1953 ret =
1954 mhd_gtls_send_handshake (session, data, datalen, 1954 MHD_gtls_send_handshake (session, data, datalen,
1955 GNUTLS_HANDSHAKE_SERVER_HELLO); 1955 GNUTLS_HANDSHAKE_SERVER_HELLO);
1956 gnutls_afree (data); 1956 MHD_gnutls_afree (data);
1957 1957
1958 return ret; 1958 return ret;
1959} 1959}
1960 1960
1961int 1961int
1962mhd_gtls_send_hello (mhd_gtls_session_t session, int again) 1962MHD_gtls_send_hello (MHD_gtls_session_t session, int again)
1963{ 1963{
1964 int ret; 1964 int ret;
1965#if MHD_DEBUG_TLS 1965#if MHD_DEBUG_TLS
1966 if (session->security_parameters.entity == GNUTLS_CLIENT) 1966 if (session->security_parameters.entity == GNUTLS_CLIENT)
1967 { 1967 {
1968 ret = _gnutls_send_client_hello (session, again); 1968 ret = MHD__gnutls_send_client_hello (session, again);
1969 1969
1970 } 1970 }
1971 else 1971 else
1972#endif 1972#endif
1973 { /* SERVER */ 1973 { /* SERVER */
1974 ret = _gnutls_send_server_hello (session, again); 1974 ret = MHD__gnutls_send_server_hello (session, again);
1975 } 1975 }
1976 1976
1977 return ret; 1977 return ret;
1978} 1978}
1979 1979
1980/* RECEIVE A HELLO MESSAGE. This should be called from gnutls_recv_handshake_int only if a 1980/* RECEIVE A HELLO MESSAGE. This should be called from MHD_gnutls_recv_handshake_int only if a
1981 * hello message is expected. It uses the security_parameters.current_cipher_suite 1981 * hello message is expected. It uses the security_parameters.current_cipher_suite
1982 * and internals.compression_method. 1982 * and internals.compression_method.
1983 */ 1983 */
1984int 1984int
1985mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen) 1985MHD_gtls_recv_hello (MHD_gtls_session_t session, opaque * data, int datalen)
1986{ 1986{
1987 int ret; 1987 int ret;
1988#if MHD_DEBUG_TLS 1988#if MHD_DEBUG_TLS
1989 if (session->security_parameters.entity == GNUTLS_CLIENT) 1989 if (session->security_parameters.entity == GNUTLS_CLIENT)
1990 { 1990 {
1991 ret = _gnutls_read_server_hello (session, data, datalen); 1991 ret = MHD__gnutls_read_server_hello (session, data, datalen);
1992 if (ret < 0) 1992 if (ret < 0)
1993 { 1993 {
1994 gnutls_assert (); 1994 MHD_gnutls_assert ();
1995 return ret; 1995 return ret;
1996 } 1996 }
1997 } 1997 }
@@ -1999,10 +1999,10 @@ mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen)
1999#endif 1999#endif
2000 { /* Server side reading a client hello */ 2000 { /* Server side reading a client hello */
2001 2001
2002 ret = _gnutls_read_client_hello (session, data, datalen); 2002 ret = MHD__gnutls_read_client_hello (session, data, datalen);
2003 if (ret < 0) 2003 if (ret < 0)
2004 { 2004 {
2005 gnutls_assert (); 2005 MHD_gnutls_assert ();
2006 return ret; 2006 return ret;
2007 } 2007 }
2008 } 2008 }
@@ -2010,7 +2010,7 @@ mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen)
2010 return ret; 2010 return ret;
2011} 2011}
2012 2012
2013/* The packets in MHD_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 @@ mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen)
2034 */ 2034 */
2035 2035
2036/** 2036/**
2037 * MHD_gnutls_rehandshake - This function will renegotiate security parameters 2037 * MHD__gnutls_rehandshake - This function will renegotiate security parameters
2038 * @session: is a #mhd_gtls_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 @@ mhd_gtls_recv_hello (mhd_gtls_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 * MHD_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,18 +2057,18 @@ mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, int datalen)
2057 * 2057 *
2058 **/ 2058 **/
2059int 2059int
2060MHD_gnutls_rehandshake (mhd_gtls_session_t session) 2060MHD__gnutls_rehandshake (MHD_gtls_session_t session)
2061{ 2061{
2062 int ret; 2062 int ret;
2063 2063
2064 ret = 2064 ret =
2065 _gnutls_send_empty_handshake (session, GNUTLS_HANDSHAKE_HELLO_REQUEST, 2065 MHD__gnutls_send_empty_handshake (session, GNUTLS_HANDSHAKE_HELLO_REQUEST,
2066 AGAIN (STATE50)); 2066 AGAIN (STATE50));
2067 STATE = STATE50; 2067 STATE = STATE50;
2068 2068
2069 if (ret < 0) 2069 if (ret < 0)
2070 { 2070 {
2071 gnutls_assert (); 2071 MHD_gnutls_assert ();
2072 return ret; 2072 return ret;
2073 } 2073 }
2074 STATE = STATE0; 2074 STATE = STATE0;
@@ -2077,10 +2077,10 @@ MHD_gnutls_rehandshake (mhd_gtls_session_t session)
2077} 2077}
2078 2078
2079inline static int 2079inline static int
2080_gnutls_abort_handshake (mhd_gtls_session_t session, int ret) 2080MHD__gnutls_abort_handshake (MHD_gtls_session_t session, int ret)
2081{ 2081{
2082 if (((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) && 2082 if (((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) &&
2083 (gnutls_alert_get (session) == GNUTLS_A_NO_RENEGOTIATION)) 2083 (MHD_gnutls_alert_get (session) == GNUTLS_A_NO_RENEGOTIATION))
2084 || ret == GNUTLS_E_GOT_APPLICATION_DATA) 2084 || ret == GNUTLS_E_GOT_APPLICATION_DATA)
2085 return 0; 2085 return 0;
2086 2086
@@ -2092,17 +2092,17 @@ _gnutls_abort_handshake (mhd_gtls_session_t session, int ret)
2092 * required for finished messages. 2092 * required for finished messages.
2093 */ 2093 */
2094inline static int 2094inline static int
2095_gnutls_handshake_hash_init (mhd_gtls_session_t session) 2095MHD__gnutls_handshake_hash_init (MHD_gtls_session_t session)
2096{ 2096{
2097 2097
2098 if (session->internals.handshake_mac_handle_md5 == NULL) 2098 if (session->internals.handshake_mac_handle_md5 == NULL)
2099 { 2099 {
2100 session->internals.handshake_mac_handle_md5 = 2100 session->internals.handshake_mac_handle_md5 =
2101 mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5); 2101 MHD_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
2102 2102
2103 if (session->internals.handshake_mac_handle_md5 == GNUTLS_HASH_FAILED) 2103 if (session->internals.handshake_mac_handle_md5 == GNUTLS_HASH_FAILED)
2104 { 2104 {
2105 gnutls_assert (); 2105 MHD_gnutls_assert ();
2106 return GNUTLS_E_MEMORY_ERROR; 2106 return GNUTLS_E_MEMORY_ERROR;
2107 } 2107 }
2108 } 2108 }
@@ -2110,10 +2110,10 @@ _gnutls_handshake_hash_init (mhd_gtls_session_t session)
2110 if (session->internals.handshake_mac_handle_sha == NULL) 2110 if (session->internals.handshake_mac_handle_sha == NULL)
2111 { 2111 {
2112 session->internals.handshake_mac_handle_sha = 2112 session->internals.handshake_mac_handle_sha =
2113 mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1); 2113 MHD_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
2114 if (session->internals.handshake_mac_handle_sha == GNUTLS_HASH_FAILED) 2114 if (session->internals.handshake_mac_handle_sha == GNUTLS_HASH_FAILED)
2115 { 2115 {
2116 gnutls_assert (); 2116 MHD_gnutls_assert ();
2117 return GNUTLS_E_MEMORY_ERROR; 2117 return GNUTLS_E_MEMORY_ERROR;
2118 } 2118 }
2119 } 2119 }
@@ -2122,68 +2122,68 @@ _gnutls_handshake_hash_init (mhd_gtls_session_t session)
2122} 2122}
2123 2123
2124static int 2124static int
2125_gnutls_send_supplemental (mhd_gtls_session_t session, int again) 2125MHD__gnutls_send_supplemental (MHD_gtls_session_t session, int again)
2126{ 2126{
2127 int ret = 0; 2127 int ret = 0;
2128 2128
2129 _gnutls_debug_log ("EXT[%x]: Sending supplemental data\n", session); 2129 MHD__gnutls_debug_log ("EXT[%x]: Sending supplemental data\n", session);
2130 2130
2131 if (again) 2131 if (again)
2132 ret = mhd_gtls_send_handshake (session, NULL, 0, 2132 ret = MHD_gtls_send_handshake (session, NULL, 0,
2133 GNUTLS_HANDSHAKE_SUPPLEMENTAL); 2133 GNUTLS_HANDSHAKE_SUPPLEMENTAL);
2134 else 2134 else
2135 { 2135 {
2136 mhd_gtls_buffer buf; 2136 MHD_gtls_buffer buf;
2137 mhd_gtls_buffer_init (&buf); 2137 MHD_gtls_buffer_init (&buf);
2138 2138
2139 ret = _gnutls_gen_supplemental (session, &buf); 2139 ret = MHD__gnutls_gen_supplemental (session, &buf);
2140 if (ret < 0) 2140 if (ret < 0)
2141 { 2141 {
2142 gnutls_assert (); 2142 MHD_gnutls_assert ();
2143 return ret; 2143 return ret;
2144 } 2144 }
2145 2145
2146 ret = mhd_gtls_send_handshake (session, buf.data, buf.length, 2146 ret = MHD_gtls_send_handshake (session, buf.data, buf.length,
2147 GNUTLS_HANDSHAKE_SUPPLEMENTAL); 2147 GNUTLS_HANDSHAKE_SUPPLEMENTAL);
2148 mhd_gtls_buffer_clear (&buf); 2148 MHD_gtls_buffer_clear (&buf);
2149 } 2149 }
2150 2150
2151 return ret; 2151 return ret;
2152} 2152}
2153 2153
2154static int 2154static int
2155_gnutls_recv_supplemental (mhd_gtls_session_t session) 2155MHD__gnutls_recv_supplemental (MHD_gtls_session_t session)
2156{ 2156{
2157 uint8_t *data = NULL; 2157 uint8_t *data = NULL;
2158 int datalen = 0; 2158 int datalen = 0;
2159 int ret; 2159 int ret;
2160 2160
2161 _gnutls_debug_log ("EXT[%x]: Expecting supplemental data\n", session); 2161 MHD__gnutls_debug_log ("EXT[%x]: Expecting supplemental data\n", session);
2162 2162
2163 ret = mhd_gtls_recv_handshake (session, &data, &datalen, 2163 ret = MHD_gtls_recv_handshake (session, &data, &datalen,
2164 GNUTLS_HANDSHAKE_SUPPLEMENTAL, 2164 GNUTLS_HANDSHAKE_SUPPLEMENTAL,
2165 OPTIONAL_PACKET); 2165 OPTIONAL_PACKET);
2166 if (ret < 0) 2166 if (ret < 0)
2167 { 2167 {
2168 gnutls_assert (); 2168 MHD_gnutls_assert ();
2169 return ret; 2169 return ret;
2170 } 2170 }
2171 2171
2172 ret = _gnutls_parse_supplemental (session, data, datalen); 2172 ret = MHD__gnutls_parse_supplemental (session, data, datalen);
2173 if (ret < 0) 2173 if (ret < 0)
2174 { 2174 {
2175 gnutls_assert (); 2175 MHD_gnutls_assert ();
2176 return ret; 2176 return ret;
2177 } 2177 }
2178 2178
2179 gnutls_free (data); 2179 MHD_gnutls_free (data);
2180 2180
2181 return ret; 2181 return ret;
2182} 2182}
2183 2183
2184/** 2184/**
2185 * MHD_gnutls_handshake - This is the main function in the handshake protocol. 2185 * MHD__gnutls_handshake - This is the main function in the handshake protocol.
2186 * @session: is a #mhd_gtls_session_t structure. 2186 * @session: is a #MHD_gtls_session_t structure.
2187 * 2187 *
2188 * This function does the handshake of the TLS/SSL protocol, and 2188 * This function does the handshake of the TLS/SSL protocol, and
2189 * initializes the TLS connection. 2189 * initializes the TLS connection.
@@ -2196,7 +2196,7 @@ _gnutls_recv_supplemental (mhd_gtls_session_t session)
2196 * The non-fatal errors such as %GNUTLS_E_AGAIN and 2196 * The non-fatal errors such as %GNUTLS_E_AGAIN and
2197 * %GNUTLS_E_INTERRUPTED interrupt the handshake procedure, which 2197 * %GNUTLS_E_INTERRUPTED interrupt the handshake procedure, which
2198 * should be later be resumed. Call this function again, until it 2198 * should be later be resumed. Call this function again, until it
2199 * returns 0; cf. MHD_gnutls_record_get_direction() and 2199 * returns 0; cf. MHD__gnutls_record_get_direction() and
2200 * MHD_gtls_error_is_fatal(). 2200 * MHD_gtls_error_is_fatal().
2201 * 2201 *
2202 * If this function is called by a server after a rehandshake request 2202 * If this function is called by a server after a rehandshake request
@@ -2209,24 +2209,24 @@ _gnutls_recv_supplemental (mhd_gtls_session_t session)
2209 * 2209 *
2210 **/ 2210 **/
2211int 2211int
2212MHD_gnutls_handshake (mhd_gtls_session_t session) 2212MHD__gnutls_handshake (MHD_gtls_session_t session)
2213{ 2213{
2214 int ret; 2214 int ret;
2215 2215
2216 if ((ret = _gnutls_handshake_hash_init (session)) < 0) 2216 if ((ret = MHD__gnutls_handshake_hash_init (session)) < 0)
2217 { 2217 {
2218 gnutls_assert (); 2218 MHD_gnutls_assert ();
2219 return ret; 2219 return ret;
2220 } 2220 }
2221#if MHD_DEBUG_TLS 2221#if MHD_DEBUG_TLS
2222 if (session->security_parameters.entity == GNUTLS_CLIENT) 2222 if (session->security_parameters.entity == GNUTLS_CLIENT)
2223 { 2223 {
2224 ret = mhd_gtls_handshake_client (session); 2224 ret = MHD_gtls_handshake_client (session);
2225 } 2225 }
2226 else 2226 else
2227#endif 2227#endif
2228 { 2228 {
2229 ret = mhd_gtls_handshake_server (session); 2229 ret = MHD_gtls_handshake_server (session);
2230 } 2230 }
2231 2231
2232 if (ret < 0) 2232 if (ret < 0)
@@ -2234,17 +2234,17 @@ MHD_gnutls_handshake (mhd_gtls_session_t session)
2234 /* In the case of a rehandshake abort 2234 /* In the case of a rehandshake abort
2235 * we should reset the handshake's internal state. 2235 * we should reset the handshake's internal state.
2236 */ 2236 */
2237 if (_gnutls_abort_handshake (session, ret) == 0) 2237 if (MHD__gnutls_abort_handshake (session, ret) == 0)
2238 STATE = STATE0; 2238 STATE = STATE0;
2239 2239
2240 return ret; 2240 return ret;
2241 } 2241 }
2242 2242
2243 ret = mhd_gtls_handshake_common (session); 2243 ret = MHD_gtls_handshake_common (session);
2244 2244
2245 if (ret < 0) 2245 if (ret < 0)
2246 { 2246 {
2247 if (_gnutls_abort_handshake (session, ret) == 0) 2247 if (MHD__gnutls_abort_handshake (session, ret) == 0)
2248 STATE = STATE0; 2248 STATE = STATE0;
2249 2249
2250 return ret; 2250 return ret;
@@ -2252,8 +2252,8 @@ MHD_gnutls_handshake (mhd_gtls_session_t session)
2252 2252
2253 STATE = STATE0; 2253 STATE = STATE0;
2254 2254
2255 _gnutls_handshake_io_buffer_clear (session); 2255 MHD__gnutls_handshake_io_buffer_clear (session);
2256 mhd_gtls_handshake_internal_state_clear (session); 2256 MHD_gtls_handshake_internal_state_clear (session);
2257 2257
2258 return 0; 2258 return 0;
2259} 2259}
@@ -2261,20 +2261,20 @@ MHD_gnutls_handshake (mhd_gtls_session_t session)
2261#define IMED_RET( str, ret) do { \ 2261#define IMED_RET( str, ret) do { \
2262 if (ret < 0) { \ 2262 if (ret < 0) { \
2263 if (MHD_gtls_error_is_fatal(ret)==0) return ret; \ 2263 if (MHD_gtls_error_is_fatal(ret)==0) return ret; \
2264 gnutls_assert(); \ 2264 MHD_gnutls_assert(); \
2265 ERR( str, ret); \ 2265 ERR( str, ret); \
2266 _gnutls_handshake_hash_buffers_clear(session); \ 2266 MHD__gnutls_handshake_hash_buffers_clear(session); \
2267 return ret; \ 2267 return ret; \
2268 } } while (0) 2268 } } while (0)
2269 2269
2270 2270
2271#if MHD_DEBUG_TLS 2271#if MHD_DEBUG_TLS
2272/* 2272/*
2273 * mhd_gtls_handshake_client 2273 * MHD_gtls_handshake_client
2274 * This function performs the client side of the handshake of the TLS/SSL protocol. 2274 * This function performs the client side of the handshake of the TLS/SSL protocol.
2275 */ 2275 */
2276int 2276int
2277mhd_gtls_handshake_client (mhd_gtls_session_t session) 2277MHD_gtls_handshake_client (MHD_gtls_session_t session)
2278{ 2278{
2279 int ret = 0; 2279 int ret = 0;
2280 2280
@@ -2282,8 +2282,8 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2282 char buf[64]; 2282 char buf[64];
2283 2283
2284 if (session->internals.resumed_security_parameters.session_id_size > 0) 2284 if (session->internals.resumed_security_parameters.session_id_size > 0)
2285 _gnutls_handshake_log ("HSK[%x]: Ask to resume: %s\n", session, 2285 MHD__gnutls_handshake_log ("HSK[%x]: Ask to resume: %s\n", session,
2286 mhd_gtls_bin2hex (session->internals. 2286 MHD_gtls_bin2hex (session->internals.
2287 resumed_security_parameters. 2287 resumed_security_parameters.
2288 session_id, 2288 session_id,
2289 session->internals. 2289 session->internals.
@@ -2296,14 +2296,14 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2296 { 2296 {
2297 case STATE0: 2297 case STATE0:
2298 case STATE1: 2298 case STATE1:
2299 ret = mhd_gtls_send_hello (session, AGAIN (STATE1)); 2299 ret = MHD_gtls_send_hello (session, AGAIN (STATE1));
2300 STATE = STATE1; 2300 STATE = STATE1;
2301 IMED_RET ("send hello", ret); 2301 IMED_RET ("send hello", ret);
2302 2302
2303 case STATE2: 2303 case STATE2:
2304 /* receive the server hello */ 2304 /* receive the server hello */
2305 ret = 2305 ret =
2306 mhd_gtls_recv_handshake (session, NULL, NULL, 2306 MHD_gtls_recv_handshake (session, NULL, NULL,
2307 GNUTLS_HANDSHAKE_SERVER_HELLO, 2307 GNUTLS_HANDSHAKE_SERVER_HELLO,
2308 MANDATORY_PACKET); 2308 MANDATORY_PACKET);
2309 STATE = STATE2; 2309 STATE = STATE2;
@@ -2312,7 +2312,7 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2312 case STATE70: 2312 case STATE70:
2313 if (session->security_parameters.extensions.do_recv_supplemental) 2313 if (session->security_parameters.extensions.do_recv_supplemental)
2314 { 2314 {
2315 ret = _gnutls_recv_supplemental (session); 2315 ret = MHD__gnutls_recv_supplemental (session);
2316 STATE = STATE70; 2316 STATE = STATE70;
2317 IMED_RET ("recv supplemental", ret); 2317 IMED_RET ("recv supplemental", ret);
2318 } 2318 }
@@ -2320,14 +2320,14 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2320 case STATE3: 2320 case STATE3:
2321 /* RECV CERTIFICATE */ 2321 /* RECV CERTIFICATE */
2322 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2322 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2323 ret = mhd_gtls_recv_server_certificate (session); 2323 ret = MHD_gtls_recv_server_certificate (session);
2324 STATE = STATE3; 2324 STATE = STATE3;
2325 IMED_RET ("recv server certificate", ret); 2325 IMED_RET ("recv server certificate", ret);
2326 2326
2327 case STATE4: 2327 case STATE4:
2328 /* receive the server key exchange */ 2328 /* receive the server key exchange */
2329 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2329 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2330 ret = mhd_gtls_recv_server_kx_message (session); 2330 ret = MHD_gtls_recv_server_kx_message (session);
2331 STATE = STATE4; 2331 STATE = STATE4;
2332 IMED_RET ("recv server kx message", ret); 2332 IMED_RET ("recv server kx message", ret);
2333 2333
@@ -2336,7 +2336,7 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2336 */ 2336 */
2337 2337
2338 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2338 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2339 ret = mhd_gtls_recv_server_certificate_request (session); 2339 ret = MHD_gtls_recv_server_certificate_request (session);
2340 STATE = STATE5; 2340 STATE = STATE5;
2341 IMED_RET ("recv server certificate request message", ret); 2341 IMED_RET ("recv server certificate request message", ret);
2342 2342
@@ -2344,7 +2344,7 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2344 /* receive the server hello done */ 2344 /* receive the server hello done */
2345 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2345 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2346 ret = 2346 ret =
2347 mhd_gtls_recv_handshake (session, NULL, NULL, 2347 MHD_gtls_recv_handshake (session, NULL, NULL,
2348 GNUTLS_HANDSHAKE_SERVER_HELLO_DONE, 2348 GNUTLS_HANDSHAKE_SERVER_HELLO_DONE,
2349 MANDATORY_PACKET); 2349 MANDATORY_PACKET);
2350 STATE = STATE6; 2350 STATE = STATE6;
@@ -2353,7 +2353,7 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2353 case STATE71: 2353 case STATE71:
2354 if (session->security_parameters.extensions.do_send_supplemental) 2354 if (session->security_parameters.extensions.do_send_supplemental)
2355 { 2355 {
2356 ret = _gnutls_send_supplemental (session, AGAIN (STATE71)); 2356 ret = MHD__gnutls_send_supplemental (session, AGAIN (STATE71));
2357 STATE = STATE71; 2357 STATE = STATE71;
2358 IMED_RET ("send supplemental", ret); 2358 IMED_RET ("send supplemental", ret);
2359 } 2359 }
@@ -2362,13 +2362,13 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2362 /* send our certificate - if any and if requested 2362 /* send our certificate - if any and if requested
2363 */ 2363 */
2364 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2364 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2365 ret = mhd_gtls_send_client_certificate (session, AGAIN (STATE7)); 2365 ret = MHD_gtls_send_client_certificate (session, AGAIN (STATE7));
2366 STATE = STATE7; 2366 STATE = STATE7;
2367 IMED_RET ("send client certificate", ret); 2367 IMED_RET ("send client certificate", ret);
2368 2368
2369 case STATE8: 2369 case STATE8:
2370 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2370 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2371 ret = mhd_gtls_send_client_kx_message (session, AGAIN (STATE8)); 2371 ret = MHD_gtls_send_client_kx_message (session, AGAIN (STATE8));
2372 STATE = STATE8; 2372 STATE = STATE8;
2373 IMED_RET ("send client kx", ret); 2373 IMED_RET ("send client kx", ret);
2374 2374
@@ -2376,7 +2376,7 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2376 /* send client certificate verify */ 2376 /* send client certificate verify */
2377 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2377 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2378 ret = 2378 ret =
2379 mhd_gtls_send_client_certificate_verify (session, AGAIN (STATE9)); 2379 MHD_gtls_send_client_certificate_verify (session, AGAIN (STATE9));
2380 STATE = STATE9; 2380 STATE = STATE9;
2381 IMED_RET ("send client certificate verify", ret); 2381 IMED_RET ("send client certificate verify", ret);
2382 2382
@@ -2393,7 +2393,7 @@ mhd_gtls_handshake_client (mhd_gtls_session_t session)
2393/* This function sends the final handshake packets and initializes connection 2393/* This function sends the final handshake packets and initializes connection
2394 */ 2394 */
2395static int 2395static int
2396_gnutls_send_handshake_final (mhd_gtls_session_t session, int init) 2396MHD__gnutls_send_handshake_final (MHD_gtls_session_t session, int init)
2397{ 2397{
2398 int ret = 0; 2398 int ret = 0;
2399 2399
@@ -2403,12 +2403,12 @@ _gnutls_send_handshake_final (mhd_gtls_session_t session, int init)
2403 { 2403 {
2404 case STATE0: 2404 case STATE0:
2405 case STATE20: 2405 case STATE20:
2406 ret = mhd_gtls_send_change_cipher_spec (session, AGAIN (STATE20)); 2406 ret = MHD_gtls_send_change_cipher_spec (session, AGAIN (STATE20));
2407 STATE = STATE20; 2407 STATE = STATE20;
2408 if (ret < 0) 2408 if (ret < 0)
2409 { 2409 {
2410 ERR ("send ChangeCipherSpec", ret); 2410 ERR ("send ChangeCipherSpec", ret);
2411 gnutls_assert (); 2411 MHD_gnutls_assert ();
2412 return ret; 2412 return ret;
2413 } 2413 }
2414 2414
@@ -2416,29 +2416,29 @@ _gnutls_send_handshake_final (mhd_gtls_session_t session, int init)
2416 */ 2416 */
2417 if (init == TRUE) 2417 if (init == TRUE)
2418 { 2418 {
2419 ret = mhd_gtls_connection_state_init (session); 2419 ret = MHD_gtls_connection_state_init (session);
2420 if (ret < 0) 2420 if (ret < 0)
2421 { 2421 {
2422 gnutls_assert (); 2422 MHD_gnutls_assert ();
2423 return ret; 2423 return ret;
2424 } 2424 }
2425 } 2425 }
2426 2426
2427 ret = mhd_gtls_write_connection_state_init (session); 2427 ret = MHD_gtls_write_connection_state_init (session);
2428 if (ret < 0) 2428 if (ret < 0)
2429 { 2429 {
2430 gnutls_assert (); 2430 MHD_gnutls_assert ();
2431 return ret; 2431 return ret;
2432 } 2432 }
2433 2433
2434 case STATE21: 2434 case STATE21:
2435 /* send the finished message */ 2435 /* send the finished message */
2436 ret = _gnutls_send_finished (session, AGAIN (STATE21)); 2436 ret = MHD__gnutls_send_finished (session, AGAIN (STATE21));
2437 STATE = STATE21; 2437 STATE = STATE21;
2438 if (ret < 0) 2438 if (ret < 0)
2439 { 2439 {
2440 ERR ("send Finished", ret); 2440 ERR ("send Finished", ret);
2441 gnutls_assert (); 2441 MHD_gnutls_assert ();
2442 return ret; 2442 return ret;
2443 } 2443 }
2444 2444
@@ -2455,7 +2455,7 @@ _gnutls_send_handshake_final (mhd_gtls_session_t session, int init)
2455 * read session. 2455 * read session.
2456 */ 2456 */
2457static int 2457static int
2458_gnutls_recv_handshake_final (mhd_gtls_session_t session, int init) 2458MHD__gnutls_recv_handshake_final (MHD_gtls_session_t session, int init)
2459{ 2459{
2460 int ret = 0; 2460 int ret = 0;
2461 uint8_t ch; 2461 uint8_t ch;
@@ -2465,40 +2465,40 @@ _gnutls_recv_handshake_final (mhd_gtls_session_t session, int init)
2465 case STATE0: 2465 case STATE0:
2466 case STATE30: 2466 case STATE30:
2467 ret = 2467 ret =
2468 mhd_gtls_recv_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, &ch, 1); 2468 MHD_gtls_recv_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, &ch, 1);
2469 STATE = STATE30; 2469 STATE = STATE30;
2470 if (ret <= 0) 2470 if (ret <= 0)
2471 { 2471 {
2472 ERR ("recv ChangeCipherSpec", ret); 2472 ERR ("recv ChangeCipherSpec", ret);
2473 gnutls_assert (); 2473 MHD_gnutls_assert ();
2474 return (ret < 0) ? ret : GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 2474 return (ret < 0) ? ret : GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
2475 } 2475 }
2476 2476
2477 /* Initialize the connection session (start encryption) - in case of server */ 2477 /* Initialize the connection session (start encryption) - in case of server */
2478 if (init == TRUE) 2478 if (init == TRUE)
2479 { 2479 {
2480 ret = mhd_gtls_connection_state_init (session); 2480 ret = MHD_gtls_connection_state_init (session);
2481 if (ret < 0) 2481 if (ret < 0)
2482 { 2482 {
2483 gnutls_assert (); 2483 MHD_gnutls_assert ();
2484 return ret; 2484 return ret;
2485 } 2485 }
2486 } 2486 }
2487 2487
2488 ret = mhd_gtls_read_connection_state_init (session); 2488 ret = MHD_gtls_read_connection_state_init (session);
2489 if (ret < 0) 2489 if (ret < 0)
2490 { 2490 {
2491 gnutls_assert (); 2491 MHD_gnutls_assert ();
2492 return ret; 2492 return ret;
2493 } 2493 }
2494 2494
2495 case STATE31: 2495 case STATE31:
2496 ret = _gnutls_recv_finished (session); 2496 ret = MHD__gnutls_recv_finished (session);
2497 STATE = STATE31; 2497 STATE = STATE31;
2498 if (ret < 0) 2498 if (ret < 0)
2499 { 2499 {
2500 ERR ("recv finished", ret); 2500 ERR ("recv finished", ret);
2501 gnutls_assert (); 2501 MHD_gnutls_assert ();
2502 return ret; 2502 return ret;
2503 } 2503 }
2504 STATE = STATE0; 2504 STATE = STATE0;
@@ -2511,12 +2511,12 @@ _gnutls_recv_handshake_final (mhd_gtls_session_t session, int init)
2511} 2511}
2512 2512
2513 /* 2513 /*
2514 * mhd_gtls_handshake_server 2514 * MHD_gtls_handshake_server
2515 * This function does the server stuff of the handshake protocol. 2515 * This function does the server stuff of the handshake protocol.
2516 */ 2516 */
2517 2517
2518int 2518int
2519mhd_gtls_handshake_server (mhd_gtls_session_t session) 2519MHD_gtls_handshake_server (MHD_gtls_session_t session)
2520{ 2520{
2521 int ret = 0; 2521 int ret = 0;
2522 2522
@@ -2525,21 +2525,21 @@ mhd_gtls_handshake_server (mhd_gtls_session_t session)
2525 case STATE0: 2525 case STATE0:
2526 case STATE1: 2526 case STATE1:
2527 ret = 2527 ret =
2528 mhd_gtls_recv_handshake (session, NULL, NULL, 2528 MHD_gtls_recv_handshake (session, NULL, NULL,
2529 GNUTLS_HANDSHAKE_CLIENT_HELLO, 2529 GNUTLS_HANDSHAKE_CLIENT_HELLO,
2530 MANDATORY_PACKET); 2530 MANDATORY_PACKET);
2531 STATE = STATE1; 2531 STATE = STATE1;
2532 IMED_RET ("recv hello", ret); 2532 IMED_RET ("recv hello", ret);
2533 2533
2534 case STATE2: 2534 case STATE2:
2535 ret = mhd_gtls_send_hello (session, AGAIN (STATE2)); 2535 ret = MHD_gtls_send_hello (session, AGAIN (STATE2));
2536 STATE = STATE2; 2536 STATE = STATE2;
2537 IMED_RET ("send hello", ret); 2537 IMED_RET ("send hello", ret);
2538 2538
2539 case STATE70: 2539 case STATE70:
2540 if (session->security_parameters.extensions.do_send_supplemental) 2540 if (session->security_parameters.extensions.do_send_supplemental)
2541 { 2541 {
2542 ret = _gnutls_send_supplemental (session, AGAIN (STATE70)); 2542 ret = MHD__gnutls_send_supplemental (session, AGAIN (STATE70));
2543 STATE = STATE70; 2543 STATE = STATE70;
2544 IMED_RET ("send supplemental data", ret); 2544 IMED_RET ("send supplemental data", ret);
2545 } 2545 }
@@ -2549,14 +2549,14 @@ mhd_gtls_handshake_server (mhd_gtls_session_t session)
2549 /* NOTE: these should not be send if we are resuming */ 2549 /* NOTE: these should not be send if we are resuming */
2550 2550
2551 if (session->internals.resumed == RESUME_FALSE) 2551 if (session->internals.resumed == RESUME_FALSE)
2552 ret = mhd_gtls_send_server_certificate (session, AGAIN (STATE3)); 2552 ret = MHD_gtls_send_server_certificate (session, AGAIN (STATE3));
2553 STATE = STATE3; 2553 STATE = STATE3;
2554 IMED_RET ("send server certificate", ret); 2554 IMED_RET ("send server certificate", ret);
2555 2555
2556 case STATE4: 2556 case STATE4:
2557 /* send server key exchange (A) */ 2557 /* send server key exchange (A) */
2558 if (session->internals.resumed == RESUME_FALSE) 2558 if (session->internals.resumed == RESUME_FALSE)
2559 ret = mhd_gtls_send_server_kx_message (session, AGAIN (STATE4)); 2559 ret = MHD_gtls_send_server_kx_message (session, AGAIN (STATE4));
2560 STATE = STATE4; 2560 STATE = STATE4;
2561 IMED_RET ("send server kx", ret); 2561 IMED_RET ("send server kx", ret);
2562 2562
@@ -2564,7 +2564,7 @@ mhd_gtls_handshake_server (mhd_gtls_session_t session)
2564 /* Send certificate request - if requested to */ 2564 /* Send certificate request - if requested to */
2565 if (session->internals.resumed == RESUME_FALSE) 2565 if (session->internals.resumed == RESUME_FALSE)
2566 ret = 2566 ret =
2567 mhd_gtls_send_server_certificate_request (session, AGAIN (STATE5)); 2567 MHD_gtls_send_server_certificate_request (session, AGAIN (STATE5));
2568 STATE = STATE5; 2568 STATE = STATE5;
2569 IMED_RET ("send server cert request", ret); 2569 IMED_RET ("send server cert request", ret);
2570 2570
@@ -2572,7 +2572,7 @@ mhd_gtls_handshake_server (mhd_gtls_session_t session)
2572 /* send the server hello done */ 2572 /* send the server hello done */
2573 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2573 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2574 ret = 2574 ret =
2575 _gnutls_send_empty_handshake (session, 2575 MHD__gnutls_send_empty_handshake (session,
2576 GNUTLS_HANDSHAKE_SERVER_HELLO_DONE, 2576 GNUTLS_HANDSHAKE_SERVER_HELLO_DONE,
2577 AGAIN (STATE6)); 2577 AGAIN (STATE6));
2578 STATE = STATE6; 2578 STATE = STATE6;
@@ -2581,7 +2581,7 @@ mhd_gtls_handshake_server (mhd_gtls_session_t session)
2581 case STATE71: 2581 case STATE71:
2582 if (session->security_parameters.extensions.do_recv_supplemental) 2582 if (session->security_parameters.extensions.do_recv_supplemental)
2583 { 2583 {
2584 ret = _gnutls_recv_supplemental (session); 2584 ret = MHD__gnutls_recv_supplemental (session);
2585 STATE = STATE71; 2585 STATE = STATE71;
2586 IMED_RET ("recv client supplemental", ret); 2586 IMED_RET ("recv client supplemental", ret);
2587 } 2587 }
@@ -2590,21 +2590,21 @@ mhd_gtls_handshake_server (mhd_gtls_session_t session)
2590 case STATE7: 2590 case STATE7:
2591 /* receive the client certificate message */ 2591 /* receive the client certificate message */
2592 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2592 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2593 ret = mhd_gtls_recv_client_certificate (session); 2593 ret = MHD_gtls_recv_client_certificate (session);
2594 STATE = STATE7; 2594 STATE = STATE7;
2595 IMED_RET ("recv client certificate", ret); 2595 IMED_RET ("recv client certificate", ret);
2596 2596
2597 case STATE8: 2597 case STATE8:
2598 /* receive the client key exchange message */ 2598 /* receive the client key exchange message */
2599 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2599 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2600 ret = mhd_gtls_recv_client_kx_message (session); 2600 ret = MHD_gtls_recv_client_kx_message (session);
2601 STATE = STATE8; 2601 STATE = STATE8;
2602 IMED_RET ("recv client kx", ret); 2602 IMED_RET ("recv client kx", ret);
2603 2603
2604 case STATE9: 2604 case STATE9:
2605 /* receive the client certificate verify message */ 2605 /* receive the client certificate verify message */
2606 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ 2606 if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
2607 ret = mhd_gtls_recv_client_certificate_verify_message (session); 2607 ret = MHD_gtls_recv_client_certificate_verify_message (session);
2608 STATE = STATE9; 2608 STATE = STATE9;
2609 IMED_RET ("recv client certificate verify", ret); 2609 IMED_RET ("recv client certificate verify", ret);
2610 2610
@@ -2617,7 +2617,7 @@ mhd_gtls_handshake_server (mhd_gtls_session_t session)
2617} 2617}
2618 2618
2619int 2619int
2620mhd_gtls_handshake_common (mhd_gtls_session_t session) 2620MHD_gtls_handshake_common (MHD_gtls_session_t session)
2621{ 2621{
2622 int ret = 0; 2622 int ret = 0;
2623 2623
@@ -2629,36 +2629,36 @@ mhd_gtls_handshake_common (mhd_gtls_session_t session)
2629 { 2629 {
2630 /* if we are a client resuming - or we are a server not resuming */ 2630 /* if we are a client resuming - or we are a server not resuming */
2631 2631
2632 ret = _gnutls_recv_handshake_final (session, TRUE); 2632 ret = MHD__gnutls_recv_handshake_final (session, TRUE);
2633 IMED_RET ("recv handshake final", ret); 2633 IMED_RET ("recv handshake final", ret);
2634 2634
2635 ret = _gnutls_send_handshake_final (session, FALSE); 2635 ret = MHD__gnutls_send_handshake_final (session, FALSE);
2636 IMED_RET ("send handshake final", ret); 2636 IMED_RET ("send handshake final", ret);
2637 } 2637 }
2638 else 2638 else
2639 { /* if we are a client not resuming - or we are a server resuming */ 2639 { /* if we are a client not resuming - or we are a server resuming */
2640 2640
2641 ret = _gnutls_send_handshake_final (session, TRUE); 2641 ret = MHD__gnutls_send_handshake_final (session, TRUE);
2642 IMED_RET ("send handshake final 2", ret); 2642 IMED_RET ("send handshake final 2", ret);
2643 2643
2644 ret = _gnutls_recv_handshake_final (session, FALSE); 2644 ret = MHD__gnutls_recv_handshake_final (session, FALSE);
2645 IMED_RET ("recv handshake final 2", ret); 2645 IMED_RET ("recv handshake final 2", ret);
2646 } 2646 }
2647 2647
2648 /* clear handshake buffer */ 2648 /* clear handshake buffer */
2649 _gnutls_handshake_hash_buffers_clear (session); 2649 MHD__gnutls_handshake_hash_buffers_clear (session);
2650 return ret; 2650 return ret;
2651 2651
2652} 2652}
2653 2653
2654int 2654int
2655mhd_gtls_generate_session_id (opaque * session_id, uint8_t * len) 2655MHD_gtls_generate_session_id (opaque * session_id, uint8_t * len)
2656{ 2656{
2657 *len = TLS_MAX_SESSION_ID_SIZE; 2657 *len = TLS_MAX_SESSION_ID_SIZE;
2658 2658
2659 if (gc_nonce (session_id, *len) != GC_OK) 2659 if (MHD_gc_nonce (session_id, *len) != GC_OK)
2660 { 2660 {
2661 gnutls_assert (); 2661 MHD_gnutls_assert ();
2662 return GNUTLS_E_RANDOM_FAILED; 2662 return GNUTLS_E_RANDOM_FAILED;
2663 } 2663 }
2664 2664
@@ -2666,19 +2666,19 @@ mhd_gtls_generate_session_id (opaque * session_id, uint8_t * len)
2666} 2666}
2667 2667
2668int 2668int
2669mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data, 2669MHD_gtls_recv_hello_request (MHD_gtls_session_t session, void *data,
2670 uint32_t data_size) 2670 uint32_t data_size)
2671{ 2671{
2672 uint8_t type; 2672 uint8_t type;
2673 2673
2674 if (session->security_parameters.entity == GNUTLS_SERVER) 2674 if (session->security_parameters.entity == GNUTLS_SERVER)
2675 { 2675 {
2676 gnutls_assert (); 2676 MHD_gnutls_assert ();
2677 return GNUTLS_E_UNEXPECTED_PACKET; 2677 return GNUTLS_E_UNEXPECTED_PACKET;
2678 } 2678 }
2679 if (data_size < 1) 2679 if (data_size < 1)
2680 { 2680 {
2681 gnutls_assert (); 2681 MHD_gnutls_assert ();
2682 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 2682 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
2683 } 2683 }
2684 type = ((uint8_t *) data)[0]; 2684 type = ((uint8_t *) data)[0];
@@ -2686,7 +2686,7 @@ mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data,
2686 return GNUTLS_E_REHANDSHAKE; 2686 return GNUTLS_E_REHANDSHAKE;
2687 else 2687 else
2688 { 2688 {
2689 gnutls_assert (); 2689 MHD_gnutls_assert ();
2690 return GNUTLS_E_UNEXPECTED_PACKET; 2690 return GNUTLS_E_UNEXPECTED_PACKET;
2691 } 2691 }
2692} 2692}
@@ -2695,33 +2695,33 @@ mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data,
2695 * (DH or RSA) set up. Otherwise returns 0. 2695 * (DH or RSA) set up. Otherwise returns 0.
2696 */ 2696 */
2697inline static int 2697inline static int
2698check_server_params (mhd_gtls_session_t session, 2698check_server_params (MHD_gtls_session_t session,
2699 enum MHD_GNUTLS_KeyExchangeAlgorithm kx, 2699 enum MHD_GNUTLS_KeyExchangeAlgorithm kx,
2700 enum MHD_GNUTLS_KeyExchangeAlgorithm *alg, int alg_size) 2700 enum MHD_GNUTLS_KeyExchangeAlgorithm *alg, int alg_size)
2701{ 2701{
2702 int cred_type; 2702 int cred_type;
2703 mhd_gtls_dh_params_t dh_params = NULL; 2703 MHD_gtls_dh_params_t dh_params = NULL;
2704 mhd_gtls_rsa_params_t rsa_params = NULL; 2704 MHD_gtls_rsa_params_t rsa_params = NULL;
2705 int j; 2705 int j;
2706 2706
2707 cred_type = mhd_gtls_map_kx_get_cred (kx, 1); 2707 cred_type = MHD_gtls_map_kx_get_cred (kx, 1);
2708 2708
2709 /* Read the Diffie Hellman parameters, if any. 2709 /* Read the Diffie Hellman parameters, if any.
2710 */ 2710 */
2711 if (cred_type == MHD_GNUTLS_CRD_CERTIFICATE) 2711 if (cred_type == MHD_GNUTLS_CRD_CERTIFICATE)
2712 { 2712 {
2713 int delete; 2713 int delete;
2714 mhd_gtls_cert_credentials_t x509_cred = 2714 MHD_gtls_cert_credentials_t x509_cred =
2715 (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key, 2715 (MHD_gtls_cert_credentials_t) MHD_gtls_get_cred (session->key,
2716 cred_type, NULL); 2716 cred_type, NULL);
2717 2717
2718 if (x509_cred != NULL) 2718 if (x509_cred != NULL)
2719 { 2719 {
2720 dh_params = 2720 dh_params =
2721 mhd_gtls_get_dh_params (x509_cred->dh_params, 2721 MHD_gtls_get_dh_params (x509_cred->dh_params,
2722 x509_cred->params_func, session); 2722 x509_cred->params_func, session);
2723 rsa_params = 2723 rsa_params =
2724 mhd_gtls_certificate_get_rsa_params (x509_cred->rsa_params, 2724 MHD_gtls_certificate_get_rsa_params (x509_cred->rsa_params,
2725 x509_cred->params_func, 2725 x509_cred->params_func,
2726 session); 2726 session);
2727 } 2727 }
@@ -2746,15 +2746,15 @@ check_server_params (mhd_gtls_session_t session,
2746 } 2746 }
2747 else if (cred_type == MHD_GNUTLS_CRD_ANON) 2747 else if (cred_type == MHD_GNUTLS_CRD_ANON)
2748 { 2748 {
2749 mhd_gtls_anon_server_credentials_t anon_cred = 2749 MHD_gtls_anon_server_credentials_t anon_cred =
2750 (mhd_gtls_anon_server_credentials_t) mhd_gtls_get_cred (session->key, 2750 (MHD_gtls_anon_server_credentials_t) MHD_gtls_get_cred (session->key,
2751 cred_type, 2751 cred_type,
2752 NULL); 2752 NULL);
2753 2753
2754 if (anon_cred != NULL) 2754 if (anon_cred != NULL)
2755 { 2755 {
2756 dh_params = 2756 dh_params =
2757 mhd_gtls_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
@@ -2762,14 +2762,14 @@ check_server_params (mhd_gtls_session_t session,
2762 } 2762 }
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 MHD_gnutls_psk_server_credentials_t psk_cred =
2766 (gnutls_psk_server_credentials_t) mhd_gtls_get_cred (session->key, 2766 (MHD_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 mhd_gtls_get_dh_params (psk_cred->dh_params, 2772 MHD_gtls_get_dh_params (psk_cred->dh_params,
2773 psk_cred->params_func, session); 2773 psk_cred->params_func, session);
2774 } 2774 }
2775#endif 2775#endif
@@ -2781,22 +2781,22 @@ check_server_params (mhd_gtls_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 (mhd_gtls_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 (MHD__gnutls_rsa_params_to_mpi (rsa_params) == NULL)
2788 { 2788 {
2789 gnutls_assert (); 2789 MHD_gnutls_assert ();
2790 return 1; 2790 return 1;
2791 } 2791 }
2792 } 2792 }
2793 2793
2794 if (mhd_gtls_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 (mhd_gtls_dh_params_to_mpi (dh_params) == NULL) 2797 if (MHD_gtls_dh_params_to_mpi (dh_params) == NULL)
2798 { 2798 {
2799 gnutls_assert (); 2799 MHD_gnutls_assert ();
2800 return 1; 2800 return 1;
2801 } 2801 }
2802 } 2802 }
@@ -2808,11 +2808,11 @@ check_server_params (mhd_gtls_session_t session,
2808 * the requested authentication method. We remove an algorithm if 2808 * the requested authentication method. We remove an algorithm if
2809 * we have a certificate with keyUsage bits set. 2809 * we have a certificate with keyUsage bits set.
2810 * 2810 *
2811 * This does a more high level check than gnutls_supported_ciphersuites(), 2811 * This does a more high level check than MHD_gnutls_supported_ciphersuites(),
2812 * by checking certificates etc. 2812 * by checking certificates etc.
2813 */ 2813 */
2814int 2814int
2815mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_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 enum MHD_GNUTLS_PublicKeyAlgorithm 2818 enum MHD_GNUTLS_PublicKeyAlgorithm
@@ -2822,7 +2822,7 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2822 int ret = 0; 2822 int ret = 0;
2823 cipher_suite_st *newSuite, cs; 2823 cipher_suite_st *newSuite, cs;
2824 int newSuiteSize = 0, i; 2824 int newSuiteSize = 0, i;
2825 mhd_gtls_cert_credentials_t cert_cred; 2825 MHD_gtls_cert_credentials_t cert_cred;
2826 enum MHD_GNUTLS_KeyExchangeAlgorithm kx; 2826 enum MHD_GNUTLS_KeyExchangeAlgorithm kx;
2827 int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0; 2827 int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0;
2828 enum MHD_GNUTLS_KeyExchangeAlgorithm *alg = NULL; 2828 enum MHD_GNUTLS_KeyExchangeAlgorithm *alg = NULL;
@@ -2835,7 +2835,7 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2835 */ 2835 */
2836 2836
2837 cert_cred = 2837 cert_cred =
2838 (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key, 2838 (MHD_gtls_cert_credentials_t) MHD_gtls_get_cred (session->key,
2839 MHD_GNUTLS_CRD_CERTIFICATE, 2839 MHD_GNUTLS_CRD_CERTIFICATE,
2840 NULL); 2840 NULL);
2841 2841
@@ -2845,11 +2845,11 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2845 if (session->security_parameters.entity == GNUTLS_SERVER 2845 if (session->security_parameters.entity == GNUTLS_SERVER
2846 && cert_cred != NULL) 2846 && cert_cred != NULL)
2847 { 2847 {
2848 ret = mhd_gtls_server_select_cert (session, requested_pk_algo); 2848 ret = MHD_gtls_server_select_cert (session, requested_pk_algo);
2849 if (ret < 0) 2849 if (ret < 0)
2850 { 2850 {
2851 gnutls_assert (); 2851 MHD_gnutls_assert ();
2852 _gnutls_x509_log ("Could not find an appropriate certificate: %s\n", 2852 MHD__gnutls_x509_log ("Could not find an appropriate certificate: %s\n",
2853 MHD_gtls_strerror (ret)); 2853 MHD_gtls_strerror (ret));
2854 cert_cred = NULL; 2854 cert_cred = NULL;
2855 } 2855 }
@@ -2859,17 +2859,17 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2859 * supported by the X509 certificate parameters. 2859 * supported by the X509 certificate parameters.
2860 */ 2860 */
2861 if ((ret = 2861 if ((ret =
2862 mhd_gtls_selected_cert_supported_kx (session, &alg, &alg_size)) < 0) 2862 MHD_gtls_selected_cert_supported_kx (session, &alg, &alg_size)) < 0)
2863 { 2863 {
2864 gnutls_assert (); 2864 MHD_gnutls_assert ();
2865 return ret; 2865 return ret;
2866 } 2866 }
2867 2867
2868 newSuite = gnutls_malloc (numCipherSuites * sizeof (cipher_suite_st)); 2868 newSuite = MHD_gnutls_malloc (numCipherSuites * sizeof (cipher_suite_st));
2869 if (newSuite == NULL) 2869 if (newSuite == NULL)
2870 { 2870 {
2871 gnutls_assert (); 2871 MHD_gnutls_assert ();
2872 gnutls_free (alg); 2872 MHD_gnutls_free (alg);
2873 return GNUTLS_E_MEMORY_ERROR; 2873 return GNUTLS_E_MEMORY_ERROR;
2874 } 2874 }
2875 2875
@@ -2882,11 +2882,11 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2882 /* finds the key exchange algorithm in 2882 /* finds the key exchange algorithm in
2883 * the ciphersuite 2883 * the ciphersuite
2884 */ 2884 */
2885 kx = mhd_gtls_cipher_suite_get_kx_algo (&(*cipherSuites)[i]); 2885 kx = MHD_gtls_cipher_suite_get_kx_algo (&(*cipherSuites)[i]);
2886 2886
2887 /* if it is defined but had no credentials 2887 /* if it is defined but had no credentials
2888 */ 2888 */
2889 if (mhd_gtls_get_kx_cred (session, kx, NULL) == NULL) 2889 if (MHD_gtls_get_kx_cred (session, kx, NULL) == NULL)
2890 { 2890 {
2891 delete = 1; 2891 delete = 1;
2892 } 2892 }
@@ -2899,12 +2899,12 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2899 } 2899 }
2900 2900
2901 /* These two SRP kx's are marked to require a CRD_CERTIFICATE, 2901 /* These two SRP kx's are marked to require a CRD_CERTIFICATE,
2902 (see cred_mappings in gnutls_algorithms.c), but it also 2902 (see cred_mappings in MHD_gnutls_algorithms.c), but it also
2903 requires a SRP credential. Don't use SRP kx unless we have a 2903 requires a SRP credential. Don't use SRP kx unless we have a
2904 SRP credential too. */ 2904 SRP credential too. */
2905 if (kx == MHD_GNUTLS_KX_SRP_RSA || kx == MHD_GNUTLS_KX_SRP_DSS) 2905 if (kx == MHD_GNUTLS_KX_SRP_RSA || kx == MHD_GNUTLS_KX_SRP_DSS)
2906 { 2906 {
2907 if (!mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_SRP, NULL)) 2907 if (!MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_SRP, NULL))
2908 delete = 1; 2908 delete = 1;
2909 } 2909 }
2910 2910
@@ -2913,24 +2913,24 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2913 if (delete == 0) 2913 if (delete == 0)
2914 { 2914 {
2915 2915
2916 _gnutls_handshake_log ("HSK[%x]: Keeping ciphersuite: %s\n", 2916 MHD__gnutls_handshake_log ("HSK[%x]: Keeping ciphersuite: %s\n",
2917 session, 2917 session,
2918 mhd_gtls_cipher_suite_get_name (&cs)); 2918 MHD_gtls_cipher_suite_get_name (&cs));
2919 2919
2920 memcpy (newSuite[newSuiteSize].suite, (*cipherSuites)[i].suite, 2); 2920 memcpy (newSuite[newSuiteSize].suite, (*cipherSuites)[i].suite, 2);
2921 newSuiteSize++; 2921 newSuiteSize++;
2922 } 2922 }
2923 else 2923 else
2924 { 2924 {
2925 _gnutls_handshake_log ("HSK[%x]: Removing ciphersuite: %s\n", 2925 MHD__gnutls_handshake_log ("HSK[%x]: Removing ciphersuite: %s\n",
2926 session, 2926 session,
2927 mhd_gtls_cipher_suite_get_name (&cs)); 2927 MHD_gtls_cipher_suite_get_name (&cs));
2928 2928
2929 } 2929 }
2930 } 2930 }
2931 2931
2932 gnutls_free (alg); 2932 MHD_gnutls_free (alg);
2933 gnutls_free (*cipherSuites); 2933 MHD_gnutls_free (*cipherSuites);
2934 *cipherSuites = newSuite; 2934 *cipherSuites = newSuite;
2935 2935
2936 ret = newSuiteSize; 2936 ret = newSuiteSize;
@@ -2940,8 +2940,8 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2940} 2940}
2941 2941
2942/** 2942/**
2943 * MHD_gnutls_handshake_set_max_packet_length - This function will set the maximum length of a handshake message 2943 * MHD__gnutls_handshake_set_max_packet_length - This function will set the maximum length of a handshake message
2944 * @session: is a #mhd_gtls_session_t structure. 2944 * @session: is a #MHD_gtls_session_t structure.
2945 * @max: is the maximum number. 2945 * @max: is the maximum number.
2946 * 2946 *
2947 * This function will set the maximum size of a handshake message. 2947 * This function will set the maximum size of a handshake message.
@@ -2951,63 +2951,63 @@ mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
2951 * 2951 *
2952 **/ 2952 **/
2953void 2953void
2954MHD_gnutls_handshake_set_max_packet_length (mhd_gtls_session_t session, 2954MHD__gnutls_handshake_set_max_packet_length (MHD_gtls_session_t session,
2955 size_t max) 2955 size_t max)
2956{ 2956{
2957 session->internals.max_handshake_data_buffer_size = max; 2957 session->internals.max_handshake_data_buffer_size = max;
2958} 2958}
2959 2959
2960void 2960void
2961mhd_gtls_set_adv_version (mhd_gtls_session_t session, 2961MHD_gtls_set_adv_version (MHD_gtls_session_t session,
2962 enum MHD_GNUTLS_Protocol ver) 2962 enum MHD_GNUTLS_Protocol ver)
2963{ 2963{
2964 set_adv_version (session, mhd_gtls_version_get_major (ver), 2964 set_adv_version (session, MHD_gtls_version_get_major (ver),
2965 mhd_gtls_version_get_minor (ver)); 2965 MHD_gtls_version_get_minor (ver));
2966} 2966}
2967 2967
2968enum MHD_GNUTLS_Protocol 2968enum MHD_GNUTLS_Protocol
2969mhd_gtls_get_adv_version (mhd_gtls_session_t session) 2969MHD_gtls_get_adv_version (MHD_gtls_session_t session)
2970{ 2970{
2971 return mhd_gtls_version_get (_gnutls_get_adv_version_major (session), 2971 return MHD_gtls_version_get (MHD__gnutls_get_adv_version_major (session),
2972 _gnutls_get_adv_version_minor (session)); 2972 MHD__gnutls_get_adv_version_minor (session));
2973} 2973}
2974 2974
2975/** 2975/**
2976 * MHD_gtls_handshake_get_last_in - Returns the last handshake message received. 2976 * MHD_gtls_handshake_get_last_in - Returns the last handshake message received.
2977 * @session: is a #mhd_gtls_session_t structure. 2977 * @session: is a #MHD_gtls_session_t structure.
2978 * 2978 *
2979 * This function is only useful to check where the last performed 2979 * This function is only useful to check where the last performed
2980 * handshake failed. If the previous handshake succeed or was not 2980 * handshake failed. If the previous handshake succeed or was not
2981 * performed at all then no meaningful value will be returned. 2981 * performed at all then no meaningful value will be returned.
2982 * 2982 *
2983 * Check %gnutls_handshake_description_t in gnutls.h for the 2983 * Check %MHD_gnutls_handshake_description_t in gnutls.h for the
2984 * available handshake descriptions. 2984 * available handshake descriptions.
2985 * 2985 *
2986 * Returns: the last handshake message type received, a 2986 * Returns: the last handshake message type received, a
2987 * %gnutls_handshake_description_t. 2987 * %MHD_gnutls_handshake_description_t.
2988 **/ 2988 **/
2989gnutls_handshake_description_t 2989MHD_gnutls_handshake_description_t
2990MHD_gtls_handshake_get_last_in (mhd_gtls_session_t session) 2990MHD_gtls_handshake_get_last_in (MHD_gtls_session_t session)
2991{ 2991{
2992 return session->internals.last_handshake_in; 2992 return session->internals.last_handshake_in;
2993} 2993}
2994 2994
2995/** 2995/**
2996 * MHD_gtls_handshake_get_last_out - Returns the last handshake message sent. 2996 * MHD_gtls_handshake_get_last_out - Returns the last handshake message sent.
2997 * @session: is a #mhd_gtls_session_t structure. 2997 * @session: is a #MHD_gtls_session_t structure.
2998 * 2998 *
2999 * This function is only useful to check where the last performed 2999 * This function is only useful to check where the last performed
3000 * handshake failed. If the previous handshake succeed or was not 3000 * handshake failed. If the previous handshake succeed or was not
3001 * performed at all then no meaningful value will be returned. 3001 * performed at all then no meaningful value will be returned.
3002 * 3002 *
3003 * Check %gnutls_handshake_description_t in gnutls.h for the 3003 * Check %MHD_gnutls_handshake_description_t in gnutls.h for the
3004 * available handshake descriptions. 3004 * available handshake descriptions.
3005 * 3005 *
3006 * Returns: the last handshake message type sent, a 3006 * Returns: the last handshake message type sent, a
3007 * %gnutls_handshake_description_t. 3007 * %MHD_gnutls_handshake_description_t.
3008 **/ 3008 **/
3009gnutls_handshake_description_t 3009MHD_gnutls_handshake_description_t
3010MHD_gtls_handshake_get_last_out (mhd_gtls_session_t session) 3010MHD_gtls_handshake_get_last_out (MHD_gtls_session_t session)
3011{ 3011{
3012 return session->internals.last_handshake_out; 3012 return session->internals.last_handshake_out;
3013} 3013}
diff --git a/src/daemon/https/tls/gnutls_handshake.h b/src/daemon/https/tls/gnutls_handshake.h
index 7679653f..6514ffc6 100644
--- a/src/daemon/https/tls/gnutls_handshake.h
+++ b/src/daemon/https/tls/gnutls_handshake.h
@@ -25,39 +25,39 @@
25typedef enum Optional 25typedef enum Optional
26{ OPTIONAL_PACKET, MANDATORY_PACKET } Optional; 26{ OPTIONAL_PACKET, MANDATORY_PACKET } Optional;
27 27
28int mhd_gtls_send_handshake (mhd_gtls_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 MHD_gnutls_handshake_description_t type);
31int mhd_gtls_recv_hello_request (mhd_gtls_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 mhd_gtls_send_hello (mhd_gtls_session_t session, int again); 33int MHD_gtls_send_hello (MHD_gtls_session_t session, int again);
34int mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data, 34int MHD_gtls_recv_hello (MHD_gtls_session_t session, opaque * data,
35 int datalen); 35 int datalen);
36int mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t **, int *, 36int MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t **, int *,
37 gnutls_handshake_description_t, 37 MHD_gnutls_handshake_description_t,
38 Optional optional); 38 Optional optional);
39int mhd_gtls_generate_session_id (opaque * session_id, uint8_t * len); 39int MHD_gtls_generate_session_id (opaque * session_id, uint8_t * len);
40int mhd_gtls_handshake_common (mhd_gtls_session_t session); 40int MHD_gtls_handshake_common (MHD_gtls_session_t session);
41int mhd_gtls_handshake_server (mhd_gtls_session_t session); 41int MHD_gtls_handshake_server (MHD_gtls_session_t session);
42void mhd_gtls_set_server_random (mhd_gtls_session_t session, uint8_t * rnd); 42void MHD_gtls_set_server_random (MHD_gtls_session_t session, uint8_t * rnd);
43void mhd_gtls_set_client_random (mhd_gtls_session_t session, uint8_t * rnd); 43void MHD_gtls_set_client_random (MHD_gtls_session_t session, uint8_t * rnd);
44int mhd_gtls_tls_create_random (opaque * dst); 44int MHD_gtls_tls_create_random (opaque * dst);
45int mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_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 enum 48 enum
49 MHD_GNUTLS_PublicKeyAlgorithm); 49 MHD_GNUTLS_PublicKeyAlgorithm);
50int mhd_gtls_find_pk_algos_in_ciphersuites (opaque * data, int datalen); 50int MHD_gtls_find_pk_algos_in_ciphersuites (opaque * data, int datalen);
51int mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data, 51int MHD_gtls_server_select_suite (MHD_gtls_session_t session, opaque * data,
52 int datalen); 52 int datalen);
53 53
54int mhd_gtls_negotiate_version (mhd_gtls_session_t session, 54int MHD_gtls_negotiate_version (MHD_gtls_session_t session,
55 enum MHD_GNUTLS_Protocol adv_version); 55 enum MHD_GNUTLS_Protocol adv_version);
56int mhd_gtls_user_hello_func (mhd_gtls_session_t, 56int MHD_gtls_user_hello_func (MHD_gtls_session_t,
57 enum MHD_GNUTLS_Protocol adv_version); 57 enum MHD_GNUTLS_Protocol adv_version);
58 58
59#if MHD_DEBUG_TLS 59#if MHD_DEBUG_TLS
60int mhd_gtls_handshake_client (mhd_gtls_session_t session); 60int MHD_gtls_handshake_client (MHD_gtls_session_t session);
61#endif 61#endif
62 62
63#define STATE session->internals.handshake_state 63#define STATE session->internals.handshake_state
diff --git a/src/daemon/https/tls/gnutls_hash_int.c b/src/daemon/https/tls/gnutls_hash_int.c
index da1880f2..158f0843 100644
--- a/src/daemon/https/tls/gnutls_hash_int.c
+++ b/src/daemon/https/tls/gnutls_hash_int.c
@@ -31,7 +31,7 @@
31#include <gnutls_errors.h> 31#include <gnutls_errors.h>
32 32
33static inline Gc_hash 33static inline Gc_hash
34_gnutls_mac2gc (enum MHD_GNUTLS_HashAlgorithm mac) 34MHD__gnutls_mac2gc (enum MHD_GNUTLS_HashAlgorithm mac)
35{ 35{
36 switch (mac) 36 switch (mac)
37 { 37 {
@@ -48,32 +48,32 @@ _gnutls_mac2gc (enum MHD_GNUTLS_HashAlgorithm mac)
48 return GC_MD5; 48 return GC_MD5;
49 break; 49 break;
50 default: 50 default:
51 gnutls_assert (); 51 MHD_gnutls_assert ();
52 return -1; 52 return -1;
53 } 53 }
54 return -1; 54 return -1;
55} 55}
56 56
57GNUTLS_HASH_HANDLE 57GNUTLS_HASH_HANDLE
58mhd_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm algorithm) 58MHD_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm algorithm)
59{ 59{
60 mac_hd_t ret; 60 mac_hd_t ret;
61 int result; 61 int result;
62 62
63 ret = gnutls_malloc (sizeof (mac_hd_st)); 63 ret = MHD_gnutls_malloc (sizeof (mac_hd_st));
64 if (ret == NULL) 64 if (ret == NULL)
65 { 65 {
66 gnutls_assert (); 66 MHD_gnutls_assert ();
67 return GNUTLS_HASH_FAILED; 67 return GNUTLS_HASH_FAILED;
68 } 68 }
69 69
70 ret->algorithm = algorithm; 70 ret->algorithm = algorithm;
71 71
72 result = gc_hash_open (_gnutls_mac2gc (algorithm), 0, &ret->handle); 72 result = MHD_gc_hash_open (MHD__gnutls_mac2gc (algorithm), 0, &ret->handle);
73 if (result) 73 if (result)
74 { 74 {
75 gnutls_assert (); 75 MHD_gnutls_assert ();
76 gnutls_free (ret); 76 MHD_gnutls_free (ret);
77 ret = GNUTLS_HASH_FAILED; 77 ret = GNUTLS_HASH_FAILED;
78 } 78 }
79 79
@@ -81,31 +81,31 @@ mhd_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm algorithm)
81} 81}
82 82
83int 83int
84mhd_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm) 84MHD_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm)
85{ 85{
86 int ret; 86 int ret;
87 87
88 ret = gc_hash_digest_length (_gnutls_mac2gc (algorithm)); 88 ret = MHD_gc_hash_digest_length (MHD__gnutls_mac2gc (algorithm));
89 89
90 return ret; 90 return ret;
91 91
92} 92}
93 93
94int 94int
95mhd_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 MHD_gc_hash_write (handle->handle, textlen, text);
99 return 0; 99 return 0;
100} 100}
101 101
102GNUTLS_HASH_HANDLE 102GNUTLS_HASH_HANDLE
103mhd_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;
107 107
108 ret = gnutls_malloc (sizeof (mac_hd_st)); 108 ret = MHD_gnutls_malloc (sizeof (mac_hd_st));
109 109
110 if (ret == NULL) 110 if (ret == NULL)
111 return GNUTLS_HASH_FAILED; 111 return GNUTLS_HASH_FAILED;
@@ -114,11 +114,11 @@ mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
114 ret->key = NULL; /* it's a hash anyway */ 114 ret->key = NULL; /* it's a hash anyway */
115 ret->keysize = 0; 115 ret->keysize = 0;
116 116
117 result = gc_hash_clone (handle->handle, &ret->handle); 117 result = MHD_gc_hash_clone (handle->handle, &ret->handle);
118 118
119 if (result) 119 if (result)
120 { 120 {
121 gnutls_free (ret); 121 MHD_gnutls_free (ret);
122 return GNUTLS_HASH_FAILED; 122 return GNUTLS_HASH_FAILED;
123 } 123 }
124 124
@@ -126,42 +126,42 @@ mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
126} 126}
127 127
128void 128void
129mhd_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 = mhd_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 = MHD_gc_hash_read (handle->handle);
137 if (digest != NULL) 137 if (digest != NULL)
138 memcpy (digest, mac, maclen); 138 memcpy (digest, mac, maclen);
139 139
140 gc_hash_close (handle->handle); 140 MHD_gc_hash_close (handle->handle);
141 141
142 gnutls_free (handle); 142 MHD_gnutls_free (handle);
143} 143}
144 144
145 145
146mac_hd_t 146mac_hd_t
147mhd_gtls_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm, 147MHD_gtls_MHD_hmac_init (enum MHD_GNUTLS_HashAlgorithm 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;
151 int result; 151 int result;
152 152
153 ret = gnutls_malloc (sizeof (mac_hd_st)); 153 ret = MHD_gnutls_malloc (sizeof (mac_hd_st));
154 if (ret == NULL) 154 if (ret == NULL)
155 return GNUTLS_MAC_FAILED; 155 return GNUTLS_MAC_FAILED;
156 156
157 result = gc_hash_open (_gnutls_mac2gc (algorithm), GC_HMAC, &ret->handle); 157 result = MHD_gc_hash_open (MHD__gnutls_mac2gc (algorithm), GC_HMAC, &ret->handle);
158 if (result) 158 if (result)
159 { 159 {
160 gnutls_free (ret); 160 MHD_gnutls_free (ret);
161 return GNUTLS_MAC_FAILED; 161 return GNUTLS_MAC_FAILED;
162 } 162 }
163 163
164 gc_hash_hmac_setkey (ret->handle, keylen, key); 164 MHD_gc_hash_MHD_hmac_setkey (ret->handle, keylen, key);
165 165
166 ret->algorithm = algorithm; 166 ret->algorithm = algorithm;
167 ret->key = key; 167 ret->key = key;
@@ -171,21 +171,21 @@ mhd_gtls_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm,
171} 171}
172 172
173void 173void
174mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest) 174MHD_gnutls_MHD_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 = mhd_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 = MHD_gc_hash_read (handle->handle);
182 182
183 if (digest != NULL) 183 if (digest != NULL)
184 memcpy (digest, mac, maclen); 184 memcpy (digest, mac, maclen);
185 185
186 gc_hash_close (handle->handle); 186 MHD_gc_hash_close (handle->handle);
187 187
188 gnutls_free (handle); 188 MHD_gnutls_free (handle);
189} 189}
190 190
191inline static int 191inline static int
@@ -203,7 +203,7 @@ get_padsize (enum MHD_GNUTLS_HashAlgorithm algorithm)
203} 203}
204 204
205mac_hd_t 205mac_hd_t
206mhd_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm, void *key, 206MHD_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm, void *key,
207 int keylen) 207 int keylen)
208{ 208{
209 mac_hd_t ret; 209 mac_hd_t ret;
@@ -213,28 +213,28 @@ mhd_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm, void *key,
213 padsize = get_padsize (algorithm); 213 padsize = get_padsize (algorithm);
214 if (padsize == 0) 214 if (padsize == 0)
215 { 215 {
216 gnutls_assert (); 216 MHD_gnutls_assert ();
217 return GNUTLS_MAC_FAILED; 217 return GNUTLS_MAC_FAILED;
218 } 218 }
219 219
220 memset (ipad, 0x36, padsize); 220 memset (ipad, 0x36, padsize);
221 221
222 ret = mhd_gtls_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 mhd_gnutls_hash (ret, key, keylen); 229 MHD_gnutls_hash (ret, key, keylen);
230 mhd_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
237mhd_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;
@@ -245,29 +245,29 @@ mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
245 padsize = get_padsize (handle->algorithm); 245 padsize = get_padsize (handle->algorithm);
246 if (padsize == 0) 246 if (padsize == 0)
247 { 247 {
248 gnutls_assert (); 248 MHD_gnutls_assert ();
249 return; 249 return;
250 } 250 }
251 251
252 memset (opad, 0x5C, padsize); 252 memset (opad, 0x5C, padsize);
253 253
254 td = mhd_gtls_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 mhd_gnutls_hash (td, handle->key, handle->keysize); 258 MHD_gnutls_hash (td, handle->key, handle->keysize);
259 259
260 mhd_gnutls_hash (td, opad, padsize); 260 MHD_gnutls_hash (td, opad, padsize);
261 block = mhd_gnutls_hash_get_algo_len (handle->algorithm); 261 block = MHD_gnutls_hash_get_algo_len (handle->algorithm);
262 mhd_gnutls_hash_deinit (handle, ret); /* get the previous hash */ 262 MHD_gnutls_hash_deinit (handle, ret); /* get the previous hash */
263 mhd_gnutls_hash (td, ret, block); 263 MHD_gnutls_hash (td, ret, block);
264 264
265 mhd_gnutls_hash_deinit (td, digest); 265 MHD_gnutls_hash_deinit (td, digest);
266 } 266 }
267} 267}
268 268
269void 269void
270mhd_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{
@@ -281,30 +281,30 @@ mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
281 padsize = get_padsize (handle->algorithm); 281 padsize = get_padsize (handle->algorithm);
282 if (padsize == 0) 282 if (padsize == 0)
283 { 283 {
284 gnutls_assert (); 284 MHD_gnutls_assert ();
285 return; 285 return;
286 } 286 }
287 287
288 memset (opad, 0x5C, padsize); 288 memset (opad, 0x5C, padsize);
289 memset (ipad, 0x36, padsize); 289 memset (ipad, 0x36, padsize);
290 290
291 td = mhd_gtls_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 mhd_gnutls_hash (td, key, key_size); 295 MHD_gnutls_hash (td, key, key_size);
296 296
297 mhd_gnutls_hash (td, opad, padsize); 297 MHD_gnutls_hash (td, opad, padsize);
298 block = mhd_gnutls_hash_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 mhd_gnutls_hash (handle, key, key_size); 301 MHD_gnutls_hash (handle, key, key_size);
302 mhd_gnutls_hash (handle, ipad, padsize); 302 MHD_gnutls_hash (handle, ipad, padsize);
303 mhd_gnutls_hash_deinit (handle, ret); /* get the previous hash */ 303 MHD_gnutls_hash_deinit (handle, ret); /* get the previous hash */
304 304
305 mhd_gnutls_hash (td, ret, block); 305 MHD_gnutls_hash (td, ret, block);
306 306
307 mhd_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 = mhd_gtls_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 MHD_gnutls_assert ();
329 return GNUTLS_E_HASH_FAILED; 329 return GNUTLS_E_HASH_FAILED;
330 } 330 }
331 331
332 mhd_gnutls_hash (td, text1, i + 1); 332 MHD_gnutls_hash (td, text1, i + 1);
333 mhd_gnutls_hash (td, secret, secret_len); 333 MHD_gnutls_hash (td, secret, secret_len);
334 mhd_gnutls_hash (td, rnd, rnd_len); 334 MHD_gnutls_hash (td, rnd, rnd_len);
335 335
336 mhd_gnutls_hash_deinit (td, digest); 336 MHD_gnutls_hash_deinit (td, digest);
337 return 0; 337 return 0;
338} 338}
339 339
@@ -345,54 +345,54 @@ 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 = mhd_gtls_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 MHD_gnutls_assert ();
352 return GNUTLS_E_HASH_FAILED; 352 return GNUTLS_E_HASH_FAILED;
353 } 353 }
354 354
355 mhd_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 MHD_gnutls_assert ();
361 mhd_gnutls_hash_deinit (td, digest); 361 MHD_gnutls_hash_deinit (td, digest);
362 return ret; 362 return ret;
363 } 363 }
364 364
365 mhd_gnutls_hash (td, tmp, 365 MHD_gnutls_hash (td, tmp,
366 mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_SHA1)); 366 MHD_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_SHA1));
367 367
368 mhd_gnutls_hash_deinit (td, digest); 368 MHD_gnutls_hash_deinit (td, digest);
369 return 0; 369 return 0;
370} 370}
371 371
372int 372int
373mhd_gnutls_ssl3_hash_md5 (void *first, int first_len, 373MHD_gnutls_ssl3_hash_md5 (void *first, int first_len,
374 void *second, int second_len, int ret_len, 374 void *second, int second_len, int ret_len,
375 opaque * ret) 375 opaque * ret)
376{ 376{
377 opaque digest[MAX_HASH_SIZE]; 377 opaque digest[MAX_HASH_SIZE];
378 mac_hd_t td; 378 mac_hd_t td;
379 int block = mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5); 379 int block = MHD_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
380 380
381 td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5); 381 td = MHD_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
382 if (td == NULL) 382 if (td == NULL)
383 { 383 {
384 gnutls_assert (); 384 MHD_gnutls_assert ();
385 return GNUTLS_E_HASH_FAILED; 385 return GNUTLS_E_HASH_FAILED;
386 } 386 }
387 387
388 mhd_gnutls_hash (td, first, first_len); 388 MHD_gnutls_hash (td, first, first_len);
389 mhd_gnutls_hash (td, second, second_len); 389 MHD_gnutls_hash (td, second, second_len);
390 390
391 mhd_gnutls_hash_deinit (td, digest); 391 MHD_gnutls_hash_deinit (td, digest);
392 392
393 if (ret_len > block) 393 if (ret_len > block)
394 { 394 {
395 gnutls_assert (); 395 MHD_gnutls_assert ();
396 return GNUTLS_E_INTERNAL_ERROR; 396 return GNUTLS_E_INTERNAL_ERROR;
397 } 397 }
398 398
@@ -403,13 +403,13 @@ mhd_gnutls_ssl3_hash_md5 (void *first, int first_len,
403} 403}
404 404
405int 405int
406mhd_gnutls_ssl3_generate_random (void *secret, int secret_len, 406MHD_gnutls_ssl3_generate_random (void *secret, int secret_len,
407 void *rnd, int rnd_len, 407 void *rnd, int rnd_len,
408 int ret_bytes, opaque * ret) 408 int ret_bytes, opaque * ret)
409{ 409{
410 int i = 0, copy, output_bytes; 410 int i = 0, copy, output_bytes;
411 opaque digest[MAX_HASH_SIZE]; 411 opaque digest[MAX_HASH_SIZE];
412 int block = mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5); 412 int block = MHD_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
413 int result, times; 413 int result, times;
414 414
415 output_bytes = 0; 415 output_bytes = 0;
@@ -427,7 +427,7 @@ mhd_gnutls_ssl3_generate_random (void *secret, int secret_len,
427 result = ssl3_md5 (i, secret, secret_len, rnd, rnd_len, digest); 427 result = ssl3_md5 (i, secret, secret_len, rnd, rnd_len, digest);
428 if (result < 0) 428 if (result < 0)
429 { 429 {
430 gnutls_assert (); 430 MHD_gnutls_assert ();
431 return result; 431 return result;
432 } 432 }
433 433
diff --git a/src/daemon/https/tls/gnutls_hash_int.h b/src/daemon/https/tls/gnutls_hash_int.h
index 7cd33a03..72f805ee 100644
--- a/src/daemon/https/tls/gnutls_hash_int.h
+++ b/src/daemon/https/tls/gnutls_hash_int.h
@@ -31,7 +31,7 @@
31 31
32typedef struct 32typedef struct
33{ 33{
34 gc_hash_handle handle; 34 MHD_gc_hash_handle handle;
35 enum MHD_GNUTLS_HashAlgorithm algorithm; 35 enum MHD_GNUTLS_HashAlgorithm algorithm;
36 const void *key; 36 const void *key;
37 int keysize; 37 int keysize;
@@ -42,31 +42,31 @@ 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 mhd_gtls_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm, 45mac_hd_t MHD_gtls_MHD_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm,
46 const void *key, int keylen); 46 const void *key, int keylen);
47 47
48void mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest); 48void MHD_gnutls_MHD_hmac_deinit (mac_hd_t handle, void *digest);
49 49
50mac_hd_t mhd_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm, 50mac_hd_t MHD_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm,
51 void *key, int keylen); 51 void *key, int keylen);
52void mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest); 52void MHD_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest);
53 53
54GNUTLS_HASH_HANDLE mhd_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm 54GNUTLS_HASH_HANDLE MHD_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm
55 algorithm); 55 algorithm);
56int mhd_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm); 56int MHD_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm);
57int mhd_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, 57int MHD_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text,
58 size_t textlen); 58 size_t textlen);
59void mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest); 59void MHD_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest);
60 60
61int mhd_gnutls_ssl3_generate_random (void *secret, int secret_len, 61int MHD_gnutls_ssl3_generate_random (void *secret, int secret_len,
62 void *rnd, int random_len, int bytes, 62 void *rnd, int random_len, int bytes,
63 opaque * ret); 63 opaque * ret);
64int mhd_gnutls_ssl3_hash_md5 (void *first, int first_len, void *second, 64int MHD_gnutls_ssl3_hash_md5 (void *first, int first_len, void *second,
65 int second_len, int ret_len, opaque * ret); 65 int second_len, int ret_len, opaque * ret);
66 66
67void mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, void *digest, 67void MHD_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, void *digest,
68 opaque * key, uint32_t key_size); 68 opaque * key, uint32_t key_size);
69 69
70GNUTLS_HASH_HANDLE mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle); 70GNUTLS_HASH_HANDLE MHD_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle);
71 71
72#endif /* GNUTLS_HASH_INT_H */ 72#endif /* GNUTLS_HASH_INT_H */
diff --git a/src/daemon/https/tls/gnutls_int.h b/src/daemon/https/tls/gnutls_int.h
index 2ef52933..af2b4499 100644
--- a/src/daemon/https/tls/gnutls_int.h
+++ b/src/daemon/https/tls/gnutls_int.h
@@ -92,9 +92,9 @@
92#define DEFAULT_VERIFY_DEPTH 32 92#define DEFAULT_VERIFY_DEPTH 32
93#define DEFAULT_VERIFY_BITS 16*1024 93#define DEFAULT_VERIFY_BITS 16*1024
94 94
95#define DECR_LEN(len, x) do { len-=x; if (len<0) {gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;} } while (0) 95#define DECR_LEN(len, x) do { len-=x; if (len<0) {MHD_gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;} } while (0)
96#define DECR_LENGTH_RET(len, x, RET) do { len-=x; if (len<0) {gnutls_assert(); return RET;} } while (0) 96#define DECR_LENGTH_RET(len, x, RET) do { len-=x; if (len<0) {MHD_gnutls_assert(); return RET;} } while (0)
97#define DECR_LENGTH_COM(len, x, COM) do { len-=x; if (len<0) {gnutls_assert(); COM;} } while (0) 97#define DECR_LENGTH_COM(len, x, COM) do { len-=x; if (len<0) {MHD_gnutls_assert(); COM;} } while (0)
98 98
99#define HASH2MAC(x) ((enum MHD_GNUTLS_HashAlgorithm)x) 99#define HASH2MAC(x) ((enum MHD_GNUTLS_HashAlgorithm)x)
100 100
@@ -129,11 +129,11 @@ typedef enum handshake_state_t
129 129
130#include <gnutls_str.h> 130#include <gnutls_str.h>
131 131
132typedef mhd_gtls_string mhd_gtls_buffer; 132typedef MHD_gtls_string MHD_gtls_buffer;
133 133
134#define mhd_gtls_buffer_init(buf) mhd_gtls_string_init(buf, gnutls_malloc, gnutls_realloc, gnutls_free); 134#define MHD_gtls_buffer_init(buf) MHD_gtls_string_init(buf, MHD_gnutls_malloc, MHD_gnutls_realloc, MHD_gnutls_free);
135#define mhd_gtls_buffer_clear mhd_gtls_string_clear 135#define MHD_gtls_buffer_clear MHD_gtls_string_clear
136#define mhd_gtls_buffer_append mhd_gtls_string_append_data 136#define MHD_gtls_buffer_append MHD_gtls_string_append_data
137 137
138/* This is the maximum number of algorithms (ciphers or macs etc). 138/* This is the maximum number of algorithms (ciphers or macs etc).
139 * keep it synced with GNUTLS_MAX_ALGORITHM_NUM in gnutls.h 139 * keep it synced with GNUTLS_MAX_ALGORITHM_NUM in gnutls.h
@@ -179,20 +179,20 @@ typedef enum content_type_t
179typedef void (*LOG_FUNC) (int, const char *); 179typedef void (*LOG_FUNC) (int, const char *);
180 180
181/* Store & Retrieve functions defines: */ 181/* Store & Retrieve functions defines: */
182typedef struct mhd_gtls_auth_cred_st 182typedef struct MHD_gtls_auth_cred_st
183{ 183{
184 enum MHD_GNUTLS_CredentialsType algorithm; 184 enum MHD_GNUTLS_CredentialsType algorithm;
185 185
186 /* the type of credentials depends on algorithm 186 /* the type of credentials depends on algorithm
187 */ 187 */
188 void *credentials; 188 void *credentials;
189 struct mhd_gtls_auth_cred_st *next; 189 struct MHD_gtls_auth_cred_st *next;
190} auth_cred_st; 190} auth_cred_st;
191 191
192struct mhd_gtls_key 192struct MHD_gtls_key
193{ 193{
194 /* For DH KX */ 194 /* For DH KX */
195 gnutls_datum_t key; 195 MHD_gnutls_datum_t key;
196 mpi_t KEY; 196 mpi_t KEY;
197 mpi_t client_Y; 197 mpi_t client_Y;
198 mpi_t client_g; 198 mpi_t client_g;
@@ -212,7 +212,7 @@ struct mhd_gtls_key
212 /* this is used to hold the peers authentication data 212 /* this is used to hold the peers authentication data
213 */ 213 */
214 /* auth_info_t structures SHOULD NOT contain malloced 214 /* auth_info_t structures SHOULD NOT contain malloced
215 * elements. Check gnutls_session_pack.c, and gnutls_auth.c. 215 * elements. Check MHD_gnutls_session_pack.c, and MHD_gnutls_auth.c.
216 * Rememember that this should be calloced! 216 * Rememember that this should be calloced!
217 */ 217 */
218 void *auth_info; 218 void *auth_info;
@@ -233,7 +233,7 @@ struct mhd_gtls_key
233 * for a client certificate verify 233 * for a client certificate verify
234 */ 234 */
235}; 235};
236typedef struct mhd_gtls_key *mhd_gtls_key_st; 236typedef struct MHD_gtls_key *MHD_gtls_key_st;
237 237
238/* STATE (cont) */ 238/* STATE (cont) */
239#include <gnutls_hash_int.h> 239#include <gnutls_hash_int.h>
@@ -254,7 +254,7 @@ typedef struct
254{ 254{
255 opaque name[MAX_SERVER_NAME_SIZE]; 255 opaque name[MAX_SERVER_NAME_SIZE];
256 unsigned name_length; 256 unsigned name_length;
257 gnutls_server_name_type_t type; 257 MHD_gnutls_server_name_type_t type;
258} server_name_st; 258} server_name_st;
259 259
260#define MAX_SERVER_NAME_EXTENSIONS 3 260#define MAX_SERVER_NAME_EXTENSIONS 3
@@ -267,20 +267,20 @@ typedef struct
267 opaque srp_username[MAX_SRP_USERNAME + 1]; 267 opaque srp_username[MAX_SRP_USERNAME + 1];
268 268
269 /* TLS/IA data. */ 269 /* TLS/IA data. */
270 int gnutls_ia_enable, gnutls_ia_peer_enable; 270 int MHD_gnutls_ia_enable, MHD_gnutls_ia_peer_enable;
271 int gnutls_ia_allowskip, gnutls_ia_peer_allowskip; 271 int MHD_gnutls_ia_allowskip, MHD_gnutls_ia_peer_allowskip;
272 272
273 /* Used by extensions that enable supplemental data. */ 273 /* Used by extensions that enable supplemental data. */
274 int do_recv_supplemental, do_send_supplemental; 274 int do_recv_supplemental, do_send_supplemental;
275 275
276 /* Opaque PRF input. */ 276 /* Opaque PRF input. */
277 gnutls_oprfi_callback_func oprfi_cb; 277 MHD_gnutls_oprfi_callback_func oprfi_cb;
278 void *oprfi_userdata; 278 void *oprfi_userdata;
279 opaque *oprfi_client; 279 opaque *oprfi_client;
280 uint16_t oprfi_client_len; 280 uint16_t oprfi_client_len;
281 opaque *oprfi_server; 281 opaque *oprfi_server;
282 uint16_t oprfi_server_len; 282 uint16_t oprfi_server_len;
283} mhd_gtls_ext_st; 283} MHD_gtls_ext_st;
284 284
285/* This flag indicates for an extension whether 285/* This flag indicates for an extension whether
286 * it is useful to application level or TLS level only. 286 * it is useful to application level or TLS level only.
@@ -292,7 +292,7 @@ typedef enum tls_ext_parse_type_t
292 EXTENSION_ANY, 292 EXTENSION_ANY,
293 EXTENSION_APPLICATION, 293 EXTENSION_APPLICATION,
294 EXTENSION_TLS 294 EXTENSION_TLS
295} mhd_gtls_ext_parse_type_t; 295} MHD_gtls_ext_parse_type_t;
296 296
297/* auth_info_t structures now MAY contain malloced 297/* auth_info_t structures now MAY contain malloced
298 * elements. 298 * elements.
@@ -305,7 +305,7 @@ typedef enum tls_ext_parse_type_t
305 */ 305 */
306 306
307/* if you add anything in Security_Parameters struct, then 307/* if you add anything in Security_Parameters struct, then
308 * also modify CPY_COMMON in gnutls_constate.c 308 * also modify CPY_COMMON in MHD_gnutls_constate.c
309 */ 309 */
310 310
311/* Note that the security parameters structure is set up after the 311/* Note that the security parameters structure is set up after the
@@ -314,7 +314,7 @@ typedef enum tls_ext_parse_type_t
314 */ 314 */
315typedef struct 315typedef struct
316{ 316{
317 gnutls_connection_end_t entity; 317 MHD_gnutls_connection_end_t entity;
318 enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm; 318 enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm;
319 /* we've got separate write/read bulk/macs because 319 /* we've got separate write/read bulk/macs because
320 * there is a time in handshake where the peer has 320 * there is a time in handshake where the peer has
@@ -339,7 +339,7 @@ typedef struct
339 opaque session_id[TLS_MAX_SESSION_ID_SIZE]; 339 opaque session_id[TLS_MAX_SESSION_ID_SIZE];
340 uint8_t session_id_size; 340 uint8_t session_id_size;
341 time_t timestamp; 341 time_t timestamp;
342 mhd_gtls_ext_st extensions; 342 MHD_gtls_ext_st extensions;
343 343
344 /* The send size is the one requested by the programmer. 344 /* The send size is the one requested by the programmer.
345 * The recv size is the one negotiated with the peer. 345 * The recv size is the one negotiated with the peer.
@@ -351,23 +351,23 @@ typedef struct
351 enum MHD_GNUTLS_Protocol version; /* moved here */ 351 enum MHD_GNUTLS_Protocol version; /* moved here */
352 /* For TLS/IA. XXX: Move to IA credential? */ 352 /* For TLS/IA. XXX: Move to IA credential? */
353 opaque inner_secret[TLS_MASTER_SIZE]; 353 opaque inner_secret[TLS_MASTER_SIZE];
354} mhd_gtls_security_param_st; 354} MHD_gtls_security_param_st;
355 355
356/* This structure holds the generated keys 356/* This structure holds the generated keys
357 */ 357 */
358typedef struct 358typedef struct
359{ 359{
360 gnutls_datum_t server_write_mac_secret; 360 MHD_gnutls_datum_t server_write_mac_secret;
361 gnutls_datum_t client_write_mac_secret; 361 MHD_gnutls_datum_t client_write_mac_secret;
362 gnutls_datum_t server_write_IV; 362 MHD_gnutls_datum_t server_write_IV;
363 gnutls_datum_t client_write_IV; 363 MHD_gnutls_datum_t client_write_IV;
364 gnutls_datum_t server_write_key; 364 MHD_gnutls_datum_t server_write_key;
365 gnutls_datum_t client_write_key; 365 MHD_gnutls_datum_t client_write_key;
366 int generated_keys; /* zero if keys have not 366 int generated_keys; /* zero if keys have not
367 * been generated. Non zero 367 * been generated. Non zero
368 * otherwise. 368 * otherwise.
369 */ 369 */
370} mhd_gtls_cipher_specs_st; 370} MHD_gtls_cipher_specs_st;
371 371
372typedef struct 372typedef struct
373{ 373{
@@ -375,29 +375,29 @@ typedef struct
375 cipher_hd_t read_cipher_state; 375 cipher_hd_t read_cipher_state;
376 comp_hd_t read_compression_state; 376 comp_hd_t read_compression_state;
377 comp_hd_t write_compression_state; 377 comp_hd_t write_compression_state;
378 gnutls_datum_t read_mac_secret; 378 MHD_gnutls_datum_t read_mac_secret;
379 gnutls_datum_t write_mac_secret; 379 MHD_gnutls_datum_t write_mac_secret;
380 uint64 read_sequence_number; 380 uint64 read_sequence_number;
381 uint64 write_sequence_number; 381 uint64 write_sequence_number;
382} mhd_gtls_conn_stat_st; 382} MHD_gtls_conn_stat_st;
383 383
384typedef struct 384typedef struct
385{ 385{
386 unsigned int priority[MAX_ALGOS]; 386 unsigned int priority[MAX_ALGOS];
387 unsigned int num_algorithms; 387 unsigned int num_algorithms;
388} mhd_gtls_priority_st; 388} MHD_gtls_priority_st;
389 389
390/* For the external api */ 390/* For the external api */
391struct MHD_gtls_priority_st 391struct MHD_gtls_priority_st
392{ 392{
393 mhd_gtls_priority_st cipher; 393 MHD_gtls_priority_st cipher;
394 mhd_gtls_priority_st mac; 394 MHD_gtls_priority_st mac;
395 mhd_gtls_priority_st kx; 395 MHD_gtls_priority_st kx;
396 mhd_gtls_priority_st compression; 396 MHD_gtls_priority_st compression;
397 mhd_gtls_priority_st protocol; 397 MHD_gtls_priority_st protocol;
398 398
399 /* certificate type : x509, OpenPGP, etc. */ 399 /* certificate type : x509, OpenPGP, etc. */
400 mhd_gtls_priority_st cert_type; 400 MHD_gtls_priority_st cert_type;
401 401
402 /* to disable record padding */ 402 /* to disable record padding */
403 int no_padding; 403 int no_padding;
@@ -410,15 +410,15 @@ typedef struct MHD_gtls_dh_params_int
410 /* [0] is the prime, [1] is the generator. 410 /* [0] is the prime, [1] is the generator.
411 */ 411 */
412 mpi_t params[2]; 412 mpi_t params[2];
413} mhd_gtls_dh_params_st; 413} MHD_gtls_dh_params_st;
414 414
415typedef struct 415typedef struct
416{ 416{
417 mhd_gtls_dh_params_t dh_params; 417 MHD_gtls_dh_params_t dh_params;
418 int free_dh_params; 418 int free_dh_params;
419 mhd_gtls_rsa_params_t rsa_params; 419 MHD_gtls_rsa_params_t rsa_params;
420 int free_rsa_params; 420 int free_rsa_params;
421} mhd_gtls_internal_params_st; 421} MHD_gtls_internal_params_st;
422 422
423typedef struct 423typedef struct
424{ 424{
@@ -427,19 +427,19 @@ typedef struct
427 size_t header_size; 427 size_t header_size;
428 /* this holds the length of the handshake packet */ 428 /* this holds the length of the handshake packet */
429 size_t packet_length; 429 size_t packet_length;
430 gnutls_handshake_description_t recv_type; 430 MHD_gnutls_handshake_description_t recv_type;
431} mhd_gtls_handshake_header_buffer_st; 431} MHD_gtls_handshake_header_buffer_st;
432 432
433typedef struct 433typedef struct
434{ 434{
435 mhd_gtls_buffer application_data_buffer; /* holds data to be delivered to application layer */ 435 MHD_gtls_buffer application_data_buffer; /* holds data to be delivered to application layer */
436 mhd_gtls_buffer handshake_hash_buffer; /* used to keep the last received handshake 436 MHD_gtls_buffer handshake_hash_buffer; /* used to keep the last received handshake
437 * message */ 437 * message */
438 mac_hd_t handshake_mac_handle_sha; /* hash of the handshake messages */ 438 mac_hd_t handshake_mac_handle_sha; /* hash of the handshake messages */
439 mac_hd_t handshake_mac_handle_md5; /* hash of the handshake messages */ 439 mac_hd_t handshake_mac_handle_md5; /* hash of the handshake messages */
440 440
441 mhd_gtls_buffer handshake_data_buffer; /* this is a buffer that holds the current handshake message */ 441 MHD_gtls_buffer handshake_data_buffer; /* this is a buffer that holds the current handshake message */
442 mhd_gtls_buffer ia_data_buffer; /* holds inner application data (TLS/IA) */ 442 MHD_gtls_buffer ia_data_buffer; /* holds inner application data (TLS/IA) */
443 resumable_session_t resumable; /* TRUE or FALSE - if we can resume that session */ 443 resumable_session_t resumable; /* TRUE or FALSE - if we can resume that session */
444 handshake_state_t handshake_state; /* holds 444 handshake_state_t handshake_state; /* holds
445 * a number which indicates where 445 * a number which indicates where
@@ -471,28 +471,28 @@ typedef struct
471 471
472 /* resumed session */ 472 /* resumed session */
473 resumable_session_t resumed; /* RESUME_TRUE or FALSE - if we are resuming a session */ 473 resumable_session_t resumed; /* RESUME_TRUE or FALSE - if we are resuming a session */
474 mhd_gtls_security_param_st resumed_security_parameters; 474 MHD_gtls_security_param_st resumed_security_parameters;
475 475
476 /* sockets internals */ 476 /* sockets internals */
477 int lowat; 477 int lowat;
478 478
479 /* These buffers are used in the handshake 479 /* These buffers are used in the handshake
480 * protocol only. freed using _gnutls_handshake_io_buffer_clear(); 480 * protocol only. freed using MHD__gnutls_handshake_io_buffer_clear();
481 */ 481 */
482 mhd_gtls_buffer handshake_send_buffer; 482 MHD_gtls_buffer handshake_send_buffer;
483 size_t handshake_send_buffer_prev_size; 483 size_t handshake_send_buffer_prev_size;
484 content_type_t handshake_send_buffer_type; 484 content_type_t handshake_send_buffer_type;
485 gnutls_handshake_description_t handshake_send_buffer_htype; 485 MHD_gnutls_handshake_description_t handshake_send_buffer_htype;
486 content_type_t handshake_recv_buffer_type; 486 content_type_t handshake_recv_buffer_type;
487 gnutls_handshake_description_t handshake_recv_buffer_htype; 487 MHD_gnutls_handshake_description_t handshake_recv_buffer_htype;
488 mhd_gtls_buffer handshake_recv_buffer; 488 MHD_gtls_buffer handshake_recv_buffer;
489 489
490 /* this buffer holds a record packet -mostly used for 490 /* this buffer holds a record packet -mostly used for
491 * non blocking IO. 491 * non blocking IO.
492 */ 492 */
493 mhd_gtls_buffer record_recv_buffer; 493 MHD_gtls_buffer record_recv_buffer;
494 mhd_gtls_buffer record_send_buffer; /* holds cached data 494 MHD_gtls_buffer record_send_buffer; /* holds cached data
495 * for the gnutls_io_write_buffered() 495 * for the MHD_gnutls_io_write_buffered()
496 * function. 496 * function.
497 */ 497 */
498 size_t record_send_buffer_prev_size; /* holds the 498 size_t record_send_buffer_prev_size; /* holds the
@@ -508,7 +508,7 @@ typedef struct
508 int have_peeked_data; 508 int have_peeked_data;
509 509
510 int expire_time; /* after expire_time seconds this session will expire */ 510 int expire_time; /* after expire_time seconds this session will expire */
511 struct mhd_gtls_mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */ 511 struct MHD_gtls_mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */
512 512
513 /* TODO rm */ 513 /* TODO rm */
514 int v2_hello; /* 0 if the client hello is v3+. 514 int v2_hello; /* 0 if the client hello is v3+.
@@ -516,7 +516,7 @@ typedef struct
516 */ 516 */
517 /* keeps the headers of the handshake packet 517 /* keeps the headers of the handshake packet
518 */ 518 */
519 mhd_gtls_handshake_header_buffer_st handshake_header_buffer; 519 MHD_gtls_handshake_header_buffer_st handshake_header_buffer;
520 520
521 /* this is the highest version available 521 /* this is the highest version available
522 * to the peer. (advertized version). 522 * to the peer. (advertized version).
@@ -533,7 +533,7 @@ typedef struct
533 int send_cert_req; 533 int send_cert_req;
534 534
535 /* bits to use for DHE and DHA 535 /* bits to use for DHE and DHA
536 * use _gnutls_dh_get_prime_bits() and MHD_gnutls_dh_set_prime_bits() 536 * use MHD__gnutls_dh_get_prime_bits() and MHD__gnutls_dh_set_prime_bits()
537 * to access it. 537 * to access it.
538 */ 538 */
539 uint16_t dh_prime_bits; 539 uint16_t dh_prime_bits;
@@ -542,17 +542,17 @@ typedef struct
542 542
543 /* PUSH & PULL functions. 543 /* PUSH & PULL functions.
544 */ 544 */
545 mhd_gtls_pull_func _gnutls_pull_func; 545 MHD_gtls_pull_func MHD__gnutls_pull_func;
546 mhd_gtls_push_func _gnutls_push_func; 546 MHD_gtls_push_func MHD__gnutls_push_func;
547 /* Holds the first argument of PUSH and PULL 547 /* Holds the first argument of PUSH and PULL
548 * functions; 548 * functions;
549 */ 549 */
550 gnutls_transport_ptr_t transport_recv_ptr; 550 MHD_gnutls_transport_ptr_t transport_recv_ptr;
551 gnutls_transport_ptr_t transport_send_ptr; 551 MHD_gnutls_transport_ptr_t transport_send_ptr;
552 552
553 /* post client hello callback (server side only) 553 /* post client hello callback (server side only)
554 */ 554 */
555 gnutls_handshake_post_client_hello_func user_hello_func; 555 MHD_gnutls_handshake_post_client_hello_func user_hello_func;
556 556
557 /* Holds the record size requested by the 557 /* Holds the record size requested by the
558 * user. 558 * user.
@@ -560,12 +560,12 @@ typedef struct
560 uint16_t proposed_record_size; 560 uint16_t proposed_record_size;
561 561
562 /* holds the selected certificate and key. 562 /* holds the selected certificate and key.
563 * use mhd_gtls_selected_certs_deinit() and mhd_gtls_selected_certs_set() 563 * use MHD_gtls_selected_certs_deinit() and MHD_gtls_selected_certs_set()
564 * to change them. 564 * to change them.
565 */ 565 */
566 gnutls_cert *selected_cert_list; 566 MHD_gnutls_cert *selected_cert_list;
567 int selected_cert_list_length; 567 int selected_cert_list_length;
568 gnutls_privkey *selected_key; 568 MHD_gnutls_privkey *selected_key;
569 int selected_need_free; 569 int selected_need_free;
570 570
571 /* holds the extensions we sent to the peer 571 /* holds the extensions we sent to the peer
@@ -615,16 +615,16 @@ typedef struct
615 * credentials structure, or from a callback. That is to 615 * credentials structure, or from a callback. That is to
616 * minimize external calls. 616 * minimize external calls.
617 */ 617 */
618 mhd_gtls_internal_params_st params; 618 MHD_gtls_internal_params_st params;
619 619
620 /* This buffer is used by the record recv functions, 620 /* This buffer is used by the record recv functions,
621 * as a temporary store buffer. 621 * as a temporary store buffer.
622 */ 622 */
623 gnutls_datum_t recv_buffer; 623 MHD_gnutls_datum_t recv_buffer;
624 624
625 /* To avoid using global variables, and especially on Windows where 625 /* To avoid using global variables, and especially on Windows where
626 * the application may use a different errno variable than GnuTLS, 626 * the application may use a different errno variable than GnuTLS,
627 * it is possible to use MHD_gnutls_transport_set_errno to set a 627 * it is possible to use MHD__gnutls_transport_set_errno to set a
628 * session-specific errno variable in the user-replaceable push/pull 628 * session-specific errno variable in the user-replaceable push/pull
629 * functions. This value is used by the send/recv functions. (The 629 * functions. This value is used by the send/recv functions. (The
630 * strange name of this variable is because 'errno' is typically 630 * strange name of this variable is because 'errno' is typically
@@ -633,44 +633,44 @@ typedef struct
633 int errnum; 633 int errnum;
634 634
635 /* Function used to perform public-key signing operation during 635 /* Function used to perform public-key signing operation during
636 handshake. Used by gnutls_sig.c:_gnutls_tls_sign(), see also 636 handshake. Used by MHD_gnutls_sig.c:MHD__gnutls_tls_sign(), see also
637 MHD_gtls_sign_callback_set(). */ 637 MHD_gtls_sign_callback_set(). */
638 gnutls_sign_func sign_func; 638 MHD_gnutls_sign_func sign_func;
639 void *sign_func_userdata; 639 void *sign_func_userdata;
640 640
641 /* If you add anything here, check mhd_gtls_handshake_internal_state_clear(). 641 /* If you add anything here, check MHD_gtls_handshake_internal_state_clear().
642 */ 642 */
643} mhd_gtls_internals_st; 643} MHD_gtls_internals_st;
644 644
645struct MHD_gtls_session_int 645struct MHD_gtls_session_int
646{ 646{
647 mhd_gtls_security_param_st security_parameters; 647 MHD_gtls_security_param_st security_parameters;
648 mhd_gtls_cipher_specs_st cipher_specs; 648 MHD_gtls_cipher_specs_st cipher_specs;
649 mhd_gtls_conn_stat_st connection_state; 649 MHD_gtls_conn_stat_st connection_state;
650 mhd_gtls_internals_st internals; 650 MHD_gtls_internals_st internals;
651 mhd_gtls_key_st key; 651 MHD_gtls_key_st key;
652}; 652};
653 653
654/* functions */ 654/* functions */
655void mhd_gtls_set_current_version (mhd_gtls_session_t session, 655void MHD_gtls_set_current_version (MHD_gtls_session_t session,
656 enum MHD_GNUTLS_Protocol version); 656 enum MHD_GNUTLS_Protocol version);
657 657
658void mhd_gtls_free_auth_info (mhd_gtls_session_t session); 658void MHD_gtls_free_auth_info (MHD_gtls_session_t session);
659 659
660/* These two macros return the advertized TLS version of 660/* These two macros return the advertized TLS version of
661 * the peer. 661 * the peer.
662 */ 662 */
663#define _gnutls_get_adv_version_major( session) \ 663#define MHD__gnutls_get_adv_version_major( session) \
664 session->internals.adv_version_major 664 session->internals.adv_version_major
665 665
666#define _gnutls_get_adv_version_minor( session) \ 666#define MHD__gnutls_get_adv_version_minor( session) \
667 session->internals.adv_version_minor 667 session->internals.adv_version_minor
668 668
669#define set_adv_version( session, major, minor) \ 669#define set_adv_version( session, major, minor) \
670 session->internals.adv_version_major = major; \ 670 session->internals.adv_version_major = major; \
671 session->internals.adv_version_minor = minor 671 session->internals.adv_version_minor = minor
672 672
673void mhd_gtls_set_adv_version (mhd_gtls_session_t, enum MHD_GNUTLS_Protocol); 673void MHD_gtls_set_adv_version (MHD_gtls_session_t, enum MHD_GNUTLS_Protocol);
674enum MHD_GNUTLS_Protocol mhd_gtls_get_adv_version (mhd_gtls_session_t); 674enum MHD_GNUTLS_Protocol MHD_gtls_get_adv_version (MHD_gtls_session_t);
675 675
676#endif /* GNUTLS_INT_H */ 676#endif /* GNUTLS_INT_H */
diff --git a/src/daemon/https/tls/gnutls_kx.c b/src/daemon/https/tls/gnutls_kx.c
index 45717b4f..5f0966f8 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 (MHD_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 (mhd_gtls_session_t session, int); 45static int generate_normal_master (MHD_gtls_session_t session, int);
46 46
47int 47int
48mhd_gtls_generate_master (mhd_gtls_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 @@ mhd_gtls_generate_master (mhd_gtls_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 (mhd_gtls_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 MHD__gnutls_hard_log ("INT: PREMASTER SECRET[%d]: %s\n", PREMASTER.size,
65 mhd_gtls_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 MHD__gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32,
68 mhd_gtls_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 MHD__gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32,
71 mhd_gtls_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 (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) 74 if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_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 (mhd_gtls_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 mhd_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.
@@ -97,25 +97,25 @@ generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
97 rndlen += session->security_parameters.extensions.oprfi_client_len; 97 rndlen += session->security_parameters.extensions.oprfi_client_len;
98 rndlen += session->security_parameters.extensions.oprfi_server_len; 98 rndlen += session->security_parameters.extensions.oprfi_server_len;
99 99
100 rnd = gnutls_malloc (rndlen + 1); 100 rnd = MHD_gnutls_malloc (rndlen + 1);
101 if (!rnd) 101 if (!rnd)
102 { 102 {
103 gnutls_assert (); 103 MHD_gnutls_assert ();
104 return GNUTLS_E_MEMORY_ERROR; 104 return GNUTLS_E_MEMORY_ERROR;
105 } 105 }
106 106
107 _gnutls_hard_log ("INT: CLIENT OPRFI[%d]: %s\n", 107 MHD__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 mhd_gtls_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, buf, 113 extensions.oprfi_client_len, buf,
114 sizeof (buf))); 114 sizeof (buf)));
115 _gnutls_hard_log ("INT: SERVER OPRFI[%d]: %s\n", 115 MHD__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 mhd_gtls_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, buf, 121 extensions.oprfi_server_len, buf,
@@ -135,12 +135,12 @@ generate_normal_master (mhd_gtls_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 = mhd_gtls_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);
142 142
143 gnutls_free (rnd); 143 MHD_gnutls_free (rnd);
144 } 144 }
145 else 145 else
146 { 146 {
@@ -152,7 +152,7 @@ generate_normal_master (mhd_gtls_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 mhd_gtls_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);
@@ -163,13 +163,13 @@ generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
163 session->security_parameters.master_secret, TLS_MASTER_SIZE); 163 session->security_parameters.master_secret, TLS_MASTER_SIZE);
164 164
165 if (!keep_premaster) 165 if (!keep_premaster)
166 _gnutls_free_datum (&PREMASTER); 166 MHD__gnutls_free_datum (&PREMASTER);
167 167
168 if (ret < 0) 168 if (ret < 0)
169 return ret; 169 return ret;
170 170
171 _gnutls_hard_log ("INT: MASTER SECRET: %s\n", 171 MHD__gnutls_hard_log ("INT: MASTER SECRET: %s\n",
172 mhd_gtls_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 (mhd_gtls_session_t session, int keep_premaster)
182 * by the selected ciphersuite. 182 * by the selected ciphersuite.
183 */ 183 */
184int 184int
185mhd_gtls_send_server_kx_message (mhd_gtls_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->mhd_gtls_gen_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;
@@ -197,30 +197,30 @@ mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again)
197 if (again == 0) 197 if (again == 0)
198 { 198 {
199 data_size = 199 data_size =
200 session->internals.auth_struct->mhd_gtls_gen_server_kx (session, 200 session->internals.auth_struct->MHD_gtls_gen_server_kx (session,
201 &data); 201 &data);
202 202
203 if (data_size == GNUTLS_E_INT_RET_0) 203 if (data_size == GNUTLS_E_INT_RET_0)
204 { 204 {
205 gnutls_assert (); 205 MHD_gnutls_assert ();
206 return 0; 206 return 0;
207 } 207 }
208 208
209 if (data_size < 0) 209 if (data_size < 0)
210 { 210 {
211 gnutls_assert (); 211 MHD_gnutls_assert ();
212 return data_size; 212 return data_size;
213 } 213 }
214 } 214 }
215 215
216 ret = 216 ret =
217 mhd_gtls_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 MHD_gnutls_free (data);
220 220
221 if (ret < 0) 221 if (ret < 0)
222 { 222 {
223 gnutls_assert (); 223 MHD_gnutls_assert ();
224 return ret; 224 return ret;
225 } 225 }
226 return data_size; 226 return data_size;
@@ -230,7 +230,7 @@ mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again)
230 * client. 230 * client.
231 */ 231 */
232int 232int
233mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session, 233MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session,
234 int again) 234 int again)
235{ 235{
236 uint8_t *data = NULL; 236 uint8_t *data = NULL;
@@ -238,7 +238,7 @@ mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
238 int ret = 0; 238 int ret = 0;
239 239
240 if (session->internals.auth_struct-> 240 if (session->internals.auth_struct->
241 mhd_gtls_gen_server_certificate_request == NULL) 241 MHD_gtls_gen_server_certificate_request == NULL)
242 return 0; 242 return 0;
243 243
244 if (session->internals.send_cert_req <= 0) 244 if (session->internals.send_cert_req <= 0)
@@ -251,22 +251,22 @@ mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
251 { 251 {
252 data_size = 252 data_size =
253 session->internals.auth_struct-> 253 session->internals.auth_struct->
254 mhd_gtls_gen_server_certificate_request (session, &data); 254 MHD_gtls_gen_server_certificate_request (session, &data);
255 255
256 if (data_size < 0) 256 if (data_size < 0)
257 { 257 {
258 gnutls_assert (); 258 MHD_gnutls_assert ();
259 return data_size; 259 return data_size;
260 } 260 }
261 } 261 }
262 ret = 262 ret =
263 mhd_gtls_send_handshake (session, data, data_size, 263 MHD_gtls_send_handshake (session, data, data_size,
264 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST); 264 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST);
265 gnutls_free (data); 265 MHD_gnutls_free (data);
266 266
267 if (ret < 0) 267 if (ret < 0)
268 { 268 {
269 gnutls_assert (); 269 MHD_gnutls_assert ();
270 return ret; 270 return ret;
271 } 271 }
272 return data_size; 272 return data_size;
@@ -277,13 +277,13 @@ mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
277 * exchange message 277 * exchange message
278 */ 278 */
279int 279int
280mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again) 280MHD_gtls_send_client_kx_message (MHD_gtls_session_t session, int again)
281{ 281{
282 uint8_t *data; 282 uint8_t *data;
283 int data_size; 283 int data_size;
284 int ret = 0; 284 int ret = 0;
285 285
286 if (session->internals.auth_struct->mhd_gtls_gen_client_kx == NULL) 286 if (session->internals.auth_struct->MHD_gtls_gen_client_kx == NULL)
287 return 0; 287 return 0;
288 288
289 289
@@ -293,22 +293,22 @@ mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again)
293 if (again == 0) 293 if (again == 0)
294 { 294 {
295 data_size = 295 data_size =
296 session->internals.auth_struct->mhd_gtls_gen_client_kx (session, 296 session->internals.auth_struct->MHD_gtls_gen_client_kx (session,
297 &data); 297 &data);
298 if (data_size < 0) 298 if (data_size < 0)
299 { 299 {
300 gnutls_assert (); 300 MHD_gnutls_assert ();
301 return data_size; 301 return data_size;
302 } 302 }
303 } 303 }
304 ret = 304 ret =
305 mhd_gtls_send_handshake (session, data, data_size, 305 MHD_gtls_send_handshake (session, data, data_size,
306 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE); 306 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE);
307 gnutls_free (data); 307 MHD_gnutls_free (data);
308 308
309 if (ret < 0) 309 if (ret < 0)
310 { 310 {
311 gnutls_assert (); 311 MHD_gnutls_assert ();
312 return ret; 312 return ret;
313 } 313 }
314 314
@@ -320,7 +320,7 @@ mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again)
320 * verify message 320 * verify message
321 */ 321 */
322int 322int
323mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session, 323MHD_gtls_send_client_certificate_verify (MHD_gtls_session_t session,
324 int again) 324 int again)
325{ 325{
326 uint8_t *data; 326 uint8_t *data;
@@ -337,9 +337,9 @@ mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
337 if (session->key->certificate_requested == 0) 337 if (session->key->certificate_requested == 0)
338 return 0; 338 return 0;
339 339
340 if (session->internals.auth_struct->mhd_gtls_gen_client_cert_vrfy == NULL) 340 if (session->internals.auth_struct->MHD_gtls_gen_client_cert_vrfy == NULL)
341 { 341 {
342 gnutls_assert (); 342 MHD_gnutls_assert ();
343 return 0; /* this algorithm does not support cli_cert_vrfy 343 return 0; /* this algorithm does not support cli_cert_vrfy
344 */ 344 */
345 } 345 }
@@ -351,10 +351,10 @@ mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
351 { 351 {
352 data_size = 352 data_size =
353 session->internals.auth_struct-> 353 session->internals.auth_struct->
354 mhd_gtls_gen_client_cert_vrfy (session, &data); 354 MHD_gtls_gen_client_cert_vrfy (session, &data);
355 if (data_size < 0) 355 if (data_size < 0)
356 { 356 {
357 gnutls_assert (); 357 MHD_gnutls_assert ();
358 return data_size; 358 return data_size;
359 } 359 }
360 if (data_size == 0) 360 if (data_size == 0)
@@ -362,53 +362,53 @@ mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
362 362
363 } 363 }
364 ret = 364 ret =
365 mhd_gtls_send_handshake (session, data, 365 MHD_gtls_send_handshake (session, data,
366 data_size, GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY); 366 data_size, GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY);
367 gnutls_free (data); 367 MHD_gnutls_free (data);
368 368
369 return ret; 369 return ret;
370} 370}
371 371
372 372
373int 373int
374mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session) 374MHD_gtls_recv_server_kx_message (MHD_gtls_session_t session)
375{ 375{
376 uint8_t *data = NULL; 376 uint8_t *data = NULL;
377 int datasize; 377 int datasize;
378 int ret = 0; 378 int ret = 0;
379 379
380 if (session->internals.auth_struct->mhd_gtls_process_server_kx != NULL) 380 if (session->internals.auth_struct->MHD_gtls_process_server_kx != NULL)
381 { 381 {
382 382
383 /* EXCEPTION FOR RSA_EXPORT cipher suite 383 /* EXCEPTION FOR RSA_EXPORT cipher suite
384 */ 384 */
385 if (mhd_gtls_session_is_export (session) != 0 && 385 if (MHD_gtls_session_is_export (session) != 0 &&
386 _gnutls_peers_cert_less_512 (session) != 0) 386 MHD__gnutls_peers_cert_less_512 (session) != 0)
387 { 387 {
388 gnutls_assert (); 388 MHD_gnutls_assert ();
389 return 0; 389 return 0;
390 } 390 }
391 391
392 ret = 392 ret =
393 mhd_gtls_recv_handshake (session, &data, 393 MHD_gtls_recv_handshake (session, &data,
394 &datasize, 394 &datasize,
395 GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE, 395 GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE,
396 MANDATORY_PACKET); 396 MANDATORY_PACKET);
397 if (ret < 0) 397 if (ret < 0)
398 { 398 {
399 gnutls_assert (); 399 MHD_gnutls_assert ();
400 return ret; 400 return ret;
401 } 401 }
402 402
403 ret = 403 ret =
404 session->internals.auth_struct->mhd_gtls_process_server_kx (session, 404 session->internals.auth_struct->MHD_gtls_process_server_kx (session,
405 data, 405 data,
406 datasize); 406 datasize);
407 gnutls_free (data); 407 MHD_gnutls_free (data);
408 408
409 if (ret < 0) 409 if (ret < 0)
410 { 410 {
411 gnutls_assert (); 411 MHD_gnutls_assert ();
412 return ret; 412 return ret;
413 } 413 }
414 414
@@ -417,18 +417,18 @@ mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session)
417} 417}
418 418
419int 419int
420mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session) 420MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session)
421{ 421{
422 uint8_t *data; 422 uint8_t *data;
423 int datasize; 423 int datasize;
424 int ret = 0; 424 int ret = 0;
425 425
426 if (session->internals.auth_struct-> 426 if (session->internals.auth_struct->
427 mhd_gtls_process_server_certificate_request != NULL) 427 MHD_gtls_process_server_certificate_request != NULL)
428 { 428 {
429 429
430 ret = 430 ret =
431 mhd_gtls_recv_handshake (session, &data, 431 MHD_gtls_recv_handshake (session, &data,
432 &datasize, 432 &datasize,
433 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST, 433 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST,
434 OPTIONAL_PACKET); 434 OPTIONAL_PACKET);
@@ -440,8 +440,8 @@ mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session)
440 440
441 ret = 441 ret =
442 session->internals.auth_struct-> 442 session->internals.auth_struct->
443 mhd_gtls_process_server_certificate_request (session, data, datasize); 443 MHD_gtls_process_server_certificate_request (session, data, datasize);
444 gnutls_free (data); 444 MHD_gnutls_free (data);
445 if (ret < 0) 445 if (ret < 0)
446 return ret; 446 return ret;
447 447
@@ -450,7 +450,7 @@ mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session)
450} 450}
451 451
452int 452int
453mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session) 453MHD_gtls_recv_client_kx_message (MHD_gtls_session_t session)
454{ 454{
455 uint8_t *data; 455 uint8_t *data;
456 int datasize; 456 int datasize;
@@ -458,11 +458,11 @@ mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
458 458
459 459
460 /* Do key exchange only if the algorithm permits it */ 460 /* Do key exchange only if the algorithm permits it */
461 if (session->internals.auth_struct->mhd_gtls_process_client_kx != NULL) 461 if (session->internals.auth_struct->MHD_gtls_process_client_kx != NULL)
462 { 462 {
463 463
464 ret = 464 ret =
465 mhd_gtls_recv_handshake (session, &data, 465 MHD_gtls_recv_handshake (session, &data,
466 &datasize, 466 &datasize,
467 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE, 467 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE,
468 MANDATORY_PACKET); 468 MANDATORY_PACKET);
@@ -470,10 +470,10 @@ mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
470 return ret; 470 return ret;
471 471
472 ret = 472 ret =
473 session->internals.auth_struct->mhd_gtls_process_client_kx (session, 473 session->internals.auth_struct->MHD_gtls_process_client_kx (session,
474 data, 474 data,
475 datasize); 475 datasize);
476 gnutls_free (data); 476 MHD_gnutls_free (data);
477 if (ret < 0) 477 if (ret < 0)
478 return ret; 478 return ret;
479 479
@@ -486,7 +486,7 @@ mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
486/* This is called when we want send our certificate 486/* This is called when we want send our certificate
487 */ 487 */
488int 488int
489mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again) 489MHD_gtls_send_client_certificate (MHD_gtls_session_t session, int again)
490{ 490{
491 uint8_t *data = NULL; 491 uint8_t *data = NULL;
492 int data_size = 0; 492 int data_size = 0;
@@ -496,7 +496,7 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
496 if (session->key->certificate_requested == 0) 496 if (session->key->certificate_requested == 0)
497 return 0; 497 return 0;
498 498
499 if (session->internals.auth_struct->mhd_gtls_gen_client_certificate == NULL) 499 if (session->internals.auth_struct->MHD_gtls_gen_client_certificate == NULL)
500 return 0; 500 return 0;
501 501
502 data = NULL; 502 data = NULL;
@@ -504,18 +504,18 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
504 504
505 if (again == 0) 505 if (again == 0)
506 { 506 {
507 if (MHD_gnutls_protocol_get_version (session) != MHD_GNUTLS_PROTOCOL_SSL3 || 507 if (MHD__gnutls_protocol_get_version (session) != MHD_GNUTLS_PROTOCOL_SSL3 ||
508 session->internals.selected_cert_list_length > 0) 508 session->internals.selected_cert_list_length > 0)
509 { 509 {
510 /* TLS 1.0 or SSL 3.0 with a valid certificate 510 /* TLS 1.0 or SSL 3.0 with a valid certificate
511 */ 511 */
512 data_size = 512 data_size =
513 session->internals.auth_struct-> 513 session->internals.auth_struct->
514 mhd_gtls_gen_client_certificate (session, &data); 514 MHD_gtls_gen_client_certificate (session, &data);
515 515
516 if (data_size < 0) 516 if (data_size < 0)
517 { 517 {
518 gnutls_assert (); 518 MHD_gnutls_assert ();
519 return data_size; 519 return data_size;
520 } 520 }
521 } 521 }
@@ -525,11 +525,11 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
525 * no certificate alert instead of an 525 * no certificate alert instead of an
526 * empty certificate. 526 * empty certificate.
527 */ 527 */
528 if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 && 528 if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 &&
529 session->internals.selected_cert_list_length == 0) 529 session->internals.selected_cert_list_length == 0)
530 { 530 {
531 ret = 531 ret =
532 MHD_gnutls_alert_send (session, GNUTLS_AL_WARNING, 532 MHD__gnutls_alert_send (session, GNUTLS_AL_WARNING,
533 GNUTLS_A_SSL3_NO_CERTIFICATE); 533 GNUTLS_A_SSL3_NO_CERTIFICATE);
534 534
535 } 535 }
@@ -537,14 +537,14 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
537 { /* TLS 1.0 or SSL 3.0 with a valid certificate 537 { /* TLS 1.0 or SSL 3.0 with a valid certificate
538 */ 538 */
539 ret = 539 ret =
540 mhd_gtls_send_handshake (session, data, data_size, 540 MHD_gtls_send_handshake (session, data, data_size,
541 GNUTLS_HANDSHAKE_CERTIFICATE_PKT); 541 GNUTLS_HANDSHAKE_CERTIFICATE_PKT);
542 gnutls_free (data); 542 MHD_gnutls_free (data);
543 } 543 }
544 544
545 if (ret < 0) 545 if (ret < 0)
546 { 546 {
547 gnutls_assert (); 547 MHD_gnutls_assert ();
548 return ret; 548 return ret;
549 } 549 }
550 550
@@ -555,14 +555,14 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
555/* This is called when we want send our certificate 555/* This is called when we want send our certificate
556 */ 556 */
557int 557int
558mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again) 558MHD_gtls_send_server_certificate (MHD_gtls_session_t session, int again)
559{ 559{
560 uint8_t *data = NULL; 560 uint8_t *data = NULL;
561 int data_size = 0; 561 int data_size = 0;
562 int ret = 0; 562 int ret = 0;
563 563
564 564
565 if (session->internals.auth_struct->mhd_gtls_gen_server_certificate == NULL) 565 if (session->internals.auth_struct->MHD_gtls_gen_server_certificate == NULL)
566 return 0; 566 return 0;
567 567
568 data = NULL; 568 data = NULL;
@@ -572,22 +572,22 @@ mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again)
572 { 572 {
573 data_size = 573 data_size =
574 session->internals.auth_struct-> 574 session->internals.auth_struct->
575 mhd_gtls_gen_server_certificate (session, &data); 575 MHD_gtls_gen_server_certificate (session, &data);
576 576
577 if (data_size < 0) 577 if (data_size < 0)
578 { 578 {
579 gnutls_assert (); 579 MHD_gnutls_assert ();
580 return data_size; 580 return data_size;
581 } 581 }
582 } 582 }
583 ret = 583 ret =
584 mhd_gtls_send_handshake (session, data, data_size, 584 MHD_gtls_send_handshake (session, data, data_size,
585 GNUTLS_HANDSHAKE_CERTIFICATE_PKT); 585 GNUTLS_HANDSHAKE_CERTIFICATE_PKT);
586 gnutls_free (data); 586 MHD_gnutls_free (data);
587 587
588 if (ret < 0) 588 if (ret < 0)
589 { 589 {
590 gnutls_assert (); 590 MHD_gnutls_assert ();
591 return ret; 591 return ret;
592 } 592 }
593 593
@@ -596,14 +596,14 @@ mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again)
596 596
597 597
598int 598int
599mhd_gtls_recv_client_certificate (mhd_gtls_session_t session) 599MHD_gtls_recv_client_certificate (MHD_gtls_session_t session)
600{ 600{
601 int datasize; 601 int datasize;
602 opaque *data; 602 opaque *data;
603 int ret = 0; 603 int ret = 0;
604 int optional; 604 int optional;
605 605
606 if (session->internals.auth_struct->mhd_gtls_process_client_certificate != 606 if (session->internals.auth_struct->MHD_gtls_process_client_certificate !=
607 NULL) 607 NULL)
608 { 608 {
609 609
@@ -620,7 +620,7 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
620 optional = OPTIONAL_PACKET; 620 optional = OPTIONAL_PACKET;
621 621
622 ret = 622 ret =
623 mhd_gtls_recv_handshake (session, &data, 623 MHD_gtls_recv_handshake (session, &data,
624 &datasize, 624 &datasize,
625 GNUTLS_HANDSHAKE_CERTIFICATE_PKT, optional); 625 GNUTLS_HANDSHAKE_CERTIFICATE_PKT, optional);
626 626
@@ -632,14 +632,14 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
632 */ 632 */
633 if (optional == OPTIONAL_PACKET && 633 if (optional == OPTIONAL_PACKET &&
634 ret == GNUTLS_E_WARNING_ALERT_RECEIVED && 634 ret == GNUTLS_E_WARNING_ALERT_RECEIVED &&
635 MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 && 635 MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 &&
636 gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE) 636 MHD_gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE)
637 { 637 {
638 638
639 /* SSL3 does not send an empty certificate, 639 /* SSL3 does not send an empty certificate,
640 * but this alert. So we just ignore it. 640 * but this alert. So we just ignore it.
641 */ 641 */
642 gnutls_assert (); 642 MHD_gnutls_assert ();
643 return 0; 643 return 0;
644 } 644 }
645 645
@@ -649,7 +649,7 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
649 || ret == GNUTLS_E_FATAL_ALERT_RECEIVED) 649 || ret == GNUTLS_E_FATAL_ALERT_RECEIVED)
650 && optional == MANDATORY_PACKET) 650 && optional == MANDATORY_PACKET)
651 { 651 {
652 gnutls_assert (); 652 MHD_gnutls_assert ();
653 return GNUTLS_E_NO_CERTIFICATE_FOUND; 653 return GNUTLS_E_NO_CERTIFICATE_FOUND;
654 } 654 }
655 655
@@ -662,17 +662,17 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
662 * well I'm not sure we should accept this 662 * well I'm not sure we should accept this
663 * behaviour. 663 * behaviour.
664 */ 664 */
665 gnutls_assert (); 665 MHD_gnutls_assert ();
666 return 0; 666 return 0;
667 } 667 }
668 ret = 668 ret =
669 session->internals.auth_struct-> 669 session->internals.auth_struct->
670 mhd_gtls_process_client_certificate (session, data, datasize); 670 MHD_gtls_process_client_certificate (session, data, datasize);
671 671
672 gnutls_free (data); 672 MHD_gnutls_free (data);
673 if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND) 673 if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND)
674 { 674 {
675 gnutls_assert (); 675 MHD_gnutls_assert ();
676 return ret; 676 return ret;
677 } 677 }
678 678
@@ -689,34 +689,34 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
689} 689}
690 690
691int 691int
692mhd_gtls_recv_server_certificate (mhd_gtls_session_t session) 692MHD_gtls_recv_server_certificate (MHD_gtls_session_t session)
693{ 693{
694 int datasize; 694 int datasize;
695 opaque *data; 695 opaque *data;
696 int ret = 0; 696 int ret = 0;
697 697
698 if (session->internals.auth_struct->mhd_gtls_process_server_certificate != 698 if (session->internals.auth_struct->MHD_gtls_process_server_certificate !=
699 NULL) 699 NULL)
700 { 700 {
701 701
702 ret = 702 ret =
703 mhd_gtls_recv_handshake (session, &data, 703 MHD_gtls_recv_handshake (session, &data,
704 &datasize, 704 &datasize,
705 GNUTLS_HANDSHAKE_CERTIFICATE_PKT, 705 GNUTLS_HANDSHAKE_CERTIFICATE_PKT,
706 MANDATORY_PACKET); 706 MANDATORY_PACKET);
707 if (ret < 0) 707 if (ret < 0)
708 { 708 {
709 gnutls_assert (); 709 MHD_gnutls_assert ();
710 return ret; 710 return ret;
711 } 711 }
712 712
713 ret = 713 ret =
714 session->internals.auth_struct-> 714 session->internals.auth_struct->
715 mhd_gtls_process_server_certificate (session, data, datasize); 715 MHD_gtls_process_server_certificate (session, data, datasize);
716 gnutls_free (data); 716 MHD_gnutls_free (data);
717 if (ret < 0) 717 if (ret < 0)
718 { 718 {
719 gnutls_assert (); 719 MHD_gnutls_assert ();
720 return ret; 720 return ret;
721 } 721 }
722 } 722 }
@@ -729,14 +729,14 @@ mhd_gtls_recv_server_certificate (mhd_gtls_session_t session)
729 * arrive if the peer did not send us a certificate. 729 * arrive if the peer did not send us a certificate.
730 */ 730 */
731int 731int
732mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session) 732MHD_gtls_recv_client_certificate_verify_message (MHD_gtls_session_t session)
733{ 733{
734 uint8_t *data; 734 uint8_t *data;
735 int datasize; 735 int datasize;
736 int ret = 0; 736 int ret = 0;
737 737
738 738
739 if (session->internals.auth_struct->mhd_gtls_process_client_cert_vrfy != 739 if (session->internals.auth_struct->MHD_gtls_process_client_cert_vrfy !=
740 NULL) 740 NULL)
741 { 741 {
742 742
@@ -747,7 +747,7 @@ mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session)
747 } 747 }
748 748
749 ret = 749 ret =
750 mhd_gtls_recv_handshake (session, &data, 750 MHD_gtls_recv_handshake (session, &data,
751 &datasize, 751 &datasize,
752 GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY, 752 GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY,
753 OPTIONAL_PACKET); 753 OPTIONAL_PACKET);
@@ -758,14 +758,14 @@ mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session)
758 && session->internals.send_cert_req == GNUTLS_CERT_REQUIRE) 758 && session->internals.send_cert_req == GNUTLS_CERT_REQUIRE)
759 { 759 {
760 /* certificate was required */ 760 /* certificate was required */
761 gnutls_assert (); 761 MHD_gnutls_assert ();
762 return GNUTLS_E_NO_CERTIFICATE_FOUND; 762 return GNUTLS_E_NO_CERTIFICATE_FOUND;
763 } 763 }
764 764
765 ret = 765 ret =
766 session->internals.auth_struct-> 766 session->internals.auth_struct->
767 mhd_gtls_process_client_cert_vrfy (session, data, datasize); 767 MHD_gtls_process_client_cert_vrfy (session, data, datasize);
768 gnutls_free (data); 768 MHD_gnutls_free (data);
769 if (ret < 0) 769 if (ret < 0)
770 return ret; 770 return ret;
771 771
diff --git a/src/daemon/https/tls/gnutls_kx.h b/src/daemon/https/tls/gnutls_kx.h
index e8bdf199..92144615 100644
--- a/src/daemon/https/tls/gnutls_kx.h
+++ b/src/daemon/https/tls/gnutls_kx.h
@@ -22,19 +22,19 @@
22 * 22 *
23 */ 23 */
24 24
25int mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again); 25int MHD_gtls_send_server_kx_message (MHD_gtls_session_t session, int again);
26int mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again); 26int MHD_gtls_send_client_kx_message (MHD_gtls_session_t session, int again);
27int mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session); 27int MHD_gtls_recv_server_kx_message (MHD_gtls_session_t session);
28int mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session); 28int MHD_gtls_recv_client_kx_message (MHD_gtls_session_t session);
29int mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session, 29int MHD_gtls_send_client_certificate_verify (MHD_gtls_session_t session,
30 int again); 30 int again);
31int mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again); 31int MHD_gtls_send_server_certificate (MHD_gtls_session_t session, int again);
32int mhd_gtls_generate_master (mhd_gtls_session_t session, int keep_premaster); 32int MHD_gtls_generate_master (MHD_gtls_session_t session, int keep_premaster);
33int mhd_gtls_recv_client_certificate (mhd_gtls_session_t session); 33int MHD_gtls_recv_client_certificate (MHD_gtls_session_t session);
34int mhd_gtls_recv_server_certificate (mhd_gtls_session_t session); 34int MHD_gtls_recv_server_certificate (MHD_gtls_session_t session);
35int mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again); 35int MHD_gtls_send_client_certificate (MHD_gtls_session_t session, int again);
36int mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session); 36int MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session);
37int mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session, 37int MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session,
38 int again); 38 int again);
39int mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t 39int MHD_gtls_recv_client_certificate_verify_message (MHD_gtls_session_t
40 session); 40 session);
diff --git a/src/daemon/https/tls/gnutls_mem.c b/src/daemon/https/tls/gnutls_mem.c
index 2d7537b8..fda4099b 100644
--- a/src/daemon/https/tls/gnutls_mem.c
+++ b/src/daemon/https/tls/gnutls_mem.c
@@ -26,40 +26,40 @@
26#include <gnutls_errors.h> 26#include <gnutls_errors.h>
27#include <gnutls_num.h> 27#include <gnutls_num.h>
28 28
29gnutls_alloc_function gnutls_secure_malloc = malloc; 29MHD_gnutls_alloc_function MHD_gnutls_secure_malloc = malloc;
30gnutls_alloc_function gnutls_malloc = malloc; 30MHD_gnutls_alloc_function MHD_gnutls_malloc = malloc;
31gnutls_free_function gnutls_free = free; 31MHD_gnutls_free_function MHD_gnutls_free = free;
32gnutls_realloc_function gnutls_realloc = realloc; 32MHD_gnutls_realloc_function MHD_gnutls_realloc = realloc;
33 33
34void *(*gnutls_calloc) (size_t, size_t) = calloc; 34void *(*MHD_gnutls_calloc) (size_t, size_t) = calloc;
35char *(*gnutls_strdup) (const char *) = mhd_gtls_strdup; 35char *(*MHD_gnutls_strdup) (const char *) = MHD_gtls_strdup;
36 36
37int 37int
38_gnutls_is_secure_mem_null (const void *ign) 38MHD__gnutls_is_secure_mem_null (const void *ign)
39{ 39{
40 return 0; 40 return 0;
41} 41}
42 42
43int (*_gnutls_is_secure_memory) (const void *) = _gnutls_is_secure_mem_null; 43int (*MHD__gnutls_is_secure_memory) (const void *) = MHD__gnutls_is_secure_mem_null;
44 44
45 45
46void * 46void *
47mhd_gtls_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;
51 ret = gnutls_malloc (size); 51 ret = MHD_gnutls_malloc (size);
52 if (ret != NULL) 52 if (ret != NULL)
53 memset (ret, 0, size); 53 memset (ret, 0, size);
54 return ret; 54 return ret;
55} 55}
56 56
57svoid * 57svoid *
58mhd_gtls_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;
62 ret = gnutls_secure_malloc (size); 62 ret = MHD_gnutls_secure_malloc (size);
63 if (ret != NULL) 63 if (ret != NULL)
64 memset (ret, 0, size); 64 memset (ret, 0, size);
65 return ret; 65 return ret;
@@ -69,29 +69,29 @@ mhd_gtls_secure_calloc (size_t nmemb, size_t size)
69 * fails. 69 * fails.
70 */ 70 */
71void * 71void *
72mhd_gtls_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
76 if (size == 0) 76 if (size == 0)
77 return ptr; 77 return ptr;
78 78
79 ret = gnutls_realloc (ptr, size); 79 ret = MHD_gnutls_realloc (ptr, size);
80 if (ret == NULL) 80 if (ret == NULL)
81 { 81 {
82 gnutls_free (ptr); 82 MHD_gnutls_free (ptr);
83 } 83 }
84 84
85 return ret; 85 return ret;
86} 86}
87 87
88char * 88char *
89mhd_gtls_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;
93 93
94 ret = gnutls_malloc (siz); 94 ret = MHD_gnutls_malloc (siz);
95 if (ret != NULL) 95 if (ret != NULL)
96 memcpy (ret, str, siz); 96 memcpy (ret, str, siz);
97 return ret; 97 return ret;
@@ -103,7 +103,7 @@ mhd_gtls_strdup (const char *str)
103 */ 103 */
104 104
105/** 105/**
106 * gnutls_malloc - Allocates and returns data 106 * MHD_gnutls_malloc - Allocates and returns data
107 * 107 *
108 * This function will allocate 's' bytes data, and 108 * This function will allocate 's' bytes data, and
109 * return a pointer to memory. This function is supposed 109 * return a pointer to memory. This function is supposed
@@ -113,12 +113,12 @@ mhd_gtls_strdup (const char *str)
113 * 113 *
114 **/ 114 **/
115void * 115void *
116gnutls_malloc (size_t s) 116MHD_gnutls_malloc (size_t s)
117{ 117{
118} 118}
119 119
120/** 120/**
121 * gnutls_free - Returns a free() like function 121 * MHD_gnutls_free - Returns a free() like function
122 * @d: pointer to memory 122 * @d: pointer to memory
123 * 123 *
124 * This function will free data pointed by ptr. 124 * This function will free data pointed by ptr.
@@ -127,7 +127,7 @@ gnutls_malloc (size_t s)
127 * 127 *
128 **/ 128 **/
129void 129void
130gnutls_free (void *ptr) 130MHD_gnutls_free (void *ptr)
131{ 131{
132} 132}
133 133
diff --git a/src/daemon/https/tls/gnutls_mem.h b/src/daemon/https/tls/gnutls_mem.h
index 51b37e32..86cd4abb 100644
--- a/src/daemon/https/tls/gnutls_mem.h
+++ b/src/daemon/https/tls/gnutls_mem.h
@@ -29,42 +29,42 @@
29# include <dmalloc.h> 29# include <dmalloc.h>
30#endif 30#endif
31 31
32typedef void svoid; /* for functions that allocate using gnutls_secure_malloc */ 32typedef void svoid; /* for functions that allocate using MHD_gnutls_secure_malloc */
33 33
34/* Use gnutls_afree() when calling alloca, or 34/* Use MHD_gnutls_afree() when calling alloca, or
35 * memory leaks may occur in systems which do not 35 * memory leaks may occur in systems which do not
36 * support alloca. 36 * support alloca.
37 */ 37 */
38#ifdef USE_EFENCE 38#ifdef USE_EFENCE
39# define gnutls_alloca gnutls_malloc 39# define MHD_gnutls_alloca MHD_gnutls_malloc
40# define gnutls_afree gnutls_free 40# define MHD_gnutls_afree MHD_gnutls_free
41#endif 41#endif
42 42
43#ifdef HAVE_ALLOCA 43#ifdef HAVE_ALLOCA
44# ifdef HAVE_ALLOCA_H 44# ifdef HAVE_ALLOCA_H
45# include <alloca.h> 45# include <alloca.h>
46# endif 46# endif
47# ifndef gnutls_alloca 47# ifndef MHD_gnutls_alloca
48# define gnutls_alloca alloca 48# define MHD_gnutls_alloca alloca
49# define gnutls_afree(x) 49# define MHD_gnutls_afree(x)
50# endif 50# endif
51#else 51#else
52# ifndef gnutls_alloca 52# ifndef MHD_gnutls_alloca
53# define gnutls_alloca gnutls_malloc 53# define MHD_gnutls_alloca MHD_gnutls_malloc
54# define gnutls_afree gnutls_free 54# define MHD_gnutls_afree MHD_gnutls_free
55# endif 55# endif
56#endif /* HAVE_ALLOCA */ 56#endif /* HAVE_ALLOCA */
57 57
58extern int (*_gnutls_is_secure_memory) (const void *); 58extern int (*MHD__gnutls_is_secure_memory) (const void *);
59 59
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 *mhd_gtls_realloc_fast (void *ptr, size_t size); 63void *MHD_gtls_realloc_fast (void *ptr, size_t size);
64 64
65svoid *mhd_gtls_secure_calloc (size_t nmemb, size_t size); 65svoid *MHD_gtls_secure_calloc (size_t nmemb, size_t size);
66 66
67void *mhd_gtls_calloc (size_t nmemb, size_t size); 67void *MHD_gtls_calloc (size_t nmemb, size_t size);
68char *mhd_gtls_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 10831b71..034b189f 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
38mhd_gtls_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 @@ mhd_gtls_mpi_release (mpi_t * x)
46/* returns zero on success 46/* returns zero on success
47 */ 47 */
48int 48int
49mhd_gtls_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 @@ mhd_gtls_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
63mhd_gtls_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
@@ -70,9 +70,9 @@ mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
70 70
71 /* MPIs with 0 bits are illegal 71 /* MPIs with 0 bits are illegal
72 */ 72 */
73 if (_gnutls_mpi_get_nbits (*ret_mpi) == 0) 73 if (MHD__gnutls_mpi_get_nbits (*ret_mpi) == 0)
74 { 74 {
75 mhd_gtls_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 @@ mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
80} 80}
81 81
82int 82int
83mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer, 83MHD_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
84 size_t * nbytes) 84 size_t * nbytes)
85{ 85{
86 int ret; 86 int ret;
@@ -90,9 +90,9 @@ mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
90 90
91 /* MPIs with 0 bits are illegal 91 /* MPIs with 0 bits are illegal
92 */ 92 */
93 if (_gnutls_mpi_get_nbits (*ret_mpi) == 0) 93 if (MHD__gnutls_mpi_get_nbits (*ret_mpi) == 0)
94 { 94 {
95 mhd_gtls_mpi_release (ret_mpi); 95 MHD_gtls_mpi_release (ret_mpi);
96 return GNUTLS_E_MPI_SCAN_FAILED; 96 return GNUTLS_E_MPI_SCAN_FAILED;
97 } 97 }
98 98
@@ -100,7 +100,7 @@ mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
100} 100}
101 101
102int 102int
103mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a) 103MHD_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
104{ 104{
105 int ret; 105 int ret;
106 106
@@ -116,7 +116,7 @@ mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
116 116
117/* Always has the first bit zero */ 117/* Always has the first bit zero */
118int 118int
119mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a) 119MHD_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
120{ 120{
121 int ret; 121 int ret;
122 122
@@ -132,7 +132,7 @@ mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
132 132
133/* Always has the first bit zero */ 133/* Always has the first bit zero */
134int 134int
135mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a) 135MHD_gtls_mpi_dprint_lz (MHD_gnutls_datum_t * dest, const mpi_t a)
136{ 136{
137 int ret; 137 int ret;
138 opaque *buf = NULL; 138 opaque *buf = NULL;
@@ -144,7 +144,7 @@ mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
144 gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &bytes, a); 144 gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &bytes, a);
145 145
146 if (bytes != 0) 146 if (bytes != 0)
147 buf = gnutls_malloc (bytes); 147 buf = MHD_gnutls_malloc (bytes);
148 if (buf == NULL) 148 if (buf == NULL)
149 return GNUTLS_E_MEMORY_ERROR; 149 return GNUTLS_E_MEMORY_ERROR;
150 150
@@ -156,12 +156,12 @@ mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
156 return 0; 156 return 0;
157 } 157 }
158 158
159 gnutls_free (buf); 159 MHD_gnutls_free (buf);
160 return GNUTLS_E_MPI_PRINT_FAILED; 160 return GNUTLS_E_MPI_PRINT_FAILED;
161} 161}
162 162
163int 163int
164mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a) 164MHD_gtls_mpi_dprint (MHD_gnutls_datum_t * dest, const mpi_t a)
165{ 165{
166 int ret; 166 int ret;
167 opaque *buf = NULL; 167 opaque *buf = NULL;
@@ -173,7 +173,7 @@ mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
173 gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, &bytes, a); 173 gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, &bytes, a);
174 174
175 if (bytes != 0) 175 if (bytes != 0)
176 buf = gnutls_malloc (bytes); 176 buf = MHD_gnutls_malloc (bytes);
177 if (buf == NULL) 177 if (buf == NULL)
178 return GNUTLS_E_MEMORY_ERROR; 178 return GNUTLS_E_MEMORY_ERROR;
179 179
@@ -185,7 +185,7 @@ mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
185 return 0; 185 return 0;
186 } 186 }
187 187
188 gnutls_free (buf); 188 MHD_gnutls_free (buf);
189 return GNUTLS_E_MPI_PRINT_FAILED; 189 return GNUTLS_E_MPI_PRINT_FAILED;
190} 190}
191 191
@@ -195,7 +195,7 @@ mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
195 * steps. 195 * steps.
196 */ 196 */
197int 197int
198_gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi) 198MHD__gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
199{ 199{
200 int result; 200 int result;
201 size_t s_len; 201 size_t s_len;
@@ -203,37 +203,37 @@ _gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
203 int tmpstr_size; 203 int tmpstr_size;
204 204
205 tmpstr_size = 0; 205 tmpstr_size = 0;
206 result = asn1_read_value (node, value, NULL, &tmpstr_size); 206 result = MHD__asn1_read_value (node, value, NULL, &tmpstr_size);
207 if (result != ASN1_MEM_ERROR) 207 if (result != ASN1_MEM_ERROR)
208 { 208 {
209 gnutls_assert (); 209 MHD_gnutls_assert ();
210 return mhd_gtls_asn2err (result); 210 return MHD_gtls_asn2err (result);
211 } 211 }
212 212
213 tmpstr = gnutls_alloca (tmpstr_size); 213 tmpstr = MHD_gnutls_alloca (tmpstr_size);
214 if (tmpstr == NULL) 214 if (tmpstr == NULL)
215 { 215 {
216 gnutls_assert (); 216 MHD_gnutls_assert ();
217 return GNUTLS_E_MEMORY_ERROR; 217 return GNUTLS_E_MEMORY_ERROR;
218 } 218 }
219 219
220 result = asn1_read_value (node, value, tmpstr, &tmpstr_size); 220 result = MHD__asn1_read_value (node, value, tmpstr, &tmpstr_size);
221 if (result != ASN1_SUCCESS) 221 if (result != ASN1_SUCCESS)
222 { 222 {
223 gnutls_assert (); 223 MHD_gnutls_assert ();
224 gnutls_afree (tmpstr); 224 MHD_gnutls_afree (tmpstr);
225 return mhd_gtls_asn2err (result); 225 return MHD_gtls_asn2err (result);
226 } 226 }
227 227
228 s_len = tmpstr_size; 228 s_len = tmpstr_size;
229 if (mhd_gtls_mpi_scan (ret_mpi, tmpstr, &s_len) != 0) 229 if (MHD_gtls_mpi_scan (ret_mpi, tmpstr, &s_len) != 0)
230 { 230 {
231 gnutls_assert (); 231 MHD_gnutls_assert ();
232 gnutls_afree (tmpstr); 232 MHD_gnutls_afree (tmpstr);
233 return GNUTLS_E_MPI_SCAN_FAILED; 233 return GNUTLS_E_MPI_SCAN_FAILED;
234 } 234 }
235 235
236 gnutls_afree (tmpstr); 236 MHD_gnutls_afree (tmpstr);
237 237
238 return 0; 238 return 0;
239} 239}
@@ -241,7 +241,7 @@ _gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
241/* Writes the specified integer into the specified node. 241/* Writes the specified integer into the specified node.
242 */ 242 */
243int 243int
244_gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz) 244MHD__gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
245{ 245{
246 opaque *tmpstr; 246 opaque *tmpstr;
247 size_t s_len; 247 size_t s_len;
@@ -249,37 +249,37 @@ _gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
249 249
250 s_len = 0; 250 s_len = 0;
251 if (lz) 251 if (lz)
252 result = mhd_gtls_mpi_print_lz (NULL, &s_len, mpi); 252 result = MHD_gtls_mpi_print_lz (NULL, &s_len, mpi);
253 else 253 else
254 result = mhd_gtls_mpi_print (NULL, &s_len, mpi); 254 result = MHD_gtls_mpi_print (NULL, &s_len, mpi);
255 255
256 tmpstr = gnutls_alloca (s_len); 256 tmpstr = MHD_gnutls_alloca (s_len);
257 if (tmpstr == NULL) 257 if (tmpstr == NULL)
258 { 258 {
259 gnutls_assert (); 259 MHD_gnutls_assert ();
260 return GNUTLS_E_MEMORY_ERROR; 260 return GNUTLS_E_MEMORY_ERROR;
261 } 261 }
262 262
263 if (lz) 263 if (lz)
264 result = mhd_gtls_mpi_print_lz (tmpstr, &s_len, mpi); 264 result = MHD_gtls_mpi_print_lz (tmpstr, &s_len, mpi);
265 else 265 else
266 result = mhd_gtls_mpi_print (tmpstr, &s_len, mpi); 266 result = MHD_gtls_mpi_print (tmpstr, &s_len, mpi);
267 267
268 if (result != 0) 268 if (result != 0)
269 { 269 {
270 gnutls_assert (); 270 MHD_gnutls_assert ();
271 gnutls_afree (tmpstr); 271 MHD_gnutls_afree (tmpstr);
272 return GNUTLS_E_MPI_PRINT_FAILED; 272 return GNUTLS_E_MPI_PRINT_FAILED;
273 } 273 }
274 274
275 result = asn1_write_value (node, value, tmpstr, s_len); 275 result = MHD__asn1_write_value (node, value, tmpstr, s_len);
276 276
277 gnutls_afree (tmpstr); 277 MHD_gnutls_afree (tmpstr);
278 278
279 if (result != ASN1_SUCCESS) 279 if (result != ASN1_SUCCESS)
280 { 280 {
281 gnutls_assert (); 281 MHD_gnutls_assert ();
282 return mhd_gtls_asn2err (result); 282 return MHD_gtls_asn2err (result);
283 } 283 }
284 284
285 return 0; 285 return 0;
diff --git a/src/daemon/https/tls/gnutls_mpi.h b/src/daemon/https/tls/gnutls_mpi.h
index 24d60c8a..ec633ca0 100644
--- a/src/daemon/https/tls/gnutls_mpi.h
+++ b/src/daemon/https/tls/gnutls_mpi.h
@@ -33,46 +33,46 @@
33 33
34typedef gcry_mpi_t mpi_t; 34typedef gcry_mpi_t mpi_t;
35 35
36#define _gnutls_mpi_cmp gcry_mpi_cmp 36#define MHD__gnutls_mpi_cmp gcry_mpi_cmp
37#define _gnutls_mpi_cmp_ui gcry_mpi_cmp_ui 37#define MHD__gnutls_mpi_cmp_ui gcry_mpi_cmp_ui
38#define _gnutls_mpi_mod gcry_mpi_mod 38#define MHD__gnutls_mpi_mod gcry_mpi_mod
39#define _gnutls_mpi_new gcry_mpi_new 39#define MHD__gnutls_mpi_new gcry_mpi_new
40#define _gnutls_mpi_snew gcry_mpi_snew 40#define MHD__gnutls_mpi_snew gcry_mpi_snew
41#define _gnutls_mpi_copy gcry_mpi_copy 41#define MHD__gnutls_mpi_copy gcry_mpi_copy
42#define _gnutls_mpi_set_ui gcry_mpi_set_ui 42#define MHD__gnutls_mpi_set_ui gcry_mpi_set_ui
43#define _gnutls_mpi_set gcry_mpi_set 43#define MHD__gnutls_mpi_set gcry_mpi_set
44#define _gnutls_mpi_randomize gcry_mpi_randomize 44#define MHD__gnutls_mpi_randomize gcry_mpi_randomize
45#define _gnutls_mpi_get_nbits gcry_mpi_get_nbits 45#define MHD__gnutls_mpi_get_nbits gcry_mpi_get_nbits
46#define _gnutls_mpi_powm gcry_mpi_powm 46#define MHD__gnutls_mpi_powm gcry_mpi_powm
47#define _gnutls_mpi_invm gcry_mpi_invm 47#define MHD__gnutls_mpi_invm gcry_mpi_invm
48#define _gnutls_mpi_addm gcry_mpi_addm 48#define MHD__gnutls_mpi_addm gcry_mpi_addm
49#define _gnutls_mpi_subm gcry_mpi_subm 49#define MHD__gnutls_mpi_subm gcry_mpi_subm
50#define _gnutls_mpi_sub_ui gcry_mpi_sub_ui 50#define MHD__gnutls_mpi_sub_ui gcry_mpi_sub_ui
51#define _gnutls_mpi_mulm gcry_mpi_mulm 51#define MHD__gnutls_mpi_mulm gcry_mpi_mulm
52#define _gnutls_mpi_mul gcry_mpi_mul 52#define MHD__gnutls_mpi_mul gcry_mpi_mul
53#define _gnutls_mpi_add gcry_mpi_add 53#define MHD__gnutls_mpi_add gcry_mpi_add
54#define _gnutls_mpi_add_ui gcry_mpi_add_ui 54#define MHD__gnutls_mpi_add_ui gcry_mpi_add_ui
55#define _gnutls_mpi_sub_ui gcry_mpi_sub_ui 55#define MHD__gnutls_mpi_sub_ui gcry_mpi_sub_ui
56#define _gnutls_mpi_mul_ui gcry_mpi_mul_ui 56#define MHD__gnutls_mpi_mul_ui gcry_mpi_mul_ui
57#define _gnutls_prime_check gcry_prime_check 57#define MHD__gnutls_prime_check gcry_prime_check
58#define _gnutls_mpi_div gcry_mpi_div 58#define MHD__gnutls_mpi_div gcry_mpi_div
59 59
60#define _gnutls_mpi_alloc_like(x) _gnutls_mpi_new(_gnutls_mpi_get_nbits(x)) 60#define MHD__gnutls_mpi_alloc_like(x) MHD__gnutls_mpi_new(MHD__gnutls_mpi_get_nbits(x))
61#define _gnutls_mpi_salloc_like(x) _gnutls_mpi_snew(_gnutls_mpi_get_nbits(x)) 61#define MHD__gnutls_mpi_salloc_like(x) MHD__gnutls_mpi_snew(MHD__gnutls_mpi_get_nbits(x))
62 62
63void mhd_gtls_mpi_release (mpi_t * x); 63void MHD_gtls_mpi_release (mpi_t * x);
64 64
65int mhd_gtls_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 mhd_gtls_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 mhd_gtls_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 mhd_gtls_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 mhd_gtls_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 mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a); 75int MHD_gtls_mpi_dprint_lz (MHD_gnutls_datum_t * dest, const mpi_t a);
76int mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a); 76int MHD_gtls_mpi_dprint (MHD_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 ab5c7196..06d2e4eb 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
38mhd_gtls_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 @@ mhd_gtls_uint64pp (uint64 * x)
60} 60}
61 61
62uint32_t 62uint32_t
63mhd_gtls_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 @@ mhd_gtls_uint24touint32 (uint24 num)
71} 71}
72 72
73uint24 73uint24
74mhd_gtls_uint32touint24 (uint32_t num) 74MHD_gtls_uint32touint24 (uint32_t num)
75{ 75{
76 uint24 ret; 76 uint24 ret;
77 77
@@ -84,7 +84,7 @@ mhd_gtls_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
87mhd_gtls_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 @@ mhd_gtls_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 = mhd_gtls_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 @@ mhd_gtls_read_uint24 (const opaque * data)
101} 101}
102 102
103void 103void
104mhd_gtls_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 = mhd_gtls_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 @@ mhd_gtls_write_uint24 (uint32_t num, opaque * data)
116} 116}
117 117
118uint32_t 118uint32_t
119mhd_gtls_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 @@ mhd_gtls_read_uint32 (const opaque * data)
128} 128}
129 129
130void 130void
131mhd_gtls_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 @@ mhd_gtls_write_uint32 (uint32_t num, opaque * data)
138} 138}
139 139
140uint16_t 140uint16_t
141mhd_gtls_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 @@ mhd_gtls_read_uint16 (const opaque * data)
149} 149}
150 150
151void 151void
152mhd_gtls_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 @@ mhd_gtls_write_uint16 (uint16_t num, opaque * data)
159} 159}
160 160
161uint32_t 161uint32_t
162mhd_gtls_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 @@ mhd_gtls_conv_uint32 (uint32_t data)
169} 169}
170 170
171uint16_t 171uint16_t
172mhd_gtls_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 @@ mhd_gtls_conv_uint16 (uint16_t data)
179} 179}
180 180
181uint32_t 181uint32_t
182mhd_gtls_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 37ce0c6d..13d1e3ae 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 mhd_gtls_uint24touint32 (uint24 num); 35uint32_t MHD_gtls_uint24touint32 (uint24 num);
36uint24 mhd_gtls_uint32touint24 (uint32_t num); 36uint24 MHD_gtls_uint32touint24 (uint32_t num);
37uint32_t mhd_gtls_read_uint32 (const opaque * data); 37uint32_t MHD_gtls_read_uint32 (const opaque * data);
38uint16_t mhd_gtls_read_uint16 (const opaque * data); 38uint16_t MHD_gtls_read_uint16 (const opaque * data);
39uint32_t mhd_gtls_conv_uint32 (uint32_t data); 39uint32_t MHD_gtls_conv_uint32 (uint32_t data);
40uint16_t mhd_gtls_conv_uint16 (uint16_t data); 40uint16_t MHD_gtls_conv_uint16 (uint16_t data);
41uint32_t mhd_gtls_read_uint24 (const opaque * data); 41uint32_t MHD_gtls_read_uint24 (const opaque * data);
42void mhd_gtls_write_uint24 (uint32_t num, opaque * data); 42void MHD_gtls_write_uint24 (uint32_t num, opaque * data);
43void mhd_gtls_write_uint32 (uint32_t num, opaque * data); 43void MHD_gtls_write_uint32 (uint32_t num, opaque * data);
44void mhd_gtls_write_uint16 (uint16_t num, opaque * data); 44void MHD_gtls_write_uint16 (uint16_t num, opaque * data);
45uint32_t mhd_gtls_uint64touint32 (const uint64 *); 45uint32_t MHD_gtls_uint64touint32 (const uint64 *);
46 46
47int mhd_gtls_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 MHD__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 20f17951..53bc6394 100644
--- a/src/daemon/https/tls/gnutls_pk.c
+++ b/src/daemon/https/tls/gnutls_pk.c
@@ -40,13 +40,13 @@
40#include "common.h" 40#include "common.h"
41#include "mpi.h" 41#include "mpi.h"
42 42
43static int _gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data, 43static int MHD__gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data,
44 mpi_t * pkey, int pkey_len); 44 mpi_t * pkey, int pkey_len);
45static int _gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, 45static int MHD__gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash,
46 mpi_t * pkey, int); 46 mpi_t * pkey, int);
47static int _gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data, 47static int MHD__gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data,
48 mpi_t * pkey, int); 48 mpi_t * pkey, int);
49static int _gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, 49static int MHD__gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data,
50 mpi_t * pkey, int); 50 mpi_t * pkey, int);
51 51
52 52
@@ -54,8 +54,8 @@ 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
57mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, 57MHD_gtls_pkcs1_rsa_encrypt (MHD_gnutls_datum_t * ciphertext,
58 const gnutls_datum_t * plaintext, 58 const MHD_gnutls_datum_t * plaintext,
59 mpi_t * params, unsigned params_len, 59 mpi_t * params, unsigned params_len,
60 unsigned btype) 60 unsigned btype)
61{ 61{
@@ -66,21 +66,21 @@ mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
66 size_t k, psize; 66 size_t k, psize;
67 size_t mod_bits; 67 size_t mod_bits;
68 68
69 mod_bits = _gnutls_mpi_get_nbits (params[0]); 69 mod_bits = MHD__gnutls_mpi_get_nbits (params[0]);
70 k = mod_bits / 8; 70 k = mod_bits / 8;
71 if (mod_bits % 8 != 0) 71 if (mod_bits % 8 != 0)
72 k++; 72 k++;
73 73
74 if (plaintext->size > k - 11) 74 if (plaintext->size > k - 11)
75 { 75 {
76 gnutls_assert (); 76 MHD_gnutls_assert ();
77 return GNUTLS_E_PK_ENCRYPTION_FAILED; 77 return GNUTLS_E_PK_ENCRYPTION_FAILED;
78 } 78 }
79 79
80 edata = gnutls_alloca (k); 80 edata = MHD_gnutls_alloca (k);
81 if (edata == NULL) 81 if (edata == NULL)
82 { 82 {
83 gnutls_assert (); 83 MHD_gnutls_assert ();
84 return GNUTLS_E_MEMORY_ERROR; 84 return GNUTLS_E_MEMORY_ERROR;
85 } 85 }
86 86
@@ -99,24 +99,24 @@ mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
99 /* using public key */ 99 /* using public key */
100 if (params_len < RSA_PUBLIC_PARAMS) 100 if (params_len < RSA_PUBLIC_PARAMS)
101 { 101 {
102 gnutls_assert (); 102 MHD_gnutls_assert ();
103 gnutls_afree (edata); 103 MHD_gnutls_afree (edata);
104 return GNUTLS_E_INTERNAL_ERROR; 104 return GNUTLS_E_INTERNAL_ERROR;
105 } 105 }
106 106
107 if (gc_pseudo_random (ps, psize) != GC_OK) 107 if (MHD_gc_pseudo_random (ps, psize) != GC_OK)
108 { 108 {
109 gnutls_assert (); 109 MHD_gnutls_assert ();
110 gnutls_afree (edata); 110 MHD_gnutls_afree (edata);
111 return GNUTLS_E_RANDOM_FAILED; 111 return GNUTLS_E_RANDOM_FAILED;
112 } 112 }
113 for (i = 0; i < psize; i++) 113 for (i = 0; i < psize; i++)
114 while (ps[i] == 0) 114 while (ps[i] == 0)
115 { 115 {
116 if (gc_pseudo_random (&ps[i], 1) != GC_OK) 116 if (MHD_gc_pseudo_random (&ps[i], 1) != GC_OK)
117 { 117 {
118 gnutls_assert (); 118 MHD_gnutls_assert ();
119 gnutls_afree (edata); 119 MHD_gnutls_afree (edata);
120 return GNUTLS_E_RANDOM_FAILED; 120 return GNUTLS_E_RANDOM_FAILED;
121 } 121 }
122 } 122 }
@@ -126,8 +126,8 @@ mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
126 126
127 if (params_len < RSA_PRIVATE_PARAMS) 127 if (params_len < RSA_PRIVATE_PARAMS)
128 { 128 {
129 gnutls_assert (); 129 MHD_gnutls_assert ();
130 gnutls_afree (edata); 130 MHD_gnutls_afree (edata);
131 return GNUTLS_E_INTERNAL_ERROR; 131 return GNUTLS_E_INTERNAL_ERROR;
132 } 132 }
133 133
@@ -135,36 +135,36 @@ mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
135 ps[i] = 0xff; 135 ps[i] = 0xff;
136 break; 136 break;
137 default: 137 default:
138 gnutls_assert (); 138 MHD_gnutls_assert ();
139 gnutls_afree (edata); 139 MHD_gnutls_afree (edata);
140 return GNUTLS_E_INTERNAL_ERROR; 140 return GNUTLS_E_INTERNAL_ERROR;
141 } 141 }
142 142
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 (mhd_gtls_mpi_scan_nz (&m, edata, &k) != 0) 146 if (MHD_gtls_mpi_scan_nz (&m, edata, &k) != 0)
147 { 147 {
148 gnutls_assert (); 148 MHD_gnutls_assert ();
149 gnutls_afree (edata); 149 MHD_gnutls_afree (edata);
150 return GNUTLS_E_MPI_SCAN_FAILED; 150 return GNUTLS_E_MPI_SCAN_FAILED;
151 } 151 }
152 gnutls_afree (edata); 152 MHD_gnutls_afree (edata);
153 153
154 if (btype == 2) /* encrypt */ 154 if (btype == 2) /* encrypt */
155 ret = _gnutls_pk_encrypt (GCRY_PK_RSA, &res, m, params, params_len); 155 ret = MHD__gnutls_pk_encrypt (GCRY_PK_RSA, &res, m, params, params_len);
156 else /* sign */ 156 else /* sign */
157 ret = _gnutls_pk_sign (GCRY_PK_RSA, &res, m, params, params_len); 157 ret = MHD__gnutls_pk_sign (GCRY_PK_RSA, &res, m, params, params_len);
158 158
159 mhd_gtls_mpi_release (&m); 159 MHD_gtls_mpi_release (&m);
160 160
161 if (ret < 0) 161 if (ret < 0)
162 { 162 {
163 gnutls_assert (); 163 MHD_gnutls_assert ();
164 return ret; 164 return ret;
165 } 165 }
166 166
167 mhd_gtls_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 {
@@ -179,25 +179,25 @@ mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
179 else 179 else
180 { /* psize > k !!! */ 180 { /* psize > k !!! */
181 /* This is an impossible situation */ 181 /* This is an impossible situation */
182 gnutls_assert (); 182 MHD_gnutls_assert ();
183 mhd_gtls_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
187 ciphertext->data = gnutls_malloc (psize); 187 ciphertext->data = MHD_gnutls_malloc (psize);
188 if (ciphertext->data == NULL) 188 if (ciphertext->data == NULL)
189 { 189 {
190 gnutls_assert (); 190 MHD_gnutls_assert ();
191 mhd_gtls_mpi_release (&res); 191 MHD_gtls_mpi_release (&res);
192 return GNUTLS_E_MEMORY_ERROR; 192 return GNUTLS_E_MEMORY_ERROR;
193 } 193 }
194 mhd_gtls_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 mhd_gtls_mpi_release (&res); 200 MHD_gtls_mpi_release (&res);
201 201
202 return 0; 202 return 0;
203} 203}
@@ -208,8 +208,8 @@ mhd_gtls_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
211mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, 211MHD_gtls_pkcs1_rsa_decrypt (MHD_gnutls_datum_t * plaintext,
212 const gnutls_datum_t * ciphertext, 212 const MHD_gnutls_datum_t * ciphertext,
213 mpi_t * params, unsigned params_len, 213 mpi_t * params, unsigned params_len,
214 unsigned btype) 214 unsigned btype)
215{ 215{
@@ -219,7 +219,7 @@ mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
219 opaque *edata; 219 opaque *edata;
220 size_t esize, mod_bits; 220 size_t esize, mod_bits;
221 221
222 mod_bits = _gnutls_mpi_get_nbits (params[0]); 222 mod_bits = MHD__gnutls_mpi_get_nbits (params[0]);
223 k = mod_bits / 8; 223 k = mod_bits / 8;
224 if (mod_bits % 8 != 0) 224 if (mod_bits % 8 != 0)
225 k++; 225 k++;
@@ -228,13 +228,13 @@ mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
228 228
229 if (esize != k) 229 if (esize != k)
230 { 230 {
231 gnutls_assert (); 231 MHD_gnutls_assert ();
232 return GNUTLS_E_PK_DECRYPTION_FAILED; 232 return GNUTLS_E_PK_DECRYPTION_FAILED;
233 } 233 }
234 234
235 if (mhd_gtls_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 MHD_gnutls_assert ();
238 return GNUTLS_E_MPI_SCAN_FAILED; 238 return GNUTLS_E_MPI_SCAN_FAILED;
239 } 239 }
240 240
@@ -242,30 +242,30 @@ mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
242 * available. 242 * available.
243 */ 243 */
244 if (btype == 2) 244 if (btype == 2)
245 ret = _gnutls_pk_decrypt (GCRY_PK_RSA, &res, c, params, params_len); 245 ret = MHD__gnutls_pk_decrypt (GCRY_PK_RSA, &res, c, params, params_len);
246 else 246 else
247 { 247 {
248 ret = _gnutls_pk_encrypt (GCRY_PK_RSA, &res, c, params, params_len); 248 ret = MHD__gnutls_pk_encrypt (GCRY_PK_RSA, &res, c, params, params_len);
249 } 249 }
250 mhd_gtls_mpi_release (&c); 250 MHD_gtls_mpi_release (&c);
251 251
252 if (ret < 0) 252 if (ret < 0)
253 { 253 {
254 gnutls_assert (); 254 MHD_gnutls_assert ();
255 return ret; 255 return ret;
256 } 256 }
257 257
258 mhd_gtls_mpi_print (NULL, &esize, res); 258 MHD_gtls_mpi_print (NULL, &esize, res);
259 edata = gnutls_alloca (esize + 1); 259 edata = MHD_gnutls_alloca (esize + 1);
260 if (edata == NULL) 260 if (edata == NULL)
261 { 261 {
262 gnutls_assert (); 262 MHD_gnutls_assert ();
263 mhd_gtls_mpi_release (&res); 263 MHD_gtls_mpi_release (&res);
264 return GNUTLS_E_MEMORY_ERROR; 264 return GNUTLS_E_MEMORY_ERROR;
265 } 265 }
266 mhd_gtls_mpi_print (&edata[1], &esize, res); 266 MHD_gtls_mpi_print (&edata[1], &esize, res);
267 267
268 mhd_gtls_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')
@@ -282,8 +282,8 @@ mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
282 282
283 if (edata[0] != 0 || edata[1] != btype) 283 if (edata[0] != 0 || edata[1] != btype)
284 { 284 {
285 gnutls_assert (); 285 MHD_gnutls_assert ();
286 gnutls_afree (edata); 286 MHD_gnutls_afree (edata);
287 return GNUTLS_E_DECRYPTION_FAILED; 287 return GNUTLS_E_DECRYPTION_FAILED;
288 } 288 }
289 289
@@ -310,7 +310,7 @@ mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
310 } 310 }
311 if (edata[i] != 0xff) 311 if (edata[i] != 0xff)
312 { 312 {
313 _gnutls_handshake_log ("PKCS #1 padding error"); 313 MHD__gnutls_handshake_log ("PKCS #1 padding error");
314 /* PKCS #1 padding error. Don't use 314 /* PKCS #1 padding error. Don't use
315 GNUTLS_E_PKCS1_WRONG_PAD here. */ 315 GNUTLS_E_PKCS1_WRONG_PAD here. */
316 break; 316 break;
@@ -318,65 +318,65 @@ mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
318 } 318 }
319 break; 319 break;
320 default: 320 default:
321 gnutls_assert (); 321 MHD_gnutls_assert ();
322 gnutls_afree (edata); 322 MHD_gnutls_afree (edata);
323 return GNUTLS_E_DECRYPTION_FAILED; 323 return GNUTLS_E_DECRYPTION_FAILED;
324 } 324 }
325 i++; 325 i++;
326 326
327 if (ret < 0) 327 if (ret < 0)
328 { 328 {
329 gnutls_assert (); 329 MHD_gnutls_assert ();
330 gnutls_afree (edata); 330 MHD_gnutls_afree (edata);
331 return GNUTLS_E_DECRYPTION_FAILED; 331 return GNUTLS_E_DECRYPTION_FAILED;
332 } 332 }
333 333
334 if (_gnutls_sset_datum (plaintext, &edata[i], esize - i) < 0) 334 if (MHD__gnutls_sset_datum (plaintext, &edata[i], esize - i) < 0)
335 { 335 {
336 gnutls_assert (); 336 MHD_gnutls_assert ();
337 gnutls_afree (edata); 337 MHD_gnutls_afree (edata);
338 return GNUTLS_E_MEMORY_ERROR; 338 return GNUTLS_E_MEMORY_ERROR;
339 } 339 }
340 340
341 gnutls_afree (edata); 341 MHD_gnutls_afree (edata);
342 342
343 return 0; 343 return 0;
344} 344}
345 345
346 346
347int 347int
348mhd_gtls_rsa_verify (const gnutls_datum_t * vdata, 348MHD_gtls_rsa_verify (const MHD_gnutls_datum_t * vdata,
349 const gnutls_datum_t * ciphertext, mpi_t * params, 349 const MHD_gnutls_datum_t * ciphertext, mpi_t * params,
350 int params_len, int btype) 350 int params_len, int btype)
351{ 351{
352 352
353 gnutls_datum_t plain; 353 MHD_gnutls_datum_t plain;
354 int ret; 354 int ret;
355 355
356 /* decrypt signature */ 356 /* decrypt signature */
357 if ((ret = 357 if ((ret =
358 mhd_gtls_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 MHD_gnutls_assert ();
362 return ret; 362 return ret;
363 } 363 }
364 364
365 if (plain.size != vdata->size) 365 if (plain.size != vdata->size)
366 { 366 {
367 gnutls_assert (); 367 MHD_gnutls_assert ();
368 _gnutls_free_datum (&plain); 368 MHD__gnutls_free_datum (&plain);
369 return GNUTLS_E_PK_SIG_VERIFY_FAILED; 369 return GNUTLS_E_PK_SIG_VERIFY_FAILED;
370 } 370 }
371 371
372 if (memcmp (plain.data, vdata->data, plain.size) != 0) 372 if (memcmp (plain.data, vdata->data, plain.size) != 0)
373 { 373 {
374 gnutls_assert (); 374 MHD_gnutls_assert ();
375 _gnutls_free_datum (&plain); 375 MHD__gnutls_free_datum (&plain);
376 return GNUTLS_E_PK_SIG_VERIFY_FAILED; 376 return GNUTLS_E_PK_SIG_VERIFY_FAILED;
377 } 377 }
378 378
379 _gnutls_free_datum (&plain); 379 MHD__gnutls_free_datum (&plain);
380 380
381 return 0; /* ok */ 381 return 0; /* ok */
382} 382}
@@ -384,45 +384,45 @@ mhd_gtls_rsa_verify (const gnutls_datum_t * vdata,
384/* encodes the Dss-Sig-Value structure 384/* encodes the Dss-Sig-Value structure
385 */ 385 */
386static int 386static int
387encode_ber_rs (gnutls_datum_t * sig_value, mpi_t r, mpi_t s) 387encode_ber_rs (MHD_gnutls_datum_t * sig_value, mpi_t r, mpi_t s)
388{ 388{
389 ASN1_TYPE sig; 389 ASN1_TYPE sig;
390 int result, tot_len; 390 int result, tot_len;
391 391
392 if ((result = 392 if ((result =
393 asn1_create_element (_gnutls_get_gnutls_asn (), 393 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (),
394 "GNUTLS.DSASignatureValue", 394 "GNUTLS.DSASignatureValue",
395 &sig)) != ASN1_SUCCESS) 395 &sig)) != ASN1_SUCCESS)
396 { 396 {
397 gnutls_assert (); 397 MHD_gnutls_assert ();
398 return mhd_gtls_asn2err (result); 398 return MHD_gtls_asn2err (result);
399 } 399 }
400 400
401 result = _gnutls_x509_write_int (sig, "r", r, 1); 401 result = MHD__gnutls_x509_write_int (sig, "r", r, 1);
402 if (result < 0) 402 if (result < 0)
403 { 403 {
404 gnutls_assert (); 404 MHD_gnutls_assert ();
405 asn1_delete_structure (&sig); 405 MHD__asn1_delete_structure (&sig);
406 return result; 406 return result;
407 } 407 }
408 408
409 result = _gnutls_x509_write_int (sig, "s", s, 1); 409 result = MHD__gnutls_x509_write_int (sig, "s", s, 1);
410 if (result < 0) 410 if (result < 0)
411 { 411 {
412 gnutls_assert (); 412 MHD_gnutls_assert ();
413 asn1_delete_structure (&sig); 413 MHD__asn1_delete_structure (&sig);
414 return result; 414 return result;
415 } 415 }
416 416
417 tot_len = 0; 417 tot_len = 0;
418 418
419 result = _gnutls_x509_der_encode (sig, "", sig_value, 0); 419 result = MHD__gnutls_x509_der_encode (sig, "", sig_value, 0);
420 420
421 asn1_delete_structure (&sig); 421 MHD__asn1_delete_structure (&sig);
422 422
423 if (result < 0) 423 if (result < 0)
424 { 424 {
425 gnutls_assert (); 425 MHD_gnutls_assert ();
426 return result; 426 return result;
427 } 427 }
428 428
@@ -433,8 +433,8 @@ 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
436mhd_gtls_dsa_sign (gnutls_datum_t * signature, 436MHD_gtls_dsa_sign (MHD_gnutls_datum_t * signature,
437 const gnutls_datum_t * hash, mpi_t * params, 437 const MHD_gnutls_datum_t * hash, mpi_t * params,
438 unsigned params_len) 438 unsigned params_len)
439{ 439{
440 mpi_t rs[2], mdata; 440 mpi_t rs[2], mdata;
@@ -444,35 +444,35 @@ mhd_gtls_dsa_sign (gnutls_datum_t * signature,
444 k = hash->size; 444 k = hash->size;
445 if (k < 20) 445 if (k < 20)
446 { /* SHA1 or better only */ 446 { /* SHA1 or better only */
447 gnutls_assert (); 447 MHD_gnutls_assert ();
448 return GNUTLS_E_PK_SIGN_FAILED; 448 return GNUTLS_E_PK_SIGN_FAILED;
449 } 449 }
450 450
451 if (mhd_gtls_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 MHD_gnutls_assert ();
454 return GNUTLS_E_MPI_SCAN_FAILED; 454 return GNUTLS_E_MPI_SCAN_FAILED;
455 } 455 }
456 456
457 ret = _gnutls_pk_sign (GCRY_PK_DSA, rs, mdata, params, params_len); 457 ret = MHD__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 mhd_gtls_mpi_release (&mdata); 459 MHD_gtls_mpi_release (&mdata);
460 460
461 if (ret < 0) 461 if (ret < 0)
462 { 462 {
463 gnutls_assert (); 463 MHD_gnutls_assert ();
464 return ret; 464 return ret;
465 } 465 }
466 466
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 mhd_gtls_mpi_release (&rs[0]); 470 MHD_gtls_mpi_release (&rs[0]);
471 mhd_gtls_mpi_release (&rs[1]); 471 MHD_gtls_mpi_release (&rs[1]);
472 472
473 if (ret != 0) 473 if (ret != 0)
474 { 474 {
475 gnutls_assert (); 475 MHD_gnutls_assert ();
476 return GNUTLS_E_MEMORY_ERROR; 476 return GNUTLS_E_MEMORY_ERROR;
477 } 477 }
478 478
@@ -482,46 +482,46 @@ mhd_gtls_dsa_sign (gnutls_datum_t * signature,
482/* decodes the Dss-Sig-Value structure 482/* decodes the Dss-Sig-Value structure
483 */ 483 */
484static int 484static int
485decode_ber_rs (const gnutls_datum_t * sig_value, mpi_t * r, mpi_t * s) 485decode_ber_rs (const MHD_gnutls_datum_t * sig_value, mpi_t * r, mpi_t * s)
486{ 486{
487 ASN1_TYPE sig; 487 ASN1_TYPE sig;
488 int result; 488 int result;
489 489
490 if ((result = 490 if ((result =
491 asn1_create_element (_gnutls_get_gnutls_asn (), 491 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (),
492 "GNUTLS.DSASignatureValue", 492 "GNUTLS.DSASignatureValue",
493 &sig)) != ASN1_SUCCESS) 493 &sig)) != ASN1_SUCCESS)
494 { 494 {
495 gnutls_assert (); 495 MHD_gnutls_assert ();
496 return mhd_gtls_asn2err (result); 496 return MHD_gtls_asn2err (result);
497 } 497 }
498 498
499 result = asn1_der_decoding (&sig, sig_value->data, sig_value->size, NULL); 499 result = MHD__asn1_der_decoding (&sig, sig_value->data, sig_value->size, NULL);
500 if (result != ASN1_SUCCESS) 500 if (result != ASN1_SUCCESS)
501 { 501 {
502 gnutls_assert (); 502 MHD_gnutls_assert ();
503 asn1_delete_structure (&sig); 503 MHD__asn1_delete_structure (&sig);
504 return mhd_gtls_asn2err (result); 504 return MHD_gtls_asn2err (result);
505 } 505 }
506 506
507 result = _gnutls_x509_read_int (sig, "r", r); 507 result = MHD__gnutls_x509_read_int (sig, "r", r);
508 if (result < 0) 508 if (result < 0)
509 { 509 {
510 gnutls_assert (); 510 MHD_gnutls_assert ();
511 asn1_delete_structure (&sig); 511 MHD__asn1_delete_structure (&sig);
512 return result; 512 return result;
513 } 513 }
514 514
515 result = _gnutls_x509_read_int (sig, "s", s); 515 result = MHD__gnutls_x509_read_int (sig, "s", s);
516 if (result < 0) 516 if (result < 0)
517 { 517 {
518 gnutls_assert (); 518 MHD_gnutls_assert ();
519 mhd_gtls_mpi_release (s); 519 MHD_gtls_mpi_release (s);
520 asn1_delete_structure (&sig); 520 MHD__asn1_delete_structure (&sig);
521 return result; 521 return result;
522 } 522 }
523 523
524 asn1_delete_structure (&sig); 524 MHD__asn1_delete_structure (&sig);
525 525
526 return 0; 526 return 0;
527} 527}
@@ -529,8 +529,8 @@ 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
532mhd_gtls_dsa_verify (const gnutls_datum_t * vdata, 532MHD_gtls_dsa_verify (const MHD_gnutls_datum_t * vdata,
533 const gnutls_datum_t * sig_value, mpi_t * params, 533 const MHD_gnutls_datum_t * sig_value, mpi_t * params,
534 int params_len) 534 int params_len)
535{ 535{
536 536
@@ -541,34 +541,34 @@ mhd_gtls_dsa_verify (const gnutls_datum_t * vdata,
541 541
542 if (vdata->size != 20) 542 if (vdata->size != 20)
543 { /* sha-1 only */ 543 { /* sha-1 only */
544 gnutls_assert (); 544 MHD_gnutls_assert ();
545 return GNUTLS_E_PK_SIG_VERIFY_FAILED; 545 return GNUTLS_E_PK_SIG_VERIFY_FAILED;
546 } 546 }
547 547
548 if (decode_ber_rs (sig_value, &rs[0], &rs[1]) != 0) 548 if (decode_ber_rs (sig_value, &rs[0], &rs[1]) != 0)
549 { 549 {
550 gnutls_assert (); 550 MHD_gnutls_assert ();
551 return GNUTLS_E_MPI_SCAN_FAILED; 551 return GNUTLS_E_MPI_SCAN_FAILED;
552 } 552 }
553 553
554 k = vdata->size; 554 k = vdata->size;
555 if (mhd_gtls_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 MHD_gnutls_assert ();
558 mhd_gtls_mpi_release (&rs[0]); 558 MHD_gtls_mpi_release (&rs[0]);
559 mhd_gtls_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 = MHD__gnutls_pk_verify (GCRY_PK_DSA, mdata, rs, params, params_len);
565 mhd_gtls_mpi_release (&mdata); 565 MHD_gtls_mpi_release (&mdata);
566 mhd_gtls_mpi_release (&rs[0]); 566 MHD_gtls_mpi_release (&rs[0]);
567 mhd_gtls_mpi_release (&rs[1]); 567 MHD_gtls_mpi_release (&rs[1]);
568 568
569 if (ret < 0) 569 if (ret < 0)
570 { 570 {
571 gnutls_assert (); 571 MHD_gnutls_assert ();
572 return ret; 572 return ret;
573 } 573 }
574 574
@@ -584,7 +584,7 @@ mhd_gtls_dsa_verify (const gnutls_datum_t * vdata,
584 * change the internal design to directly fit to libgcrypt. 584 * change the internal design to directly fit to libgcrypt.
585 */ 585 */
586static int 586static int
587_gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data, 587MHD__gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data,
588 mpi_t * pkey, int pkey_len) 588 mpi_t * pkey, int pkey_len)
589{ 589{
590 gcry_sexp_t s_ciph, s_data, s_pkey; 590 gcry_sexp_t s_ciph, s_data, s_pkey;
@@ -601,20 +601,20 @@ _gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data,
601 break; 601 break;
602 602
603 default: 603 default:
604 gnutls_assert (); 604 MHD_gnutls_assert ();
605 return GNUTLS_E_INTERNAL_ERROR; 605 return GNUTLS_E_INTERNAL_ERROR;
606 } 606 }
607 607
608 if (rc != 0) 608 if (rc != 0)
609 { 609 {
610 gnutls_assert (); 610 MHD_gnutls_assert ();
611 return GNUTLS_E_INTERNAL_ERROR; 611 return GNUTLS_E_INTERNAL_ERROR;
612 } 612 }
613 613
614 /* put the data into a simple list */ 614 /* put the data into a simple list */
615 if (gcry_sexp_build (&s_data, NULL, "%m", data)) 615 if (gcry_sexp_build (&s_data, NULL, "%m", data))
616 { 616 {
617 gnutls_assert (); 617 MHD_gnutls_assert ();
618 gcry_sexp_release (s_pkey); 618 gcry_sexp_release (s_pkey);
619 return GNUTLS_E_INTERNAL_ERROR; 619 return GNUTLS_E_INTERNAL_ERROR;
620 } 620 }
@@ -626,7 +626,7 @@ _gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data,
626 626
627 if (rc != 0) 627 if (rc != 0)
628 { 628 {
629 gnutls_assert (); 629 MHD_gnutls_assert ();
630 return GNUTLS_E_PK_ENCRYPTION_FAILED; 630 return GNUTLS_E_PK_ENCRYPTION_FAILED;
631 631
632 } 632 }
@@ -635,7 +635,7 @@ _gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data,
635 gcry_sexp_t list = gcry_sexp_find_token (s_ciph, "a", 0); 635 gcry_sexp_t list = gcry_sexp_find_token (s_ciph, "a", 0);
636 if (list == NULL) 636 if (list == NULL)
637 { 637 {
638 gnutls_assert (); 638 MHD_gnutls_assert ();
639 gcry_sexp_release (s_ciph); 639 gcry_sexp_release (s_ciph);
640 return GNUTLS_E_INTERNAL_ERROR; 640 return GNUTLS_E_INTERNAL_ERROR;
641 } 641 }
@@ -645,7 +645,7 @@ _gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data,
645 645
646 if (resarr[0] == NULL) 646 if (resarr[0] == NULL)
647 { 647 {
648 gnutls_assert (); 648 MHD_gnutls_assert ();
649 gcry_sexp_release (s_ciph); 649 gcry_sexp_release (s_ciph);
650 return GNUTLS_E_INTERNAL_ERROR; 650 return GNUTLS_E_INTERNAL_ERROR;
651 } 651 }
@@ -656,7 +656,7 @@ _gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data,
656} 656}
657 657
658static int 658static int
659_gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, mpi_t * pkey, 659MHD__gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, mpi_t * pkey,
660 int pkey_len) 660 int pkey_len)
661{ 661{
662 gcry_sexp_t s_plain, s_data, s_pkey; 662 gcry_sexp_t s_plain, s_data, s_pkey;
@@ -674,20 +674,20 @@ _gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, mpi_t * pkey,
674 break; 674 break;
675 675
676 default: 676 default:
677 gnutls_assert (); 677 MHD_gnutls_assert ();
678 return GNUTLS_E_INTERNAL_ERROR; 678 return GNUTLS_E_INTERNAL_ERROR;
679 } 679 }
680 680
681 if (rc != 0) 681 if (rc != 0)
682 { 682 {
683 gnutls_assert (); 683 MHD_gnutls_assert ();
684 return GNUTLS_E_INTERNAL_ERROR; 684 return GNUTLS_E_INTERNAL_ERROR;
685 } 685 }
686 686
687 /* put the data into a simple list */ 687 /* put the data into a simple list */
688 if (gcry_sexp_build (&s_data, NULL, "(enc-val(rsa(a%m)))", data)) 688 if (gcry_sexp_build (&s_data, NULL, "(enc-val(rsa(a%m)))", data))
689 { 689 {
690 gnutls_assert (); 690 MHD_gnutls_assert ();
691 gcry_sexp_release (s_pkey); 691 gcry_sexp_release (s_pkey);
692 return GNUTLS_E_INTERNAL_ERROR; 692 return GNUTLS_E_INTERNAL_ERROR;
693 } 693 }
@@ -699,7 +699,7 @@ _gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, mpi_t * pkey,
699 699
700 if (rc != 0) 700 if (rc != 0)
701 { 701 {
702 gnutls_assert (); 702 MHD_gnutls_assert ();
703 return GNUTLS_E_PK_DECRYPTION_FAILED; 703 return GNUTLS_E_PK_DECRYPTION_FAILED;
704 704
705 } 705 }
@@ -709,7 +709,7 @@ _gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, mpi_t * pkey,
709 709
710 if (resarr[0] == NULL) 710 if (resarr[0] == NULL)
711 { 711 {
712 gnutls_assert (); 712 MHD_gnutls_assert ();
713 gcry_sexp_release (s_plain); 713 gcry_sexp_release (s_plain);
714 return GNUTLS_E_INTERNAL_ERROR; 714 return GNUTLS_E_INTERNAL_ERROR;
715 } 715 }
@@ -723,7 +723,7 @@ _gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, mpi_t * pkey,
723/* in case of DSA puts into data, r,s 723/* in case of DSA puts into data, r,s
724 */ 724 */
725static int 725static int
726_gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey, 726MHD__gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey,
727 int pkey_len) 727 int pkey_len)
728{ 728{
729 gcry_sexp_t s_hash, s_key, s_sig; 729 gcry_sexp_t s_hash, s_key, s_sig;
@@ -739,7 +739,7 @@ _gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey,
739 pkey[0], pkey[1], pkey[2], pkey[3], pkey[4]); 739 pkey[0], pkey[1], pkey[2], pkey[3], pkey[4]);
740 else 740 else
741 { 741 {
742 gnutls_assert (); 742 MHD_gnutls_assert ();
743 } 743 }
744 744
745 break; 745 break;
@@ -751,25 +751,25 @@ _gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey,
751 pkey[4], pkey[5]); 751 pkey[4], pkey[5]);
752 else 752 else
753 { 753 {
754 gnutls_assert (); 754 MHD_gnutls_assert ();
755 } 755 }
756 break; 756 break;
757 757
758 default: 758 default:
759 gnutls_assert (); 759 MHD_gnutls_assert ();
760 return GNUTLS_E_INTERNAL_ERROR; 760 return GNUTLS_E_INTERNAL_ERROR;
761 } 761 }
762 762
763 if (rc != 0) 763 if (rc != 0)
764 { 764 {
765 gnutls_assert (); 765 MHD_gnutls_assert ();
766 return GNUTLS_E_INTERNAL_ERROR; 766 return GNUTLS_E_INTERNAL_ERROR;
767 } 767 }
768 768
769 /* put the data into a simple list */ 769 /* put the data into a simple list */
770 if (gcry_sexp_build (&s_hash, NULL, "%m", hash)) 770 if (gcry_sexp_build (&s_hash, NULL, "%m", hash))
771 { 771 {
772 gnutls_assert (); 772 MHD_gnutls_assert ();
773 return GNUTLS_E_INTERNAL_ERROR; 773 return GNUTLS_E_INTERNAL_ERROR;
774 } 774 }
775 775
@@ -780,7 +780,7 @@ _gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey,
780 780
781 if (rc != 0) 781 if (rc != 0)
782 { 782 {
783 gnutls_assert (); 783 MHD_gnutls_assert ();
784 return GNUTLS_E_PK_SIGN_FAILED; 784 return GNUTLS_E_PK_SIGN_FAILED;
785 785
786 } 786 }
@@ -793,7 +793,7 @@ _gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey,
793 list = gcry_sexp_find_token (s_sig, "r", 0); 793 list = gcry_sexp_find_token (s_sig, "r", 0);
794 if (list == NULL) 794 if (list == NULL)
795 { 795 {
796 gnutls_assert (); 796 MHD_gnutls_assert ();
797 gcry_sexp_release (s_sig); 797 gcry_sexp_release (s_sig);
798 return GNUTLS_E_INTERNAL_ERROR; 798 return GNUTLS_E_INTERNAL_ERROR;
799 } 799 }
@@ -804,7 +804,7 @@ _gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey,
804 list = gcry_sexp_find_token (s_sig, "s", 0); 804 list = gcry_sexp_find_token (s_sig, "s", 0);
805 if (list == NULL) 805 if (list == NULL)
806 { 806 {
807 gnutls_assert (); 807 MHD_gnutls_assert ();
808 gcry_sexp_release (s_sig); 808 gcry_sexp_release (s_sig);
809 return GNUTLS_E_INTERNAL_ERROR; 809 return GNUTLS_E_INTERNAL_ERROR;
810 } 810 }
@@ -817,7 +817,7 @@ _gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey,
817 list = gcry_sexp_find_token (s_sig, "s", 0); 817 list = gcry_sexp_find_token (s_sig, "s", 0);
818 if (list == NULL) 818 if (list == NULL)
819 { 819 {
820 gnutls_assert (); 820 MHD_gnutls_assert ();
821 gcry_sexp_release (s_sig); 821 gcry_sexp_release (s_sig);
822 return GNUTLS_E_INTERNAL_ERROR; 822 return GNUTLS_E_INTERNAL_ERROR;
823 } 823 }
@@ -833,7 +833,7 @@ _gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey,
833 833
834 834
835static int 835static int
836_gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data, 836MHD__gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data,
837 mpi_t * pkey, int pkey_len) 837 mpi_t * pkey, int pkey_len)
838{ 838{
839 gcry_sexp_t s_sig, s_hash, s_pkey; 839 gcry_sexp_t s_sig, s_hash, s_pkey;
@@ -856,20 +856,20 @@ _gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data,
856 break; 856 break;
857 857
858 default: 858 default:
859 gnutls_assert (); 859 MHD_gnutls_assert ();
860 return GNUTLS_E_INTERNAL_ERROR; 860 return GNUTLS_E_INTERNAL_ERROR;
861 } 861 }
862 862
863 if (rc != 0) 863 if (rc != 0)
864 { 864 {
865 gnutls_assert (); 865 MHD_gnutls_assert ();
866 return GNUTLS_E_INTERNAL_ERROR; 866 return GNUTLS_E_INTERNAL_ERROR;
867 } 867 }
868 868
869 /* put the data into a simple list */ 869 /* put the data into a simple list */
870 if (gcry_sexp_build (&s_hash, NULL, "%m", hash)) 870 if (gcry_sexp_build (&s_hash, NULL, "%m", hash))
871 { 871 {
872 gnutls_assert (); 872 MHD_gnutls_assert ();
873 gcry_sexp_release (s_pkey); 873 gcry_sexp_release (s_pkey);
874 return GNUTLS_E_INTERNAL_ERROR; 874 return GNUTLS_E_INTERNAL_ERROR;
875 } 875 }
@@ -885,7 +885,7 @@ _gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data,
885 break; 885 break;
886 886
887 default: 887 default:
888 gnutls_assert (); 888 MHD_gnutls_assert ();
889 gcry_sexp_release (s_pkey); 889 gcry_sexp_release (s_pkey);
890 gcry_sexp_release (s_hash); 890 gcry_sexp_release (s_hash);
891 return GNUTLS_E_INTERNAL_ERROR; 891 return GNUTLS_E_INTERNAL_ERROR;
@@ -893,7 +893,7 @@ _gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data,
893 893
894 if (rc != 0) 894 if (rc != 0)
895 { 895 {
896 gnutls_assert (); 896 MHD_gnutls_assert ();
897 gcry_sexp_release (s_pkey); 897 gcry_sexp_release (s_pkey);
898 gcry_sexp_release (s_hash); 898 gcry_sexp_release (s_hash);
899 return GNUTLS_E_INTERNAL_ERROR; 899 return GNUTLS_E_INTERNAL_ERROR;
@@ -907,7 +907,7 @@ _gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data,
907 907
908 if (rc != 0) 908 if (rc != 0)
909 { 909 {
910 gnutls_assert (); 910 MHD_gnutls_assert ();
911 return GNUTLS_E_PK_SIG_VERIFY_FAILED; 911 return GNUTLS_E_PK_SIG_VERIFY_FAILED;
912 } 912 }
913 913
diff --git a/src/daemon/https/tls/gnutls_pk.h b/src/daemon/https/tls/gnutls_pk.h
index ef4723d4..bd153a45 100644
--- a/src/daemon/https/tls/gnutls_pk.h
+++ b/src/daemon/https/tls/gnutls_pk.h
@@ -25,22 +25,22 @@
25#ifndef GNUTLS_PK_H 25#ifndef GNUTLS_PK_H
26#define GNUTLS_PK_H 26#define GNUTLS_PK_H
27 27
28int mhd_gtls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, 28int MHD_gtls_pkcs1_rsa_encrypt (MHD_gnutls_datum_t * ciphertext,
29 const gnutls_datum_t * plaintext, 29 const MHD_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 mhd_gtls_dsa_sign (gnutls_datum_t * signature, 32int MHD_gtls_dsa_sign (MHD_gnutls_datum_t * signature,
33 const gnutls_datum_t * plaintext, mpi_t * params, 33 const MHD_gnutls_datum_t * plaintext, mpi_t * params,
34 unsigned params_len); 34 unsigned params_len);
35int mhd_gtls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, 35int MHD_gtls_pkcs1_rsa_decrypt (MHD_gnutls_datum_t * plaintext,
36 const gnutls_datum_t * ciphertext, 36 const MHD_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 mhd_gtls_rsa_verify (const gnutls_datum_t * vdata, 39int MHD_gtls_rsa_verify (const MHD_gnutls_datum_t * vdata,
40 const gnutls_datum_t * ciphertext, mpi_t * params, 40 const MHD_gnutls_datum_t * ciphertext, mpi_t * params,
41 int params_len, int btype); 41 int params_len, int btype);
42int mhd_gtls_dsa_verify (const gnutls_datum_t * vdata, 42int MHD_gtls_dsa_verify (const MHD_gnutls_datum_t * vdata,
43 const gnutls_datum_t * sig_value, mpi_t * params, 43 const MHD_gnutls_datum_t * sig_value, mpi_t * params,
44 int params_len); 44 int params_len);
45 45
46#endif /* GNUTLS_PK_H */ 46#endif /* GNUTLS_PK_H */
diff --git a/src/daemon/https/tls/gnutls_priority.c b/src/daemon/https/tls/gnutls_priority.c
index f0a91bd6..06398e83 100644
--- a/src/daemon/https/tls/gnutls_priority.c
+++ b/src/daemon/https/tls/gnutls_priority.c
@@ -22,7 +22,7 @@
22 * 22 *
23 */ 23 */
24 24
25/* Here lies the code of the gnutls_*_set_priority() functions. 25/* Here lies the code of the MHD_gnutls_*_set_priority() functions.
26 */ 26 */
27 27
28#include "gnutls_int.h" 28#include "gnutls_int.h"
@@ -33,8 +33,8 @@
33#define MAX_ELEMENTS 48 33#define MAX_ELEMENTS 48
34 34
35/** 35/**
36 * MHD_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 #mhd_gtls_session_t structure. 37 * @session: is a #MHD_gtls_session_t structure.
38 * @list: is a 0 terminated list of enum MHD_GNUTLS_CipherAlgorithm elements. 38 * @list: is a 0 terminated list of enum MHD_GNUTLS_CipherAlgorithm 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
51MHD_gnutls_cipher_set_priority (mhd_gtls_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 @@ MHD_gnutls_cipher_set_priority (mhd_gtls_session_t session, const int *list)
67} 67}
68 68
69static int 69static int
70_set_priority (mhd_gtls_priority_st * st, const int *list) 70_set_priority (MHD_gtls_priority_st * st, const int *list)
71{ 71{
72 int num = 0; 72 int num = 0;
73 73
@@ -80,8 +80,8 @@ _set_priority (mhd_gtls_priority_st * st, const int *list)
80} 80}
81 81
82/** 82/**
83 * MHD_gnutls_kx_set_priority - Sets the priority on the key exchange algorithms supported by gnutls. 83 * MHD__gnutls_kx_set_priority - Sets the priority on the key exchange algorithms supported by gnutls.
84 * @session: is a #mhd_gtls_session_t structure. 84 * @session: is a #MHD_gtls_session_t structure.
85 * @list: is a 0 terminated list of enum MHD_GNUTLS_KeyExchangeAlgorithm elements. 85 * @list: is a 0 terminated list of enum MHD_GNUTLS_KeyExchangeAlgorithm elements.
86 * 86 *
87 * Sets the priority on the key exchange algorithms supported by gnutls. 87 * Sets the priority on the key exchange algorithms supported by gnutls.
@@ -95,14 +95,14 @@ _set_priority (mhd_gtls_priority_st * st, const int *list)
95 * 95 *
96 **/ 96 **/
97int 97int
98MHD_gnutls_kx_set_priority (mhd_gtls_session_t session, const int *list) 98MHD__gnutls_kx_set_priority (MHD_gtls_session_t session, const int *list)
99{ 99{
100 return _set_priority (&session->internals.priorities.kx, list); 100 return _set_priority (&session->internals.priorities.kx, list);
101} 101}
102 102
103/** 103/**
104 * MHD_gnutls_mac_set_priority - Sets the priority on the mac algorithms supported by gnutls. 104 * MHD__gnutls_mac_set_priority - Sets the priority on the mac algorithms supported by gnutls.
105 * @session: is a #mhd_gtls_session_t structure. 105 * @session: is a #MHD_gtls_session_t structure.
106 * @list: is a 0 terminated list of enum MHD_GNUTLS_HashAlgorithm elements. 106 * @list: is a 0 terminated list of enum MHD_GNUTLS_HashAlgorithm elements.
107 * 107 *
108 * Sets the priority on the mac algorithms supported by gnutls. 108 * Sets the priority on the mac algorithms supported by gnutls.
@@ -116,14 +116,14 @@ MHD_gnutls_kx_set_priority (mhd_gtls_session_t session, const int *list)
116 * 116 *
117 **/ 117 **/
118int 118int
119MHD_gnutls_mac_set_priority (mhd_gtls_session_t session, const int *list) 119MHD__gnutls_mac_set_priority (MHD_gtls_session_t session, const int *list)
120{ 120{
121 return _set_priority (&session->internals.priorities.mac, list); 121 return _set_priority (&session->internals.priorities.mac, list);
122} 122}
123 123
124/** 124/**
125 * MHD_gnutls_compression_set_priority - Sets the priority on the compression algorithms supported by gnutls. 125 * MHD__gnutls_compression_set_priority - Sets the priority on the compression algorithms supported by gnutls.
126 * @session: is a #mhd_gtls_session_t structure. 126 * @session: is a #MHD_gtls_session_t structure.
127 * @list: is a 0 terminated list of enum MHD_GNUTLS_CompressionMethod elements. 127 * @list: is a 0 terminated list of enum MHD_GNUTLS_CompressionMethod elements.
128 * 128 *
129 * Sets the priority on the compression algorithms supported by gnutls. 129 * Sets the priority on the compression algorithms supported by gnutls.
@@ -141,15 +141,15 @@ MHD_gnutls_mac_set_priority (mhd_gtls_session_t session, const int *list)
141 * 141 *
142 **/ 142 **/
143int 143int
144MHD_gnutls_compression_set_priority (mhd_gtls_session_t session, 144MHD__gnutls_compression_set_priority (MHD_gtls_session_t session,
145 const int *list) 145 const int *list)
146{ 146{
147 return _set_priority (&session->internals.priorities.compression, list); 147 return _set_priority (&session->internals.priorities.compression, list);
148} 148}
149 149
150/** 150/**
151 * MHD_gnutls_protocol_set_priority - Sets the priority on the protocol versions supported by gnutls. 151 * MHD__gnutls_protocol_set_priority - Sets the priority on the protocol versions supported by gnutls.
152 * @session: is a #mhd_gtls_session_t structure. 152 * @session: is a #MHD_gtls_session_t structure.
153 * @list: is a 0 terminated list of enum MHD_GNUTLS_Protocol elements. 153 * @list: is a 0 terminated list of enum MHD_GNUTLS_Protocol elements.
154 * 154 *
155 * Sets the priority on the protocol versions supported by gnutls. 155 * Sets the priority on the protocol versions supported by gnutls.
@@ -160,7 +160,7 @@ MHD_gnutls_compression_set_priority (mhd_gtls_session_t session,
160 * 160 *
161 **/ 161 **/
162int 162int
163MHD_gnutls_protocol_set_priority (mhd_gtls_session_t session, const int *list) 163MHD__gnutls_protocol_set_priority (MHD_gtls_session_t session, const int *list)
164{ 164{
165 int ret; 165 int ret;
166 166
@@ -168,14 +168,14 @@ MHD_gnutls_protocol_set_priority (mhd_gtls_session_t session, const int *list)
168 /* set the current version to the first in the chain. 168 /* set the current version to the first in the chain.
169 * This will be overridden later. 169 * This will be overridden later.
170 */ 170 */
171 mhd_gtls_set_current_version (session, list[0]); 171 MHD_gtls_set_current_version (session, list[0]);
172 172
173 return ret; 173 return ret;
174} 174}
175 175
176/** 176/**
177 * MHD_gnutls_certificate_type_set_priority - Sets the priority on the certificate types supported by gnutls. 177 * MHD__gnutls_certificate_type_set_priority - Sets the priority on the certificate types supported by gnutls.
178 * @session: is a #mhd_gtls_session_t structure. 178 * @session: is a #MHD_gtls_session_t structure.
179 * @list: is a 0 terminated list of enum MHD_GNUTLS_CertificateType elements. 179 * @list: is a 0 terminated list of enum MHD_GNUTLS_CertificateType elements.
180 * 180 *
181 * Sets the priority on the certificate types supported by gnutls. 181 * Sets the priority on the certificate types supported by gnutls.
@@ -189,7 +189,7 @@ MHD_gnutls_protocol_set_priority (mhd_gtls_session_t session, const int *list)
189 * 189 *
190 **/ 190 **/
191int 191int
192MHD_gnutls_certificate_type_set_priority (mhd_gtls_session_t session, 192MHD__gnutls_certificate_type_set_priority (MHD_gtls_session_t session,
193 const int *list) 193 const int *list)
194{ 194{
195#if ENABLE_OPENPGP 195#if ENABLE_OPENPGP
@@ -201,39 +201,39 @@ MHD_gnutls_certificate_type_set_priority (mhd_gtls_session_t session,
201#endif 201#endif
202} 202}
203 203
204static const int mhd_gtls_protocol_priority[] = { MHD_GNUTLS_PROTOCOL_TLS1_1, 204static const int MHD_gtls_protocol_priority[] = { MHD_GNUTLS_PROTOCOL_TLS1_1,
205 MHD_GNUTLS_PROTOCOL_TLS1_0, 205 MHD_GNUTLS_PROTOCOL_TLS1_0,
206 MHD_GNUTLS_PROTOCOL_SSL3, 206 MHD_GNUTLS_PROTOCOL_SSL3,
207 0 207 0
208}; 208};
209 209
210static const int mhd_gtls_cipher_priority_secure256[] = 210static const int MHD_gtls_cipher_priority_secure256[] =
211 { MHD_GNUTLS_CIPHER_AES_256_CBC, 211 { MHD_GNUTLS_CIPHER_AES_256_CBC,
212 0 212 0
213}; 213};
214 214
215static const int mhd_gtls_kx_priority_secure[] = { MHD_GNUTLS_KX_RSA, 215static const int MHD_gtls_kx_priority_secure[] = { MHD_GNUTLS_KX_RSA,
216 0 216 0
217}; 217};
218 218
219static const int mhd_gtls_mac_priority_secure[] = { MHD_GNUTLS_MAC_SHA1, 219static const int MHD_gtls_mac_priority_secure[] = { MHD_GNUTLS_MAC_SHA1,
220 0 220 0
221}; 221};
222 222
223static int mhd_gtls_cert_type_priority[] = { MHD_GNUTLS_CRT_X509, 223static int MHD_gtls_cert_type_priority[] = { MHD_GNUTLS_CRT_X509,
224 0 224 0
225}; 225};
226 226
227static const int mhd_gtls_comp_priority[] = { MHD_GNUTLS_COMP_NULL, 227static const int MHD_gtls_comp_priority[] = { MHD_GNUTLS_COMP_NULL,
228 0 228 0
229}; 229};
230 230
231typedef void (rmadd_func) (mhd_gtls_priority_st * priority_list, int alg); 231typedef void (rmadd_func) (MHD_gtls_priority_st * priority_list, int alg);
232 232
233/** 233/**
234 * MHD_gnutls_priority_set - Sets priorities for the cipher suites supported by gnutls. 234 * MHD__gnutls_priority_set - Sets priorities for the cipher suites supported by gnutls.
235 * @session: is a #mhd_gtls_session_t structure. 235 * @session: is a #MHD_gtls_session_t structure.
236 * @priority: is a #gnutls_priority_t structure. 236 * @priority: is a #MHD_gnutls_priority_t structure.
237 * 237 *
238 * Sets the priorities to use on the ciphers, key exchange methods, 238 * Sets the priorities to use on the ciphers, key exchange methods,
239 * macs and compression methods. 239 * macs and compression methods.
@@ -242,12 +242,12 @@ typedef void (rmadd_func) (mhd_gtls_priority_st * priority_list, int alg);
242 * 242 *
243 **/ 243 **/
244int 244int
245MHD_gnutls_priority_set (mhd_gtls_session_t session, 245MHD__gnutls_priority_set (MHD_gtls_session_t session,
246 gnutls_priority_t priority) 246 MHD_gnutls_priority_t priority)
247{ 247{
248 if (priority == NULL) 248 if (priority == NULL)
249 { 249 {
250 gnutls_assert (); 250 MHD_gnutls_assert ();
251 return GNUTLS_E_NO_CIPHER_SUITES; 251 return GNUTLS_E_NO_CIPHER_SUITES;
252 } 252 }
253 253
@@ -259,13 +259,13 @@ MHD_gnutls_priority_set (mhd_gtls_session_t session,
259 259
260/** 260/**
261 * MHD_tls_set_default_priority - Sets priorities for the cipher suites supported by gnutls. 261 * MHD_tls_set_default_priority - Sets priorities for the cipher suites supported by gnutls.
262 * @priority_cache: is a #gnutls_prioritity_t structure. 262 * @priority_cache: is a #MHD_gnutls_prioritity_t structure.
263 * @priorities: is a string describing priorities 263 * @priorities: is a string describing priorities
264 * @err_pos: In case of an error this will have the position in the string the error occured 264 * @err_pos: In case of an error this will have the position in the string the error occured
265 * 265 *
266 * Sets priorities for the ciphers, key exchange methods, macs and 266 * Sets priorities for the ciphers, key exchange methods, macs and
267 * compression methods. This is to avoid using the 267 * compression methods. This is to avoid using the
268 * gnutls_*_priority() functions. 268 * MHD_gnutls_*_priority() functions.
269 * 269 *
270 * The #priorities option allows you to specify a semi-colon 270 * The #priorities option allows you to specify a semi-colon
271 * separated list of the cipher priorities to enable. 271 * separated list of the cipher priorities to enable.
@@ -323,45 +323,45 @@ MHD_gnutls_priority_set (mhd_gtls_session_t session,
323 * 0 on success. 323 * 0 on success.
324 **/ 324 **/
325int 325int
326MHD_tls_set_default_priority (gnutls_priority_t * priority_cache, 326MHD_tls_set_default_priority (MHD_gnutls_priority_t * priority_cache,
327 const char *priorities, const char **err_pos) 327 const char *priorities, const char **err_pos)
328{ 328{
329 *priority_cache = gnutls_calloc (1, sizeof (struct MHD_gtls_priority_st)); 329 *priority_cache = MHD_gnutls_calloc (1, sizeof (struct MHD_gtls_priority_st));
330 if (*priority_cache == NULL) 330 if (*priority_cache == NULL)
331 { 331 {
332 gnutls_assert (); 332 MHD_gnutls_assert ();
333 return GNUTLS_E_MEMORY_ERROR; 333 return GNUTLS_E_MEMORY_ERROR;
334 } 334 }
335 335
336 /* set mode to "SECURE256" */ 336 /* set mode to "SECURE256" */
337 _set_priority (&(*priority_cache)->protocol, mhd_gtls_protocol_priority); 337 _set_priority (&(*priority_cache)->protocol, MHD_gtls_protocol_priority);
338 _set_priority (&(*priority_cache)->cipher, 338 _set_priority (&(*priority_cache)->cipher,
339 mhd_gtls_cipher_priority_secure256); 339 MHD_gtls_cipher_priority_secure256);
340 _set_priority (&(*priority_cache)->kx, mhd_gtls_kx_priority_secure); 340 _set_priority (&(*priority_cache)->kx, MHD_gtls_kx_priority_secure);
341 _set_priority (&(*priority_cache)->mac, mhd_gtls_mac_priority_secure); 341 _set_priority (&(*priority_cache)->mac, MHD_gtls_mac_priority_secure);
342 _set_priority (&(*priority_cache)->cert_type, mhd_gtls_cert_type_priority); 342 _set_priority (&(*priority_cache)->cert_type, MHD_gtls_cert_type_priority);
343 _set_priority (&(*priority_cache)->compression, mhd_gtls_comp_priority); 343 _set_priority (&(*priority_cache)->compression, MHD_gtls_comp_priority);
344 344
345 (*priority_cache)->no_padding = 0; 345 (*priority_cache)->no_padding = 0;
346 return 0; 346 return 0;
347} 347}
348 348
349/** 349/**
350 * MHD_gnutls_priority_deinit - Deinitialize the priorities cache for the cipher suites supported by gnutls. 350 * MHD__gnutls_priority_deinit - Deinitialize the priorities cache for the cipher suites supported by gnutls.
351 * @priority_cache: is a #gnutls_prioritity_t structure. 351 * @priority_cache: is a #MHD_gnutls_prioritity_t structure.
352 * 352 *
353 * Deinitializes the priority cache. 353 * Deinitializes the priority cache.
354 * 354 *
355 **/ 355 **/
356void 356void
357MHD_gnutls_priority_deinit (gnutls_priority_t priority_cache) 357MHD__gnutls_priority_deinit (MHD_gnutls_priority_t priority_cache)
358{ 358{
359 gnutls_free (priority_cache); 359 MHD_gnutls_free (priority_cache);
360} 360}
361 361
362/** 362/**
363 * MHD_gnutls_priority_set_direct - Sets priorities for the cipher suites supported by gnutls. 363 * MHD__gnutls_priority_set_direct - Sets priorities for the cipher suites supported by gnutls.
364 * @session: is a #mhd_gtls_session_t structure. 364 * @session: is a #MHD_gtls_session_t structure.
365 * @priorities: is a string describing priorities 365 * @priorities: is a string describing priorities
366 * @err_pos: In case of an error this will have the position in the string the error occured 366 * @err_pos: In case of an error this will have the position in the string the error occured
367 * 367 *
@@ -374,27 +374,27 @@ MHD_gnutls_priority_deinit (gnutls_priority_t priority_cache)
374 * 374 *
375 **/ 375 **/
376int 376int
377MHD_gnutls_priority_set_direct (mhd_gtls_session_t session, 377MHD__gnutls_priority_set_direct (MHD_gtls_session_t session,
378 const char *priorities, const char **err_pos) 378 const char *priorities, const char **err_pos)
379{ 379{
380 gnutls_priority_t prio; 380 MHD_gnutls_priority_t prio;
381 int ret; 381 int ret;
382 382
383 ret = MHD_tls_set_default_priority (&prio, priorities, err_pos); 383 ret = MHD_tls_set_default_priority (&prio, priorities, err_pos);
384 if (ret < 0) 384 if (ret < 0)
385 { 385 {
386 gnutls_assert (); 386 MHD_gnutls_assert ();
387 return ret; 387 return ret;
388 } 388 }
389 389
390 ret = MHD_gnutls_priority_set (session, prio); 390 ret = MHD__gnutls_priority_set (session, prio);
391 if (ret < 0) 391 if (ret < 0)
392 { 392 {
393 gnutls_assert (); 393 MHD_gnutls_assert ();
394 return ret; 394 return ret;
395 } 395 }
396 396
397 MHD_gnutls_priority_deinit (prio); 397 MHD__gnutls_priority_deinit (prio);
398 398
399 return 0; 399 return 0;
400} 400}
diff --git a/src/daemon/https/tls/gnutls_record.c b/src/daemon/https/tls/gnutls_record.c
index a9422c76..9ccdb1e3 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 * MHD_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 #mhd_gtls_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 **/
52enum MHD_GNUTLS_Protocol 52enum MHD_GNUTLS_Protocol
53MHD_gnutls_protocol_get_version (mhd_gtls_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
59mhd_gtls_set_current_version (mhd_gtls_session_t session, 59MHD_gtls_set_current_version (MHD_gtls_session_t session,
60 enum MHD_GNUTLS_Protocol version) 60 enum MHD_GNUTLS_Protocol version)
61{ 61{
62 session->security_parameters.version = version; 62 session->security_parameters.version = version;
63} 63}
64 64
65/** 65/**
66 * MHD_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 #mhd_gtls_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 @@ mhd_gtls_set_current_version (mhd_gtls_session_t session,
75 * to zero. 75 * to zero.
76 **/ 76 **/
77void 77void
78MHD_gnutls_transport_set_lowat (mhd_gtls_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 * MHD_gtls_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 #mhd_gtls_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 @@ MHD_gnutls_transport_set_lowat (mhd_gtls_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
96MHD_gtls_record_disable_padding (mhd_gtls_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 * MHD_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 #mhd_gtls_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,16 +108,16 @@ MHD_gtls_record_disable_padding (mhd_gtls_session_t session)
108 * the connection handle. 108 * the connection handle.
109 **/ 109 **/
110void 110void
111MHD_gnutls_transport_set_ptr (mhd_gtls_session_t session, 111MHD__gnutls_transport_set_ptr (MHD_gtls_session_t session,
112 gnutls_transport_ptr_t ptr) 112 MHD_gnutls_transport_ptr_t ptr)
113{ 113{
114 session->internals.transport_recv_ptr = ptr; 114 session->internals.transport_recv_ptr = ptr;
115 session->internals.transport_send_ptr = ptr; 115 session->internals.transport_send_ptr = ptr;
116} 116}
117 117
118/** 118/**
119 * MHD_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 #mhd_gtls_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,21 +127,21 @@ MHD_gnutls_transport_set_ptr (mhd_gtls_session_t session,
127 * different pointers for receiving and sending. 127 * different pointers for receiving and sending.
128 **/ 128 **/
129void 129void
130MHD_gnutls_transport_set_ptr2 (mhd_gtls_session_t session, 130MHD__gnutls_transport_set_ptr2 (MHD_gtls_session_t session,
131 gnutls_transport_ptr_t recv_ptr, 131 MHD_gnutls_transport_ptr_t recv_ptr,
132 gnutls_transport_ptr_t send_ptr) 132 MHD_gnutls_transport_ptr_t send_ptr)
133{ 133{
134 session->internals.transport_send_ptr = send_ptr; 134 session->internals.transport_send_ptr = send_ptr;
135 session->internals.transport_recv_ptr = recv_ptr; 135 session->internals.transport_recv_ptr = recv_ptr;
136} 136}
137 137
138/** 138/**
139 * MHD_gnutls_bye - This function terminates the current TLS/SSL connection. 139 * MHD__gnutls_bye - This function terminates the current TLS/SSL connection.
140 * @session: is a #mhd_gtls_session_t structure. 140 * @session: is a #MHD_gtls_session_t structure.
141 * @how: is an integer 141 * @how: is an integer
142 * 142 *
143 * Terminates the current TLS/SSL connection. The connection should 143 * Terminates the current TLS/SSL connection. The connection should
144 * have been initiated using MHD_gnutls_handshake(). @how should be one 144 * have been initiated using MHD__gnutls_handshake(). @how should be one
145 * of %GNUTLS_SHUT_RDWR, %GNUTLS_SHUT_WR. 145 * of %GNUTLS_SHUT_RDWR, %GNUTLS_SHUT_WR.
146 * 146 *
147 * In case of %GNUTLS_SHUT_RDWR then the TLS connection gets 147 * In case of %GNUTLS_SHUT_RDWR then the TLS connection gets
@@ -163,13 +163,13 @@ MHD_gnutls_transport_set_ptr2 (mhd_gtls_session_t session,
163 * session, thus this behavior is not recommended. 163 * session, thus this behavior is not recommended.
164 * 164 *
165 * This function may also return %GNUTLS_E_AGAIN or 165 * This function may also return %GNUTLS_E_AGAIN or
166 * %GNUTLS_E_INTERRUPTED; cf. MHD_gnutls_record_get_direction(). 166 * %GNUTLS_E_INTERRUPTED; cf. MHD__gnutls_record_get_direction().
167 * 167 *
168 * Returns: %GNUTLS_E_SUCCESS on success, or an error code, see 168 * Returns: %GNUTLS_E_SUCCESS on success, or an error code, see
169 * function documentation for entire semantics. 169 * function documentation for entire semantics.
170 **/ 170 **/
171int 171int
172MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how) 172MHD__gnutls_bye (MHD_gtls_session_t session, MHD_gnutls_close_request_t how)
173{ 173{
174 int ret = 0; 174 int ret = 0;
175 175
@@ -177,22 +177,22 @@ MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how)
177 { 177 {
178 case STATE0: 178 case STATE0:
179 case STATE60: 179 case STATE60:
180 ret = mhd_gtls_io_write_flush (session); 180 ret = MHD_gtls_io_write_flush (session);
181 STATE = STATE60; 181 STATE = STATE60;
182 if (ret < 0) 182 if (ret < 0)
183 { 183 {
184 gnutls_assert (); 184 MHD_gnutls_assert ();
185 return ret; 185 return ret;
186 } 186 }
187 187
188 case STATE61: 188 case STATE61:
189 ret = 189 ret =
190 MHD_gnutls_alert_send (session, GNUTLS_AL_WARNING, 190 MHD__gnutls_alert_send (session, GNUTLS_AL_WARNING,
191 GNUTLS_A_CLOSE_NOTIFY); 191 GNUTLS_A_CLOSE_NOTIFY);
192 STATE = STATE61; 192 STATE = STATE61;
193 if (ret < 0) 193 if (ret < 0)
194 { 194 {
195 gnutls_assert (); 195 MHD_gnutls_assert ();
196 return ret; 196 return ret;
197 } 197 }
198 198
@@ -202,8 +202,8 @@ MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how)
202 { 202 {
203 do 203 do
204 { 204 {
205 mhd_gtls_io_clear_peeked_data (session); 205 MHD_gtls_io_clear_peeked_data (session);
206 ret = mhd_gtls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0); 206 ret = MHD_gtls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0);
207 } 207 }
208 while (ret == GNUTLS_E_GOT_APPLICATION_DATA); 208 while (ret == GNUTLS_E_GOT_APPLICATION_DATA);
209 209
@@ -212,7 +212,7 @@ MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how)
212 212
213 if (ret < 0) 213 if (ret < 0)
214 { 214 {
215 gnutls_assert (); 215 MHD_gnutls_assert ();
216 return ret; 216 return ret;
217 } 217 }
218 } 218 }
@@ -220,7 +220,7 @@ MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how)
220 220
221 break; 221 break;
222 default: 222 default:
223 gnutls_assert (); 223 MHD_gnutls_assert ();
224 return GNUTLS_E_INTERNAL_ERROR; 224 return GNUTLS_E_INTERNAL_ERROR;
225 } 225 }
226 226
@@ -231,13 +231,13 @@ MHD_gnutls_bye (mhd_gtls_session_t session, gnutls_close_request_t how)
231} 231}
232 232
233inline static void 233inline static void
234session_invalidate (mhd_gtls_session_t session) 234session_invalidate (MHD_gtls_session_t session)
235{ 235{
236 session->internals.valid_connection = VALID_FALSE; 236 session->internals.valid_connection = VALID_FALSE;
237} 237}
238 238
239inline static void 239inline static void
240session_unresumable (mhd_gtls_session_t session) 240session_unresumable (MHD_gtls_session_t session)
241{ 241{
242 session->internals.resumable = RESUME_FALSE; 242 session->internals.resumable = RESUME_FALSE;
243} 243}
@@ -245,7 +245,7 @@ session_unresumable (mhd_gtls_session_t session)
245/* returns 0 if session is valid 245/* returns 0 if session is valid
246 */ 246 */
247inline static int 247inline static int
248session_is_valid (mhd_gtls_session_t session) 248session_is_valid (MHD_gtls_session_t session)
249{ 249{
250 if (session->internals.valid_connection == VALID_FALSE) 250 if (session->internals.valid_connection == VALID_FALSE)
251 return GNUTLS_E_INVALID_SESSION; 251 return GNUTLS_E_INVALID_SESSION;
@@ -257,18 +257,18 @@ session_is_valid (mhd_gtls_session_t session)
257 * version must have 2 bytes at least. 257 * version must have 2 bytes at least.
258 */ 258 */
259inline static void 259inline static void
260copy_record_version (mhd_gtls_session_t session, 260copy_record_version (MHD_gtls_session_t session,
261 gnutls_handshake_description_t htype, opaque version[2]) 261 MHD_gnutls_handshake_description_t htype, opaque version[2])
262{ 262{
263 enum MHD_GNUTLS_Protocol lver; 263 enum MHD_GNUTLS_Protocol lver;
264 264
265 if (htype != GNUTLS_HANDSHAKE_CLIENT_HELLO 265 if (htype != GNUTLS_HANDSHAKE_CLIENT_HELLO
266 || session->internals.default_record_version[0] == 0) 266 || session->internals.default_record_version[0] == 0)
267 { 267 {
268 lver = MHD_gnutls_protocol_get_version (session); 268 lver = MHD__gnutls_protocol_get_version (session);
269 269
270 version[0] = mhd_gtls_version_get_major (lver); 270 version[0] = MHD_gtls_version_get_major (lver);
271 version[1] = mhd_gtls_version_get_minor (lver); 271 version[1] = MHD_gtls_version_get_minor (lver);
272 } 272 }
273 else 273 else
274 { 274 {
@@ -278,7 +278,7 @@ copy_record_version (mhd_gtls_session_t session,
278} 278}
279 279
280/* This function behaves exactly like write(). The only difference is 280/* This function behaves exactly like write(). The only difference is
281 * that it accepts, the mhd_gtls_session_t and the content_type_t of data to 281 * that it accepts, the MHD_gtls_session_t and the content_type_t of data to
282 * send (if called by the user the Content is specific) 282 * send (if called by the user the Content is specific)
283 * It is intended to transfer data, under the current session. 283 * It is intended to transfer data, under the current session.
284 * 284 *
@@ -292,9 +292,9 @@ copy_record_version (mhd_gtls_session_t session,
292 * 292 *
293 */ 293 */
294ssize_t 294ssize_t
295mhd_gtls_send_int (mhd_gtls_session_t session, 295MHD_gtls_send_int (MHD_gtls_session_t session,
296 content_type_t type, 296 content_type_t type,
297 gnutls_handshake_description_t htype, 297 MHD_gnutls_handshake_description_t htype,
298 const void *_data, size_t sizeofdata) 298 const void *_data, size_t sizeofdata)
299{ 299{
300 uint8_t *cipher; 300 uint8_t *cipher;
@@ -311,14 +311,14 @@ mhd_gtls_send_int (mhd_gtls_session_t session,
311 if (session->internals.record_send_buffer.length == 0 && (sizeofdata == 0 311 if (session->internals.record_send_buffer.length == 0 && (sizeofdata == 0
312 && _data == NULL)) 312 && _data == NULL))
313 { 313 {
314 gnutls_assert (); 314 MHD_gnutls_assert ();
315 return GNUTLS_E_INVALID_REQUEST; 315 return GNUTLS_E_INVALID_REQUEST;
316 } 316 }
317 317
318 if (type != GNUTLS_ALERT) /* alert messages are sent anyway */ 318 if (type != GNUTLS_ALERT) /* alert messages are sent anyway */
319 if (session_is_valid (session) || session->internals.may_not_write != 0) 319 if (session_is_valid (session) || session->internals.may_not_write != 0)
320 { 320 {
321 gnutls_assert (); 321 MHD_gnutls_assert ();
322 return GNUTLS_E_INVALID_SESSION; 322 return GNUTLS_E_INVALID_SESSION;
323 } 323 }
324 324
@@ -329,11 +329,11 @@ mhd_gtls_send_int (mhd_gtls_session_t session,
329 */ 329 */
330 copy_record_version (session, htype, &headers[1]); 330 copy_record_version (session, htype, &headers[1]);
331 331
332 _gnutls_record_log 332 MHD__gnutls_record_log
333 ("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session, 333 ("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session,
334 (int) mhd_gtls_uint64touint32 (&session->connection_state. 334 (int) MHD_gtls_uint64touint32 (&session->connection_state.
335 write_sequence_number), 335 write_sequence_number),
336 _gnutls_packet2str (type), type, sizeofdata); 336 MHD__gnutls_packet2str (type), type, sizeofdata);
337 337
338 if (sizeofdata > MAX_RECORD_SEND_SIZE) 338 if (sizeofdata > MAX_RECORD_SEND_SIZE)
339 data2send_size = MAX_RECORD_SEND_SIZE; 339 data2send_size = MAX_RECORD_SEND_SIZE;
@@ -345,7 +345,7 @@ mhd_gtls_send_int (mhd_gtls_session_t session,
345 */ 345 */
346 if (session->internals.record_send_buffer.length > 0) 346 if (session->internals.record_send_buffer.length > 0)
347 { 347 {
348 ret = mhd_gtls_io_write_flush (session); 348 ret = MHD_gtls_io_write_flush (session);
349 if (ret > 0) 349 if (ret > 0)
350 cipher_size = ret; 350 cipher_size = ret;
351 else 351 else
@@ -360,24 +360,24 @@ mhd_gtls_send_int (mhd_gtls_session_t session,
360 /* now proceed to packet encryption 360 /* now proceed to packet encryption
361 */ 361 */
362 cipher_size = data2send_size + MAX_RECORD_OVERHEAD; 362 cipher_size = data2send_size + MAX_RECORD_OVERHEAD;
363 cipher = gnutls_malloc (cipher_size); 363 cipher = MHD_gnutls_malloc (cipher_size);
364 if (cipher == NULL) 364 if (cipher == NULL)
365 { 365 {
366 gnutls_assert (); 366 MHD_gnutls_assert ();
367 return GNUTLS_E_MEMORY_ERROR; 367 return GNUTLS_E_MEMORY_ERROR;
368 } 368 }
369 369
370 cipher_size = 370 cipher_size =
371 mhd_gtls_encrypt (session, headers, RECORD_HEADER_SIZE, data, 371 MHD_gtls_encrypt (session, headers, RECORD_HEADER_SIZE, data,
372 data2send_size, cipher, cipher_size, type, 372 data2send_size, cipher, cipher_size, type,
373 (session->internals.priorities.no_padding == 373 (session->internals.priorities.no_padding ==
374 0) ? 1 : 0); 374 0) ? 1 : 0);
375 if (cipher_size <= 0) 375 if (cipher_size <= 0)
376 { 376 {
377 gnutls_assert (); 377 MHD_gnutls_assert ();
378 if (cipher_size == 0) 378 if (cipher_size == 0)
379 cipher_size = GNUTLS_E_ENCRYPTION_FAILED; 379 cipher_size = GNUTLS_E_ENCRYPTION_FAILED;
380 gnutls_free (cipher); 380 MHD_gnutls_free (cipher);
381 return cipher_size; /* error */ 381 return cipher_size; /* error */
382 } 382 }
383 383
@@ -386,17 +386,17 @@ mhd_gtls_send_int (mhd_gtls_session_t session,
386 386
387 /* increase sequence number 387 /* increase sequence number
388 */ 388 */
389 if (mhd_gtls_uint64pp 389 if (MHD_gtls_uint64pp
390 (&session->connection_state.write_sequence_number) != 0) 390 (&session->connection_state.write_sequence_number) != 0)
391 { 391 {
392 session_invalidate (session); 392 session_invalidate (session);
393 gnutls_assert (); 393 MHD_gnutls_assert ();
394 gnutls_free (cipher); 394 MHD_gnutls_free (cipher);
395 return GNUTLS_E_RECORD_LIMIT_REACHED; 395 return GNUTLS_E_RECORD_LIMIT_REACHED;
396 } 396 }
397 397
398 ret = mhd_gtls_io_write_buffered (session, cipher, cipher_size); 398 ret = MHD_gtls_io_write_buffered (session, cipher, cipher_size);
399 gnutls_free (cipher); 399 MHD_gnutls_free (cipher);
400 } 400 }
401 401
402 if (ret != cipher_size) 402 if (ret != cipher_size)
@@ -406,29 +406,29 @@ mhd_gtls_send_int (mhd_gtls_session_t session,
406 /* If we have sent any data then just return 406 /* If we have sent any data then just return
407 * the error value. Do not invalidate the session. 407 * the error value. Do not invalidate the session.
408 */ 408 */
409 gnutls_assert (); 409 MHD_gnutls_assert ();
410 return ret; 410 return ret;
411 } 411 }
412 412
413 if (ret > 0) 413 if (ret > 0)
414 { 414 {
415 gnutls_assert (); 415 MHD_gnutls_assert ();
416 ret = GNUTLS_E_INTERNAL_ERROR; 416 ret = GNUTLS_E_INTERNAL_ERROR;
417 } 417 }
418 session_unresumable (session); 418 session_unresumable (session);
419 session->internals.may_not_write = 1; 419 session->internals.may_not_write = 1;
420 gnutls_assert (); 420 MHD_gnutls_assert ();
421 return ret; 421 return ret;
422 } 422 }
423 423
424 session->internals.record_send_buffer_user_size = 0; 424 session->internals.record_send_buffer_user_size = 0;
425 425
426 _gnutls_record_log ("REC[%x]: Sent Packet[%d] %s(%d) with length: %d\n", 426 MHD__gnutls_record_log ("REC[%x]: Sent Packet[%d] %s(%d) with length: %d\n",
427 session, 427 session,
428 (int) 428 (int)
429 mhd_gtls_uint64touint32 429 MHD_gtls_uint64touint32
430 (&session->connection_state.write_sequence_number), 430 (&session->connection_state.write_sequence_number),
431 _gnutls_packet2str (type), type, cipher_size); 431 MHD__gnutls_packet2str (type), type, cipher_size);
432 432
433 return retval; 433 return retval;
434} 434}
@@ -437,20 +437,20 @@ mhd_gtls_send_int (mhd_gtls_session_t session,
437 * completed. This sends a Change Cipher Spec packet to the peer. 437 * completed. This sends a Change Cipher Spec packet to the peer.
438 */ 438 */
439ssize_t 439ssize_t
440mhd_gtls_send_change_cipher_spec (mhd_gtls_session_t session, int again) 440MHD_gtls_send_change_cipher_spec (MHD_gtls_session_t session, int again)
441{ 441{
442 static const opaque data[1] = { 442 static const opaque data[1] = {
443 GNUTLS_TYPE_CHANGE_CIPHER_SPEC 443 GNUTLS_TYPE_CHANGE_CIPHER_SPEC
444 }; 444 };
445 445
446 _gnutls_handshake_log ("REC[%x]: Sent ChangeCipherSpec\n", session); 446 MHD__gnutls_handshake_log ("REC[%x]: Sent ChangeCipherSpec\n", session);
447 447
448 if (again == 0) 448 if (again == 0)
449 return mhd_gtls_send_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, data, 449 return MHD_gtls_send_int (session, GNUTLS_CHANGE_CIPHER_SPEC, -1, data,
450 1); 450 1);
451 else 451 else
452 { 452 {
453 return mhd_gtls_io_write_flush (session); 453 return MHD_gtls_io_write_flush (session);
454 } 454 }
455} 455}
456 456
@@ -466,7 +466,7 @@ check_recv_type (content_type_t recv_type)
466 case GNUTLS_INNER_APPLICATION: 466 case GNUTLS_INNER_APPLICATION:
467 return 0; 467 return 0;
468 default: 468 default:
469 gnutls_assert (); 469 MHD_gnutls_assert ();
470 return GNUTLS_A_UNEXPECTED_MESSAGE; 470 return GNUTLS_A_UNEXPECTED_MESSAGE;
471 } 471 }
472 472
@@ -476,27 +476,27 @@ check_recv_type (content_type_t recv_type)
476 * then it copies the data. 476 * then it copies the data.
477 */ 477 */
478static int 478static int
479check_buffers (mhd_gtls_session_t session, 479check_buffers (MHD_gtls_session_t session,
480 content_type_t type, opaque * data, int sizeofdata) 480 content_type_t type, opaque * data, int sizeofdata)
481{ 481{
482 if ((type == GNUTLS_APPLICATION_DATA || type == GNUTLS_HANDSHAKE || type 482 if ((type == GNUTLS_APPLICATION_DATA || type == GNUTLS_HANDSHAKE || type
483 == GNUTLS_INNER_APPLICATION) 483 == GNUTLS_INNER_APPLICATION)
484 && mhd_gnutls_record_buffer_get_size (type, session) > 0) 484 && MHD_gnutls_record_buffer_get_size (type, session) > 0)
485 { 485 {
486 int ret, ret2; 486 int ret, ret2;
487 ret = mhd_gtls_record_buffer_get (type, session, data, sizeofdata); 487 ret = MHD_gtls_record_buffer_get (type, session, data, sizeofdata);
488 if (ret < 0) 488 if (ret < 0)
489 { 489 {
490 gnutls_assert (); 490 MHD_gnutls_assert ();
491 return ret; 491 return ret;
492 } 492 }
493 493
494 /* if the buffer just got empty */ 494 /* if the buffer just got empty */
495 if (mhd_gnutls_record_buffer_get_size (type, session) == 0) 495 if (MHD_gnutls_record_buffer_get_size (type, session) == 0)
496 { 496 {
497 if ((ret2 = mhd_gtls_io_clear_peeked_data (session)) < 0) 497 if ((ret2 = MHD_gtls_io_clear_peeked_data (session)) < 0)
498 { 498 {
499 gnutls_assert (); 499 MHD_gnutls_assert ();
500 return ret2; 500 return ret2;
501 } 501 }
502 } 502 }
@@ -511,10 +511,10 @@ check_buffers (mhd_gtls_session_t session,
511 * content type. 511 * content type.
512 */ 512 */
513static int 513static int
514record_check_headers (mhd_gtls_session_t session, 514record_check_headers (MHD_gtls_session_t session,
515 uint8_t headers[RECORD_HEADER_SIZE], 515 uint8_t headers[RECORD_HEADER_SIZE],
516 content_type_t type, 516 content_type_t type,
517 gnutls_handshake_description_t htype, 517 MHD_gnutls_handshake_description_t htype,
518 /*output */ content_type_t * recv_type, 518 /*output */ content_type_t * recv_type,
519 opaque version[2], 519 opaque version[2],
520 uint16_t * length, uint16_t * header_size) 520 uint16_t * length, uint16_t * header_size)
@@ -546,7 +546,7 @@ record_check_headers (mhd_gtls_session_t session,
546 */ 546 */
547 session->internals.v2_hello = *length; 547 session->internals.v2_hello = *length;
548 548
549 _gnutls_record_log ("REC[%x]: V2 packet received. Length: %d\n", 549 MHD__gnutls_record_log ("REC[%x]: V2 packet received. Length: %d\n",
550 session, *length); 550 session, *length);
551 551
552 } 552 }
@@ -559,7 +559,7 @@ record_check_headers (mhd_gtls_session_t session,
559 559
560 /* No DECR_LEN, since headers has enough size. 560 /* No DECR_LEN, since headers has enough size.
561 */ 561 */
562 *length = mhd_gtls_read_uint16 (&headers[3]); 562 *length = MHD_gtls_read_uint16 (&headers[3]);
563 } 563 }
564 564
565 return 0; 565 return 0;
@@ -569,8 +569,8 @@ record_check_headers (mhd_gtls_session_t session,
569 * negotiated in the handshake. 569 * negotiated in the handshake.
570 */ 570 */
571inline static int 571inline static int
572record_check_version (mhd_gtls_session_t session, 572record_check_version (MHD_gtls_session_t session,
573 gnutls_handshake_description_t htype, opaque version[2]) 573 MHD_gnutls_handshake_description_t htype, opaque version[2])
574{ 574{
575 if (htype == GNUTLS_HANDSHAKE_CLIENT_HELLO) 575 if (htype == GNUTLS_HANDSHAKE_CLIENT_HELLO)
576 { 576 {
@@ -578,23 +578,23 @@ record_check_version (mhd_gtls_session_t session,
578 */ 578 */
579 if (version[0] > 3) 579 if (version[0] > 3)
580 { 580 {
581 gnutls_assert (); 581 MHD_gnutls_assert ();
582 _gnutls_record_log 582 MHD__gnutls_record_log
583 ("REC[%x]: INVALID VERSION PACKET: (%d) %d.%d\n", session, 583 ("REC[%x]: INVALID VERSION PACKET: (%d) %d.%d\n", session,
584 htype, version[0], version[1]); 584 htype, version[0], version[1]);
585 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET; 585 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;
586 } 586 }
587 } 587 }
588 else if (htype != GNUTLS_HANDSHAKE_SERVER_HELLO 588 else if (htype != GNUTLS_HANDSHAKE_SERVER_HELLO
589 && MHD_gnutls_protocol_get_version (session) 589 && MHD__gnutls_protocol_get_version (session)
590 != mhd_gtls_version_get (version[0], version[1])) 590 != MHD_gtls_version_get (version[0], version[1]))
591 { 591 {
592 /* Reject record packets that have a different version than the 592 /* Reject record packets that have a different version than the
593 * one negotiated. Note that this version is not protected by any 593 * one negotiated. Note that this version is not protected by any
594 * mac. I don't really think that this check serves any purpose. 594 * mac. I don't really think that this check serves any purpose.
595 */ 595 */
596 gnutls_assert (); 596 MHD_gnutls_assert ();
597 _gnutls_record_log ("REC[%x]: INVALID VERSION PACKET: (%d) %d.%d\n", 597 MHD__gnutls_record_log ("REC[%x]: INVALID VERSION PACKET: (%d) %d.%d\n",
598 session, htype, version[0], version[1]); 598 session, htype, version[0], version[1]);
599 599
600 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET; 600 return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;
@@ -607,10 +607,10 @@ record_check_version (mhd_gtls_session_t session,
607 * the one we actually expect. 607 * the one we actually expect.
608 */ 608 */
609static int 609static int
610record_check_type (mhd_gtls_session_t session, 610record_check_type (MHD_gtls_session_t session,
611 content_type_t recv_type, 611 content_type_t recv_type,
612 content_type_t type, 612 content_type_t type,
613 gnutls_handshake_description_t htype, 613 MHD_gnutls_handshake_description_t htype,
614 opaque * data, int data_size) 614 opaque * data, int data_size)
615{ 615{
616 616
@@ -620,7 +620,7 @@ record_check_type (mhd_gtls_session_t session,
620 == GNUTLS_HANDSHAKE 620 == GNUTLS_HANDSHAKE
621 || type == GNUTLS_INNER_APPLICATION)) 621 || type == GNUTLS_INNER_APPLICATION))
622 { 622 {
623 mhd_gnutls_record_buffer_put (type, session, (void *) data, data_size); 623 MHD_gnutls_record_buffer_put (type, session, (void *) data, data_size);
624 } 624 }
625 else 625 else
626 { 626 {
@@ -628,9 +628,9 @@ record_check_type (mhd_gtls_session_t session,
628 { 628 {
629 case GNUTLS_ALERT: 629 case GNUTLS_ALERT:
630 630
631 _gnutls_record_log 631 MHD__gnutls_record_log
632 ("REC[%x]: Alert[%d|%d] - %s - was received\n", session, 632 ("REC[%x]: Alert[%d|%d] - %s - was received\n", session,
633 data[0], data[1], MHD_gnutls_alert_get_name ((int) data[1])); 633 data[0], data[1], MHD__gnutls_alert_get_name ((int) data[1]));
634 634
635 session->internals.last_alert = data[1]; 635 session->internals.last_alert = data[1];
636 session->internals.last_alert_level = data[0]; 636 session->internals.last_alert_level = data[0];
@@ -651,7 +651,7 @@ record_check_type (mhd_gtls_session_t session,
651 /* if the alert is FATAL or WARNING 651 /* if the alert is FATAL or WARNING
652 * return the apropriate message 652 * return the apropriate message
653 */ 653 */
654 gnutls_assert (); 654 MHD_gnutls_assert ();
655 ret = GNUTLS_E_WARNING_ALERT_RECEIVED; 655 ret = GNUTLS_E_WARNING_ALERT_RECEIVED;
656 if (data[0] == GNUTLS_AL_FATAL) 656 if (data[0] == GNUTLS_AL_FATAL)
657 { 657 {
@@ -668,17 +668,17 @@ record_check_type (mhd_gtls_session_t session,
668 /* this packet is now handled in the recv_int() 668 /* this packet is now handled in the recv_int()
669 * function 669 * function
670 */ 670 */
671 gnutls_assert (); 671 MHD_gnutls_assert ();
672 672
673 return GNUTLS_E_UNEXPECTED_PACKET; 673 return GNUTLS_E_UNEXPECTED_PACKET;
674 674
675 case GNUTLS_APPLICATION_DATA: 675 case GNUTLS_APPLICATION_DATA:
676 /* even if data is unexpected put it into the buffer */ 676 /* even if data is unexpected put it into the buffer */
677 if ((ret = 677 if ((ret =
678 mhd_gnutls_record_buffer_put (recv_type, session, 678 MHD_gnutls_record_buffer_put (recv_type, session,
679 (void *) data, data_size)) < 0) 679 (void *) data, data_size)) < 0)
680 { 680 {
681 gnutls_assert (); 681 MHD_gnutls_assert ();
682 return ret; 682 return ret;
683 } 683 }
684 684
@@ -691,7 +691,7 @@ record_check_type (mhd_gtls_session_t session,
691 return GNUTLS_E_GOT_APPLICATION_DATA; 691 return GNUTLS_E_GOT_APPLICATION_DATA;
692 else 692 else
693 { 693 {
694 gnutls_assert (); 694 MHD_gnutls_assert ();
695 return GNUTLS_E_UNEXPECTED_PACKET; 695 return GNUTLS_E_UNEXPECTED_PACKET;
696 } 696 }
697 697
@@ -702,7 +702,7 @@ record_check_type (mhd_gtls_session_t session,
702 */ 702 */
703 if (session->security_parameters.entity == GNUTLS_SERVER) 703 if (session->security_parameters.entity == GNUTLS_SERVER)
704 { 704 {
705 gnutls_assert (); 705 MHD_gnutls_assert ();
706 return GNUTLS_E_REHANDSHAKE; 706 return GNUTLS_E_REHANDSHAKE;
707 } 707 }
708 708
@@ -712,28 +712,28 @@ record_check_type (mhd_gtls_session_t session,
712 */ 712 */
713 713
714 /* So we accept it */ 714 /* So we accept it */
715 return mhd_gtls_recv_hello_request (session, data, data_size); 715 return MHD_gtls_recv_hello_request (session, data, data_size);
716 716
717 break; 717 break;
718 case GNUTLS_INNER_APPLICATION: 718 case GNUTLS_INNER_APPLICATION:
719 /* even if data is unexpected put it into the buffer */ 719 /* even if data is unexpected put it into the buffer */
720 if ((ret = 720 if ((ret =
721 mhd_gnutls_record_buffer_put (recv_type, session, 721 MHD_gnutls_record_buffer_put (recv_type, session,
722 (void *) data, data_size)) < 0) 722 (void *) data, data_size)) < 0)
723 { 723 {
724 gnutls_assert (); 724 MHD_gnutls_assert ();
725 return ret; 725 return ret;
726 } 726 }
727 gnutls_assert (); 727 MHD_gnutls_assert ();
728 return GNUTLS_E_UNEXPECTED_PACKET; 728 return GNUTLS_E_UNEXPECTED_PACKET;
729 break; 729 break;
730 default: 730 default:
731 731
732 _gnutls_record_log 732 MHD__gnutls_record_log
733 ("REC[%x]: Received Unknown packet %d expecting %d\n", 733 ("REC[%x]: Received Unknown packet %d expecting %d\n",
734 session, recv_type, type); 734 session, recv_type, type);
735 735
736 gnutls_assert (); 736 MHD_gnutls_assert ();
737 return GNUTLS_E_INTERNAL_ERROR; 737 return GNUTLS_E_INTERNAL_ERROR;
738 } 738 }
739 } 739 }
@@ -747,7 +747,7 @@ record_check_type (mhd_gtls_session_t session,
747 * also initialize it. 747 * also initialize it.
748 */ 748 */
749inline static int 749inline static int
750get_temp_recv_buffer (mhd_gtls_session_t session, gnutls_datum_t * tmp) 750get_temp_recv_buffer (MHD_gtls_session_t session, MHD_gnutls_datum_t * tmp)
751{ 751{
752 size_t max_record_size; 752 size_t max_record_size;
753 753
@@ -769,11 +769,11 @@ get_temp_recv_buffer (mhd_gtls_session_t session, gnutls_datum_t * tmp)
769 */ 769 */
770 session->internals.recv_buffer.data 770 session->internals.recv_buffer.data
771 = 771 =
772 gnutls_realloc (session->internals.recv_buffer.data, max_record_size); 772 MHD_gnutls_realloc (session->internals.recv_buffer.data, max_record_size);
773 773
774 if (session->internals.recv_buffer.data == NULL) 774 if (session->internals.recv_buffer.data == NULL)
775 { 775 {
776 gnutls_assert (); 776 MHD_gnutls_assert ();
777 return GNUTLS_E_MEMORY_ERROR; 777 return GNUTLS_E_MEMORY_ERROR;
778 } 778 }
779 779
@@ -789,19 +789,19 @@ get_temp_recv_buffer (mhd_gtls_session_t session, gnutls_datum_t * tmp)
789#define MAX_EMPTY_PACKETS_SEQUENCE 4 789#define MAX_EMPTY_PACKETS_SEQUENCE 4
790 790
791/* This function behaves exactly like read(). The only difference is 791/* This function behaves exactly like read(). The only difference is
792 * that it accepts the mhd_gtls_session_t and the content_type_t of data to 792 * that it accepts the MHD_gtls_session_t and the content_type_t of data to
793 * receive (if called by the user the Content is Userdata only) 793 * receive (if called by the user the Content is Userdata only)
794 * It is intended to receive data, under the current session. 794 * It is intended to receive data, under the current session.
795 * 795 *
796 * The gnutls_handshake_description_t was introduced to support SSL V2.0 client hellos. 796 * The MHD_gnutls_handshake_description_t was introduced to support SSL V2.0 client hellos.
797 */ 797 */
798ssize_t 798ssize_t
799mhd_gtls_recv_int (mhd_gtls_session_t session, 799MHD_gtls_recv_int (MHD_gtls_session_t session,
800 content_type_t type, 800 content_type_t type,
801 gnutls_handshake_description_t htype, 801 MHD_gnutls_handshake_description_t htype,
802 opaque * data, size_t sizeofdata) 802 opaque * data, size_t sizeofdata)
803{ 803{
804 gnutls_datum_t tmp; 804 MHD_gnutls_datum_t tmp;
805 int decrypted_length; 805 int decrypted_length;
806 opaque version[2]; 806 opaque version[2];
807 uint8_t *headers; 807 uint8_t *headers;
@@ -822,7 +822,7 @@ begin:
822 822
823 if (empty_packet > MAX_EMPTY_PACKETS_SEQUENCE) 823 if (empty_packet > MAX_EMPTY_PACKETS_SEQUENCE)
824 { 824 {
825 gnutls_assert (); 825 MHD_gnutls_assert ();
826 return GNUTLS_E_TOO_MANY_EMPTY_PACKETS; 826 return GNUTLS_E_TOO_MANY_EMPTY_PACKETS;
827 } 827 }
828 828
@@ -835,7 +835,7 @@ begin:
835 else if (session_is_valid (session) != 0 || session->internals.may_not_read 835 else if (session_is_valid (session) != 0 || session->internals.may_not_read
836 != 0) 836 != 0)
837 { 837 {
838 gnutls_assert (); 838 MHD_gnutls_assert ();
839 return GNUTLS_E_INVALID_SESSION; 839 return GNUTLS_E_INVALID_SESSION;
840 } 840 }
841 841
@@ -850,7 +850,7 @@ begin:
850 */ 850 */
851 header_size = RECORD_HEADER_SIZE; 851 header_size = RECORD_HEADER_SIZE;
852 852
853 if ((ret = mhd_gtls_io_read_buffered (session, &headers, header_size, -1)) 853 if ((ret = MHD_gtls_io_read_buffered (session, &headers, header_size, -1))
854 != header_size) 854 != header_size)
855 { 855 {
856 if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0) 856 if (ret < 0 && MHD_gtls_error_is_fatal (ret) == 0)
@@ -859,18 +859,18 @@ begin:
859 session_invalidate (session); 859 session_invalidate (session);
860 if (type == GNUTLS_ALERT) 860 if (type == GNUTLS_ALERT)
861 { 861 {
862 gnutls_assert (); 862 MHD_gnutls_assert ();
863 return 0; /* we were expecting close notify */ 863 return 0; /* we were expecting close notify */
864 } 864 }
865 session_unresumable (session); 865 session_unresumable (session);
866 gnutls_assert (); 866 MHD_gnutls_assert ();
867 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 867 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
868 } 868 }
869 869
870 if ((ret = record_check_headers (session, headers, type, htype, &recv_type, 870 if ((ret = record_check_headers (session, headers, type, htype, &recv_type,
871 version, &length, &header_size)) < 0) 871 version, &length, &header_size)) < 0)
872 { 872 {
873 gnutls_assert (); 873 MHD_gnutls_assert ();
874 return ret; 874 return ret;
875 } 875 }
876 876
@@ -879,7 +879,7 @@ begin:
879 */ 879 */
880 if ((ret = check_recv_type (recv_type)) < 0) 880 if ((ret = check_recv_type (recv_type)) < 0)
881 { 881 {
882 gnutls_assert (); 882 MHD_gnutls_assert ();
883 return ret; 883 return ret;
884 } 884 }
885 885
@@ -888,38 +888,38 @@ begin:
888 */ 888 */
889 if ((ret = record_check_version (session, htype, version)) < 0) 889 if ((ret = record_check_version (session, htype, version)) < 0)
890 { 890 {
891 gnutls_assert (); 891 MHD_gnutls_assert ();
892 session_invalidate (session); 892 session_invalidate (session);
893 return ret; 893 return ret;
894 } 894 }
895 895
896 _gnutls_record_log 896 MHD__gnutls_record_log
897 ("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session, 897 ("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session,
898 (int) mhd_gtls_uint64touint32 (&session->connection_state. 898 (int) MHD_gtls_uint64touint32 (&session->connection_state.
899 read_sequence_number), 899 read_sequence_number),
900 _gnutls_packet2str (type), type, sizeofdata); 900 MHD__gnutls_packet2str (type), type, sizeofdata);
901 _gnutls_record_log ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", 901 MHD__gnutls_record_log ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n",
902 session, 902 session,
903 (int) 903 (int)
904 mhd_gtls_uint64touint32 (&session->connection_state. 904 MHD_gtls_uint64touint32 (&session->connection_state.
905 read_sequence_number), 905 read_sequence_number),
906 _gnutls_packet2str (recv_type), recv_type, length); 906 MHD__gnutls_packet2str (recv_type), recv_type, length);
907 907
908 if (length > MAX_RECV_SIZE) 908 if (length > MAX_RECV_SIZE)
909 { 909 {
910 _gnutls_record_log 910 MHD__gnutls_record_log
911 ("REC[%x]: FATAL ERROR: Received packet with length: %d\n", 911 ("REC[%x]: FATAL ERROR: Received packet with length: %d\n",
912 session, length); 912 session, length);
913 913
914 session_unresumable (session); 914 session_unresumable (session);
915 session_invalidate (session); 915 session_invalidate (session);
916 gnutls_assert (); 916 MHD_gnutls_assert ();
917 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 917 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
918 } 918 }
919 919
920 /* check if we have that data into buffer. 920 /* check if we have that data into buffer.
921 */ 921 */
922 if ((ret = mhd_gtls_io_read_buffered (session, &recv_data, 922 if ((ret = MHD_gtls_io_read_buffered (session, &recv_data,
923 header_size + length, recv_type)) 923 header_size + length, recv_type))
924 != header_size + length) 924 != header_size + length)
925 { 925 {
@@ -928,31 +928,31 @@ begin:
928 928
929 session_unresumable (session); 929 session_unresumable (session);
930 session_invalidate (session); 930 session_invalidate (session);
931 gnutls_assert (); 931 MHD_gnutls_assert ();
932 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 932 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
933 } 933 }
934 934
935 /* ok now we are sure that we can read all the data - so 935 /* ok now we are sure that we can read all the data - so
936 * move on ! 936 * move on !
937 */ 937 */
938 mhd_gtls_io_clear_read_buffer (session); 938 MHD_gtls_io_clear_read_buffer (session);
939 ciphertext = &recv_data[header_size]; 939 ciphertext = &recv_data[header_size];
940 940
941 ret = get_temp_recv_buffer (session, &tmp); 941 ret = get_temp_recv_buffer (session, &tmp);
942 if (ret < 0) 942 if (ret < 0)
943 { 943 {
944 gnutls_assert (); 944 MHD_gnutls_assert ();
945 return ret; 945 return ret;
946 } 946 }
947 947
948 /* decrypt the data we got. */ 948 /* decrypt the data we got. */
949 ret = mhd_gtls_decrypt (session, ciphertext, length, tmp.data, tmp.size, 949 ret = MHD_gtls_decrypt (session, ciphertext, length, tmp.data, tmp.size,
950 recv_type); 950 recv_type);
951 if (ret < 0) 951 if (ret < 0)
952 { 952 {
953 session_unresumable (session); 953 session_unresumable (session);
954 session_invalidate (session); 954 session_invalidate (session);
955 gnutls_assert (); 955 MHD_gnutls_assert ();
956 return ret; 956 return ret;
957 } 957 }
958 decrypted_length = ret; 958 decrypted_length = ret;
@@ -963,12 +963,12 @@ begin:
963 == GNUTLS_CHANGE_CIPHER_SPEC) 963 == GNUTLS_CHANGE_CIPHER_SPEC)
964 { 964 {
965 965
966 _gnutls_record_log 966 MHD__gnutls_record_log
967 ("REC[%x]: ChangeCipherSpec Packet was received\n", session); 967 ("REC[%x]: ChangeCipherSpec Packet was received\n", session);
968 968
969 if ((size_t) ret != sizeofdata) 969 if ((size_t) ret != sizeofdata)
970 { /* sizeofdata should be 1 */ 970 { /* sizeofdata should be 1 */
971 gnutls_assert (); 971 MHD_gnutls_assert ();
972 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; 972 return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
973 } 973 }
974 memcpy (data, tmp.data, sizeofdata); 974 memcpy (data, tmp.data, sizeofdata);
@@ -976,19 +976,19 @@ begin:
976 return ret; 976 return ret;
977 } 977 }
978 978
979 _gnutls_record_log 979 MHD__gnutls_record_log
980 ("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session, 980 ("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session,
981 (int) mhd_gtls_uint64touint32 (&session->connection_state. 981 (int) MHD_gtls_uint64touint32 (&session->connection_state.
982 read_sequence_number), 982 read_sequence_number),
983 _gnutls_packet2str (recv_type), recv_type, decrypted_length); 983 MHD__gnutls_packet2str (recv_type), recv_type, decrypted_length);
984 984
985 /* increase sequence number 985 /* increase sequence number
986 */ 986 */
987 if (mhd_gtls_uint64pp (&session->connection_state.read_sequence_number) != 987 if (MHD_gtls_uint64pp (&session->connection_state.read_sequence_number) !=
988 0) 988 0)
989 { 989 {
990 session_invalidate (session); 990 session_invalidate (session);
991 gnutls_assert (); 991 MHD_gnutls_assert ();
992 return GNUTLS_E_RECORD_LIMIT_REACHED; 992 return GNUTLS_E_RECORD_LIMIT_REACHED;
993 } 993 }
994 994
@@ -999,7 +999,7 @@ begin:
999 { 999 {
1000 if (ret == GNUTLS_E_INT_RET_0) 1000 if (ret == GNUTLS_E_INT_RET_0)
1001 return 0; 1001 return 0;
1002 gnutls_assert (); 1002 MHD_gnutls_assert ();
1003 return ret; 1003 return ret;
1004 } 1004 }
1005 1005
@@ -1010,27 +1010,27 @@ begin:
1010 || type == GNUTLS_INNER_APPLICATION)) 1010 || type == GNUTLS_INNER_APPLICATION))
1011 { 1011 {
1012 1012
1013 ret = mhd_gtls_record_buffer_get (type, session, data, sizeofdata); 1013 ret = MHD_gtls_record_buffer_get (type, session, data, sizeofdata);
1014 if (ret < 0) 1014 if (ret < 0)
1015 { 1015 {
1016 gnutls_assert (); 1016 MHD_gnutls_assert ();
1017 return ret; 1017 return ret;
1018 } 1018 }
1019 1019
1020 /* if the buffer just got empty 1020 /* if the buffer just got empty
1021 */ 1021 */
1022 if (mhd_gnutls_record_buffer_get_size (type, session) == 0) 1022 if (MHD_gnutls_record_buffer_get_size (type, session) == 0)
1023 { 1023 {
1024 if ((ret2 = mhd_gtls_io_clear_peeked_data (session)) < 0) 1024 if ((ret2 = MHD_gtls_io_clear_peeked_data (session)) < 0)
1025 { 1025 {
1026 gnutls_assert (); 1026 MHD_gnutls_assert ();
1027 return ret2; 1027 return ret2;
1028 } 1028 }
1029 } 1029 }
1030 } 1030 }
1031 else 1031 else
1032 { 1032 {
1033 gnutls_assert (); 1033 MHD_gnutls_assert ();
1034 return GNUTLS_E_UNEXPECTED_PACKET; 1034 return GNUTLS_E_UNEXPECTED_PACKET;
1035 /* we didn't get what we wanted to 1035 /* we didn't get what we wanted to
1036 */ 1036 */
@@ -1053,8 +1053,8 @@ begin:
1053} 1053}
1054 1054
1055/** 1055/**
1056 * MHD_gnutls_record_send - sends to the peer the specified data 1056 * MHD__gnutls_record_send - sends to the peer the specified data
1057 * @session: is a #mhd_gtls_session_t structure. 1057 * @session: is a #MHD_gtls_session_t structure.
1058 * @data: contains the data to send 1058 * @data: contains the data to send
1059 * @sizeofdata: is the length of the data 1059 * @sizeofdata: is the length of the data
1060 * 1060 *
@@ -1065,7 +1065,7 @@ begin:
1065 * Note that if the send buffer is full, send() will block this 1065 * Note that if the send buffer is full, send() will block this
1066 * function. See the send() documentation for full information. You 1066 * function. See the send() documentation for full information. You
1067 * can replace the default push function by using 1067 * can replace the default push function by using
1068 * MHD_gnutls_transport_set_ptr2() with a call to send() with a 1068 * MHD__gnutls_transport_set_ptr2() with a call to send() with a
1069 * MSG_DONTWAIT flag if blocking is a problem. 1069 * MSG_DONTWAIT flag if blocking is a problem.
1070 * 1070 *
1071 * If the EINTR is returned by the internal push function (the 1071 * If the EINTR is returned by the internal push function (the
@@ -1073,7 +1073,7 @@ begin:
1073 * %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must 1073 * %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must
1074 * call this function again, with the same parameters; alternatively 1074 * call this function again, with the same parameters; alternatively
1075 * you could provide a %NULL pointer for data, and 0 for 1075 * you could provide a %NULL pointer for data, and 0 for
1076 * size. cf. MHD_gnutls_record_get_direction(). 1076 * size. cf. MHD__gnutls_record_get_direction().
1077 * 1077 *
1078 * Returns: the number of bytes sent, or a negative error code. The 1078 * Returns: the number of bytes sent, or a negative error code. The
1079 * number of bytes sent might be less than @sizeofdata. The maximum 1079 * number of bytes sent might be less than @sizeofdata. The maximum
@@ -1081,16 +1081,16 @@ begin:
1081 * the negotiated maximum record size. 1081 * the negotiated maximum record size.
1082 **/ 1082 **/
1083ssize_t 1083ssize_t
1084MHD_gnutls_record_send (mhd_gtls_session_t session, 1084MHD__gnutls_record_send (MHD_gtls_session_t session,
1085 const void *data, size_t sizeofdata) 1085 const void *data, size_t sizeofdata)
1086{ 1086{
1087 return mhd_gtls_send_int (session, GNUTLS_APPLICATION_DATA, -1, data, 1087 return MHD_gtls_send_int (session, GNUTLS_APPLICATION_DATA, -1, data,
1088 sizeofdata); 1088 sizeofdata);
1089} 1089}
1090 1090
1091/** 1091/**
1092 * MHD_gnutls_record_recv - reads data from the TLS record protocol 1092 * MHD__gnutls_record_recv - reads data from the TLS record protocol
1093 * @session: is a #mhd_gtls_session_t structure. 1093 * @session: is a #MHD_gtls_session_t structure.
1094 * @data: the buffer that the data will be read into 1094 * @data: the buffer that the data will be read into
1095 * @sizeofdata: the number of requested bytes 1095 * @sizeofdata: the number of requested bytes
1096 * 1096 *
@@ -1108,7 +1108,7 @@ MHD_gnutls_record_send (mhd_gtls_session_t session,
1108 * is recv()) then %GNUTLS_E_INTERRUPTED will be returned. If 1108 * is recv()) then %GNUTLS_E_INTERRUPTED will be returned. If
1109 * %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must 1109 * %GNUTLS_E_INTERRUPTED or %GNUTLS_E_AGAIN is returned, you must
1110 * call this function again to get the data. See also 1110 * call this function again to get the data. See also
1111 * MHD_gnutls_record_get_direction(). 1111 * MHD__gnutls_record_get_direction().
1112 * 1112 *
1113 * A server may also receive %GNUTLS_E_REHANDSHAKE when a client has 1113 * A server may also receive %GNUTLS_E_REHANDSHAKE when a client has
1114 * initiated a handshake. In that case the server can only initiate a 1114 * initiated a handshake. In that case the server can only initiate a
@@ -1119,23 +1119,23 @@ MHD_gnutls_record_send (mhd_gtls_session_t session,
1119 * received might be less than @sizeofdata. 1119 * received might be less than @sizeofdata.
1120 **/ 1120 **/
1121ssize_t 1121ssize_t
1122MHD_gnutls_record_recv (mhd_gtls_session_t session, void *data, 1122MHD__gnutls_record_recv (MHD_gtls_session_t session, void *data,
1123 size_t sizeofdata) 1123 size_t sizeofdata)
1124{ 1124{
1125 return mhd_gtls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data, 1125 return MHD_gtls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data,
1126 sizeofdata); 1126 sizeofdata);
1127} 1127}
1128 1128
1129/** 1129/**
1130 * MHD_gnutls_record_get_max_size - returns the maximum record size 1130 * MHD__gnutls_record_get_max_size - returns the maximum record size
1131 * @session: is a #mhd_gtls_session_t structure. 1131 * @session: is a #MHD_gtls_session_t structure.
1132 * 1132 *
1133 * This function returns the maximum record packet size in this 1133 * This function returns the maximum record packet size in this
1134 * connection. The maximum record size is negotiated by the client 1134 * connection. The maximum record size is negotiated by the client
1135 * after the first handshake message. 1135 * after the first handshake message.
1136 **/ 1136 **/
1137size_t 1137size_t
1138MHD_gnutls_record_get_max_size (mhd_gtls_session_t session) 1138MHD__gnutls_record_get_max_size (MHD_gtls_session_t session)
1139{ 1139{
1140 /* Recv will hold the negotiated max record size 1140 /* Recv will hold the negotiated max record size
1141 * always. 1141 * always.
@@ -1144,8 +1144,8 @@ MHD_gnutls_record_get_max_size (mhd_gtls_session_t session)
1144} 1144}
1145 1145
1146/** 1146/**
1147 * MHD_gnutls_record_set_max_size - sets the maximum record size 1147 * MHD__gnutls_record_set_max_size - sets the maximum record size
1148 * @session: is a #mhd_gtls_session_t structure. 1148 * @session: is a #MHD_gtls_session_t structure.
1149 * @size: is the new size 1149 * @size: is the new size
1150 * 1150 *
1151 * This function sets the maximum record packet size in this 1151 * This function sets the maximum record packet size in this
@@ -1161,18 +1161,18 @@ MHD_gnutls_record_get_max_size (mhd_gtls_session_t session)
1161 * all TLS implementations use or even understand this extension. 1161 * all TLS implementations use or even understand this extension.
1162 **/ 1162 **/
1163ssize_t 1163ssize_t
1164MHD_gnutls_record_set_max_size (mhd_gtls_session_t session, size_t size) 1164MHD__gnutls_record_set_max_size (MHD_gtls_session_t session, size_t size)
1165{ 1165{
1166 ssize_t new_size; 1166 ssize_t new_size;
1167 1167
1168 if (session->security_parameters.entity == GNUTLS_SERVER) 1168 if (session->security_parameters.entity == GNUTLS_SERVER)
1169 return GNUTLS_E_INVALID_REQUEST; 1169 return GNUTLS_E_INVALID_REQUEST;
1170 1170
1171 new_size = mhd_gtls_mre_record2num (size); 1171 new_size = MHD_gtls_mre_record2num (size);
1172 1172
1173 if (new_size < 0) 1173 if (new_size < 0)
1174 { 1174 {
1175 gnutls_assert (); 1175 MHD_gnutls_assert ();
1176 return new_size; 1176 return new_size;
1177 } 1177 }
1178 1178
diff --git a/src/daemon/https/tls/gnutls_record.h b/src/daemon/https/tls/gnutls_record.h
index e1fea3f2..fe7300b6 100644
--- a/src/daemon/https/tls/gnutls_record.h
+++ b/src/daemon/https/tls/gnutls_record.h
@@ -22,12 +22,12 @@
22 * 22 *
23 */ 23 */
24 24
25ssize_t mhd_gtls_send_int (mhd_gtls_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 MHD_gnutls_handshake_description_t htype,
27 const void *data, size_t sizeofdata); 27 const void *data, size_t sizeofdata);
28ssize_t mhd_gtls_recv_int (mhd_gtls_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 MHD_gnutls_handshake_description_t, opaque * data,
30 size_t sizeofdata); 30 size_t sizeofdata);
31ssize_t mhd_gtls_send_change_cipher_spec (mhd_gtls_session_t session, 31ssize_t MHD_gtls_send_change_cipher_spec (MHD_gtls_session_t session,
32 int again); 32 int again);
33void MHD_gnutls_transport_set_lowat (mhd_gtls_session_t session, int num); 33void 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 ce06e47e..64834a98 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 (mhd_gtls_rsa_params_t rsa_params) 49MHD__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 {
@@ -61,7 +61,7 @@ _gnutls_rsa_params_to_mpi (mhd_gtls_rsa_params_t rsa_params)
61 * prime1 - p (3), prime2 - q(4), u (5). 61 * prime1 - p (3), prime2 - q(4), u (5).
62 */ 62 */
63int 63int
64_gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits) 64MHD__gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
65{ 65{
66 66
67 int ret; 67 int ret;
@@ -70,7 +70,7 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
70 ret = gcry_sexp_build (&parms, NULL, "(genkey(rsa(nbits %d)))", bits); 70 ret = gcry_sexp_build (&parms, NULL, "(genkey(rsa(nbits %d)))", bits);
71 if (ret != 0) 71 if (ret != 0)
72 { 72 {
73 gnutls_assert (); 73 MHD_gnutls_assert ();
74 return GNUTLS_E_INTERNAL_ERROR; 74 return GNUTLS_E_INTERNAL_ERROR;
75 } 75 }
76 76
@@ -80,14 +80,14 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
80 80
81 if (ret != 0) 81 if (ret != 0)
82 { 82 {
83 gnutls_assert (); 83 MHD_gnutls_assert ();
84 return GNUTLS_E_INTERNAL_ERROR; 84 return GNUTLS_E_INTERNAL_ERROR;
85 } 85 }
86 86
87 list = gcry_sexp_find_token (key, "n", 0); 87 list = gcry_sexp_find_token (key, "n", 0);
88 if (list == NULL) 88 if (list == NULL)
89 { 89 {
90 gnutls_assert (); 90 MHD_gnutls_assert ();
91 gcry_sexp_release (key); 91 gcry_sexp_release (key);
92 return GNUTLS_E_INTERNAL_ERROR; 92 return GNUTLS_E_INTERNAL_ERROR;
93 } 93 }
@@ -98,7 +98,7 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
98 list = gcry_sexp_find_token (key, "e", 0); 98 list = gcry_sexp_find_token (key, "e", 0);
99 if (list == NULL) 99 if (list == NULL)
100 { 100 {
101 gnutls_assert (); 101 MHD_gnutls_assert ();
102 gcry_sexp_release (key); 102 gcry_sexp_release (key);
103 return GNUTLS_E_INTERNAL_ERROR; 103 return GNUTLS_E_INTERNAL_ERROR;
104 } 104 }
@@ -109,7 +109,7 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
109 list = gcry_sexp_find_token (key, "d", 0); 109 list = gcry_sexp_find_token (key, "d", 0);
110 if (list == NULL) 110 if (list == NULL)
111 { 111 {
112 gnutls_assert (); 112 MHD_gnutls_assert ();
113 gcry_sexp_release (key); 113 gcry_sexp_release (key);
114 return GNUTLS_E_INTERNAL_ERROR; 114 return GNUTLS_E_INTERNAL_ERROR;
115 } 115 }
@@ -120,7 +120,7 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
120 list = gcry_sexp_find_token (key, "p", 0); 120 list = gcry_sexp_find_token (key, "p", 0);
121 if (list == NULL) 121 if (list == NULL)
122 { 122 {
123 gnutls_assert (); 123 MHD_gnutls_assert ();
124 gcry_sexp_release (key); 124 gcry_sexp_release (key);
125 return GNUTLS_E_INTERNAL_ERROR; 125 return GNUTLS_E_INTERNAL_ERROR;
126 } 126 }
@@ -132,7 +132,7 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
132 list = gcry_sexp_find_token (key, "q", 0); 132 list = gcry_sexp_find_token (key, "q", 0);
133 if (list == NULL) 133 if (list == NULL)
134 { 134 {
135 gnutls_assert (); 135 MHD_gnutls_assert ();
136 gcry_sexp_release (key); 136 gcry_sexp_release (key);
137 return GNUTLS_E_INTERNAL_ERROR; 137 return GNUTLS_E_INTERNAL_ERROR;
138 } 138 }
@@ -144,7 +144,7 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
144 list = gcry_sexp_find_token (key, "u", 0); 144 list = gcry_sexp_find_token (key, "u", 0);
145 if (list == NULL) 145 if (list == NULL)
146 { 146 {
147 gnutls_assert (); 147 MHD_gnutls_assert ();
148 gcry_sexp_release (key); 148 gcry_sexp_release (key);
149 return GNUTLS_E_INTERNAL_ERROR; 149 return GNUTLS_E_INTERNAL_ERROR;
150 } 150 }
@@ -154,12 +154,12 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
154 154
155 gcry_sexp_release (key); 155 gcry_sexp_release (key);
156 156
157 _gnutls_dump_mpi ("n: ", resarr[0]); 157 MHD__gnutls_dump_mpi ("n: ", resarr[0]);
158 _gnutls_dump_mpi ("e: ", resarr[1]); 158 MHD__gnutls_dump_mpi ("e: ", resarr[1]);
159 _gnutls_dump_mpi ("d: ", resarr[2]); 159 MHD__gnutls_dump_mpi ("d: ", resarr[2]);
160 _gnutls_dump_mpi ("p: ", resarr[3]); 160 MHD__gnutls_dump_mpi ("p: ", resarr[3]);
161 _gnutls_dump_mpi ("q: ", resarr[4]); 161 MHD__gnutls_dump_mpi ("q: ", resarr[4]);
162 _gnutls_dump_mpi ("u: ", resarr[5]); 162 MHD__gnutls_dump_mpi ("u: ", resarr[5]);
163 163
164 *resarr_len = 6; 164 *resarr_len = 6;
165 165
@@ -168,21 +168,21 @@ _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
168} 168}
169 169
170/** 170/**
171 * MHD_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
172 * @rsa_params: Is a structure that will hold the parameters 172 * @rsa_params: Is a structure that will hold the parameters
173 * 173 *
174 * This function will initialize the temporary RSA parameters structure. 174 * This function will initialize the temporary RSA parameters structure.
175 * 175 *
176 **/ 176 **/
177int 177int
178MHD_gnutls_rsa_params_init (mhd_gtls_rsa_params_t * rsa_params) 178MHD__gnutls_rsa_params_init (MHD_gtls_rsa_params_t * rsa_params)
179{ 179{
180 int ret; 180 int ret;
181 181
182 ret = gnutls_x509_privkey_init (rsa_params); 182 ret = MHD_gnutls_x509_privkey_init (rsa_params);
183 if (ret < 0) 183 if (ret < 0)
184 { 184 {
185 gnutls_assert (); 185 MHD_gnutls_assert ();
186 return ret; 186 return ret;
187 } 187 }
188 188
@@ -192,20 +192,20 @@ MHD_gnutls_rsa_params_init (mhd_gtls_rsa_params_t * rsa_params)
192} 192}
193 193
194/** 194/**
195 * MHD_gnutls_rsa_params_deinit - This function will deinitialize the RSA parameters 195 * MHD__gnutls_rsa_params_deinit - This function will deinitialize the RSA parameters
196 * @rsa_params: Is a structure that holds the parameters 196 * @rsa_params: Is a structure that holds the parameters
197 * 197 *
198 * This function will deinitialize the RSA parameters structure. 198 * This function will deinitialize the RSA parameters structure.
199 * 199 *
200 **/ 200 **/
201void 201void
202MHD_gnutls_rsa_params_deinit (mhd_gtls_rsa_params_t rsa_params) 202MHD__gnutls_rsa_params_deinit (MHD_gtls_rsa_params_t rsa_params)
203{ 203{
204 gnutls_x509_privkey_deinit (rsa_params); 204 MHD_gnutls_x509_privkey_deinit (rsa_params);
205} 205}
206 206
207/** 207/**
208 * MHD_gnutls_rsa_params_generate2 - This function will generate temporary RSA parameters 208 * MHD__gnutls_rsa_params_generate2 - This function will generate temporary RSA parameters
209 * @params: The structure where the parameters will be stored 209 * @params: The structure where the parameters will be stored
210 * @bits: is the prime's number of bits 210 * @bits: is the prime's number of bits
211 * 211 *
@@ -220,8 +220,8 @@ MHD_gnutls_rsa_params_deinit (mhd_gtls_rsa_params_t rsa_params)
220 * 220 *
221 **/ 221 **/
222int 222int
223MHD_gnutls_rsa_params_generate2 (mhd_gtls_rsa_params_t params, 223MHD__gnutls_rsa_params_generate2 (MHD_gtls_rsa_params_t params,
224 unsigned int bits) 224 unsigned int bits)
225{ 225{
226 return gnutls_x509_privkey_generate (params, MHD_GNUTLS_PK_RSA, bits, 0); 226 return MHD_gnutls_x509_privkey_generate (params, MHD_GNUTLS_PK_RSA, bits, 0);
227} 227}
diff --git a/src/daemon/https/tls/gnutls_rsa_export.h b/src/daemon/https/tls/gnutls_rsa_export.h
index 8e21ed59..61cfdd97 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 (mhd_gtls_rsa_params_t); 25const mpi_t *MHD__gnutls_rsa_params_to_mpi (MHD_gtls_rsa_params_t);
26int _gnutls_peers_cert_less_512 (mhd_gtls_session_t session); 26int MHD__gnutls_peers_cert_less_512 (MHD_gtls_session_t session);
27int _gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits); 27int MHD__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 95758817..81a56d5c 100644
--- a/src/daemon/https/tls/gnutls_session.c
+++ b/src/daemon/https/tls/gnutls_session.c
@@ -31,7 +31,7 @@
31 31
32/** 32/**
33 * MHD_gtls_session_get_id - Returns session id. 33 * MHD_gtls_session_get_id - Returns session id.
34 * @session: is a #mhd_gtls_session_t structure. 34 * @session: is a #MHD_gtls_session_t structure.
35 * @session_id: is a pointer to space to hold the session id. 35 * @session_id: is a pointer to space to hold the session id.
36 * @session_id_size: is the session id's size, or it will be set by the function. 36 * @session_id_size: is the session id's size, or it will be set by the function.
37 * 37 *
@@ -46,7 +46,7 @@
46 * Returns zero on success. 46 * Returns zero on success.
47 **/ 47 **/
48int 48int
49MHD_gtls_session_get_id (mhd_gtls_session_t session, 49MHD_gtls_session_get_id (MHD_gtls_session_t session,
50 void *session_id, size_t * session_id_size) 50 void *session_id, size_t * session_id_size)
51{ 51{
52 size_t given_session_id_size = *session_id_size; 52 size_t given_session_id_size = *session_id_size;
diff --git a/src/daemon/https/tls/gnutls_session_pack.c b/src/daemon/https/tls/gnutls_session_pack.c
index 85bebc8c..258cd9c2 100644
--- a/src/daemon/https/tls/gnutls_session_pack.c
+++ b/src/daemon/https/tls/gnutls_session_pack.c
@@ -43,16 +43,16 @@
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 (mhd_gtls_session_t, 46static int pack_certificate_auth_info (MHD_gtls_session_t,
47 gnutls_datum_t * packed_session); 47 MHD_gnutls_datum_t * packed_session);
48static int unpack_certificate_auth_info (mhd_gtls_session_t, 48static int unpack_certificate_auth_info (MHD_gtls_session_t,
49 const gnutls_datum_t * 49 const MHD_gnutls_datum_t *
50 packed_session); 50 packed_session);
51 51
52static int unpack_security_parameters (mhd_gtls_session_t session, 52static int unpack_security_parameters (MHD_gtls_session_t session,
53 const gnutls_datum_t * packed_session); 53 const MHD_gnutls_datum_t * packed_session);
54static int pack_security_parameters (mhd_gtls_session_t session, 54static int pack_security_parameters (MHD_gtls_session_t session,
55 gnutls_datum_t * packed_session); 55 MHD_gnutls_datum_t * packed_session);
56 56
57/* Packs the ANON session authentication data. */ 57/* Packs the ANON session authentication data. */
58#ifdef ENABLE_ANON 58#ifdef ENABLE_ANON
@@ -69,10 +69,10 @@ static int pack_security_parameters (mhd_gtls_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 (mhd_gtls_session_t session, 72pack_anon_auth_info (MHD_gtls_session_t session,
73 gnutls_datum_t * packed_session) 73 MHD_gnutls_datum_t * packed_session)
74{ 74{
75 mhd_anon_auth_info_t info = mhd_gtls_get_auth_info (session); 75 mhd_anon_auth_info_t info = MHD_gtls_get_auth_info (session);
76 int pos = 0; 76 int pos = 0;
77 size_t pack_size; 77 size_t pack_size;
78 78
@@ -87,29 +87,29 @@ pack_anon_auth_info (mhd_gtls_session_t session,
87 /* calculate the size and allocate the data. 87 /* calculate the size and allocate the data.
88 */ 88 */
89 packed_session->data = 89 packed_session->data =
90 gnutls_malloc (packed_session->size + MAX_SEC_PARAMS); 90 MHD_gnutls_malloc (packed_session->size + MAX_SEC_PARAMS);
91 91
92 if (packed_session->data == NULL) 92 if (packed_session->data == NULL)
93 { 93 {
94 gnutls_assert (); 94 MHD_gnutls_assert ();
95 return GNUTLS_E_MEMORY_ERROR; 95 return GNUTLS_E_MEMORY_ERROR;
96 } 96 }
97 97
98 packed_session->data[0] = MHD_GNUTLS_CRD_ANON; 98 packed_session->data[0] = MHD_GNUTLS_CRD_ANON;
99 mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]); 99 MHD_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
100 pos += 4 + PACK_HEADER_SIZE; 100 pos += 4 + PACK_HEADER_SIZE;
101 101
102 if (pack_size > 0) 102 if (pack_size > 0)
103 { 103 {
104 mhd_gtls_write_uint16 (info->dh.secret_bits, 104 MHD_gtls_write_uint16 (info->dh.secret_bits,
105 &packed_session->data[pos]); 105 &packed_session->data[pos]);
106 pos += 2; 106 pos += 2;
107 107
108 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime); 108 MHD_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
109 pos += 4 + info->dh.prime.size; 109 pos += 4 + info->dh.prime.size;
110 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator); 110 MHD_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
111 pos += 4 + info->dh.generator.size; 111 pos += 4 + info->dh.generator.size;
112 mhd_gtls_write_datum32 (&packed_session->data[pos], 112 MHD_gtls_write_datum32 (&packed_session->data[pos],
113 info->dh.public_key); 113 info->dh.public_key);
114 pos += 4 + info->dh.public_key.size; 114 pos += 4 + info->dh.public_key.size;
115 115
@@ -130,8 +130,8 @@ pack_anon_auth_info (mhd_gtls_session_t session,
130 * x bytes the public key 130 * x bytes the public key
131 */ 131 */
132static int 132static int
133unpack_anon_auth_info (mhd_gtls_session_t session, 133unpack_anon_auth_info (MHD_gtls_session_t session,
134 const gnutls_datum_t * packed_session) 134 const MHD_gnutls_datum_t * packed_session)
135{ 135{
136 size_t pack_size; 136 size_t pack_size;
137 int pos = 0, size, ret; 137 int pos = 0, size, ret;
@@ -139,11 +139,11 @@ unpack_anon_auth_info (mhd_gtls_session_t session,
139 139
140 if (packed_session->data[0] != MHD_GNUTLS_CRD_ANON) 140 if (packed_session->data[0] != MHD_GNUTLS_CRD_ANON)
141 { 141 {
142 gnutls_assert (); 142 MHD_gnutls_assert ();
143 return GNUTLS_E_INVALID_REQUEST; 143 return GNUTLS_E_INVALID_REQUEST;
144 } 144 }
145 145
146 pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]); 146 pack_size = MHD_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
147 pos += PACK_HEADER_SIZE + 4; 147 pos += PACK_HEADER_SIZE + 4;
148 148
149 149
@@ -153,60 +153,60 @@ unpack_anon_auth_info (mhd_gtls_session_t session,
153 /* a simple check for integrity */ 153 /* a simple check for integrity */
154 if (pack_size + PACK_HEADER_SIZE + 4 > packed_session->size) 154 if (pack_size + PACK_HEADER_SIZE + 4 > packed_session->size)
155 { 155 {
156 gnutls_assert (); 156 MHD_gnutls_assert ();
157 return GNUTLS_E_INVALID_REQUEST; 157 return GNUTLS_E_INVALID_REQUEST;
158 } 158 }
159 159
160 /* client and serer have the same auth_info here 160 /* client and serer have the same auth_info here
161 */ 161 */
162 ret = 162 ret =
163 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON, 163 MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
164 sizeof (anon_auth_info_st), 1); 164 sizeof (anon_auth_info_st), 1);
165 if (ret < 0) 165 if (ret < 0)
166 { 166 {
167 gnutls_assert (); 167 MHD_gnutls_assert ();
168 return ret; 168 return ret;
169 } 169 }
170 170
171 info = mhd_gtls_get_auth_info (session); 171 info = MHD_gtls_get_auth_info (session);
172 if (info == NULL) 172 if (info == NULL)
173 { 173 {
174 gnutls_assert (); 174 MHD_gnutls_assert ();
175 return GNUTLS_E_INTERNAL_ERROR; 175 return GNUTLS_E_INTERNAL_ERROR;
176 } 176 }
177 177
178 info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]); 178 info->dh.secret_bits = MHD_gtls_read_uint16 (&packed_session->data[pos]);
179 pos += 2; 179 pos += 2;
180 180
181 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 181 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
182 pos += 4; 182 pos += 4;
183 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); 183 ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
184 if (ret < 0) 184 if (ret < 0)
185 { 185 {
186 gnutls_assert (); 186 MHD_gnutls_assert ();
187 goto error; 187 goto error;
188 } 188 }
189 pos += size; 189 pos += size;
190 190
191 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 191 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
192 pos += 4; 192 pos += 4;
193 ret = 193 ret =
194 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); 194 MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
195 if (ret < 0) 195 if (ret < 0)
196 { 196 {
197 gnutls_assert (); 197 MHD_gnutls_assert ();
198 goto error; 198 goto error;
199 } 199 }
200 pos += size; 200 pos += size;
201 201
202 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 202 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
203 pos += 4; 203 pos += 4;
204 ret = 204 ret =
205 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], 205 MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
206 size); 206 size);
207 if (ret < 0) 207 if (ret < 0)
208 { 208 {
209 gnutls_assert (); 209 MHD_gnutls_assert ();
210 goto error; 210 goto error;
211 } 211 }
212 pos += size; 212 pos += size;
@@ -214,9 +214,9 @@ unpack_anon_auth_info (mhd_gtls_session_t session,
214 return 0; 214 return 0;
215 215
216error: 216error:
217 _gnutls_free_datum (&info->dh.prime); 217 MHD__gnutls_free_datum (&info->dh.prime);
218 _gnutls_free_datum (&info->dh.generator); 218 MHD__gnutls_free_datum (&info->dh.generator);
219 _gnutls_free_datum (&info->dh.public_key); 219 MHD__gnutls_free_datum (&info->dh.public_key);
220 return ret; 220 return ret;
221} 221}
222#endif /* ANON */ 222#endif /* ANON */
@@ -230,14 +230,14 @@ error:
230 * The data will be in a platform independent format. 230 * The data will be in a platform independent format.
231 */ 231 */
232int 232int
233mhd_gtls_session_pack (mhd_gtls_session_t session, 233MHD_gtls_session_pack (MHD_gtls_session_t session,
234 gnutls_datum_t * packed_session) 234 MHD_gnutls_datum_t * packed_session)
235{ 235{
236 int ret; 236 int ret;
237 237
238 if (packed_session == NULL) 238 if (packed_session == NULL)
239 { 239 {
240 gnutls_assert (); 240 MHD_gnutls_assert ();
241 return GNUTLS_E_INTERNAL_ERROR; 241 return GNUTLS_E_INTERNAL_ERROR;
242 } 242 }
243 243
@@ -249,7 +249,7 @@ mhd_gtls_session_pack (mhd_gtls_session_t session,
249 ret = pack_srp_auth_info (session, packed_session); 249 ret = pack_srp_auth_info (session, packed_session);
250 if (ret < 0) 250 if (ret < 0)
251 { 251 {
252 gnutls_assert (); 252 MHD_gnutls_assert ();
253 return ret; 253 return ret;
254 } 254 }
255 break; 255 break;
@@ -259,7 +259,7 @@ mhd_gtls_session_pack (mhd_gtls_session_t session,
259 ret = pack_psk_auth_info (session, packed_session); 259 ret = pack_psk_auth_info (session, packed_session);
260 if (ret < 0) 260 if (ret < 0)
261 { 261 {
262 gnutls_assert (); 262 MHD_gnutls_assert ();
263 return ret; 263 return ret;
264 } 264 }
265 break; 265 break;
@@ -269,7 +269,7 @@ mhd_gtls_session_pack (mhd_gtls_session_t session,
269 ret = pack_anon_auth_info (session, packed_session); 269 ret = pack_anon_auth_info (session, packed_session);
270 if (ret < 0) 270 if (ret < 0)
271 { 271 {
272 gnutls_assert (); 272 MHD_gnutls_assert ();
273 return ret; 273 return ret;
274 } 274 }
275 break; 275 break;
@@ -278,7 +278,7 @@ mhd_gtls_session_pack (mhd_gtls_session_t session,
278 ret = pack_certificate_auth_info (session, packed_session); 278 ret = pack_certificate_auth_info (session, packed_session);
279 if (ret < 0) 279 if (ret < 0)
280 { 280 {
281 gnutls_assert (); 281 MHD_gnutls_assert ();
282 return ret; 282 return ret;
283 } 283 }
284 break; 284 break;
@@ -287,14 +287,14 @@ mhd_gtls_session_pack (mhd_gtls_session_t session,
287 287
288 } 288 }
289 289
290 /* Auth_info structures copied. Now copy mhd_gtls_security_param_st. 290 /* Auth_info structures copied. Now copy MHD_gtls_security_param_st.
291 * packed_session must have allocated space for the security parameters. 291 * packed_session must have allocated space for the security parameters.
292 */ 292 */
293 ret = pack_security_parameters (session, packed_session); 293 ret = pack_security_parameters (session, packed_session);
294 if (ret < 0) 294 if (ret < 0)
295 { 295 {
296 gnutls_assert (); 296 MHD_gnutls_assert ();
297 _gnutls_free_datum (packed_session); 297 MHD__gnutls_free_datum (packed_session);
298 return ret; 298 return ret;
299 } 299 }
300 300
@@ -305,20 +305,20 @@ mhd_gtls_session_pack (mhd_gtls_session_t session,
305/* Load session data from a buffer. 305/* Load session data from a buffer.
306 */ 306 */
307int 307int
308mhd_gtls_session_unpack (mhd_gtls_session_t session, 308MHD_gtls_session_unpack (MHD_gtls_session_t session,
309 const gnutls_datum_t * packed_session) 309 const MHD_gnutls_datum_t * packed_session)
310{ 310{
311 int ret; 311 int ret;
312 312
313 if (packed_session == NULL || packed_session->size == 0) 313 if (packed_session == NULL || packed_session->size == 0)
314 { 314 {
315 gnutls_assert (); 315 MHD_gnutls_assert ();
316 return GNUTLS_E_INTERNAL_ERROR; 316 return GNUTLS_E_INTERNAL_ERROR;
317 } 317 }
318 318
319 if (mhd_gtls_get_auth_info (session) != NULL) 319 if (MHD_gtls_get_auth_info (session) != NULL)
320 { 320 {
321 mhd_gtls_free_auth_info (session); 321 MHD_gtls_free_auth_info (session);
322 } 322 }
323 323
324 switch (packed_session->data[0]) 324 switch (packed_session->data[0])
@@ -328,7 +328,7 @@ mhd_gtls_session_unpack (mhd_gtls_session_t session,
328 ret = unpack_srp_auth_info (session, packed_session); 328 ret = unpack_srp_auth_info (session, packed_session);
329 if (ret < 0) 329 if (ret < 0)
330 { 330 {
331 gnutls_assert (); 331 MHD_gnutls_assert ();
332 return ret; 332 return ret;
333 } 333 }
334 break; 334 break;
@@ -338,7 +338,7 @@ mhd_gtls_session_unpack (mhd_gtls_session_t session,
338 ret = unpack_psk_auth_info (session, packed_session); 338 ret = unpack_psk_auth_info (session, packed_session);
339 if (ret < 0) 339 if (ret < 0)
340 { 340 {
341 gnutls_assert (); 341 MHD_gnutls_assert ();
342 return ret; 342 return ret;
343 } 343 }
344 break; 344 break;
@@ -348,7 +348,7 @@ mhd_gtls_session_unpack (mhd_gtls_session_t session,
348 ret = unpack_anon_auth_info (session, packed_session); 348 ret = unpack_anon_auth_info (session, packed_session);
349 if (ret < 0) 349 if (ret < 0)
350 { 350 {
351 gnutls_assert (); 351 MHD_gnutls_assert ();
352 return ret; 352 return ret;
353 } 353 }
354 break; 354 break;
@@ -357,23 +357,23 @@ mhd_gtls_session_unpack (mhd_gtls_session_t session,
357 ret = unpack_certificate_auth_info (session, packed_session); 357 ret = unpack_certificate_auth_info (session, packed_session);
358 if (ret < 0) 358 if (ret < 0)
359 { 359 {
360 gnutls_assert (); 360 MHD_gnutls_assert ();
361 return ret; 361 return ret;
362 } 362 }
363 break; 363 break;
364 default: 364 default:
365 gnutls_assert (); 365 MHD_gnutls_assert ();
366 return GNUTLS_E_INTERNAL_ERROR; 366 return GNUTLS_E_INTERNAL_ERROR;
367 367
368 } 368 }
369 369
370 /* Auth_info structures copied. Now copy mhd_gtls_security_param_st. 370 /* Auth_info structures copied. Now copy MHD_gtls_security_param_st.
371 * packed_session must have allocated space for the security parameters. 371 * packed_session must have allocated space for the security parameters.
372 */ 372 */
373 ret = unpack_security_parameters (session, packed_session); 373 ret = unpack_security_parameters (session, packed_session);
374 if (ret < 0) 374 if (ret < 0)
375 { 375 {
376 gnutls_assert (); 376 MHD_gnutls_assert ();
377 return ret; 377 return ret;
378 } 378 }
379 379
@@ -404,12 +404,12 @@ mhd_gtls_session_unpack (mhd_gtls_session_t session,
404 * and so on... 404 * and so on...
405 */ 405 */
406static int 406static int
407pack_certificate_auth_info (mhd_gtls_session_t session, 407pack_certificate_auth_info (MHD_gtls_session_t session,
408 gnutls_datum_t * packed_session) 408 MHD_gnutls_datum_t * packed_session)
409{ 409{
410 unsigned int pos = 0, i; 410 unsigned int pos = 0, i;
411 int cert_size, pack_size; 411 int cert_size, pack_size;
412 cert_auth_info_t info = mhd_gtls_get_auth_info (session); 412 cert_auth_info_t info = MHD_gtls_get_auth_info (session);
413 413
414 if (info) 414 if (info)
415 { 415 {
@@ -431,47 +431,47 @@ pack_certificate_auth_info (mhd_gtls_session_t session,
431 /* calculate the size and allocate the data. 431 /* calculate the size and allocate the data.
432 */ 432 */
433 packed_session->data = 433 packed_session->data =
434 gnutls_malloc (packed_session->size + MAX_SEC_PARAMS); 434 MHD_gnutls_malloc (packed_session->size + MAX_SEC_PARAMS);
435 435
436 if (packed_session->data == NULL) 436 if (packed_session->data == NULL)
437 { 437 {
438 gnutls_assert (); 438 MHD_gnutls_assert ();
439 return GNUTLS_E_MEMORY_ERROR; 439 return GNUTLS_E_MEMORY_ERROR;
440 } 440 }
441 441
442 packed_session->data[0] = MHD_GNUTLS_CRD_CERTIFICATE; 442 packed_session->data[0] = MHD_GNUTLS_CRD_CERTIFICATE;
443 mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]); 443 MHD_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
444 pos += 4 + PACK_HEADER_SIZE; 444 pos += 4 + PACK_HEADER_SIZE;
445 445
446 446
447 if (pack_size > 0) 447 if (pack_size > 0)
448 { 448 {
449 449
450 mhd_gtls_write_uint16 (info->dh.secret_bits, 450 MHD_gtls_write_uint16 (info->dh.secret_bits,
451 &packed_session->data[pos]); 451 &packed_session->data[pos]);
452 pos += 2; 452 pos += 2;
453 453
454 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime); 454 MHD_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
455 pos += 4 + info->dh.prime.size; 455 pos += 4 + info->dh.prime.size;
456 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator); 456 MHD_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
457 pos += 4 + info->dh.generator.size; 457 pos += 4 + info->dh.generator.size;
458 mhd_gtls_write_datum32 (&packed_session->data[pos], 458 MHD_gtls_write_datum32 (&packed_session->data[pos],
459 info->dh.public_key); 459 info->dh.public_key);
460 pos += 4 + info->dh.public_key.size; 460 pos += 4 + info->dh.public_key.size;
461 461
462 mhd_gtls_write_datum32 (&packed_session->data[pos], 462 MHD_gtls_write_datum32 (&packed_session->data[pos],
463 info->rsa_export.modulus); 463 info->rsa_export.modulus);
464 pos += 4 + info->rsa_export.modulus.size; 464 pos += 4 + info->rsa_export.modulus.size;
465 mhd_gtls_write_datum32 (&packed_session->data[pos], 465 MHD_gtls_write_datum32 (&packed_session->data[pos],
466 info->rsa_export.exponent); 466 info->rsa_export.exponent);
467 pos += 4 + info->rsa_export.exponent.size; 467 pos += 4 + info->rsa_export.exponent.size;
468 468
469 mhd_gtls_write_uint32 (info->ncerts, &packed_session->data[pos]); 469 MHD_gtls_write_uint32 (info->ncerts, &packed_session->data[pos]);
470 pos += 4; 470 pos += 4;
471 471
472 for (i = 0; i < info->ncerts; i++) 472 for (i = 0; i < info->ncerts; i++)
473 { 473 {
474 mhd_gtls_write_datum32 (&packed_session->data[pos], 474 MHD_gtls_write_datum32 (&packed_session->data[pos],
475 info->raw_certificate_list[i]); 475 info->raw_certificate_list[i]);
476 pos += sizeof (uint32_t) + info->raw_certificate_list[i].size; 476 pos += sizeof (uint32_t) + info->raw_certificate_list[i].size;
477 } 477 }
@@ -484,8 +484,8 @@ pack_certificate_auth_info (mhd_gtls_session_t session,
484/* Upack certificate info. 484/* Upack certificate info.
485 */ 485 */
486static int 486static int
487unpack_certificate_auth_info (mhd_gtls_session_t session, 487unpack_certificate_auth_info (MHD_gtls_session_t session,
488 const gnutls_datum_t * packed_session) 488 const MHD_gnutls_datum_t * packed_session)
489{ 489{
490 int pos = 0, size, ret; 490 int pos = 0, size, ret;
491 unsigned int i = 0, j; 491 unsigned int i = 0, j;
@@ -494,11 +494,11 @@ unpack_certificate_auth_info (mhd_gtls_session_t session,
494 494
495 if (packed_session->data[0] != MHD_GNUTLS_CRD_CERTIFICATE) 495 if (packed_session->data[0] != MHD_GNUTLS_CRD_CERTIFICATE)
496 { 496 {
497 gnutls_assert (); 497 MHD_gnutls_assert ();
498 return GNUTLS_E_INVALID_REQUEST; 498 return GNUTLS_E_INVALID_REQUEST;
499 } 499 }
500 500
501 pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]); 501 pack_size = MHD_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
502 pos += PACK_HEADER_SIZE + 4; 502 pos += PACK_HEADER_SIZE + 4;
503 503
504 if (pack_size == 0) 504 if (pack_size == 0)
@@ -507,98 +507,98 @@ unpack_certificate_auth_info (mhd_gtls_session_t session,
507 /* a simple check for integrity */ 507 /* a simple check for integrity */
508 if (pack_size + PACK_HEADER_SIZE + 4 > packed_session->size) 508 if (pack_size + PACK_HEADER_SIZE + 4 > packed_session->size)
509 { 509 {
510 gnutls_assert (); 510 MHD_gnutls_assert ();
511 return GNUTLS_E_INVALID_REQUEST; 511 return GNUTLS_E_INVALID_REQUEST;
512 } 512 }
513 513
514 /* client and server have the same auth_info here 514 /* client and server have the same auth_info here
515 */ 515 */
516 ret = 516 ret =
517 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE, 517 MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
518 sizeof (cert_auth_info_st), 1); 518 sizeof (cert_auth_info_st), 1);
519 if (ret < 0) 519 if (ret < 0)
520 { 520 {
521 gnutls_assert (); 521 MHD_gnutls_assert ();
522 return ret; 522 return ret;
523 } 523 }
524 524
525 info = mhd_gtls_get_auth_info (session); 525 info = MHD_gtls_get_auth_info (session);
526 if (info == NULL) 526 if (info == NULL)
527 { 527 {
528 gnutls_assert (); 528 MHD_gnutls_assert ();
529 return GNUTLS_E_INTERNAL_ERROR; 529 return GNUTLS_E_INTERNAL_ERROR;
530 } 530 }
531 531
532 info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]); 532 info->dh.secret_bits = MHD_gtls_read_uint16 (&packed_session->data[pos]);
533 pos += 2; 533 pos += 2;
534 534
535 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 535 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
536 pos += 4; 536 pos += 4;
537 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); 537 ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
538 if (ret < 0) 538 if (ret < 0)
539 { 539 {
540 gnutls_assert (); 540 MHD_gnutls_assert ();
541 goto error; 541 goto error;
542 } 542 }
543 pos += size; 543 pos += size;
544 544
545 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 545 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
546 pos += 4; 546 pos += 4;
547 ret = 547 ret =
548 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); 548 MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
549 if (ret < 0) 549 if (ret < 0)
550 { 550 {
551 gnutls_assert (); 551 MHD_gnutls_assert ();
552 goto error; 552 goto error;
553 } 553 }
554 pos += size; 554 pos += size;
555 555
556 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 556 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
557 pos += 4; 557 pos += 4;
558 ret = 558 ret =
559 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], 559 MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
560 size); 560 size);
561 if (ret < 0) 561 if (ret < 0)
562 { 562 {
563 gnutls_assert (); 563 MHD_gnutls_assert ();
564 goto error; 564 goto error;
565 } 565 }
566 pos += size; 566 pos += size;
567 567
568 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 568 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
569 pos += 4; 569 pos += 4;
570 ret = 570 ret =
571 _gnutls_set_datum (&info->rsa_export.modulus, 571 MHD__gnutls_set_datum (&info->rsa_export.modulus,
572 &packed_session->data[pos], size); 572 &packed_session->data[pos], size);
573 if (ret < 0) 573 if (ret < 0)
574 { 574 {
575 gnutls_assert (); 575 MHD_gnutls_assert ();
576 goto error; 576 goto error;
577 } 577 }
578 pos += size; 578 pos += size;
579 579
580 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 580 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
581 pos += 4; 581 pos += 4;
582 ret = 582 ret =
583 _gnutls_set_datum (&info->rsa_export.exponent, 583 MHD__gnutls_set_datum (&info->rsa_export.exponent,
584 &packed_session->data[pos], size); 584 &packed_session->data[pos], size);
585 if (ret < 0) 585 if (ret < 0)
586 { 586 {
587 gnutls_assert (); 587 MHD_gnutls_assert ();
588 goto error; 588 goto error;
589 } 589 }
590 pos += size; 590 pos += size;
591 591
592 info->ncerts = mhd_gtls_read_uint32 (&packed_session->data[pos]); 592 info->ncerts = MHD_gtls_read_uint32 (&packed_session->data[pos]);
593 pos += 4; 593 pos += 4;
594 594
595 if (info->ncerts > 0) 595 if (info->ncerts > 0)
596 { 596 {
597 info->raw_certificate_list = 597 info->raw_certificate_list =
598 gnutls_calloc (1, sizeof (gnutls_datum_t) * info->ncerts); 598 MHD_gnutls_calloc (1, sizeof (MHD_gnutls_datum_t) * info->ncerts);
599 if (info->raw_certificate_list == NULL) 599 if (info->raw_certificate_list == NULL)
600 { 600 {
601 gnutls_assert (); 601 MHD_gnutls_assert ();
602 ret = GNUTLS_E_MEMORY_ERROR; 602 ret = GNUTLS_E_MEMORY_ERROR;
603 goto error; 603 goto error;
604 } 604 }
@@ -606,17 +606,17 @@ unpack_certificate_auth_info (mhd_gtls_session_t session,
606 606
607 for (i = 0; i < info->ncerts; i++) 607 for (i = 0; i < info->ncerts; i++)
608 { 608 {
609 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 609 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
610 pos += sizeof (uint32_t); 610 pos += sizeof (uint32_t);
611 611
612 ret = 612 ret =
613 _gnutls_set_datum (&info->raw_certificate_list[i], 613 MHD__gnutls_set_datum (&info->raw_certificate_list[i],
614 &packed_session->data[pos], size); 614 &packed_session->data[pos], size);
615 pos += size; 615 pos += size;
616 616
617 if (ret < 0) 617 if (ret < 0)
618 { 618 {
619 gnutls_assert (); 619 MHD_gnutls_assert ();
620 goto error; 620 goto error;
621 } 621 }
622 } 622 }
@@ -625,17 +625,17 @@ unpack_certificate_auth_info (mhd_gtls_session_t session,
625 return 0; 625 return 0;
626 626
627error: 627error:
628 _gnutls_free_datum (&info->dh.prime); 628 MHD__gnutls_free_datum (&info->dh.prime);
629 _gnutls_free_datum (&info->dh.generator); 629 MHD__gnutls_free_datum (&info->dh.generator);
630 _gnutls_free_datum (&info->dh.public_key); 630 MHD__gnutls_free_datum (&info->dh.public_key);
631 631
632 _gnutls_free_datum (&info->rsa_export.modulus); 632 MHD__gnutls_free_datum (&info->rsa_export.modulus);
633 _gnutls_free_datum (&info->rsa_export.exponent); 633 MHD__gnutls_free_datum (&info->rsa_export.exponent);
634 634
635 for (j = 0; j < i; j++) 635 for (j = 0; j < i; j++)
636 _gnutls_free_datum (&info->raw_certificate_list[j]); 636 MHD__gnutls_free_datum (&info->raw_certificate_list[j]);
637 637
638 gnutls_free (info->raw_certificate_list); 638 MHD_gnutls_free (info->raw_certificate_list);
639 639
640 return ret; 640 return ret;
641 641
@@ -651,10 +651,10 @@ error:
651 * x bytes the SRP username 651 * x bytes the SRP username
652 */ 652 */
653static int 653static int
654pack_srp_auth_info (mhd_gtls_session_t session, 654pack_srp_auth_info (MHD_gtls_session_t session,
655 gnutls_datum_t * packed_session) 655 MHD_gnutls_datum_t * packed_session)
656{ 656{
657 srp_server_auth_info_t info = mhd_gtls_get_auth_info (session); 657 srp_server_auth_info_t info = MHD_gtls_get_auth_info (session);
658 int pack_size; 658 int pack_size;
659 659
660 if (info && info->username) 660 if (info && info->username)
@@ -667,16 +667,16 @@ pack_srp_auth_info (mhd_gtls_session_t session,
667 /* calculate the size and allocate the data. 667 /* calculate the size and allocate the data.
668 */ 668 */
669 packed_session->data = 669 packed_session->data =
670 gnutls_malloc (packed_session->size + MAX_SEC_PARAMS); 670 MHD_gnutls_malloc (packed_session->size + MAX_SEC_PARAMS);
671 671
672 if (packed_session->data == NULL) 672 if (packed_session->data == NULL)
673 { 673 {
674 gnutls_assert (); 674 MHD_gnutls_assert ();
675 return GNUTLS_E_MEMORY_ERROR; 675 return GNUTLS_E_MEMORY_ERROR;
676 } 676 }
677 677
678 packed_session->data[0] = MHD_GNUTLS_CRD_SRP; 678 packed_session->data[0] = MHD_GNUTLS_CRD_SRP;
679 mhd_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]); 679 MHD_gtls_write_uint32 (pack_size, &packed_session->data[PACK_HEADER_SIZE]);
680 680
681 if (pack_size > 0) 681 if (pack_size > 0)
682 memcpy (&packed_session->data[PACK_HEADER_SIZE + sizeof (uint32_t)], 682 memcpy (&packed_session->data[PACK_HEADER_SIZE + sizeof (uint32_t)],
@@ -687,8 +687,8 @@ pack_srp_auth_info (mhd_gtls_session_t session,
687 687
688 688
689static int 689static int
690unpack_srp_auth_info (mhd_gtls_session_t session, 690unpack_srp_auth_info (MHD_gtls_session_t session,
691 const gnutls_datum_t * packed_session) 691 const MHD_gnutls_datum_t * packed_session)
692{ 692{
693 size_t username_size; 693 size_t username_size;
694 int ret; 694 int ret;
@@ -696,12 +696,12 @@ unpack_srp_auth_info (mhd_gtls_session_t session,
696 696
697 if (packed_session->data[0] != MHD_GNUTLS_CRD_SRP) 697 if (packed_session->data[0] != MHD_GNUTLS_CRD_SRP)
698 { 698 {
699 gnutls_assert (); 699 MHD_gnutls_assert ();
700 return GNUTLS_E_INVALID_REQUEST; 700 return GNUTLS_E_INVALID_REQUEST;
701 } 701 }
702 702
703 username_size = 703 username_size =
704 mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]); 704 MHD_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
705 705
706 if (username_size == 0) 706 if (username_size == 0)
707 return 0; /* nothing to be done */ 707 return 0; /* nothing to be done */
@@ -709,23 +709,23 @@ unpack_srp_auth_info (mhd_gtls_session_t session,
709 /* a simple check for integrity */ 709 /* a simple check for integrity */
710 if (username_size + 4 + PACK_HEADER_SIZE > packed_session->size) 710 if (username_size + 4 + PACK_HEADER_SIZE > packed_session->size)
711 { 711 {
712 gnutls_assert (); 712 MHD_gnutls_assert ();
713 return GNUTLS_E_INVALID_REQUEST; 713 return GNUTLS_E_INVALID_REQUEST;
714 } 714 }
715 715
716 ret = 716 ret =
717 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_SRP, 717 MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_SRP,
718 sizeof (srp_server_auth_info_st), 1); 718 sizeof (srp_server_auth_info_st), 1);
719 if (ret < 0) 719 if (ret < 0)
720 { 720 {
721 gnutls_assert (); 721 MHD_gnutls_assert ();
722 return ret; 722 return ret;
723 } 723 }
724 724
725 info = mhd_gtls_get_auth_info (session); 725 info = MHD_gtls_get_auth_info (session);
726 if (info == NULL) 726 if (info == NULL)
727 { 727 {
728 gnutls_assert (); 728 MHD_gnutls_assert ();
729 return GNUTLS_E_INTERNAL_ERROR; 729 return GNUTLS_E_INTERNAL_ERROR;
730 } 730 }
731 731
@@ -757,13 +757,13 @@ unpack_srp_auth_info (mhd_gtls_session_t session,
757 * x bytes the public key 757 * x bytes the public key
758 */ 758 */
759static int 759static int
760pack_psk_auth_info (mhd_gtls_session_t session, 760pack_psk_auth_info (MHD_gtls_session_t session,
761 gnutls_datum_t * packed_session) 761 MHD_gnutls_datum_t * packed_session)
762{ 762{
763 psk_auth_info_t info; 763 psk_auth_info_t info;
764 int pack_size, username_size = 0, pos; 764 int pack_size, username_size = 0, pos;
765 765
766 info = mhd_gtls_get_auth_info (session); 766 info = MHD_gtls_get_auth_info (session);
767 767
768 if (info) 768 if (info)
769 { 769 {
@@ -780,11 +780,11 @@ pack_psk_auth_info (mhd_gtls_session_t session,
780 /* calculate the size and allocate the data. 780 /* calculate the size and allocate the data.
781 */ 781 */
782 packed_session->data = 782 packed_session->data =
783 gnutls_malloc (packed_session->size + MAX_SEC_PARAMS); 783 MHD_gnutls_malloc (packed_session->size + MAX_SEC_PARAMS);
784 784
785 if (packed_session->data == NULL) 785 if (packed_session->data == NULL)
786 { 786 {
787 gnutls_assert (); 787 MHD_gnutls_assert ();
788 return GNUTLS_E_MEMORY_ERROR; 788 return GNUTLS_E_MEMORY_ERROR;
789 } 789 }
790 790
@@ -793,27 +793,27 @@ pack_psk_auth_info (mhd_gtls_session_t session,
793 packed_session->data[pos] = MHD_GNUTLS_CRD_PSK; 793 packed_session->data[pos] = MHD_GNUTLS_CRD_PSK;
794 pos++; 794 pos++;
795 795
796 mhd_gtls_write_uint32 (pack_size, &packed_session->data[pos]); 796 MHD_gtls_write_uint32 (pack_size, &packed_session->data[pos]);
797 pos += 4; 797 pos += 4;
798 798
799 799
800 if (pack_size > 0) 800 if (pack_size > 0)
801 { 801 {
802 mhd_gtls_write_uint32 (username_size, &packed_session->data[pos]); 802 MHD_gtls_write_uint32 (username_size, &packed_session->data[pos]);
803 pos += 4; 803 pos += 4;
804 804
805 memcpy (&packed_session->data[pos], info->username, username_size); 805 memcpy (&packed_session->data[pos], info->username, username_size);
806 pos += username_size; 806 pos += username_size;
807 807
808 mhd_gtls_write_uint16 (info->dh.secret_bits, 808 MHD_gtls_write_uint16 (info->dh.secret_bits,
809 &packed_session->data[pos]); 809 &packed_session->data[pos]);
810 pos += 2; 810 pos += 2;
811 811
812 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime); 812 MHD_gtls_write_datum32 (&packed_session->data[pos], info->dh.prime);
813 pos += 4 + info->dh.prime.size; 813 pos += 4 + info->dh.prime.size;
814 mhd_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator); 814 MHD_gtls_write_datum32 (&packed_session->data[pos], info->dh.generator);
815 pos += 4 + info->dh.generator.size; 815 pos += 4 + info->dh.generator.size;
816 mhd_gtls_write_datum32 (&packed_session->data[pos], 816 MHD_gtls_write_datum32 (&packed_session->data[pos],
817 info->dh.public_key); 817 info->dh.public_key);
818 pos += 4 + info->dh.public_key.size; 818 pos += 4 + info->dh.public_key.size;
819 819
@@ -824,8 +824,8 @@ pack_psk_auth_info (mhd_gtls_session_t session,
824} 824}
825 825
826static int 826static int
827unpack_psk_auth_info (mhd_gtls_session_t session, 827unpack_psk_auth_info (MHD_gtls_session_t session,
828 const gnutls_datum_t * packed_session) 828 const MHD_gnutls_datum_t * packed_session)
829{ 829{
830 size_t username_size; 830 size_t username_size;
831 size_t pack_size; 831 size_t pack_size;
@@ -834,11 +834,11 @@ unpack_psk_auth_info (mhd_gtls_session_t session,
834 834
835 if (packed_session->data[0] != MHD_GNUTLS_CRD_PSK) 835 if (packed_session->data[0] != MHD_GNUTLS_CRD_PSK)
836 { 836 {
837 gnutls_assert (); 837 MHD_gnutls_assert ();
838 return GNUTLS_E_INVALID_REQUEST; 838 return GNUTLS_E_INVALID_REQUEST;
839 } 839 }
840 840
841 pack_size = mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]); 841 pack_size = MHD_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]);
842 pos += PACK_HEADER_SIZE + 4; 842 pos += PACK_HEADER_SIZE + 4;
843 843
844 844
@@ -848,66 +848,66 @@ unpack_psk_auth_info (mhd_gtls_session_t session,
848 /* a simple check for integrity */ 848 /* a simple check for integrity */
849 if (pack_size + PACK_HEADER_SIZE + 4 > packed_session->size) 849 if (pack_size + PACK_HEADER_SIZE + 4 > packed_session->size)
850 { 850 {
851 gnutls_assert (); 851 MHD_gnutls_assert ();
852 return GNUTLS_E_INVALID_REQUEST; 852 return GNUTLS_E_INVALID_REQUEST;
853 } 853 }
854 854
855 /* client and serer have the same auth_info here 855 /* client and serer have the same auth_info here
856 */ 856 */
857 ret = 857 ret =
858 mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_PSK, 858 MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_PSK,
859 sizeof (psk_auth_info_st), 1); 859 sizeof (psk_auth_info_st), 1);
860 if (ret < 0) 860 if (ret < 0)
861 { 861 {
862 gnutls_assert (); 862 MHD_gnutls_assert ();
863 return ret; 863 return ret;
864 } 864 }
865 865
866 info = mhd_gtls_get_auth_info (session); 866 info = MHD_gtls_get_auth_info (session);
867 if (info == NULL) 867 if (info == NULL)
868 { 868 {
869 gnutls_assert (); 869 MHD_gnutls_assert ();
870 return GNUTLS_E_INTERNAL_ERROR; 870 return GNUTLS_E_INTERNAL_ERROR;
871 } 871 }
872 872
873 username_size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 873 username_size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
874 pos += 4; 874 pos += 4;
875 875
876 memcpy (info->username, &packed_session->data[pos], username_size); 876 memcpy (info->username, &packed_session->data[pos], username_size);
877 pos += username_size; 877 pos += username_size;
878 878
879 info->dh.secret_bits = mhd_gtls_read_uint16 (&packed_session->data[pos]); 879 info->dh.secret_bits = MHD_gtls_read_uint16 (&packed_session->data[pos]);
880 pos += 2; 880 pos += 2;
881 881
882 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 882 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
883 pos += 4; 883 pos += 4;
884 ret = _gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); 884 ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size);
885 if (ret < 0) 885 if (ret < 0)
886 { 886 {
887 gnutls_assert (); 887 MHD_gnutls_assert ();
888 goto error; 888 goto error;
889 } 889 }
890 pos += size; 890 pos += size;
891 891
892 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 892 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
893 pos += 4; 893 pos += 4;
894 ret = 894 ret =
895 _gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); 895 MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size);
896 if (ret < 0) 896 if (ret < 0)
897 { 897 {
898 gnutls_assert (); 898 MHD_gnutls_assert ();
899 goto error; 899 goto error;
900 } 900 }
901 pos += size; 901 pos += size;
902 902
903 size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 903 size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
904 pos += 4; 904 pos += 4;
905 ret = 905 ret =
906 _gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], 906 MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos],
907 size); 907 size);
908 if (ret < 0) 908 if (ret < 0)
909 { 909 {
910 gnutls_assert (); 910 MHD_gnutls_assert ();
911 goto error; 911 goto error;
912 } 912 }
913 pos += size; 913 pos += size;
@@ -915,9 +915,9 @@ unpack_psk_auth_info (mhd_gtls_session_t session,
915 return 0; 915 return 0;
916 916
917error: 917error:
918 _gnutls_free_datum (&info->dh.prime); 918 MHD__gnutls_free_datum (&info->dh.prime);
919 _gnutls_free_datum (&info->dh.generator); 919 MHD__gnutls_free_datum (&info->dh.generator);
920 _gnutls_free_datum (&info->dh.public_key); 920 MHD__gnutls_free_datum (&info->dh.public_key);
921 return ret; 921 return ret;
922} 922}
923#endif 923#endif
@@ -972,8 +972,8 @@ error:
972 * MAX: 7+MAX_SRP_USERNAME+MAX_SERVER_NAME_EXTENSIONS*(3+MAX_SERVER_NAME_SIZE) 972 * MAX: 7+MAX_SRP_USERNAME+MAX_SERVER_NAME_EXTENSIONS*(3+MAX_SERVER_NAME_SIZE)
973 */ 973 */
974static int 974static int
975pack_security_parameters (mhd_gtls_session_t session, 975pack_security_parameters (MHD_gtls_session_t session,
976 gnutls_datum_t * packed_session) 976 MHD_gnutls_datum_t * packed_session)
977{ 977{
978 int pos = 0; 978 int pos = 0;
979 size_t len, init, i; 979 size_t len, init, i;
@@ -981,7 +981,7 @@ pack_security_parameters (mhd_gtls_session_t session,
981 /* move after the auth info stuff. 981 /* move after the auth info stuff.
982 */ 982 */
983 init = 983 init =
984 mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 + 984 MHD_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 +
985 PACK_HEADER_SIZE; 985 PACK_HEADER_SIZE;
986 986
987 pos = init + 4; /* make some space to write later the size */ 987 pos = init + 4; /* make some space to write later the size */
@@ -1024,16 +1024,16 @@ pack_security_parameters (mhd_gtls_session_t session,
1024 session->security_parameters.session_id_size); 1024 session->security_parameters.session_id_size);
1025 pos += session->security_parameters.session_id_size; 1025 pos += session->security_parameters.session_id_size;
1026 1026
1027 mhd_gtls_write_uint32 (session->security_parameters.timestamp, 1027 MHD_gtls_write_uint32 (session->security_parameters.timestamp,
1028 &packed_session->data[pos]); 1028 &packed_session->data[pos]);
1029 pos += 4; 1029 pos += 4;
1030 1030
1031 /* Extensions */ 1031 /* Extensions */
1032 mhd_gtls_write_uint16 (session->security_parameters.max_record_send_size, 1032 MHD_gtls_write_uint16 (session->security_parameters.max_record_send_size,
1033 &packed_session->data[pos]); 1033 &packed_session->data[pos]);
1034 pos += 2; 1034 pos += 2;
1035 1035
1036 mhd_gtls_write_uint16 (session->security_parameters.max_record_recv_size, 1036 MHD_gtls_write_uint16 (session->security_parameters.max_record_recv_size,
1037 &packed_session->data[pos]); 1037 &packed_session->data[pos]);
1038 pos += 2; 1038 pos += 2;
1039 1039
@@ -1045,7 +1045,7 @@ pack_security_parameters (mhd_gtls_session_t session,
1045 session->security_parameters.extensions.srp_username, len); 1045 session->security_parameters.extensions.srp_username, len);
1046 pos += len; 1046 pos += len;
1047 1047
1048 mhd_gtls_write_uint16 (session->security_parameters.extensions. 1048 MHD_gtls_write_uint16 (session->security_parameters.extensions.
1049 server_names_size, &packed_session->data[pos]); 1049 server_names_size, &packed_session->data[pos]);
1050 pos += 2; 1050 pos += 2;
1051 1051
@@ -1054,7 +1054,7 @@ pack_security_parameters (mhd_gtls_session_t session,
1054 { 1054 {
1055 packed_session->data[pos++] = 1055 packed_session->data[pos++] =
1056 session->security_parameters.extensions.server_names[i].type; 1056 session->security_parameters.extensions.server_names[i].type;
1057 mhd_gtls_write_uint16 (session->security_parameters.extensions. 1057 MHD_gtls_write_uint16 (session->security_parameters.extensions.
1058 server_names[i].name_length, 1058 server_names[i].name_length,
1059 &packed_session->data[pos]); 1059 &packed_session->data[pos]);
1060 pos += 2; 1060 pos += 2;
@@ -1068,7 +1068,7 @@ pack_security_parameters (mhd_gtls_session_t session,
1068 } 1068 }
1069 1069
1070 /* write the total size */ 1070 /* write the total size */
1071 mhd_gtls_write_uint32 (pos - init - 4, &packed_session->data[init]); 1071 MHD_gtls_write_uint32 (pos - init - 4, &packed_session->data[init]);
1072 packed_session->size += pos - init; 1072 packed_session->size += pos - init;
1073 1073
1074 return 0; 1074 return 0;
@@ -1076,8 +1076,8 @@ pack_security_parameters (mhd_gtls_session_t session,
1076 1076
1077 1077
1078static int 1078static int
1079unpack_security_parameters (mhd_gtls_session_t session, 1079unpack_security_parameters (MHD_gtls_session_t session,
1080 const gnutls_datum_t * packed_session) 1080 const MHD_gnutls_datum_t * packed_session)
1081{ 1081{
1082 size_t pack_size, init, i; 1082 size_t pack_size, init, i;
1083 int pos = 0, len; 1083 int pos = 0, len;
@@ -1086,12 +1086,12 @@ unpack_security_parameters (mhd_gtls_session_t session,
1086 1086
1087 /* skip the auth info stuff */ 1087 /* skip the auth info stuff */
1088 init = 1088 init =
1089 mhd_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 + 1089 MHD_gtls_read_uint32 (&packed_session->data[PACK_HEADER_SIZE]) + 4 +
1090 PACK_HEADER_SIZE; 1090 PACK_HEADER_SIZE;
1091 1091
1092 pos = init; 1092 pos = init;
1093 1093
1094 pack_size = mhd_gtls_read_uint32 (&packed_session->data[pos]); 1094 pack_size = MHD_gtls_read_uint32 (&packed_session->data[pos]);
1095 pos += 4; 1095 pos += 4;
1096 1096
1097 1097
@@ -1101,7 +1101,7 @@ unpack_security_parameters (mhd_gtls_session_t session,
1101 /* a simple check for integrity */ 1101 /* a simple check for integrity */
1102 if (pack_size > MAX_SEC_PARAMS) 1102 if (pack_size > MAX_SEC_PARAMS)
1103 { 1103 {
1104 gnutls_assert (); 1104 MHD_gnutls_assert ();
1105 return GNUTLS_E_INVALID_REQUEST; 1105 return GNUTLS_E_INVALID_REQUEST;
1106 } 1106 }
1107 1107
@@ -1150,24 +1150,24 @@ unpack_security_parameters (mhd_gtls_session_t session,
1150 pos += session->internals.resumed_security_parameters.session_id_size; 1150 pos += session->internals.resumed_security_parameters.session_id_size;
1151 1151
1152 session->internals.resumed_security_parameters.timestamp = 1152 session->internals.resumed_security_parameters.timestamp =
1153 mhd_gtls_read_uint32 (&packed_session->data[pos]); 1153 MHD_gtls_read_uint32 (&packed_session->data[pos]);
1154 pos += 4; 1154 pos += 4;
1155 1155
1156 if (timestamp - session->internals.resumed_security_parameters.timestamp > 1156 if (timestamp - session->internals.resumed_security_parameters.timestamp >
1157 session->internals.expire_time 1157 session->internals.expire_time
1158 || session->internals.resumed_security_parameters.timestamp > timestamp) 1158 || session->internals.resumed_security_parameters.timestamp > timestamp)
1159 { 1159 {
1160 gnutls_assert (); 1160 MHD_gnutls_assert ();
1161 return GNUTLS_E_EXPIRED; 1161 return GNUTLS_E_EXPIRED;
1162 } 1162 }
1163 1163
1164 /* Extensions */ 1164 /* Extensions */
1165 session->internals.resumed_security_parameters.max_record_send_size = 1165 session->internals.resumed_security_parameters.max_record_send_size =
1166 mhd_gtls_read_uint16 (&packed_session->data[pos]); 1166 MHD_gtls_read_uint16 (&packed_session->data[pos]);
1167 pos += 2; 1167 pos += 2;
1168 1168
1169 session->internals.resumed_security_parameters.max_record_recv_size = 1169 session->internals.resumed_security_parameters.max_record_recv_size =
1170 mhd_gtls_read_uint16 (&packed_session->data[pos]); 1170 MHD_gtls_read_uint16 (&packed_session->data[pos]);
1171 pos += 2; 1171 pos += 2;
1172 1172
1173 1173
@@ -1180,7 +1180,7 @@ unpack_security_parameters (mhd_gtls_session_t session,
1180 pos += len; 1180 pos += len;
1181 1181
1182 session->internals.resumed_security_parameters.extensions. 1182 session->internals.resumed_security_parameters.extensions.
1183 server_names_size = mhd_gtls_read_uint16 (&packed_session->data[pos]); 1183 server_names_size = MHD_gtls_read_uint16 (&packed_session->data[pos]);
1184 pos += 2; 1184 pos += 2;
1185 for (i = 0; 1185 for (i = 0;
1186 i < 1186 i <
@@ -1191,7 +1191,7 @@ unpack_security_parameters (mhd_gtls_session_t session,
1191 server_names[i].type = packed_session->data[pos++]; 1191 server_names[i].type = packed_session->data[pos++];
1192 session->internals.resumed_security_parameters.extensions. 1192 session->internals.resumed_security_parameters.extensions.
1193 server_names[i].name_length = 1193 server_names[i].name_length =
1194 mhd_gtls_read_uint16 (&packed_session->data[pos]); 1194 MHD_gtls_read_uint16 (&packed_session->data[pos]);
1195 pos += 2; 1195 pos += 2;
1196 1196
1197 memcpy (session->internals.resumed_security_parameters.extensions. 1197 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 e93d9d28..e327f71f 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 mhd_gtls_session_pack (mhd_gtls_session_t session, 25int MHD_gtls_session_pack (MHD_gtls_session_t session,
26 gnutls_datum_t * packed_session); 26 MHD_gnutls_datum_t * packed_session);
27int mhd_gtls_session_unpack (mhd_gtls_session_t session, 27int MHD_gtls_session_unpack (MHD_gtls_session_t session,
28 const gnutls_datum_t * packed_session); 28 const MHD_gnutls_datum_t * packed_session);
diff --git a/src/daemon/https/tls/gnutls_sig.c b/src/daemon/https/tls/gnutls_sig.c
index 3a41999d..0309e588 100644
--- a/src/daemon/https/tls/gnutls_sig.c
+++ b/src/daemon/https/tls/gnutls_sig.c
@@ -37,79 +37,79 @@
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 (mhd_gtls_session_t session, 40static int MHD__gnutls_tls_sign (MHD_gtls_session_t session,
41 gnutls_cert * cert, 41 MHD_gnutls_cert * cert,
42 gnutls_privkey * pkey, 42 MHD_gnutls_privkey * pkey,
43 const gnutls_datum_t * hash_concat, 43 const MHD_gnutls_datum_t * hash_concat,
44 gnutls_datum_t * signature); 44 MHD_gnutls_datum_t * signature);
45 45
46/* Generates a signature of all the previous sent packets in the 46/* Generates a signature of all the previous sent packets in the
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
50mhd_gtls_tls_sign_hdata (mhd_gtls_session_t session, 50MHD_gtls_tls_sign_hdata (MHD_gtls_session_t session,
51 gnutls_cert * cert, 51 MHD_gnutls_cert * cert,
52 gnutls_privkey * pkey, gnutls_datum_t * signature) 52 MHD_gnutls_privkey * pkey, MHD_gnutls_datum_t * signature)
53{ 53{
54 gnutls_datum_t dconcat; 54 MHD_gnutls_datum_t dconcat;
55 int ret; 55 int ret;
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 enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); 59 enum MHD_GNUTLS_Protocol ver = MHD__gnutls_protocol_get_version (session);
60 60
61 td_sha = mhd_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 MHD_gnutls_assert ();
65 return GNUTLS_E_HASH_FAILED; 65 return GNUTLS_E_HASH_FAILED;
66 } 66 }
67 67
68 if (ver == MHD_GNUTLS_PROTOCOL_SSL3) 68 if (ver == MHD_GNUTLS_PROTOCOL_SSL3)
69 { 69 {
70 ret = mhd_gtls_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 MHD_gnutls_assert ();
74 return ret; 74 return ret;
75 } 75 }
76 76
77 mhd_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 mhd_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 mhd_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 MHD_gnutls_assert ();
92 return GNUTLS_E_HASH_FAILED; 92 return GNUTLS_E_HASH_FAILED;
93 } 93 }
94 94
95 if (ver == MHD_GNUTLS_PROTOCOL_SSL3) 95 if (ver == MHD_GNUTLS_PROTOCOL_SSL3)
96 mhd_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 mhd_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;
104 break; 104 break;
105 default: 105 default:
106 gnutls_assert (); 106 MHD_gnutls_assert ();
107 return GNUTLS_E_INTERNAL_ERROR; 107 return GNUTLS_E_INTERNAL_ERROR;
108 } 108 }
109 ret = _gnutls_tls_sign (session, cert, pkey, &dconcat, signature); 109 ret = MHD__gnutls_tls_sign (session, cert, pkey, &dconcat, signature);
110 if (ret < 0) 110 if (ret < 0)
111 { 111 {
112 gnutls_assert (); 112 MHD_gnutls_assert ();
113 } 113 }
114 114
115 return ret; 115 return ret;
@@ -119,50 +119,50 @@ mhd_gtls_tls_sign_hdata (mhd_gtls_session_t session,
119 * Used in DHE_* ciphersuites. 119 * Used in DHE_* ciphersuites.
120 */ 120 */
121int 121int
122mhd_gtls_tls_sign_params (mhd_gtls_session_t session, 122MHD_gtls_tls_sign_params (MHD_gtls_session_t session,
123 gnutls_cert * cert, 123 MHD_gnutls_cert * cert,
124 gnutls_privkey * pkey, 124 MHD_gnutls_privkey * pkey,
125 gnutls_datum_t * params, gnutls_datum_t * signature) 125 MHD_gnutls_datum_t * params, MHD_gnutls_datum_t * signature)
126{ 126{
127 gnutls_datum_t dconcat; 127 MHD_gnutls_datum_t dconcat;
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 enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); 131 enum MHD_GNUTLS_Protocol ver = MHD__gnutls_protocol_get_version (session);
132 132
133 td_sha = mhd_gtls_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 MHD_gnutls_assert ();
137 return GNUTLS_E_HASH_FAILED; 137 return GNUTLS_E_HASH_FAILED;
138 } 138 }
139 139
140 mhd_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 mhd_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 mhd_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_PROTOCOL_TLS1_2) 149 if (ver < MHD_GNUTLS_PROTOCOL_TLS1_2)
150 { 150 {
151 mac_hd_t td_md5 = mhd_gtls_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 MHD_gnutls_assert ();
155 return GNUTLS_E_HASH_FAILED; 155 return GNUTLS_E_HASH_FAILED;
156 } 156 }
157 157
158 mhd_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 mhd_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 mhd_gnutls_hash (td_md5, params->data, params->size); 162 MHD_gnutls_hash (td_md5, params->data, params->size);
163 163
164 mhd_gnutls_hash_deinit (td_md5, concat); 164 MHD_gnutls_hash_deinit (td_md5, concat);
165 mhd_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,27 +173,27 @@ mhd_gtls_tls_sign_params (mhd_gtls_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 mhd_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 mhd_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 }
186 dconcat.data = concat; 186 dconcat.data = concat;
187 break; 187 break;
188 default: 188 default:
189 gnutls_assert (); 189 MHD_gnutls_assert ();
190 mhd_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 = MHD__gnutls_tls_sign (session, cert, pkey, &dconcat, signature);
194 if (ret < 0) 194 if (ret < 0)
195 { 195 {
196 gnutls_assert (); 196 MHD_gnutls_assert ();
197 } 197 }
198 198
199 return ret; 199 return ret;
@@ -204,10 +204,10 @@ mhd_gtls_tls_sign_params (mhd_gtls_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
207mhd_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo, 207MHD_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm 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 MHD_gnutls_datum_t * data, MHD_gnutls_datum_t * signature)
211{ 211{
212 int ret; 212 int ret;
213 213
@@ -216,16 +216,16 @@ mhd_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo,
216 case MHD_GNUTLS_PK_RSA: 216 case MHD_GNUTLS_PK_RSA:
217 /* encrypt */ 217 /* encrypt */
218 if ((ret = 218 if ((ret =
219 mhd_gtls_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 MHD_gnutls_assert ();
223 return ret; 223 return ret;
224 } 224 }
225 225
226 break; 226 break;
227 default: 227 default:
228 gnutls_assert (); 228 MHD_gnutls_assert ();
229 return GNUTLS_E_INTERNAL_ERROR; 229 return GNUTLS_E_INTERNAL_ERROR;
230 break; 230 break;
231 } 231 }
@@ -238,11 +238,11 @@ mhd_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo,
238 * it supports signing. 238 * it supports signing.
239 */ 239 */
240static int 240static int
241_gnutls_tls_sign (mhd_gtls_session_t session, 241MHD__gnutls_tls_sign (MHD_gtls_session_t session,
242 gnutls_cert * cert, 242 MHD_gnutls_cert * cert,
243 gnutls_privkey * pkey, 243 MHD_gnutls_privkey * pkey,
244 const gnutls_datum_t * hash_concat, 244 const MHD_gnutls_datum_t * hash_concat,
245 gnutls_datum_t * signature) 245 MHD_gnutls_datum_t * signature)
246{ 246{
247 247
248 /* If our certificate supports signing 248 /* If our certificate supports signing
@@ -252,7 +252,7 @@ _gnutls_tls_sign (mhd_gtls_session_t session,
252 if (cert->key_usage != 0) 252 if (cert->key_usage != 0)
253 if (!(cert->key_usage & KEY_DIGITAL_SIGNATURE)) 253 if (!(cert->key_usage & KEY_DIGITAL_SIGNATURE))
254 { 254 {
255 gnutls_assert (); 255 MHD_gnutls_assert ();
256 return GNUTLS_E_KEY_USAGE_VIOLATION; 256 return GNUTLS_E_KEY_USAGE_VIOLATION;
257 } 257 }
258 258
@@ -269,23 +269,23 @@ _gnutls_tls_sign (mhd_gtls_session_t session,
269 hash_concat, signature); 269 hash_concat, signature);
270 } 270 }
271 271
272 return mhd_gtls_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
276static int 276static int
277_gnutls_verify_sig (gnutls_cert * cert, 277MHD__gnutls_verify_sig (MHD_gnutls_cert * cert,
278 const gnutls_datum_t * hash_concat, 278 const MHD_gnutls_datum_t * hash_concat,
279 gnutls_datum_t * signature, size_t sha1pos) 279 MHD_gnutls_datum_t * signature, size_t sha1pos)
280{ 280{
281 int ret; 281 int ret;
282 gnutls_datum_t vdata; 282 MHD_gnutls_datum_t vdata;
283 283
284 if ( (cert == NULL) || (cert->version == 0) ) 284 if ( (cert == NULL) || (cert->version == 0) )
285 { /* this is the only way to check 285 { /* this is the only way to check
286 * if it is initialized 286 * if it is initialized
287 */ 287 */
288 gnutls_assert (); 288 MHD_gnutls_assert ();
289 return GNUTLS_E_CERTIFICATE_ERROR; 289 return GNUTLS_E_CERTIFICATE_ERROR;
290 } 290 }
291 291
@@ -295,7 +295,7 @@ _gnutls_verify_sig (gnutls_cert * cert,
295 if (cert->key_usage != 0) 295 if (cert->key_usage != 0)
296 if (!(cert->key_usage & KEY_DIGITAL_SIGNATURE)) 296 if (!(cert->key_usage & KEY_DIGITAL_SIGNATURE))
297 { 297 {
298 gnutls_assert (); 298 MHD_gnutls_assert ();
299 return GNUTLS_E_KEY_USAGE_VIOLATION; 299 return GNUTLS_E_KEY_USAGE_VIOLATION;
300 } 300 }
301 301
@@ -307,16 +307,16 @@ _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 = mhd_gtls_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 MHD_gnutls_assert ();
314 return ret; 314 return ret;
315 } 315 }
316 316
317 break; 317 break;
318 default: 318 default:
319 gnutls_assert (); 319 MHD_gnutls_assert ();
320 return GNUTLS_E_INTERNAL_ERROR; 320 return GNUTLS_E_INTERNAL_ERROR;
321 } 321 }
322 322
@@ -327,60 +327,60 @@ _gnutls_verify_sig (gnutls_cert * cert,
327 * verify message). 327 * verify message).
328 */ 328 */
329int 329int
330mhd_gtls_verify_sig_hdata (mhd_gtls_session_t session, 330MHD_gtls_verify_sig_hdata (MHD_gtls_session_t session,
331 gnutls_cert * cert, gnutls_datum_t * signature) 331 MHD_gnutls_cert * cert, MHD_gnutls_datum_t * signature)
332{ 332{
333 int ret; 333 int ret;
334 opaque concat[36]; 334 opaque concat[36];
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 MHD_gnutls_datum_t dconcat;
338 enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); 338 enum MHD_GNUTLS_Protocol ver = MHD__gnutls_protocol_get_version (session);
339 339
340 td_md5 = mhd_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 MHD_gnutls_assert ();
344 return GNUTLS_E_HASH_FAILED; 344 return GNUTLS_E_HASH_FAILED;
345 } 345 }
346 346
347 td_sha = mhd_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 MHD_gnutls_assert ();
351 mhd_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_PROTOCOL_SSL3) 355 if (ver == MHD_GNUTLS_PROTOCOL_SSL3)
356 { 356 {
357 ret = mhd_gtls_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 MHD_gnutls_assert ();
361 return ret; 361 return ret;
362 } 362 }
363 363
364 mhd_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 mhd_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 mhd_gnutls_hash_deinit (td_md5, concat); 373 MHD_gnutls_hash_deinit (td_md5, concat);
374 mhd_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;
378 dconcat.size = 20 + 16; /* md5+ sha */ 378 dconcat.size = 20 + 16; /* md5+ sha */
379 379
380 ret = _gnutls_verify_sig (cert, &dconcat, signature, 16); 380 ret = MHD__gnutls_verify_sig (cert, &dconcat, signature, 16);
381 if (ret < 0) 381 if (ret < 0)
382 { 382 {
383 gnutls_assert (); 383 MHD_gnutls_assert ();
384 return ret; 384 return ret;
385 } 385 }
386 386
@@ -392,53 +392,53 @@ mhd_gtls_verify_sig_hdata (mhd_gtls_session_t session,
392 * Used in DHE_* ciphersuites. 392 * Used in DHE_* ciphersuites.
393 */ 393 */
394int 394int
395mhd_gtls_verify_sig_params (mhd_gtls_session_t session, 395MHD_gtls_verify_sig_params (MHD_gtls_session_t session,
396 gnutls_cert * cert, 396 MHD_gnutls_cert * cert,
397 const gnutls_datum_t * params, 397 const MHD_gnutls_datum_t * params,
398 gnutls_datum_t * signature) 398 MHD_gnutls_datum_t * signature)
399{ 399{
400 gnutls_datum_t dconcat; 400 MHD_gnutls_datum_t dconcat;
401 int ret; 401 int ret;
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 enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); 405 enum MHD_GNUTLS_Protocol ver = MHD__gnutls_protocol_get_version (session);
406 406
407 if (ver < MHD_GNUTLS_PROTOCOL_TLS1_2) 407 if (ver < MHD_GNUTLS_PROTOCOL_TLS1_2)
408 { 408 {
409 td_md5 = mhd_gtls_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 MHD_gnutls_assert ();
413 return GNUTLS_E_HASH_FAILED; 413 return GNUTLS_E_HASH_FAILED;
414 } 414 }
415 415
416 mhd_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 mhd_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 mhd_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 = mhd_gtls_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 MHD_gnutls_assert ();
427 if (td_md5) 427 if (td_md5)
428 mhd_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 mhd_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 mhd_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 mhd_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_PROTOCOL_TLS1_2) 438 if (ver < MHD_GNUTLS_PROTOCOL_TLS1_2)
439 { 439 {
440 mhd_gnutls_hash_deinit (td_md5, concat); 440 MHD_gnutls_hash_deinit (td_md5, concat);
441 mhd_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,23 +448,23 @@ mhd_gtls_verify_sig_params (mhd_gtls_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 mhd_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 mhd_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 }
461 461
462 dconcat.data = concat; 462 dconcat.data = concat;
463 463
464 ret = _gnutls_verify_sig (cert, &dconcat, signature, dconcat.size - 20); 464 ret = MHD__gnutls_verify_sig (cert, &dconcat, signature, dconcat.size - 20);
465 if (ret < 0) 465 if (ret < 0)
466 { 466 {
467 gnutls_assert (); 467 MHD_gnutls_assert ();
468 return ret; 468 return ret;
469 } 469 }
470 470
diff --git a/src/daemon/https/tls/gnutls_sig.h b/src/daemon/https/tls/gnutls_sig.h
index eaef5226..6259191d 100644
--- a/src/daemon/https/tls/gnutls_sig.h
+++ b/src/daemon/https/tls/gnutls_sig.h
@@ -25,28 +25,28 @@
25#ifndef GNUTLS_SIG_H 25#ifndef GNUTLS_SIG_H
26# define GNUTLS_SIG_H 26# define GNUTLS_SIG_H
27 27
28int mhd_gtls_tls_sign_hdata (mhd_gtls_session_t session, 28int MHD_gtls_tls_sign_hdata (MHD_gtls_session_t session,
29 gnutls_cert * cert, 29 MHD_gnutls_cert * cert,
30 gnutls_privkey * pkey, 30 MHD_gnutls_privkey * pkey,
31 gnutls_datum_t * signature); 31 MHD_gnutls_datum_t * signature);
32 32
33int mhd_gtls_tls_sign_params (mhd_gtls_session_t session, 33int MHD_gtls_tls_sign_params (MHD_gtls_session_t session,
34 gnutls_cert * cert, 34 MHD_gnutls_cert * cert,
35 gnutls_privkey * pkey, 35 MHD_gnutls_privkey * pkey,
36 gnutls_datum_t * params, 36 MHD_gnutls_datum_t * params,
37 gnutls_datum_t * signature); 37 MHD_gnutls_datum_t * signature);
38 38
39int mhd_gtls_verify_sig_hdata (mhd_gtls_session_t session, 39int MHD_gtls_verify_sig_hdata (MHD_gtls_session_t session,
40 gnutls_cert * cert, 40 MHD_gnutls_cert * cert,
41 gnutls_datum_t * signature); 41 MHD_gnutls_datum_t * signature);
42 42
43int mhd_gtls_verify_sig_params (mhd_gtls_session_t session, 43int MHD_gtls_verify_sig_params (MHD_gtls_session_t session,
44 gnutls_cert * cert, 44 MHD_gnutls_cert * cert,
45 const gnutls_datum_t * params, 45 const MHD_gnutls_datum_t * params,
46 gnutls_datum_t * signature); 46 MHD_gnutls_datum_t * signature);
47 47
48int mhd_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo, 48int MHD_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo,
49 mpi_t * params, int params_size, 49 mpi_t * params, int params_size,
50 const gnutls_datum_t * data, gnutls_datum_t * signature); 50 const MHD_gnutls_datum_t * data, MHD_gnutls_datum_t * signature);
51 51
52#endif 52#endif
diff --git a/src/daemon/https/tls/gnutls_state.c b/src/daemon/https/tls/gnutls_state.c
index ae793ee0..49802b2e 100644
--- a/src/daemon/https/tls/gnutls_state.c
+++ b/src/daemon/https/tls/gnutls_state.c
@@ -22,8 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25/* Functions to manipulate the session (gnutls_int.h), and some other stuff 25/* Functions to manipulate the session (MHD_gnutls_int.h), and some other stuff
26 * are included here. The file's name is traditionally gnutls_state even if the 26 * are included here. The file's name is traditionally MHD_gnutls_state even if the
27 * state has been renamed to session. 27 * state has been renamed to session.
28 */ 28 */
29 29
@@ -43,27 +43,27 @@
43#include <gnutls_rsa_export.h> 43#include <gnutls_rsa_export.h>
44 44
45void 45void
46_gnutls_session_cert_type_set (mhd_gtls_session_t session, 46MHD__gnutls_session_cert_type_set (MHD_gtls_session_t session,
47 enum MHD_GNUTLS_CertificateType ct) 47 enum MHD_GNUTLS_CertificateType ct)
48{ 48{
49 session->security_parameters.cert_type = ct; 49 session->security_parameters.cert_type = ct;
50} 50}
51 51
52/** 52/**
53 * gnutls_cipher_get - Returns the currently used cipher. 53 * MHD_gnutls_cipher_get - Returns the currently used cipher.
54 * @session: is a #mhd_gtls_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 **/
58enum MHD_GNUTLS_CipherAlgorithm 58enum MHD_GNUTLS_CipherAlgorithm
59gnutls_cipher_get (mhd_gtls_session_t session) 59MHD_gnutls_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 * MHD_gnutls_certificate_type_get - Returns the currently used certificate type.
66 * @session: is a #mhd_gtls_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 (mhd_gtls_session_t session)
72 * type. 72 * type.
73 **/ 73 **/
74enum MHD_GNUTLS_CertificateType 74enum MHD_GNUTLS_CertificateType
75gnutls_certificate_type_get (mhd_gtls_session_t session) 75MHD_gnutls_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 * MHD_gnutls_kx_get - Returns the key exchange algorithm.
82 * @session: is a #mhd_gtls_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 **/
86enum MHD_GNUTLS_KeyExchangeAlgorithm 86enum MHD_GNUTLS_KeyExchangeAlgorithm
87gnutls_kx_get (mhd_gtls_session_t session) 87MHD_gnutls_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 * MHD_gnutls_mac_get - Returns the currently used mac algorithm.
94 * @session: is a #mhd_gtls_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 **/
98enum MHD_GNUTLS_HashAlgorithm 98enum MHD_GNUTLS_HashAlgorithm
99gnutls_mac_get (mhd_gtls_session_t session) 99MHD_gnutls_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 * MHD_gnutls_compression_get - Returns the currently used compression algorithm.
106 * @session: is a #mhd_gtls_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 **/
110enum MHD_GNUTLS_CompressionMethod 110enum MHD_GNUTLS_CompressionMethod
111MHD_gtls_compression_get (mhd_gtls_session_t session) 111MHD_gtls_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,18 +118,18 @@ MHD_gtls_compression_get (mhd_gtls_session_t session)
118 * and a matching certificate exists. 118 * and a matching certificate exists.
119 */ 119 */
120int 120int
121mhd_gtls_session_cert_type_supported (mhd_gtls_session_t session, 121MHD_gtls_session_cert_type_supported (MHD_gtls_session_t session,
122 enum MHD_GNUTLS_CertificateType 122 enum MHD_GNUTLS_CertificateType
123 cert_type) 123 cert_type)
124{ 124{
125 unsigned i; 125 unsigned i;
126 unsigned cert_found = 0; 126 unsigned cert_found = 0;
127 mhd_gtls_cert_credentials_t cred; 127 MHD_gtls_cert_credentials_t cred;
128 128
129 if (session->security_parameters.entity == GNUTLS_SERVER) 129 if (session->security_parameters.entity == GNUTLS_SERVER)
130 { 130 {
131 cred 131 cred
132 = (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key, 132 = (MHD_gtls_cert_credentials_t) MHD_gtls_get_cred (session->key,
133 MHD_GNUTLS_CRD_CERTIFICATE, 133 MHD_GNUTLS_CRD_CERTIFICATE,
134 NULL); 134 NULL);
135 135
@@ -173,13 +173,13 @@ mhd_gtls_session_cert_type_supported (mhd_gtls_session_t session,
173 * in a session struct. 173 * in a session struct.
174 */ 174 */
175inline static void 175inline static void
176deinit_internal_params (mhd_gtls_session_t session) 176deinit_internal_params (MHD_gtls_session_t session)
177{ 177{
178 if (session->internals.params.free_dh_params) 178 if (session->internals.params.free_dh_params)
179 MHD_gnutls_dh_params_deinit (session->internals.params.dh_params); 179 MHD__gnutls_dh_params_deinit (session->internals.params.dh_params);
180 180
181 if (session->internals.params.free_rsa_params) 181 if (session->internals.params.free_rsa_params)
182 MHD_gnutls_rsa_params_deinit (session->internals.params.rsa_params); 182 MHD__gnutls_rsa_params_deinit (session->internals.params.rsa_params);
183 183
184 memset (&session->internals.params, 0, sizeof (session->internals.params)); 184 memset (&session->internals.params, 0, sizeof (session->internals.params));
185} 185}
@@ -189,7 +189,7 @@ deinit_internal_params (mhd_gtls_session_t session)
189 * This is used to allow further handshakes. 189 * This is used to allow further handshakes.
190 */ 190 */
191void 191void
192mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t session) 192MHD_gtls_handshake_internal_state_clear (MHD_gtls_session_t session)
193{ 193{
194 session->internals.extensions_sent_size = 0; 194 session->internals.extensions_sent_size = 0;
195 195
@@ -199,7 +199,7 @@ mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t session)
199 session->internals.adv_version_minor = 0; 199 session->internals.adv_version_minor = 0;
200 session->internals.v2_hello = 0; 200 session->internals.v2_hello = 0;
201 memset (&session->internals.handshake_header_buffer, 0, 201 memset (&session->internals.handshake_header_buffer, 0,
202 sizeof (mhd_gtls_handshake_header_buffer_st)); 202 sizeof (MHD_gtls_handshake_header_buffer_st));
203 session->internals.adv_version_minor = 0; 203 session->internals.adv_version_minor = 0;
204 session->internals.adv_version_minor = 0; 204 session->internals.adv_version_minor = 0;
205 session->internals.direction = 0; 205 session->internals.direction = 0;
@@ -211,7 +211,7 @@ mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t session)
211 session->internals.last_handshake_out = -1; 211 session->internals.last_handshake_out = -1;
212 212
213 session->internals.resumable = RESUME_TRUE; 213 session->internals.resumable = RESUME_TRUE;
214 _gnutls_free_datum (&session->internals.recv_buffer); 214 MHD__gnutls_free_datum (&session->internals.recv_buffer);
215 215
216 deinit_internal_params (session); 216 deinit_internal_params (session);
217 217
@@ -219,14 +219,14 @@ mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t session)
219 219
220#define MIN_DH_BITS 727 220#define MIN_DH_BITS 727
221/** 221/**
222 * MHD_gnutls_init - This function initializes the session to null (null encryption etc...). 222 * MHD__gnutls_init - This function initializes the session to null (null encryption etc...).
223 * @con_end: indicate if this session is to be used for server or client. 223 * @con_end: indicate if this session is to be used for server or client.
224 * @session: is a pointer to a #mhd_gtls_session_t structure. 224 * @session: is a pointer to a #MHD_gtls_session_t structure.
225 * 225 *
226 * This function initializes the current session to null. Every 226 * This function initializes the current session to null. Every
227 * session must be initialized before use, so internal structures can 227 * session must be initialized before use, so internal structures can
228 * be allocated. This function allocates structures which can only 228 * be allocated. This function allocates structures which can only
229 * be free'd by calling MHD_gnutls_deinit(). Returns zero on success. 229 * be free'd by calling MHD__gnutls_deinit(). Returns zero on success.
230 * 230 *
231 * @con_end can be one of %GNUTLS_CLIENT and %GNUTLS_SERVER. 231 * @con_end can be one of %GNUTLS_CLIENT and %GNUTLS_SERVER.
232 * 232 *
@@ -235,10 +235,10 @@ mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t session)
235 235
236/* TODO rm redundent pointer ref */ 236/* TODO rm redundent pointer ref */
237int 237int
238MHD_gnutls_init (mhd_gtls_session_t * session, 238MHD__gnutls_init (MHD_gtls_session_t * session,
239 gnutls_connection_end_t con_end) 239 MHD_gnutls_connection_end_t con_end)
240{ 240{
241 *session = gnutls_calloc (1, sizeof (struct MHD_gtls_session_int)); 241 *session = MHD_gnutls_calloc (1, sizeof (struct MHD_gtls_session_int));
242 if (*session == NULL) 242 if (*session == NULL)
243 return GNUTLS_E_MEMORY_ERROR; 243 return GNUTLS_E_MEMORY_ERROR;
244 244
@@ -263,32 +263,32 @@ MHD_gnutls_init (mhd_gtls_session_t * session,
263 (*session)->internals.enable_private = 0; 263 (*session)->internals.enable_private = 0;
264 264
265 /* Initialize buffers */ 265 /* Initialize buffers */
266 mhd_gtls_buffer_init (&(*session)->internals.application_data_buffer); 266 MHD_gtls_buffer_init (&(*session)->internals.application_data_buffer);
267 mhd_gtls_buffer_init (&(*session)->internals.handshake_data_buffer); 267 MHD_gtls_buffer_init (&(*session)->internals.handshake_data_buffer);
268 mhd_gtls_buffer_init (&(*session)->internals.handshake_hash_buffer); 268 MHD_gtls_buffer_init (&(*session)->internals.handshake_hash_buffer);
269 mhd_gtls_buffer_init (&(*session)->internals.ia_data_buffer); 269 MHD_gtls_buffer_init (&(*session)->internals.ia_data_buffer);
270 270
271 mhd_gtls_buffer_init (&(*session)->internals.record_send_buffer); 271 MHD_gtls_buffer_init (&(*session)->internals.record_send_buffer);
272 mhd_gtls_buffer_init (&(*session)->internals.record_recv_buffer); 272 MHD_gtls_buffer_init (&(*session)->internals.record_recv_buffer);
273 273
274 mhd_gtls_buffer_init (&(*session)->internals.handshake_send_buffer); 274 MHD_gtls_buffer_init (&(*session)->internals.handshake_send_buffer);
275 mhd_gtls_buffer_init (&(*session)->internals.handshake_recv_buffer); 275 MHD_gtls_buffer_init (&(*session)->internals.handshake_recv_buffer);
276 276
277 (*session)->key = gnutls_calloc (1, sizeof (struct mhd_gtls_key)); 277 (*session)->key = MHD_gnutls_calloc (1, sizeof (struct MHD_gtls_key));
278 if ((*session)->key == NULL) 278 if ((*session)->key == NULL)
279 { 279 {
280 cleanup_session:gnutls_free (*session); 280 cleanup_session:MHD_gnutls_free (*session);
281 *session = NULL; 281 *session = NULL;
282 return GNUTLS_E_MEMORY_ERROR; 282 return GNUTLS_E_MEMORY_ERROR;
283 } 283 }
284 284
285 (*session)->internals.expire_time = DEFAULT_EXPIRE_TIME; /* one hour default */ 285 (*session)->internals.expire_time = DEFAULT_EXPIRE_TIME; /* one hour default */
286 286
287 MHD_gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS); 287 MHD__gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS);
288 288
289 MHD_gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */ 289 MHD__gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */
290 290
291 MHD_gnutls_handshake_set_max_packet_length ((*session), 291 MHD__gnutls_handshake_set_max_packet_length ((*session),
292 MAX_HANDSHAKE_PACKET_SIZE); 292 MAX_HANDSHAKE_PACKET_SIZE);
293 293
294 /* Allocate a minimum size for recv_data 294 /* Allocate a minimum size for recv_data
@@ -296,16 +296,16 @@ MHD_gnutls_init (mhd_gtls_session_t * session,
296 * the receive procedure slow. 296 * the receive procedure slow.
297 */ 297 */
298 (*session)->internals.record_recv_buffer.data 298 (*session)->internals.record_recv_buffer.data
299 = gnutls_malloc (INITIAL_RECV_BUFFER_SIZE); 299 = MHD_gnutls_malloc (INITIAL_RECV_BUFFER_SIZE);
300 if ((*session)->internals.record_recv_buffer.data == NULL) 300 if ((*session)->internals.record_recv_buffer.data == NULL)
301 { 301 {
302 gnutls_free ((*session)->key); 302 MHD_gnutls_free ((*session)->key);
303 goto cleanup_session; 303 goto cleanup_session;
304 } 304 }
305 305
306 /* set the socket pointers to -1; */ 306 /* set the socket pointers to -1; */
307 (*session)->internals.transport_recv_ptr = (gnutls_transport_ptr_t) - 1; 307 (*session)->internals.transport_recv_ptr = (MHD_gnutls_transport_ptr_t) - 1;
308 (*session)->internals.transport_send_ptr = (gnutls_transport_ptr_t) - 1; 308 (*session)->internals.transport_send_ptr = (MHD_gnutls_transport_ptr_t) - 1;
309 309
310 /* set the default maximum record size for TLS 310 /* set the default maximum record size for TLS
311 */ 311 */
@@ -318,7 +318,7 @@ MHD_gnutls_init (mhd_gtls_session_t * session,
318 * as NULL or 0. This is why calloc is used. 318 * as NULL or 0. This is why calloc is used.
319 */ 319 */
320 320
321 mhd_gtls_handshake_internal_state_clear (*session); 321 MHD_gtls_handshake_internal_state_clear (*session);
322 322
323 return 0; 323 return 0;
324} 324}
@@ -326,113 +326,113 @@ MHD_gnutls_init (mhd_gtls_session_t * session,
326/* returns RESUME_FALSE or RESUME_TRUE. 326/* returns RESUME_FALSE or RESUME_TRUE.
327 */ 327 */
328int 328int
329mhd_gtls_session_is_resumable (mhd_gtls_session_t session) 329MHD_gtls_session_is_resumable (MHD_gtls_session_t session)
330{ 330{
331 return session->internals.resumable; 331 return session->internals.resumable;
332} 332}
333 333
334/** 334/**
335 * MHD_gnutls_deinit - This function clears all buffers associated with a session 335 * MHD__gnutls_deinit - This function clears all buffers associated with a session
336 * @session: is a #mhd_gtls_session_t structure. 336 * @session: is a #MHD_gtls_session_t structure.
337 * 337 *
338 * This function clears all buffers associated with the @session. 338 * This function clears all buffers associated with the @session.
339 * This function will also remove session data from the session 339 * This function will also remove session data from the session
340 * database if the session was terminated abnormally. 340 * database if the session was terminated abnormally.
341 **/ 341 **/
342void 342void
343MHD_gnutls_deinit (mhd_gtls_session_t session) 343MHD__gnutls_deinit (MHD_gtls_session_t session)
344{ 344{
345 345
346 if (session == NULL) 346 if (session == NULL)
347 return; 347 return;
348 348
349 /* remove auth info firstly */ 349 /* remove auth info firstly */
350 mhd_gtls_free_auth_info (session); 350 MHD_gtls_free_auth_info (session);
351 351
352 mhd_gtls_handshake_internal_state_clear (session); 352 MHD_gtls_handshake_internal_state_clear (session);
353 _gnutls_handshake_io_buffer_clear (session); 353 MHD__gnutls_handshake_io_buffer_clear (session);
354 354
355 _gnutls_free_datum (&session->connection_state.read_mac_secret); 355 MHD__gnutls_free_datum (&session->connection_state.read_mac_secret);
356 _gnutls_free_datum (&session->connection_state.write_mac_secret); 356 MHD__gnutls_free_datum (&session->connection_state.write_mac_secret);
357 357
358 mhd_gtls_buffer_clear (&session->internals.ia_data_buffer); 358 MHD_gtls_buffer_clear (&session->internals.ia_data_buffer);
359 mhd_gtls_buffer_clear (&session->internals.handshake_hash_buffer); 359 MHD_gtls_buffer_clear (&session->internals.handshake_hash_buffer);
360 mhd_gtls_buffer_clear (&session->internals.handshake_data_buffer); 360 MHD_gtls_buffer_clear (&session->internals.handshake_data_buffer);
361 mhd_gtls_buffer_clear (&session->internals.application_data_buffer); 361 MHD_gtls_buffer_clear (&session->internals.application_data_buffer);
362 mhd_gtls_buffer_clear (&session->internals.record_recv_buffer); 362 MHD_gtls_buffer_clear (&session->internals.record_recv_buffer);
363 mhd_gtls_buffer_clear (&session->internals.record_send_buffer); 363 MHD_gtls_buffer_clear (&session->internals.record_send_buffer);
364 364
365 MHD_gnutls_credentials_clear (session); 365 MHD__gnutls_credentials_clear (session);
366 mhd_gtls_selected_certs_deinit (session); 366 MHD_gtls_selected_certs_deinit (session);
367 367
368 if (session->connection_state.read_cipher_state != NULL) 368 if (session->connection_state.read_cipher_state != NULL)
369 mhd_gnutls_cipher_deinit (session->connection_state.read_cipher_state); 369 MHD_gnutls_cipher_deinit (session->connection_state.read_cipher_state);
370 if (session->connection_state.write_cipher_state != NULL) 370 if (session->connection_state.write_cipher_state != NULL)
371 mhd_gnutls_cipher_deinit (session->connection_state.write_cipher_state); 371 MHD_gnutls_cipher_deinit (session->connection_state.write_cipher_state);
372 372
373 if (session->connection_state.read_compression_state != NULL) 373 if (session->connection_state.read_compression_state != NULL)
374 mhd_gtls_comp_deinit (session->connection_state.read_compression_state, 374 MHD_gtls_comp_deinit (session->connection_state.read_compression_state,
375 1); 375 1);
376 if (session->connection_state.write_compression_state != NULL) 376 if (session->connection_state.write_compression_state != NULL)
377 mhd_gtls_comp_deinit (session->connection_state.write_compression_state, 377 MHD_gtls_comp_deinit (session->connection_state.write_compression_state,
378 0); 378 0);
379 379
380 _gnutls_free_datum (&session->cipher_specs.server_write_mac_secret); 380 MHD__gnutls_free_datum (&session->cipher_specs.server_write_mac_secret);
381 _gnutls_free_datum (&session->cipher_specs.client_write_mac_secret); 381 MHD__gnutls_free_datum (&session->cipher_specs.client_write_mac_secret);
382 _gnutls_free_datum (&session->cipher_specs.server_write_IV); 382 MHD__gnutls_free_datum (&session->cipher_specs.server_write_IV);
383 _gnutls_free_datum (&session->cipher_specs.client_write_IV); 383 MHD__gnutls_free_datum (&session->cipher_specs.client_write_IV);
384 _gnutls_free_datum (&session->cipher_specs.server_write_key); 384 MHD__gnutls_free_datum (&session->cipher_specs.server_write_key);
385 _gnutls_free_datum (&session->cipher_specs.client_write_key); 385 MHD__gnutls_free_datum (&session->cipher_specs.client_write_key);
386 386
387 if (session->key != NULL) 387 if (session->key != NULL)
388 { 388 {
389 mhd_gtls_mpi_release (&session->key->KEY); 389 MHD_gtls_mpi_release (&session->key->KEY);
390 mhd_gtls_mpi_release (&session->key->client_Y); 390 MHD_gtls_mpi_release (&session->key->client_Y);
391 mhd_gtls_mpi_release (&session->key->client_p); 391 MHD_gtls_mpi_release (&session->key->client_p);
392 mhd_gtls_mpi_release (&session->key->client_g); 392 MHD_gtls_mpi_release (&session->key->client_g);
393 393
394 mhd_gtls_mpi_release (&session->key->u); 394 MHD_gtls_mpi_release (&session->key->u);
395 mhd_gtls_mpi_release (&session->key->a); 395 MHD_gtls_mpi_release (&session->key->a);
396 mhd_gtls_mpi_release (&session->key->x); 396 MHD_gtls_mpi_release (&session->key->x);
397 mhd_gtls_mpi_release (&session->key->A); 397 MHD_gtls_mpi_release (&session->key->A);
398 mhd_gtls_mpi_release (&session->key->B); 398 MHD_gtls_mpi_release (&session->key->B);
399 mhd_gtls_mpi_release (&session->key->b); 399 MHD_gtls_mpi_release (&session->key->b);
400 400
401 /* RSA */ 401 /* RSA */
402 mhd_gtls_mpi_release (&session->key->rsa[0]); 402 MHD_gtls_mpi_release (&session->key->rsa[0]);
403 mhd_gtls_mpi_release (&session->key->rsa[1]); 403 MHD_gtls_mpi_release (&session->key->rsa[1]);
404 404
405 mhd_gtls_mpi_release (&session->key->dh_secret); 405 MHD_gtls_mpi_release (&session->key->dh_secret);
406 gnutls_free (session->key); 406 MHD_gnutls_free (session->key);
407 407
408 session->key = NULL; 408 session->key = NULL;
409 } 409 }
410 410
411 gnutls_free (session->internals.srp_username); 411 MHD_gnutls_free (session->internals.srp_username);
412 412
413 if (session->internals.srp_password) 413 if (session->internals.srp_password)
414 { 414 {
415 memset (session->internals.srp_password, 0, 415 memset (session->internals.srp_password, 0,
416 strlen (session->internals.srp_password)); 416 strlen (session->internals.srp_password));
417 gnutls_free (session->internals.srp_password); 417 MHD_gnutls_free (session->internals.srp_password);
418 } 418 }
419 419
420 memset (session, 0, sizeof (struct MHD_gtls_session_int)); 420 memset (session, 0, sizeof (struct MHD_gtls_session_int));
421 gnutls_free (session); 421 MHD_gnutls_free (session);
422} 422}
423 423
424/* Returns the minimum prime bits that are acceptable. 424/* Returns the minimum prime bits that are acceptable.
425 */ 425 */
426int 426int
427mhd_gtls_dh_get_allowed_prime_bits (mhd_gtls_session_t session) 427MHD_gtls_dh_get_allowed_prime_bits (MHD_gtls_session_t session)
428{ 428{
429 return session->internals.dh_prime_bits; 429 return session->internals.dh_prime_bits;
430} 430}
431 431
432int 432int
433mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public) 433MHD_gtls_dh_set_peer_public (MHD_gtls_session_t session, mpi_t public)
434{ 434{
435 mhd_gtls_dh_info_st *dh; 435 MHD_gtls_dh_info_st *dh;
436 int ret; 436 int ret;
437 437
438 switch (MHD_gtls_auth_get_type (session)) 438 switch (MHD_gtls_auth_get_type (session))
@@ -440,7 +440,7 @@ mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public)
440 case MHD_GNUTLS_CRD_ANON: 440 case MHD_GNUTLS_CRD_ANON:
441 { 441 {
442 mhd_anon_auth_info_t info; 442 mhd_anon_auth_info_t info;
443 info = mhd_gtls_get_auth_info (session); 443 info = MHD_gtls_get_auth_info (session);
444 if (info == NULL) 444 if (info == NULL)
445 return GNUTLS_E_INTERNAL_ERROR; 445 return GNUTLS_E_INTERNAL_ERROR;
446 446
@@ -451,7 +451,7 @@ mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public)
451 { 451 {
452 cert_auth_info_t info; 452 cert_auth_info_t info;
453 453
454 info = mhd_gtls_get_auth_info (session); 454 info = MHD_gtls_get_auth_info (session);
455 if (info == NULL) 455 if (info == NULL)
456 return GNUTLS_E_INTERNAL_ERROR; 456 return GNUTLS_E_INTERNAL_ERROR;
457 457
@@ -459,14 +459,14 @@ mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public)
459 break; 459 break;
460 } 460 }
461 default: 461 default:
462 gnutls_assert (); 462 MHD_gnutls_assert ();
463 return GNUTLS_E_INTERNAL_ERROR; 463 return GNUTLS_E_INTERNAL_ERROR;
464 } 464 }
465 465
466 ret = mhd_gtls_mpi_dprint_lz (&dh->public_key, public); 466 ret = MHD_gtls_mpi_dprint_lz (&dh->public_key, public);
467 if (ret < 0) 467 if (ret < 0)
468 { 468 {
469 gnutls_assert (); 469 MHD_gnutls_assert ();
470 return ret; 470 return ret;
471 } 471 }
472 472
@@ -474,14 +474,14 @@ mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public)
474} 474}
475 475
476int 476int
477mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits) 477MHD_gtls_dh_set_secret_bits (MHD_gtls_session_t session, unsigned bits)
478{ 478{
479 switch (MHD_gtls_auth_get_type (session)) 479 switch (MHD_gtls_auth_get_type (session))
480 { 480 {
481 case MHD_GNUTLS_CRD_ANON: 481 case MHD_GNUTLS_CRD_ANON:
482 { 482 {
483 mhd_anon_auth_info_t info; 483 mhd_anon_auth_info_t info;
484 info = mhd_gtls_get_auth_info (session); 484 info = MHD_gtls_get_auth_info (session);
485 if (info == NULL) 485 if (info == NULL)
486 return GNUTLS_E_INTERNAL_ERROR; 486 return GNUTLS_E_INTERNAL_ERROR;
487 info->dh.secret_bits = bits; 487 info->dh.secret_bits = bits;
@@ -491,14 +491,14 @@ mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits)
491 { 491 {
492 cert_auth_info_t info; 492 cert_auth_info_t info;
493 493
494 info = mhd_gtls_get_auth_info (session); 494 info = MHD_gtls_get_auth_info (session);
495 if (info == NULL) 495 if (info == NULL)
496 return GNUTLS_E_INTERNAL_ERROR; 496 return GNUTLS_E_INTERNAL_ERROR;
497 497
498 info->dh.secret_bits = bits; 498 info->dh.secret_bits = bits;
499 break; 499 break;
500 default: 500 default:
501 gnutls_assert (); 501 MHD_gnutls_assert ();
502 return GNUTLS_E_INTERNAL_ERROR; 502 return GNUTLS_E_INTERNAL_ERROR;
503 } 503 }
504 } 504 }
@@ -510,28 +510,28 @@ mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits)
510 * RSA exponent and the modulus. 510 * RSA exponent and the modulus.
511 */ 511 */
512int 512int
513mhd_gtls_rsa_export_set_pubkey (mhd_gtls_session_t session, 513MHD_gtls_rsa_export_set_pubkey (MHD_gtls_session_t session,
514 mpi_t exponent, mpi_t modulus) 514 mpi_t exponent, mpi_t modulus)
515{ 515{
516 cert_auth_info_t info; 516 cert_auth_info_t info;
517 int ret; 517 int ret;
518 518
519 info = mhd_gtls_get_auth_info (session); 519 info = MHD_gtls_get_auth_info (session);
520 if (info == NULL) 520 if (info == NULL)
521 return GNUTLS_E_INTERNAL_ERROR; 521 return GNUTLS_E_INTERNAL_ERROR;
522 522
523 ret = mhd_gtls_mpi_dprint_lz (&info->rsa_export.modulus, modulus); 523 ret = MHD_gtls_mpi_dprint_lz (&info->rsa_export.modulus, modulus);
524 if (ret < 0) 524 if (ret < 0)
525 { 525 {
526 gnutls_assert (); 526 MHD_gnutls_assert ();
527 return ret; 527 return ret;
528 } 528 }
529 529
530 ret = mhd_gtls_mpi_dprint_lz (&info->rsa_export.exponent, exponent); 530 ret = MHD_gtls_mpi_dprint_lz (&info->rsa_export.exponent, exponent);
531 if (ret < 0) 531 if (ret < 0)
532 { 532 {
533 gnutls_assert (); 533 MHD_gnutls_assert ();
534 _gnutls_free_datum (&info->rsa_export.modulus); 534 MHD__gnutls_free_datum (&info->rsa_export.modulus);
535 return ret; 535 return ret;
536 } 536 }
537 537
@@ -541,9 +541,9 @@ mhd_gtls_rsa_export_set_pubkey (mhd_gtls_session_t session,
541/* Sets the prime and the generator in the auth info structure. 541/* Sets the prime and the generator in the auth info structure.
542 */ 542 */
543int 543int
544mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime) 544MHD_gtls_dh_set_group (MHD_gtls_session_t session, mpi_t gen, mpi_t prime)
545{ 545{
546 mhd_gtls_dh_info_st *dh; 546 MHD_gtls_dh_info_st *dh;
547 int ret; 547 int ret;
548 548
549 switch (MHD_gtls_auth_get_type (session)) 549 switch (MHD_gtls_auth_get_type (session))
@@ -551,7 +551,7 @@ mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime)
551 case MHD_GNUTLS_CRD_ANON: 551 case MHD_GNUTLS_CRD_ANON:
552 { 552 {
553 mhd_anon_auth_info_t info; 553 mhd_anon_auth_info_t info;
554 info = mhd_gtls_get_auth_info (session); 554 info = MHD_gtls_get_auth_info (session);
555 if (info == NULL) 555 if (info == NULL)
556 return GNUTLS_E_INTERNAL_ERROR; 556 return GNUTLS_E_INTERNAL_ERROR;
557 557
@@ -562,7 +562,7 @@ mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime)
562 { 562 {
563 cert_auth_info_t info; 563 cert_auth_info_t info;
564 564
565 info = mhd_gtls_get_auth_info (session); 565 info = MHD_gtls_get_auth_info (session);
566 if (info == NULL) 566 if (info == NULL)
567 return GNUTLS_E_INTERNAL_ERROR; 567 return GNUTLS_E_INTERNAL_ERROR;
568 568
@@ -570,26 +570,26 @@ mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime)
570 break; 570 break;
571 } 571 }
572 default: 572 default:
573 gnutls_assert (); 573 MHD_gnutls_assert ();
574 return GNUTLS_E_INTERNAL_ERROR; 574 return GNUTLS_E_INTERNAL_ERROR;
575 } 575 }
576 576
577 /* prime 577 /* prime
578 */ 578 */
579 ret = mhd_gtls_mpi_dprint_lz (&dh->prime, prime); 579 ret = MHD_gtls_mpi_dprint_lz (&dh->prime, prime);
580 if (ret < 0) 580 if (ret < 0)
581 { 581 {
582 gnutls_assert (); 582 MHD_gnutls_assert ();
583 return ret; 583 return ret;
584 } 584 }
585 585
586 /* generator 586 /* generator
587 */ 587 */
588 ret = mhd_gtls_mpi_dprint_lz (&dh->generator, gen); 588 ret = MHD_gtls_mpi_dprint_lz (&dh->generator, gen);
589 if (ret < 0) 589 if (ret < 0)
590 { 590 {
591 gnutls_assert (); 591 MHD_gnutls_assert ();
592 _gnutls_free_datum (&dh->prime); 592 MHD__gnutls_free_datum (&dh->prime);
593 return ret; 593 return ret;
594 } 594 }
595 595
@@ -597,8 +597,8 @@ mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime)
597} 597}
598 598
599/** 599/**
600 * MHD_gnutls_certificate_send_x509_rdn_sequence - This function will order gnutls to send or not the x.509 rdn sequence 600 * MHD__gnutls_certificate_send_x509_rdn_sequence - This function will order gnutls to send or not the x.509 rdn sequence
601 * @session: is a pointer to a #mhd_gtls_session_t structure. 601 * @session: is a pointer to a #MHD_gtls_session_t structure.
602 * @status: is 0 or 1 602 * @status: is 0 or 1
603 * 603 *
604 * If status is non zero, this function will order gnutls not to send 604 * If status is non zero, this function will order gnutls not to send
@@ -611,15 +611,15 @@ mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, mpi_t prime)
611 * methods other than certificate with X.509 certificates. 611 * methods other than certificate with X.509 certificates.
612 **/ 612 **/
613void 613void
614MHD_gnutls_certificate_send_x509_rdn_sequence (mhd_gtls_session_t session, 614MHD__gnutls_certificate_send_x509_rdn_sequence (MHD_gtls_session_t session,
615 int status) 615 int status)
616{ 616{
617 session->internals.ignore_rdn_sequence = status; 617 session->internals.ignore_rdn_sequence = status;
618} 618}
619 619
620/*- 620/*-
621 * _gnutls_record_set_default_version - Used to set the default version for the first record packet 621 * MHD__gnutls_record_set_default_version - Used to set the default version for the first record packet
622 * @session: is a #mhd_gtls_session_t structure. 622 * @session: is a #MHD_gtls_session_t structure.
623 * @major: is a tls major version 623 * @major: is a tls major version
624 * @minor: is a tls minor version 624 * @minor: is a tls minor version
625 * 625 *
@@ -629,7 +629,7 @@ MHD_gnutls_certificate_send_x509_rdn_sequence (mhd_gtls_session_t session,
629 * 629 *
630 -*/ 630 -*/
631void 631void
632_gnutls_record_set_default_version (mhd_gtls_session_t session, 632MHD__gnutls_record_set_default_version (MHD_gtls_session_t session,
633 unsigned char major, unsigned char minor) 633 unsigned char major, unsigned char minor)
634{ 634{
635 session->internals.default_record_version[0] = major; 635 session->internals.default_record_version[0] = major;
@@ -638,7 +638,7 @@ _gnutls_record_set_default_version (mhd_gtls_session_t session,
638 638
639/** 639/**
640 * MHD_gtls_handshake_set_private_extensions - Used to enable the private cipher suites 640 * MHD_gtls_handshake_set_private_extensions - Used to enable the private cipher suites
641 * @session: is a #mhd_gtls_session_t structure. 641 * @session: is a #MHD_gtls_session_t structure.
642 * @allow: is an integer (0 or 1) 642 * @allow: is an integer (0 or 1)
643 * 643 *
644 * This function will enable or disable the use of private cipher 644 * This function will enable or disable the use of private cipher
@@ -653,29 +653,29 @@ _gnutls_record_set_default_version (mhd_gtls_session_t session,
653 * gnutls servers and clients may cause interoperability problems. 653 * gnutls servers and clients may cause interoperability problems.
654 **/ 654 **/
655void 655void
656MHD_gtls_handshake_set_private_extensions (mhd_gtls_session_t session, 656MHD_gtls_handshake_set_private_extensions (MHD_gtls_session_t session,
657 int allow) 657 int allow)
658{ 658{
659 session->internals.enable_private = allow; 659 session->internals.enable_private = allow;
660} 660}
661 661
662inline static int 662inline static int
663_gnutls_cal_PRF_A (enum MHD_GNUTLS_HashAlgorithm algorithm, 663MHD__gnutls_cal_PRF_A (enum MHD_GNUTLS_HashAlgorithm algorithm,
664 const void *secret, 664 const void *secret,
665 int secret_size, 665 int secret_size,
666 const void *seed, int seed_size, void *result) 666 const void *seed, int seed_size, void *result)
667{ 667{
668 mac_hd_t td1; 668 mac_hd_t td1;
669 669
670 td1 = mhd_gtls_hmac_init (algorithm, secret, secret_size); 670 td1 = MHD_gtls_MHD_hmac_init (algorithm, secret, secret_size);
671 if (td1 == GNUTLS_MAC_FAILED) 671 if (td1 == GNUTLS_MAC_FAILED)
672 { 672 {
673 gnutls_assert (); 673 MHD_gnutls_assert ();
674 return GNUTLS_E_INTERNAL_ERROR; 674 return GNUTLS_E_INTERNAL_ERROR;
675 } 675 }
676 676
677 mhd_gnutls_hash (td1, seed, seed_size); 677 MHD_gnutls_hash (td1, seed, seed_size);
678 mhd_gnutls_hmac_deinit (td1, result); 678 MHD_gnutls_MHD_hmac_deinit (td1, result);
679 679
680 return 0; 680 return 0;
681} 681}
@@ -686,7 +686,7 @@ _gnutls_cal_PRF_A (enum MHD_GNUTLS_HashAlgorithm algorithm,
686 * (used in the PRF function) 686 * (used in the PRF function)
687 */ 687 */
688static int 688static int
689_gnutls_P_hash (enum MHD_GNUTLS_HashAlgorithm algorithm, 689MHD__gnutls_P_hash (enum MHD_GNUTLS_HashAlgorithm algorithm,
690 const opaque * secret, 690 const opaque * secret,
691 int secret_size, 691 int secret_size,
692 const opaque * seed, 692 const opaque * seed,
@@ -700,11 +700,11 @@ _gnutls_P_hash (enum MHD_GNUTLS_HashAlgorithm algorithm,
700 700
701 if (seed_size > MAX_SEED_SIZE || total_bytes <= 0) 701 if (seed_size > MAX_SEED_SIZE || total_bytes <= 0)
702 { 702 {
703 gnutls_assert (); 703 MHD_gnutls_assert ();
704 return GNUTLS_E_INTERNAL_ERROR; 704 return GNUTLS_E_INTERNAL_ERROR;
705 } 705 }
706 706
707 blocksize = mhd_gnutls_hash_get_algo_len (algorithm); 707 blocksize = MHD_gnutls_hash_get_algo_len (algorithm);
708 708
709 output_bytes = 0; 709 output_bytes = 0;
710 do 710 do
@@ -722,27 +722,27 @@ _gnutls_P_hash (enum MHD_GNUTLS_HashAlgorithm algorithm,
722 722
723 for (i = 0; i < times; i++) 723 for (i = 0; i < times; i++)
724 { 724 {
725 td2 = mhd_gtls_hmac_init (algorithm, secret, secret_size); 725 td2 = MHD_gtls_MHD_hmac_init (algorithm, secret, secret_size);
726 if (td2 == GNUTLS_MAC_FAILED) 726 if (td2 == GNUTLS_MAC_FAILED)
727 { 727 {
728 gnutls_assert (); 728 MHD_gnutls_assert ();
729 return GNUTLS_E_INTERNAL_ERROR; 729 return GNUTLS_E_INTERNAL_ERROR;
730 } 730 }
731 731
732 /* here we calculate A(i+1) */ 732 /* here we calculate A(i+1) */
733 if ((result = _gnutls_cal_PRF_A (algorithm, secret, secret_size, Atmp, 733 if ((result = MHD__gnutls_cal_PRF_A (algorithm, secret, secret_size, Atmp,
734 A_size, Atmp)) < 0) 734 A_size, Atmp)) < 0)
735 { 735 {
736 gnutls_assert (); 736 MHD_gnutls_assert ();
737 mhd_gnutls_hmac_deinit (td2, final); 737 MHD_gnutls_MHD_hmac_deinit (td2, final);
738 return result; 738 return result;
739 } 739 }
740 740
741 A_size = blocksize; 741 A_size = blocksize;
742 742
743 mhd_gnutls_hash (td2, Atmp, A_size); 743 MHD_gnutls_hash (td2, Atmp, A_size);
744 mhd_gnutls_hash (td2, seed, seed_size); 744 MHD_gnutls_hash (td2, seed, seed_size);
745 mhd_gnutls_hmac_deinit (td2, final); 745 MHD_gnutls_MHD_hmac_deinit (td2, final);
746 746
747 if ((1 + i) * blocksize < total_bytes) 747 if ((1 + i) * blocksize < total_bytes)
748 { 748 {
@@ -765,7 +765,7 @@ _gnutls_P_hash (enum MHD_GNUTLS_HashAlgorithm algorithm,
765/* Xor's two buffers and puts the output in the first one. 765/* Xor's two buffers and puts the output in the first one.
766 */ 766 */
767inline static void 767inline static void
768_gnutls_xor (opaque * o1, opaque * o2, int length) 768MHD__gnutls_xor (opaque * o1, opaque * o2, int length)
769{ 769{
770 int i; 770 int i;
771 for (i = 0; i < length; i++) 771 for (i = 0; i < length; i++)
@@ -781,7 +781,7 @@ _gnutls_xor (opaque * o1, opaque * o2, int length)
781 * available. 781 * available.
782 */ 782 */
783int 783int
784mhd_gtls_PRF (mhd_gtls_session_t session, 784MHD_gtls_PRF (MHD_gtls_session_t session,
785 const opaque * secret, 785 const opaque * secret,
786 int secret_size, 786 int secret_size,
787 const char *label, 787 const char *label,
@@ -793,11 +793,11 @@ mhd_gtls_PRF (mhd_gtls_session_t session,
793 opaque s_seed[MAX_SEED_SIZE]; 793 opaque s_seed[MAX_SEED_SIZE];
794 opaque o1[MAX_PRF_BYTES], o2[MAX_PRF_BYTES]; 794 opaque o1[MAX_PRF_BYTES], o2[MAX_PRF_BYTES];
795 int result; 795 int result;
796 enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); 796 enum MHD_GNUTLS_Protocol ver = MHD__gnutls_protocol_get_version (session);
797 797
798 if (total_bytes > MAX_PRF_BYTES) 798 if (total_bytes > MAX_PRF_BYTES)
799 { 799 {
800 gnutls_assert (); 800 MHD_gnutls_assert ();
801 return GNUTLS_E_INTERNAL_ERROR; 801 return GNUTLS_E_INTERNAL_ERROR;
802 } 802 }
803 /* label+seed = s_seed */ 803 /* label+seed = s_seed */
@@ -805,7 +805,7 @@ mhd_gtls_PRF (mhd_gtls_session_t session,
805 805
806 if (s_seed_size > MAX_SEED_SIZE) 806 if (s_seed_size > MAX_SEED_SIZE)
807 { 807 {
808 gnutls_assert (); 808 MHD_gnutls_assert ();
809 return GNUTLS_E_INTERNAL_ERROR; 809 return GNUTLS_E_INTERNAL_ERROR;
810 } 810 }
811 811
@@ -815,11 +815,11 @@ mhd_gtls_PRF (mhd_gtls_session_t session,
815 if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_2) 815 if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_2)
816 { 816 {
817 result = 817 result =
818 _gnutls_P_hash (MHD_GNUTLS_MAC_SHA1, secret, secret_size, s_seed, 818 MHD__gnutls_P_hash (MHD_GNUTLS_MAC_SHA1, secret, secret_size, s_seed,
819 s_seed_size, total_bytes, ret); 819 s_seed_size, total_bytes, ret);
820 if (result < 0) 820 if (result < 0)
821 { 821 {
822 gnutls_assert (); 822 MHD_gnutls_assert ();
823 return result; 823 return result;
824 } 824 }
825 } 825 }
@@ -836,24 +836,24 @@ mhd_gtls_PRF (mhd_gtls_session_t session,
836 } 836 }
837 837
838 result = 838 result =
839 _gnutls_P_hash (MHD_GNUTLS_MAC_MD5, s1, l_s, s_seed, s_seed_size, 839 MHD__gnutls_P_hash (MHD_GNUTLS_MAC_MD5, s1, l_s, s_seed, s_seed_size,
840 total_bytes, o1); 840 total_bytes, o1);
841 if (result < 0) 841 if (result < 0)
842 { 842 {
843 gnutls_assert (); 843 MHD_gnutls_assert ();
844 return result; 844 return result;
845 } 845 }
846 846
847 result = 847 result =
848 _gnutls_P_hash (MHD_GNUTLS_MAC_SHA1, s2, l_s, s_seed, s_seed_size, 848 MHD__gnutls_P_hash (MHD_GNUTLS_MAC_SHA1, s2, l_s, s_seed, s_seed_size,
849 total_bytes, o2); 849 total_bytes, o2);
850 if (result < 0) 850 if (result < 0)
851 { 851 {
852 gnutls_assert (); 852 MHD_gnutls_assert ();
853 return result; 853 return result;
854 } 854 }
855 855
856 _gnutls_xor (o1, o2, total_bytes); 856 MHD__gnutls_xor (o1, o2, total_bytes);
857 857
858 memcpy (ret, o1, total_bytes); 858 memcpy (ret, o1, total_bytes);
859 } 859 }
@@ -863,8 +863,8 @@ mhd_gtls_PRF (mhd_gtls_session_t session,
863} 863}
864 864
865/** 865/**
866 * MHD_gnutls_prf_raw - access the TLS PRF directly 866 * MHD__gnutls_prf_raw - access the TLS PRF directly
867 * @session: is a #mhd_gtls_session_t structure. 867 * @session: is a #MHD_gtls_session_t structure.
868 * @label_size: length of the @label variable. 868 * @label_size: length of the @label variable.
869 * @label: label used in PRF computation, typically a short string. 869 * @label: label used in PRF computation, typically a short string.
870 * @seed_size: length of the @seed variable. 870 * @seed_size: length of the @seed variable.
@@ -885,14 +885,14 @@ mhd_gtls_PRF (mhd_gtls_session_t session,
885 * session unless @seed include the client random and server random 885 * session unless @seed include the client random and server random
886 * fields (the PRF would output the same data on another connection 886 * fields (the PRF would output the same data on another connection
887 * resumed from the first one), it is not recommended to use this 887 * resumed from the first one), it is not recommended to use this
888 * function directly. The MHD_gnutls_prf() function seed the PRF with the 888 * function directly. The MHD__gnutls_prf() function seed the PRF with the
889 * client and server random fields directly, and is recommended if you 889 * client and server random fields directly, and is recommended if you
890 * want to generate pseudo random data unique for each session. 890 * want to generate pseudo random data unique for each session.
891 * 891 *
892 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 892 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
893 **/ 893 **/
894int 894int
895MHD_gnutls_prf_raw (mhd_gtls_session_t session, 895MHD__gnutls_prf_raw (MHD_gtls_session_t session,
896 size_t label_size, 896 size_t label_size,
897 const char *label, 897 const char *label,
898 size_t seed_size, const char *seed, size_t outsize, 898 size_t seed_size, const char *seed, size_t outsize,
@@ -900,7 +900,7 @@ MHD_gnutls_prf_raw (mhd_gtls_session_t session,
900{ 900{
901 int ret; 901 int ret;
902 902
903 ret = mhd_gtls_PRF (session, session->security_parameters.master_secret, 903 ret = MHD_gtls_PRF (session, session->security_parameters.master_secret,
904 TLS_MASTER_SIZE, label, label_size, (opaque *) seed, 904 TLS_MASTER_SIZE, label, label_size, (opaque *) seed,
905 seed_size, outsize, out); 905 seed_size, outsize, out);
906 906
@@ -908,8 +908,8 @@ MHD_gnutls_prf_raw (mhd_gtls_session_t session,
908} 908}
909 909
910/** 910/**
911 * MHD_gnutls_prf - derive pseudo-random data using the TLS PRF 911 * MHD__gnutls_prf - derive pseudo-random data using the TLS PRF
912 * @session: is a #mhd_gtls_session_t structure. 912 * @session: is a #MHD_gtls_session_t structure.
913 * @label_size: length of the @label variable. 913 * @label_size: length of the @label variable.
914 * @label: label used in PRF computation, typically a short string. 914 * @label: label used in PRF computation, typically a short string.
915 * @server_random_first: non-0 if server random field should be first in seed 915 * @server_random_first: non-0 if server random field should be first in seed
@@ -937,7 +937,7 @@ MHD_gnutls_prf_raw (mhd_gtls_session_t session,
937 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 937 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
938 **/ 938 **/
939int 939int
940MHD_gnutls_prf (mhd_gtls_session_t session, 940MHD__gnutls_prf (MHD_gtls_session_t session,
941 size_t label_size, 941 size_t label_size,
942 const char *label, 942 const char *label,
943 int server_random_first, 943 int server_random_first,
@@ -948,10 +948,10 @@ MHD_gnutls_prf (mhd_gtls_session_t session,
948 opaque *seed; 948 opaque *seed;
949 size_t seedsize = 2 * TLS_RANDOM_SIZE + extra_size; 949 size_t seedsize = 2 * TLS_RANDOM_SIZE + extra_size;
950 950
951 seed = gnutls_malloc (seedsize); 951 seed = MHD_gnutls_malloc (seedsize);
952 if (!seed) 952 if (!seed)
953 { 953 {
954 gnutls_assert (); 954 MHD_gnutls_assert ();
955 return GNUTLS_E_MEMORY_ERROR; 955 return GNUTLS_E_MEMORY_ERROR;
956 } 956 }
957 957
@@ -964,18 +964,18 @@ MHD_gnutls_prf (mhd_gtls_session_t session,
964 964
965 memcpy (seed + 2 * TLS_RANDOM_SIZE, extra, extra_size); 965 memcpy (seed + 2 * TLS_RANDOM_SIZE, extra, extra_size);
966 966
967 ret = mhd_gtls_PRF (session, session->security_parameters.master_secret, 967 ret = MHD_gtls_PRF (session, session->security_parameters.master_secret,
968 TLS_MASTER_SIZE, label, label_size, seed, seedsize, 968 TLS_MASTER_SIZE, label, label_size, seed, seedsize,
969 outsize, out); 969 outsize, out);
970 970
971 gnutls_free (seed); 971 MHD_gnutls_free (seed);
972 972
973 return ret; 973 return ret;
974} 974}
975 975
976/** 976/**
977 * MHD_gtls_session_get_client_random - get the session's client random value 977 * MHD_gtls_session_get_client_random - get the session's client random value
978 * @session: is a #mhd_gtls_session_t structure. 978 * @session: is a #MHD_gtls_session_t structure.
979 * 979 *
980 * Return a pointer to the 32-byte client random field used in the 980 * Return a pointer to the 32-byte client random field used in the
981 * session. The pointer must not be modified or deallocated. 981 * session. The pointer must not be modified or deallocated.
@@ -987,14 +987,14 @@ MHD_gnutls_prf (mhd_gtls_session_t session,
987 * Returns: pointer to client random data. 987 * Returns: pointer to client random data.
988 **/ 988 **/
989const void * 989const void *
990MHD_gtls_session_get_client_random (mhd_gtls_session_t session) 990MHD_gtls_session_get_client_random (MHD_gtls_session_t session)
991{ 991{
992 return (char *) session->security_parameters.client_random; 992 return (char *) session->security_parameters.client_random;
993} 993}
994 994
995/** 995/**
996 * MHD_gtls_session_get_server_random - get the session's server random value 996 * MHD_gtls_session_get_server_random - get the session's server random value
997 * @session: is a #mhd_gtls_session_t structure. 997 * @session: is a #MHD_gtls_session_t structure.
998 * 998 *
999 * Return a pointer to the 32-byte server random field used in the 999 * Return a pointer to the 32-byte server random field used in the
1000 * session. The pointer must not be modified or deallocated. 1000 * session. The pointer must not be modified or deallocated.
@@ -1006,14 +1006,14 @@ MHD_gtls_session_get_client_random (mhd_gtls_session_t session)
1006 * Returns: pointer to server random data. 1006 * Returns: pointer to server random data.
1007 **/ 1007 **/
1008const void * 1008const void *
1009MHD_gtls_session_get_server_random (mhd_gtls_session_t session) 1009MHD_gtls_session_get_server_random (MHD_gtls_session_t session)
1010{ 1010{
1011 return (char *) session->security_parameters.server_random; 1011 return (char *) session->security_parameters.server_random;
1012} 1012}
1013 1013
1014/** 1014/**
1015 * MHD_gtls_session_get_master_secret - get the session's master secret value 1015 * MHD_gtls_session_get_master_secret - get the session's master secret value
1016 * @session: is a #mhd_gtls_session_t structure. 1016 * @session: is a #MHD_gtls_session_t structure.
1017 * 1017 *
1018 * Return a pointer to the 48-byte master secret in the session. The 1018 * Return a pointer to the 48-byte master secret in the session. The
1019 * pointer must not be modified or deallocated. 1019 * pointer must not be modified or deallocated.
@@ -1022,26 +1022,26 @@ MHD_gtls_session_get_server_random (mhd_gtls_session_t session)
1022 * will be garbage; in particular, a %NULL return value should not be 1022 * will be garbage; in particular, a %NULL return value should not be
1023 * expected. 1023 * expected.
1024 * 1024 *
1025 * Consider using MHD_gnutls_prf() rather than extracting the master 1025 * Consider using MHD__gnutls_prf() rather than extracting the master
1026 * secret and use it to derive further data. 1026 * secret and use it to derive further data.
1027 * 1027 *
1028 * Returns: pointer to master secret data. 1028 * Returns: pointer to master secret data.
1029 **/ 1029 **/
1030const void * 1030const void *
1031MHD_gtls_session_get_master_secret (mhd_gtls_session_t session) 1031MHD_gtls_session_get_master_secret (MHD_gtls_session_t session)
1032{ 1032{
1033 return (char *) session->security_parameters.master_secret; 1033 return (char *) session->security_parameters.master_secret;
1034} 1034}
1035 1035
1036/** 1036/**
1037 * MHD_gtls_session_is_resumed - Used to check whether this session is a resumed one 1037 * MHD_gtls_session_is_resumed - Used to check whether this session is a resumed one
1038 * @session: is a #mhd_gtls_session_t structure. 1038 * @session: is a #MHD_gtls_session_t structure.
1039 * 1039 *
1040 * Returns: non zero if this session is resumed, or a zero if this is 1040 * Returns: non zero if this session is resumed, or a zero if this is
1041 * a new session. 1041 * a new session.
1042 **/ 1042 **/
1043int 1043int
1044MHD_gtls_session_is_resumed (mhd_gtls_session_t session) 1044MHD_gtls_session_is_resumed (MHD_gtls_session_t session)
1045{ 1045{
1046#if MHD_DEBUG_TLS 1046#if MHD_DEBUG_TLS
1047 if (session->security_parameters.entity == GNUTLS_CLIENT) 1047 if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -1066,22 +1066,22 @@ MHD_gtls_session_is_resumed (mhd_gtls_session_t session)
1066} 1066}
1067 1067
1068/*- 1068/*-
1069 * mhd_gtls_session_is_export - Used to check whether this session is of export grade 1069 * MHD_gtls_session_is_export - Used to check whether this session is of export grade
1070 * @session: is a #mhd_gtls_session_t structure. 1070 * @session: is a #MHD_gtls_session_t structure.
1071 * 1071 *
1072 * This function will return non zero if this session is of export grade. 1072 * This function will return non zero if this session is of export grade.
1073 * 1073 *
1074 -*/ 1074 -*/
1075int 1075int
1076mhd_gtls_session_is_export (mhd_gtls_session_t session) 1076MHD_gtls_session_is_export (MHD_gtls_session_t session)
1077{ 1077{
1078 enum MHD_GNUTLS_CipherAlgorithm cipher; 1078 enum MHD_GNUTLS_CipherAlgorithm cipher;
1079 1079
1080 cipher = 1080 cipher =
1081 mhd_gtls_cipher_suite_get_cipher_algo (&session->security_parameters. 1081 MHD_gtls_cipher_suite_get_cipher_algo (&session->security_parameters.
1082 current_cipher_suite); 1082 current_cipher_suite);
1083 1083
1084 if (mhd_gtls_cipher_get_export_flag (cipher) != 0) 1084 if (MHD_gtls_cipher_get_export_flag (cipher) != 0)
1085 return 1; 1085 return 1;
1086 1086
1087 return 0; 1087 return 0;
@@ -1089,20 +1089,20 @@ mhd_gtls_session_is_export (mhd_gtls_session_t session)
1089 1089
1090/** 1090/**
1091 * MHD_gtls_session_get_ptr - Used to get the user pointer from the session structure 1091 * MHD_gtls_session_get_ptr - Used to get the user pointer from the session structure
1092 * @session: is a #mhd_gtls_session_t structure. 1092 * @session: is a #MHD_gtls_session_t structure.
1093 * 1093 *
1094 * Returns: the user given pointer from the session structure. This 1094 * Returns: the user given pointer from the session structure. This
1095 * is the pointer set with MHD_gnutls_session_set_ptr(). 1095 * is the pointer set with MHD__gnutls_session_set_ptr().
1096 **/ 1096 **/
1097void * 1097void *
1098MHD_gtls_session_get_ptr (mhd_gtls_session_t session) 1098MHD_gtls_session_get_ptr (MHD_gtls_session_t session)
1099{ 1099{
1100 return session->internals.user_ptr; 1100 return session->internals.user_ptr;
1101} 1101}
1102 1102
1103/** 1103/**
1104 * MHD_gnutls_session_set_ptr - Used to set the user pointer to the session structure 1104 * MHD__gnutls_session_set_ptr - Used to set the user pointer to the session structure
1105 * @session: is a #mhd_gtls_session_t structure. 1105 * @session: is a #MHD_gtls_session_t structure.
1106 * @ptr: is the user pointer 1106 * @ptr: is the user pointer
1107 * 1107 *
1108 * This function will set (associate) the user given pointer to the 1108 * This function will set (associate) the user given pointer to the
@@ -1110,37 +1110,37 @@ MHD_gtls_session_get_ptr (mhd_gtls_session_t session)
1110 * MHD_gtls_session_get_ptr(). 1110 * MHD_gtls_session_get_ptr().
1111 **/ 1111 **/
1112void 1112void
1113MHD_gnutls_session_set_ptr (mhd_gtls_session_t session, void *ptr) 1113MHD__gnutls_session_set_ptr (MHD_gtls_session_t session, void *ptr)
1114{ 1114{
1115 session->internals.user_ptr = ptr; 1115 session->internals.user_ptr = ptr;
1116} 1116}
1117 1117
1118/** 1118/**
1119 * MHD_gnutls_record_get_direction - This function will return the direction of the last interrupted function call 1119 * MHD__gnutls_record_get_direction - This function will return the direction of the last interrupted function call
1120 * @session: is a #mhd_gtls_session_t structure. 1120 * @session: is a #MHD_gtls_session_t structure.
1121 * 1121 *
1122 * This function provides information about the internals of the 1122 * This function provides information about the internals of the
1123 * record protocol and is only useful if a prior gnutls function call 1123 * record protocol and is only useful if a prior gnutls function call
1124 * (e.g. MHD_gnutls_handshake()) was interrupted for some reason, that 1124 * (e.g. MHD__gnutls_handshake()) was interrupted for some reason, that
1125 * is, if a function returned %GNUTLS_E_INTERRUPTED or 1125 * is, if a function returned %GNUTLS_E_INTERRUPTED or
1126 * %GNUTLS_E_AGAIN. In such a case, you might want to call select() 1126 * %GNUTLS_E_AGAIN. In such a case, you might want to call select()
1127 * or poll() before calling the interrupted gnutls function again. 1127 * or poll() before calling the interrupted gnutls function again.
1128 * To tell you whether a file descriptor should be selected for 1128 * To tell you whether a file descriptor should be selected for
1129 * either reading or writing, MHD_gnutls_record_get_direction() returns 0 1129 * either reading or writing, MHD__gnutls_record_get_direction() returns 0
1130 * if the interrupted function was trying to read data, and 1 if it 1130 * if the interrupted function was trying to read data, and 1 if it
1131 * was trying to write data. 1131 * was trying to write data.
1132 * 1132 *
1133 * Returns: 0 if trying to read data, 1 if trying to write data. 1133 * Returns: 0 if trying to read data, 1 if trying to write data.
1134 **/ 1134 **/
1135int 1135int
1136MHD_gnutls_record_get_direction (mhd_gtls_session_t session) 1136MHD__gnutls_record_get_direction (MHD_gtls_session_t session)
1137{ 1137{
1138 return session->internals.direction; 1138 return session->internals.direction;
1139} 1139}
1140 1140
1141/*- 1141/*-
1142 * _gnutls_rsa_pms_set_version - Sets a version to be used at the RSA PMS 1142 * MHD__gnutls_rsa_pms_set_version - Sets a version to be used at the RSA PMS
1143 * @session: is a #mhd_gtls_session_t structure. 1143 * @session: is a #MHD_gtls_session_t structure.
1144 * @major: is the major version to use 1144 * @major: is the major version to use
1145 * @minor: is the minor version to use 1145 * @minor: is the minor version to use
1146 * 1146 *
@@ -1150,7 +1150,7 @@ MHD_gnutls_record_get_direction (mhd_gtls_session_t session)
1150 * 1150 *
1151 -*/ 1151 -*/
1152void 1152void
1153_gnutls_rsa_pms_set_version (mhd_gtls_session_t session, 1153MHD__gnutls_rsa_pms_set_version (MHD_gtls_session_t session,
1154 unsigned char major, unsigned char minor) 1154 unsigned char major, unsigned char minor)
1155{ 1155{
1156 session->internals.rsa_pms_version[0] = major; 1156 session->internals.rsa_pms_version[0] = major;
@@ -1158,8 +1158,8 @@ _gnutls_rsa_pms_set_version (mhd_gtls_session_t session,
1158} 1158}
1159 1159
1160/** 1160/**
1161 * MHD_gnutls_handshake_set_post_client_hello_function - This function will a callback to be called after the client hello is received 1161 * MHD__gnutls_handshake_set_post_client_hello_function - This function will a callback to be called after the client hello is received
1162 * @res: is a mhd_gtls_anon_server_credentials_t structure 1162 * @res: is a MHD_gtls_anon_server_credentials_t structure
1163 * @func: is the function to be called 1163 * @func: is the function to be called
1164 * 1164 *
1165 * This function will set a callback to be called after the client 1165 * This function will set a callback to be called after the client
@@ -1180,9 +1180,9 @@ _gnutls_rsa_pms_set_version (mhd_gtls_session_t session,
1180 * 1180 *
1181 **/ 1181 **/
1182void 1182void
1183MHD_gnutls_handshake_set_post_client_hello_function (mhd_gtls_session_t 1183MHD__gnutls_handshake_set_post_client_hello_function (MHD_gtls_session_t
1184 session, 1184 session,
1185 gnutls_handshake_post_client_hello_func 1185 MHD_gnutls_handshake_post_client_hello_func
1186 func) 1186 func)
1187{ 1187{
1188 session->internals.user_hello_func = func; 1188 session->internals.user_hello_func = func;
diff --git a/src/daemon/https/tls/gnutls_state.h b/src/daemon/https/tls/gnutls_state.h
index e5d1877a..34aeda93 100644
--- a/src/daemon/https/tls/gnutls_state.h
+++ b/src/daemon/https/tls/gnutls_state.h
@@ -27,51 +27,51 @@
27 27
28#include <gnutls_int.h> 28#include <gnutls_int.h>
29 29
30void _gnutls_session_cert_type_set (mhd_gtls_session_t session, 30void MHD__gnutls_session_cert_type_set (MHD_gtls_session_t session,
31 enum MHD_GNUTLS_CertificateType); 31 enum MHD_GNUTLS_CertificateType);
32enum MHD_GNUTLS_KeyExchangeAlgorithm gnutls_kx_get (mhd_gtls_session_t 32enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gnutls_kx_get (MHD_gtls_session_t
33 session); 33 session);
34enum MHD_GNUTLS_CipherAlgorithm gnutls_cipher_get (mhd_gtls_session_t 34enum MHD_GNUTLS_CipherAlgorithm MHD_gnutls_cipher_get (MHD_gtls_session_t
35 session); 35 session);
36enum MHD_GNUTLS_CertificateType 36enum MHD_GNUTLS_CertificateType
37gnutls_certificate_type_get (mhd_gtls_session_t); 37MHD_gnutls_certificate_type_get (MHD_gtls_session_t);
38 38
39#include <gnutls_auth_int.h> 39#include <gnutls_auth_int.h>
40 40
41#define CHECK_AUTH(auth, ret) if (MHD_gtls_auth_get_type(session) != auth) { \ 41#define CHECK_AUTH(auth, ret) if (MHD_gtls_auth_get_type(session) != auth) { \
42 gnutls_assert(); \ 42 MHD_gnutls_assert(); \
43 return ret; \ 43 return ret; \
44 } 44 }
45 45
46#endif 46#endif
47 47
48int mhd_gtls_session_cert_type_supported (mhd_gtls_session_t, 48int MHD_gtls_session_cert_type_supported (MHD_gtls_session_t,
49 enum MHD_GNUTLS_CertificateType); 49 enum MHD_GNUTLS_CertificateType);
50 50
51int mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits); 51int MHD_gtls_dh_set_secret_bits (MHD_gtls_session_t session, unsigned bits);
52 52
53int mhd_gtls_dh_set_peer_public (mhd_gtls_session_t session, mpi_t public); 53int MHD_gtls_dh_set_peer_public (MHD_gtls_session_t session, mpi_t public);
54int mhd_gtls_dh_set_group (mhd_gtls_session_t session, mpi_t gen, 54int MHD_gtls_dh_set_group (MHD_gtls_session_t session, mpi_t gen,
55 mpi_t prime); 55 mpi_t prime);
56 56
57int mhd_gtls_dh_get_allowed_prime_bits (mhd_gtls_session_t session); 57int MHD_gtls_dh_get_allowed_prime_bits (MHD_gtls_session_t session);
58void mhd_gtls_handshake_internal_state_clear (mhd_gtls_session_t); 58void MHD_gtls_handshake_internal_state_clear (MHD_gtls_session_t);
59 59
60int mhd_gtls_rsa_export_set_pubkey (mhd_gtls_session_t session, 60int MHD_gtls_rsa_export_set_pubkey (MHD_gtls_session_t session,
61 mpi_t exponent, mpi_t modulus); 61 mpi_t exponent, mpi_t modulus);
62 62
63int mhd_gtls_session_is_resumable (mhd_gtls_session_t session); 63int MHD_gtls_session_is_resumable (MHD_gtls_session_t session);
64int mhd_gtls_session_is_export (mhd_gtls_session_t session); 64int MHD_gtls_session_is_export (MHD_gtls_session_t session);
65 65
66int mhd_gtls_openpgp_send_fingerprint (mhd_gtls_session_t session); 66int MHD_gtls_openpgp_send_fingerprint (MHD_gtls_session_t session);
67 67
68int mhd_gtls_PRF (mhd_gtls_session_t session, 68int MHD_gtls_PRF (MHD_gtls_session_t session,
69 const opaque * secret, int secret_size, 69 const opaque * secret, int secret_size,
70 const char *label, int label_size, 70 const char *label, int label_size,
71 const opaque * seed, int seed_size, 71 const opaque * seed, int seed_size,
72 int total_bytes, void *ret); 72 int total_bytes, void *ret);
73 73
74int MHD_gnutls_init (mhd_gtls_session_t * session, 74int MHD__gnutls_init (MHD_gtls_session_t * session,
75 gnutls_connection_end_t con_end); 75 MHD_gnutls_connection_end_t con_end);
76 76
77#define DEFAULT_CERT_TYPE MHD_GNUTLS_CRT_X509 77#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 38f04738..4fc4174b 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
37mhd_gtls_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 @@ mhd_gtls_str_cat (char *dest, size_t dest_tot_size, const char *src)
54} 54}
55 55
56void 56void
57mhd_gtls_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 @@ mhd_gtls_str_cpy (char *dest, size_t dest_tot_size, const char *src)
73} 73}
74 74
75void 75void
76mhd_gtls_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,10 +91,10 @@ mhd_gtls_mem_cpy (char *dest,
91} 91}
92 92
93void 93void
94mhd_gtls_string_init (mhd_gtls_string * str, 94MHD_gtls_string_init (MHD_gtls_string * str,
95 gnutls_alloc_function alloc_func, 95 MHD_gnutls_alloc_function alloc_func,
96 gnutls_realloc_function realloc_func, 96 MHD_gnutls_realloc_function realloc_func,
97 gnutls_free_function free_func) 97 MHD_gnutls_free_function free_func)
98{ 98{
99 str->data = NULL; 99 str->data = NULL;
100 str->max_length = 0; 100 str->max_length = 0;
@@ -106,7 +106,7 @@ mhd_gtls_string_init (mhd_gtls_string * str,
106} 106}
107 107
108void 108void
109mhd_gtls_string_clear (mhd_gtls_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;
@@ -119,10 +119,10 @@ mhd_gtls_string_clear (mhd_gtls_string * str)
119 119
120/* This one does not copy the string. 120/* This one does not copy the string.
121 */ 121 */
122gnutls_datum_t 122MHD_gnutls_datum_t
123mhd_gtls_string2datum (mhd_gtls_string * str) 123MHD_gtls_string2datum (MHD_gtls_string * str)
124{ 124{
125 gnutls_datum_t ret; 125 MHD_gnutls_datum_t ret;
126 126
127 ret.data = str->data; 127 ret.data = str->data;
128 ret.size = str->length; 128 ret.size = str->length;
@@ -133,7 +133,7 @@ mhd_gtls_string2datum (mhd_gtls_string * str)
133#define MIN_CHUNK 256 133#define MIN_CHUNK 256
134 134
135int 135int
136mhd_gtls_string_copy_str (mhd_gtls_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;
@@ -150,7 +150,7 @@ mhd_gtls_string_copy_str (mhd_gtls_string * dest, const char *src)
150 dest->data = dest->realloc_func (dest->data, max); 150 dest->data = dest->realloc_func (dest->data, max);
151 if (dest->data == NULL) 151 if (dest->data == NULL)
152 { 152 {
153 gnutls_assert (); 153 MHD_gnutls_assert ();
154 return GNUTLS_E_MEMORY_ERROR; 154 return GNUTLS_E_MEMORY_ERROR;
155 } 155 }
156 dest->max_length = MAX (MIN_CHUNK, src_len); 156 dest->max_length = MAX (MIN_CHUNK, src_len);
@@ -163,7 +163,7 @@ mhd_gtls_string_copy_str (mhd_gtls_string * dest, const char *src)
163} 163}
164 164
165int 165int
166mhd_gtls_string_append_str (mhd_gtls_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;
@@ -183,7 +183,7 @@ mhd_gtls_string_append_str (mhd_gtls_string * dest, const char *src)
183 dest->data = dest->realloc_func (dest->data, new_len); 183 dest->data = dest->realloc_func (dest->data, new_len);
184 if (dest->data == NULL) 184 if (dest->data == NULL)
185 { 185 {
186 gnutls_assert (); 186 MHD_gnutls_assert ();
187 return GNUTLS_E_MEMORY_ERROR; 187 return GNUTLS_E_MEMORY_ERROR;
188 } 188 }
189 dest->max_length = new_len; 189 dest->max_length = new_len;
@@ -196,7 +196,7 @@ mhd_gtls_string_append_str (mhd_gtls_string * dest, const char *src)
196} 196}
197 197
198int 198int
199mhd_gtls_string_append_data (mhd_gtls_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;
@@ -215,7 +215,7 @@ mhd_gtls_string_append_data (mhd_gtls_string * dest,
215 dest->data = dest->realloc_func (dest->data, new_len); 215 dest->data = dest->realloc_func (dest->data, new_len);
216 if (dest->data == NULL) 216 if (dest->data == NULL)
217 { 217 {
218 gnutls_assert (); 218 MHD_gnutls_assert ();
219 return GNUTLS_E_MEMORY_ERROR; 219 return GNUTLS_E_MEMORY_ERROR;
220 } 220 }
221 dest->max_length = new_len; 221 dest->max_length = new_len;
@@ -233,7 +233,7 @@ mhd_gtls_string_append_data (mhd_gtls_string * dest,
233 * truncated hex string is returned (always null terminated). 233 * truncated hex string is returned (always null terminated).
234 */ 234 */
235char * 235char *
236mhd_gtls_bin2hex (const void *_old, 236MHD_gtls_bin2hex (const void *_old,
237 size_t oldlen, char *buffer, size_t buffer_size) 237 size_t oldlen, char *buffer, size_t buffer_size)
238{ 238{
239 unsigned int i, j; 239 unsigned int i, j;
@@ -252,7 +252,7 @@ mhd_gtls_bin2hex (const void *_old,
252/* just a hex2bin function. 252/* just a hex2bin function.
253 */ 253 */
254int 254int
255mhd_gtls_hex2bin (const opaque * hex_data, 255MHD_gtls_hex2bin (const opaque * hex_data,
256 int hex_size, opaque * bin_data, size_t * bin_size) 256 int hex_size, opaque * bin_data, size_t * bin_size)
257{ 257{
258 int i, j; 258 int i, j;
@@ -265,7 +265,7 @@ mhd_gtls_hex2bin (const opaque * hex_data,
265 265
266 if (*bin_size < (size_t) hex_size) 266 if (*bin_size < (size_t) hex_size)
267 { 267 {
268 gnutls_assert (); 268 MHD_gnutls_assert ();
269 return GNUTLS_E_SHORT_MEMORY_BUFFER; 269 return GNUTLS_E_SHORT_MEMORY_BUFFER;
270 } 270 }
271 271
@@ -277,7 +277,7 @@ mhd_gtls_hex2bin (const opaque * hex_data,
277 val = strtoul ((char *) hex2_data, NULL, 16); 277 val = strtoul ((char *) hex2_data, NULL, 16);
278 if (val == ULONG_MAX) 278 if (val == ULONG_MAX)
279 { 279 {
280 gnutls_assert (); 280 MHD_gnutls_assert ();
281 return GNUTLS_E_SRP_PWD_PARSING_ERROR; 281 return GNUTLS_E_SRP_PWD_PARSING_ERROR;
282 } 282 }
283 bin_data[j] = val; 283 bin_data[j] = val;
diff --git a/src/daemon/https/tls/gnutls_str.h b/src/daemon/https/tls/gnutls_str.h
index ead7ba2a..bedee1df 100644
--- a/src/daemon/https/tls/gnutls_str.h
+++ b/src/daemon/https/tls/gnutls_str.h
@@ -27,37 +27,37 @@
27 27
28#include <gnutls_int.h> 28#include <gnutls_int.h>
29 29
30void mhd_gtls_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 mhd_gtls_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 mhd_gtls_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{
37 opaque *data; 37 opaque *data;
38 size_t max_length; 38 size_t max_length;
39 size_t length; 39 size_t length;
40 gnutls_realloc_function realloc_func; 40 MHD_gnutls_realloc_function realloc_func;
41 gnutls_alloc_function alloc_func; 41 MHD_gnutls_alloc_function alloc_func;
42 gnutls_free_function free_func; 42 MHD_gnutls_free_function free_func;
43} mhd_gtls_string; 43} MHD_gtls_string;
44 44
45void mhd_gtls_string_init (mhd_gtls_string *, gnutls_alloc_function, 45void MHD_gtls_string_init (MHD_gtls_string *, MHD_gnutls_alloc_function,
46 gnutls_realloc_function, gnutls_free_function); 46 MHD_gnutls_realloc_function, MHD_gnutls_free_function);
47void mhd_gtls_string_clear (mhd_gtls_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 mhd_gtls_string2datum (mhd_gtls_string * str); 52MHD_gnutls_datum_t MHD_gtls_string2datum (MHD_gtls_string * str);
53 53
54int mhd_gtls_string_copy_str (mhd_gtls_string * dest, const char *src); 54int MHD_gtls_string_copy_str (MHD_gtls_string * dest, const char *src);
55int mhd_gtls_string_append_str (mhd_gtls_string *, const char *str); 55int MHD_gtls_string_append_str (MHD_gtls_string *, const char *str);
56int mhd_gtls_string_append_data (mhd_gtls_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);
58char *mhd_gtls_bin2hex (const void *old, size_t oldlen, char *buffer, 58char *MHD_gtls_bin2hex (const void *old, size_t oldlen, char *buffer,
59 size_t buffer_size); 59 size_t buffer_size);
60int mhd_gtls_hex2bin (const opaque * hex_data, int hex_size, 60int MHD_gtls_hex2bin (const opaque * hex_data, int hex_size,
61 opaque * bin_data, size_t * bin_size); 61 opaque * bin_data, size_t * bin_size);
62 62
63#endif 63#endif
diff --git a/src/daemon/https/tls/gnutls_supplemental.c b/src/daemon/https/tls/gnutls_supplemental.c
index 997da8a1..7b265031 100644
--- a/src/daemon/https/tls/gnutls_supplemental.c
+++ b/src/daemon/https/tls/gnutls_supplemental.c
@@ -25,13 +25,13 @@
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. MHD_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 MHD__gnutls_gen_supplemental and MHD__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
32 * do_recv_supplemental or do_send_supplemental in the session. 32 * do_recv_supplemental or do_send_supplemental in the session.
33 * 33 *
34 * The functions in this file iterate through the _gnutls_supplemental 34 * The functions in this file iterate through the MHD__gnutls_supplemental
35 * array, and calls the send/recv functions for each respective data 35 * array, and calls the send/recv functions for each respective data
36 * type. 36 * type.
37 * 37 *
@@ -50,29 +50,29 @@
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) (mhd_gtls_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) (mhd_gtls_session_t session, 55typedef int (*supp_send_func) (MHD_gtls_session_t session,
56 mhd_gtls_buffer * buf); 56 MHD_gtls_buffer * buf);
57 57
58typedef struct 58typedef struct
59{ 59{
60 const char *name; 60 const char *name;
61 gnutls_supplemental_data_format_type_t type; 61 MHD_gnutls_supplemental_data_format_type_t type;
62 supp_recv_func supp_recv_func; 62 supp_recv_func supp_recv_func;
63 supp_send_func supp_send_func; 63 supp_send_func supp_send_func;
64} gnutls_supplemental_entry; 64} MHD_gnutls_supplemental_entry;
65 65
66gnutls_supplemental_entry _gnutls_supplemental[] = { 66MHD_gnutls_supplemental_entry MHD__gnutls_supplemental[] = {
67 {0, 0, 0, 0} 67 {0, 0, 0, 0}
68}; 68};
69 69
70const char * 70const char *
71MHD_gtls_supplemental_get_name (gnutls_supplemental_data_format_type_t type) 71MHD_gtls_supplemental_get_name (MHD_gnutls_supplemental_data_format_type_t type)
72{ 72{
73 gnutls_supplemental_entry *p; 73 MHD_gnutls_supplemental_entry *p;
74 74
75 for (p = _gnutls_supplemental; p->name != NULL; p++) 75 for (p = MHD__gnutls_supplemental; p->name != NULL; p++)
76 if (p->type == type) 76 if (p->type == type)
77 return p->name; 77 return p->name;
78 78
@@ -80,11 +80,11 @@ MHD_gtls_supplemental_get_name (gnutls_supplemental_data_format_type_t type)
80} 80}
81 81
82static supp_recv_func 82static supp_recv_func
83get_supp_func_recv (gnutls_supplemental_data_format_type_t type) 83get_supp_func_recv (MHD_gnutls_supplemental_data_format_type_t type)
84{ 84{
85 gnutls_supplemental_entry *p; 85 MHD_gnutls_supplemental_entry *p;
86 86
87 for (p = _gnutls_supplemental; p->name != NULL; p++) 87 for (p = MHD__gnutls_supplemental; p->name != NULL; p++)
88 if (p->type == type) 88 if (p->type == type)
89 return p->supp_recv_func; 89 return p->supp_recv_func;
90 90
@@ -92,37 +92,37 @@ get_supp_func_recv (gnutls_supplemental_data_format_type_t type)
92} 92}
93 93
94int 94int
95_gnutls_gen_supplemental (mhd_gtls_session_t session, mhd_gtls_buffer * buf) 95MHD__gnutls_gen_supplemental (MHD_gtls_session_t session, MHD_gtls_buffer * buf)
96{ 96{
97 gnutls_supplemental_entry *p; 97 MHD_gnutls_supplemental_entry *p;
98 int ret; 98 int ret;
99 99
100 /* Make room for 3 byte length field. */ 100 /* Make room for 3 byte length field. */
101 ret = mhd_gtls_buffer_append (buf, "\0\0\0", 3); 101 ret = MHD_gtls_buffer_append (buf, "\0\0\0", 3);
102 if (ret < 0) 102 if (ret < 0)
103 { 103 {
104 gnutls_assert (); 104 MHD_gnutls_assert ();
105 return ret; 105 return ret;
106 } 106 }
107 107
108 for (p = _gnutls_supplemental; p->name; p++) 108 for (p = MHD__gnutls_supplemental; p->name; p++)
109 { 109 {
110 supp_send_func supp_send = p->supp_send_func; 110 supp_send_func supp_send = p->supp_send_func;
111 size_t sizepos = buf->length; 111 size_t sizepos = buf->length;
112 int ret; 112 int ret;
113 113
114 /* Make room for supplement type and length byte length field. */ 114 /* Make room for supplement type and length byte length field. */
115 ret = mhd_gtls_buffer_append (buf, "\0\0\0\0", 4); 115 ret = MHD_gtls_buffer_append (buf, "\0\0\0\0", 4);
116 if (ret < 0) 116 if (ret < 0)
117 { 117 {
118 gnutls_assert (); 118 MHD_gnutls_assert ();
119 return ret; 119 return ret;
120 } 120 }
121 121
122 ret = supp_send (session, buf); 122 ret = supp_send (session, buf);
123 if (ret < 0) 123 if (ret < 0)
124 { 124 {
125 gnutls_assert (); 125 MHD_gnutls_assert ();
126 return ret; 126 return ret;
127 } 127 }
128 128
@@ -142,14 +142,14 @@ _gnutls_gen_supplemental (mhd_gtls_session_t session, mhd_gtls_buffer * buf)
142 buf->data[1] = ((buf->length - 3) >> 8) & 0xFF; 142 buf->data[1] = ((buf->length - 3) >> 8) & 0xFF;
143 buf->data[2] = (buf->length - 3) & 0xFF; 143 buf->data[2] = (buf->length - 3) & 0xFF;
144 144
145 _gnutls_debug_log ("EXT[%x]: Sending %d bytes of supplemental data\n", 145 MHD__gnutls_debug_log ("EXT[%x]: Sending %d bytes of supplemental data\n",
146 session, buf->length); 146 session, buf->length);
147 147
148 return buf->length; 148 return buf->length;
149} 149}
150 150
151int 151int
152_gnutls_parse_supplemental (mhd_gtls_session_t session, 152MHD__gnutls_parse_supplemental (MHD_gtls_session_t session,
153 const uint8_t * data, int datalen) 153 const uint8_t * data, int datalen)
154{ 154{
155 const opaque *p = data; 155 const opaque *p = data;
@@ -157,12 +157,12 @@ _gnutls_parse_supplemental (mhd_gtls_session_t session,
157 size_t total_size; 157 size_t total_size;
158 158
159 DECR_LEN (dsize, 3); 159 DECR_LEN (dsize, 3);
160 total_size = mhd_gtls_read_uint24 (p); 160 total_size = MHD_gtls_read_uint24 (p);
161 p += 3; 161 p += 3;
162 162
163 if (dsize != total_size) 163 if (dsize != total_size)
164 { 164 {
165 gnutls_assert (); 165 MHD_gnutls_assert ();
166 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; 166 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
167 } 167 }
168 168
@@ -173,14 +173,14 @@ _gnutls_parse_supplemental (mhd_gtls_session_t session,
173 supp_recv_func recv_func; 173 supp_recv_func recv_func;
174 174
175 DECR_LEN (dsize, 2); 175 DECR_LEN (dsize, 2);
176 supp_data_type = mhd_gtls_read_uint16 (p); 176 supp_data_type = MHD_gtls_read_uint16 (p);
177 p += 2; 177 p += 2;
178 178
179 DECR_LEN (dsize, 2); 179 DECR_LEN (dsize, 2);
180 supp_data_length = mhd_gtls_read_uint16 (p); 180 supp_data_length = MHD_gtls_read_uint16 (p);
181 p += 2; 181 p += 2;
182 182
183 _gnutls_debug_log ("EXT[%x]: Got supplemental type=%02x length=%d\n", 183 MHD__gnutls_debug_log ("EXT[%x]: Got supplemental type=%02x length=%d\n",
184 session, supp_data_type, supp_data_length); 184 session, supp_data_type, supp_data_length);
185 185
186 recv_func = get_supp_func_recv (supp_data_type); 186 recv_func = get_supp_func_recv (supp_data_type);
@@ -189,13 +189,13 @@ _gnutls_parse_supplemental (mhd_gtls_session_t session,
189 int ret = recv_func (session, p, supp_data_length); 189 int ret = recv_func (session, p, supp_data_length);
190 if (ret < 0) 190 if (ret < 0)
191 { 191 {
192 gnutls_assert (); 192 MHD_gnutls_assert ();
193 return ret; 193 return ret;
194 } 194 }
195 } 195 }
196 else 196 else
197 { 197 {
198 gnutls_assert (); 198 MHD_gnutls_assert ();
199 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; 199 return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
200 } 200 }
201 201
diff --git a/src/daemon/https/tls/gnutls_supplemental.h b/src/daemon/https/tls/gnutls_supplemental.h
index eaccfe74..a215ab56 100644
--- a/src/daemon/https/tls/gnutls_supplemental.h
+++ b/src/daemon/https/tls/gnutls_supplemental.h
@@ -24,7 +24,7 @@
24 24
25#include <gnutls_int.h> 25#include <gnutls_int.h>
26 26
27int _gnutls_parse_supplemental (mhd_gtls_session_t session, 27int MHD__gnutls_parse_supplemental (MHD_gtls_session_t session,
28 const uint8_t * data, int data_size); 28 const uint8_t * data, int data_size);
29int _gnutls_gen_supplemental (mhd_gtls_session_t session, 29int MHD__gnutls_gen_supplemental (MHD_gtls_session_t session,
30 mhd_gtls_buffer * buf); 30 MHD_gtls_buffer * buf);
diff --git a/src/daemon/https/tls/gnutls_ui.c b/src/daemon/https/tls/gnutls_ui.c
index b211a175..7709b2b7 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 * MHD_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 #mhd_gtls_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
56MHD_gnutls_dh_set_prime_bits (mhd_gtls_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 * MHD_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.
@@ -67,16 +67,16 @@ MHD_gnutls_dh_set_prime_bits (mhd_gtls_session_t session, unsigned int bits)
67 * This function will return the group parameters used in the last Diffie Hellman 67 * This function will return the group parameters used in the last Diffie Hellman
68 * authentication with the peer. These are the prime and the generator used. 68 * authentication with the peer. These are the prime and the generator used.
69 * This function should be used for both anonymous and ephemeral diffie Hellman. 69 * This function should be used for both anonymous and ephemeral diffie Hellman.
70 * The output parameters must be freed with gnutls_free(). 70 * The output parameters must be freed with MHD_gnutls_free().
71 * 71 *
72 * Returns a negative value in case of an error. 72 * Returns a negative value in case of an error.
73 * 73 *
74 **/ 74 **/
75int 75int
76MHD_gnutls_dh_get_group (mhd_gtls_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 MHD_gnutls_datum_t * raw_gen, MHD_gnutls_datum_t * raw_prime)
78{ 78{
79 mhd_gtls_dh_info_st *dh; 79 MHD_gtls_dh_info_st *dh;
80 int ret; 80 int ret;
81 mhd_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;
@@ -84,34 +84,34 @@ MHD_gnutls_dh_get_group (mhd_gtls_session_t session,
84 switch (MHD_gtls_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 = mhd_gtls_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 = mhd_gtls_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;
97 break; 97 break;
98 default: 98 default:
99 gnutls_assert (); 99 MHD_gnutls_assert ();
100 return GNUTLS_E_INVALID_REQUEST; 100 return GNUTLS_E_INVALID_REQUEST;
101 } 101 }
102 102
103 ret = _gnutls_set_datum (raw_prime, dh->prime.data, dh->prime.size); 103 ret = MHD__gnutls_set_datum (raw_prime, dh->prime.data, dh->prime.size);
104 if (ret < 0) 104 if (ret < 0)
105 { 105 {
106 gnutls_assert (); 106 MHD_gnutls_assert ();
107 return ret; 107 return ret;
108 } 108 }
109 109
110 ret = _gnutls_set_datum (raw_gen, dh->generator.data, dh->generator.size); 110 ret = MHD__gnutls_set_datum (raw_gen, dh->generator.data, dh->generator.size);
111 if (ret < 0) 111 if (ret < 0)
112 { 112 {
113 gnutls_assert (); 113 MHD_gnutls_assert ();
114 _gnutls_free_datum (raw_prime); 114 MHD__gnutls_free_datum (raw_prime);
115 return ret; 115 return ret;
116 } 116 }
117 117
@@ -119,22 +119,22 @@ MHD_gnutls_dh_get_group (mhd_gtls_session_t session,
119} 119}
120 120
121/** 121/**
122 * MHD_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 *
126 * This function will return the peer's public key used in the last Diffie Hellman authentication. 126 * This function will return the peer's public key used in the last Diffie Hellman authentication.
127 * This function should be used for both anonymous and ephemeral diffie Hellman. 127 * This function should be used for both anonymous and ephemeral diffie Hellman.
128 * The output parameters must be freed with gnutls_free(). 128 * The output parameters must be freed with MHD_gnutls_free().
129 * 129 *
130 * Returns a negative value in case of an error. 130 * Returns a negative value in case of an error.
131 * 131 *
132 **/ 132 **/
133int 133int
134MHD_gnutls_dh_get_pubkey (mhd_gtls_session_t session, 134MHD__gnutls_dh_get_pubkey (MHD_gtls_session_t session,
135 gnutls_datum_t * raw_key) 135 MHD_gnutls_datum_t * raw_key)
136{ 136{
137 mhd_gtls_dh_info_st *dh; 137 MHD_gtls_dh_info_st *dh;
138 mhd_anon_auth_info_t anon_info; 138 mhd_anon_auth_info_t anon_info;
139 cert_auth_info_t cert_info; 139 cert_auth_info_t cert_info;
140 cert_auth_info_t psk_info; 140 cert_auth_info_t psk_info;
@@ -143,7 +143,7 @@ MHD_gnutls_dh_get_pubkey (mhd_gtls_session_t session,
143 { 143 {
144 case MHD_GNUTLS_CRD_ANON: 144 case MHD_GNUTLS_CRD_ANON:
145 { 145 {
146 anon_info = mhd_gtls_get_auth_info (session); 146 anon_info = MHD_gtls_get_auth_info (session);
147 if (anon_info == NULL) 147 if (anon_info == NULL)
148 return GNUTLS_E_INTERNAL_ERROR; 148 return GNUTLS_E_INTERNAL_ERROR;
149 dh = &anon_info->dh; 149 dh = &anon_info->dh;
@@ -151,7 +151,7 @@ MHD_gnutls_dh_get_pubkey (mhd_gtls_session_t session,
151 } 151 }
152 case MHD_GNUTLS_CRD_PSK: 152 case MHD_GNUTLS_CRD_PSK:
153 { 153 {
154 psk_info = mhd_gtls_get_auth_info (session); 154 psk_info = MHD_gtls_get_auth_info (session);
155 if (psk_info == NULL) 155 if (psk_info == NULL)
156 return GNUTLS_E_INTERNAL_ERROR; 156 return GNUTLS_E_INTERNAL_ERROR;
157 dh = &psk_info->dh; 157 dh = &psk_info->dh;
@@ -160,18 +160,18 @@ MHD_gnutls_dh_get_pubkey (mhd_gtls_session_t session,
160 case MHD_GNUTLS_CRD_CERTIFICATE: 160 case MHD_GNUTLS_CRD_CERTIFICATE:
161 { 161 {
162 162
163 cert_info = mhd_gtls_get_auth_info (session); 163 cert_info = MHD_gtls_get_auth_info (session);
164 if (cert_info == NULL) 164 if (cert_info == NULL)
165 return GNUTLS_E_INTERNAL_ERROR; 165 return GNUTLS_E_INTERNAL_ERROR;
166 dh = &cert_info->dh; 166 dh = &cert_info->dh;
167 break; 167 break;
168 } 168 }
169 default: 169 default:
170 gnutls_assert (); 170 MHD_gnutls_assert ();
171 return GNUTLS_E_INVALID_REQUEST; 171 return GNUTLS_E_INVALID_REQUEST;
172 } 172 }
173 173
174 return _gnutls_set_datum (raw_key, dh->public_key.data, 174 return MHD__gnutls_set_datum (raw_key, dh->public_key.data,
175 dh->public_key.size); 175 dh->public_key.size);
176} 176}
177 177
@@ -183,39 +183,39 @@ MHD_gnutls_dh_get_pubkey (mhd_gtls_session_t session,
183 * 183 *
184 * This function will return the peer's public key exponent and 184 * This function will return the peer's public key exponent and
185 * modulus used in the last RSA-EXPORT authentication. The output 185 * modulus used in the last RSA-EXPORT authentication. The output
186 * parameters must be freed with gnutls_free(). 186 * parameters must be freed with MHD_gnutls_free().
187 * 187 *
188 * Returns a negative value in case of an error. 188 * Returns a negative value in case of an error.
189 * 189 *
190 **/ 190 **/
191int 191int
192MHD_gtls_rsa_export_get_pubkey (mhd_gtls_session_t session, 192MHD_gtls_rsa_export_get_pubkey (MHD_gtls_session_t session,
193 gnutls_datum_t * exponent, 193 MHD_gnutls_datum_t * exponent,
194 gnutls_datum_t * modulus) 194 MHD_gnutls_datum_t * modulus)
195{ 195{
196 cert_auth_info_t info; 196 cert_auth_info_t info;
197 int ret; 197 int ret;
198 198
199 if (MHD_gtls_auth_get_type (session) == MHD_GNUTLS_CRD_CERTIFICATE) 199 if (MHD_gtls_auth_get_type (session) == MHD_GNUTLS_CRD_CERTIFICATE)
200 { 200 {
201 info = mhd_gtls_get_auth_info (session); 201 info = MHD_gtls_get_auth_info (session);
202 if (info == NULL) 202 if (info == NULL)
203 return GNUTLS_E_INTERNAL_ERROR; 203 return GNUTLS_E_INTERNAL_ERROR;
204 204
205 ret = _gnutls_set_datum (modulus, info->rsa_export.modulus.data, 205 ret = MHD__gnutls_set_datum (modulus, info->rsa_export.modulus.data,
206 info->rsa_export.modulus.size); 206 info->rsa_export.modulus.size);
207 if (ret < 0) 207 if (ret < 0)
208 { 208 {
209 gnutls_assert (); 209 MHD_gnutls_assert ();
210 return ret; 210 return ret;
211 } 211 }
212 212
213 ret = _gnutls_set_datum (exponent, info->rsa_export.exponent.data, 213 ret = MHD__gnutls_set_datum (exponent, info->rsa_export.exponent.data,
214 info->rsa_export.exponent.size); 214 info->rsa_export.exponent.size);
215 if (ret < 0) 215 if (ret < 0)
216 { 216 {
217 gnutls_assert (); 217 MHD_gnutls_assert ();
218 _gnutls_free_datum (modulus); 218 MHD__gnutls_free_datum (modulus);
219 return ret; 219 return ret;
220 } 220 }
221 221
@@ -226,7 +226,7 @@ MHD_gtls_rsa_export_get_pubkey (mhd_gtls_session_t session,
226} 226}
227 227
228/** 228/**
229 * MHD_gnutls_dh_get_secret_bits - This function returns the bits used in DH authentication 229 * MHD__gnutls_dh_get_secret_bits - This function returns the bits used in DH authentication
230 * @session: is a gnutls session 230 * @session: is a gnutls session
231 * 231 *
232 * This function will return the bits used in the last Diffie Hellman authentication 232 * This function will return the bits used in the last Diffie Hellman authentication
@@ -235,7 +235,7 @@ MHD_gtls_rsa_export_get_pubkey (mhd_gtls_session_t session,
235 * 235 *
236 **/ 236 **/
237int 237int
238MHD_gnutls_dh_get_secret_bits (mhd_gtls_session_t session) 238MHD__gnutls_dh_get_secret_bits (MHD_gtls_session_t session)
239{ 239{
240 switch (MHD_gtls_auth_get_type (session)) 240 switch (MHD_gtls_auth_get_type (session))
241 { 241 {
@@ -243,7 +243,7 @@ MHD_gnutls_dh_get_secret_bits (mhd_gtls_session_t session)
243 { 243 {
244 mhd_anon_auth_info_t info; 244 mhd_anon_auth_info_t info;
245 245
246 info = mhd_gtls_get_auth_info (session); 246 info = MHD_gtls_get_auth_info (session);
247 if (info == NULL) 247 if (info == NULL)
248 return GNUTLS_E_INTERNAL_ERROR; 248 return GNUTLS_E_INTERNAL_ERROR;
249 return info->dh.secret_bits; 249 return info->dh.secret_bits;
@@ -252,20 +252,20 @@ MHD_gnutls_dh_get_secret_bits (mhd_gtls_session_t session)
252 { 252 {
253 cert_auth_info_t info; 253 cert_auth_info_t info;
254 254
255 info = mhd_gtls_get_auth_info (session); 255 info = MHD_gtls_get_auth_info (session);
256 if (info == NULL) 256 if (info == NULL)
257 return GNUTLS_E_INTERNAL_ERROR; 257 return GNUTLS_E_INTERNAL_ERROR;
258 258
259 return info->dh.secret_bits; 259 return info->dh.secret_bits;
260 } 260 }
261 default: 261 default:
262 gnutls_assert (); 262 MHD_gnutls_assert ();
263 return GNUTLS_E_INVALID_REQUEST; 263 return GNUTLS_E_INVALID_REQUEST;
264 } 264 }
265} 265}
266 266
267/** 267/**
268 * MHD_gnutls_dh_get_prime_bits - This function returns the bits used in DH authentication 268 * MHD__gnutls_dh_get_prime_bits - This function returns the bits used in DH authentication
269 * @session: is a gnutls session 269 * @session: is a gnutls session
270 * 270 *
271 * This function will return the bits of the prime used in the last Diffie Hellman authentication 271 * This function will return the bits of the prime used in the last Diffie Hellman authentication
@@ -274,9 +274,9 @@ MHD_gnutls_dh_get_secret_bits (mhd_gtls_session_t session)
274 * 274 *
275 **/ 275 **/
276int 276int
277MHD_gnutls_dh_get_prime_bits (mhd_gtls_session_t session) 277MHD__gnutls_dh_get_prime_bits (MHD_gtls_session_t session)
278{ 278{
279 mhd_gtls_dh_info_st *dh; 279 MHD_gtls_dh_info_st *dh;
280 280
281 switch (MHD_gtls_auth_get_type (session)) 281 switch (MHD_gtls_auth_get_type (session))
282 { 282 {
@@ -284,7 +284,7 @@ MHD_gnutls_dh_get_prime_bits (mhd_gtls_session_t session)
284 { 284 {
285 mhd_anon_auth_info_t info; 285 mhd_anon_auth_info_t info;
286 286
287 info = mhd_gtls_get_auth_info (session); 287 info = MHD_gtls_get_auth_info (session);
288 if (info == NULL) 288 if (info == NULL)
289 return GNUTLS_E_INTERNAL_ERROR; 289 return GNUTLS_E_INTERNAL_ERROR;
290 dh = &info->dh; 290 dh = &info->dh;
@@ -294,7 +294,7 @@ MHD_gnutls_dh_get_prime_bits (mhd_gtls_session_t session)
294 { 294 {
295 cert_auth_info_t info; 295 cert_auth_info_t info;
296 296
297 info = mhd_gtls_get_auth_info (session); 297 info = MHD_gtls_get_auth_info (session);
298 if (info == NULL) 298 if (info == NULL)
299 return GNUTLS_E_INTERNAL_ERROR; 299 return GNUTLS_E_INTERNAL_ERROR;
300 300
@@ -302,7 +302,7 @@ MHD_gnutls_dh_get_prime_bits (mhd_gtls_session_t session)
302 break; 302 break;
303 } 303 }
304 default: 304 default:
305 gnutls_assert (); 305 MHD_gnutls_assert ();
306 return GNUTLS_E_INVALID_REQUEST; 306 return GNUTLS_E_INVALID_REQUEST;
307 } 307 }
308 308
@@ -320,11 +320,11 @@ MHD_gnutls_dh_get_prime_bits (mhd_gtls_session_t session)
320 * 320 *
321 **/ 321 **/
322int 322int
323MHD_gtls_rsa_export_get_modulus_bits (mhd_gtls_session_t session) 323MHD_gtls_rsa_export_get_modulus_bits (MHD_gtls_session_t session)
324{ 324{
325 cert_auth_info_t info; 325 cert_auth_info_t info;
326 326
327 info = mhd_gtls_get_auth_info (session); 327 info = MHD_gtls_get_auth_info (session);
328 if (info == NULL) 328 if (info == NULL)
329 return GNUTLS_E_INTERNAL_ERROR; 329 return GNUTLS_E_INTERNAL_ERROR;
330 330
@@ -332,7 +332,7 @@ MHD_gtls_rsa_export_get_modulus_bits (mhd_gtls_session_t session)
332} 332}
333 333
334/** 334/**
335 * MHD_gnutls_dh_get_peers_public_bits - This function returns the bits used in DH authentication 335 * MHD__gnutls_dh_get_peers_public_bits - This function returns the bits used in DH authentication
336 * @session: is a gnutls session 336 * @session: is a gnutls session
337 * 337 *
338 * This function will return the bits used in the last Diffie Hellman authentication 338 * This function will return the bits used in the last Diffie Hellman authentication
@@ -341,9 +341,9 @@ MHD_gtls_rsa_export_get_modulus_bits (mhd_gtls_session_t session)
341 * 341 *
342 **/ 342 **/
343int 343int
344MHD_gnutls_dh_get_peers_public_bits (mhd_gtls_session_t session) 344MHD__gnutls_dh_get_peers_public_bits (MHD_gtls_session_t session)
345{ 345{
346 mhd_gtls_dh_info_st *dh; 346 MHD_gtls_dh_info_st *dh;
347 347
348 switch (MHD_gtls_auth_get_type (session)) 348 switch (MHD_gtls_auth_get_type (session))
349 { 349 {
@@ -351,7 +351,7 @@ MHD_gnutls_dh_get_peers_public_bits (mhd_gtls_session_t session)
351 { 351 {
352 mhd_anon_auth_info_t info; 352 mhd_anon_auth_info_t info;
353 353
354 info = mhd_gtls_get_auth_info (session); 354 info = MHD_gtls_get_auth_info (session);
355 if (info == NULL) 355 if (info == NULL)
356 return GNUTLS_E_INTERNAL_ERROR; 356 return GNUTLS_E_INTERNAL_ERROR;
357 357
@@ -362,7 +362,7 @@ MHD_gnutls_dh_get_peers_public_bits (mhd_gtls_session_t session)
362 { 362 {
363 cert_auth_info_t info; 363 cert_auth_info_t info;
364 364
365 info = mhd_gtls_get_auth_info (session); 365 info = MHD_gtls_get_auth_info (session);
366 if (info == NULL) 366 if (info == NULL)
367 return GNUTLS_E_INTERNAL_ERROR; 367 return GNUTLS_E_INTERNAL_ERROR;
368 368
@@ -370,7 +370,7 @@ MHD_gnutls_dh_get_peers_public_bits (mhd_gtls_session_t session)
370 break; 370 break;
371 } 371 }
372 default: 372 default:
373 gnutls_assert (); 373 MHD_gnutls_assert ();
374 return GNUTLS_E_INVALID_REQUEST; 374 return GNUTLS_E_INVALID_REQUEST;
375 } 375 }
376 376
@@ -391,20 +391,20 @@ MHD_gnutls_dh_get_peers_public_bits (mhd_gtls_session_t session)
391 * Returns NULL in case of an error, or if no certificate was used. 391 * Returns NULL in case of an error, or if no certificate was used.
392 * 392 *
393 **/ 393 **/
394const gnutls_datum_t * 394const MHD_gnutls_datum_t *
395MHD_gtls_certificate_get_ours (mhd_gtls_session_t session) 395MHD_gtls_certificate_get_ours (MHD_gtls_session_t session)
396{ 396{
397 mhd_gtls_cert_credentials_t cred; 397 MHD_gtls_cert_credentials_t cred;
398 398
399 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, NULL); 399 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, NULL);
400 400
401 cred 401 cred
402 = (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key, 402 = (MHD_gtls_cert_credentials_t) MHD_gtls_get_cred (session->key,
403 MHD_GNUTLS_CRD_CERTIFICATE, 403 MHD_GNUTLS_CRD_CERTIFICATE,
404 NULL); 404 NULL);
405 if (cred == NULL || cred->cert_list == NULL) 405 if (cred == NULL || cred->cert_list == NULL)
406 { 406 {
407 gnutls_assert (); 407 MHD_gnutls_assert ();
408 return NULL; 408 return NULL;
409 } 409 }
410 410
@@ -431,15 +431,15 @@ MHD_gtls_certificate_get_ours (mhd_gtls_session_t session)
431 * Returns NULL in case of an error, or if no certificate was sent. 431 * Returns NULL in case of an error, or if no certificate was sent.
432 * 432 *
433 **/ 433 **/
434const gnutls_datum_t * 434const MHD_gnutls_datum_t *
435MHD_gtls_certificate_get_peers (mhd_gtls_session_t 435MHD_gtls_certificate_get_peers (MHD_gtls_session_t
436 session, unsigned int *list_size) 436 session, unsigned int *list_size)
437{ 437{
438 cert_auth_info_t info; 438 cert_auth_info_t info;
439 439
440 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, NULL); 440 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, NULL);
441 441
442 info = mhd_gtls_get_auth_info (session); 442 info = MHD_gtls_get_auth_info (session);
443 if (info == NULL) 443 if (info == NULL)
444 return NULL; 444 return NULL;
445 445
@@ -457,20 +457,20 @@ MHD_gtls_certificate_get_peers (mhd_gtls_session_t
457 * 457 *
458 **/ 458 **/
459int 459int
460MHD_gtls_certificate_client_get_request_status (mhd_gtls_session_t session) 460MHD_gtls_certificate_client_get_request_status (MHD_gtls_session_t session)
461{ 461{
462 cert_auth_info_t info; 462 cert_auth_info_t info;
463 463
464 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, 0); 464 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, 0);
465 465
466 info = mhd_gtls_get_auth_info (session); 466 info = MHD_gtls_get_auth_info (session);
467 if (info == NULL) 467 if (info == NULL)
468 return GNUTLS_E_INTERNAL_ERROR; 468 return GNUTLS_E_INTERNAL_ERROR;
469 return info->certificate_requested; 469 return info->certificate_requested;
470} 470}
471 471
472/** 472/**
473 * MHD_gnutls_fingerprint - This function calculates the fingerprint of the given data 473 * MHD__gnutls_fingerprint - This function calculates the fingerprint of the given data
474 * @algo: is a digest algorithm 474 * @algo: is a digest algorithm
475 * @data: is the data 475 * @data: is the data
476 * @result: is the place where the result will be copied (may be null). 476 * @result: is the place where the result will be copied (may be null).
@@ -490,12 +490,12 @@ MHD_gtls_certificate_client_get_request_status (mhd_gtls_session_t session)
490 * 490 *
491 **/ 491 **/
492int 492int
493MHD_gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo, 493MHD__gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo,
494 const gnutls_datum_t * data, 494 const MHD_gnutls_datum_t * data,
495 void *result, size_t * result_size) 495 void *result, size_t * result_size)
496{ 496{
497 GNUTLS_HASH_HANDLE td; 497 GNUTLS_HASH_HANDLE td;
498 int hash_len = mhd_gnutls_hash_get_algo_len (HASH2MAC (algo)); 498 int hash_len = MHD_gnutls_hash_get_algo_len (HASH2MAC (algo));
499 499
500 if (hash_len < 0 || (unsigned) hash_len > *result_size || result == NULL) 500 if (hash_len < 0 || (unsigned) hash_len > *result_size || result == NULL)
501 { 501 {
@@ -506,21 +506,21 @@ MHD_gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo,
506 506
507 if (result) 507 if (result)
508 { 508 {
509 td = mhd_gtls_hash_init (HASH2MAC (algo)); 509 td = MHD_gtls_hash_init (HASH2MAC (algo));
510 if (td == NULL) 510 if (td == NULL)
511 return GNUTLS_E_HASH_FAILED; 511 return GNUTLS_E_HASH_FAILED;
512 512
513 mhd_gnutls_hash (td, data->data, data->size); 513 MHD_gnutls_hash (td, data->data, data->size);
514 514
515 mhd_gnutls_hash_deinit (td, result); 515 MHD_gnutls_hash_deinit (td, result);
516 } 516 }
517 517
518 return 0; 518 return 0;
519} 519}
520 520
521/** 521/**
522 * MHD_gnutls_certificate_set_dh_params - This function will set the DH parameters for a server to use 522 * MHD__gnutls_certificate_set_dh_params - This function will set the DH parameters for a server to use
523 * @res: is a mhd_gtls_cert_credentials_t structure 523 * @res: is a MHD_gtls_cert_credentials_t structure
524 * @dh_params: is a structure that holds diffie hellman parameters. 524 * @dh_params: is a structure that holds diffie hellman parameters.
525 * 525 *
526 * This function will set the diffie hellman parameters for a 526 * This function will set the diffie hellman parameters for a
@@ -532,15 +532,15 @@ MHD_gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo,
532 * 532 *
533 **/ 533 **/
534void 534void
535MHD_gnutls_certificate_set_dh_params (mhd_gtls_cert_credentials_t res, 535MHD__gnutls_certificate_set_dh_params (MHD_gtls_cert_credentials_t res,
536 mhd_gtls_dh_params_t dh_params) 536 MHD_gtls_dh_params_t dh_params)
537{ 537{
538 res->dh_params = dh_params; 538 res->dh_params = dh_params;
539} 539}
540 540
541/** 541/**
542 * gnutls_certificate_set_params_function - This function will set the DH or RSA parameters callback 542 * MHD_gnutls_certificate_set_params_function - This function will set the DH or RSA parameters callback
543 * @res: is a mhd_gtls_cert_credentials_t structure 543 * @res: is a MHD_gtls_cert_credentials_t structure
544 * @func: is the function to be called 544 * @func: is the function to be called
545 * 545 *
546 * This function will set a callback in order for the server to get the 546 * This function will set a callback in order for the server to get the
@@ -549,32 +549,32 @@ MHD_gnutls_certificate_set_dh_params (mhd_gtls_cert_credentials_t res,
549 * 549 *
550 **/ 550 **/
551void 551void
552gnutls_certificate_set_params_function (mhd_gtls_cert_credentials_t res, 552MHD_gnutls_certificate_set_params_function (MHD_gtls_cert_credentials_t res,
553 gnutls_params_function * func) 553 MHD_gnutls_params_function * func)
554{ 554{
555 res->params_func = func; 555 res->params_func = func;
556} 556}
557 557
558/** 558/**
559 * MHD_gnutls_certificate_set_verify_flags - This function will set the flags to be used at certificate verification 559 * MHD__gnutls_certificate_set_verify_flags - This function will set the flags to be used at certificate verification
560 * @res: is a mhd_gtls_cert_credentials_t structure 560 * @res: is a MHD_gtls_cert_credentials_t structure
561 * @flags: are the flags 561 * @flags: are the flags
562 * 562 *
563 * This function will set the flags to be used at verification of the 563 * This function will set the flags to be used at verification of the
564 * certificates. Flags must be OR of the 564 * certificates. Flags must be OR of the
565 * #gnutls_certificate_verify_flags enumerations. 565 * #MHD_gnutls_certificate_verify_flags enumerations.
566 * 566 *
567 **/ 567 **/
568void 568void
569MHD_gnutls_certificate_set_verify_flags (mhd_gtls_cert_credentials_t 569MHD__gnutls_certificate_set_verify_flags (MHD_gtls_cert_credentials_t
570 res, unsigned int flags) 570 res, unsigned int flags)
571{ 571{
572 res->verify_flags = flags; 572 res->verify_flags = flags;
573} 573}
574 574
575/** 575/**
576 * MHD_gnutls_certificate_set_verify_limits - This function will set the upper limits to be used at certificate verification 576 * MHD__gnutls_certificate_set_verify_limits - This function will set the upper limits to be used at certificate verification
577 * @res: is a gnutls_certificate_credentials structure 577 * @res: is a MHD_gnutls_certificate_credentials structure
578 * @max_bits: is the number of bits of an acceptable certificate (default 8200) 578 * @max_bits: is the number of bits of an acceptable certificate (default 8200)
579 * @max_depth: is maximum depth of the verification of a certificate chain (default 5) 579 * @max_depth: is maximum depth of the verification of a certificate chain (default 5)
580 * 580 *
@@ -584,7 +584,7 @@ MHD_gnutls_certificate_set_verify_flags (mhd_gtls_cert_credentials_t
584 * 584 *
585 **/ 585 **/
586void 586void
587MHD_gnutls_certificate_set_verify_limits (mhd_gtls_cert_credentials_t 587MHD__gnutls_certificate_set_verify_limits (MHD_gtls_cert_credentials_t
588 res, 588 res,
589 unsigned int max_bits, 589 unsigned int max_bits,
590 unsigned int max_depth) 590 unsigned int max_depth)
@@ -594,8 +594,8 @@ MHD_gnutls_certificate_set_verify_limits (mhd_gtls_cert_credentials_t
594} 594}
595 595
596/** 596/**
597 * MHD_gnutls_certificate_set_rsa_export_params - This function will set the RSA parameters for a server to use 597 * MHD__gnutls_certificate_set_rsa_export_params - This function will set the RSA parameters for a server to use
598 * @res: is a mhd_gtls_cert_credentials_t structure 598 * @res: is a MHD_gtls_cert_credentials_t structure
599 * @rsa_params: is a structure that holds temporary RSA parameters. 599 * @rsa_params: is a structure that holds temporary RSA parameters.
600 * 600 *
601 * This function will set the temporary RSA parameters for a certificate 601 * This function will set the temporary RSA parameters for a certificate
@@ -604,17 +604,17 @@ MHD_gnutls_certificate_set_verify_limits (mhd_gtls_cert_credentials_t
604 * 604 *
605 **/ 605 **/
606void 606void
607MHD_gnutls_certificate_set_rsa_export_params (mhd_gtls_cert_credentials_t 607MHD__gnutls_certificate_set_rsa_export_params (MHD_gtls_cert_credentials_t
608 res, 608 res,
609 mhd_gtls_rsa_params_t 609 MHD_gtls_rsa_params_t
610 rsa_params) 610 rsa_params)
611{ 611{
612 res->rsa_params = rsa_params; 612 res->rsa_params = rsa_params;
613} 613}
614 614
615/** 615/**
616 * gnutls_anon_set_params_function - This function will set the DH or RSA parameters callback 616 * MHD_gnutls_anon_set_params_function - This function will set the DH or RSA parameters callback
617 * @res: is a mhd_gtls_anon_server_credentials_t structure 617 * @res: is a MHD_gtls_anon_server_credentials_t structure
618 * @func: is the function to be called 618 * @func: is the function to be called
619 * 619 *
620 * This function will set a callback in order for the server to get the 620 * This function will set a callback in order for the server to get the
@@ -623,8 +623,8 @@ MHD_gnutls_certificate_set_rsa_export_params (mhd_gtls_cert_credentials_t
623 * 623 *
624 **/ 624 **/
625void 625void
626gnutls_anon_set_params_function (mhd_gtls_anon_server_credentials_t res, 626MHD_gnutls_anon_set_params_function (MHD_gtls_anon_server_credentials_t res,
627 gnutls_params_function * func) 627 MHD_gnutls_params_function * func)
628{ 628{
629 res->params_func = func; 629 res->params_func = func;
630} 630}
diff --git a/src/daemon/https/tls/gnutls_x509.c b/src/daemon/https/tls/gnutls_x509.c
index f854b710..811f5dbe 100644
--- a/src/daemon/https/tls/gnutls_x509.c
+++ b/src/daemon/https/tls/gnutls_x509.c
@@ -64,21 +64,21 @@
64 * is unacceptable. 64 * is unacceptable.
65 */ 65 */
66inline static int 66inline static int
67check_bits (gnutls_x509_crt_t crt, unsigned int max_bits) 67check_bits (MHD_gnutls_x509_crt_t crt, unsigned int max_bits)
68{ 68{
69 int ret; 69 int ret;
70 unsigned int bits; 70 unsigned int bits;
71 71
72 ret = gnutls_x509_crt_get_pk_algorithm (crt, &bits); 72 ret = MHD_gnutls_x509_crt_get_pk_algorithm (crt, &bits);
73 if (ret < 0) 73 if (ret < 0)
74 { 74 {
75 gnutls_assert (); 75 MHD_gnutls_assert ();
76 return ret; 76 return ret;
77 } 77 }
78 78
79 if (bits > max_bits && max_bits > 0) 79 if (bits > max_bits && max_bits > 0)
80 { 80 {
81 gnutls_assert (); 81 MHD_gnutls_assert ();
82 return GNUTLS_E_CONSTRAINT_ERROR; 82 return GNUTLS_E_CONSTRAINT_ERROR;
83 } 83 }
84 84
@@ -88,43 +88,43 @@ check_bits (gnutls_x509_crt_t crt, unsigned int max_bits)
88 88
89#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) { \ 89#define CLEAR_CERTS for(x=0;x<peer_certificate_list_size;x++) { \
90 if (peer_certificate_list[x]) \ 90 if (peer_certificate_list[x]) \
91 gnutls_x509_crt_deinit(peer_certificate_list[x]); \ 91 MHD_gnutls_x509_crt_deinit(peer_certificate_list[x]); \
92 } \ 92 } \
93 gnutls_free( peer_certificate_list) 93 MHD_gnutls_free( peer_certificate_list)
94 94
95/*- 95/*-
96 * _gnutls_x509_cert_verify_peers - This function returns the peer's certificate status 96 * MHD__gnutls_x509_cert_verify_peers - This function returns the peer's certificate status
97 * @session: is a gnutls session 97 * @session: is a gnutls session
98 * 98 *
99 * This function will try to verify the peer's certificate and return its status (TRUSTED, REVOKED etc.). 99 * This function will try to verify the peer's certificate and return its status (TRUSTED, REVOKED etc.).
100 * The return value (status) should be one of the gnutls_certificate_status_t enumerated elements. 100 * The return value (status) should be one of the MHD_gnutls_certificate_status_t enumerated elements.
101 * However you must also check the peer's name in order to check if the verified certificate belongs to the 101 * However you must also check the peer's name in order to check if the verified certificate belongs to the
102 * actual peer. Returns a negative error code in case of an error, or GNUTLS_E_NO_CERTIFICATE_FOUND if no certificate was sent. 102 * actual peer. Returns a negative error code in case of an error, or GNUTLS_E_NO_CERTIFICATE_FOUND if no certificate was sent.
103 * 103 *
104 -*/ 104 -*/
105int 105int
106_gnutls_x509_cert_verify_peers (mhd_gtls_session_t session, 106MHD__gnutls_x509_cert_verify_peers (MHD_gtls_session_t session,
107 unsigned int *status) 107 unsigned int *status)
108{ 108{
109 cert_auth_info_t info; 109 cert_auth_info_t info;
110 mhd_gtls_cert_credentials_t cred; 110 MHD_gtls_cert_credentials_t cred;
111 gnutls_x509_crt_t *peer_certificate_list; 111 MHD_gnutls_x509_crt_t *peer_certificate_list;
112 int peer_certificate_list_size, i, x, ret; 112 int peer_certificate_list_size, i, x, ret;
113 113
114 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST); 114 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
115 115
116 info = mhd_gtls_get_auth_info (session); 116 info = MHD_gtls_get_auth_info (session);
117 if (info == NULL) 117 if (info == NULL)
118 { 118 {
119 gnutls_assert (); 119 MHD_gnutls_assert ();
120 return GNUTLS_E_INVALID_REQUEST; 120 return GNUTLS_E_INVALID_REQUEST;
121 } 121 }
122 122
123 cred = (mhd_gtls_cert_credentials_t) 123 cred = (MHD_gtls_cert_credentials_t)
124 mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); 124 MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
125 if (cred == NULL) 125 if (cred == NULL)
126 { 126 {
127 gnutls_assert (); 127 MHD_gnutls_assert ();
128 return GNUTLS_E_INSUFFICIENT_CREDENTIALS; 128 return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
129 } 129 }
130 130
@@ -133,40 +133,40 @@ _gnutls_x509_cert_verify_peers (mhd_gtls_session_t session,
133 133
134 if (info->ncerts > cred->verify_depth && cred->verify_depth > 0) 134 if (info->ncerts > cred->verify_depth && cred->verify_depth > 0)
135 { 135 {
136 gnutls_assert (); 136 MHD_gnutls_assert ();
137 return GNUTLS_E_CONSTRAINT_ERROR; 137 return GNUTLS_E_CONSTRAINT_ERROR;
138 } 138 }
139 139
140 /* generate a list of gnutls_certs based on the auth info 140 /* generate a list of MHD_gnutls_certs based on the auth info
141 * raw certs. 141 * raw certs.
142 */ 142 */
143 peer_certificate_list_size = info->ncerts; 143 peer_certificate_list_size = info->ncerts;
144 peer_certificate_list = 144 peer_certificate_list =
145 gnutls_calloc (1, 145 MHD_gnutls_calloc (1,
146 peer_certificate_list_size * sizeof (gnutls_x509_crt_t)); 146 peer_certificate_list_size * sizeof (MHD_gnutls_x509_crt_t));
147 if (peer_certificate_list == NULL) 147 if (peer_certificate_list == NULL)
148 { 148 {
149 gnutls_assert (); 149 MHD_gnutls_assert ();
150 return GNUTLS_E_MEMORY_ERROR; 150 return GNUTLS_E_MEMORY_ERROR;
151 } 151 }
152 152
153 for (i = 0; i < peer_certificate_list_size; i++) 153 for (i = 0; i < peer_certificate_list_size; i++)
154 { 154 {
155 ret = gnutls_x509_crt_init (&peer_certificate_list[i]); 155 ret = MHD_gnutls_x509_crt_init (&peer_certificate_list[i]);
156 if (ret < 0) 156 if (ret < 0)
157 { 157 {
158 gnutls_assert (); 158 MHD_gnutls_assert ();
159 CLEAR_CERTS; 159 CLEAR_CERTS;
160 return ret; 160 return ret;
161 } 161 }
162 162
163 ret = 163 ret =
164 gnutls_x509_crt_import (peer_certificate_list[i], 164 MHD_gnutls_x509_crt_import (peer_certificate_list[i],
165 &info->raw_certificate_list[i], 165 &info->raw_certificate_list[i],
166 GNUTLS_X509_FMT_DER); 166 GNUTLS_X509_FMT_DER);
167 if (ret < 0) 167 if (ret < 0)
168 { 168 {
169 gnutls_assert (); 169 MHD_gnutls_assert ();
170 CLEAR_CERTS; 170 CLEAR_CERTS;
171 return ret; 171 return ret;
172 } 172 }
@@ -174,7 +174,7 @@ _gnutls_x509_cert_verify_peers (mhd_gtls_session_t session,
174 ret = check_bits (peer_certificate_list[i], cred->verify_bits); 174 ret = check_bits (peer_certificate_list[i], cred->verify_bits);
175 if (ret < 0) 175 if (ret < 0)
176 { 176 {
177 gnutls_assert (); 177 MHD_gnutls_assert ();
178 CLEAR_CERTS; 178 CLEAR_CERTS;
179 return ret; 179 return ret;
180 } 180 }
@@ -184,7 +184,7 @@ _gnutls_x509_cert_verify_peers (mhd_gtls_session_t session,
184 /* Verify certificate 184 /* Verify certificate
185 */ 185 */
186 ret = 186 ret =
187 gnutls_x509_crt_list_verify (peer_certificate_list, 187 MHD_gnutls_x509_crt_list_verify (peer_certificate_list,
188 peer_certificate_list_size, 188 peer_certificate_list_size,
189 cred->x509_ca_list, cred->x509_ncas, 189 cred->x509_ca_list, cred->x509_ncas,
190 cred->x509_crl_list, cred->x509_ncrls, 190 cred->x509_crl_list, cred->x509_ncrls,
@@ -194,7 +194,7 @@ _gnutls_x509_cert_verify_peers (mhd_gtls_session_t session,
194 194
195 if (ret < 0) 195 if (ret < 0)
196 { 196 {
197 gnutls_assert (); 197 MHD_gnutls_assert ();
198 return ret; 198 return ret;
199 } 199 }
200 200
@@ -209,55 +209,55 @@ _gnutls_x509_cert_verify_peers (mhd_gtls_session_t session,
209 * the given key parameters. 209 * the given key parameters.
210 */ 210 */
211static int 211static int
212_gnutls_check_key_cert_match (mhd_gtls_cert_credentials_t res) 212MHD__gnutls_check_key_cert_match (MHD_gtls_cert_credentials_t res)
213{ 213{
214 gnutls_datum_t cid; 214 MHD_gnutls_datum_t cid;
215 gnutls_datum_t kid; 215 MHD_gnutls_datum_t kid;
216 unsigned pk = res->cert_list[res->ncerts - 1][0].subject_pk_algorithm; 216 unsigned pk = res->cert_list[res->ncerts - 1][0].subject_pk_algorithm;
217 217
218 if (res->pkey[res->ncerts - 1].pk_algorithm != pk) 218 if (res->pkey[res->ncerts - 1].pk_algorithm != pk)
219 { 219 {
220 gnutls_assert (); 220 MHD_gnutls_assert ();
221 return GNUTLS_E_CERTIFICATE_KEY_MISMATCH; 221 return GNUTLS_E_CERTIFICATE_KEY_MISMATCH;
222 } 222 }
223 223
224 _gnutls_x509_write_rsa_params (res->pkey[res->ncerts - 1].params, 224 MHD__gnutls_x509_write_rsa_params (res->pkey[res->ncerts - 1].params,
225 res->pkey[res->ncerts - 225 res->pkey[res->ncerts -
226 1].params_size, &kid); 226 1].params_size, &kid);
227 227
228 228
229 _gnutls_x509_write_rsa_params (res->cert_list[res->ncerts - 1][0].params, 229 MHD__gnutls_x509_write_rsa_params (res->cert_list[res->ncerts - 1][0].params,
230 res->cert_list[res->ncerts - 230 res->cert_list[res->ncerts -
231 1][0].params_size, &cid); 231 1][0].params_size, &cid);
232 232
233 if (cid.size != kid.size) 233 if (cid.size != kid.size)
234 { 234 {
235 gnutls_assert (); 235 MHD_gnutls_assert ();
236 _gnutls_free_datum (&kid); 236 MHD__gnutls_free_datum (&kid);
237 _gnutls_free_datum (&cid); 237 MHD__gnutls_free_datum (&cid);
238 return GNUTLS_E_CERTIFICATE_KEY_MISMATCH; 238 return GNUTLS_E_CERTIFICATE_KEY_MISMATCH;
239 } 239 }
240 240
241 if (memcmp (kid.data, cid.data, kid.size) != 0) 241 if (memcmp (kid.data, cid.data, kid.size) != 0)
242 { 242 {
243 gnutls_assert (); 243 MHD_gnutls_assert ();
244 _gnutls_free_datum (&kid); 244 MHD__gnutls_free_datum (&kid);
245 _gnutls_free_datum (&cid); 245 MHD__gnutls_free_datum (&cid);
246 return GNUTLS_E_CERTIFICATE_KEY_MISMATCH; 246 return GNUTLS_E_CERTIFICATE_KEY_MISMATCH;
247 } 247 }
248 248
249 _gnutls_free_datum (&kid); 249 MHD__gnutls_free_datum (&kid);
250 _gnutls_free_datum (&cid); 250 MHD__gnutls_free_datum (&cid);
251 return 0; 251 return 0;
252} 252}
253 253
254/* Reads a DER encoded certificate list from memory and stores it to 254/* Reads a DER encoded certificate list from memory and stores it to
255 * a gnutls_cert structure. 255 * a MHD_gnutls_cert structure.
256 * Returns the number of certificates parsed. 256 * Returns the number of certificates parsed.
257 */ 257 */
258static int 258static int
259parse_crt_mem (gnutls_cert ** cert_list, unsigned *ncerts, 259parse_crt_mem (MHD_gnutls_cert ** cert_list, unsigned *ncerts,
260 gnutls_x509_crt_t cert) 260 MHD_gnutls_x509_crt_t cert)
261{ 261{
262 int i; 262 int i;
263 int ret; 263 int ret;
@@ -265,19 +265,19 @@ parse_crt_mem (gnutls_cert ** cert_list, unsigned *ncerts,
265 i = *ncerts + 1; 265 i = *ncerts + 1;
266 266
267 *cert_list = 267 *cert_list =
268 (gnutls_cert *) mhd_gtls_realloc_fast (*cert_list, 268 (MHD_gnutls_cert *) MHD_gtls_realloc_fast (*cert_list,
269 i * sizeof (gnutls_cert)); 269 i * sizeof (MHD_gnutls_cert));
270 270
271 if (*cert_list == NULL) 271 if (*cert_list == NULL)
272 { 272 {
273 gnutls_assert (); 273 MHD_gnutls_assert ();
274 return GNUTLS_E_MEMORY_ERROR; 274 return GNUTLS_E_MEMORY_ERROR;
275 } 275 }
276 276
277 ret = mhd_gtls_x509_crt_to_gcert (&cert_list[0][i - 1], cert, 0); 277 ret = MHD_gtls_x509_crt_to_gcert (&cert_list[0][i - 1], cert, 0);
278 if (ret < 0) 278 if (ret < 0)
279 { 279 {
280 gnutls_assert (); 280 MHD_gnutls_assert ();
281 return ret; 281 return ret;
282 } 282 }
283 283
@@ -287,65 +287,65 @@ parse_crt_mem (gnutls_cert ** cert_list, unsigned *ncerts,
287} 287}
288 288
289/* Reads a DER encoded certificate list from memory and stores it to 289/* Reads a DER encoded certificate list from memory and stores it to
290 * a gnutls_cert structure. 290 * a MHD_gnutls_cert structure.
291 * Returns the number of certificates parsed. 291 * Returns the number of certificates parsed.
292 */ 292 */
293static int 293static int
294parse_der_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts, 294parse_der_cert_mem (MHD_gnutls_cert ** cert_list, unsigned *ncerts,
295 const void *input_cert, int input_cert_size) 295 const void *input_cert, int input_cert_size)
296{ 296{
297 gnutls_datum_t tmp; 297 MHD_gnutls_datum_t tmp;
298 gnutls_x509_crt_t cert; 298 MHD_gnutls_x509_crt_t cert;
299 int ret; 299 int ret;
300 300
301 ret = gnutls_x509_crt_init (&cert); 301 ret = MHD_gnutls_x509_crt_init (&cert);
302 if (ret < 0) 302 if (ret < 0)
303 { 303 {
304 gnutls_assert (); 304 MHD_gnutls_assert ();
305 return ret; 305 return ret;
306 } 306 }
307 307
308 tmp.data = (opaque *) input_cert; 308 tmp.data = (opaque *) input_cert;
309 tmp.size = input_cert_size; 309 tmp.size = input_cert_size;
310 310
311 ret = gnutls_x509_crt_import (cert, &tmp, GNUTLS_X509_FMT_DER); 311 ret = MHD_gnutls_x509_crt_import (cert, &tmp, GNUTLS_X509_FMT_DER);
312 if (ret < 0) 312 if (ret < 0)
313 { 313 {
314 gnutls_assert (); 314 MHD_gnutls_assert ();
315 gnutls_x509_crt_deinit (cert); 315 MHD_gnutls_x509_crt_deinit (cert);
316 return ret; 316 return ret;
317 } 317 }
318 318
319 ret = parse_crt_mem (cert_list, ncerts, cert); 319 ret = parse_crt_mem (cert_list, ncerts, cert);
320 gnutls_x509_crt_deinit (cert); 320 MHD_gnutls_x509_crt_deinit (cert);
321 321
322 return ret; 322 return ret;
323} 323}
324 324
325/* Reads a base64 encoded certificate list from memory and stores it to 325/* Reads a base64 encoded certificate list from memory and stores it to
326 * a gnutls_cert structure. Returns the number of certificate parsed. 326 * a MHD_gnutls_cert structure. Returns the number of certificate parsed.
327 */ 327 */
328static int 328static int
329parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts, 329parse_pem_cert_mem (MHD_gnutls_cert ** cert_list, unsigned *ncerts,
330 const char *input_cert, int input_cert_size) 330 const char *input_cert, int input_cert_size)
331{ 331{
332 int size, siz2, i; 332 int size, siz2, i;
333 const char *ptr; 333 const char *ptr;
334 opaque *ptr2; 334 opaque *ptr2;
335 gnutls_datum_t tmp; 335 MHD_gnutls_datum_t tmp;
336 int ret, count; 336 int ret, count;
337 337
338 /* move to the certificate 338 /* move to the certificate
339 */ 339 */
340 ptr = memmem (input_cert, input_cert_size, 340 ptr = MHD_memmem (input_cert, input_cert_size,
341 PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1); 341 PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
342 if (ptr == NULL) 342 if (ptr == NULL)
343 ptr = memmem (input_cert, input_cert_size, 343 ptr = MHD_memmem (input_cert, input_cert_size,
344 PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1); 344 PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1);
345 345
346 if (ptr == NULL) 346 if (ptr == NULL)
347 { 347 {
348 gnutls_assert (); 348 MHD_gnutls_assert ();
349 return GNUTLS_E_BASE64_DECODING_ERROR; 349 return GNUTLS_E_BASE64_DECODING_ERROR;
350 } 350 }
351 size = input_cert_size - (ptr - input_cert); 351 size = input_cert_size - (ptr - input_cert);
@@ -356,34 +356,34 @@ parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts,
356 do 356 do
357 { 357 {
358 358
359 siz2 = _gnutls_fbase64_decode (NULL, (const unsigned char*) ptr, size, &ptr2); 359 siz2 = MHD__gnutls_fbase64_decode (NULL, (const unsigned char*) ptr, size, &ptr2);
360 360
361 if (siz2 < 0) 361 if (siz2 < 0)
362 { 362 {
363 gnutls_assert (); 363 MHD_gnutls_assert ();
364 return GNUTLS_E_BASE64_DECODING_ERROR; 364 return GNUTLS_E_BASE64_DECODING_ERROR;
365 } 365 }
366 366
367 *cert_list = 367 *cert_list =
368 (gnutls_cert *) mhd_gtls_realloc_fast (*cert_list, 368 (MHD_gnutls_cert *) MHD_gtls_realloc_fast (*cert_list,
369 i * sizeof (gnutls_cert)); 369 i * sizeof (MHD_gnutls_cert));
370 370
371 if (*cert_list == NULL) 371 if (*cert_list == NULL)
372 { 372 {
373 gnutls_assert (); 373 MHD_gnutls_assert ();
374 return GNUTLS_E_MEMORY_ERROR; 374 return GNUTLS_E_MEMORY_ERROR;
375 } 375 }
376 376
377 tmp.data = ptr2; 377 tmp.data = ptr2;
378 tmp.size = siz2; 378 tmp.size = siz2;
379 379
380 ret = mhd_gtls_x509_raw_cert_to_gcert (&cert_list[0][i - 1], &tmp, 0); 380 ret = MHD_gtls_x509_raw_cert_to_gcert (&cert_list[0][i - 1], &tmp, 0);
381 if (ret < 0) 381 if (ret < 0)
382 { 382 {
383 gnutls_assert (); 383 MHD_gnutls_assert ();
384 return ret; 384 return ret;
385 } 385 }
386 _gnutls_free_datum (&tmp); /* free ptr2 */ 386 MHD__gnutls_free_datum (&tmp); /* free ptr2 */
387 387
388 /* now we move ptr after the pem header 388 /* now we move ptr after the pem header
389 */ 389 */
@@ -396,9 +396,9 @@ parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts,
396 { 396 {
397 char *ptr3; 397 char *ptr3;
398 398
399 ptr3 = memmem (ptr, size, PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1); 399 ptr3 = MHD_memmem (ptr, size, PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
400 if (ptr3 == NULL) 400 if (ptr3 == NULL)
401 ptr3 = memmem (ptr, size, PEM_CERT_SEP2, 401 ptr3 = MHD_memmem (ptr, size, PEM_CERT_SEP2,
402 sizeof (PEM_CERT_SEP2) - 1); 402 sizeof (PEM_CERT_SEP2) - 1);
403 403
404 ptr = ptr3; 404 ptr = ptr3;
@@ -422,30 +422,30 @@ parse_pem_cert_mem (gnutls_cert ** cert_list, unsigned *ncerts,
422/* Reads a DER or PEM certificate from memory 422/* Reads a DER or PEM certificate from memory
423 */ 423 */
424static int 424static int
425read_cert_mem (mhd_gtls_cert_credentials_t res, const void *cert, 425read_cert_mem (MHD_gtls_cert_credentials_t res, const void *cert,
426 int cert_size, gnutls_x509_crt_fmt_t type) 426 int cert_size, MHD_gnutls_x509_crt_fmt_t type)
427{ 427{
428 int ret; 428 int ret;
429 429
430 /* allocate space for the certificate to add 430 /* allocate space for the certificate to add
431 */ 431 */
432 res->cert_list = mhd_gtls_realloc_fast (res->cert_list, 432 res->cert_list = MHD_gtls_realloc_fast (res->cert_list,
433 (1 + 433 (1 +
434 res->ncerts) * 434 res->ncerts) *
435 sizeof (gnutls_cert *)); 435 sizeof (MHD_gnutls_cert *));
436 if (res->cert_list == NULL) 436 if (res->cert_list == NULL)
437 { 437 {
438 gnutls_assert (); 438 MHD_gnutls_assert ();
439 return GNUTLS_E_MEMORY_ERROR; 439 return GNUTLS_E_MEMORY_ERROR;
440 } 440 }
441 441
442 res->cert_list_length = mhd_gtls_realloc_fast (res->cert_list_length, 442 res->cert_list_length = MHD_gtls_realloc_fast (res->cert_list_length,
443 (1 + 443 (1 +
444 res->ncerts) * 444 res->ncerts) *
445 sizeof (int)); 445 sizeof (int));
446 if (res->cert_list_length == NULL) 446 if (res->cert_list_length == NULL)
447 { 447 {
448 gnutls_assert (); 448 MHD_gnutls_assert ();
449 return GNUTLS_E_MEMORY_ERROR; 449 return GNUTLS_E_MEMORY_ERROR;
450 } 450 }
451 451
@@ -464,7 +464,7 @@ read_cert_mem (mhd_gtls_cert_credentials_t res, const void *cert,
464 464
465 if (ret < 0) 465 if (ret < 0)
466 { 466 {
467 gnutls_assert (); 467 MHD_gnutls_assert ();
468 return ret; 468 return ret;
469 } 469 }
470 470
@@ -473,19 +473,19 @@ read_cert_mem (mhd_gtls_cert_credentials_t res, const void *cert,
473 473
474 474
475int 475int
476_gnutls_x509_privkey_to_gkey (gnutls_privkey * dest, 476MHD__gnutls_x509_privkey_to_gkey (MHD_gnutls_privkey * dest,
477 gnutls_x509_privkey_t src) 477 MHD_gnutls_x509_privkey_t src)
478{ 478{
479 int i, ret; 479 int i, ret;
480 480
481 memset (dest, 0, sizeof (gnutls_privkey)); 481 memset (dest, 0, sizeof (MHD_gnutls_privkey));
482 482
483 for (i = 0; i < src->params_size; i++) 483 for (i = 0; i < src->params_size; i++)
484 { 484 {
485 dest->params[i] = _gnutls_mpi_copy (src->params[i]); 485 dest->params[i] = MHD__gnutls_mpi_copy (src->params[i]);
486 if (dest->params[i] == NULL) 486 if (dest->params[i] == NULL)
487 { 487 {
488 gnutls_assert (); 488 MHD_gnutls_assert ();
489 ret = GNUTLS_E_MEMORY_ERROR; 489 ret = GNUTLS_E_MEMORY_ERROR;
490 goto cleanup; 490 goto cleanup;
491 } 491 }
@@ -500,13 +500,13 @@ cleanup:
500 500
501 for (i = 0; i < src->params_size; i++) 501 for (i = 0; i < src->params_size; i++)
502 { 502 {
503 mhd_gtls_mpi_release (&dest->params[i]); 503 MHD_gtls_mpi_release (&dest->params[i]);
504 } 504 }
505 return ret; 505 return ret;
506} 506}
507 507
508void 508void
509mhd_gtls_gkey_deinit (gnutls_privkey * key) 509MHD_gtls_gkey_deinit (MHD_gnutls_privkey * key)
510{ 510{
511 int i; 511 int i;
512 if (key == NULL) 512 if (key == NULL)
@@ -514,51 +514,51 @@ mhd_gtls_gkey_deinit (gnutls_privkey * key)
514 514
515 for (i = 0; i < key->params_size; i++) 515 for (i = 0; i < key->params_size; i++)
516 { 516 {
517 mhd_gtls_mpi_release (&key->params[i]); 517 MHD_gtls_mpi_release (&key->params[i]);
518 } 518 }
519} 519}
520 520
521int 521int
522_gnutls_x509_raw_privkey_to_gkey (gnutls_privkey * privkey, 522MHD__gnutls_x509_raw_privkey_to_gkey (MHD_gnutls_privkey * privkey,
523 const gnutls_datum_t * raw_key, 523 const MHD_gnutls_datum_t * raw_key,
524 gnutls_x509_crt_fmt_t type) 524 MHD_gnutls_x509_crt_fmt_t type)
525{ 525{
526 gnutls_x509_privkey_t tmpkey; 526 MHD_gnutls_x509_privkey_t tmpkey;
527 int ret; 527 int ret;
528 528
529 ret = gnutls_x509_privkey_init (&tmpkey); 529 ret = MHD_gnutls_x509_privkey_init (&tmpkey);
530 if (ret < 0) 530 if (ret < 0)
531 { 531 {
532 gnutls_assert (); 532 MHD_gnutls_assert ();
533 return ret; 533 return ret;
534 } 534 }
535 535
536 ret = gnutls_x509_privkey_import (tmpkey, raw_key, type); 536 ret = MHD_gnutls_x509_privkey_import (tmpkey, raw_key, type);
537 537
538#ifdef ENABLE_PKI 538#ifdef ENABLE_PKI
539 /* If normal key decoding doesn't work try decoding a plain PKCS #8 key */ 539 /* If normal key decoding doesn't work try decoding a plain PKCS #8 key */
540 if (ret < 0) 540 if (ret < 0)
541 ret = 541 ret =
542 gnutls_x509_privkey_import_pkcs8 (tmpkey, raw_key, type, NULL, 542 MHD_gnutls_x509_privkey_import_pkcs8 (tmpkey, raw_key, type, NULL,
543 GNUTLS_PKCS_PLAIN); 543 GNUTLS_PKCS_PLAIN);
544#endif 544#endif
545 545
546 if (ret < 0) 546 if (ret < 0)
547 { 547 {
548 gnutls_assert (); 548 MHD_gnutls_assert ();
549 gnutls_x509_privkey_deinit (tmpkey); 549 MHD_gnutls_x509_privkey_deinit (tmpkey);
550 return ret; 550 return ret;
551 } 551 }
552 552
553 ret = _gnutls_x509_privkey_to_gkey (privkey, tmpkey); 553 ret = MHD__gnutls_x509_privkey_to_gkey (privkey, tmpkey);
554 if (ret < 0) 554 if (ret < 0)
555 { 555 {
556 gnutls_assert (); 556 MHD_gnutls_assert ();
557 gnutls_x509_privkey_deinit (tmpkey); 557 MHD_gnutls_x509_privkey_deinit (tmpkey);
558 return ret; 558 return ret;
559 } 559 }
560 560
561 gnutls_x509_privkey_deinit (tmpkey); 561 MHD_gnutls_x509_privkey_deinit (tmpkey);
562 562
563 return 0; 563 return 0;
564} 564}
@@ -568,20 +568,20 @@ _gnutls_x509_raw_privkey_to_gkey (gnutls_privkey * privkey,
568 * that GnuTLS doesn't know the private key. 568 * that GnuTLS doesn't know the private key.
569 */ 569 */
570static int 570static int
571read_key_mem (mhd_gtls_cert_credentials_t res, 571read_key_mem (MHD_gtls_cert_credentials_t res,
572 const void *key, int key_size, gnutls_x509_crt_fmt_t type) 572 const void *key, int key_size, MHD_gnutls_x509_crt_fmt_t type)
573{ 573{
574 int ret; 574 int ret;
575 gnutls_datum_t tmp; 575 MHD_gnutls_datum_t tmp;
576 576
577 /* allocate space for the pkey list 577 /* allocate space for the pkey list
578 */ 578 */
579 res->pkey = 579 res->pkey =
580 mhd_gtls_realloc_fast (res->pkey, 580 MHD_gtls_realloc_fast (res->pkey,
581 (res->ncerts + 1) * sizeof (gnutls_privkey)); 581 (res->ncerts + 1) * sizeof (MHD_gnutls_privkey));
582 if (res->pkey == NULL) 582 if (res->pkey == NULL)
583 { 583 {
584 gnutls_assert (); 584 MHD_gnutls_assert ();
585 return GNUTLS_E_MEMORY_ERROR; 585 return GNUTLS_E_MEMORY_ERROR;
586 } 586 }
587 587
@@ -591,29 +591,29 @@ read_key_mem (mhd_gtls_cert_credentials_t res,
591 tmp.size = key_size; 591 tmp.size = key_size;
592 592
593 ret = 593 ret =
594 _gnutls_x509_raw_privkey_to_gkey (&res->pkey[res->ncerts], &tmp, 594 MHD__gnutls_x509_raw_privkey_to_gkey (&res->pkey[res->ncerts], &tmp,
595 type); 595 type);
596 if (ret < 0) 596 if (ret < 0)
597 { 597 {
598 gnutls_assert (); 598 MHD_gnutls_assert ();
599 return ret; 599 return ret;
600 } 600 }
601 } 601 }
602 else 602 else
603 memset (&res->pkey[res->ncerts], 0, sizeof (gnutls_privkey)); 603 memset (&res->pkey[res->ncerts], 0, sizeof (MHD_gnutls_privkey));
604 604
605 return 0; 605 return 0;
606} 606}
607 607
608/** 608/**
609 * MHD_gnutls_certificate_set_x509_key_mem - Used to set keys in a mhd_gtls_cert_credentials_t structure 609 * MHD__gnutls_certificate_set_x509_key_mem - Used to set keys in a MHD_gtls_cert_credentials_t structure
610 * @res: is an #mhd_gtls_cert_credentials_t structure. 610 * @res: is an #MHD_gtls_cert_credentials_t structure.
611 * @cert: contains a certificate list (path) for the specified private key 611 * @cert: contains a certificate list (path) for the specified private key
612 * @key: is the private key, or %NULL 612 * @key: is the private key, or %NULL
613 * @type: is PEM or DER 613 * @type: is PEM or DER
614 * 614 *
615 * This function sets a certificate/private key pair in the 615 * This function sets a certificate/private key pair in the
616 * mhd_gtls_cert_credentials_t structure. This function may be called 616 * MHD_gtls_cert_credentials_t structure. This function may be called
617 * more than once (in case multiple keys/certificates exist for the 617 * more than once (in case multiple keys/certificates exist for the
618 * server). 618 * server).
619 * 619 *
@@ -636,10 +636,10 @@ read_key_mem (mhd_gtls_cert_credentials_t res,
636 * Returns: %GNUTLS_E_SUCCESS on success, or an error code. 636 * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
637 **/ 637 **/
638int 638int
639MHD_gnutls_certificate_set_x509_key_mem (mhd_gtls_cert_credentials_t 639MHD__gnutls_certificate_set_x509_key_mem (MHD_gtls_cert_credentials_t
640 res, const gnutls_datum_t * cert, 640 res, const MHD_gnutls_datum_t * cert,
641 const gnutls_datum_t * key, 641 const MHD_gnutls_datum_t * key,
642 gnutls_x509_crt_fmt_t type) 642 MHD_gnutls_x509_crt_fmt_t type)
643{ 643{
644 int ret; 644 int ret;
645 645
@@ -654,9 +654,9 @@ MHD_gnutls_certificate_set_x509_key_mem (mhd_gtls_cert_credentials_t
654 654
655 res->ncerts++; 655 res->ncerts++;
656 656
657 if (key && (ret = _gnutls_check_key_cert_match (res)) < 0) 657 if (key && (ret = MHD__gnutls_check_key_cert_match (res)) < 0)
658 { 658 {
659 gnutls_assert (); 659 MHD_gnutls_assert ();
660 return ret; 660 return ret;
661 } 661 }
662 662
@@ -664,9 +664,9 @@ MHD_gnutls_certificate_set_x509_key_mem (mhd_gtls_cert_credentials_t
664} 664}
665 665
666static int 666static int
667generate_rdn_seq (mhd_gtls_cert_credentials_t res) 667generate_rdn_seq (MHD_gtls_cert_credentials_t res)
668{ 668{
669 gnutls_datum_t tmp; 669 MHD_gnutls_datum_t tmp;
670 int ret; 670 int ret;
671 unsigned size, i; 671 unsigned size, i;
672 opaque *pdata; 672 opaque *pdata;
@@ -685,22 +685,22 @@ generate_rdn_seq (mhd_gtls_cert_credentials_t res)
685 size = 0; 685 size = 0;
686 for (i = 0; i < res->x509_ncas; i++) 686 for (i = 0; i < res->x509_ncas; i++)
687 { 687 {
688 if ((ret = gnutls_x509_crt_get_raw_dn (res->x509_ca_list[i], &tmp)) < 0) 688 if ((ret = MHD_gnutls_x509_crt_get_raw_dn (res->x509_ca_list[i], &tmp)) < 0)
689 { 689 {
690 gnutls_assert (); 690 MHD_gnutls_assert ();
691 return ret; 691 return ret;
692 } 692 }
693 size += (2 + tmp.size); 693 size += (2 + tmp.size);
694 _gnutls_free_datum (&tmp); 694 MHD__gnutls_free_datum (&tmp);
695 } 695 }
696 696
697 if (res->x509_rdn_sequence.data != NULL) 697 if (res->x509_rdn_sequence.data != NULL)
698 gnutls_free (res->x509_rdn_sequence.data); 698 MHD_gnutls_free (res->x509_rdn_sequence.data);
699 699
700 res->x509_rdn_sequence.data = gnutls_malloc (size); 700 res->x509_rdn_sequence.data = MHD_gnutls_malloc (size);
701 if (res->x509_rdn_sequence.data == NULL) 701 if (res->x509_rdn_sequence.data == NULL)
702 { 702 {
703 gnutls_assert (); 703 MHD_gnutls_assert ();
704 return GNUTLS_E_MEMORY_ERROR; 704 return GNUTLS_E_MEMORY_ERROR;
705 } 705 }
706 res->x509_rdn_sequence.size = size; 706 res->x509_rdn_sequence.size = size;
@@ -709,16 +709,16 @@ generate_rdn_seq (mhd_gtls_cert_credentials_t res)
709 709
710 for (i = 0; i < res->x509_ncas; i++) 710 for (i = 0; i < res->x509_ncas; i++)
711 { 711 {
712 if ((ret = gnutls_x509_crt_get_raw_dn (res->x509_ca_list[i], &tmp)) < 0) 712 if ((ret = MHD_gnutls_x509_crt_get_raw_dn (res->x509_ca_list[i], &tmp)) < 0)
713 { 713 {
714 _gnutls_free_datum (&res->x509_rdn_sequence); 714 MHD__gnutls_free_datum (&res->x509_rdn_sequence);
715 gnutls_assert (); 715 MHD_gnutls_assert ();
716 return ret; 716 return ret;
717 } 717 }
718 718
719 mhd_gtls_write_datum16 (pdata, tmp); 719 MHD_gtls_write_datum16 (pdata, tmp);
720 pdata += (2 + tmp.size); 720 pdata += (2 + tmp.size);
721 _gnutls_free_datum (&tmp); 721 MHD__gnutls_free_datum (&tmp);
722 } 722 }
723 723
724 return 0; 724 return 0;
@@ -728,7 +728,7 @@ generate_rdn_seq (mhd_gtls_cert_credentials_t res)
728 * certificate (uses the KeyUsage field). 728 * certificate (uses the KeyUsage field).
729 */ 729 */
730int 730int
731_gnutls_check_key_usage (const gnutls_cert * cert, 731MHD__gnutls_check_key_usage (const MHD_gnutls_cert * cert,
732 enum MHD_GNUTLS_KeyExchangeAlgorithm alg) 732 enum MHD_GNUTLS_KeyExchangeAlgorithm alg)
733{ 733{
734 unsigned int key_usage = 0; 734 unsigned int key_usage = 0;
@@ -736,17 +736,17 @@ _gnutls_check_key_usage (const gnutls_cert * cert,
736 736
737 if (cert == NULL) 737 if (cert == NULL)
738 { 738 {
739 gnutls_assert (); 739 MHD_gnutls_assert ();
740 return GNUTLS_E_INTERNAL_ERROR; 740 return GNUTLS_E_INTERNAL_ERROR;
741 } 741 }
742 742
743 if (mhd_gtls_map_kx_get_cred (alg, 1) == MHD_GNUTLS_CRD_CERTIFICATE || 743 if (MHD_gtls_map_kx_get_cred (alg, 1) == MHD_GNUTLS_CRD_CERTIFICATE ||
744 mhd_gtls_map_kx_get_cred (alg, 0) == MHD_GNUTLS_CRD_CERTIFICATE) 744 MHD_gtls_map_kx_get_cred (alg, 0) == MHD_GNUTLS_CRD_CERTIFICATE)
745 { 745 {
746 746
747 key_usage = cert->key_usage; 747 key_usage = cert->key_usage;
748 748
749 encipher_type = mhd_gtls_kx_encipher_type (alg); 749 encipher_type = MHD_gtls_kx_encipher_type (alg);
750 750
751 if (key_usage != 0 && encipher_type != CIPHER_IGN) 751 if (key_usage != 0 && encipher_type != CIPHER_IGN)
752 { 752 {
@@ -761,7 +761,7 @@ _gnutls_check_key_usage (const gnutls_cert * cert,
761 */ 761 */
762 if (!(key_usage & KEY_KEY_ENCIPHERMENT)) 762 if (!(key_usage & KEY_KEY_ENCIPHERMENT))
763 { 763 {
764 gnutls_assert (); 764 MHD_gnutls_assert ();
765 return GNUTLS_E_KEY_USAGE_VIOLATION; 765 return GNUTLS_E_KEY_USAGE_VIOLATION;
766 } 766 }
767 } 767 }
@@ -772,7 +772,7 @@ _gnutls_check_key_usage (const gnutls_cert * cert,
772 */ 772 */
773 if (!(key_usage & KEY_DIGITAL_SIGNATURE)) 773 if (!(key_usage & KEY_DIGITAL_SIGNATURE))
774 { 774 {
775 gnutls_assert (); 775 MHD_gnutls_assert ();
776 return GNUTLS_E_KEY_USAGE_VIOLATION; 776 return GNUTLS_E_KEY_USAGE_VIOLATION;
777 } 777 }
778 } 778 }
@@ -784,25 +784,25 @@ _gnutls_check_key_usage (const gnutls_cert * cert,
784 784
785 785
786static int 786static int
787parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts, 787parse_pem_ca_mem (MHD_gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
788 const opaque * input_cert, int input_cert_size) 788 const opaque * input_cert, int input_cert_size)
789{ 789{
790 int i, size; 790 int i, size;
791 const opaque *ptr; 791 const opaque *ptr;
792 gnutls_datum_t tmp; 792 MHD_gnutls_datum_t tmp;
793 int ret, count; 793 int ret, count;
794 794
795 /* move to the certificate 795 /* move to the certificate
796 */ 796 */
797 ptr = memmem (input_cert, input_cert_size, 797 ptr = MHD_memmem (input_cert, input_cert_size,
798 PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1); 798 PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
799 if (ptr == NULL) 799 if (ptr == NULL)
800 ptr = memmem (input_cert, input_cert_size, 800 ptr = MHD_memmem (input_cert, input_cert_size,
801 PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1); 801 PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1);
802 802
803 if (ptr == NULL) 803 if (ptr == NULL)
804 { 804 {
805 gnutls_assert (); 805 MHD_gnutls_assert ();
806 return GNUTLS_E_BASE64_DECODING_ERROR; 806 return GNUTLS_E_BASE64_DECODING_ERROR;
807 } 807 }
808 size = input_cert_size - (ptr - input_cert); 808 size = input_cert_size - (ptr - input_cert);
@@ -814,21 +814,21 @@ parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
814 { 814 {
815 815
816 *cert_list = 816 *cert_list =
817 (gnutls_x509_crt_t *) mhd_gtls_realloc_fast (*cert_list, 817 (MHD_gnutls_x509_crt_t *) MHD_gtls_realloc_fast (*cert_list,
818 i * 818 i *
819 sizeof 819 sizeof
820 (gnutls_x509_crt_t)); 820 (MHD_gnutls_x509_crt_t));
821 821
822 if (*cert_list == NULL) 822 if (*cert_list == NULL)
823 { 823 {
824 gnutls_assert (); 824 MHD_gnutls_assert ();
825 return GNUTLS_E_MEMORY_ERROR; 825 return GNUTLS_E_MEMORY_ERROR;
826 } 826 }
827 827
828 ret = gnutls_x509_crt_init (&cert_list[0][i - 1]); 828 ret = MHD_gnutls_x509_crt_init (&cert_list[0][i - 1]);
829 if (ret < 0) 829 if (ret < 0)
830 { 830 {
831 gnutls_assert (); 831 MHD_gnutls_assert ();
832 return ret; 832 return ret;
833 } 833 }
834 834
@@ -836,11 +836,11 @@ parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
836 tmp.size = size; 836 tmp.size = size;
837 837
838 ret = 838 ret =
839 gnutls_x509_crt_import (cert_list[0][i - 1], 839 MHD_gnutls_x509_crt_import (cert_list[0][i - 1],
840 &tmp, GNUTLS_X509_FMT_PEM); 840 &tmp, GNUTLS_X509_FMT_PEM);
841 if (ret < 0) 841 if (ret < 0)
842 { 842 {
843 gnutls_assert (); 843 MHD_gnutls_assert ();
844 return ret; 844 return ret;
845 } 845 }
846 846
@@ -855,9 +855,9 @@ parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
855 { 855 {
856 char *ptr3; 856 char *ptr3;
857 857
858 ptr3 = memmem (ptr, size, PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1); 858 ptr3 = MHD_memmem (ptr, size, PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
859 if (ptr3 == NULL) 859 if (ptr3 == NULL)
860 ptr3 = memmem (ptr, size, 860 ptr3 = MHD_memmem (ptr, size,
861 PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1); 861 PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1);
862 862
863 ptr = (const opaque *) ptr3; 863 ptr = (const opaque *) ptr3;
@@ -878,45 +878,45 @@ parse_pem_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
878} 878}
879 879
880/* Reads a DER encoded certificate list from memory and stores it to 880/* Reads a DER encoded certificate list from memory and stores it to
881 * a gnutls_cert structure. 881 * a MHD_gnutls_cert structure.
882 * returns the number of certificates parsed. 882 * returns the number of certificates parsed.
883 */ 883 */
884static int 884static int
885parse_der_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts, 885parse_der_ca_mem (MHD_gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
886 const void *input_cert, int input_cert_size) 886 const void *input_cert, int input_cert_size)
887{ 887{
888 int i; 888 int i;
889 gnutls_datum_t tmp; 889 MHD_gnutls_datum_t tmp;
890 int ret; 890 int ret;
891 891
892 i = *ncerts + 1; 892 i = *ncerts + 1;
893 893
894 *cert_list = 894 *cert_list =
895 (gnutls_x509_crt_t *) mhd_gtls_realloc_fast (*cert_list, 895 (MHD_gnutls_x509_crt_t *) MHD_gtls_realloc_fast (*cert_list,
896 i * 896 i *
897 sizeof (gnutls_x509_crt_t)); 897 sizeof (MHD_gnutls_x509_crt_t));
898 898
899 if (*cert_list == NULL) 899 if (*cert_list == NULL)
900 { 900 {
901 gnutls_assert (); 901 MHD_gnutls_assert ();
902 return GNUTLS_E_MEMORY_ERROR; 902 return GNUTLS_E_MEMORY_ERROR;
903 } 903 }
904 904
905 tmp.data = (opaque *) input_cert; 905 tmp.data = (opaque *) input_cert;
906 tmp.size = input_cert_size; 906 tmp.size = input_cert_size;
907 907
908 ret = gnutls_x509_crt_init (&cert_list[0][i - 1]); 908 ret = MHD_gnutls_x509_crt_init (&cert_list[0][i - 1]);
909 if (ret < 0) 909 if (ret < 0)
910 { 910 {
911 gnutls_assert (); 911 MHD_gnutls_assert ();
912 return ret; 912 return ret;
913 } 913 }
914 914
915 ret = 915 ret =
916 gnutls_x509_crt_import (cert_list[0][i - 1], &tmp, GNUTLS_X509_FMT_DER); 916 MHD_gnutls_x509_crt_import (cert_list[0][i - 1], &tmp, GNUTLS_X509_FMT_DER);
917 if (ret < 0) 917 if (ret < 0)
918 { 918 {
919 gnutls_assert (); 919 MHD_gnutls_assert ();
920 return ret; 920 return ret;
921 } 921 }
922 922
@@ -926,8 +926,8 @@ parse_der_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
926} 926}
927 927
928/** 928/**
929 * MHD_gnutls_certificate_set_x509_trust_mem - Used to add trusted CAs in a mhd_gtls_cert_credentials_t structure 929 * MHD__gnutls_certificate_set_x509_trust_mem - Used to add trusted CAs in a MHD_gtls_cert_credentials_t structure
930 * @res: is an #mhd_gtls_cert_credentials_t structure. 930 * @res: is an #MHD_gtls_cert_credentials_t structure.
931 * @ca: is a list of trusted CAs or a DER certificate 931 * @ca: is a list of trusted CAs or a DER certificate
932 * @type: is DER or PEM 932 * @type: is DER or PEM
933 * 933 *
@@ -939,15 +939,15 @@ parse_der_ca_mem (gnutls_x509_crt_t ** cert_list, unsigned *ncerts,
939 * 939 *
940 * In case of a server the CAs set here will be sent to the client if 940 * In case of a server the CAs set here will be sent to the client if
941 * a certificate request is sent. This can be disabled using 941 * a certificate request is sent. This can be disabled using
942 * MHD_gnutls_certificate_send_x509_rdn_sequence(). 942 * MHD__gnutls_certificate_send_x509_rdn_sequence().
943 * 943 *
944 * Returns: the number of certificates processed or a negative value 944 * Returns: the number of certificates processed or a negative value
945 * on error. 945 * on error.
946 **/ 946 **/
947int 947int
948MHD_gnutls_certificate_set_x509_trust_mem (mhd_gtls_cert_credentials_t 948MHD__gnutls_certificate_set_x509_trust_mem (MHD_gtls_cert_credentials_t
949 res, const gnutls_datum_t * ca, 949 res, const MHD_gnutls_datum_t * ca,
950 gnutls_x509_crt_fmt_t type) 950 MHD_gnutls_x509_crt_fmt_t type)
951{ 951{
952 int ret, ret2; 952 int ret, ret2;
953 953
@@ -967,21 +967,21 @@ MHD_gnutls_certificate_set_x509_trust_mem (mhd_gtls_cert_credentials_t
967#ifdef ENABLE_PKI 967#ifdef ENABLE_PKI
968 968
969static int 969static int
970parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls, 970parse_pem_crl_mem (MHD_gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
971 const opaque * input_crl, int input_crl_size) 971 const opaque * input_crl, int input_crl_size)
972{ 972{
973 int size, i; 973 int size, i;
974 const opaque *ptr; 974 const opaque *ptr;
975 gnutls_datum_t tmp; 975 MHD_gnutls_datum_t tmp;
976 int ret, count; 976 int ret, count;
977 977
978 /* move to the certificate 978 /* move to the certificate
979 */ 979 */
980 ptr = memmem (input_crl, input_crl_size, 980 ptr = MHD_memmem (input_crl, input_crl_size,
981 PEM_CRL_SEP, sizeof (PEM_CRL_SEP) - 1); 981 PEM_CRL_SEP, sizeof (PEM_CRL_SEP) - 1);
982 if (ptr == NULL) 982 if (ptr == NULL)
983 { 983 {
984 gnutls_assert (); 984 MHD_gnutls_assert ();
985 return GNUTLS_E_BASE64_DECODING_ERROR; 985 return GNUTLS_E_BASE64_DECODING_ERROR;
986 } 986 }
987 987
@@ -994,21 +994,21 @@ parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
994 { 994 {
995 995
996 *crl_list = 996 *crl_list =
997 (gnutls_x509_crl_t *) mhd_gtls_realloc_fast (*crl_list, 997 (MHD_gnutls_x509_crl_t *) MHD_gtls_realloc_fast (*crl_list,
998 i * 998 i *
999 sizeof 999 sizeof
1000 (gnutls_x509_crl_t)); 1000 (MHD_gnutls_x509_crl_t));
1001 1001
1002 if (*crl_list == NULL) 1002 if (*crl_list == NULL)
1003 { 1003 {
1004 gnutls_assert (); 1004 MHD_gnutls_assert ();
1005 return GNUTLS_E_MEMORY_ERROR; 1005 return GNUTLS_E_MEMORY_ERROR;
1006 } 1006 }
1007 1007
1008 ret = gnutls_x509_crl_init (&crl_list[0][i - 1]); 1008 ret = MHD_gnutls_x509_crl_init (&crl_list[0][i - 1]);
1009 if (ret < 0) 1009 if (ret < 0)
1010 { 1010 {
1011 gnutls_assert (); 1011 MHD_gnutls_assert ();
1012 return ret; 1012 return ret;
1013 } 1013 }
1014 1014
@@ -1016,11 +1016,11 @@ parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
1016 tmp.size = size; 1016 tmp.size = size;
1017 1017
1018 ret = 1018 ret =
1019 gnutls_x509_crl_import (crl_list[0][i - 1], 1019 MHD_gnutls_x509_crl_import (crl_list[0][i - 1],
1020 &tmp, GNUTLS_X509_FMT_PEM); 1020 &tmp, GNUTLS_X509_FMT_PEM);
1021 if (ret < 0) 1021 if (ret < 0)
1022 { 1022 {
1023 gnutls_assert (); 1023 MHD_gnutls_assert ();
1024 return ret; 1024 return ret;
1025 } 1025 }
1026 1026
@@ -1033,7 +1033,7 @@ parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
1033 size = input_crl_size - (ptr - input_crl); 1033 size = input_crl_size - (ptr - input_crl);
1034 1034
1035 if (size > 0) 1035 if (size > 0)
1036 ptr = memmem (ptr, size, PEM_CRL_SEP, sizeof (PEM_CRL_SEP) - 1); 1036 ptr = MHD_memmem (ptr, size, PEM_CRL_SEP, sizeof (PEM_CRL_SEP) - 1);
1037 else 1037 else
1038 ptr = NULL; 1038 ptr = NULL;
1039 i++; 1039 i++;
@@ -1048,45 +1048,45 @@ parse_pem_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
1048} 1048}
1049 1049
1050/* Reads a DER encoded certificate list from memory and stores it to 1050/* Reads a DER encoded certificate list from memory and stores it to
1051 * a gnutls_cert structure. 1051 * a MHD_gnutls_cert structure.
1052 * returns the number of certificates parsed. 1052 * returns the number of certificates parsed.
1053 */ 1053 */
1054static int 1054static int
1055parse_der_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls, 1055parse_der_crl_mem (MHD_gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
1056 const void *input_crl, int input_crl_size) 1056 const void *input_crl, int input_crl_size)
1057{ 1057{
1058 int i; 1058 int i;
1059 gnutls_datum_t tmp; 1059 MHD_gnutls_datum_t tmp;
1060 int ret; 1060 int ret;
1061 1061
1062 i = *ncrls + 1; 1062 i = *ncrls + 1;
1063 1063
1064 *crl_list = 1064 *crl_list =
1065 (gnutls_x509_crl_t *) mhd_gtls_realloc_fast (*crl_list, 1065 (MHD_gnutls_x509_crl_t *) MHD_gtls_realloc_fast (*crl_list,
1066 i * 1066 i *
1067 sizeof (gnutls_x509_crl_t)); 1067 sizeof (MHD_gnutls_x509_crl_t));
1068 1068
1069 if (*crl_list == NULL) 1069 if (*crl_list == NULL)
1070 { 1070 {
1071 gnutls_assert (); 1071 MHD_gnutls_assert ();
1072 return GNUTLS_E_MEMORY_ERROR; 1072 return GNUTLS_E_MEMORY_ERROR;
1073 } 1073 }
1074 1074
1075 tmp.data = (opaque *) input_crl; 1075 tmp.data = (opaque *) input_crl;
1076 tmp.size = input_crl_size; 1076 tmp.size = input_crl_size;
1077 1077
1078 ret = gnutls_x509_crl_init (&crl_list[0][i - 1]); 1078 ret = MHD_gnutls_x509_crl_init (&crl_list[0][i - 1]);
1079 if (ret < 0) 1079 if (ret < 0)
1080 { 1080 {
1081 gnutls_assert (); 1081 MHD_gnutls_assert ();
1082 return ret; 1082 return ret;
1083 } 1083 }
1084 1084
1085 ret = 1085 ret =
1086 gnutls_x509_crl_import (crl_list[0][i - 1], &tmp, GNUTLS_X509_FMT_DER); 1086 MHD_gnutls_x509_crl_import (crl_list[0][i - 1], &tmp, GNUTLS_X509_FMT_DER);
1087 if (ret < 0) 1087 if (ret < 0)
1088 { 1088 {
1089 gnutls_assert (); 1089 MHD_gnutls_assert ();
1090 return ret; 1090 return ret;
1091 } 1091 }
1092 1092
@@ -1099,20 +1099,20 @@ parse_der_crl_mem (gnutls_x509_crl_t ** crl_list, unsigned *ncrls,
1099/* Reads a DER or PEM CRL from memory 1099/* Reads a DER or PEM CRL from memory
1100 */ 1100 */
1101static int 1101static int
1102read_crl_mem (mhd_gtls_cert_credentials_t res, const void *crl, 1102read_crl_mem (MHD_gtls_cert_credentials_t res, const void *crl,
1103 int crl_size, gnutls_x509_crt_fmt_t type) 1103 int crl_size, MHD_gnutls_x509_crt_fmt_t type)
1104{ 1104{
1105 int ret; 1105 int ret;
1106 1106
1107 /* allocate space for the certificate to add 1107 /* allocate space for the certificate to add
1108 */ 1108 */
1109 res->x509_crl_list = mhd_gtls_realloc_fast (res->x509_crl_list, 1109 res->x509_crl_list = MHD_gtls_realloc_fast (res->x509_crl_list,
1110 (1 + 1110 (1 +
1111 res->x509_ncrls) * 1111 res->x509_ncrls) *
1112 sizeof (gnutls_x509_crl_t)); 1112 sizeof (MHD_gnutls_x509_crl_t));
1113 if (res->x509_crl_list == NULL) 1113 if (res->x509_crl_list == NULL)
1114 { 1114 {
1115 gnutls_assert (); 1115 MHD_gnutls_assert ();
1116 return GNUTLS_E_MEMORY_ERROR; 1116 return GNUTLS_E_MEMORY_ERROR;
1117 } 1117 }
1118 1118
@@ -1125,7 +1125,7 @@ read_crl_mem (mhd_gtls_cert_credentials_t res, const void *crl,
1125 1125
1126 if (ret < 0) 1126 if (ret < 0)
1127 { 1127 {
1128 gnutls_assert (); 1128 MHD_gnutls_assert ();
1129 return ret; 1129 return ret;
1130 } 1130 }
1131 1131
@@ -1133,8 +1133,8 @@ read_crl_mem (mhd_gtls_cert_credentials_t res, const void *crl,
1133} 1133}
1134 1134
1135/** 1135/**
1136 * MHD_gnutls_certificate_set_x509_crl_mem - Used to add CRLs in a mhd_gtls_cert_credentials_t structure 1136 * MHD__gnutls_certificate_set_x509_crl_mem - Used to add CRLs in a MHD_gtls_cert_credentials_t structure
1137 * @res: is an #mhd_gtls_cert_credentials_t structure. 1137 * @res: is an #MHD_gtls_cert_credentials_t structure.
1138 * @CRL: is a list of trusted CRLs. They should have been verified before. 1138 * @CRL: is a list of trusted CRLs. They should have been verified before.
1139 * @type: is DER or PEM 1139 * @type: is DER or PEM
1140 * 1140 *
@@ -1147,9 +1147,9 @@ read_crl_mem (mhd_gtls_cert_credentials_t res, const void *crl,
1147 * Returns: number of CRLs processed, or a negative value on error. 1147 * Returns: number of CRLs processed, or a negative value on error.
1148 **/ 1148 **/
1149int 1149int
1150MHD_gnutls_certificate_set_x509_crl_mem (mhd_gtls_cert_credentials_t 1150MHD__gnutls_certificate_set_x509_crl_mem (MHD_gtls_cert_credentials_t
1151 res, const gnutls_datum_t * CRL, 1151 res, const MHD_gnutls_datum_t * CRL,
1152 gnutls_x509_crt_fmt_t type) 1152 MHD_gnutls_x509_crt_fmt_t type)
1153{ 1153{
1154 int ret; 1154 int ret;
1155 1155
@@ -1162,26 +1162,26 @@ MHD_gnutls_certificate_set_x509_crl_mem (mhd_gtls_cert_credentials_t
1162#include <pkcs12.h> 1162#include <pkcs12.h>
1163 1163
1164/** 1164/**
1165 * MHD_gnutls_certificate_free_crls - Used to free all the CRLs from a mhd_gtls_cert_credentials_t structure 1165 * MHD__gnutls_certificate_free_crls - Used to free all the CRLs from a MHD_gtls_cert_credentials_t structure
1166 * @sc: is an #mhd_gtls_cert_credentials_t structure. 1166 * @sc: is an #MHD_gtls_cert_credentials_t structure.
1167 * 1167 *
1168 * This function will delete all the CRLs associated 1168 * This function will delete all the CRLs associated
1169 * with the given credentials. 1169 * with the given credentials.
1170 * 1170 *
1171 **/ 1171 **/
1172void 1172void
1173MHD_gnutls_certificate_free_crls (mhd_gtls_cert_credentials_t sc) 1173MHD__gnutls_certificate_free_crls (MHD_gtls_cert_credentials_t sc)
1174{ 1174{
1175 unsigned j; 1175 unsigned j;
1176 1176
1177 for (j = 0; j < sc->x509_ncrls; j++) 1177 for (j = 0; j < sc->x509_ncrls; j++)
1178 { 1178 {
1179 gnutls_x509_crl_deinit (sc->x509_crl_list[j]); 1179 MHD_gnutls_x509_crl_deinit (sc->x509_crl_list[j]);
1180 } 1180 }
1181 1181
1182 sc->x509_ncrls = 0; 1182 sc->x509_ncrls = 0;
1183 1183
1184 gnutls_free (sc->x509_crl_list); 1184 MHD_gnutls_free (sc->x509_crl_list);
1185 sc->x509_crl_list = NULL; 1185 sc->x509_crl_list = NULL;
1186} 1186}
1187 1187
diff --git a/src/daemon/https/tls/gnutls_x509.h b/src/daemon/https/tls/gnutls_x509.h
index b0135d95..b2d92603 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 (mhd_gtls_session_t session, 27int MHD__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"
@@ -35,14 +35,14 @@ int _gnutls_x509_cert_verify_peers (mhd_gtls_session_t session,
35#define PEM_KEY_RSA_SEP "-----BEGIN RSA" 35#define PEM_KEY_RSA_SEP "-----BEGIN RSA"
36#define PEM_KEY_DSA_SEP "-----BEGIN DSA" 36#define PEM_KEY_DSA_SEP "-----BEGIN DSA"
37 37
38int _gnutls_check_key_usage (const gnutls_cert * cert, 38int MHD__gnutls_check_key_usage (const MHD_gnutls_cert * cert,
39 enum MHD_GNUTLS_KeyExchangeAlgorithm alg); 39 enum MHD_GNUTLS_KeyExchangeAlgorithm alg);
40 40
41int _gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params); 41int MHD__gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params);
42int _gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params); 42int MHD__gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params);
43 43
44int _gnutls_x509_raw_privkey_to_gkey (gnutls_privkey * privkey, 44int MHD__gnutls_x509_raw_privkey_to_gkey (MHD_gnutls_privkey * privkey,
45 const gnutls_datum_t * raw_key, 45 const MHD_gnutls_datum_t * raw_key,
46 gnutls_x509_crt_fmt_t type); 46 MHD_gnutls_x509_crt_fmt_t type);
47int _gnutls_x509_privkey_to_gkey (gnutls_privkey * privkey, 47int MHD__gnutls_x509_privkey_to_gkey (MHD_gnutls_privkey * privkey,
48 gnutls_x509_privkey_t); 48 MHD_gnutls_x509_privkey_t);
diff --git a/src/daemon/https/tls/pkix_asn1_tab.c b/src/daemon/https/tls/pkix_asn1_tab.c
index e8471bfd..30b5ddd1 100644
--- a/src/daemon/https/tls/pkix_asn1_tab.c
+++ b/src/daemon/https/tls/pkix_asn1_tab.c
@@ -4,7 +4,7 @@
4 4
5#include <libtasn1.h> 5#include <libtasn1.h>
6 6
7const ASN1_ARRAY_TYPE pkix_asn1_tab[] = { 7const ASN1_ARRAY_TYPE MHD_pkix_asn1_tab[] = {
8 {"PKIX1", 536875024, 0}, 8 {"PKIX1", 536875024, 0},
9 {0, 1073741836, 0}, 9 {0, 1073741836, 0},
10 {"id-ce", 1879048204, 0}, 10 {"id-ce", 1879048204, 0},
diff --git a/src/daemon/https/tls/x509_b64.c b/src/daemon/https/tls/x509_b64.c
index d4100bc9..b19e301f 100644
--- a/src/daemon/https/tls/x509_b64.c
+++ b/src/daemon/https/tls/x509_b64.c
@@ -142,7 +142,7 @@ decode (uint8_t * result, const opaque * data)
142 * The result_size is the return value 142 * The result_size is the return value
143 */ 143 */
144int 144int
145_gnutls_base64_encode (const uint8_t * data, size_t data_size, 145MHD__gnutls_base64_encode (const uint8_t * data, size_t data_size,
146 uint8_t ** result) 146 uint8_t ** result)
147{ 147{
148 unsigned int i, j; 148 unsigned int i, j;
@@ -151,7 +151,7 @@ _gnutls_base64_encode (const uint8_t * data, size_t data_size,
151 151
152 ret = B64SIZE (data_size); 152 ret = B64SIZE (data_size);
153 153
154 (*result) = gnutls_malloc (ret + 1); 154 (*result) = MHD_gnutls_malloc (ret + 1);
155 if ((*result) == NULL) 155 if ((*result) == NULL)
156 return GNUTLS_E_MEMORY_ERROR; 156 return GNUTLS_E_MEMORY_ERROR;
157 157
@@ -160,7 +160,7 @@ _gnutls_base64_encode (const uint8_t * data, size_t data_size,
160 tmp = encode (tmpres, &data[i], data_size - i); 160 tmp = encode (tmpres, &data[i], data_size - i);
161 if (tmp == -1) 161 if (tmp == -1)
162 { 162 {
163 gnutls_free ((*result)); 163 MHD_gnutls_free ((*result));
164 return GNUTLS_E_MEMORY_ERROR; 164 return GNUTLS_E_MEMORY_ERROR;
165 } 165 }
166 memcpy (&(*result)[j], tmpres, tmp); 166 memcpy (&(*result)[j], tmpres, tmp);
@@ -174,8 +174,8 @@ _gnutls_base64_encode (const uint8_t * data, size_t data_size,
174 do { \ 174 do { \
175 what+=size; \ 175 what+=size; \
176 if (what > ret) { \ 176 if (what > ret) { \
177 gnutls_assert(); \ 177 MHD_gnutls_assert(); \
178 gnutls_free( (*result)); *result = NULL; \ 178 MHD_gnutls_free( (*result)); *result = NULL; \
179 return GNUTLS_E_INTERNAL_ERROR; \ 179 return GNUTLS_E_INTERNAL_ERROR; \
180 } \ 180 } \
181 } while(0) 181 } while(0)
@@ -184,7 +184,7 @@ _gnutls_base64_encode (const uint8_t * data, size_t data_size,
184 * The result_size (including the null terminator) is the return value. 184 * The result_size (including the null terminator) is the return value.
185 */ 185 */
186int 186int
187_gnutls_fbase64_encode (const char *msg, const uint8_t * data, 187MHD__gnutls_fbase64_encode (const char *msg, const uint8_t * data,
188 int data_size, uint8_t ** result) 188 int data_size, uint8_t ** result)
189{ 189{
190 int i, ret, tmp, j; 190 int i, ret, tmp, j;
@@ -197,7 +197,7 @@ _gnutls_fbase64_encode (const char *msg, const uint8_t * data,
197 197
198 if (msglen > 50) 198 if (msglen > 50)
199 { 199 {
200 gnutls_assert (); 200 MHD_gnutls_assert ();
201 return GNUTLS_E_BASE64_ENCODING_ERROR; 201 return GNUTLS_E_BASE64_ENCODING_ERROR;
202 } 202 }
203 203
@@ -217,10 +217,10 @@ _gnutls_fbase64_encode (const char *msg, const uint8_t * data,
217 217
218 ret = B64FSIZE (msglen, data_size); 218 ret = B64FSIZE (msglen, data_size);
219 219
220 (*result) = gnutls_calloc (1, ret + 1); 220 (*result) = MHD_gnutls_calloc (1, ret + 1);
221 if ((*result) == NULL) 221 if ((*result) == NULL)
222 { 222 {
223 gnutls_assert (); 223 MHD_gnutls_assert ();
224 return GNUTLS_E_MEMORY_ERROR; 224 return GNUTLS_E_MEMORY_ERROR;
225 } 225 }
226 226
@@ -236,8 +236,8 @@ _gnutls_fbase64_encode (const char *msg, const uint8_t * data,
236 tmp = encode (tmpres, &data[i], data_size - i); 236 tmp = encode (tmpres, &data[i], data_size - i);
237 if (tmp == -1) 237 if (tmp == -1)
238 { 238 {
239 gnutls_assert (); 239 MHD_gnutls_assert ();
240 gnutls_free ((*result)); 240 MHD_gnutls_free ((*result));
241 *result = NULL; 241 *result = NULL;
242 return GNUTLS_E_BASE64_ENCODING_ERROR; 242 return GNUTLS_E_BASE64_ENCODING_ERROR;
243 } 243 }
@@ -302,26 +302,26 @@ _gnutls_fbase64_encode (const char *msg, const uint8_t * data,
302 * 302 *
303 **/ 303 **/
304int 304int
305MHD_gtls_pem_base64_encode (const char *msg, const gnutls_datum_t * data, 305MHD_gtls_pem_base64_encode (const char *msg, const MHD_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;
309 int size; 309 int size;
310 310
311 size = _gnutls_fbase64_encode (msg, data->data, data->size, &ret); 311 size = MHD__gnutls_fbase64_encode (msg, data->data, data->size, &ret);
312 if (size < 0) 312 if (size < 0)
313 return size; 313 return size;
314 314
315 if (result == NULL || *result_size < (unsigned) size) 315 if (result == NULL || *result_size < (unsigned) size)
316 { 316 {
317 gnutls_free (ret); 317 MHD_gnutls_free (ret);
318 *result_size = size; 318 *result_size = size;
319 return GNUTLS_E_SHORT_MEMORY_BUFFER; 319 return GNUTLS_E_SHORT_MEMORY_BUFFER;
320 } 320 }
321 else 321 else
322 { 322 {
323 memcpy (result, ret, size); 323 memcpy (result, ret, size);
324 gnutls_free (ret); 324 MHD_gnutls_free (ret);
325 *result_size = size - 1; 325 *result_size = size - 1;
326 } 326 }
327 327
@@ -338,13 +338,13 @@ MHD_gtls_pem_base64_encode (const char *msg, const gnutls_datum_t * data,
338 * encoding. This is the encoding used in PEM messages. This function will 338 * encoding. This is the encoding used in PEM messages. This function will
339 * allocate the required memory to hold the encoded data. 339 * allocate the required memory to hold the encoded data.
340 * 340 *
341 * You should use gnutls_free() to free the returned data. 341 * You should use MHD_gnutls_free() to free the returned data.
342 * 342 *
343 **/ 343 **/
344int 344int
345MHD_gtls_pem_base64_encode_alloc (const char *msg, 345MHD_gtls_pem_base64_encode_alloc (const char *msg,
346 const gnutls_datum_t * data, 346 const MHD_gnutls_datum_t * data,
347 gnutls_datum_t * result) 347 MHD_gnutls_datum_t * result)
348{ 348{
349 opaque *ret; 349 opaque *ret;
350 int size; 350 int size;
@@ -352,7 +352,7 @@ MHD_gtls_pem_base64_encode_alloc (const char *msg,
352 if (result == NULL) 352 if (result == NULL)
353 return GNUTLS_E_INVALID_REQUEST; 353 return GNUTLS_E_INVALID_REQUEST;
354 354
355 size = _gnutls_fbase64_encode (msg, data->data, data->size, &ret); 355 size = MHD__gnutls_fbase64_encode (msg, data->data, data->size, &ret);
356 if (size < 0) 356 if (size < 0)
357 return size; 357 return size;
358 358
@@ -366,7 +366,7 @@ MHD_gtls_pem_base64_encode_alloc (const char *msg,
366 * The result_size is the return value 366 * The result_size is the return value
367 */ 367 */
368int 368int
369_gnutls_base64_decode (const uint8_t * data, size_t data_size, 369MHD__gnutls_base64_decode (const uint8_t * data, size_t data_size,
370 uint8_t ** result) 370 uint8_t ** result)
371{ 371{
372 unsigned int i, j; 372 unsigned int i, j;
@@ -374,7 +374,7 @@ _gnutls_base64_decode (const uint8_t * data, size_t data_size,
374 uint8_t tmpres[3]; 374 uint8_t tmpres[3];
375 375
376 est = ((data_size * 3) / 4) + 1; 376 est = ((data_size * 3) / 4) + 1;
377 (*result) = gnutls_malloc (est); 377 (*result) = MHD_gnutls_malloc (est);
378 if ((*result) == NULL) 378 if ((*result) == NULL)
379 return GNUTLS_E_MEMORY_ERROR; 379 return GNUTLS_E_MEMORY_ERROR;
380 380
@@ -384,7 +384,7 @@ _gnutls_base64_decode (const uint8_t * data, size_t data_size,
384 tmp = decode (tmpres, &data[i]); 384 tmp = decode (tmpres, &data[i]);
385 if (tmp < 0) 385 if (tmp < 0)
386 { 386 {
387 gnutls_free (*result); 387 MHD_gnutls_free (*result);
388 *result = NULL; 388 *result = NULL;
389 return tmp; 389 return tmp;
390 } 390 }
@@ -402,7 +402,7 @@ cpydata (const uint8_t * data, int data_size, uint8_t ** result)
402{ 402{
403 int i, j; 403 int i, j;
404 404
405 (*result) = gnutls_malloc (data_size); 405 (*result) = MHD_gnutls_malloc (data_size);
406 if (*result == NULL) 406 if (*result == NULL)
407 return GNUTLS_E_MEMORY_ERROR; 407 return GNUTLS_E_MEMORY_ERROR;
408 408
@@ -424,7 +424,7 @@ cpydata (const uint8_t * data, int data_size, uint8_t ** result)
424#define ENDSTR "-----\n" 424#define ENDSTR "-----\n"
425#define ENDSTR2 "-----\r" 425#define ENDSTR2 "-----\r"
426int 426int
427_gnutls_fbase64_decode (const char *header, const opaque * data, 427MHD__gnutls_fbase64_decode (const char *header, const opaque * data,
428 size_t data_size, uint8_t ** result) 428 size_t data_size, uint8_t ** result)
429{ 429{
430 int ret; 430 int ret;
@@ -436,16 +436,16 @@ _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 mhd_gtls_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 mhd_gtls_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 = MHD_memmem (data, data_size, pem_header, strlen (pem_header));
444 444
445 if (rdata == NULL) 445 if (rdata == NULL)
446 { 446 {
447 gnutls_assert (); 447 MHD_gnutls_assert ();
448 _gnutls_debug_log ("Could not find '%s'\n", pem_header); 448 MHD__gnutls_debug_log ("Could not find '%s'\n", pem_header);
449 return GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR; 449 return GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR;
450 } 450 }
451 451
@@ -453,20 +453,20 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
453 453
454 if (data_size < 4 + strlen (bottom)) 454 if (data_size < 4 + strlen (bottom))
455 { 455 {
456 gnutls_assert (); 456 MHD_gnutls_assert ();
457 return GNUTLS_E_BASE64_DECODING_ERROR; 457 return GNUTLS_E_BASE64_DECODING_ERROR;
458 } 458 }
459 459
460 kdata = memmem (rdata, data_size, ENDSTR, sizeof (ENDSTR) - 1); 460 kdata = MHD_memmem (rdata, data_size, ENDSTR, sizeof (ENDSTR) - 1);
461 /* allow CR as well. 461 /* allow CR as well.
462 */ 462 */
463 if (kdata == NULL) 463 if (kdata == NULL)
464 kdata = memmem (rdata, data_size, ENDSTR2, sizeof (ENDSTR2) - 1); 464 kdata = MHD_memmem (rdata, data_size, ENDSTR2, sizeof (ENDSTR2) - 1);
465 465
466 if (kdata == NULL) 466 if (kdata == NULL)
467 { 467 {
468 gnutls_assert (); 468 MHD_gnutls_assert ();
469 _gnutls_x509_log ("Could not find '%s'\n", ENDSTR); 469 MHD__gnutls_x509_log ("Could not find '%s'\n", ENDSTR);
470 return GNUTLS_E_BASE64_DECODING_ERROR; 470 return GNUTLS_E_BASE64_DECODING_ERROR;
471 } 471 }
472 data_size -= strlen (ENDSTR); 472 data_size -= strlen (ENDSTR);
@@ -476,10 +476,10 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
476 476
477 /* position is now after the ---BEGIN--- headers */ 477 /* position is now after the ---BEGIN--- headers */
478 478
479 kdata = memmem (rdata, data_size, bottom, strlen (bottom)); 479 kdata = MHD_memmem (rdata, data_size, bottom, strlen (bottom));
480 if (kdata == NULL) 480 if (kdata == NULL)
481 { 481 {
482 gnutls_assert (); 482 MHD_gnutls_assert ();
483 return GNUTLS_E_BASE64_DECODING_ERROR; 483 return GNUTLS_E_BASE64_DECODING_ERROR;
484 } 484 }
485 485
@@ -489,7 +489,7 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
489 489
490 if (rdata_size < 4) 490 if (rdata_size < 4)
491 { 491 {
492 gnutls_assert (); 492 MHD_gnutls_assert ();
493 return GNUTLS_E_BASE64_DECODING_ERROR; 493 return GNUTLS_E_BASE64_DECODING_ERROR;
494 } 494 }
495 495
@@ -497,24 +497,24 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
497 497
498 if (kdata_size < 0) 498 if (kdata_size < 0)
499 { 499 {
500 gnutls_assert (); 500 MHD_gnutls_assert ();
501 return kdata_size; 501 return kdata_size;
502 } 502 }
503 503
504 if (kdata_size < 4) 504 if (kdata_size < 4)
505 { 505 {
506 gnutls_assert (); 506 MHD_gnutls_assert ();
507 gnutls_free (kdata); 507 MHD_gnutls_free (kdata);
508 return GNUTLS_E_BASE64_DECODING_ERROR; 508 return GNUTLS_E_BASE64_DECODING_ERROR;
509 } 509 }
510 510
511 if ((ret = _gnutls_base64_decode (kdata, kdata_size, result)) < 0) 511 if ((ret = MHD__gnutls_base64_decode (kdata, kdata_size, result)) < 0)
512 { 512 {
513 gnutls_free (kdata); 513 MHD_gnutls_free (kdata);
514 gnutls_assert (); 514 MHD_gnutls_assert ();
515 return GNUTLS_E_BASE64_DECODING_ERROR; 515 return GNUTLS_E_BASE64_DECODING_ERROR;
516 } 516 }
517 gnutls_free (kdata); 517 MHD_gnutls_free (kdata);
518 518
519 return ret; 519 return ret;
520} 520}
@@ -535,27 +535,27 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
535 **/ 535 **/
536int 536int
537MHD_gtls_pem_base64_decode (const char *header, 537MHD_gtls_pem_base64_decode (const char *header,
538 const gnutls_datum_t * b64_data, 538 const MHD_gnutls_datum_t * b64_data,
539 unsigned char *result, size_t * result_size) 539 unsigned char *result, size_t * result_size)
540{ 540{
541 opaque *ret; 541 opaque *ret;
542 int size; 542 int size;
543 543
544 size = 544 size =
545 _gnutls_fbase64_decode (header, b64_data->data, b64_data->size, &ret); 545 MHD__gnutls_fbase64_decode (header, b64_data->data, b64_data->size, &ret);
546 if (size < 0) 546 if (size < 0)
547 return size; 547 return size;
548 548
549 if (result == NULL || *result_size < (unsigned) size) 549 if (result == NULL || *result_size < (unsigned) size)
550 { 550 {
551 gnutls_free (ret); 551 MHD_gnutls_free (ret);
552 *result_size = size; 552 *result_size = size;
553 return GNUTLS_E_SHORT_MEMORY_BUFFER; 553 return GNUTLS_E_SHORT_MEMORY_BUFFER;
554 } 554 }
555 else 555 else
556 { 556 {
557 memcpy (result, ret, size); 557 memcpy (result, ret, size);
558 gnutls_free (ret); 558 MHD_gnutls_free (ret);
559 *result_size = size; 559 *result_size = size;
560 } 560 }
561 561
@@ -574,13 +574,13 @@ MHD_gtls_pem_base64_decode (const char *header,
574 * "-----BEGIN header" and decode only this part. Otherwise it will decode the 574 * "-----BEGIN header" and decode only this part. Otherwise it will decode the
575 * first PEM packet found. 575 * first PEM packet found.
576 * 576 *
577 * You should use gnutls_free() to free the returned data. 577 * You should use MHD_gnutls_free() to free the returned data.
578 * 578 *
579 **/ 579 **/
580int 580int
581MHD_gtls_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 MHD_gnutls_datum_t * b64_data,
583 gnutls_datum_t * result) 583 MHD_gnutls_datum_t * result)
584{ 584{
585 opaque *ret; 585 opaque *ret;
586 int size; 586 int size;
@@ -589,7 +589,7 @@ MHD_gtls_pem_base64_decode_alloc (const char *header,
589 return GNUTLS_E_INVALID_REQUEST; 589 return GNUTLS_E_INVALID_REQUEST;
590 590
591 size = 591 size =
592 _gnutls_fbase64_decode (header, b64_data->data, b64_data->size, &ret); 592 MHD__gnutls_fbase64_decode (header, b64_data->data, b64_data->size, &ret);
593 if (size < 0) 593 if (size < 0)
594 return size; 594 return size;
595 595
diff --git a/src/daemon/https/tls/x509_b64.h b/src/daemon/https/tls/x509_b64.h
index d079ebc6..8638420b 100644
--- a/src/daemon/https/tls/x509_b64.h
+++ b/src/daemon/https/tls/x509_b64.h
@@ -22,13 +22,13 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_base64_encode (const uint8_t * data, size_t data_size, 25int MHD__gnutls_base64_encode (const uint8_t * data, size_t data_size,
26 uint8_t ** result); 26 uint8_t ** result);
27int _gnutls_fbase64_encode (const char *msg, const uint8_t * data, 27int MHD__gnutls_fbase64_encode (const char *msg, const uint8_t * data,
28 int data_size, uint8_t ** result); 28 int data_size, uint8_t ** result);
29int _gnutls_base64_decode (const uint8_t * data, size_t data_size, 29int MHD__gnutls_base64_decode (const uint8_t * data, size_t data_size,
30 uint8_t ** result); 30 uint8_t ** result);
31int _gnutls_fbase64_decode (const char *header, const uint8_t * data, 31int MHD__gnutls_fbase64_decode (const char *header, const uint8_t * data,
32 size_t data_size, uint8_t ** result); 32 size_t data_size, uint8_t ** result);
33 33
34#define B64SIZE( data_size) ((data_size%3==0)?((data_size*4)/3):(4+((data_size/3)*4))) 34#define B64SIZE( data_size) ((data_size%3==0)?((data_size*4)/3):(4+((data_size/3)*4)))
diff --git a/src/daemon/https/x509/common.c b/src/daemon/https/x509/common.c
index 53ae4be8..43da45c9 100644
--- a/src/daemon/https/x509/common.c
+++ b/src/daemon/https/x509/common.c
@@ -170,7 +170,7 @@ static const oid2string _oid2str[] = {
170/* Returns 1 if the data defined by the OID are printable. 170/* Returns 1 if the data defined by the OID are printable.
171 */ 171 */
172int 172int
173_gnutls_x509_oid_data_printable (const char *oid) 173MHD__gnutls_x509_oid_data_printable (const char *oid)
174{ 174{
175 int i = 0; 175 int i = 0;
176 176
@@ -186,11 +186,11 @@ _gnutls_x509_oid_data_printable (const char *oid)
186} 186}
187 187
188/** 188/**
189 * gnutls_x509_dn_oid_known - This function will return true if the given OID is known 189 * MHD_gnutls_x509_dn_oid_known - This function will return true if the given OID is known
190 * @oid: holds an Object Identifier in a null terminated string 190 * @oid: holds an Object Identifier in a null terminated string
191 * 191 *
192 * This function will inform about known DN OIDs. This is useful since functions 192 * This function will inform about known DN OIDs. This is useful since functions
193 * like gnutls_x509_crt_set_dn_by_oid() use the information on known 193 * like MHD_gnutls_x509_crt_set_dn_by_oid() use the information on known
194 * OIDs to properly encode their input. Object Identifiers that are not 194 * OIDs to properly encode their input. Object Identifiers that are not
195 * known are not encoded by these functions, and their input is stored directly 195 * known are not encoded by these functions, and their input is stored directly
196 * into the ASN.1 structure. In that case of unknown OIDs, you have 196 * into the ASN.1 structure. In that case of unknown OIDs, you have
@@ -200,7 +200,7 @@ _gnutls_x509_oid_data_printable (const char *oid)
200 * 200 *
201 **/ 201 **/
202int 202int
203gnutls_x509_dn_oid_known (const char *oid) 203MHD_gnutls_x509_dn_oid_known (const char *oid)
204{ 204{
205 int i = 0; 205 int i = 0;
206 206
@@ -219,7 +219,7 @@ gnutls_x509_dn_oid_known (const char *oid)
219 * type. 219 * type.
220 */ 220 */
221int 221int
222_gnutls_x509_oid_data_choice (const char *oid) 222MHD__gnutls_x509_oid_data_choice (const char *oid)
223{ 223{
224 int i = 0; 224 int i = 0;
225 225
@@ -235,7 +235,7 @@ _gnutls_x509_oid_data_choice (const char *oid)
235} 235}
236 236
237const char * 237const char *
238_gnutls_x509_oid2ldap_string (const char *oid) 238MHD__gnutls_x509_oid2ldap_string (const char *oid)
239{ 239{
240 int i = 0; 240 int i = 0;
241 241
@@ -257,7 +257,7 @@ _gnutls_x509_oid2ldap_string (const char *oid)
257 * hold the string. 257 * hold the string.
258 */ 258 */
259int 259int
260_gnutls_x509_oid_data2string (const char *oid, 260MHD__gnutls_x509_oid_data2string (const char *oid,
261 void *value, 261 void *value,
262 int value_size, char *res, size_t * res_size) 262 int value_size, char *res, size_t * res_size)
263{ 263{
@@ -265,57 +265,57 @@ _gnutls_x509_oid_data2string (const char *oid,
265 const char *ANAME = NULL; 265 const char *ANAME = NULL;
266 int CHOICE = -1, len = -1, result; 266 int CHOICE = -1, len = -1, result;
267 ASN1_TYPE tmpasn = ASN1_TYPE_EMPTY; 267 ASN1_TYPE tmpasn = ASN1_TYPE_EMPTY;
268 char asn1_err[MAX_ERROR_DESCRIPTION_SIZE] = ""; 268 char MHD__asn1_err[MAX_ERROR_DESCRIPTION_SIZE] = "";
269 269
270 if (value == NULL || value_size <= 0 || res_size == NULL) 270 if (value == NULL || value_size <= 0 || res_size == NULL)
271 { 271 {
272 gnutls_assert (); 272 MHD_gnutls_assert ();
273 return GNUTLS_E_INVALID_REQUEST; 273 return GNUTLS_E_INVALID_REQUEST;
274 } 274 }
275 275
276 if (_gnutls_x509_oid_data_printable (oid) == 0) 276 if (MHD__gnutls_x509_oid_data_printable (oid) == 0)
277 { 277 {
278 gnutls_assert (); 278 MHD_gnutls_assert ();
279 return GNUTLS_E_INTERNAL_ERROR; 279 return GNUTLS_E_INTERNAL_ERROR;
280 } 280 }
281 281
282 ANAME = asn1_find_structure_from_oid (_gnutls_get_pkix (), oid); 282 ANAME = MHD__asn1_find_structure_from_oid (MHD__gnutls_get_pkix (), oid);
283 CHOICE = _gnutls_x509_oid_data_choice (oid); 283 CHOICE = MHD__gnutls_x509_oid_data_choice (oid);
284 284
285 if (ANAME == NULL) 285 if (ANAME == NULL)
286 { 286 {
287 gnutls_assert (); 287 MHD_gnutls_assert ();
288 return GNUTLS_E_INTERNAL_ERROR; 288 return GNUTLS_E_INTERNAL_ERROR;
289 } 289 }
290 290
291 mhd_gtls_str_cpy (str, sizeof (str), "PKIX1."); 291 MHD_gtls_str_cpy (str, sizeof (str), "PKIX1.");
292 mhd_gtls_str_cat (str, sizeof (str), ANAME); 292 MHD_gtls_str_cat (str, sizeof (str), ANAME);
293 293
294 if ((result = asn1_create_element (_gnutls_get_pkix (), str, 294 if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), str,
295 &tmpasn)) != ASN1_SUCCESS) 295 &tmpasn)) != ASN1_SUCCESS)
296 { 296 {
297 gnutls_assert (); 297 MHD_gnutls_assert ();
298 return mhd_gtls_asn2err (result); 298 return MHD_gtls_asn2err (result);
299 } 299 }
300 300
301 if ((result = asn1_der_decoding (&tmpasn, value, value_size, asn1_err)) 301 if ((result = MHD__asn1_der_decoding (&tmpasn, value, value_size, MHD__asn1_err))
302 != ASN1_SUCCESS) 302 != ASN1_SUCCESS)
303 { 303 {
304 gnutls_assert (); 304 MHD_gnutls_assert ();
305 _gnutls_x509_log ("asn1_der_decoding: %s:%s\n", str, asn1_err); 305 MHD__gnutls_x509_log ("MHD__asn1_der_decoding: %s:%s\n", str, MHD__asn1_err);
306 asn1_delete_structure (&tmpasn); 306 MHD__asn1_delete_structure (&tmpasn);
307 return mhd_gtls_asn2err (result); 307 return MHD_gtls_asn2err (result);
308 } 308 }
309 309
310 /* If this is a choice then we read the choice. Otherwise it 310 /* If this is a choice then we read the choice. Otherwise it
311 * is the value; 311 * is the value;
312 */ 312 */
313 len = sizeof (str) - 1; 313 len = sizeof (str) - 1;
314 if ((result = asn1_read_value (tmpasn, "", str, &len)) != ASN1_SUCCESS) 314 if ((result = MHD__asn1_read_value (tmpasn, "", str, &len)) != ASN1_SUCCESS)
315 { /* CHOICE */ 315 { /* CHOICE */
316 gnutls_assert (); 316 MHD_gnutls_assert ();
317 asn1_delete_structure (&tmpasn); 317 MHD__asn1_delete_structure (&tmpasn);
318 return mhd_gtls_asn2err (result); 318 return MHD_gtls_asn2err (result);
319 } 319 }
320 320
321 if (CHOICE == 0) 321 if (CHOICE == 0)
@@ -323,10 +323,10 @@ _gnutls_x509_oid_data2string (const char *oid,
323 str[len] = 0; 323 str[len] = 0;
324 324
325 if (res) 325 if (res)
326 mhd_gtls_str_cpy (res, *res_size, str); 326 MHD_gtls_str_cpy (res, *res_size, str);
327 *res_size = len; 327 *res_size = len;
328 328
329 asn1_delete_structure (&tmpasn); 329 MHD__asn1_delete_structure (&tmpasn);
330 } 330 }
331 else 331 else
332 { /* CHOICE */ 332 { /* CHOICE */
@@ -345,17 +345,17 @@ _gnutls_x509_oid_data2string (const char *oid,
345 if (strcmp (str, "teletexString") == 0) 345 if (strcmp (str, "teletexString") == 0)
346 teletex = 1; 346 teletex = 1;
347 347
348 mhd_gtls_str_cpy (tmpname, sizeof (tmpname), str); 348 MHD_gtls_str_cpy (tmpname, sizeof (tmpname), str);
349 349
350 len = sizeof (str) - 1; 350 len = sizeof (str) - 1;
351 if ((result = asn1_read_value (tmpasn, tmpname, str, &len)) 351 if ((result = MHD__asn1_read_value (tmpasn, tmpname, str, &len))
352 != ASN1_SUCCESS) 352 != ASN1_SUCCESS)
353 { 353 {
354 asn1_delete_structure (&tmpasn); 354 MHD__asn1_delete_structure (&tmpasn);
355 return mhd_gtls_asn2err (result); 355 return MHD_gtls_asn2err (result);
356 } 356 }
357 357
358 asn1_delete_structure (&tmpasn); 358 MHD__asn1_delete_structure (&tmpasn);
359 359
360 if (teletex != 0) 360 if (teletex != 0)
361 { 361 {
@@ -376,15 +376,15 @@ _gnutls_x509_oid_data2string (const char *oid,
376 if (non_printable == 0) 376 if (non_printable == 0)
377 { 377 {
378 str[len] = 0; 378 str[len] = 0;
379 mhd_gtls_str_cpy (res, *res_size, str); 379 MHD_gtls_str_cpy (res, *res_size, str);
380 *res_size = len; 380 *res_size = len;
381 } 381 }
382 else 382 else
383 { 383 {
384 result = _gnutls_x509_data2hex (str, len, res, res_size); 384 result = MHD__gnutls_x509_data2hex (str, len, res, res_size);
385 if (result < 0) 385 if (result < 0)
386 { 386 {
387 gnutls_assert (); 387 MHD_gnutls_assert ();
388 return result; 388 return result;
389 } 389 }
390 } 390 }
@@ -399,7 +399,7 @@ _gnutls_x509_oid_data2string (const char *oid,
399 * something like '#01020304' 399 * something like '#01020304'
400 */ 400 */
401int 401int
402_gnutls_x509_data2hex (const opaque * data, 402MHD__gnutls_x509_data2hex (const opaque * data,
403 size_t data_size, opaque * out, size_t * sizeof_out) 403 size_t data_size, opaque * out, size_t * sizeof_out)
404{ 404{
405 char *res; 405 char *res;
@@ -407,11 +407,11 @@ _gnutls_x509_data2hex (const opaque * data,
407 407
408 if (2 * data_size + 1 > MAX_STRING_LEN) 408 if (2 * data_size + 1 > MAX_STRING_LEN)
409 { 409 {
410 gnutls_assert (); 410 MHD_gnutls_assert ();
411 return GNUTLS_E_INTERNAL_ERROR; 411 return GNUTLS_E_INTERNAL_ERROR;
412 } 412 }
413 413
414 res = mhd_gtls_bin2hex (data, data_size, escaped, sizeof (escaped)); 414 res = MHD_gtls_bin2hex (data, data_size, escaped, sizeof (escaped));
415 415
416 if (res) 416 if (res)
417 { 417 {
@@ -433,7 +433,7 @@ _gnutls_x509_data2hex (const opaque * data,
433 } 433 }
434 else 434 else
435 { 435 {
436 gnutls_assert (); 436 MHD_gnutls_assert ();
437 return GNUTLS_E_INTERNAL_ERROR; 437 return GNUTLS_E_INTERNAL_ERROR;
438 } 438 }
439 439
@@ -522,7 +522,7 @@ mktime_utc (const struct fake_tm *tm)
522 * and year is given. Returns a time_t date. 522 * and year is given. Returns a time_t date.
523 */ 523 */
524time_t 524time_t
525_gnutls_x509_time2gtime (const char *ttime, int year) 525MHD__gnutls_x509_time2gtime (const char *ttime, int year)
526{ 526{
527 char xx[3]; 527 char xx[3];
528 struct fake_tm etime; 528 struct fake_tm etime;
@@ -530,7 +530,7 @@ _gnutls_x509_time2gtime (const char *ttime, int year)
530 530
531 if (strlen (ttime) < 8) 531 if (strlen (ttime) < 8)
532 { 532 {
533 gnutls_assert (); 533 MHD_gnutls_assert ();
534 return (time_t) - 1; 534 return (time_t) - 1;
535 } 535 }
536 536
@@ -589,14 +589,14 @@ _gnutls_x509_time2gtime (const char *ttime, int year)
589 * (seconds are optional) 589 * (seconds are optional)
590 */ 590 */
591time_t 591time_t
592_gnutls_x509_utcTime2gtime (const char *ttime) 592MHD__gnutls_x509_utcTime2gtime (const char *ttime)
593{ 593{
594 char xx[3]; 594 char xx[3];
595 int year; 595 int year;
596 596
597 if (strlen (ttime) < 10) 597 if (strlen (ttime) < 10)
598 { 598 {
599 gnutls_assert (); 599 MHD_gnutls_assert ();
600 return (time_t) - 1; 600 return (time_t) - 1;
601 } 601 }
602 xx[2] = 0; 602 xx[2] = 0;
@@ -611,7 +611,7 @@ _gnutls_x509_utcTime2gtime (const char *ttime)
611 else 611 else
612 year += 2000; 612 year += 2000;
613 613
614 return _gnutls_x509_time2gtime (ttime, year); 614 return MHD__gnutls_x509_time2gtime (ttime, year);
615} 615}
616 616
617/* returns a time value that contains the given time. 617/* returns a time value that contains the given time.
@@ -619,7 +619,7 @@ _gnutls_x509_utcTime2gtime (const char *ttime)
619 * YEAR(2)|MONTH(2)|DAY(2)|HOUR(2)|MIN(2)|SEC(2) 619 * YEAR(2)|MONTH(2)|DAY(2)|HOUR(2)|MIN(2)|SEC(2)
620 */ 620 */
621int 621int
622_gnutls_x509_gtime2utcTime (time_t gtime, char *str_time, int str_time_size) 622MHD__gnutls_x509_gtime2utcTime (time_t gtime, char *str_time, int str_time_size)
623{ 623{
624 size_t ret; 624 size_t ret;
625 625
@@ -639,7 +639,7 @@ _gnutls_x509_gtime2utcTime (time_t gtime, char *str_time, int str_time_size)
639 639
640 if (!ret) 640 if (!ret)
641 { 641 {
642 gnutls_assert (); 642 MHD_gnutls_assert ();
643 return GNUTLS_E_SHORT_MEMORY_BUFFER; 643 return GNUTLS_E_SHORT_MEMORY_BUFFER;
644 } 644 }
645 645
@@ -652,20 +652,20 @@ _gnutls_x509_gtime2utcTime (time_t gtime, char *str_time, int str_time_size)
652 * YEAR(4)|MONTH(2)|DAY(2)|HOUR(2)|MIN(2)|SEC(2)* 652 * YEAR(4)|MONTH(2)|DAY(2)|HOUR(2)|MIN(2)|SEC(2)*
653 */ 653 */
654time_t 654time_t
655_gnutls_x509_generalTime2gtime (const char *ttime) 655MHD__gnutls_x509_generalTime2gtime (const char *ttime)
656{ 656{
657 char xx[5]; 657 char xx[5];
658 int year; 658 int year;
659 659
660 if (strlen (ttime) < 12) 660 if (strlen (ttime) < 12)
661 { 661 {
662 gnutls_assert (); 662 MHD_gnutls_assert ();
663 return (time_t) - 1; 663 return (time_t) - 1;
664 } 664 }
665 665
666 if (strchr (ttime, 'Z') == 0) 666 if (strchr (ttime, 'Z') == 0)
667 { 667 {
668 gnutls_assert (); 668 MHD_gnutls_assert ();
669 /* sorry we don't support it yet 669 /* sorry we don't support it yet
670 */ 670 */
671 return (time_t) - 1; 671 return (time_t) - 1;
@@ -678,7 +678,7 @@ _gnutls_x509_generalTime2gtime (const char *ttime)
678 year = atoi (xx); 678 year = atoi (xx);
679 ttime += 4; 679 ttime += 4;
680 680
681 return _gnutls_x509_time2gtime (ttime, year); 681 return MHD__gnutls_x509_time2gtime (ttime, year);
682 682
683} 683}
684 684
@@ -687,19 +687,19 @@ _gnutls_x509_generalTime2gtime (const char *ttime)
687 */ 687 */
688#define MAX_TIME 64 688#define MAX_TIME 64
689time_t 689time_t
690_gnutls_x509_get_time (ASN1_TYPE c2, const char *when) 690MHD__gnutls_x509_get_time (ASN1_TYPE c2, const char *when)
691{ 691{
692 char ttime[MAX_TIME]; 692 char ttime[MAX_TIME];
693 char name[128]; 693 char name[128];
694 time_t c_time = (time_t) - 1; 694 time_t c_time = (time_t) - 1;
695 int len, result; 695 int len, result;
696 696
697 mhd_gtls_str_cpy (name, sizeof (name), when); 697 MHD_gtls_str_cpy (name, sizeof (name), when);
698 698
699 len = sizeof (ttime) - 1; 699 len = sizeof (ttime) - 1;
700 if ((result = asn1_read_value (c2, name, ttime, &len)) < 0) 700 if ((result = MHD__asn1_read_value (c2, name, ttime, &len)) < 0)
701 { 701 {
702 gnutls_assert (); 702 MHD_gnutls_assert ();
703 return (time_t) (-1); 703 return (time_t) (-1);
704 } 704 }
705 705
@@ -707,20 +707,20 @@ _gnutls_x509_get_time (ASN1_TYPE c2, const char *when)
707 if (strcmp (ttime, "generalTime") == 0) 707 if (strcmp (ttime, "generalTime") == 0)
708 { 708 {
709 709
710 mhd_gtls_str_cat (name, sizeof (name), ".generalTime"); 710 MHD_gtls_str_cat (name, sizeof (name), ".generalTime");
711 len = sizeof (ttime) - 1; 711 len = sizeof (ttime) - 1;
712 result = asn1_read_value (c2, name, ttime, &len); 712 result = MHD__asn1_read_value (c2, name, ttime, &len);
713 if (result == ASN1_SUCCESS) 713 if (result == ASN1_SUCCESS)
714 c_time = _gnutls_x509_generalTime2gtime (ttime); 714 c_time = MHD__gnutls_x509_generalTime2gtime (ttime);
715 } 715 }
716 else 716 else
717 { /* UTCTIME */ 717 { /* UTCTIME */
718 718
719 mhd_gtls_str_cat (name, sizeof (name), ".utcTime"); 719 MHD_gtls_str_cat (name, sizeof (name), ".utcTime");
720 len = sizeof (ttime) - 1; 720 len = sizeof (ttime) - 1;
721 result = asn1_read_value (c2, name, ttime, &len); 721 result = MHD__asn1_read_value (c2, name, ttime, &len);
722 if (result == ASN1_SUCCESS) 722 if (result == ASN1_SUCCESS)
723 c_time = _gnutls_x509_utcTime2gtime (ttime); 723 c_time = MHD__gnutls_x509_utcTime2gtime (ttime);
724 } 724 }
725 725
726 /* We cannot handle dates after 2031 in 32 bit machines. 726 /* We cannot handle dates after 2031 in 32 bit machines.
@@ -729,7 +729,7 @@ _gnutls_x509_get_time (ASN1_TYPE c2, const char *when)
729 729
730 if (result != ASN1_SUCCESS) 730 if (result != ASN1_SUCCESS)
731 { 731 {
732 gnutls_assert (); 732 MHD_gnutls_assert ();
733 return (time_t) (-1); 733 return (time_t) (-1);
734 } 734 }
735 return c_time; 735 return c_time;
@@ -739,42 +739,42 @@ _gnutls_x509_get_time (ASN1_TYPE c2, const char *when)
739 * be something like "tbsCertList.thisUpdate". 739 * be something like "tbsCertList.thisUpdate".
740 */ 740 */
741int 741int
742_gnutls_x509_set_time (ASN1_TYPE c2, const char *where, time_t tim) 742MHD__gnutls_x509_set_time (ASN1_TYPE c2, const char *where, time_t tim)
743{ 743{
744 char str_time[MAX_TIME]; 744 char str_time[MAX_TIME];
745 char name[128]; 745 char name[128];
746 int result, len; 746 int result, len;
747 747
748 mhd_gtls_str_cpy (name, sizeof (name), where); 748 MHD_gtls_str_cpy (name, sizeof (name), where);
749 749
750 if ((result = asn1_write_value (c2, name, "utcTime", 1)) < 0) 750 if ((result = MHD__asn1_write_value (c2, name, "utcTime", 1)) < 0)
751 { 751 {
752 gnutls_assert (); 752 MHD_gnutls_assert ();
753 return mhd_gtls_asn2err (result); 753 return MHD_gtls_asn2err (result);
754 } 754 }
755 755
756 result = _gnutls_x509_gtime2utcTime (tim, str_time, sizeof (str_time)); 756 result = MHD__gnutls_x509_gtime2utcTime (tim, str_time, sizeof (str_time));
757 if (result < 0) 757 if (result < 0)
758 { 758 {
759 gnutls_assert (); 759 MHD_gnutls_assert ();
760 return result; 760 return result;
761 } 761 }
762 762
763 mhd_gtls_str_cat (name, sizeof (name), ".utcTime"); 763 MHD_gtls_str_cat (name, sizeof (name), ".utcTime");
764 764
765 len = strlen (str_time); 765 len = strlen (str_time);
766 result = asn1_write_value (c2, name, str_time, len); 766 result = MHD__asn1_write_value (c2, name, str_time, len);
767 if (result != ASN1_SUCCESS) 767 if (result != ASN1_SUCCESS)
768 { 768 {
769 gnutls_assert (); 769 MHD_gnutls_assert ();
770 return mhd_gtls_asn2err (result); 770 return MHD_gtls_asn2err (result);
771 } 771 }
772 772
773 return 0; 773 return 0;
774} 774}
775 775
776gnutls_x509_subject_alt_name_t 776MHD_gnutls_x509_subject_alt_name_t
777_gnutls_x509_san_find_type (char *str_type) 777MHD__gnutls_x509_san_find_type (char *str_type)
778{ 778{
779 if (strcmp (str_type, "dNSName") == 0) 779 if (strcmp (str_type, "dNSName") == 0)
780 return GNUTLS_SAN_DNSNAME; 780 return GNUTLS_SAN_DNSNAME;
@@ -788,15 +788,15 @@ _gnutls_x509_san_find_type (char *str_type)
788 return GNUTLS_SAN_OTHERNAME; 788 return GNUTLS_SAN_OTHERNAME;
789 if (strcmp (str_type, "directoryName") == 0) 789 if (strcmp (str_type, "directoryName") == 0)
790 return GNUTLS_SAN_DN; 790 return GNUTLS_SAN_DN;
791 return (gnutls_x509_subject_alt_name_t) - 1; 791 return (MHD_gnutls_x509_subject_alt_name_t) - 1;
792} 792}
793 793
794/* A generic export function. Will export the given ASN.1 encoded data 794/* A generic export function. Will export the given ASN.1 encoded data
795 * to PEM or DER raw data. 795 * to PEM or DER raw data.
796 */ 796 */
797int 797int
798_gnutls_x509_export_int (ASN1_TYPE asn1_data, 798MHD__gnutls_x509_export_int (ASN1_TYPE MHD__asn1_data,
799 gnutls_x509_crt_fmt_t format, 799 MHD_gnutls_x509_crt_fmt_t format,
800 char *pem_header, 800 char *pem_header,
801 unsigned char *output_data, 801 unsigned char *output_data,
802 size_t * output_data_size) 802 size_t * output_data_size)
@@ -811,7 +811,7 @@ _gnutls_x509_export_int (ASN1_TYPE asn1_data,
811 811
812 len = *output_data_size; 812 len = *output_data_size;
813 813
814 if ((result = asn1_der_coding (asn1_data, "", output_data, &len, 814 if ((result = MHD__asn1_der_coding (MHD__asn1_data, "", output_data, &len,
815 NULL)) != ASN1_SUCCESS) 815 NULL)) != ASN1_SUCCESS)
816 { 816 {
817 *output_data_size = len; 817 *output_data_size = len;
@@ -819,8 +819,8 @@ _gnutls_x509_export_int (ASN1_TYPE asn1_data,
819 { 819 {
820 return GNUTLS_E_SHORT_MEMORY_BUFFER; 820 return GNUTLS_E_SHORT_MEMORY_BUFFER;
821 } 821 }
822 gnutls_assert (); 822 MHD_gnutls_assert ();
823 return mhd_gtls_asn2err (result); 823 return MHD_gtls_asn2err (result);
824 } 824 }
825 825
826 *output_data_size = len; 826 *output_data_size = len;
@@ -829,35 +829,35 @@ _gnutls_x509_export_int (ASN1_TYPE asn1_data,
829 else 829 else
830 { /* PEM */ 830 { /* PEM */
831 opaque *out; 831 opaque *out;
832 gnutls_datum_t tmp; 832 MHD_gnutls_datum_t tmp;
833 833
834 result = _gnutls_x509_der_encode (asn1_data, "", &tmp, 0); 834 result = MHD__gnutls_x509_der_encode (MHD__asn1_data, "", &tmp, 0);
835 if (result < 0) 835 if (result < 0)
836 { 836 {
837 gnutls_assert (); 837 MHD_gnutls_assert ();
838 return result; 838 return result;
839 } 839 }
840 840
841 result = _gnutls_fbase64_encode (pem_header, tmp.data, tmp.size, &out); 841 result = MHD__gnutls_fbase64_encode (pem_header, tmp.data, tmp.size, &out);
842 842
843 _gnutls_free_datum (&tmp); 843 MHD__gnutls_free_datum (&tmp);
844 844
845 if (result < 0) 845 if (result < 0)
846 { 846 {
847 gnutls_assert (); 847 MHD_gnutls_assert ();
848 return result; 848 return result;
849 } 849 }
850 850
851 if (result == 0) 851 if (result == 0)
852 { /* oooops */ 852 { /* oooops */
853 gnutls_assert (); 853 MHD_gnutls_assert ();
854 return GNUTLS_E_INTERNAL_ERROR; 854 return GNUTLS_E_INTERNAL_ERROR;
855 } 855 }
856 856
857 if ((unsigned) result > *output_data_size) 857 if ((unsigned) result > *output_data_size)
858 { 858 {
859 gnutls_assert (); 859 MHD_gnutls_assert ();
860 gnutls_free (out); 860 MHD_gnutls_free (out);
861 *output_data_size = result; 861 *output_data_size = result;
862 return GNUTLS_E_SHORT_MEMORY_BUFFER; 862 return GNUTLS_E_SHORT_MEMORY_BUFFER;
863 } 863 }
@@ -872,7 +872,7 @@ _gnutls_x509_export_int (ASN1_TYPE asn1_data,
872 */ 872 */
873 *output_data_size = result - 1; 873 *output_data_size = result - 1;
874 } 874 }
875 gnutls_free (out); 875 MHD_gnutls_free (out);
876 876
877 } 877 }
878 878
@@ -884,7 +884,7 @@ _gnutls_x509_export_int (ASN1_TYPE asn1_data,
884 * etc. 884 * etc.
885 */ 885 */
886int 886int
887_gnutls_x509_decode_octet_string (const char *string_type, 887MHD__gnutls_x509_decode_octet_string (const char *string_type,
888 const opaque * der, 888 const opaque * der,
889 size_t der_size, 889 size_t der_size,
890 opaque * output, size_t * output_size) 890 opaque * output, size_t * output_size)
@@ -894,45 +894,45 @@ _gnutls_x509_decode_octet_string (const char *string_type,
894 char strname[64]; 894 char strname[64];
895 895
896 if (string_type == NULL) 896 if (string_type == NULL)
897 mhd_gtls_str_cpy (strname, sizeof (strname), "PKIX1.pkcs-7-Data"); 897 MHD_gtls_str_cpy (strname, sizeof (strname), "PKIX1.pkcs-7-Data");
898 else 898 else
899 { 899 {
900 mhd_gtls_str_cpy (strname, sizeof (strname), "PKIX1."); 900 MHD_gtls_str_cpy (strname, sizeof (strname), "PKIX1.");
901 mhd_gtls_str_cat (strname, sizeof (strname), string_type); 901 MHD_gtls_str_cat (strname, sizeof (strname), string_type);
902 } 902 }
903 903
904 if ((result = 904 if ((result =
905 asn1_create_element (_gnutls_get_pkix (), strname, 905 MHD__asn1_create_element (MHD__gnutls_get_pkix (), strname,
906 &c2)) != ASN1_SUCCESS) 906 &c2)) != ASN1_SUCCESS)
907 { 907 {
908 gnutls_assert (); 908 MHD_gnutls_assert ();
909 result = mhd_gtls_asn2err (result); 909 result = MHD_gtls_asn2err (result);
910 goto cleanup; 910 goto cleanup;
911 } 911 }
912 912
913 result = asn1_der_decoding (&c2, der, der_size, NULL); 913 result = MHD__asn1_der_decoding (&c2, der, der_size, NULL);
914 if (result != ASN1_SUCCESS) 914 if (result != ASN1_SUCCESS)
915 { 915 {
916 gnutls_assert (); 916 MHD_gnutls_assert ();
917 result = mhd_gtls_asn2err (result); 917 result = MHD_gtls_asn2err (result);
918 goto cleanup; 918 goto cleanup;
919 } 919 }
920 920
921 tmp_output_size = *output_size; 921 tmp_output_size = *output_size;
922 result = asn1_read_value (c2, "", output, &tmp_output_size); 922 result = MHD__asn1_read_value (c2, "", output, &tmp_output_size);
923 *output_size = tmp_output_size; 923 *output_size = tmp_output_size;
924 924
925 if (result != ASN1_SUCCESS) 925 if (result != ASN1_SUCCESS)
926 { 926 {
927 gnutls_assert (); 927 MHD_gnutls_assert ();
928 result = mhd_gtls_asn2err (result); 928 result = MHD_gtls_asn2err (result);
929 goto cleanup; 929 goto cleanup;
930 } 930 }
931 931
932 return 0; 932 return 0;
933 933
934cleanup:if (c2) 934cleanup:if (c2)
935 asn1_delete_structure (&c2); 935 MHD__asn1_delete_structure (&c2);
936 936
937 return result; 937 return result;
938} 938}
@@ -944,37 +944,37 @@ cleanup:if (c2)
944 * flags == 2 the value is a BIT STRING 944 * flags == 2 the value is a BIT STRING
945 */ 945 */
946int 946int
947_gnutls_x509_read_value (ASN1_TYPE c, 947MHD__gnutls_x509_read_value (ASN1_TYPE c,
948 const char *root, gnutls_datum_t * ret, int flags) 948 const char *root, MHD_gnutls_datum_t * ret, int flags)
949{ 949{
950 int len = 0, result; 950 int len = 0, result;
951 size_t slen; 951 size_t slen;
952 opaque *tmp = NULL; 952 opaque *tmp = NULL;
953 953
954 result = asn1_read_value (c, root, NULL, &len); 954 result = MHD__asn1_read_value (c, root, NULL, &len);
955 if (result != ASN1_MEM_ERROR) 955 if (result != ASN1_MEM_ERROR)
956 { 956 {
957 gnutls_assert (); 957 MHD_gnutls_assert ();
958 result = mhd_gtls_asn2err (result); 958 result = MHD_gtls_asn2err (result);
959 return result; 959 return result;
960 } 960 }
961 961
962 if (flags == 2) 962 if (flags == 2)
963 len /= 8; 963 len /= 8;
964 964
965 tmp = gnutls_malloc (len); 965 tmp = MHD_gnutls_malloc (len);
966 if (tmp == NULL) 966 if (tmp == NULL)
967 { 967 {
968 gnutls_assert (); 968 MHD_gnutls_assert ();
969 result = GNUTLS_E_MEMORY_ERROR; 969 result = GNUTLS_E_MEMORY_ERROR;
970 goto cleanup; 970 goto cleanup;
971 } 971 }
972 972
973 result = asn1_read_value (c, root, tmp, &len); 973 result = MHD__asn1_read_value (c, root, tmp, &len);
974 if (result != ASN1_SUCCESS) 974 if (result != ASN1_SUCCESS)
975 { 975 {
976 gnutls_assert (); 976 MHD_gnutls_assert ();
977 result = mhd_gtls_asn2err (result); 977 result = MHD_gtls_asn2err (result);
978 goto cleanup; 978 goto cleanup;
979 } 979 }
980 980
@@ -987,10 +987,10 @@ _gnutls_x509_read_value (ASN1_TYPE c,
987 if (flags == 1) 987 if (flags == 1)
988 { 988 {
989 slen = len; 989 slen = len;
990 result = _gnutls_x509_decode_octet_string (NULL, tmp, slen, tmp, &slen); 990 result = MHD__gnutls_x509_decode_octet_string (NULL, tmp, slen, tmp, &slen);
991 if (result < 0) 991 if (result < 0)
992 { 992 {
993 gnutls_assert (); 993 MHD_gnutls_assert ();
994 goto cleanup; 994 goto cleanup;
995 } 995 }
996 len = slen; 996 len = slen;
@@ -1001,7 +1001,7 @@ _gnutls_x509_read_value (ASN1_TYPE c,
1001 1001
1002 return 0; 1002 return 0;
1003 1003
1004cleanup:gnutls_free (tmp); 1004cleanup:MHD_gnutls_free (tmp);
1005 return result; 1005 return result;
1006 1006
1007} 1007}
@@ -1011,8 +1011,8 @@ cleanup:gnutls_free (tmp);
1011 * an OCTET STRING. 1011 * an OCTET STRING.
1012 */ 1012 */
1013int 1013int
1014_gnutls_x509_der_encode (ASN1_TYPE src, 1014MHD__gnutls_x509_der_encode (ASN1_TYPE src,
1015 const char *src_name, gnutls_datum_t * res, int str) 1015 const char *src_name, MHD_gnutls_datum_t * res, int str)
1016{ 1016{
1017 int size, result; 1017 int size, result;
1018 int asize; 1018 int asize;
@@ -1020,11 +1020,11 @@ _gnutls_x509_der_encode (ASN1_TYPE src,
1020 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 1020 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
1021 1021
1022 size = 0; 1022 size = 0;
1023 result = asn1_der_coding (src, src_name, NULL, &size, NULL); 1023 result = MHD__asn1_der_coding (src, src_name, NULL, &size, NULL);
1024 if (result != ASN1_MEM_ERROR) 1024 if (result != ASN1_MEM_ERROR)
1025 { 1025 {
1026 gnutls_assert (); 1026 MHD_gnutls_assert ();
1027 result = mhd_gtls_asn2err (result); 1027 result = MHD_gtls_asn2err (result);
1028 goto cleanup; 1028 goto cleanup;
1029 } 1029 }
1030 1030
@@ -1035,60 +1035,60 @@ _gnutls_x509_der_encode (ASN1_TYPE src,
1035 size += 16; /* for later to include the octet tags */ 1035 size += 16; /* for later to include the octet tags */
1036 asize = size; 1036 asize = size;
1037 1037
1038 data = gnutls_malloc (size); 1038 data = MHD_gnutls_malloc (size);
1039 if (data == NULL) 1039 if (data == NULL)
1040 { 1040 {
1041 gnutls_assert (); 1041 MHD_gnutls_assert ();
1042 result = GNUTLS_E_MEMORY_ERROR; 1042 result = GNUTLS_E_MEMORY_ERROR;
1043 goto cleanup; 1043 goto cleanup;
1044 } 1044 }
1045 1045
1046 result = asn1_der_coding (src, src_name, data, &size, NULL); 1046 result = MHD__asn1_der_coding (src, src_name, data, &size, NULL);
1047 if (result != ASN1_SUCCESS) 1047 if (result != ASN1_SUCCESS)
1048 { 1048 {
1049 gnutls_assert (); 1049 MHD_gnutls_assert ();
1050 result = mhd_gtls_asn2err (result); 1050 result = MHD_gtls_asn2err (result);
1051 goto cleanup; 1051 goto cleanup;
1052 } 1052 }
1053 1053
1054 if (str) 1054 if (str)
1055 { 1055 {
1056 if ((result = 1056 if ((result =
1057 asn1_create_element (_gnutls_get_pkix (), "PKIX1.pkcs-7-Data", 1057 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-Data",
1058 &c2)) != ASN1_SUCCESS) 1058 &c2)) != ASN1_SUCCESS)
1059 { 1059 {
1060 gnutls_assert (); 1060 MHD_gnutls_assert ();
1061 result = mhd_gtls_asn2err (result); 1061 result = MHD_gtls_asn2err (result);
1062 goto cleanup; 1062 goto cleanup;
1063 } 1063 }
1064 1064
1065 result = asn1_write_value (c2, "", data, size); 1065 result = MHD__asn1_write_value (c2, "", data, size);
1066 if (result != ASN1_SUCCESS) 1066 if (result != ASN1_SUCCESS)
1067 { 1067 {
1068 gnutls_assert (); 1068 MHD_gnutls_assert ();
1069 result = mhd_gtls_asn2err (result); 1069 result = MHD_gtls_asn2err (result);
1070 goto cleanup; 1070 goto cleanup;
1071 } 1071 }
1072 1072
1073 result = asn1_der_coding (c2, "", data, &asize, NULL); 1073 result = MHD__asn1_der_coding (c2, "", data, &asize, NULL);
1074 if (result != ASN1_SUCCESS) 1074 if (result != ASN1_SUCCESS)
1075 { 1075 {
1076 gnutls_assert (); 1076 MHD_gnutls_assert ();
1077 result = mhd_gtls_asn2err (result); 1077 result = MHD_gtls_asn2err (result);
1078 goto cleanup; 1078 goto cleanup;
1079 } 1079 }
1080 1080
1081 size = asize; 1081 size = asize;
1082 1082
1083 asn1_delete_structure (&c2); 1083 MHD__asn1_delete_structure (&c2);
1084 } 1084 }
1085 1085
1086 res->data = data; 1086 res->data = data;
1087 res->size = size; 1087 res->size = size;
1088 return 0; 1088 return 0;
1089 1089
1090cleanup:gnutls_free (data); 1090cleanup:MHD_gnutls_free (data);
1091 asn1_delete_structure (&c2); 1091 MHD__asn1_delete_structure (&c2);
1092 return result; 1092 return result;
1093 1093
1094} 1094}
@@ -1099,32 +1099,32 @@ cleanup:gnutls_free (data);
1099 * an OCTET STRING. 1099 * an OCTET STRING.
1100 */ 1100 */
1101int 1101int
1102_gnutls_x509_der_encode_and_copy (ASN1_TYPE src, 1102MHD__gnutls_x509_der_encode_and_copy (ASN1_TYPE src,
1103 const char *src_name, 1103 const char *src_name,
1104 ASN1_TYPE dest, 1104 ASN1_TYPE dest,
1105 const char *dest_name, int str) 1105 const char *dest_name, int str)
1106{ 1106{
1107 int result; 1107 int result;
1108 gnutls_datum_t encoded; 1108 MHD_gnutls_datum_t encoded;
1109 1109
1110 result = _gnutls_x509_der_encode (src, src_name, &encoded, str); 1110 result = MHD__gnutls_x509_der_encode (src, src_name, &encoded, str);
1111 1111
1112 if (result < 0) 1112 if (result < 0)
1113 { 1113 {
1114 gnutls_assert (); 1114 MHD_gnutls_assert ();
1115 return result; 1115 return result;
1116 } 1116 }
1117 1117
1118 /* Write the data. 1118 /* Write the data.
1119 */ 1119 */
1120 result = asn1_write_value (dest, dest_name, encoded.data, encoded.size); 1120 result = MHD__asn1_write_value (dest, dest_name, encoded.data, encoded.size);
1121 1121
1122 _gnutls_free_datum (&encoded); 1122 MHD__gnutls_free_datum (&encoded);
1123 1123
1124 if (result != ASN1_SUCCESS) 1124 if (result != ASN1_SUCCESS)
1125 { 1125 {
1126 gnutls_assert (); 1126 MHD_gnutls_assert ();
1127 return mhd_gtls_asn2err (result); 1127 return MHD_gtls_asn2err (result);
1128 } 1128 }
1129 1129
1130 return 0; 1130 return 0;
@@ -1134,21 +1134,21 @@ _gnutls_x509_der_encode_and_copy (ASN1_TYPE src,
1134 * zero it encodes it as OCTET STRING. 1134 * zero it encodes it as OCTET STRING.
1135 */ 1135 */
1136int 1136int
1137_gnutls_x509_write_value (ASN1_TYPE c, 1137MHD__gnutls_x509_write_value (ASN1_TYPE c,
1138 const char *root, 1138 const char *root,
1139 const gnutls_datum_t * data, int str) 1139 const MHD_gnutls_datum_t * data, int str)
1140{ 1140{
1141 int result; 1141 int result;
1142 int asize; 1142 int asize;
1143 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 1143 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
1144 gnutls_datum_t val; 1144 MHD_gnutls_datum_t val;
1145 1145
1146 asize = data->size + 16; 1146 asize = data->size + 16;
1147 1147
1148 val.data = gnutls_malloc (asize); 1148 val.data = MHD_gnutls_malloc (asize);
1149 if (val.data == NULL) 1149 if (val.data == NULL)
1150 { 1150 {
1151 gnutls_assert (); 1151 MHD_gnutls_assert ();
1152 result = GNUTLS_E_MEMORY_ERROR; 1152 result = GNUTLS_E_MEMORY_ERROR;
1153 goto cleanup; 1153 goto cleanup;
1154 } 1154 }
@@ -1158,26 +1158,26 @@ _gnutls_x509_write_value (ASN1_TYPE c,
1158 /* Convert it to OCTET STRING 1158 /* Convert it to OCTET STRING
1159 */ 1159 */
1160 if ((result = 1160 if ((result =
1161 asn1_create_element (_gnutls_get_pkix (), "PKIX1.pkcs-7-Data", 1161 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-Data",
1162 &c2)) != ASN1_SUCCESS) 1162 &c2)) != ASN1_SUCCESS)
1163 { 1163 {
1164 gnutls_assert (); 1164 MHD_gnutls_assert ();
1165 result = mhd_gtls_asn2err (result); 1165 result = MHD_gtls_asn2err (result);
1166 goto cleanup; 1166 goto cleanup;
1167 } 1167 }
1168 1168
1169 result = asn1_write_value (c2, "", data->data, data->size); 1169 result = MHD__asn1_write_value (c2, "", data->data, data->size);
1170 if (result != ASN1_SUCCESS) 1170 if (result != ASN1_SUCCESS)
1171 { 1171 {
1172 gnutls_assert (); 1172 MHD_gnutls_assert ();
1173 result = mhd_gtls_asn2err (result); 1173 result = MHD_gtls_asn2err (result);
1174 goto cleanup; 1174 goto cleanup;
1175 } 1175 }
1176 1176
1177 result = _gnutls_x509_der_encode (c2, "", &val, 0); 1177 result = MHD__gnutls_x509_der_encode (c2, "", &val, 0);
1178 if (result < 0) 1178 if (result < 0)
1179 { 1179 {
1180 gnutls_assert (); 1180 MHD_gnutls_assert ();
1181 goto cleanup; 1181 goto cleanup;
1182 } 1182 }
1183 1183
@@ -1190,21 +1190,21 @@ _gnutls_x509_write_value (ASN1_TYPE c,
1190 1190
1191 /* Write the data. 1191 /* Write the data.
1192 */ 1192 */
1193 result = asn1_write_value (c, root, val.data, val.size); 1193 result = MHD__asn1_write_value (c, root, val.data, val.size);
1194 1194
1195 if (val.data != data->data) 1195 if (val.data != data->data)
1196 _gnutls_free_datum (&val); 1196 MHD__gnutls_free_datum (&val);
1197 1197
1198 if (result != ASN1_SUCCESS) 1198 if (result != ASN1_SUCCESS)
1199 { 1199 {
1200 gnutls_assert (); 1200 MHD_gnutls_assert ();
1201 return mhd_gtls_asn2err (result); 1201 return MHD_gtls_asn2err (result);
1202 } 1202 }
1203 1203
1204 return 0; 1204 return 0;
1205 1205
1206cleanup:if (val.data != data->data) 1206cleanup:if (val.data != data->data)
1207 _gnutls_free_datum (&val); 1207 MHD__gnutls_free_datum (&val);
1208 return result; 1208 return result;
1209} 1209}
1210 1210
@@ -1213,69 +1213,69 @@ cleanup:if (val.data != data->data)
1213 * 1213 *
1214 */ 1214 */
1215int 1215int
1216_gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst, 1216MHD__gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst,
1217 const char *dst_name, 1217 const char *dst_name,
1218 enum MHD_GNUTLS_PublicKeyAlgorithm 1218 enum MHD_GNUTLS_PublicKeyAlgorithm
1219 pk_algorithm, 1219 pk_algorithm,
1220 mpi_t * params, int params_size) 1220 mpi_t * params, int params_size)
1221{ 1221{
1222 const char *pk; 1222 const char *pk;
1223 gnutls_datum_t der = { NULL, 1223 MHD_gnutls_datum_t der = { NULL,
1224 0 1224 0
1225 }; 1225 };
1226 int result; 1226 int result;
1227 char name[128]; 1227 char name[128];
1228 1228
1229 pk = mhd_gtls_x509_pk_to_oid (pk_algorithm); 1229 pk = MHD_gtls_x509_pk_to_oid (pk_algorithm);
1230 if (pk == NULL) 1230 if (pk == NULL)
1231 { 1231 {
1232 gnutls_assert (); 1232 MHD_gnutls_assert ();
1233 return GNUTLS_E_UNKNOWN_PK_ALGORITHM; 1233 return GNUTLS_E_UNKNOWN_PK_ALGORITHM;
1234 } 1234 }
1235 1235
1236 /* write the OID 1236 /* write the OID
1237 */ 1237 */
1238 mhd_gtls_str_cpy (name, sizeof (name), dst_name); 1238 MHD_gtls_str_cpy (name, sizeof (name), dst_name);
1239 mhd_gtls_str_cat (name, sizeof (name), ".algorithm.algorithm"); 1239 MHD_gtls_str_cat (name, sizeof (name), ".algorithm.algorithm");
1240 result = asn1_write_value (dst, name, pk, 1); 1240 result = MHD__asn1_write_value (dst, name, pk, 1);
1241 if (result != ASN1_SUCCESS) 1241 if (result != ASN1_SUCCESS)
1242 { 1242 {
1243 gnutls_assert (); 1243 MHD_gnutls_assert ();
1244 return mhd_gtls_asn2err (result); 1244 return MHD_gtls_asn2err (result);
1245 } 1245 }
1246 1246
1247 if (pk_algorithm == MHD_GNUTLS_PK_RSA) 1247 if (pk_algorithm == MHD_GNUTLS_PK_RSA)
1248 { 1248 {
1249 /* disable parameters, which are not used in RSA. 1249 /* disable parameters, which are not used in RSA.
1250 */ 1250 */
1251 mhd_gtls_str_cpy (name, sizeof (name), dst_name); 1251 MHD_gtls_str_cpy (name, sizeof (name), dst_name);
1252 mhd_gtls_str_cat (name, sizeof (name), ".algorithm.parameters"); 1252 MHD_gtls_str_cat (name, sizeof (name), ".algorithm.parameters");
1253 result = asn1_write_value (dst, name, NULL, 0); 1253 result = MHD__asn1_write_value (dst, name, NULL, 0);
1254 if (result != ASN1_SUCCESS) 1254 if (result != ASN1_SUCCESS)
1255 { 1255 {
1256 gnutls_assert (); 1256 MHD_gnutls_assert ();
1257 return mhd_gtls_asn2err (result); 1257 return MHD_gtls_asn2err (result);
1258 } 1258 }
1259 1259
1260 result = _gnutls_x509_write_rsa_params (params, params_size, &der); 1260 result = MHD__gnutls_x509_write_rsa_params (params, params_size, &der);
1261 if (result < 0) 1261 if (result < 0)
1262 { 1262 {
1263 gnutls_assert (); 1263 MHD_gnutls_assert ();
1264 return result; 1264 return result;
1265 } 1265 }
1266 1266
1267 /* Write the DER parameters. (in bits) 1267 /* Write the DER parameters. (in bits)
1268 */ 1268 */
1269 mhd_gtls_str_cpy (name, sizeof (name), dst_name); 1269 MHD_gtls_str_cpy (name, sizeof (name), dst_name);
1270 mhd_gtls_str_cat (name, sizeof (name), ".subjectPublicKey"); 1270 MHD_gtls_str_cat (name, sizeof (name), ".subjectPublicKey");
1271 result = asn1_write_value (dst, name, der.data, der.size * 8); 1271 result = MHD__asn1_write_value (dst, name, der.data, der.size * 8);
1272 1272
1273 _gnutls_free_datum (&der); 1273 MHD__gnutls_free_datum (&der);
1274 1274
1275 if (result != ASN1_SUCCESS) 1275 if (result != ASN1_SUCCESS)
1276 { 1276 {
1277 gnutls_assert (); 1277 MHD_gnutls_assert ();
1278 return mhd_gtls_asn2err (result); 1278 return MHD_gtls_asn2err (result);
1279 } 1279 }
1280 } 1280 }
1281 else 1281 else
@@ -1288,7 +1288,7 @@ _gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst,
1288 * ASN.1 structure. src_name should be something like "tbsCertificate.subjectPublicKeyInfo". 1288 * ASN.1 structure. src_name should be something like "tbsCertificate.subjectPublicKeyInfo".
1289 */ 1289 */
1290int 1290int
1291_gnutls_x509_get_pk_algorithm (ASN1_TYPE src, 1291MHD__gnutls_x509_get_pk_algorithm (ASN1_TYPE src,
1292 const char *src_name, unsigned int *bits) 1292 const char *src_name, unsigned int *bits)
1293{ 1293{
1294 int result; 1294 int result;
@@ -1299,64 +1299,64 @@ _gnutls_x509_get_pk_algorithm (ASN1_TYPE src,
1299 mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; 1299 mpi_t params[MAX_PUBLIC_PARAMS_SIZE];
1300 char name[128]; 1300 char name[128];
1301 1301
1302 mhd_gtls_str_cpy (name, sizeof (name), src_name); 1302 MHD_gtls_str_cpy (name, sizeof (name), src_name);
1303 mhd_gtls_str_cat (name, sizeof (name), ".algorithm.algorithm"); 1303 MHD_gtls_str_cat (name, sizeof (name), ".algorithm.algorithm");
1304 1304
1305 len = sizeof (oid); 1305 len = sizeof (oid);
1306 result = asn1_read_value (src, name, oid, &len); 1306 result = MHD__asn1_read_value (src, name, oid, &len);
1307 1307
1308 if (result != ASN1_SUCCESS) 1308 if (result != ASN1_SUCCESS)
1309 { 1309 {
1310 gnutls_assert (); 1310 MHD_gnutls_assert ();
1311 return mhd_gtls_asn2err (result); 1311 return MHD_gtls_asn2err (result);
1312 } 1312 }
1313 1313
1314 algo = mhd_gtls_x509_oid2pk_algorithm (oid); 1314 algo = MHD_gtls_x509_oid2pk_algorithm (oid);
1315 1315
1316 if (bits == NULL) 1316 if (bits == NULL)
1317 { 1317 {
1318 gnutls_free (str); 1318 MHD_gnutls_free (str);
1319 return algo; 1319 return algo;
1320 } 1320 }
1321 1321
1322 /* Now read the parameters' bits 1322 /* Now read the parameters' bits
1323 */ 1323 */
1324 mhd_gtls_str_cpy (name, sizeof (name), src_name); 1324 MHD_gtls_str_cpy (name, sizeof (name), src_name);
1325 mhd_gtls_str_cat (name, sizeof (name), ".subjectPublicKey"); 1325 MHD_gtls_str_cat (name, sizeof (name), ".subjectPublicKey");
1326 1326
1327 len = 0; 1327 len = 0;
1328 result = asn1_read_value (src, name, NULL, &len); 1328 result = MHD__asn1_read_value (src, name, NULL, &len);
1329 if (result != ASN1_MEM_ERROR) 1329 if (result != ASN1_MEM_ERROR)
1330 { 1330 {
1331 gnutls_assert (); 1331 MHD_gnutls_assert ();
1332 return mhd_gtls_asn2err (result); 1332 return MHD_gtls_asn2err (result);
1333 } 1333 }
1334 1334
1335 if (len % 8 != 0) 1335 if (len % 8 != 0)
1336 { 1336 {
1337 gnutls_assert (); 1337 MHD_gnutls_assert ();
1338 return GNUTLS_E_CERTIFICATE_ERROR; 1338 return GNUTLS_E_CERTIFICATE_ERROR;
1339 } 1339 }
1340 1340
1341 len /= 8; 1341 len /= 8;
1342 1342
1343 str = gnutls_malloc (len); 1343 str = MHD_gnutls_malloc (len);
1344 if (str == NULL) 1344 if (str == NULL)
1345 { 1345 {
1346 gnutls_assert (); 1346 MHD_gnutls_assert ();
1347 return GNUTLS_E_MEMORY_ERROR; 1347 return GNUTLS_E_MEMORY_ERROR;
1348 } 1348 }
1349 1349
1350 mhd_gtls_str_cpy (name, sizeof (name), src_name); 1350 MHD_gtls_str_cpy (name, sizeof (name), src_name);
1351 mhd_gtls_str_cat (name, sizeof (name), ".subjectPublicKey"); 1351 MHD_gtls_str_cat (name, sizeof (name), ".subjectPublicKey");
1352 1352
1353 result = asn1_read_value (src, name, str, &len); 1353 result = MHD__asn1_read_value (src, name, str, &len);
1354 1354
1355 if (result != ASN1_SUCCESS) 1355 if (result != ASN1_SUCCESS)
1356 { 1356 {
1357 gnutls_assert (); 1357 MHD_gnutls_assert ();
1358 gnutls_free (str); 1358 MHD_gnutls_free (str);
1359 return mhd_gtls_asn2err (result); 1359 return MHD_gtls_asn2err (result);
1360 } 1360 }
1361 1361
1362 len /= 8; 1362 len /= 8;
@@ -1365,24 +1365,24 @@ _gnutls_x509_get_pk_algorithm (ASN1_TYPE src,
1365 { 1365 {
1366 case MHD_GNUTLS_PK_RSA: 1366 case MHD_GNUTLS_PK_RSA:
1367 { 1367 {
1368 if ((result = _gnutls_x509_read_rsa_params (str, len, params)) < 0) 1368 if ((result = MHD__gnutls_x509_read_rsa_params (str, len, params)) < 0)
1369 { 1369 {
1370 gnutls_assert (); 1370 MHD_gnutls_assert ();
1371 return result; 1371 return result;
1372 } 1372 }
1373 1373
1374 bits[0] = _gnutls_mpi_get_nbits (params[0]); 1374 bits[0] = MHD__gnutls_mpi_get_nbits (params[0]);
1375 1375
1376 mhd_gtls_mpi_release (&params[0]); 1376 MHD_gtls_mpi_release (&params[0]);
1377 mhd_gtls_mpi_release (&params[1]); 1377 MHD_gtls_mpi_release (&params[1]);
1378 } 1378 }
1379 break; 1379 break;
1380 default: 1380 default:
1381 _gnutls_x509_log 1381 MHD__gnutls_x509_log
1382 ("_gnutls_x509_get_pk_algorithm: unhandled algorithm %d\n", algo); 1382 ("MHD__gnutls_x509_get_pk_algorithm: unhandled algorithm %d\n", algo);
1383 } 1383 }
1384 1384
1385 gnutls_free (str); 1385 MHD_gnutls_free (str);
1386 return algo; 1386 return algo;
1387} 1387}
1388 1388
@@ -1390,42 +1390,42 @@ _gnutls_x509_get_pk_algorithm (ASN1_TYPE src,
1390 * returns them into signed_data. 1390 * returns them into signed_data.
1391 */ 1391 */
1392int 1392int
1393_gnutls_x509_get_signed_data (ASN1_TYPE src, 1393MHD__gnutls_x509_get_signed_data (ASN1_TYPE src,
1394 const char *src_name, 1394 const char *src_name,
1395 gnutls_datum_t * signed_data) 1395 MHD_gnutls_datum_t * signed_data)
1396{ 1396{
1397 gnutls_datum_t der; 1397 MHD_gnutls_datum_t der;
1398 int start, end, result; 1398 int start, end, result;
1399 1399
1400 result = _gnutls_x509_der_encode (src, "", &der, 0); 1400 result = MHD__gnutls_x509_der_encode (src, "", &der, 0);
1401 if (result < 0) 1401 if (result < 0)
1402 { 1402 {
1403 gnutls_assert (); 1403 MHD_gnutls_assert ();
1404 return result; 1404 return result;
1405 } 1405 }
1406 1406
1407 /* Get the signed data 1407 /* Get the signed data
1408 */ 1408 */
1409 result = asn1_der_decoding_startEnd (src, der.data, der.size, src_name, 1409 result = MHD__asn1_der_decoding_startEnd (src, der.data, der.size, src_name,
1410 &start, &end); 1410 &start, &end);
1411 if (result != ASN1_SUCCESS) 1411 if (result != ASN1_SUCCESS)
1412 { 1412 {
1413 result = mhd_gtls_asn2err (result); 1413 result = MHD_gtls_asn2err (result);
1414 gnutls_assert (); 1414 MHD_gnutls_assert ();
1415 goto cleanup; 1415 goto cleanup;
1416 } 1416 }
1417 1417
1418 result = _gnutls_set_datum (signed_data, &der.data[start], end - start + 1); 1418 result = MHD__gnutls_set_datum (signed_data, &der.data[start], end - start + 1);
1419 1419
1420 if (result < 0) 1420 if (result < 0)
1421 { 1421 {
1422 gnutls_assert (); 1422 MHD_gnutls_assert ();
1423 goto cleanup; 1423 goto cleanup;
1424 } 1424 }
1425 1425
1426 result = 0; 1426 result = 0;
1427 1427
1428cleanup:_gnutls_free_datum (&der); 1428cleanup:MHD__gnutls_free_datum (&der);
1429 1429
1430 return result; 1430 return result;
1431} 1431}
@@ -1434,8 +1434,8 @@ cleanup:_gnutls_free_datum (&der);
1434 * returns them into signed_data. 1434 * returns them into signed_data.
1435 */ 1435 */
1436int 1436int
1437_gnutls_x509_get_signature (ASN1_TYPE src, 1437MHD__gnutls_x509_get_signature (ASN1_TYPE src,
1438 const char *src_name, gnutls_datum_t * signature) 1438 const char *src_name, MHD_gnutls_datum_t * signature)
1439{ 1439{
1440 int bits, result, len; 1440 int bits, result, len;
1441 1441
@@ -1445,28 +1445,28 @@ _gnutls_x509_get_signature (ASN1_TYPE src,
1445 /* Read the signature 1445 /* Read the signature
1446 */ 1446 */
1447 bits = 0; 1447 bits = 0;
1448 result = asn1_read_value (src, src_name, NULL, &bits); 1448 result = MHD__asn1_read_value (src, src_name, NULL, &bits);
1449 1449
1450 if (result != ASN1_MEM_ERROR) 1450 if (result != ASN1_MEM_ERROR)
1451 { 1451 {
1452 result = mhd_gtls_asn2err (result); 1452 result = MHD_gtls_asn2err (result);
1453 gnutls_assert (); 1453 MHD_gnutls_assert ();
1454 goto cleanup; 1454 goto cleanup;
1455 } 1455 }
1456 1456
1457 if (bits % 8 != 0) 1457 if (bits % 8 != 0)
1458 { 1458 {
1459 gnutls_assert (); 1459 MHD_gnutls_assert ();
1460 result = GNUTLS_E_CERTIFICATE_ERROR; 1460 result = GNUTLS_E_CERTIFICATE_ERROR;
1461 goto cleanup; 1461 goto cleanup;
1462 } 1462 }
1463 1463
1464 len = bits / 8; 1464 len = bits / 8;
1465 1465
1466 signature->data = gnutls_malloc (len); 1466 signature->data = MHD_gnutls_malloc (len);
1467 if (signature->data == NULL) 1467 if (signature->data == NULL)
1468 { 1468 {
1469 gnutls_assert (); 1469 MHD_gnutls_assert ();
1470 result = GNUTLS_E_MEMORY_ERROR; 1470 result = GNUTLS_E_MEMORY_ERROR;
1471 return result; 1471 return result;
1472 } 1472 }
@@ -1474,12 +1474,12 @@ _gnutls_x509_get_signature (ASN1_TYPE src,
1474 /* read the bit string of the signature 1474 /* read the bit string of the signature
1475 */ 1475 */
1476 bits = len; 1476 bits = len;
1477 result = asn1_read_value (src, src_name, signature->data, &bits); 1477 result = MHD__asn1_read_value (src, src_name, signature->data, &bits);
1478 1478
1479 if (result != ASN1_SUCCESS) 1479 if (result != ASN1_SUCCESS)
1480 { 1480 {
1481 result = mhd_gtls_asn2err (result); 1481 result = MHD_gtls_asn2err (result);
1482 gnutls_assert (); 1482 MHD_gnutls_assert ();
1483 goto cleanup; 1483 goto cleanup;
1484 } 1484 }
1485 1485
diff --git a/src/daemon/https/x509/common.h b/src/daemon/https/x509/common.h
index 0e91c96d..4050f36b 100644
--- a/src/daemon/https/x509/common.h
+++ b/src/daemon/https/x509/common.h
@@ -58,70 +58,70 @@
58#define SIG_GOST_R3410_94_OID "1.2.643.2.2.4" 58#define SIG_GOST_R3410_94_OID "1.2.643.2.2.4"
59#define SIG_GOST_R3410_2001_OID "1.2.643.2.2.3" 59#define SIG_GOST_R3410_2001_OID "1.2.643.2.2.3"
60 60
61time_t _gnutls_x509_utcTime2gtime (const char *ttime); 61time_t MHD__gnutls_x509_utcTime2gtime (const char *ttime);
62time_t _gnutls_x509_generalTime2gtime (const char *ttime); 62time_t MHD__gnutls_x509_generalTime2gtime (const char *ttime);
63int _gnutls_x509_set_time (ASN1_TYPE c2, const char *where, time_t tim); 63int MHD__gnutls_x509_set_time (ASN1_TYPE c2, const char *where, time_t tim);
64 64
65int _gnutls_x509_decode_octet_string (const char *string_type, 65int MHD__gnutls_x509_decode_octet_string (const char *string_type,
66 const opaque * der, size_t der_size, 66 const opaque * der, size_t der_size,
67 opaque * output, size_t * output_size); 67 opaque * output, size_t * output_size);
68int _gnutls_x509_oid_data2string (const char *OID, void *value, 68int MHD__gnutls_x509_oid_data2string (const char *OID, void *value,
69 int value_size, char *res, 69 int value_size, char *res,
70 size_t * res_size); 70 size_t * res_size);
71int _gnutls_x509_data2hex (const opaque * data, size_t data_size, 71int MHD__gnutls_x509_data2hex (const opaque * data, size_t data_size,
72 opaque * out, size_t * sizeof_out); 72 opaque * out, size_t * sizeof_out);
73 73
74const char *_gnutls_x509_oid2ldap_string (const char *OID); 74const char *MHD__gnutls_x509_oid2ldap_string (const char *OID);
75 75
76int _gnutls_x509_oid_data_choice (const char *OID); 76int MHD__gnutls_x509_oid_data_choice (const char *OID);
77int _gnutls_x509_oid_data_printable (const char *OID); 77int MHD__gnutls_x509_oid_data_printable (const char *OID);
78 78
79time_t _gnutls_x509_get_time (ASN1_TYPE c2, const char *when); 79time_t MHD__gnutls_x509_get_time (ASN1_TYPE c2, const char *when);
80 80
81gnutls_x509_subject_alt_name_t _gnutls_x509_san_find_type (char *str_type); 81MHD_gnutls_x509_subject_alt_name_t MHD__gnutls_x509_san_find_type (char *str_type);
82 82
83int _gnutls_x509_der_encode_and_copy (ASN1_TYPE src, const char *src_name, 83int MHD__gnutls_x509_der_encode_and_copy (ASN1_TYPE src, const char *src_name,
84 ASN1_TYPE dest, const char *dest_name, 84 ASN1_TYPE dest, const char *dest_name,
85 int str); 85 int str);
86int _gnutls_x509_der_encode (ASN1_TYPE src, const char *src_name, 86int MHD__gnutls_x509_der_encode (ASN1_TYPE src, const char *src_name,
87 gnutls_datum_t * res, int str); 87 MHD_gnutls_datum_t * res, int str);
88 88
89int _gnutls_x509_export_int (ASN1_TYPE asn1_data, 89int MHD__gnutls_x509_export_int (ASN1_TYPE MHD__asn1_data,
90 gnutls_x509_crt_fmt_t format, char *pem_header, 90 MHD_gnutls_x509_crt_fmt_t format, char *pem_header,
91 unsigned char *output_data, 91 unsigned char *output_data,
92 size_t * output_data_size); 92 size_t * output_data_size);
93 93
94int _gnutls_x509_read_value (ASN1_TYPE c, const char *root, 94int MHD__gnutls_x509_read_value (ASN1_TYPE c, const char *root,
95 gnutls_datum_t * ret, int str); 95 MHD_gnutls_datum_t * ret, int str);
96int _gnutls_x509_write_value (ASN1_TYPE c, const char *root, 96int MHD__gnutls_x509_write_value (ASN1_TYPE c, const char *root,
97 const gnutls_datum_t * data, int str); 97 const MHD_gnutls_datum_t * data, int str);
98 98
99int _gnutls_x509_encode_and_write_attribute (const char *given_oid, 99int MHD__gnutls_x509_encode_and_write_attribute (const char *given_oid,
100 ASN1_TYPE asn1_struct, 100 ASN1_TYPE MHD__asn1_struct,
101 const char *where, 101 const char *where,
102 const void *data, 102 const void *data,
103 int sizeof_data, int multi); 103 int sizeof_data, int multi);
104int _gnutls_x509_decode_and_read_attribute (ASN1_TYPE asn1_struct, 104int MHD__gnutls_x509_decode_and_read_attribute (ASN1_TYPE MHD__asn1_struct,
105 const char *where, char *oid, 105 const char *where, char *oid,
106 int oid_size, 106 int oid_size,
107 gnutls_datum_t * value, int multi, 107 MHD_gnutls_datum_t * value, int multi,
108 int octet); 108 int octet);
109 109
110int _gnutls_x509_get_pk_algorithm (ASN1_TYPE src, const char *src_name, 110int MHD__gnutls_x509_get_pk_algorithm (ASN1_TYPE src, const char *src_name,
111 unsigned int *bits); 111 unsigned int *bits);
112 112
113int _gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst, 113int MHD__gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst,
114 const char *dst_name, 114 const char *dst_name,
115 enum 115 enum
116 MHD_GNUTLS_PublicKeyAlgorithm 116 MHD_GNUTLS_PublicKeyAlgorithm
117 pk_algorithm, mpi_t * params, 117 pk_algorithm, mpi_t * params,
118 int params_size); 118 int params_size);
119int _gnutls_asn1_copy_node (ASN1_TYPE * dst, const char *dst_name, 119int MHD__gnutlsMHD__asn1_copy_node (ASN1_TYPE * dst, const char *dst_name,
120 ASN1_TYPE src, const char *src_name); 120 ASN1_TYPE src, const char *src_name);
121 121
122int _gnutls_x509_get_signed_data (ASN1_TYPE src, const char *src_name, 122int MHD__gnutls_x509_get_signed_data (ASN1_TYPE src, const char *src_name,
123 gnutls_datum_t * signed_data); 123 MHD_gnutls_datum_t * signed_data);
124int _gnutls_x509_get_signature (ASN1_TYPE src, const char *src_name, 124int MHD__gnutls_x509_get_signature (ASN1_TYPE src, const char *src_name,
125 gnutls_datum_t * signature); 125 MHD_gnutls_datum_t * signature);
126 126
127#endif 127#endif
diff --git a/src/daemon/https/x509/crl.c b/src/daemon/https/x509/crl.c
index 9ad49c67..17703b91 100644
--- a/src/daemon/https/x509/crl.c
+++ b/src/daemon/https/x509/crl.c
@@ -36,7 +36,7 @@
36#include <dn.h> 36#include <dn.h>
37 37
38/** 38/**
39 * gnutls_x509_crl_init - This function initializes a gnutls_x509_crl_t structure 39 * MHD_gnutls_x509_crl_init - This function initializes a MHD_gnutls_x509_crl_t structure
40 * @crl: The structure to be initialized 40 * @crl: The structure to be initialized
41 * 41 *
42 * This function will initialize a CRL structure. CRL stands for 42 * This function will initialize a CRL structure. CRL stands for
@@ -49,20 +49,20 @@
49 * 49 *
50 **/ 50 **/
51int 51int
52gnutls_x509_crl_init (gnutls_x509_crl_t * crl) 52MHD_gnutls_x509_crl_init (MHD_gnutls_x509_crl_t * crl)
53{ 53{
54 *crl = gnutls_calloc (1, sizeof (gnutls_x509_crl_int)); 54 *crl = MHD_gnutls_calloc (1, sizeof (MHD_gnutls_x509_crl_int));
55 55
56 if (*crl) 56 if (*crl)
57 { 57 {
58 int result = asn1_create_element (_gnutls_get_pkix (), 58 int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
59 "PKIX1.CertificateList", 59 "PKIX1.CertificateList",
60 &(*crl)->crl); 60 &(*crl)->crl);
61 if (result != ASN1_SUCCESS) 61 if (result != ASN1_SUCCESS)
62 { 62 {
63 gnutls_assert (); 63 MHD_gnutls_assert ();
64 gnutls_free (*crl); 64 MHD_gnutls_free (*crl);
65 return mhd_gtls_asn2err (result); 65 return MHD_gtls_asn2err (result);
66 } 66 }
67 return 0; /* success */ 67 return 0; /* success */
68 } 68 }
@@ -70,32 +70,32 @@ gnutls_x509_crl_init (gnutls_x509_crl_t * crl)
70} 70}
71 71
72/** 72/**
73 * gnutls_x509_crl_deinit - This function deinitializes memory used by a gnutls_x509_crl_t structure 73 * MHD_gnutls_x509_crl_deinit - This function deinitializes memory used by a MHD_gnutls_x509_crl_t structure
74 * @crl: The structure to be initialized 74 * @crl: The structure to be initialized
75 * 75 *
76 * This function will deinitialize a CRL structure. 76 * This function will deinitialize a CRL structure.
77 * 77 *
78 **/ 78 **/
79void 79void
80gnutls_x509_crl_deinit (gnutls_x509_crl_t crl) 80MHD_gnutls_x509_crl_deinit (MHD_gnutls_x509_crl_t crl)
81{ 81{
82 if (!crl) 82 if (!crl)
83 return; 83 return;
84 84
85 if (crl->crl) 85 if (crl->crl)
86 asn1_delete_structure (&crl->crl); 86 MHD__asn1_delete_structure (&crl->crl);
87 87
88 gnutls_free (crl); 88 MHD_gnutls_free (crl);
89} 89}
90 90
91/** 91/**
92 * gnutls_x509_crl_import - This function will import a DER or PEM encoded CRL 92 * MHD_gnutls_x509_crl_import - This function will import a DER or PEM encoded CRL
93 * @crl: The structure to store the parsed CRL. 93 * @crl: The structure to store the parsed CRL.
94 * @data: The DER or PEM encoded CRL. 94 * @data: The DER or PEM encoded CRL.
95 * @format: One of DER or PEM 95 * @format: One of DER or PEM
96 * 96 *
97 * This function will convert the given DER or PEM encoded CRL 97 * This function will convert the given DER or PEM encoded CRL
98 * to the native gnutls_x509_crl_t format. The output will be stored in 'crl'. 98 * to the native MHD_gnutls_x509_crl_t format. The output will be stored in 'crl'.
99 * 99 *
100 * If the CRL is PEM encoded it should have a header of "X509 CRL". 100 * If the CRL is PEM encoded it should have a header of "X509 CRL".
101 * 101 *
@@ -103,19 +103,19 @@ gnutls_x509_crl_deinit (gnutls_x509_crl_t crl)
103 * 103 *
104 **/ 104 **/
105int 105int
106gnutls_x509_crl_import (gnutls_x509_crl_t crl, 106MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl,
107 const gnutls_datum_t * data, 107 const MHD_gnutls_datum_t * data,
108 gnutls_x509_crt_fmt_t format) 108 MHD_gnutls_x509_crt_fmt_t format)
109{ 109{
110 int result = 0, need_free = 0; 110 int result = 0, need_free = 0;
111 gnutls_datum_t _data; 111 MHD_gnutls_datum_t _data;
112 112
113 _data.data = data->data; 113 _data.data = data->data;
114 _data.size = data->size; 114 _data.size = data->size;
115 115
116 if (crl == NULL) 116 if (crl == NULL)
117 { 117 {
118 gnutls_assert (); 118 MHD_gnutls_assert ();
119 return GNUTLS_E_INVALID_REQUEST; 119 return GNUTLS_E_INVALID_REQUEST;
120 } 120 }
121 121
@@ -125,13 +125,13 @@ gnutls_x509_crl_import (gnutls_x509_crl_t crl,
125 { 125 {
126 opaque *out; 126 opaque *out;
127 127
128 result = _gnutls_fbase64_decode (PEM_CRL, data->data, data->size, &out); 128 result = MHD__gnutls_fbase64_decode (PEM_CRL, data->data, data->size, &out);
129 129
130 if (result <= 0) 130 if (result <= 0)
131 { 131 {
132 if (result == 0) 132 if (result == 0)
133 result = GNUTLS_E_INTERNAL_ERROR; 133 result = GNUTLS_E_INTERNAL_ERROR;
134 gnutls_assert (); 134 MHD_gnutls_assert ();
135 return result; 135 return result;
136 } 136 }
137 137
@@ -142,29 +142,29 @@ gnutls_x509_crl_import (gnutls_x509_crl_t crl,
142 } 142 }
143 143
144 144
145 result = asn1_der_decoding (&crl->crl, _data.data, _data.size, NULL); 145 result = MHD__asn1_der_decoding (&crl->crl, _data.data, _data.size, NULL);
146 if (result != ASN1_SUCCESS) 146 if (result != ASN1_SUCCESS)
147 { 147 {
148 result = mhd_gtls_asn2err (result); 148 result = MHD_gtls_asn2err (result);
149 gnutls_assert (); 149 MHD_gnutls_assert ();
150 goto cleanup; 150 goto cleanup;
151 } 151 }
152 152
153 if (need_free) 153 if (need_free)
154 _gnutls_free_datum (&_data); 154 MHD__gnutls_free_datum (&_data);
155 155
156 return 0; 156 return 0;
157 157
158cleanup: 158cleanup:
159 if (need_free) 159 if (need_free)
160 _gnutls_free_datum (&_data); 160 MHD__gnutls_free_datum (&_data);
161 return result; 161 return result;
162} 162}
163 163
164 164
165/** 165/**
166 * gnutls_x509_crl_get_issuer_dn - This function returns the CRL's issuer distinguished name 166 * MHD_gnutls_x509_crl_get_issuer_dn - This function returns the CRL's issuer distinguished name
167 * @crl: should contain a gnutls_x509_crl_t structure 167 * @crl: should contain a MHD_gnutls_x509_crl_t structure
168 * @buf: a pointer to a structure to hold the peer's name (may be null) 168 * @buf: a pointer to a structure to hold the peer's name (may be null)
169 * @sizeof_buf: initially holds the size of @buf 169 * @sizeof_buf: initially holds the size of @buf
170 * 170 *
@@ -180,23 +180,23 @@ cleanup:
180 * 180 *
181 **/ 181 **/
182int 182int
183gnutls_x509_crl_get_issuer_dn (const gnutls_x509_crl_t crl, char *buf, 183MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl, char *buf,
184 size_t * sizeof_buf) 184 size_t * sizeof_buf)
185{ 185{
186 if (crl == NULL) 186 if (crl == NULL)
187 { 187 {
188 gnutls_assert (); 188 MHD_gnutls_assert ();
189 return GNUTLS_E_INVALID_REQUEST; 189 return GNUTLS_E_INVALID_REQUEST;
190 } 190 }
191 191
192 return _gnutls_x509_parse_dn (crl->crl, 192 return MHD__gnutls_x509_parse_dn (crl->crl,
193 "tbsCertList.issuer.rdnSequence", 193 "tbsCertList.issuer.rdnSequence",
194 buf, sizeof_buf); 194 buf, sizeof_buf);
195} 195}
196 196
197/** 197/**
198 * gnutls_x509_crl_get_issuer_dn_by_oid - This function returns the CRL's issuer distinguished name 198 * MHD_gnutls_x509_crl_get_issuer_dn_by_oid - This function returns the CRL's issuer distinguished name
199 * @crl: should contain a gnutls_x509_crl_t structure 199 * @crl: should contain a MHD_gnutls_x509_crl_t structure
200 * @oid: holds an Object Identified in null terminated string 200 * @oid: holds an Object Identified in null terminated string
201 * @indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one. 201 * @indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
202 * @raw_flag: If non zero returns the raw DER data of the DN part. 202 * @raw_flag: If non zero returns the raw DER data of the DN part.
@@ -210,7 +210,7 @@ gnutls_x509_crl_get_issuer_dn (const gnutls_x509_crl_t crl, char *buf,
210 * Some helper macros with popular OIDs can be found in gnutls/x509.h 210 * Some helper macros with popular OIDs can be found in gnutls/x509.h
211 * If raw flag is zero, this function will only return known OIDs as text. Other OIDs 211 * If raw flag is zero, this function will only return known OIDs as text. Other OIDs
212 * will be DER encoded, as described in RFC2253 -- in hex format with a '\#' prefix. 212 * will be DER encoded, as described in RFC2253 -- in hex format with a '\#' prefix.
213 * You can check about known OIDs using gnutls_x509_dn_oid_known(). 213 * You can check about known OIDs using MHD_gnutls_x509_dn_oid_known().
214 * 214 *
215 * If buf is null then only the size will be filled. 215 * If buf is null then only the size will be filled.
216 * 216 *
@@ -220,25 +220,25 @@ gnutls_x509_crl_get_issuer_dn (const gnutls_x509_crl_t crl, char *buf,
220 * 220 *
221 **/ 221 **/
222int 222int
223gnutls_x509_crl_get_issuer_dn_by_oid (gnutls_x509_crl_t crl, 223MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl,
224 const char *oid, int indx, 224 const char *oid, int indx,
225 unsigned int raw_flag, void *buf, 225 unsigned int raw_flag, void *buf,
226 size_t * sizeof_buf) 226 size_t * sizeof_buf)
227{ 227{
228 if (crl == NULL) 228 if (crl == NULL)
229 { 229 {
230 gnutls_assert (); 230 MHD_gnutls_assert ();
231 return GNUTLS_E_INVALID_REQUEST; 231 return GNUTLS_E_INVALID_REQUEST;
232 } 232 }
233 233
234 return _gnutls_x509_parse_dn_oid (crl->crl, 234 return MHD__gnutls_x509_parse_dn_oid (crl->crl,
235 "tbsCertList.issuer.rdnSequence", 235 "tbsCertList.issuer.rdnSequence",
236 oid, indx, raw_flag, buf, sizeof_buf); 236 oid, indx, raw_flag, buf, sizeof_buf);
237} 237}
238 238
239/** 239/**
240 * gnutls_x509_crl_get_dn_oid - This function returns the Certificate request issuer's distinguished name OIDs 240 * MHD_gnutls_x509_crl_get_dn_oid - This function returns the Certificate request issuer's distinguished name OIDs
241 * @crl: should contain a gnutls_x509_crl_t structure 241 * @crl: should contain a MHD_gnutls_x509_crl_t structure
242 * @indx: Specifies which DN OID to send. Use zero to get the first one. 242 * @indx: Specifies which DN OID to send. Use zero to get the first one.
243 * @oid: a pointer to a structure to hold the name (may be null) 243 * @oid: a pointer to a structure to hold the name (may be null)
244 * @sizeof_oid: initially holds the size of 'oid' 244 * @sizeof_oid: initially holds the size of 'oid'
@@ -254,40 +254,40 @@ gnutls_x509_crl_get_issuer_dn_by_oid (gnutls_x509_crl_t crl,
254 * 254 *
255 **/ 255 **/
256int 256int
257gnutls_x509_crl_get_dn_oid (gnutls_x509_crl_t crl, 257MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl,
258 int indx, void *oid, size_t * sizeof_oid) 258 int indx, void *oid, size_t * sizeof_oid)
259{ 259{
260 if (crl == NULL) 260 if (crl == NULL)
261 { 261 {
262 gnutls_assert (); 262 MHD_gnutls_assert ();
263 return GNUTLS_E_INVALID_REQUEST; 263 return GNUTLS_E_INVALID_REQUEST;
264 } 264 }
265 265
266 return _gnutls_x509_get_dn_oid (crl->crl, 266 return MHD__gnutls_x509_get_dn_oid (crl->crl,
267 "tbsCertList.issuer.rdnSequence", indx, 267 "tbsCertList.issuer.rdnSequence", indx,
268 oid, sizeof_oid); 268 oid, sizeof_oid);
269} 269}
270 270
271 271
272/** 272/**
273 * gnutls_x509_crl_get_signature_algorithm - This function returns the CRL's signature algorithm 273 * MHD_gnutls_x509_crl_get_signature_algorithm - This function returns the CRL's signature algorithm
274 * @crl: should contain a gnutls_x509_crl_t structure 274 * @crl: should contain a MHD_gnutls_x509_crl_t structure
275 * 275 *
276 * This function will return a value of the gnutls_sign_algorithm_t enumeration that 276 * This function will return a value of the MHD_gnutls_sign_algorithm_t enumeration that
277 * is the signature algorithm. 277 * is the signature algorithm.
278 * 278 *
279 * Returns a negative value on error. 279 * Returns a negative value on error.
280 * 280 *
281 **/ 281 **/
282int 282int
283gnutls_x509_crl_get_signature_algorithm (gnutls_x509_crl_t crl) 283MHD_gnutls_x509_crl_get_signature_algorithm (MHD_gnutls_x509_crl_t crl)
284{ 284{
285 int result; 285 int result;
286 gnutls_datum_t sa; 286 MHD_gnutls_datum_t sa;
287 287
288 if (crl == NULL) 288 if (crl == NULL)
289 { 289 {
290 gnutls_assert (); 290 MHD_gnutls_assert ();
291 return GNUTLS_E_INVALID_REQUEST; 291 return GNUTLS_E_INVALID_REQUEST;
292 } 292 }
293 293
@@ -296,25 +296,25 @@ gnutls_x509_crl_get_signature_algorithm (gnutls_x509_crl_t crl)
296 */ 296 */
297 297
298 result = 298 result =
299 _gnutls_x509_read_value (crl->crl, "signatureAlgorithm.algorithm", 299 MHD__gnutls_x509_read_value (crl->crl, "signatureAlgorithm.algorithm",
300 &sa, 0); 300 &sa, 0);
301 301
302 if (result < 0) 302 if (result < 0)
303 { 303 {
304 gnutls_assert (); 304 MHD_gnutls_assert ();
305 return result; 305 return result;
306 } 306 }
307 307
308 result = mhd_gtls_x509_oid2sign_algorithm ((const char *) sa.data); 308 result = MHD_gtls_x509_oid2sign_algorithm ((const char *) sa.data);
309 309
310 _gnutls_free_datum (&sa); 310 MHD__gnutls_free_datum (&sa);
311 311
312 return result; 312 return result;
313} 313}
314 314
315/** 315/**
316 * gnutls_x509_crl_get_signature - Returns the CRL's signature 316 * MHD_gnutls_x509_crl_get_signature - Returns the CRL's signature
317 * @crl: should contain a gnutls_x509_crl_t structure 317 * @crl: should contain a MHD_gnutls_x509_crl_t structure
318 * @sig: a pointer where the signature part will be copied (may be null). 318 * @sig: a pointer where the signature part will be copied (may be null).
319 * @sizeof_sig: initially holds the size of @sig 319 * @sizeof_sig: initially holds the size of @sig
320 * 320 *
@@ -323,7 +323,7 @@ gnutls_x509_crl_get_signature_algorithm (gnutls_x509_crl_t crl)
323 * Returns 0 on success, and a negative value on error. 323 * Returns 0 on success, and a negative value on error.
324 **/ 324 **/
325int 325int
326gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl, 326MHD_gnutls_x509_crl_get_signature (MHD_gnutls_x509_crl_t crl,
327 char *sig, size_t * sizeof_sig) 327 char *sig, size_t * sizeof_sig)
328{ 328{
329 int result; 329 int result;
@@ -331,21 +331,21 @@ gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl,
331 331
332 if (crl == NULL) 332 if (crl == NULL)
333 { 333 {
334 gnutls_assert (); 334 MHD_gnutls_assert ();
335 return GNUTLS_E_INVALID_REQUEST; 335 return GNUTLS_E_INVALID_REQUEST;
336 } 336 }
337 337
338 bits = 0; 338 bits = 0;
339 result = asn1_read_value (crl->crl, "signature", NULL, &bits); 339 result = MHD__asn1_read_value (crl->crl, "signature", NULL, &bits);
340 if (result != ASN1_MEM_ERROR) 340 if (result != ASN1_MEM_ERROR)
341 { 341 {
342 gnutls_assert (); 342 MHD_gnutls_assert ();
343 return mhd_gtls_asn2err (result); 343 return MHD_gtls_asn2err (result);
344 } 344 }
345 345
346 if (bits % 8 != 0) 346 if (bits % 8 != 0)
347 { 347 {
348 gnutls_assert (); 348 MHD_gnutls_assert ();
349 return GNUTLS_E_CERTIFICATE_ERROR; 349 return GNUTLS_E_CERTIFICATE_ERROR;
350 } 350 }
351 351
@@ -357,19 +357,19 @@ gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl,
357 return GNUTLS_E_SHORT_MEMORY_BUFFER; 357 return GNUTLS_E_SHORT_MEMORY_BUFFER;
358 } 358 }
359 359
360 result = asn1_read_value (crl->crl, "signature", sig, &len); 360 result = MHD__asn1_read_value (crl->crl, "signature", sig, &len);
361 if (result != ASN1_SUCCESS) 361 if (result != ASN1_SUCCESS)
362 { 362 {
363 gnutls_assert (); 363 MHD_gnutls_assert ();
364 return mhd_gtls_asn2err (result); 364 return MHD_gtls_asn2err (result);
365 } 365 }
366 366
367 return 0; 367 return 0;
368} 368}
369 369
370/** 370/**
371 * gnutls_x509_crl_get_version - This function returns the CRL's version number 371 * MHD_gnutls_x509_crl_get_version - This function returns the CRL's version number
372 * @crl: should contain a gnutls_x509_crl_t structure 372 * @crl: should contain a MHD_gnutls_x509_crl_t structure
373 * 373 *
374 * This function will return the version of the specified CRL. 374 * This function will return the version of the specified CRL.
375 * 375 *
@@ -377,32 +377,32 @@ gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl,
377 * 377 *
378 **/ 378 **/
379int 379int
380gnutls_x509_crl_get_version (gnutls_x509_crl_t crl) 380MHD_gnutls_x509_crl_get_version (MHD_gnutls_x509_crl_t crl)
381{ 381{
382 opaque version[5]; 382 opaque version[5];
383 int len, result; 383 int len, result;
384 384
385 if (crl == NULL) 385 if (crl == NULL)
386 { 386 {
387 gnutls_assert (); 387 MHD_gnutls_assert ();
388 return GNUTLS_E_INVALID_REQUEST; 388 return GNUTLS_E_INVALID_REQUEST;
389 } 389 }
390 390
391 len = sizeof (version); 391 len = sizeof (version);
392 if ((result = 392 if ((result =
393 asn1_read_value (crl->crl, "tbsCertList.version", version, 393 MHD__asn1_read_value (crl->crl, "tbsCertList.version", version,
394 &len)) != ASN1_SUCCESS) 394 &len)) != ASN1_SUCCESS)
395 { 395 {
396 gnutls_assert (); 396 MHD_gnutls_assert ();
397 return mhd_gtls_asn2err (result); 397 return MHD_gtls_asn2err (result);
398 } 398 }
399 399
400 return (int) version[0] + 1; 400 return (int) version[0] + 1;
401} 401}
402 402
403/** 403/**
404 * gnutls_x509_crl_get_this_update - This function returns the CRL's thisUpdate time 404 * MHD_gnutls_x509_crl_get_this_update - This function returns the CRL's thisUpdate time
405 * @crl: should contain a gnutls_x509_crl_t structure 405 * @crl: should contain a MHD_gnutls_x509_crl_t structure
406 * 406 *
407 * This function will return the time this CRL was issued. 407 * This function will return the time this CRL was issued.
408 * 408 *
@@ -410,20 +410,20 @@ gnutls_x509_crl_get_version (gnutls_x509_crl_t crl)
410 * 410 *
411 **/ 411 **/
412time_t 412time_t
413gnutls_x509_crl_get_this_update (gnutls_x509_crl_t crl) 413MHD_gnutls_x509_crl_get_this_update (MHD_gnutls_x509_crl_t crl)
414{ 414{
415 if (crl == NULL) 415 if (crl == NULL)
416 { 416 {
417 gnutls_assert (); 417 MHD_gnutls_assert ();
418 return (time_t) - 1; 418 return (time_t) - 1;
419 } 419 }
420 420
421 return _gnutls_x509_get_time (crl->crl, "tbsCertList.thisUpdate"); 421 return MHD__gnutls_x509_get_time (crl->crl, "tbsCertList.thisUpdate");
422} 422}
423 423
424/** 424/**
425 * gnutls_x509_crl_get_next_update - This function returns the CRL's nextUpdate time 425 * MHD_gnutls_x509_crl_get_next_update - This function returns the CRL's nextUpdate time
426 * @crl: should contain a gnutls_x509_crl_t structure 426 * @crl: should contain a MHD_gnutls_x509_crl_t structure
427 * 427 *
428 * This function will return the time the next CRL will be issued. 428 * This function will return the time the next CRL will be issued.
429 * This field is optional in a CRL so it might be normal to get 429 * This field is optional in a CRL so it might be normal to get
@@ -433,20 +433,20 @@ gnutls_x509_crl_get_this_update (gnutls_x509_crl_t crl)
433 * 433 *
434 **/ 434 **/
435time_t 435time_t
436gnutls_x509_crl_get_next_update (gnutls_x509_crl_t crl) 436MHD_gnutls_x509_crl_get_next_update (MHD_gnutls_x509_crl_t crl)
437{ 437{
438 if (crl == NULL) 438 if (crl == NULL)
439 { 439 {
440 gnutls_assert (); 440 MHD_gnutls_assert ();
441 return (time_t) - 1; 441 return (time_t) - 1;
442 } 442 }
443 443
444 return _gnutls_x509_get_time (crl->crl, "tbsCertList.nextUpdate"); 444 return MHD__gnutls_x509_get_time (crl->crl, "tbsCertList.nextUpdate");
445} 445}
446 446
447/** 447/**
448 * gnutls_x509_crl_get_crt_count - This function returns the number of revoked certificates in a CRL 448 * MHD_gnutls_x509_crl_get_crt_count - This function returns the number of revoked certificates in a CRL
449 * @crl: should contain a gnutls_x509_crl_t structure 449 * @crl: should contain a MHD_gnutls_x509_crl_t structure
450 * 450 *
451 * This function will return the number of revoked certificates in the 451 * This function will return the number of revoked certificates in the
452 * given CRL. 452 * given CRL.
@@ -455,24 +455,24 @@ gnutls_x509_crl_get_next_update (gnutls_x509_crl_t crl)
455 * 455 *
456 **/ 456 **/
457int 457int
458gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t crl) 458MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl)
459{ 459{
460 460
461 int count, result; 461 int count, result;
462 462
463 if (crl == NULL) 463 if (crl == NULL)
464 { 464 {
465 gnutls_assert (); 465 MHD_gnutls_assert ();
466 return GNUTLS_E_INVALID_REQUEST; 466 return GNUTLS_E_INVALID_REQUEST;
467 } 467 }
468 468
469 result = 469 result =
470 asn1_number_of_elements (crl->crl, 470 MHD__asn1_number_of_elements (crl->crl,
471 "tbsCertList.revokedCertificates", &count); 471 "tbsCertList.revokedCertificates", &count);
472 472
473 if (result != ASN1_SUCCESS) 473 if (result != ASN1_SUCCESS)
474 { 474 {
475 gnutls_assert (); 475 MHD_gnutls_assert ();
476 return 0; /* no certificates */ 476 return 0; /* no certificates */
477 } 477 }
478 478
@@ -480,8 +480,8 @@ gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t crl)
480} 480}
481 481
482/** 482/**
483 * gnutls_x509_crl_get_crt_serial - This function returns the serial number of a revoked certificate 483 * MHD_gnutls_x509_crl_get_crt_serial - This function returns the serial number of a revoked certificate
484 * @crl: should contain a gnutls_x509_crl_t structure 484 * @crl: should contain a MHD_gnutls_x509_crl_t structure
485 * @indx: the index of the certificate to extract (starting from 0) 485 * @indx: the index of the certificate to extract (starting from 0)
486 * @serial: where the serial number will be copied 486 * @serial: where the serial number will be copied
487 * @serial_size: initially holds the size of serial 487 * @serial_size: initially holds the size of serial
@@ -494,7 +494,7 @@ gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t crl)
494 * 494 *
495 **/ 495 **/
496int 496int
497gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, int indx, 497MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, int indx,
498 unsigned char *serial, 498 unsigned char *serial,
499 size_t * serial_size, time_t * t) 499 size_t * serial_size, time_t * t)
500{ 500{
@@ -505,7 +505,7 @@ gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, int indx,
505 505
506 if (crl == NULL) 506 if (crl == NULL)
507 { 507 {
508 gnutls_assert (); 508 MHD_gnutls_assert ();
509 return GNUTLS_E_INVALID_REQUEST; 509 return GNUTLS_E_INVALID_REQUEST;
510 } 510 }
511 511
@@ -515,28 +515,28 @@ gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, int indx,
515 "tbsCertList.revokedCertificates.?%u.revocationDate", indx + 1); 515 "tbsCertList.revokedCertificates.?%u.revocationDate", indx + 1);
516 516
517 _serial_size = *serial_size; 517 _serial_size = *serial_size;
518 result = asn1_read_value (crl->crl, serial_name, serial, &_serial_size); 518 result = MHD__asn1_read_value (crl->crl, serial_name, serial, &_serial_size);
519 519
520 *serial_size = _serial_size; 520 *serial_size = _serial_size;
521 if (result != ASN1_SUCCESS) 521 if (result != ASN1_SUCCESS)
522 { 522 {
523 gnutls_assert (); 523 MHD_gnutls_assert ();
524 if (result == ASN1_ELEMENT_NOT_FOUND) 524 if (result == ASN1_ELEMENT_NOT_FOUND)
525 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 525 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
526 return mhd_gtls_asn2err (result); 526 return MHD_gtls_asn2err (result);
527 } 527 }
528 528
529 if (t) 529 if (t)
530 { 530 {
531 *t = _gnutls_x509_get_time (crl->crl, date_name); 531 *t = MHD__gnutls_x509_get_time (crl->crl, date_name);
532 } 532 }
533 533
534 return 0; 534 return 0;
535} 535}
536 536
537/*- 537/*-
538 * _gnutls_x509_crl_get_raw_issuer_dn - This function returns the issuer's DN DER encoded 538 * MHD__gnutls_x509_crl_get_raw_issuer_dn - This function returns the issuer's DN DER encoded
539 * @crl: should contain a gnutls_x509_crl_t structure 539 * @crl: should contain a MHD_gnutls_x509_crl_t structure
540 * @dn: will hold the starting point of the DN 540 * @dn: will hold the starting point of the DN
541 * 541 *
542 * This function will return a pointer to the DER encoded DN structure and 542 * This function will return a pointer to the DER encoded DN structure and
@@ -546,75 +546,75 @@ gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, int indx,
546 * 546 *
547 -*/ 547 -*/
548int 548int
549_gnutls_x509_crl_get_raw_issuer_dn (gnutls_x509_crl_t crl, 549MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl,
550 gnutls_datum_t * dn) 550 MHD_gnutls_datum_t * dn)
551{ 551{
552 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 552 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
553 int result, len1; 553 int result, len1;
554 int start1, end1; 554 int start1, end1;
555 gnutls_datum_t crl_signed_data; 555 MHD_gnutls_datum_t crl_signed_data;
556 556
557 if (crl == NULL) 557 if (crl == NULL)
558 { 558 {
559 gnutls_assert (); 559 MHD_gnutls_assert ();
560 return GNUTLS_E_INVALID_REQUEST; 560 return GNUTLS_E_INVALID_REQUEST;
561 } 561 }
562 562
563 /* get the issuer of 'crl' 563 /* get the issuer of 'crl'
564 */ 564 */
565 if ((result = 565 if ((result =
566 asn1_create_element (_gnutls_get_pkix (), "PKIX1.TBSCertList", 566 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.TBSCertList",
567 &c2)) != ASN1_SUCCESS) 567 &c2)) != ASN1_SUCCESS)
568 { 568 {
569 gnutls_assert (); 569 MHD_gnutls_assert ();
570 return mhd_gtls_asn2err (result); 570 return MHD_gtls_asn2err (result);
571 } 571 }
572 572
573 result = 573 result =
574 _gnutls_x509_get_signed_data (crl->crl, "tbsCertList", &crl_signed_data); 574 MHD__gnutls_x509_get_signed_data (crl->crl, "tbsCertList", &crl_signed_data);
575 if (result < 0) 575 if (result < 0)
576 { 576 {
577 gnutls_assert (); 577 MHD_gnutls_assert ();
578 goto cleanup; 578 goto cleanup;
579 } 579 }
580 580
581 result = 581 result =
582 asn1_der_decoding (&c2, crl_signed_data.data, crl_signed_data.size, NULL); 582 MHD__asn1_der_decoding (&c2, crl_signed_data.data, crl_signed_data.size, NULL);
583 if (result != ASN1_SUCCESS) 583 if (result != ASN1_SUCCESS)
584 { 584 {
585 /* couldn't decode DER */ 585 /* couldn't decode DER */
586 gnutls_assert (); 586 MHD_gnutls_assert ();
587 asn1_delete_structure (&c2); 587 MHD__asn1_delete_structure (&c2);
588 result = mhd_gtls_asn2err (result); 588 result = MHD_gtls_asn2err (result);
589 goto cleanup; 589 goto cleanup;
590 } 590 }
591 591
592 result = 592 result =
593 asn1_der_decoding_startEnd (c2, crl_signed_data.data, 593 MHD__asn1_der_decoding_startEnd (c2, crl_signed_data.data,
594 crl_signed_data.size, "issuer", 594 crl_signed_data.size, "issuer",
595 &start1, &end1); 595 &start1, &end1);
596 596
597 if (result != ASN1_SUCCESS) 597 if (result != ASN1_SUCCESS)
598 { 598 {
599 gnutls_assert (); 599 MHD_gnutls_assert ();
600 result = mhd_gtls_asn2err (result); 600 result = MHD_gtls_asn2err (result);
601 goto cleanup; 601 goto cleanup;
602 } 602 }
603 603
604 len1 = end1 - start1 + 1; 604 len1 = end1 - start1 + 1;
605 605
606 _gnutls_set_datum (dn, &crl_signed_data.data[start1], len1); 606 MHD__gnutls_set_datum (dn, &crl_signed_data.data[start1], len1);
607 607
608 result = 0; 608 result = 0;
609 609
610cleanup: 610cleanup:
611 asn1_delete_structure (&c2); 611 MHD__asn1_delete_structure (&c2);
612 _gnutls_free_datum (&crl_signed_data); 612 MHD__gnutls_free_datum (&crl_signed_data);
613 return result; 613 return result;
614} 614}
615 615
616/** 616/**
617 * gnutls_x509_crl_export - This function will export the CRL 617 * MHD_gnutls_x509_crl_export - This function will export the CRL
618 * @crl: Holds the revocation list 618 * @crl: Holds the revocation list
619 * @format: the format of output params. One of PEM or DER. 619 * @format: the format of output params. One of PEM or DER.
620 * @output_data: will contain a private key PEM or DER encoded 620 * @output_data: will contain a private key PEM or DER encoded
@@ -632,22 +632,22 @@ cleanup:
632 * 632 *
633 **/ 633 **/
634int 634int
635gnutls_x509_crl_export (gnutls_x509_crl_t crl, 635MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl,
636 gnutls_x509_crt_fmt_t format, void *output_data, 636 MHD_gnutls_x509_crt_fmt_t format, void *output_data,
637 size_t * output_data_size) 637 size_t * output_data_size)
638{ 638{
639 if (crl == NULL) 639 if (crl == NULL)
640 { 640 {
641 gnutls_assert (); 641 MHD_gnutls_assert ();
642 return GNUTLS_E_INVALID_REQUEST; 642 return GNUTLS_E_INVALID_REQUEST;
643 } 643 }
644 644
645 return _gnutls_x509_export_int (crl->crl, format, PEM_CRL, 645 return MHD__gnutls_x509_export_int (crl->crl, format, PEM_CRL,
646 output_data, output_data_size); 646 output_data, output_data_size);
647} 647}
648 648
649/*- 649/*-
650 * _gnutls_x509_crl_cpy - This function copies a gnutls_x509_crl_t structure 650 * MHD__gnutls_x509_crl_cpy - This function copies a MHD_gnutls_x509_crl_t structure
651 * @dest: The structure where to copy 651 * @dest: The structure where to copy
652 * @src: The structure to be copied 652 * @src: The structure to be copied
653 * 653 *
@@ -657,44 +657,44 @@ gnutls_x509_crl_export (gnutls_x509_crl_t crl,
657 * 657 *
658 -*/ 658 -*/
659int 659int
660_gnutls_x509_crl_cpy (gnutls_x509_crl_t dest, gnutls_x509_crl_t src) 660MHD__gnutls_x509_crl_cpy (MHD_gnutls_x509_crl_t dest, MHD_gnutls_x509_crl_t src)
661{ 661{
662 int ret; 662 int ret;
663 size_t der_size; 663 size_t der_size;
664 opaque *der; 664 opaque *der;
665 gnutls_datum_t tmp; 665 MHD_gnutls_datum_t tmp;
666 666
667 ret = gnutls_x509_crl_export (src, GNUTLS_X509_FMT_DER, NULL, &der_size); 667 ret = MHD_gnutls_x509_crl_export (src, GNUTLS_X509_FMT_DER, NULL, &der_size);
668 if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER) 668 if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
669 { 669 {
670 gnutls_assert (); 670 MHD_gnutls_assert ();
671 return ret; 671 return ret;
672 } 672 }
673 673
674 der = gnutls_alloca (der_size); 674 der = MHD_gnutls_alloca (der_size);
675 if (der == NULL) 675 if (der == NULL)
676 { 676 {
677 gnutls_assert (); 677 MHD_gnutls_assert ();
678 return GNUTLS_E_MEMORY_ERROR; 678 return GNUTLS_E_MEMORY_ERROR;
679 } 679 }
680 680
681 ret = gnutls_x509_crl_export (src, GNUTLS_X509_FMT_DER, der, &der_size); 681 ret = MHD_gnutls_x509_crl_export (src, GNUTLS_X509_FMT_DER, der, &der_size);
682 if (ret < 0) 682 if (ret < 0)
683 { 683 {
684 gnutls_assert (); 684 MHD_gnutls_assert ();
685 gnutls_afree (der); 685 MHD_gnutls_afree (der);
686 return ret; 686 return ret;
687 } 687 }
688 688
689 tmp.data = der; 689 tmp.data = der;
690 tmp.size = der_size; 690 tmp.size = der_size;
691 ret = gnutls_x509_crl_import (dest, &tmp, GNUTLS_X509_FMT_DER); 691 ret = MHD_gnutls_x509_crl_import (dest, &tmp, GNUTLS_X509_FMT_DER);
692 692
693 gnutls_afree (der); 693 MHD_gnutls_afree (der);
694 694
695 if (ret < 0) 695 if (ret < 0)
696 { 696 {
697 gnutls_assert (); 697 MHD_gnutls_assert ();
698 return ret; 698 return ret;
699 } 699 }
700 700
diff --git a/src/daemon/https/x509/crq.c b/src/daemon/https/x509/crq.c
index 1f240007..147be276 100644
--- a/src/daemon/https/x509/crq.c
+++ b/src/daemon/https/x509/crq.c
@@ -43,7 +43,7 @@
43#include <libtasn1.h> 43#include <libtasn1.h>
44 44
45/** 45/**
46 * gnutls_x509_crq_init - This function initializes a gnutls_x509_crq_t structure 46 * MHD_gnutls_x509_crq_init - This function initializes a MHD_gnutls_x509_crq_t structure
47 * @crq: The structure to be initialized 47 * @crq: The structure to be initialized
48 * 48 *
49 * This function will initialize a PKCS10 certificate request structure. 49 * This function will initialize a PKCS10 certificate request structure.
@@ -52,20 +52,20 @@
52 * 52 *
53 **/ 53 **/
54int 54int
55gnutls_x509_crq_init (gnutls_x509_crq_t * crq) 55MHD_gnutls_x509_crq_init (MHD_gnutls_x509_crq_t * crq)
56{ 56{
57 *crq = gnutls_calloc (1, sizeof (gnutls_x509_crq_int)); 57 *crq = MHD_gnutls_calloc (1, sizeof (MHD_gnutls_x509_crq_int));
58 58
59 if (*crq) 59 if (*crq)
60 { 60 {
61 int result = asn1_create_element (_gnutls_get_pkix (), 61 int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
62 "PKIX1.pkcs-10-CertificationRequest", 62 "PKIX1.pkcs-10-CertificationRequest",
63 &((*crq)->crq)); 63 &((*crq)->crq));
64 if (result != ASN1_SUCCESS) 64 if (result != ASN1_SUCCESS)
65 { 65 {
66 gnutls_assert (); 66 MHD_gnutls_assert ();
67 gnutls_free (*crq); 67 MHD_gnutls_free (*crq);
68 return mhd_gtls_asn2err (result); 68 return MHD_gtls_asn2err (result);
69 } 69 }
70 return 0; /* success */ 70 return 0; /* success */
71 } 71 }
@@ -73,35 +73,35 @@ gnutls_x509_crq_init (gnutls_x509_crq_t * crq)
73} 73}
74 74
75/** 75/**
76 * gnutls_x509_crq_deinit - This function deinitializes memory used by a gnutls_x509_crq_t structure 76 * MHD_gnutls_x509_crq_deinit - This function deinitializes memory used by a MHD_gnutls_x509_crq_t structure
77 * @crq: The structure to be initialized 77 * @crq: The structure to be initialized
78 * 78 *
79 * This function will deinitialize a CRL structure. 79 * This function will deinitialize a CRL structure.
80 * 80 *
81 **/ 81 **/
82void 82void
83gnutls_x509_crq_deinit (gnutls_x509_crq_t crq) 83MHD_gnutls_x509_crq_deinit (MHD_gnutls_x509_crq_t crq)
84{ 84{
85 if (!crq) 85 if (!crq)
86 return; 86 return;
87 87
88 if (crq->crq) 88 if (crq->crq)
89 asn1_delete_structure (&crq->crq); 89 MHD__asn1_delete_structure (&crq->crq);
90 90
91 gnutls_free (crq); 91 MHD_gnutls_free (crq);
92} 92}
93 93
94#define PEM_CRQ "NEW CERTIFICATE REQUEST" 94#define PEM_CRQ "NEW CERTIFICATE REQUEST"
95#define PEM_CRQ2 "CERTIFICATE REQUEST" 95#define PEM_CRQ2 "CERTIFICATE REQUEST"
96 96
97/** 97/**
98 * gnutls_x509_crq_import - This function will import a DER or PEM encoded Certificate request 98 * MHD_gnutls_x509_crq_import - This function will import a DER or PEM encoded Certificate request
99 * @crq: The structure to store the parsed certificate request. 99 * @crq: The structure to store the parsed certificate request.
100 * @data: The DER or PEM encoded certificate. 100 * @data: The DER or PEM encoded certificate.
101 * @format: One of DER or PEM 101 * @format: One of DER or PEM
102 * 102 *
103 * This function will convert the given DER or PEM encoded Certificate 103 * This function will convert the given DER or PEM encoded Certificate
104 * to the native gnutls_x509_crq_t format. The output will be stored in @cert. 104 * to the native MHD_gnutls_x509_crq_t format. The output will be stored in @cert.
105 * 105 *
106 * If the Certificate is PEM encoded it should have a header of "NEW CERTIFICATE REQUEST". 106 * If the Certificate is PEM encoded it should have a header of "NEW CERTIFICATE REQUEST".
107 * 107 *
@@ -109,16 +109,16 @@ gnutls_x509_crq_deinit (gnutls_x509_crq_t crq)
109 * 109 *
110 **/ 110 **/
111int 111int
112gnutls_x509_crq_import (gnutls_x509_crq_t crq, 112MHD_gnutls_x509_crq_import (MHD_gnutls_x509_crq_t crq,
113 const gnutls_datum_t * data, 113 const MHD_gnutls_datum_t * data,
114 gnutls_x509_crt_fmt_t format) 114 MHD_gnutls_x509_crt_fmt_t format)
115{ 115{
116 int result = 0, need_free = 0; 116 int result = 0, need_free = 0;
117 gnutls_datum_t _data; 117 MHD_gnutls_datum_t _data;
118 118
119 if (crq == NULL) 119 if (crq == NULL)
120 { 120 {
121 gnutls_assert (); 121 MHD_gnutls_assert ();
122 return GNUTLS_E_INVALID_REQUEST; 122 return GNUTLS_E_INVALID_REQUEST;
123 } 123 }
124 124
@@ -132,17 +132,17 @@ gnutls_x509_crq_import (gnutls_x509_crq_t crq,
132 opaque *out; 132 opaque *out;
133 133
134 /* Try the first header */ 134 /* Try the first header */
135 result = _gnutls_fbase64_decode (PEM_CRQ, data->data, data->size, &out); 135 result = MHD__gnutls_fbase64_decode (PEM_CRQ, data->data, data->size, &out);
136 136
137 if (result <= 0) /* Go for the second header */ 137 if (result <= 0) /* Go for the second header */
138 result = 138 result =
139 _gnutls_fbase64_decode (PEM_CRQ2, data->data, data->size, &out); 139 MHD__gnutls_fbase64_decode (PEM_CRQ2, data->data, data->size, &out);
140 140
141 if (result <= 0) 141 if (result <= 0)
142 { 142 {
143 if (result == 0) 143 if (result == 0)
144 result = GNUTLS_E_INTERNAL_ERROR; 144 result = GNUTLS_E_INTERNAL_ERROR;
145 gnutls_assert (); 145 MHD_gnutls_assert ();
146 return result; 146 return result;
147 } 147 }
148 148
@@ -152,11 +152,11 @@ gnutls_x509_crq_import (gnutls_x509_crq_t crq,
152 need_free = 1; 152 need_free = 1;
153 } 153 }
154 154
155 result = asn1_der_decoding (&crq->crq, _data.data, _data.size, NULL); 155 result = MHD__asn1_der_decoding (&crq->crq, _data.data, _data.size, NULL);
156 if (result != ASN1_SUCCESS) 156 if (result != ASN1_SUCCESS)
157 { 157 {
158 result = mhd_gtls_asn2err (result); 158 result = MHD_gtls_asn2err (result);
159 gnutls_assert (); 159 MHD_gnutls_assert ();
160 goto cleanup; 160 goto cleanup;
161 } 161 }
162 162
@@ -164,15 +164,15 @@ gnutls_x509_crq_import (gnutls_x509_crq_t crq,
164 164
165cleanup: 165cleanup:
166 if (need_free) 166 if (need_free)
167 _gnutls_free_datum (&_data); 167 MHD__gnutls_free_datum (&_data);
168 return result; 168 return result;
169} 169}
170 170
171 171
172 172
173/** 173/**
174 * gnutls_x509_crq_get_dn - This function returns the Certificate request subject's distinguished name 174 * MHD_gnutls_x509_crq_get_dn - This function returns the Certificate request subject's distinguished name
175 * @crq: should contain a gnutls_x509_crq_t structure 175 * @crq: should contain a MHD_gnutls_x509_crq_t structure
176 * @buf: a pointer to a structure to hold the name (may be null) 176 * @buf: a pointer to a structure to hold the name (may be null)
177 * @sizeof_buf: initially holds the size of @buf 177 * @sizeof_buf: initially holds the size of @buf
178 * 178 *
@@ -189,22 +189,22 @@ cleanup:
189 * 189 *
190 **/ 190 **/
191int 191int
192gnutls_x509_crq_get_dn (gnutls_x509_crq_t crq, char *buf, size_t * sizeof_buf) 192MHD_gnutls_x509_crq_get_dn (MHD_gnutls_x509_crq_t crq, char *buf, size_t * sizeof_buf)
193{ 193{
194 if (crq == NULL) 194 if (crq == NULL)
195 { 195 {
196 gnutls_assert (); 196 MHD_gnutls_assert ();
197 return GNUTLS_E_INVALID_REQUEST; 197 return GNUTLS_E_INVALID_REQUEST;
198 } 198 }
199 199
200 return _gnutls_x509_parse_dn (crq->crq, 200 return MHD__gnutls_x509_parse_dn (crq->crq,
201 "certificationRequestInfo.subject.rdnSequence", 201 "certificationRequestInfo.subject.rdnSequence",
202 buf, sizeof_buf); 202 buf, sizeof_buf);
203} 203}
204 204
205/** 205/**
206 * gnutls_x509_crq_get_dn_by_oid - This function returns the Certificate request subject's distinguished name 206 * MHD_gnutls_x509_crq_get_dn_by_oid - This function returns the Certificate request subject's distinguished name
207 * @crq: should contain a gnutls_x509_crq_t structure 207 * @crq: should contain a MHD_gnutls_x509_crq_t structure
208 * @oid: holds an Object Identified in null terminated string 208 * @oid: holds an Object Identified in null terminated string
209 * @indx: In case multiple same OIDs exist in the RDN, this specifies 209 * @indx: In case multiple same OIDs exist in the RDN, this specifies
210 * which to send. Use zero to get the first one. 210 * which to send. Use zero to get the first one.
@@ -221,7 +221,7 @@ gnutls_x509_crq_get_dn (gnutls_x509_crq_t crq, char *buf, size_t * sizeof_buf)
221 * If raw flag is zero, this function will only return known OIDs as 221 * If raw flag is zero, this function will only return known OIDs as
222 * text. Other OIDs will be DER encoded, as described in RFC2253 -- 222 * text. Other OIDs will be DER encoded, as described in RFC2253 --
223 * in hex format with a '\#' prefix. You can check about known OIDs 223 * in hex format with a '\#' prefix. You can check about known OIDs
224 * using gnutls_x509_dn_oid_known(). 224 * using MHD_gnutls_x509_dn_oid_known().
225 * 225 *
226 * If @buf is null then only the size will be filled. 226 * If @buf is null then only the size will be filled.
227 * 227 *
@@ -231,24 +231,24 @@ gnutls_x509_crq_get_dn (gnutls_x509_crq_t crq, char *buf, size_t * sizeof_buf)
231 * 231 *
232 **/ 232 **/
233int 233int
234gnutls_x509_crq_get_dn_by_oid (gnutls_x509_crq_t crq, const char *oid, 234MHD_gnutls_x509_crq_get_dn_by_oid (MHD_gnutls_x509_crq_t crq, const char *oid,
235 int indx, unsigned int raw_flag, 235 int indx, unsigned int raw_flag,
236 void *buf, size_t * sizeof_buf) 236 void *buf, size_t * sizeof_buf)
237{ 237{
238 if (crq == NULL) 238 if (crq == NULL)
239 { 239 {
240 gnutls_assert (); 240 MHD_gnutls_assert ();
241 return GNUTLS_E_INVALID_REQUEST; 241 return GNUTLS_E_INVALID_REQUEST;
242 } 242 }
243 243
244 return _gnutls_x509_parse_dn_oid (crq->crq, 244 return MHD__gnutls_x509_parse_dn_oid (crq->crq,
245 "certificationRequestInfo.subject.rdnSequence", 245 "certificationRequestInfo.subject.rdnSequence",
246 oid, indx, raw_flag, buf, sizeof_buf); 246 oid, indx, raw_flag, buf, sizeof_buf);
247} 247}
248 248
249/** 249/**
250 * gnutls_x509_crq_get_dn_oid - This function returns the Certificate request subject's distinguished name OIDs 250 * MHD_gnutls_x509_crq_get_dn_oid - This function returns the Certificate request subject's distinguished name OIDs
251 * @crq: should contain a gnutls_x509_crq_t structure 251 * @crq: should contain a MHD_gnutls_x509_crq_t structure
252 * @indx: Specifies which DN OID to send. Use zero to get the first one. 252 * @indx: Specifies which DN OID to send. Use zero to get the first one.
253 * @oid: a pointer to a structure to hold the name (may be null) 253 * @oid: a pointer to a structure to hold the name (may be null)
254 * @sizeof_oid: initially holds the size of @oid 254 * @sizeof_oid: initially holds the size of @oid
@@ -264,30 +264,30 @@ gnutls_x509_crq_get_dn_by_oid (gnutls_x509_crq_t crq, const char *oid,
264 * 264 *
265 **/ 265 **/
266int 266int
267gnutls_x509_crq_get_dn_oid (gnutls_x509_crq_t crq, 267MHD_gnutls_x509_crq_get_dn_oid (MHD_gnutls_x509_crq_t crq,
268 int indx, void *oid, size_t * sizeof_oid) 268 int indx, void *oid, size_t * sizeof_oid)
269{ 269{
270 if (crq == NULL) 270 if (crq == NULL)
271 { 271 {
272 gnutls_assert (); 272 MHD_gnutls_assert ();
273 return GNUTLS_E_INVALID_REQUEST; 273 return GNUTLS_E_INVALID_REQUEST;
274 } 274 }
275 275
276 return _gnutls_x509_get_dn_oid (crq->crq, 276 return MHD__gnutls_x509_get_dn_oid (crq->crq,
277 "certificationRequestInfo.subject.rdnSequence", 277 "certificationRequestInfo.subject.rdnSequence",
278 indx, oid, sizeof_oid); 278 indx, oid, sizeof_oid);
279} 279}
280 280
281/* Parses an Attribute list in the asn1_struct, and searches for the 281/* Parses an Attribute list in the MHD__asn1_struct, and searches for the
282 * given OID. The index indicates the attribute value to be returned. 282 * given OID. The index indicates the attribute value to be returned.
283 * 283 *
284 * If raw==0 only printable data are returned, or GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE. 284 * If raw==0 only printable data are returned, or GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE.
285 * 285 *
286 * asn1_attr_name must be a string in the form "certificationRequestInfo.attributes" 286 * MHD__asn1_attr_name must be a string in the form "certificationRequestInfo.attributes"
287 * 287 *
288 */ 288 */
289static int 289static int
290parse_attribute (ASN1_TYPE asn1_struct, 290parse_attribute (ASN1_TYPE MHD__asn1_struct,
291 const char *attr_name, const char *given_oid, int indx, 291 const char *attr_name, const char *given_oid, int indx,
292 int raw, char *buf, size_t * sizeof_buf) 292 int raw, char *buf, size_t * sizeof_buf)
293{ 293{
@@ -300,7 +300,7 @@ parse_attribute (ASN1_TYPE asn1_struct,
300 300
301 if (*sizeof_buf == 0) 301 if (*sizeof_buf == 0)
302 { 302 {
303 gnutls_assert (); 303 MHD_gnutls_assert ();
304 return GNUTLS_E_INVALID_REQUEST; 304 return GNUTLS_E_INVALID_REQUEST;
305 } 305 }
306 306
@@ -319,18 +319,18 @@ parse_attribute (ASN1_TYPE asn1_struct,
319 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1); 319 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1);
320 320
321 len = sizeof (value) - 1; 321 len = sizeof (value) - 1;
322 result = asn1_read_value (asn1_struct, tmpbuffer1, value, &len); 322 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len);
323 323
324 if (result == ASN1_ELEMENT_NOT_FOUND) 324 if (result == ASN1_ELEMENT_NOT_FOUND)
325 { 325 {
326 gnutls_assert (); 326 MHD_gnutls_assert ();
327 break; 327 break;
328 } 328 }
329 329
330 if (result != ASN1_VALUE_NOT_FOUND) 330 if (result != ASN1_VALUE_NOT_FOUND)
331 { 331 {
332 gnutls_assert (); 332 MHD_gnutls_assert ();
333 result = mhd_gtls_asn2err (result); 333 result = MHD_gtls_asn2err (result);
334 goto cleanup; 334 goto cleanup;
335 } 335 }
336 336
@@ -338,18 +338,18 @@ parse_attribute (ASN1_TYPE asn1_struct,
338 */ 338 */
339 /* Read the OID 339 /* Read the OID
340 */ 340 */
341 mhd_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer1); 341 MHD_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer1);
342 mhd_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type"); 342 MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type");
343 343
344 len = sizeof (oid) - 1; 344 len = sizeof (oid) - 1;
345 result = asn1_read_value (asn1_struct, tmpbuffer3, oid, &len); 345 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len);
346 346
347 if (result == ASN1_ELEMENT_NOT_FOUND) 347 if (result == ASN1_ELEMENT_NOT_FOUND)
348 break; 348 break;
349 else if (result != ASN1_SUCCESS) 349 else if (result != ASN1_SUCCESS)
350 { 350 {
351 gnutls_assert (); 351 MHD_gnutls_assert ();
352 result = mhd_gtls_asn2err (result); 352 result = MHD_gtls_asn2err (result);
353 goto cleanup; 353 goto cleanup;
354 } 354 }
355 355
@@ -362,32 +362,32 @@ parse_attribute (ASN1_TYPE asn1_struct,
362 tmpbuffer1, indx + 1); 362 tmpbuffer1, indx + 1);
363 363
364 len = sizeof (value) - 1; 364 len = sizeof (value) - 1;
365 result = asn1_read_value (asn1_struct, tmpbuffer3, value, &len); 365 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, value, &len);
366 366
367 if (result != ASN1_SUCCESS) 367 if (result != ASN1_SUCCESS)
368 { 368 {
369 gnutls_assert (); 369 MHD_gnutls_assert ();
370 result = mhd_gtls_asn2err (result); 370 result = MHD_gtls_asn2err (result);
371 goto cleanup; 371 goto cleanup;
372 } 372 }
373 373
374 if (raw == 0) 374 if (raw == 0)
375 { 375 {
376 printable = _gnutls_x509_oid_data_printable (oid); 376 printable = MHD__gnutls_x509_oid_data_printable (oid);
377 if (printable == 1) 377 if (printable == 1)
378 { 378 {
379 if ((result = 379 if ((result =
380 _gnutls_x509_oid_data2string 380 MHD__gnutls_x509_oid_data2string
381 (oid, value, len, buf, sizeof_buf)) < 0) 381 (oid, value, len, buf, sizeof_buf)) < 0)
382 { 382 {
383 gnutls_assert (); 383 MHD_gnutls_assert ();
384 goto cleanup; 384 goto cleanup;
385 } 385 }
386 return 0; 386 return 0;
387 } 387 }
388 else 388 else
389 { 389 {
390 gnutls_assert (); 390 MHD_gnutls_assert ();
391 return GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE; 391 return GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE;
392 } 392 }
393 } 393 }
@@ -403,7 +403,7 @@ parse_attribute (ASN1_TYPE asn1_struct,
403 else 403 else
404 { 404 {
405 *sizeof_buf = len; 405 *sizeof_buf = len;
406 gnutls_assert (); 406 MHD_gnutls_assert ();
407 return GNUTLS_E_SHORT_MEMORY_BUFFER; 407 return GNUTLS_E_SHORT_MEMORY_BUFFER;
408 } 408 }
409 } 409 }
@@ -412,7 +412,7 @@ parse_attribute (ASN1_TYPE asn1_struct,
412 } 412 }
413 while (1); 413 while (1);
414 414
415 gnutls_assert (); 415 MHD_gnutls_assert ();
416 416
417 result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 417 result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
418 418
@@ -421,8 +421,8 @@ cleanup:
421} 421}
422 422
423/** 423/**
424 * gnutls_x509_crq_get_challenge_password - This function will get the challenge password 424 * MHD_gnutls_x509_crq_get_challenge_password - This function will get the challenge password
425 * @crq: should contain a gnutls_x509_crq_t structure 425 * @crq: should contain a MHD_gnutls_x509_crq_t structure
426 * @pass: will hold a null terminated password 426 * @pass: will hold a null terminated password
427 * @sizeof_pass: Initially holds the size of @pass. 427 * @sizeof_pass: Initially holds the size of @pass.
428 * 428 *
@@ -433,12 +433,12 @@ cleanup:
433 * 433 *
434 **/ 434 **/
435int 435int
436gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq, 436MHD_gnutls_x509_crq_get_challenge_password (MHD_gnutls_x509_crq_t crq,
437 char *pass, size_t * sizeof_pass) 437 char *pass, size_t * sizeof_pass)
438{ 438{
439 if (crq == NULL) 439 if (crq == NULL)
440 { 440 {
441 gnutls_assert (); 441 MHD_gnutls_assert ();
442 return GNUTLS_E_INVALID_REQUEST; 442 return GNUTLS_E_INVALID_REQUEST;
443 } 443 }
444 444
@@ -447,8 +447,8 @@ gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq,
447} 447}
448 448
449/** 449/**
450 * gnutls_x509_crq_set_attribute_by_oid - This function will set an attribute in the request 450 * MHD_gnutls_x509_crq_set_attribute_by_oid - This function will set an attribute in the request
451 * @crq: should contain a gnutls_x509_crq_t structure 451 * @crq: should contain a MHD_gnutls_x509_crq_t structure
452 * @oid: holds an Object Identified in null terminated string 452 * @oid: holds an Object Identified in null terminated string
453 * @buf: a pointer to a structure that holds the attribute data 453 * @buf: a pointer to a structure that holds the attribute data
454 * @sizeof_buf: holds the size of @buf 454 * @sizeof_buf: holds the size of @buf
@@ -460,7 +460,7 @@ gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq,
460 * 460 *
461 **/ 461 **/
462int 462int
463gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq, 463MHD_gnutls_x509_crq_set_attribute_by_oid (MHD_gnutls_x509_crq_t crq,
464 const char *oid, void *buf, 464 const char *oid, void *buf,
465 size_t sizeof_buf) 465 size_t sizeof_buf)
466{ 466{
@@ -468,30 +468,30 @@ gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq,
468 468
469 if (crq == NULL) 469 if (crq == NULL)
470 { 470 {
471 gnutls_assert (); 471 MHD_gnutls_assert ();
472 return GNUTLS_E_INVALID_REQUEST; 472 return GNUTLS_E_INVALID_REQUEST;
473 } 473 }
474 474
475 /* Add the attribute. 475 /* Add the attribute.
476 */ 476 */
477 result = 477 result =
478 asn1_write_value (crq->crq, "certificationRequestInfo.attributes", 478 MHD__asn1_write_value (crq->crq, "certificationRequestInfo.attributes",
479 "NEW", 1); 479 "NEW", 1);
480 if (result != ASN1_SUCCESS) 480 if (result != ASN1_SUCCESS)
481 { 481 {
482 gnutls_assert (); 482 MHD_gnutls_assert ();
483 return mhd_gtls_asn2err (result); 483 return MHD_gtls_asn2err (result);
484 } 484 }
485 485
486 result = 486 result =
487 _gnutls_x509_encode_and_write_attribute (oid, 487 MHD__gnutls_x509_encode_and_write_attribute (oid,
488 crq->crq, 488 crq->crq,
489 "certificationRequestInfo.attributes.?LAST", 489 "certificationRequestInfo.attributes.?LAST",
490 buf, sizeof_buf, 1); 490 buf, sizeof_buf, 1);
491 491
492 if (result < 0) 492 if (result < 0)
493 { 493 {
494 gnutls_assert (); 494 MHD_gnutls_assert ();
495 return result; 495 return result;
496 } 496 }
497 497
@@ -499,8 +499,8 @@ gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq,
499} 499}
500 500
501/** 501/**
502 * gnutls_x509_crq_get_attribute_by_oid - This function will get an attribute of the request 502 * MHD_gnutls_x509_crq_get_attribute_by_oid - This function will get an attribute of the request
503 * @crq: should contain a gnutls_x509_crq_t structure 503 * @crq: should contain a MHD_gnutls_x509_crq_t structure
504 * @oid: holds an Object Identified in null terminated string 504 * @oid: holds an Object Identified in null terminated string
505 * @indx: In case multiple same OIDs exist in the attribute list, this specifies 505 * @indx: In case multiple same OIDs exist in the attribute list, this specifies
506 * which to send. Use zero to get the first one. 506 * which to send. Use zero to get the first one.
@@ -514,13 +514,13 @@ gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq,
514 * 514 *
515 **/ 515 **/
516int 516int
517gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t crq, 517MHD_gnutls_x509_crq_get_attribute_by_oid (MHD_gnutls_x509_crq_t crq,
518 const char *oid, int indx, void *buf, 518 const char *oid, int indx, void *buf,
519 size_t * sizeof_buf) 519 size_t * sizeof_buf)
520{ 520{
521 if (crq == NULL) 521 if (crq == NULL)
522 { 522 {
523 gnutls_assert (); 523 MHD_gnutls_assert ();
524 return GNUTLS_E_INVALID_REQUEST; 524 return GNUTLS_E_INVALID_REQUEST;
525 } 525 }
526 526
@@ -529,8 +529,8 @@ gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t crq,
529} 529}
530 530
531/** 531/**
532 * gnutls_x509_crq_set_dn_by_oid - This function will set the Certificate request subject's distinguished name 532 * MHD_gnutls_x509_crq_set_dn_by_oid - This function will set the Certificate request subject's distinguished name
533 * @crq: should contain a gnutls_x509_crq_t structure 533 * @crq: should contain a MHD_gnutls_x509_crq_t structure
534 * @oid: holds an Object Identifier in a null terminated string 534 * @oid: holds an Object Identifier in a null terminated string
535 * @raw_flag: must be 0, or 1 if the data are DER encoded 535 * @raw_flag: must be 0, or 1 if the data are DER encoded
536 * @data: a pointer to the input data 536 * @data: a pointer to the input data
@@ -541,7 +541,7 @@ gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t crq,
541 * 541 *
542 * Some helper macros with popular OIDs can be found in gnutls/x509.h 542 * Some helper macros with popular OIDs can be found in gnutls/x509.h
543 * With this function you can only set the known OIDs. You can test 543 * With this function you can only set the known OIDs. You can test
544 * for known OIDs using gnutls_x509_dn_oid_known(). For OIDs that are 544 * for known OIDs using MHD_gnutls_x509_dn_oid_known(). For OIDs that are
545 * not known (by gnutls) you should properly DER encode your data, and 545 * not known (by gnutls) you should properly DER encode your data, and
546 * call this function with raw_flag set. 546 * call this function with raw_flag set.
547 * 547 *
@@ -549,7 +549,7 @@ gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t crq,
549 * 549 *
550 **/ 550 **/
551int 551int
552gnutls_x509_crq_set_dn_by_oid (gnutls_x509_crq_t crq, const char *oid, 552MHD_gnutls_x509_crq_set_dn_by_oid (MHD_gnutls_x509_crq_t crq, const char *oid,
553 unsigned int raw_flag, const void *data, 553 unsigned int raw_flag, const void *data,
554 unsigned int sizeof_data) 554 unsigned int sizeof_data)
555{ 555{
@@ -558,14 +558,14 @@ gnutls_x509_crq_set_dn_by_oid (gnutls_x509_crq_t crq, const char *oid,
558 return GNUTLS_E_INVALID_REQUEST; 558 return GNUTLS_E_INVALID_REQUEST;
559 } 559 }
560 560
561 return _gnutls_x509_set_dn_oid (crq->crq, 561 return MHD__gnutls_x509_set_dn_oid (crq->crq,
562 "certificationRequestInfo.subject", oid, 562 "certificationRequestInfo.subject", oid,
563 raw_flag, data, sizeof_data); 563 raw_flag, data, sizeof_data);
564} 564}
565 565
566/** 566/**
567 * gnutls_x509_crq_set_version - This function will set the Certificate request version 567 * MHD_gnutls_x509_crq_set_version - This function will set the Certificate request version
568 * @crq: should contain a gnutls_x509_crq_t structure 568 * @crq: should contain a MHD_gnutls_x509_crq_t structure
569 * @version: holds the version number. For v1 Requests must be 1. 569 * @version: holds the version number. For v1 Requests must be 1.
570 * 570 *
571 * This function will set the version of the certificate request. For 571 * This function will set the version of the certificate request. For
@@ -575,14 +575,14 @@ gnutls_x509_crq_set_dn_by_oid (gnutls_x509_crq_t crq, const char *oid,
575 * 575 *
576 **/ 576 **/
577int 577int
578gnutls_x509_crq_set_version (gnutls_x509_crq_t crq, unsigned int version) 578MHD_gnutls_x509_crq_set_version (MHD_gnutls_x509_crq_t crq, unsigned int version)
579{ 579{
580 int result; 580 int result;
581 unsigned char null = version; 581 unsigned char null = version;
582 582
583 if (crq == NULL) 583 if (crq == NULL)
584 { 584 {
585 gnutls_assert (); 585 MHD_gnutls_assert ();
586 return GNUTLS_E_INVALID_REQUEST; 586 return GNUTLS_E_INVALID_REQUEST;
587 } 587 }
588 588
@@ -590,19 +590,19 @@ gnutls_x509_crq_set_version (gnutls_x509_crq_t crq, unsigned int version)
590 null--; 590 null--;
591 591
592 result = 592 result =
593 asn1_write_value (crq->crq, "certificationRequestInfo.version", &null, 1); 593 MHD__asn1_write_value (crq->crq, "certificationRequestInfo.version", &null, 1);
594 if (result != ASN1_SUCCESS) 594 if (result != ASN1_SUCCESS)
595 { 595 {
596 gnutls_assert (); 596 MHD_gnutls_assert ();
597 return mhd_gtls_asn2err (result); 597 return MHD_gtls_asn2err (result);
598 } 598 }
599 599
600 return 0; 600 return 0;
601} 601}
602 602
603/** 603/**
604 * gnutls_x509_crq_get_version - This function returns the Certificate request's version number 604 * MHD_gnutls_x509_crq_get_version - This function returns the Certificate request's version number
605 * @crq: should contain a gnutls_x509_crq_t structure 605 * @crq: should contain a MHD_gnutls_x509_crq_t structure
606 * 606 *
607 * This function will return the version of the specified Certificate request. 607 * This function will return the version of the specified Certificate request.
608 * 608 *
@@ -610,35 +610,35 @@ gnutls_x509_crq_set_version (gnutls_x509_crq_t crq, unsigned int version)
610 * 610 *
611 **/ 611 **/
612int 612int
613gnutls_x509_crq_get_version (gnutls_x509_crq_t crq) 613MHD_gnutls_x509_crq_get_version (MHD_gnutls_x509_crq_t crq)
614{ 614{
615 opaque version[5]; 615 opaque version[5];
616 int len, result; 616 int len, result;
617 617
618 if (crq == NULL) 618 if (crq == NULL)
619 { 619 {
620 gnutls_assert (); 620 MHD_gnutls_assert ();
621 return GNUTLS_E_INVALID_REQUEST; 621 return GNUTLS_E_INVALID_REQUEST;
622 } 622 }
623 623
624 len = sizeof (version); 624 len = sizeof (version);
625 if ((result = 625 if ((result =
626 asn1_read_value (crq->crq, "certificationRequestInfo.version", 626 MHD__asn1_read_value (crq->crq, "certificationRequestInfo.version",
627 version, &len)) != ASN1_SUCCESS) 627 version, &len)) != ASN1_SUCCESS)
628 { 628 {
629 629
630 if (result == ASN1_ELEMENT_NOT_FOUND) 630 if (result == ASN1_ELEMENT_NOT_FOUND)
631 return 1; /* the DEFAULT version */ 631 return 1; /* the DEFAULT version */
632 gnutls_assert (); 632 MHD_gnutls_assert ();
633 return mhd_gtls_asn2err (result); 633 return MHD_gtls_asn2err (result);
634 } 634 }
635 635
636 return (int) version[0] + 1; 636 return (int) version[0] + 1;
637} 637}
638 638
639/** 639/**
640 * gnutls_x509_crq_set_key - This function will associate the Certificate request with a key 640 * MHD_gnutls_x509_crq_set_key - This function will associate the Certificate request with a key
641 * @crq: should contain a gnutls_x509_crq_t structure 641 * @crq: should contain a MHD_gnutls_x509_crq_t structure
642 * @key: holds a private key 642 * @key: holds a private key
643 * 643 *
644 * This function will set the public parameters from the given private key to the 644 * This function will set the public parameters from the given private key to the
@@ -648,17 +648,17 @@ gnutls_x509_crq_get_version (gnutls_x509_crq_t crq)
648 * 648 *
649 **/ 649 **/
650int 650int
651gnutls_x509_crq_set_key (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key) 651MHD_gnutls_x509_crq_set_key (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t key)
652{ 652{
653 int result; 653 int result;
654 654
655 if (crq == NULL) 655 if (crq == NULL)
656 { 656 {
657 gnutls_assert (); 657 MHD_gnutls_assert ();
658 return GNUTLS_E_INVALID_REQUEST; 658 return GNUTLS_E_INVALID_REQUEST;
659 } 659 }
660 660
661 result = _gnutls_x509_encode_and_copy_PKI_params (crq->crq, 661 result = MHD__gnutls_x509_encode_and_copy_PKI_params (crq->crq,
662 "certificationRequestInfo.subjectPKInfo", 662 "certificationRequestInfo.subjectPKInfo",
663 key->pk_algorithm, 663 key->pk_algorithm,
664 key->params, 664 key->params,
@@ -666,7 +666,7 @@ gnutls_x509_crq_set_key (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
666 666
667 if (result < 0) 667 if (result < 0)
668 { 668 {
669 gnutls_assert (); 669 MHD_gnutls_assert ();
670 return result; 670 return result;
671 } 671 }
672 672
@@ -674,8 +674,8 @@ gnutls_x509_crq_set_key (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
674} 674}
675 675
676/** 676/**
677 * gnutls_x509_crq_set_challenge_password - This function will set a challenge password 677 * MHD_gnutls_x509_crq_set_challenge_password - This function will set a challenge password
678 * @crq: should contain a gnutls_x509_crq_t structure 678 * @crq: should contain a MHD_gnutls_x509_crq_t structure
679 * @pass: holds a null terminated password 679 * @pass: holds a null terminated password
680 * 680 *
681 * This function will set a challenge password to be used when revoking the request. 681 * This function will set a challenge password to be used when revoking the request.
@@ -684,37 +684,37 @@ gnutls_x509_crq_set_key (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
684 * 684 *
685 **/ 685 **/
686int 686int
687gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t crq, 687MHD_gnutls_x509_crq_set_challenge_password (MHD_gnutls_x509_crq_t crq,
688 const char *pass) 688 const char *pass)
689{ 689{
690 int result; 690 int result;
691 691
692 if (crq == NULL) 692 if (crq == NULL)
693 { 693 {
694 gnutls_assert (); 694 MHD_gnutls_assert ();
695 return GNUTLS_E_INVALID_REQUEST; 695 return GNUTLS_E_INVALID_REQUEST;
696 } 696 }
697 697
698 /* Add the attribute. 698 /* Add the attribute.
699 */ 699 */
700 result = 700 result =
701 asn1_write_value (crq->crq, "certificationRequestInfo.attributes", 701 MHD__asn1_write_value (crq->crq, "certificationRequestInfo.attributes",
702 "NEW", 1); 702 "NEW", 1);
703 if (result != ASN1_SUCCESS) 703 if (result != ASN1_SUCCESS)
704 { 704 {
705 gnutls_assert (); 705 MHD_gnutls_assert ();
706 return mhd_gtls_asn2err (result); 706 return MHD_gtls_asn2err (result);
707 } 707 }
708 708
709 result = 709 result =
710 _gnutls_x509_encode_and_write_attribute ("1.2.840.113549.1.9.7", 710 MHD__gnutls_x509_encode_and_write_attribute ("1.2.840.113549.1.9.7",
711 crq->crq, 711 crq->crq,
712 "certificationRequestInfo.attributes.?LAST", 712 "certificationRequestInfo.attributes.?LAST",
713 pass, strlen (pass), 1); 713 pass, strlen (pass), 1);
714 714
715 if (result < 0) 715 if (result < 0)
716 { 716 {
717 gnutls_assert (); 717 MHD_gnutls_assert ();
718 return result; 718 return result;
719 } 719 }
720 720
@@ -722,14 +722,14 @@ gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t crq,
722} 722}
723 723
724/** 724/**
725 * gnutls_x509_crq_sign2 - This function will sign a Certificate request with a key 725 * MHD_gnutls_x509_crq_sign2 - This function will sign a Certificate request with a key
726 * @crq: should contain a gnutls_x509_crq_t structure 726 * @crq: should contain a MHD_gnutls_x509_crq_t structure
727 * @key: holds a private key 727 * @key: holds a private key
728 * @dig: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing. 728 * @dig: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing.
729 * @flags: must be 0 729 * @flags: must be 0
730 * 730 *
731 * This function will sign the certificate request with a private key. 731 * This function will sign the certificate request with a private key.
732 * This must be the same key as the one used in gnutls_x509_crt_set_key() since a 732 * This must be the same key as the one used in MHD_gnutls_x509_crt_set_key() since a
733 * certificate request is self signed. 733 * certificate request is self signed.
734 * 734 *
735 * This must be the last step in a certificate request generation since all 735 * This must be the last step in a certificate request generation since all
@@ -739,52 +739,52 @@ gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t crq,
739 * 739 *
740 **/ 740 **/
741int 741int
742gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key, 742MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t key,
743 enum MHD_GNUTLS_HashAlgorithm dig, unsigned int flags) 743 enum MHD_GNUTLS_HashAlgorithm dig, unsigned int flags)
744{ 744{
745 int result; 745 int result;
746 gnutls_datum_t signature; 746 MHD_gnutls_datum_t signature;
747 747
748 if (crq == NULL) 748 if (crq == NULL)
749 { 749 {
750 gnutls_assert (); 750 MHD_gnutls_assert ();
751 return GNUTLS_E_INVALID_REQUEST; 751 return GNUTLS_E_INVALID_REQUEST;
752 } 752 }
753 753
754 /* Step 1. Self sign the request. 754 /* Step 1. Self sign the request.
755 */ 755 */
756 result = 756 result =
757 _gnutls_x509_sign_tbs (crq->crq, "certificationRequestInfo", 757 MHD__gnutls_x509_sign_tbs (crq->crq, "certificationRequestInfo",
758 dig, key, &signature); 758 dig, key, &signature);
759 759
760 if (result < 0) 760 if (result < 0)
761 { 761 {
762 gnutls_assert (); 762 MHD_gnutls_assert ();
763 return result; 763 return result;
764 } 764 }
765 765
766 /* Step 2. write the signature (bits) 766 /* Step 2. write the signature (bits)
767 */ 767 */
768 result = 768 result =
769 asn1_write_value (crq->crq, "signature", signature.data, 769 MHD__asn1_write_value (crq->crq, "signature", signature.data,
770 signature.size * 8); 770 signature.size * 8);
771 771
772 _gnutls_free_datum (&signature); 772 MHD__gnutls_free_datum (&signature);
773 773
774 if (result != ASN1_SUCCESS) 774 if (result != ASN1_SUCCESS)
775 { 775 {
776 gnutls_assert (); 776 MHD_gnutls_assert ();
777 return mhd_gtls_asn2err (result); 777 return MHD_gtls_asn2err (result);
778 } 778 }
779 779
780 /* Step 3. Write the signatureAlgorithm field. 780 /* Step 3. Write the signatureAlgorithm field.
781 */ 781 */
782 result = _gnutls_x509_write_sig_params (crq->crq, "signatureAlgorithm", 782 result = MHD__gnutls_x509_write_sig_params (crq->crq, "signatureAlgorithm",
783 key->pk_algorithm, dig, key->params, 783 key->pk_algorithm, dig, key->params,
784 key->params_size); 784 key->params_size);
785 if (result < 0) 785 if (result < 0)
786 { 786 {
787 gnutls_assert (); 787 MHD_gnutls_assert ();
788 return result; 788 return result;
789 } 789 }
790 790
@@ -792,24 +792,24 @@ gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key,
792} 792}
793 793
794/** 794/**
795 * gnutls_x509_crq_sign - This function will sign a Certificate request with a key 795 * MHD_gnutls_x509_crq_sign - This function will sign a Certificate request with a key
796 * @crq: should contain a gnutls_x509_crq_t structure 796 * @crq: should contain a MHD_gnutls_x509_crq_t structure
797 * @key: holds a private key 797 * @key: holds a private key
798 * 798 *
799 * This function is the same a gnutls_x509_crq_sign2() with no flags, and 799 * This function is the same a MHD_gnutls_x509_crq_sign2() with no flags, and
800 * SHA1 as the hash algorithm. 800 * SHA1 as the hash algorithm.
801 * 801 *
802 * Returns 0 on success. 802 * Returns 0 on success.
803 * 803 *
804 **/ 804 **/
805int 805int
806gnutls_x509_crq_sign (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key) 806MHD_gnutls_x509_crq_sign (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t key)
807{ 807{
808 return gnutls_x509_crq_sign2 (crq, key, MHD_GNUTLS_MAC_SHA1, 0); 808 return MHD_gnutls_x509_crq_sign2 (crq, key, MHD_GNUTLS_MAC_SHA1, 0);
809} 809}
810 810
811/** 811/**
812 * gnutls_x509_crq_export - Export the generated certificate request 812 * MHD_gnutls_x509_crq_export - Export the generated certificate request
813 * @crq: Holds the request 813 * @crq: Holds the request
814 * @format: the format of output params. One of PEM or DER. 814 * @format: the format of output params. One of PEM or DER.
815 * @output_data: will contain a certificate request PEM or DER encoded 815 * @output_data: will contain a certificate request PEM or DER encoded
@@ -830,23 +830,23 @@ gnutls_x509_crq_sign (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
830 * 830 *
831 **/ 831 **/
832int 832int
833gnutls_x509_crq_export (gnutls_x509_crq_t crq, 833MHD_gnutls_x509_crq_export (MHD_gnutls_x509_crq_t crq,
834 gnutls_x509_crt_fmt_t format, void *output_data, 834 MHD_gnutls_x509_crt_fmt_t format, void *output_data,
835 size_t * output_data_size) 835 size_t * output_data_size)
836{ 836{
837 if (crq == NULL) 837 if (crq == NULL)
838 { 838 {
839 gnutls_assert (); 839 MHD_gnutls_assert ();
840 return GNUTLS_E_INVALID_REQUEST; 840 return GNUTLS_E_INVALID_REQUEST;
841 } 841 }
842 842
843 return _gnutls_x509_export_int (crq->crq, format, PEM_CRQ, 843 return MHD__gnutls_x509_export_int (crq->crq, format, PEM_CRQ,
844 output_data, output_data_size); 844 output_data, output_data_size);
845} 845}
846 846
847/** 847/**
848 * gnutls_x509_crq_get_pk_algorithm - This function returns the certificate request's PublicKey algorithm 848 * MHD_gnutls_x509_crq_get_pk_algorithm - This function returns the certificate request's PublicKey algorithm
849 * @crq: should contain a gnutls_x509_crq_t structure 849 * @crq: should contain a MHD_gnutls_x509_crq_t structure
850 * @bits: if bits is non null it will hold the size of the parameters' in bits 850 * @bits: if bits is non null it will hold the size of the parameters' in bits
851 * 851 *
852 * This function will return the public key algorithm of a PKCS \#10 852 * This function will return the public key algorithm of a PKCS \#10
@@ -862,23 +862,23 @@ gnutls_x509_crq_export (gnutls_x509_crq_t crq,
862 * 862 *
863 **/ 863 **/
864int 864int
865gnutls_x509_crq_get_pk_algorithm (gnutls_x509_crq_t crq, unsigned int *bits) 865MHD_gnutls_x509_crq_get_pk_algorithm (MHD_gnutls_x509_crq_t crq, unsigned int *bits)
866{ 866{
867 int result; 867 int result;
868 868
869 if (crq == NULL) 869 if (crq == NULL)
870 { 870 {
871 gnutls_assert (); 871 MHD_gnutls_assert ();
872 return GNUTLS_E_INVALID_REQUEST; 872 return GNUTLS_E_INVALID_REQUEST;
873 } 873 }
874 874
875 result = 875 result =
876 _gnutls_x509_get_pk_algorithm (crq->crq, 876 MHD__gnutls_x509_get_pk_algorithm (crq->crq,
877 "certificationRequestInfo.subjectPKInfo", 877 "certificationRequestInfo.subjectPKInfo",
878 bits); 878 bits);
879 if (result < 0) 879 if (result < 0)
880 { 880 {
881 gnutls_assert (); 881 MHD_gnutls_assert ();
882 } 882 }
883 883
884 return result; 884 return result;
diff --git a/src/daemon/https/x509/crq.h b/src/daemon/https/x509/crq.h
index 80e600b5..661701bd 100644
--- a/src/daemon/https/x509/crq.h
+++ b/src/daemon/https/x509/crq.h
@@ -24,7 +24,7 @@
24 24
25#include <x509.h> 25#include <x509.h>
26 26
27typedef struct gnutls_x509_crq_int 27typedef struct MHD_gnutls_x509_crq_int
28{ 28{
29 ASN1_TYPE crq; 29 ASN1_TYPE crq;
30} gnutls_x509_crq_int; 30} MHD_gnutls_x509_crq_int;
diff --git a/src/daemon/https/x509/dn.c b/src/daemon/https/x509/dn.c
index 0c6a2f7a..8dcc458a 100644
--- a/src/daemon/https/x509/dn.c
+++ b/src/daemon/https/x509/dn.c
@@ -44,7 +44,7 @@ oid2ldap_string (const char *oid)
44{ 44{
45 const char *ret; 45 const char *ret;
46 46
47 ret = _gnutls_x509_oid2ldap_string (oid); 47 ret = MHD__gnutls_x509_oid2ldap_string (oid);
48 if (ret) 48 if (ret)
49 return ret; 49 return ret;
50 50
@@ -80,18 +80,18 @@ str_escape (char *str, char *buffer, unsigned int buffer_size)
80 return buffer; 80 return buffer;
81} 81}
82 82
83/* Parses an X509 DN in the asn1_struct, and puts the output into 83/* Parses an X509 DN in the MHD__asn1_struct, and puts the output into
84 * the string buf. The output is an LDAP encoded DN. 84 * the string buf. The output is an LDAP encoded DN.
85 * 85 *
86 * asn1_rdn_name must be a string in the form "tbsCertificate.issuer.rdnSequence". 86 * MHD__asn1_rdn_name must be a string in the form "tbsCertificate.issuer.rdnSequence".
87 * That is to point in the rndSequence. 87 * That is to point in the rndSequence.
88 */ 88 */
89int 89int
90_gnutls_x509_parse_dn (ASN1_TYPE asn1_struct, 90MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct,
91 const char *asn1_rdn_name, char *buf, 91 const char *MHD__asn1_rdn_name, char *buf,
92 size_t * sizeof_buf) 92 size_t * sizeof_buf)
93{ 93{
94 mhd_gtls_string out_str; 94 MHD_gtls_string out_str;
95 int k2, k1, result; 95 int k2, k1, result;
96 char tmpbuffer1[MAX_NAME_SIZE]; 96 char tmpbuffer1[MAX_NAME_SIZE];
97 char tmpbuffer2[MAX_NAME_SIZE]; 97 char tmpbuffer2[MAX_NAME_SIZE];
@@ -106,7 +106,7 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
106 106
107 if (sizeof_buf == NULL) 107 if (sizeof_buf == NULL)
108 { 108 {
109 gnutls_assert (); 109 MHD_gnutls_assert ();
110 return GNUTLS_E_INVALID_REQUEST; 110 return GNUTLS_E_INVALID_REQUEST;
111 } 111 }
112 112
@@ -115,7 +115,7 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
115 else 115 else
116 *sizeof_buf = 0; 116 *sizeof_buf = 0;
117 117
118 mhd_gtls_string_init (&out_str, gnutls_malloc, gnutls_realloc, gnutls_free); 118 MHD_gtls_string_init (&out_str, MHD_gnutls_malloc, MHD_gnutls_realloc, MHD_gnutls_free);
119 119
120 k1 = 0; 120 k1 = 0;
121 do 121 do
@@ -124,14 +124,14 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
124 k1++; 124 k1++;
125 /* create a string like "tbsCertList.issuer.rdnSequence.?1" 125 /* create a string like "tbsCertList.issuer.rdnSequence.?1"
126 */ 126 */
127 if (asn1_rdn_name[0] != 0) 127 if (MHD__asn1_rdn_name[0] != 0)
128 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", asn1_rdn_name, 128 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", MHD__asn1_rdn_name,
129 k1); 129 k1);
130 else 130 else
131 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1); 131 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1);
132 132
133 len = sizeof (value) - 1; 133 len = sizeof (value) - 1;
134 result = asn1_read_value (asn1_struct, tmpbuffer1, value, &len); 134 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len);
135 135
136 if (result == ASN1_ELEMENT_NOT_FOUND) 136 if (result == ASN1_ELEMENT_NOT_FOUND)
137 { 137 {
@@ -140,8 +140,8 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
140 140
141 if (result != ASN1_VALUE_NOT_FOUND) 141 if (result != ASN1_VALUE_NOT_FOUND)
142 { 142 {
143 gnutls_assert (); 143 MHD_gnutls_assert ();
144 result = mhd_gtls_asn2err (result); 144 result = MHD_gtls_asn2err (result);
145 goto cleanup; 145 goto cleanup;
146 } 146 }
147 147
@@ -162,60 +162,60 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
162 */ 162 */
163 163
164 len = sizeof (value) - 1; 164 len = sizeof (value) - 1;
165 result = asn1_read_value (asn1_struct, tmpbuffer2, value, &len); 165 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len);
166 166
167 if (result == ASN1_ELEMENT_NOT_FOUND) 167 if (result == ASN1_ELEMENT_NOT_FOUND)
168 break; 168 break;
169 if (result != ASN1_VALUE_NOT_FOUND) 169 if (result != ASN1_VALUE_NOT_FOUND)
170 { 170 {
171 gnutls_assert (); 171 MHD_gnutls_assert ();
172 result = mhd_gtls_asn2err (result); 172 result = MHD_gtls_asn2err (result);
173 goto cleanup; 173 goto cleanup;
174 } 174 }
175 175
176 /* Read the OID 176 /* Read the OID
177 */ 177 */
178 mhd_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2); 178 MHD_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
179 mhd_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type"); 179 MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type");
180 180
181 len = sizeof (oid) - 1; 181 len = sizeof (oid) - 1;
182 result = asn1_read_value (asn1_struct, tmpbuffer3, oid, &len); 182 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len);
183 183
184 if (result == ASN1_ELEMENT_NOT_FOUND) 184 if (result == ASN1_ELEMENT_NOT_FOUND)
185 break; 185 break;
186 else if (result != ASN1_SUCCESS) 186 else if (result != ASN1_SUCCESS)
187 { 187 {
188 gnutls_assert (); 188 MHD_gnutls_assert ();
189 result = mhd_gtls_asn2err (result); 189 result = MHD_gtls_asn2err (result);
190 goto cleanup; 190 goto cleanup;
191 } 191 }
192 192
193 /* Read the Value 193 /* Read the Value
194 */ 194 */
195 mhd_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2); 195 MHD_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
196 mhd_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".value"); 196 MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".value");
197 197
198 len = 0; 198 len = 0;
199 result = asn1_read_value (asn1_struct, tmpbuffer3, NULL, &len); 199 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, NULL, &len);
200 200
201 value2 = gnutls_malloc (len); 201 value2 = MHD_gnutls_malloc (len);
202 if (value2 == NULL) 202 if (value2 == NULL)
203 { 203 {
204 gnutls_assert (); 204 MHD_gnutls_assert ();
205 result = GNUTLS_E_MEMORY_ERROR; 205 result = GNUTLS_E_MEMORY_ERROR;
206 goto cleanup; 206 goto cleanup;
207 } 207 }
208 208
209 result = asn1_read_value (asn1_struct, tmpbuffer3, value2, &len); 209 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, value2, &len);
210 210
211 if (result != ASN1_SUCCESS) 211 if (result != ASN1_SUCCESS)
212 { 212 {
213 gnutls_assert (); 213 MHD_gnutls_assert ();
214 result = mhd_gtls_asn2err (result); 214 result = MHD_gtls_asn2err (result);
215 goto cleanup; 215 goto cleanup;
216 } 216 }
217#define STR_APPEND(y) if ((result=mhd_gtls_string_append_str( &out_str, y)) < 0) { \ 217#define STR_APPEND(y) if ((result=MHD_gtls_string_append_str( &out_str, y)) < 0) { \
218 gnutls_assert(); \ 218 MHD_gnutls_assert(); \
219 goto cleanup; \ 219 goto cleanup; \
220} 220}
221 /* The encodings of adjoining RelativeDistinguishedNames are separated 221 /* The encodings of adjoining RelativeDistinguishedNames are separated
@@ -239,24 +239,24 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
239 } 239 }
240 240
241 ldap_desc = oid2ldap_string (oid); 241 ldap_desc = oid2ldap_string (oid);
242 printable = _gnutls_x509_oid_data_printable (oid); 242 printable = MHD__gnutls_x509_oid_data_printable (oid);
243 243
244 sizeof_escaped = 2 * len + 1; 244 sizeof_escaped = 2 * len + 1;
245 245
246 escaped = gnutls_malloc (sizeof_escaped); 246 escaped = MHD_gnutls_malloc (sizeof_escaped);
247 if (escaped == NULL) 247 if (escaped == NULL)
248 { 248 {
249 gnutls_assert (); 249 MHD_gnutls_assert ();
250 result = GNUTLS_E_MEMORY_ERROR; 250 result = GNUTLS_E_MEMORY_ERROR;
251 goto cleanup; 251 goto cleanup;
252 } 252 }
253 253
254 sizeof_string = 2 * len + 2; /* in case it is not printable */ 254 sizeof_string = 2 * len + 2; /* in case it is not printable */
255 255
256 string = gnutls_malloc (sizeof_string); 256 string = MHD_gnutls_malloc (sizeof_string);
257 if (string == NULL) 257 if (string == NULL)
258 { 258 {
259 gnutls_assert (); 259 MHD_gnutls_assert ();
260 result = GNUTLS_E_MEMORY_ERROR; 260 result = GNUTLS_E_MEMORY_ERROR;
261 goto cleanup; 261 goto cleanup;
262 } 262 }
@@ -267,30 +267,30 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
267 267
268 if (printable) 268 if (printable)
269 result = 269 result =
270 _gnutls_x509_oid_data2string (oid, 270 MHD__gnutls_x509_oid_data2string (oid,
271 value2, len, 271 value2, len,
272 string, &sizeof_string); 272 string, &sizeof_string);
273 273
274 if (!printable || result < 0) 274 if (!printable || result < 0)
275 result = 275 result =
276 _gnutls_x509_data2hex (value2, len, string, &sizeof_string); 276 MHD__gnutls_x509_data2hex (value2, len, string, &sizeof_string);
277 277
278 if (result < 0) 278 if (result < 0)
279 { 279 {
280 gnutls_assert (); 280 MHD_gnutls_assert ();
281 _gnutls_x509_log 281 MHD__gnutls_x509_log
282 ("Found OID: '%s' with value '%s'\n", 282 ("Found OID: '%s' with value '%s'\n",
283 oid, mhd_gtls_bin2hex (value2, len, escaped, 283 oid, MHD_gtls_bin2hex (value2, len, escaped,
284 sizeof_escaped)); 284 sizeof_escaped));
285 goto cleanup; 285 goto cleanup;
286 } 286 }
287 STR_APPEND (str_escape (string, escaped, sizeof_escaped)); 287 STR_APPEND (str_escape (string, escaped, sizeof_escaped));
288 gnutls_free (string); 288 MHD_gnutls_free (string);
289 string = NULL; 289 string = NULL;
290 290
291 gnutls_free (escaped); 291 MHD_gnutls_free (escaped);
292 escaped = NULL; 292 escaped = NULL;
293 gnutls_free (value2); 293 MHD_gnutls_free (value2);
294 value2 = NULL; 294 value2 = NULL;
295 295
296 } 296 }
@@ -301,7 +301,7 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
301 301
302 if (out_str.length >= (unsigned int) *sizeof_buf) 302 if (out_str.length >= (unsigned int) *sizeof_buf)
303 { 303 {
304 gnutls_assert (); 304 MHD_gnutls_assert ();
305 *sizeof_buf = out_str.length + 1; 305 *sizeof_buf = out_str.length + 1;
306 result = GNUTLS_E_SHORT_MEMORY_BUFFER; 306 result = GNUTLS_E_SHORT_MEMORY_BUFFER;
307 goto cleanup; 307 goto cleanup;
@@ -317,28 +317,28 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
317 result = 0; 317 result = 0;
318 318
319cleanup: 319cleanup:
320 gnutls_free (value2); 320 MHD_gnutls_free (value2);
321 gnutls_free (string); 321 MHD_gnutls_free (string);
322 gnutls_free (escaped); 322 MHD_gnutls_free (escaped);
323 mhd_gtls_string_clear (&out_str); 323 MHD_gtls_string_clear (&out_str);
324 return result; 324 return result;
325} 325}
326 326
327/* Parses an X509 DN in the asn1_struct, and searches for the 327/* Parses an X509 DN in the MHD__asn1_struct, and searches for the
328 * given OID in the DN. 328 * given OID in the DN.
329 * 329 *
330 * If raw_flag == 0, the output will be encoded in the LDAP way. (#hex for non printable) 330 * If raw_flag == 0, the output will be encoded in the LDAP way. (#hex for non printable)
331 * Otherwise the raw DER data are returned. 331 * Otherwise the raw DER data are returned.
332 * 332 *
333 * asn1_rdn_name must be a string in the form "tbsCertificate.issuer.rdnSequence". 333 * MHD__asn1_rdn_name must be a string in the form "tbsCertificate.issuer.rdnSequence".
334 * That is to point in the rndSequence. 334 * That is to point in the rndSequence.
335 * 335 *
336 * indx specifies which OID to return. Ie 0 means return the first specified 336 * indx specifies which OID to return. Ie 0 means return the first specified
337 * OID found, 1 the second etc. 337 * OID found, 1 the second etc.
338 */ 338 */
339int 339int
340_gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct, 340MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct,
341 const char *asn1_rdn_name, 341 const char *MHD__asn1_rdn_name,
342 const char *given_oid, int indx, 342 const char *given_oid, int indx,
343 unsigned int raw_flag, 343 unsigned int raw_flag,
344 void *buf, size_t * sizeof_buf) 344 void *buf, size_t * sizeof_buf)
@@ -365,25 +365,25 @@ _gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct,
365 k1++; 365 k1++;
366 /* create a string like "tbsCertList.issuer.rdnSequence.?1" 366 /* create a string like "tbsCertList.issuer.rdnSequence.?1"
367 */ 367 */
368 if (asn1_rdn_name[0] != 0) 368 if (MHD__asn1_rdn_name[0] != 0)
369 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", asn1_rdn_name, 369 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", MHD__asn1_rdn_name,
370 k1); 370 k1);
371 else 371 else
372 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1); 372 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1);
373 373
374 len = sizeof (value) - 1; 374 len = sizeof (value) - 1;
375 result = asn1_read_value (asn1_struct, tmpbuffer1, value, &len); 375 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len);
376 376
377 if (result == ASN1_ELEMENT_NOT_FOUND) 377 if (result == ASN1_ELEMENT_NOT_FOUND)
378 { 378 {
379 gnutls_assert (); 379 MHD_gnutls_assert ();
380 break; 380 break;
381 } 381 }
382 382
383 if (result != ASN1_VALUE_NOT_FOUND) 383 if (result != ASN1_VALUE_NOT_FOUND)
384 { 384 {
385 gnutls_assert (); 385 MHD_gnutls_assert ();
386 result = mhd_gtls_asn2err (result); 386 result = MHD_gtls_asn2err (result);
387 goto cleanup; 387 goto cleanup;
388 } 388 }
389 389
@@ -404,7 +404,7 @@ _gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct,
404 */ 404 */
405 405
406 len = sizeof (value) - 1; 406 len = sizeof (value) - 1;
407 result = asn1_read_value (asn1_struct, tmpbuffer2, value, &len); 407 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len);
408 408
409 if (result == ASN1_ELEMENT_NOT_FOUND) 409 if (result == ASN1_ELEMENT_NOT_FOUND)
410 { 410 {
@@ -412,25 +412,25 @@ _gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct,
412 } 412 }
413 if (result != ASN1_VALUE_NOT_FOUND) 413 if (result != ASN1_VALUE_NOT_FOUND)
414 { 414 {
415 gnutls_assert (); 415 MHD_gnutls_assert ();
416 result = mhd_gtls_asn2err (result); 416 result = MHD_gtls_asn2err (result);
417 goto cleanup; 417 goto cleanup;
418 } 418 }
419 419
420 /* Read the OID 420 /* Read the OID
421 */ 421 */
422 mhd_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2); 422 MHD_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
423 mhd_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type"); 423 MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type");
424 424
425 len = sizeof (oid) - 1; 425 len = sizeof (oid) - 1;
426 result = asn1_read_value (asn1_struct, tmpbuffer3, oid, &len); 426 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len);
427 427
428 if (result == ASN1_ELEMENT_NOT_FOUND) 428 if (result == ASN1_ELEMENT_NOT_FOUND)
429 break; 429 break;
430 else if (result != ASN1_SUCCESS) 430 else if (result != ASN1_SUCCESS)
431 { 431 {
432 gnutls_assert (); 432 MHD_gnutls_assert ();
433 result = mhd_gtls_asn2err (result); 433 result = MHD_gtls_asn2err (result);
434 goto cleanup; 434 goto cleanup;
435 } 435 }
436 436
@@ -439,18 +439,18 @@ _gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct,
439 439
440 /* Read the Value 440 /* Read the Value
441 */ 441 */
442 mhd_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2); 442 MHD_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
443 mhd_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".value"); 443 MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".value");
444 444
445 len = *sizeof_buf; 445 len = *sizeof_buf;
446 result = asn1_read_value (asn1_struct, tmpbuffer3, buf, &len); 446 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, buf, &len);
447 447
448 if (result != ASN1_SUCCESS) 448 if (result != ASN1_SUCCESS)
449 { 449 {
450 gnutls_assert (); 450 MHD_gnutls_assert ();
451 if (result == ASN1_MEM_ERROR) 451 if (result == ASN1_MEM_ERROR)
452 *sizeof_buf = len; 452 *sizeof_buf = len;
453 result = mhd_gtls_asn2err (result); 453 result = MHD_gtls_asn2err (result);
454 goto cleanup; 454 goto cleanup;
455 } 455 }
456 456
@@ -469,19 +469,19 @@ _gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct,
469 } 469 }
470 else 470 else
471 { /* parse data. raw_flag == 0 */ 471 { /* parse data. raw_flag == 0 */
472 printable = _gnutls_x509_oid_data_printable (oid); 472 printable = MHD__gnutls_x509_oid_data_printable (oid);
473 473
474 if (printable == 1) 474 if (printable == 1)
475 result = 475 result =
476 _gnutls_x509_oid_data2string (oid, buf, len, 476 MHD__gnutls_x509_oid_data2string (oid, buf, len,
477 cbuf, sizeof_buf); 477 cbuf, sizeof_buf);
478 else 478 else
479 result = 479 result =
480 _gnutls_x509_data2hex (buf, len, cbuf, sizeof_buf); 480 MHD__gnutls_x509_data2hex (buf, len, cbuf, sizeof_buf);
481 481
482 if (result < 0) 482 if (result < 0)
483 { 483 {
484 gnutls_assert (); 484 MHD_gnutls_assert ();
485 goto cleanup; 485 goto cleanup;
486 } 486 }
487 487
@@ -495,7 +495,7 @@ _gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct,
495 } 495 }
496 while (1); 496 while (1);
497 497
498 gnutls_assert (); 498 MHD_gnutls_assert ();
499 499
500 result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 500 result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
501 501
@@ -504,18 +504,18 @@ cleanup:
504} 504}
505 505
506 506
507/* Parses an X509 DN in the asn1_struct, and returns the requested 507/* Parses an X509 DN in the MHD__asn1_struct, and returns the requested
508 * DN OID. 508 * DN OID.
509 * 509 *
510 * asn1_rdn_name must be a string in the form "tbsCertificate.issuer.rdnSequence". 510 * MHD__asn1_rdn_name must be a string in the form "tbsCertificate.issuer.rdnSequence".
511 * That is to point in the rndSequence. 511 * That is to point in the rndSequence.
512 * 512 *
513 * indx specifies which OID to return. Ie 0 means return the first specified 513 * indx specifies which OID to return. Ie 0 means return the first specified
514 * OID found, 1 the second etc. 514 * OID found, 1 the second etc.
515 */ 515 */
516int 516int
517_gnutls_x509_get_dn_oid (ASN1_TYPE asn1_struct, 517MHD__gnutls_x509_get_dn_oid (ASN1_TYPE MHD__asn1_struct,
518 const char *asn1_rdn_name, 518 const char *MHD__asn1_rdn_name,
519 int indx, void *_oid, size_t * sizeof_oid) 519 int indx, void *_oid, size_t * sizeof_oid)
520{ 520{
521 int k2, k1, result; 521 int k2, k1, result;
@@ -534,25 +534,25 @@ _gnutls_x509_get_dn_oid (ASN1_TYPE asn1_struct,
534 k1++; 534 k1++;
535 /* create a string like "tbsCertList.issuer.rdnSequence.?1" 535 /* create a string like "tbsCertList.issuer.rdnSequence.?1"
536 */ 536 */
537 if (asn1_rdn_name[0] != 0) 537 if (MHD__asn1_rdn_name[0] != 0)
538 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", asn1_rdn_name, 538 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", MHD__asn1_rdn_name,
539 k1); 539 k1);
540 else 540 else
541 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1); 541 snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1);
542 542
543 len = sizeof (value) - 1; 543 len = sizeof (value) - 1;
544 result = asn1_read_value (asn1_struct, tmpbuffer1, value, &len); 544 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len);
545 545
546 if (result == ASN1_ELEMENT_NOT_FOUND) 546 if (result == ASN1_ELEMENT_NOT_FOUND)
547 { 547 {
548 gnutls_assert (); 548 MHD_gnutls_assert ();
549 break; 549 break;
550 } 550 }
551 551
552 if (result != ASN1_VALUE_NOT_FOUND) 552 if (result != ASN1_VALUE_NOT_FOUND)
553 { 553 {
554 gnutls_assert (); 554 MHD_gnutls_assert ();
555 result = mhd_gtls_asn2err (result); 555 result = MHD_gtls_asn2err (result);
556 goto cleanup; 556 goto cleanup;
557 } 557 }
558 558
@@ -573,7 +573,7 @@ _gnutls_x509_get_dn_oid (ASN1_TYPE asn1_struct,
573 */ 573 */
574 574
575 len = sizeof (value) - 1; 575 len = sizeof (value) - 1;
576 result = asn1_read_value (asn1_struct, tmpbuffer2, value, &len); 576 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len);
577 577
578 if (result == ASN1_ELEMENT_NOT_FOUND) 578 if (result == ASN1_ELEMENT_NOT_FOUND)
579 { 579 {
@@ -581,25 +581,25 @@ _gnutls_x509_get_dn_oid (ASN1_TYPE asn1_struct,
581 } 581 }
582 if (result != ASN1_VALUE_NOT_FOUND) 582 if (result != ASN1_VALUE_NOT_FOUND)
583 { 583 {
584 gnutls_assert (); 584 MHD_gnutls_assert ();
585 result = mhd_gtls_asn2err (result); 585 result = MHD_gtls_asn2err (result);
586 goto cleanup; 586 goto cleanup;
587 } 587 }
588 588
589 /* Read the OID 589 /* Read the OID
590 */ 590 */
591 mhd_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2); 591 MHD_gtls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
592 mhd_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type"); 592 MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type");
593 593
594 len = sizeof (oid) - 1; 594 len = sizeof (oid) - 1;
595 result = asn1_read_value (asn1_struct, tmpbuffer3, oid, &len); 595 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len);
596 596
597 if (result == ASN1_ELEMENT_NOT_FOUND) 597 if (result == ASN1_ELEMENT_NOT_FOUND)
598 break; 598 break;
599 else if (result != ASN1_SUCCESS) 599 else if (result != ASN1_SUCCESS)
600 { 600 {
601 gnutls_assert (); 601 MHD_gnutls_assert ();
602 result = mhd_gtls_asn2err (result); 602 result = MHD_gtls_asn2err (result);
603 goto cleanup; 603 goto cleanup;
604 } 604 }
605 605
@@ -611,7 +611,7 @@ _gnutls_x509_get_dn_oid (ASN1_TYPE asn1_struct,
611 if (*sizeof_oid < (unsigned) len) 611 if (*sizeof_oid < (unsigned) len)
612 { 612 {
613 *sizeof_oid = len; 613 *sizeof_oid = len;
614 gnutls_assert (); 614 MHD_gnutls_assert ();
615 return GNUTLS_E_SHORT_MEMORY_BUFFER; 615 return GNUTLS_E_SHORT_MEMORY_BUFFER;
616 } 616 }
617 617
@@ -626,7 +626,7 @@ _gnutls_x509_get_dn_oid (ASN1_TYPE asn1_struct,
626 } 626 }
627 while (1); 627 while (1);
628 628
629 gnutls_assert (); 629 MHD_gnutls_assert ();
630 630
631 result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 631 result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
632 632
@@ -639,8 +639,8 @@ cleanup:
639 * In all cases only one value is written. 639 * In all cases only one value is written.
640 */ 640 */
641int 641int
642_gnutls_x509_encode_and_write_attribute (const char *given_oid, 642MHD__gnutls_x509_encode_and_write_attribute (const char *given_oid,
643 ASN1_TYPE asn1_struct, 643 ASN1_TYPE MHD__asn1_struct,
644 const char *where, 644 const char *where,
645 const void *_data, 645 const void *_data,
646 int sizeof_data, int multi) 646 int sizeof_data, int multi)
@@ -654,26 +654,26 @@ _gnutls_x509_encode_and_write_attribute (const char *given_oid,
654 654
655 /* Find how to encode the data. 655 /* Find how to encode the data.
656 */ 656 */
657 val_name = asn1_find_structure_from_oid (_gnutls_get_pkix (), given_oid); 657 val_name = MHD__asn1_find_structure_from_oid (MHD__gnutls_get_pkix (), given_oid);
658 if (val_name == NULL) 658 if (val_name == NULL)
659 { 659 {
660 gnutls_assert (); 660 MHD_gnutls_assert ();
661 return GNUTLS_E_X509_UNSUPPORTED_OID; 661 return GNUTLS_E_X509_UNSUPPORTED_OID;
662 } 662 }
663 663
664 mhd_gtls_str_cpy (tmp, sizeof (tmp), "PKIX1."); 664 MHD_gtls_str_cpy (tmp, sizeof (tmp), "PKIX1.");
665 mhd_gtls_str_cat (tmp, sizeof (tmp), val_name); 665 MHD_gtls_str_cat (tmp, sizeof (tmp), val_name);
666 666
667 result = asn1_create_element (_gnutls_get_pkix (), tmp, &c2); 667 result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), tmp, &c2);
668 if (result != ASN1_SUCCESS) 668 if (result != ASN1_SUCCESS)
669 { 669 {
670 gnutls_assert (); 670 MHD_gnutls_assert ();
671 return mhd_gtls_asn2err (result); 671 return MHD_gtls_asn2err (result);
672 } 672 }
673 673
674 tmp[0] = 0; 674 tmp[0] = 0;
675 675
676 if ((result = _gnutls_x509_oid_data_choice (given_oid)) > 0) 676 if ((result = MHD__gnutls_x509_oid_data_choice (given_oid)) > 0)
677 { 677 {
678 char *string_type; 678 char *string_type;
679 int i; 679 int i;
@@ -695,64 +695,64 @@ _gnutls_x509_encode_and_write_attribute (const char *given_oid,
695 /* if the type is a CHOICE then write the 695 /* if the type is a CHOICE then write the
696 * type we'll use. 696 * type we'll use.
697 */ 697 */
698 result = asn1_write_value (c2, "", string_type, 1); 698 result = MHD__asn1_write_value (c2, "", string_type, 1);
699 if (result != ASN1_SUCCESS) 699 if (result != ASN1_SUCCESS)
700 { 700 {
701 gnutls_assert (); 701 MHD_gnutls_assert ();
702 asn1_delete_structure (&c2); 702 MHD__asn1_delete_structure (&c2);
703 return mhd_gtls_asn2err (result); 703 return MHD_gtls_asn2err (result);
704 } 704 }
705 705
706 mhd_gtls_str_cpy (tmp, sizeof (tmp), string_type); 706 MHD_gtls_str_cpy (tmp, sizeof (tmp), string_type);
707 } 707 }
708 708
709 result = asn1_write_value (c2, tmp, data, sizeof_data); 709 result = MHD__asn1_write_value (c2, tmp, data, sizeof_data);
710 if (result != ASN1_SUCCESS) 710 if (result != ASN1_SUCCESS)
711 { 711 {
712 gnutls_assert (); 712 MHD_gnutls_assert ();
713 asn1_delete_structure (&c2); 713 MHD__asn1_delete_structure (&c2);
714 return mhd_gtls_asn2err (result); 714 return MHD_gtls_asn2err (result);
715 } 715 }
716 716
717 717
718 /* write the data (value) 718 /* write the data (value)
719 */ 719 */
720 720
721 mhd_gtls_str_cpy (tmp, sizeof (tmp), where); 721 MHD_gtls_str_cpy (tmp, sizeof (tmp), where);
722 mhd_gtls_str_cat (tmp, sizeof (tmp), ".value"); 722 MHD_gtls_str_cat (tmp, sizeof (tmp), ".value");
723 723
724 if (multi != 0) 724 if (multi != 0)
725 { /* if not writing an AttributeTypeAndValue, but an Attribute */ 725 { /* if not writing an AttributeTypeAndValue, but an Attribute */
726 mhd_gtls_str_cat (tmp, sizeof (tmp), "s"); /* values */ 726 MHD_gtls_str_cat (tmp, sizeof (tmp), "s"); /* values */
727 727
728 result = asn1_write_value (asn1_struct, tmp, "NEW", 1); 728 result = MHD__asn1_write_value (MHD__asn1_struct, tmp, "NEW", 1);
729 if (result != ASN1_SUCCESS) 729 if (result != ASN1_SUCCESS)
730 { 730 {
731 gnutls_assert (); 731 MHD_gnutls_assert ();
732 return mhd_gtls_asn2err (result); 732 return MHD_gtls_asn2err (result);
733 } 733 }
734 734
735 mhd_gtls_str_cat (tmp, sizeof (tmp), ".?LAST"); 735 MHD_gtls_str_cat (tmp, sizeof (tmp), ".?LAST");
736 736
737 } 737 }
738 738
739 result = _gnutls_x509_der_encode_and_copy (c2, "", asn1_struct, tmp, 0); 739 result = MHD__gnutls_x509_der_encode_and_copy (c2, "", MHD__asn1_struct, tmp, 0);
740 if (result < 0) 740 if (result < 0)
741 { 741 {
742 gnutls_assert (); 742 MHD_gnutls_assert ();
743 return result; 743 return result;
744 } 744 }
745 745
746 /* write the type 746 /* write the type
747 */ 747 */
748 mhd_gtls_str_cpy (tmp, sizeof (tmp), where); 748 MHD_gtls_str_cpy (tmp, sizeof (tmp), where);
749 mhd_gtls_str_cat (tmp, sizeof (tmp), ".type"); 749 MHD_gtls_str_cat (tmp, sizeof (tmp), ".type");
750 750
751 result = asn1_write_value (asn1_struct, tmp, given_oid, 1); 751 result = MHD__asn1_write_value (MHD__asn1_struct, tmp, given_oid, 1);
752 if (result != ASN1_SUCCESS) 752 if (result != ASN1_SUCCESS)
753 { 753 {
754 gnutls_assert (); 754 MHD_gnutls_assert ();
755 return mhd_gtls_asn2err (result); 755 return MHD_gtls_asn2err (result);
756 } 756 }
757 757
758 return 0; 758 return 0;
@@ -762,8 +762,8 @@ _gnutls_x509_encode_and_write_attribute (const char *given_oid,
762 * In all cases only one value is written. 762 * In all cases only one value is written.
763 */ 763 */
764static int 764static int
765_gnutls_x509_write_attribute (const char *given_oid, 765MHD__gnutls_x509_write_attribute (const char *given_oid,
766 ASN1_TYPE asn1_struct, const char *where, 766 ASN1_TYPE MHD__asn1_struct, const char *where,
767 const void *_data, int sizeof_data) 767 const void *_data, int sizeof_data)
768{ 768{
769 char tmp[128]; 769 char tmp[128];
@@ -772,26 +772,26 @@ _gnutls_x509_write_attribute (const char *given_oid,
772 /* write the data (value) 772 /* write the data (value)
773 */ 773 */
774 774
775 mhd_gtls_str_cpy (tmp, sizeof (tmp), where); 775 MHD_gtls_str_cpy (tmp, sizeof (tmp), where);
776 mhd_gtls_str_cat (tmp, sizeof (tmp), ".value"); 776 MHD_gtls_str_cat (tmp, sizeof (tmp), ".value");
777 777
778 result = asn1_write_value (asn1_struct, tmp, _data, sizeof_data); 778 result = MHD__asn1_write_value (MHD__asn1_struct, tmp, _data, sizeof_data);
779 if (result < 0) 779 if (result < 0)
780 { 780 {
781 gnutls_assert (); 781 MHD_gnutls_assert ();
782 return mhd_gtls_asn2err (result); 782 return MHD_gtls_asn2err (result);
783 } 783 }
784 784
785 /* write the type 785 /* write the type
786 */ 786 */
787 mhd_gtls_str_cpy (tmp, sizeof (tmp), where); 787 MHD_gtls_str_cpy (tmp, sizeof (tmp), where);
788 mhd_gtls_str_cat (tmp, sizeof (tmp), ".type"); 788 MHD_gtls_str_cat (tmp, sizeof (tmp), ".type");
789 789
790 result = asn1_write_value (asn1_struct, tmp, given_oid, 1); 790 result = MHD__asn1_write_value (MHD__asn1_struct, tmp, given_oid, 1);
791 if (result != ASN1_SUCCESS) 791 if (result != ASN1_SUCCESS)
792 { 792 {
793 gnutls_assert (); 793 MHD_gnutls_assert ();
794 return mhd_gtls_asn2err (result); 794 return MHD_gtls_asn2err (result);
795 } 795 }
796 796
797 return 0; 797 return 0;
@@ -807,9 +807,9 @@ _gnutls_x509_write_attribute (const char *given_oid,
807 * The output is allocated and stored in value. 807 * The output is allocated and stored in value.
808 */ 808 */
809int 809int
810_gnutls_x509_decode_and_read_attribute (ASN1_TYPE asn1_struct, 810MHD__gnutls_x509_decode_and_read_attribute (ASN1_TYPE MHD__asn1_struct,
811 const char *where, char *oid, 811 const char *where, char *oid,
812 int oid_size, gnutls_datum_t * value, 812 int oid_size, MHD_gnutls_datum_t * value,
813 int multi, int octet_string) 813 int multi, int octet_string)
814{ 814{
815 char tmpbuffer[128]; 815 char tmpbuffer[128];
@@ -817,33 +817,33 @@ _gnutls_x509_decode_and_read_attribute (ASN1_TYPE asn1_struct,
817 817
818 /* Read the OID 818 /* Read the OID
819 */ 819 */
820 mhd_gtls_str_cpy (tmpbuffer, sizeof (tmpbuffer), where); 820 MHD_gtls_str_cpy (tmpbuffer, sizeof (tmpbuffer), where);
821 mhd_gtls_str_cat (tmpbuffer, sizeof (tmpbuffer), ".type"); 821 MHD_gtls_str_cat (tmpbuffer, sizeof (tmpbuffer), ".type");
822 822
823 len = oid_size - 1; 823 len = oid_size - 1;
824 result = asn1_read_value (asn1_struct, tmpbuffer, oid, &len); 824 result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer, oid, &len);
825 825
826 if (result != ASN1_SUCCESS) 826 if (result != ASN1_SUCCESS)
827 { 827 {
828 gnutls_assert (); 828 MHD_gnutls_assert ();
829 result = mhd_gtls_asn2err (result); 829 result = MHD_gtls_asn2err (result);
830 return result; 830 return result;
831 } 831 }
832 832
833 /* Read the Value 833 /* Read the Value
834 */ 834 */
835 835
836 mhd_gtls_str_cpy (tmpbuffer, sizeof (tmpbuffer), where); 836 MHD_gtls_str_cpy (tmpbuffer, sizeof (tmpbuffer), where);
837 mhd_gtls_str_cat (tmpbuffer, sizeof (tmpbuffer), ".value"); 837 MHD_gtls_str_cat (tmpbuffer, sizeof (tmpbuffer), ".value");
838 838
839 if (multi) 839 if (multi)
840 mhd_gtls_str_cat (tmpbuffer, sizeof (tmpbuffer), "s.?1"); /* .values.?1 */ 840 MHD_gtls_str_cat (tmpbuffer, sizeof (tmpbuffer), "s.?1"); /* .values.?1 */
841 841
842 result = 842 result =
843 _gnutls_x509_read_value (asn1_struct, tmpbuffer, value, octet_string); 843 MHD__gnutls_x509_read_value (MHD__asn1_struct, tmpbuffer, value, octet_string);
844 if (result < 0) 844 if (result < 0)
845 { 845 {
846 gnutls_assert (); 846 MHD_gnutls_assert ();
847 return result; 847 return result;
848 } 848 }
849 849
@@ -851,83 +851,83 @@ _gnutls_x509_decode_and_read_attribute (ASN1_TYPE asn1_struct,
851 851
852} 852}
853 853
854/* Sets an X509 DN in the asn1_struct, and puts the given OID in the DN. 854/* Sets an X509 DN in the MHD__asn1_struct, and puts the given OID in the DN.
855 * The input is assumed to be raw data. 855 * The input is assumed to be raw data.
856 * 856 *
857 * asn1_rdn_name must be a string in the form "tbsCertificate.issuer". 857 * MHD__asn1_rdn_name must be a string in the form "tbsCertificate.issuer".
858 * That is to point before the rndSequence. 858 * That is to point before the rndSequence.
859 * 859 *
860 */ 860 */
861int 861int
862_gnutls_x509_set_dn_oid (ASN1_TYPE asn1_struct, 862MHD__gnutls_x509_set_dn_oid (ASN1_TYPE MHD__asn1_struct,
863 const char *asn1_name, const char *given_oid, 863 const char *MHD__asn1_name, const char *given_oid,
864 int raw_flag, const char *name, int sizeof_name) 864 int raw_flag, const char *name, int sizeof_name)
865{ 865{
866 int result; 866 int result;
867 char tmp[MAX_NAME_SIZE], asn1_rdn_name[MAX_NAME_SIZE]; 867 char tmp[MAX_NAME_SIZE], MHD__asn1_rdn_name[MAX_NAME_SIZE];
868 868
869 if (sizeof_name == 0 || name == NULL) 869 if (sizeof_name == 0 || name == NULL)
870 { 870 {
871 gnutls_assert (); 871 MHD_gnutls_assert ();
872 return GNUTLS_E_INVALID_REQUEST; 872 return GNUTLS_E_INVALID_REQUEST;
873 } 873 }
874 874
875 /* create the rdnSequence 875 /* create the rdnSequence
876 */ 876 */
877 result = asn1_write_value (asn1_struct, asn1_name, "rdnSequence", 1); 877 result = MHD__asn1_write_value (MHD__asn1_struct, MHD__asn1_name, "rdnSequence", 1);
878 if (result != ASN1_SUCCESS) 878 if (result != ASN1_SUCCESS)
879 { 879 {
880 gnutls_assert (); 880 MHD_gnutls_assert ();
881 return mhd_gtls_asn2err (result); 881 return MHD_gtls_asn2err (result);
882 } 882 }
883 883
884 mhd_gtls_str_cpy (asn1_rdn_name, sizeof (asn1_rdn_name), asn1_name); 884 MHD_gtls_str_cpy (MHD__asn1_rdn_name, sizeof (MHD__asn1_rdn_name), MHD__asn1_name);
885 mhd_gtls_str_cat (asn1_rdn_name, sizeof (asn1_rdn_name), ".rdnSequence"); 885 MHD_gtls_str_cat (MHD__asn1_rdn_name, sizeof (MHD__asn1_rdn_name), ".rdnSequence");
886 886
887 /* create a new element 887 /* create a new element
888 */ 888 */
889 result = asn1_write_value (asn1_struct, asn1_rdn_name, "NEW", 1); 889 result = MHD__asn1_write_value (MHD__asn1_struct, MHD__asn1_rdn_name, "NEW", 1);
890 if (result != ASN1_SUCCESS) 890 if (result != ASN1_SUCCESS)
891 { 891 {
892 gnutls_assert (); 892 MHD_gnutls_assert ();
893 return mhd_gtls_asn2err (result); 893 return MHD_gtls_asn2err (result);
894 } 894 }
895 895
896 mhd_gtls_str_cpy (tmp, sizeof (tmp), asn1_rdn_name); 896 MHD_gtls_str_cpy (tmp, sizeof (tmp), MHD__asn1_rdn_name);
897 mhd_gtls_str_cat (tmp, sizeof (tmp), ".?LAST"); 897 MHD_gtls_str_cat (tmp, sizeof (tmp), ".?LAST");
898 898
899 /* create the set with only one element 899 /* create the set with only one element
900 */ 900 */
901 result = asn1_write_value (asn1_struct, tmp, "NEW", 1); 901 result = MHD__asn1_write_value (MHD__asn1_struct, tmp, "NEW", 1);
902 if (result != ASN1_SUCCESS) 902 if (result != ASN1_SUCCESS)
903 { 903 {
904 gnutls_assert (); 904 MHD_gnutls_assert ();
905 return mhd_gtls_asn2err (result); 905 return MHD_gtls_asn2err (result);
906 } 906 }
907 907
908 908
909 /* Encode and write the data 909 /* Encode and write the data
910 */ 910 */
911 mhd_gtls_str_cpy (tmp, sizeof (tmp), asn1_rdn_name); 911 MHD_gtls_str_cpy (tmp, sizeof (tmp), MHD__asn1_rdn_name);
912 mhd_gtls_str_cat (tmp, sizeof (tmp), ".?LAST.?LAST"); 912 MHD_gtls_str_cat (tmp, sizeof (tmp), ".?LAST.?LAST");
913 913
914 if (!raw_flag) 914 if (!raw_flag)
915 { 915 {
916 result = 916 result =
917 _gnutls_x509_encode_and_write_attribute (given_oid, 917 MHD__gnutls_x509_encode_and_write_attribute (given_oid,
918 asn1_struct, 918 MHD__asn1_struct,
919 tmp, name, sizeof_name, 0); 919 tmp, name, sizeof_name, 0);
920 } 920 }
921 else 921 else
922 { 922 {
923 result = 923 result =
924 _gnutls_x509_write_attribute (given_oid, asn1_struct, 924 MHD__gnutls_x509_write_attribute (given_oid, MHD__asn1_struct,
925 tmp, name, sizeof_name); 925 tmp, name, sizeof_name);
926 } 926 }
927 927
928 if (result < 0) 928 if (result < 0)
929 { 929 {
930 gnutls_assert (); 930 MHD_gnutls_assert ();
931 return result; 931 return result;
932 } 932 }
933 933
@@ -936,7 +936,7 @@ _gnutls_x509_set_dn_oid (ASN1_TYPE asn1_struct,
936 936
937 937
938/** 938/**
939 * gnutls_x509_rdn_get - This function parses an RDN sequence and returns a string 939 * MHD_gnutls_x509_rdn_get - This function parses an RDN sequence and returns a string
940 * @idn: should contain a DER encoded RDN sequence 940 * @idn: should contain a DER encoded RDN sequence
941 * @buf: a pointer to a structure to hold the peer's name 941 * @buf: a pointer to a structure to hold the peer's name
942 * @sizeof_buf: holds the size of @buf 942 * @sizeof_buf: holds the size of @buf
@@ -951,7 +951,7 @@ _gnutls_x509_set_dn_oid (ASN1_TYPE asn1_struct,
951 * 951 *
952 **/ 952 **/
953int 953int
954gnutls_x509_rdn_get (const gnutls_datum_t * idn, 954MHD_gnutls_x509_rdn_get (const MHD_gnutls_datum_t * idn,
955 char *buf, size_t * sizeof_buf) 955 char *buf, size_t * sizeof_buf)
956{ 956{
957 int result; 957 int result;
@@ -959,7 +959,7 @@ gnutls_x509_rdn_get (const gnutls_datum_t * idn,
959 959
960 if (sizeof_buf == 0) 960 if (sizeof_buf == 0)
961 { 961 {
962 gnutls_assert (); 962 MHD_gnutls_assert ();
963 return GNUTLS_E_INVALID_REQUEST; 963 return GNUTLS_E_INVALID_REQUEST;
964 } 964 }
965 965
@@ -968,31 +968,31 @@ gnutls_x509_rdn_get (const gnutls_datum_t * idn,
968 968
969 969
970 if ((result = 970 if ((result =
971 asn1_create_element (_gnutls_get_pkix (), 971 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
972 "PKIX1.Name", &dn)) != ASN1_SUCCESS) 972 "PKIX1.Name", &dn)) != ASN1_SUCCESS)
973 { 973 {
974 gnutls_assert (); 974 MHD_gnutls_assert ();
975 return mhd_gtls_asn2err (result); 975 return MHD_gtls_asn2err (result);
976 } 976 }
977 977
978 result = asn1_der_decoding (&dn, idn->data, idn->size, NULL); 978 result = MHD__asn1_der_decoding (&dn, idn->data, idn->size, NULL);
979 if (result != ASN1_SUCCESS) 979 if (result != ASN1_SUCCESS)
980 { 980 {
981 /* couldn't decode DER */ 981 /* couldn't decode DER */
982 gnutls_assert (); 982 MHD_gnutls_assert ();
983 asn1_delete_structure (&dn); 983 MHD__asn1_delete_structure (&dn);
984 return mhd_gtls_asn2err (result); 984 return MHD_gtls_asn2err (result);
985 } 985 }
986 986
987 result = _gnutls_x509_parse_dn (dn, "rdnSequence", buf, sizeof_buf); 987 result = MHD__gnutls_x509_parse_dn (dn, "rdnSequence", buf, sizeof_buf);
988 988
989 asn1_delete_structure (&dn); 989 MHD__asn1_delete_structure (&dn);
990 return result; 990 return result;
991 991
992} 992}
993 993
994/** 994/**
995 * gnutls_x509_rdn_get_by_oid - This function parses an RDN sequence and returns a string 995 * MHD_gnutls_x509_rdn_get_by_oid - This function parses an RDN sequence and returns a string
996 * @idn: should contain a DER encoded RDN sequence 996 * @idn: should contain a DER encoded RDN sequence
997 * @oid: an Object Identifier 997 * @oid: an Object Identifier
998 * @indx: In case multiple same OIDs exist in the RDN indicates which 998 * @indx: In case multiple same OIDs exist in the RDN indicates which
@@ -1010,7 +1010,7 @@ gnutls_x509_rdn_get (const gnutls_datum_t * idn,
1010 * 1010 *
1011 **/ 1011 **/
1012int 1012int
1013gnutls_x509_rdn_get_by_oid (const gnutls_datum_t * idn, const char *oid, 1013MHD_gnutls_x509_rdn_get_by_oid (const MHD_gnutls_datum_t * idn, const char *oid,
1014 int indx, unsigned int raw_flag, 1014 int indx, unsigned int raw_flag,
1015 void *buf, size_t * sizeof_buf) 1015 void *buf, size_t * sizeof_buf)
1016{ 1016{
@@ -1023,33 +1023,33 @@ gnutls_x509_rdn_get_by_oid (const gnutls_datum_t * idn, const char *oid,
1023 } 1023 }
1024 1024
1025 if ((result = 1025 if ((result =
1026 asn1_create_element (_gnutls_get_pkix (), 1026 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1027 "PKIX1.Name", &dn)) != ASN1_SUCCESS) 1027 "PKIX1.Name", &dn)) != ASN1_SUCCESS)
1028 { 1028 {
1029 gnutls_assert (); 1029 MHD_gnutls_assert ();
1030 return mhd_gtls_asn2err (result); 1030 return MHD_gtls_asn2err (result);
1031 } 1031 }
1032 1032
1033 result = asn1_der_decoding (&dn, idn->data, idn->size, NULL); 1033 result = MHD__asn1_der_decoding (&dn, idn->data, idn->size, NULL);
1034 if (result != ASN1_SUCCESS) 1034 if (result != ASN1_SUCCESS)
1035 { 1035 {
1036 /* couldn't decode DER */ 1036 /* couldn't decode DER */
1037 gnutls_assert (); 1037 MHD_gnutls_assert ();
1038 asn1_delete_structure (&dn); 1038 MHD__asn1_delete_structure (&dn);
1039 return mhd_gtls_asn2err (result); 1039 return MHD_gtls_asn2err (result);
1040 } 1040 }
1041 1041
1042 result = 1042 result =
1043 _gnutls_x509_parse_dn_oid (dn, "rdnSequence", oid, indx, 1043 MHD__gnutls_x509_parse_dn_oid (dn, "rdnSequence", oid, indx,
1044 raw_flag, buf, sizeof_buf); 1044 raw_flag, buf, sizeof_buf);
1045 1045
1046 asn1_delete_structure (&dn); 1046 MHD__asn1_delete_structure (&dn);
1047 return result; 1047 return result;
1048 1048
1049} 1049}
1050 1050
1051/** 1051/**
1052 * gnutls_x509_rdn_get_oid - This function parses an RDN sequence and returns an OID. 1052 * MHD_gnutls_x509_rdn_get_oid - This function parses an RDN sequence and returns an OID.
1053 * @idn: should contain a DER encoded RDN sequence 1053 * @idn: should contain a DER encoded RDN sequence
1054 * @indx: Indicates which OID to return. Use 0 for the first one. 1054 * @indx: Indicates which OID to return. Use 0 for the first one.
1055 * @oid: a pointer to a structure to hold the peer's name OID 1055 * @oid: a pointer to a structure to hold the peer's name OID
@@ -1063,7 +1063,7 @@ gnutls_x509_rdn_get_by_oid (const gnutls_datum_t * idn, const char *oid,
1063 * 1063 *
1064 **/ 1064 **/
1065int 1065int
1066gnutls_x509_rdn_get_oid (const gnutls_datum_t * idn, 1066MHD_gnutls_x509_rdn_get_oid (const MHD_gnutls_datum_t * idn,
1067 int indx, void *buf, size_t * sizeof_buf) 1067 int indx, void *buf, size_t * sizeof_buf)
1068{ 1068{
1069 int result; 1069 int result;
@@ -1075,25 +1075,25 @@ gnutls_x509_rdn_get_oid (const gnutls_datum_t * idn,
1075 } 1075 }
1076 1076
1077 if ((result = 1077 if ((result =
1078 asn1_create_element (_gnutls_get_pkix (), 1078 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1079 "PKIX1.Name", &dn)) != ASN1_SUCCESS) 1079 "PKIX1.Name", &dn)) != ASN1_SUCCESS)
1080 { 1080 {
1081 gnutls_assert (); 1081 MHD_gnutls_assert ();
1082 return mhd_gtls_asn2err (result); 1082 return MHD_gtls_asn2err (result);
1083 } 1083 }
1084 1084
1085 result = asn1_der_decoding (&dn, idn->data, idn->size, NULL); 1085 result = MHD__asn1_der_decoding (&dn, idn->data, idn->size, NULL);
1086 if (result != ASN1_SUCCESS) 1086 if (result != ASN1_SUCCESS)
1087 { 1087 {
1088 /* couldn't decode DER */ 1088 /* couldn't decode DER */
1089 gnutls_assert (); 1089 MHD_gnutls_assert ();
1090 asn1_delete_structure (&dn); 1090 MHD__asn1_delete_structure (&dn);
1091 return mhd_gtls_asn2err (result); 1091 return MHD_gtls_asn2err (result);
1092 } 1092 }
1093 1093
1094 result = _gnutls_x509_get_dn_oid (dn, "rdnSequence", indx, buf, sizeof_buf); 1094 result = MHD__gnutls_x509_get_dn_oid (dn, "rdnSequence", indx, buf, sizeof_buf);
1095 1095
1096 asn1_delete_structure (&dn); 1096 MHD__asn1_delete_structure (&dn);
1097 return result; 1097 return result;
1098 1098
1099} 1099}
@@ -1107,18 +1107,18 @@ gnutls_x509_rdn_get_oid (const gnutls_datum_t * idn,
1107 * a negative value is returned to indicate error. 1107 * a negative value is returned to indicate error.
1108 */ 1108 */
1109int 1109int
1110_gnutls_x509_compare_raw_dn (const gnutls_datum_t * dn1, 1110MHD__gnutls_x509_compare_raw_dn (const MHD_gnutls_datum_t * dn1,
1111 const gnutls_datum_t * dn2) 1111 const MHD_gnutls_datum_t * dn2)
1112{ 1112{
1113 1113
1114 if (dn1->size != dn2->size) 1114 if (dn1->size != dn2->size)
1115 { 1115 {
1116 gnutls_assert (); 1116 MHD_gnutls_assert ();
1117 return 0; 1117 return 0;
1118 } 1118 }
1119 if (memcmp (dn1->data, dn2->data, dn2->size) != 0) 1119 if (memcmp (dn1->data, dn2->data, dn2->size) != 0)
1120 { 1120 {
1121 gnutls_assert (); 1121 MHD_gnutls_assert ();
1122 return 0; 1122 return 0;
1123 } 1123 }
1124 return 1; /* they match */ 1124 return 1; /* they match */
diff --git a/src/daemon/https/x509/dn.h b/src/daemon/https/x509/dn.h
index 97f85e16..04352b10 100644
--- a/src/daemon/https/x509/dn.h
+++ b/src/daemon/https/x509/dn.h
@@ -37,21 +37,21 @@
37#define OID_LDAP_UID "0.9.2342.19200300.100.1.1" 37#define OID_LDAP_UID "0.9.2342.19200300.100.1.1"
38#define OID_PKCS9_EMAIL "1.2.840.113549.1.9.1" 38#define OID_PKCS9_EMAIL "1.2.840.113549.1.9.1"
39 39
40int _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct, 40int MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct,
41 const char *asn1_rdn_name, char *buf, 41 const char *MHD__asn1_rdn_name, char *buf,
42 size_t * sizeof_buf); 42 size_t * sizeof_buf);
43 43
44int _gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct, 44int MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct,
45 const char *asn1_rdn_name, const char *oid, 45 const char *MHD__asn1_rdn_name, const char *oid,
46 int indx, unsigned int raw_flag, void *buf, 46 int indx, unsigned int raw_flag, void *buf,
47 size_t * sizeof_buf); 47 size_t * sizeof_buf);
48 48
49int _gnutls_x509_set_dn_oid (ASN1_TYPE asn1_struct, 49int MHD__gnutls_x509_set_dn_oid (ASN1_TYPE MHD__asn1_struct,
50 const char *asn1_rdn_name, const char *oid, 50 const char *MHD__asn1_rdn_name, const char *oid,
51 int raw_flag, const char *name, int sizeof_name); 51 int raw_flag, const char *name, int sizeof_name);
52 52
53int _gnutls_x509_get_dn_oid (ASN1_TYPE asn1_struct, 53int MHD__gnutls_x509_get_dn_oid (ASN1_TYPE MHD__asn1_struct,
54 const char *asn1_rdn_name, 54 const char *MHD__asn1_rdn_name,
55 int indx, void *_oid, size_t * sizeof_oid); 55 int indx, void *_oid, size_t * sizeof_oid);
56 56
57 57
diff --git a/src/daemon/https/x509/dsa.c b/src/daemon/https/x509/dsa.c
index d65bcede..d344c38f 100644
--- a/src/daemon/https/x509/dsa.c
+++ b/src/daemon/https/x509/dsa.c
@@ -33,7 +33,7 @@
33/* resarr will contain: p(0), q(1), g(2), y(3), x(4). 33/* resarr will contain: p(0), q(1), g(2), y(3), x(4).
34 */ 34 */
35int 35int
36_gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits) 36MHD__gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
37{ 37{
38 38
39 int ret; 39 int ret;
@@ -42,20 +42,20 @@ _gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
42 /* FIXME: Remove me once we depend on 1.3.1 */ 42 /* FIXME: Remove me once we depend on 1.3.1 */
43 if (bits > 1024 && gcry_check_version ("1.3.1") == NULL) 43 if (bits > 1024 && gcry_check_version ("1.3.1") == NULL)
44 { 44 {
45 gnutls_assert (); 45 MHD_gnutls_assert ();
46 return GNUTLS_E_INVALID_REQUEST; 46 return GNUTLS_E_INVALID_REQUEST;
47 } 47 }
48 48
49 if (bits < 512) 49 if (bits < 512)
50 { 50 {
51 gnutls_assert (); 51 MHD_gnutls_assert ();
52 return GNUTLS_E_INVALID_REQUEST; 52 return GNUTLS_E_INVALID_REQUEST;
53 } 53 }
54 54
55 ret = gcry_sexp_build (&parms, NULL, "(genkey(dsa(nbits %d)))", bits); 55 ret = gcry_sexp_build (&parms, NULL, "(genkey(dsa(nbits %d)))", bits);
56 if (ret != 0) 56 if (ret != 0)
57 { 57 {
58 gnutls_assert (); 58 MHD_gnutls_assert ();
59 return GNUTLS_E_INTERNAL_ERROR; 59 return GNUTLS_E_INTERNAL_ERROR;
60 } 60 }
61 61
@@ -66,14 +66,14 @@ _gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
66 66
67 if (ret != 0) 67 if (ret != 0)
68 { 68 {
69 gnutls_assert (); 69 MHD_gnutls_assert ();
70 return GNUTLS_E_INTERNAL_ERROR; 70 return GNUTLS_E_INTERNAL_ERROR;
71 } 71 }
72 72
73 list = gcry_sexp_find_token (key, "p", 0); 73 list = gcry_sexp_find_token (key, "p", 0);
74 if (list == NULL) 74 if (list == NULL)
75 { 75 {
76 gnutls_assert (); 76 MHD_gnutls_assert ();
77 gcry_sexp_release (key); 77 gcry_sexp_release (key);
78 return GNUTLS_E_INTERNAL_ERROR; 78 return GNUTLS_E_INTERNAL_ERROR;
79 } 79 }
@@ -84,7 +84,7 @@ _gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
84 list = gcry_sexp_find_token (key, "q", 0); 84 list = gcry_sexp_find_token (key, "q", 0);
85 if (list == NULL) 85 if (list == NULL)
86 { 86 {
87 gnutls_assert (); 87 MHD_gnutls_assert ();
88 gcry_sexp_release (key); 88 gcry_sexp_release (key);
89 return GNUTLS_E_INTERNAL_ERROR; 89 return GNUTLS_E_INTERNAL_ERROR;
90 } 90 }
@@ -95,7 +95,7 @@ _gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
95 list = gcry_sexp_find_token (key, "g", 0); 95 list = gcry_sexp_find_token (key, "g", 0);
96 if (list == NULL) 96 if (list == NULL)
97 { 97 {
98 gnutls_assert (); 98 MHD_gnutls_assert ();
99 gcry_sexp_release (key); 99 gcry_sexp_release (key);
100 return GNUTLS_E_INTERNAL_ERROR; 100 return GNUTLS_E_INTERNAL_ERROR;
101 } 101 }
@@ -106,7 +106,7 @@ _gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
106 list = gcry_sexp_find_token (key, "y", 0); 106 list = gcry_sexp_find_token (key, "y", 0);
107 if (list == NULL) 107 if (list == NULL)
108 { 108 {
109 gnutls_assert (); 109 MHD_gnutls_assert ();
110 gcry_sexp_release (key); 110 gcry_sexp_release (key);
111 return GNUTLS_E_INTERNAL_ERROR; 111 return GNUTLS_E_INTERNAL_ERROR;
112 } 112 }
@@ -118,7 +118,7 @@ _gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
118 list = gcry_sexp_find_token (key, "x", 0); 118 list = gcry_sexp_find_token (key, "x", 0);
119 if (list == NULL) 119 if (list == NULL)
120 { 120 {
121 gnutls_assert (); 121 MHD_gnutls_assert ();
122 gcry_sexp_release (key); 122 gcry_sexp_release (key);
123 return GNUTLS_E_INTERNAL_ERROR; 123 return GNUTLS_E_INTERNAL_ERROR;
124 } 124 }
@@ -129,11 +129,11 @@ _gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
129 129
130 gcry_sexp_release (key); 130 gcry_sexp_release (key);
131 131
132 _gnutls_dump_mpi ("p: ", resarr[0]); 132 MHD__gnutls_dump_mpi ("p: ", resarr[0]);
133 _gnutls_dump_mpi ("q: ", resarr[1]); 133 MHD__gnutls_dump_mpi ("q: ", resarr[1]);
134 _gnutls_dump_mpi ("g: ", resarr[2]); 134 MHD__gnutls_dump_mpi ("g: ", resarr[2]);
135 _gnutls_dump_mpi ("y: ", resarr[3]); 135 MHD__gnutls_dump_mpi ("y: ", resarr[3]);
136 _gnutls_dump_mpi ("x: ", resarr[4]); 136 MHD__gnutls_dump_mpi ("x: ", resarr[4]);
137 137
138 *resarr_len = 5; 138 *resarr_len = 5;
139 139
diff --git a/src/daemon/https/x509/dsa.h b/src/daemon/https/x509/dsa.h
index 5489ffa3..bed87a7d 100644
--- a/src/daemon/https/x509/dsa.h
+++ b/src/daemon/https/x509/dsa.h
@@ -22,4 +22,4 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits); 25int MHD__gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits);
diff --git a/src/daemon/https/x509/extensions.c b/src/daemon/https/x509/extensions.c
index 5cf170af..f22fac36 100644
--- a/src/daemon/https/x509/extensions.c
+++ b/src/daemon/https/x509/extensions.c
@@ -45,9 +45,9 @@
45 * be returned. 45 * be returned.
46 */ 46 */
47int 47int
48_gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert, 48MHD__gnutls_x509_crt_get_extension (MHD_gnutls_x509_crt_t cert,
49 const char *extension_id, int indx, 49 const char *extension_id, int indx,
50 gnutls_datum_t * ret, unsigned int *_critical) 50 MHD_gnutls_datum_t * ret, unsigned int *_critical)
51{ 51{
52 int k, result, len; 52 int k, result, len;
53 char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE]; 53 char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE];
@@ -55,7 +55,7 @@ _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert,
55 char str_critical[10]; 55 char str_critical[10];
56 int critical = 0; 56 int critical = 0;
57 char extnID[128]; 57 char extnID[128];
58 gnutls_datum_t value; 58 MHD_gnutls_datum_t value;
59 int indx_counter = 0; 59 int indx_counter = 0;
60 60
61 ret->data = NULL; 61 ret->data = NULL;
@@ -69,7 +69,7 @@ _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert,
69 snprintf (name, sizeof (name), "tbsCertificate.extensions.?%u", k); 69 snprintf (name, sizeof (name), "tbsCertificate.extensions.?%u", k);
70 70
71 len = sizeof (str) - 1; 71 len = sizeof (str) - 1;
72 result = asn1_read_value (cert->cert, name, str, &len); 72 result = MHD__asn1_read_value (cert->cert, name, str, &len);
73 73
74 /* move to next 74 /* move to next
75 */ 75 */
@@ -82,21 +82,21 @@ _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert,
82 do 82 do
83 { 83 {
84 84
85 mhd_gtls_str_cpy (name2, sizeof (name2), name); 85 MHD_gtls_str_cpy (name2, sizeof (name2), name);
86 mhd_gtls_str_cat (name2, sizeof (name2), ".extnID"); 86 MHD_gtls_str_cat (name2, sizeof (name2), ".extnID");
87 87
88 len = sizeof (extnID) - 1; 88 len = sizeof (extnID) - 1;
89 result = asn1_read_value (cert->cert, name2, extnID, &len); 89 result = MHD__asn1_read_value (cert->cert, name2, extnID, &len);
90 90
91 if (result == ASN1_ELEMENT_NOT_FOUND) 91 if (result == ASN1_ELEMENT_NOT_FOUND)
92 { 92 {
93 gnutls_assert (); 93 MHD_gnutls_assert ();
94 break; 94 break;
95 } 95 }
96 else if (result != ASN1_SUCCESS) 96 else if (result != ASN1_SUCCESS)
97 { 97 {
98 gnutls_assert (); 98 MHD_gnutls_assert ();
99 return mhd_gtls_asn2err (result); 99 return MHD_gtls_asn2err (result);
100 } 100 }
101 101
102 /* Handle Extension 102 /* Handle Extension
@@ -108,22 +108,22 @@ _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert,
108 108
109 /* read the critical status. 109 /* read the critical status.
110 */ 110 */
111 mhd_gtls_str_cpy (name2, sizeof (name2), name); 111 MHD_gtls_str_cpy (name2, sizeof (name2), name);
112 mhd_gtls_str_cat (name2, sizeof (name2), ".critical"); 112 MHD_gtls_str_cat (name2, sizeof (name2), ".critical");
113 113
114 len = sizeof (str_critical); 114 len = sizeof (str_critical);
115 result = 115 result =
116 asn1_read_value (cert->cert, name2, str_critical, &len); 116 MHD__asn1_read_value (cert->cert, name2, str_critical, &len);
117 117
118 if (result == ASN1_ELEMENT_NOT_FOUND) 118 if (result == ASN1_ELEMENT_NOT_FOUND)
119 { 119 {
120 gnutls_assert (); 120 MHD_gnutls_assert ();
121 break; 121 break;
122 } 122 }
123 else if (result != ASN1_SUCCESS) 123 else if (result != ASN1_SUCCESS)
124 { 124 {
125 gnutls_assert (); 125 MHD_gnutls_assert ();
126 return mhd_gtls_asn2err (result); 126 return MHD_gtls_asn2err (result);
127 } 127 }
128 128
129 if (str_critical[0] == 'T') 129 if (str_critical[0] == 'T')
@@ -133,13 +133,13 @@ _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert,
133 133
134 /* read the value. 134 /* read the value.
135 */ 135 */
136 mhd_gtls_str_cpy (name2, sizeof (name2), name); 136 MHD_gtls_str_cpy (name2, sizeof (name2), name);
137 mhd_gtls_str_cat (name2, sizeof (name2), ".extnValue"); 137 MHD_gtls_str_cat (name2, sizeof (name2), ".extnValue");
138 138
139 result = _gnutls_x509_read_value (cert->cert, name2, &value, 0); 139 result = MHD__gnutls_x509_read_value (cert->cert, name2, &value, 0);
140 if (result < 0) 140 if (result < 0)
141 { 141 {
142 gnutls_assert (); 142 MHD_gnutls_assert ();
143 return result; 143 return result;
144 } 144 }
145 145
@@ -164,8 +164,8 @@ _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert,
164 } 164 }
165 else 165 else
166 { 166 {
167 gnutls_assert (); 167 MHD_gnutls_assert ();
168 return mhd_gtls_asn2err (result); 168 return MHD_gtls_asn2err (result);
169 } 169 }
170} 170}
171 171
@@ -176,7 +176,7 @@ _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert,
176 * be returned. 176 * be returned.
177 */ 177 */
178int 178int
179_gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, 179MHD__gnutls_x509_crt_get_extension_oid (MHD_gnutls_x509_crt_t cert,
180 int indx, void *oid, size_t * sizeof_oid) 180 int indx, void *oid, size_t * sizeof_oid)
181{ 181{
182 int k, result, len; 182 int k, result, len;
@@ -193,7 +193,7 @@ _gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
193 snprintf (name, sizeof (name), "tbsCertificate.extensions.?%u", k); 193 snprintf (name, sizeof (name), "tbsCertificate.extensions.?%u", k);
194 194
195 len = sizeof (str) - 1; 195 len = sizeof (str) - 1;
196 result = asn1_read_value (cert->cert, name, str, &len); 196 result = MHD__asn1_read_value (cert->cert, name, str, &len);
197 197
198 /* move to next 198 /* move to next
199 */ 199 */
@@ -206,21 +206,21 @@ _gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
206 do 206 do
207 { 207 {
208 208
209 mhd_gtls_str_cpy (name2, sizeof (name2), name); 209 MHD_gtls_str_cpy (name2, sizeof (name2), name);
210 mhd_gtls_str_cat (name2, sizeof (name2), ".extnID"); 210 MHD_gtls_str_cat (name2, sizeof (name2), ".extnID");
211 211
212 len = sizeof (extnID) - 1; 212 len = sizeof (extnID) - 1;
213 result = asn1_read_value (cert->cert, name2, extnID, &len); 213 result = MHD__asn1_read_value (cert->cert, name2, extnID, &len);
214 214
215 if (result == ASN1_ELEMENT_NOT_FOUND) 215 if (result == ASN1_ELEMENT_NOT_FOUND)
216 { 216 {
217 gnutls_assert (); 217 MHD_gnutls_assert ();
218 break; 218 break;
219 } 219 }
220 else if (result != ASN1_SUCCESS) 220 else if (result != ASN1_SUCCESS)
221 { 221 {
222 gnutls_assert (); 222 MHD_gnutls_assert ();
223 return mhd_gtls_asn2err (result); 223 return MHD_gtls_asn2err (result);
224 } 224 }
225 225
226 /* Handle Extension 226 /* Handle Extension
@@ -232,7 +232,7 @@ _gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
232 if (*sizeof_oid < (unsigned) len) 232 if (*sizeof_oid < (unsigned) len)
233 { 233 {
234 *sizeof_oid = len; 234 *sizeof_oid = len;
235 gnutls_assert (); 235 MHD_gnutls_assert ();
236 return GNUTLS_E_SHORT_MEMORY_BUFFER; 236 return GNUTLS_E_SHORT_MEMORY_BUFFER;
237 } 237 }
238 238
@@ -254,8 +254,8 @@ _gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
254 } 254 }
255 else 255 else
256 { 256 {
257 gnutls_assert (); 257 MHD_gnutls_assert ();
258 return mhd_gtls_asn2err (result); 258 return MHD_gtls_asn2err (result);
259 } 259 }
260} 260}
261 261
@@ -266,27 +266,27 @@ _gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
266 */ 266 */
267static int 267static int
268set_extension (ASN1_TYPE asn, const char *extension_id, 268set_extension (ASN1_TYPE asn, const char *extension_id,
269 const gnutls_datum_t * ext_data, unsigned int critical) 269 const MHD_gnutls_datum_t * ext_data, unsigned int critical)
270{ 270{
271 int result; 271 int result;
272 const char *str; 272 const char *str;
273 273
274 /* Add a new extension in the list. 274 /* Add a new extension in the list.
275 */ 275 */
276 result = asn1_write_value (asn, "tbsCertificate.extensions", "NEW", 1); 276 result = MHD__asn1_write_value (asn, "tbsCertificate.extensions", "NEW", 1);
277 if (result != ASN1_SUCCESS) 277 if (result != ASN1_SUCCESS)
278 { 278 {
279 gnutls_assert (); 279 MHD_gnutls_assert ();
280 return mhd_gtls_asn2err (result); 280 return MHD_gtls_asn2err (result);
281 } 281 }
282 282
283 result = 283 result =
284 asn1_write_value (asn, "tbsCertificate.extensions.?LAST.extnID", 284 MHD__asn1_write_value (asn, "tbsCertificate.extensions.?LAST.extnID",
285 extension_id, 1); 285 extension_id, 1);
286 if (result != ASN1_SUCCESS) 286 if (result != ASN1_SUCCESS)
287 { 287 {
288 gnutls_assert (); 288 MHD_gnutls_assert ();
289 return mhd_gtls_asn2err (result); 289 return MHD_gtls_asn2err (result);
290 } 290 }
291 291
292 if (critical == 0) 292 if (critical == 0)
@@ -296,21 +296,21 @@ set_extension (ASN1_TYPE asn, const char *extension_id,
296 296
297 297
298 result = 298 result =
299 asn1_write_value (asn, "tbsCertificate.extensions.?LAST.critical", 299 MHD__asn1_write_value (asn, "tbsCertificate.extensions.?LAST.critical",
300 str, 1); 300 str, 1);
301 if (result != ASN1_SUCCESS) 301 if (result != ASN1_SUCCESS)
302 { 302 {
303 gnutls_assert (); 303 MHD_gnutls_assert ();
304 return mhd_gtls_asn2err (result); 304 return MHD_gtls_asn2err (result);
305 } 305 }
306 306
307 result = 307 result =
308 _gnutls_x509_write_value (asn, 308 MHD__gnutls_x509_write_value (asn,
309 "tbsCertificate.extensions.?LAST.extnValue", 309 "tbsCertificate.extensions.?LAST.extnValue",
310 ext_data, 0); 310 ext_data, 0);
311 if (result < 0) 311 if (result < 0)
312 { 312 {
313 gnutls_assert (); 313 MHD_gnutls_assert ();
314 return result; 314 return result;
315 } 315 }
316 316
@@ -322,7 +322,7 @@ set_extension (ASN1_TYPE asn, const char *extension_id,
322 */ 322 */
323static int 323static int
324overwrite_extension (ASN1_TYPE asn, unsigned int indx, 324overwrite_extension (ASN1_TYPE asn, unsigned int indx,
325 const gnutls_datum_t * ext_data, unsigned int critical) 325 const MHD_gnutls_datum_t * ext_data, unsigned int critical)
326{ 326{
327 char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE]; 327 char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE];
328 const char *str; 328 const char *str;
@@ -335,23 +335,23 @@ overwrite_extension (ASN1_TYPE asn, unsigned int indx,
335 else 335 else
336 str = "TRUE"; 336 str = "TRUE";
337 337
338 mhd_gtls_str_cpy (name2, sizeof (name2), name); 338 MHD_gtls_str_cpy (name2, sizeof (name2), name);
339 mhd_gtls_str_cat (name2, sizeof (name2), ".critical"); 339 MHD_gtls_str_cat (name2, sizeof (name2), ".critical");
340 340
341 result = asn1_write_value (asn, name2, str, 1); 341 result = MHD__asn1_write_value (asn, name2, str, 1);
342 if (result != ASN1_SUCCESS) 342 if (result != ASN1_SUCCESS)
343 { 343 {
344 gnutls_assert (); 344 MHD_gnutls_assert ();
345 return mhd_gtls_asn2err (result); 345 return MHD_gtls_asn2err (result);
346 } 346 }
347 347
348 mhd_gtls_str_cpy (name2, sizeof (name2), name); 348 MHD_gtls_str_cpy (name2, sizeof (name2), name);
349 mhd_gtls_str_cat (name2, sizeof (name2), ".extnValue"); 349 MHD_gtls_str_cat (name2, sizeof (name2), ".extnValue");
350 350
351 result = _gnutls_x509_write_value (asn, name2, ext_data, 0); 351 result = MHD__gnutls_x509_write_value (asn, name2, ext_data, 0);
352 if (result < 0) 352 if (result < 0)
353 { 353 {
354 gnutls_assert (); 354 MHD_gnutls_assert ();
355 return result; 355 return result;
356 } 356 }
357 357
@@ -364,9 +364,9 @@ overwrite_extension (ASN1_TYPE asn, unsigned int indx,
364 * Critical will be either 0 or 1. 364 * Critical will be either 0 or 1.
365 */ 365 */
366int 366int
367_gnutls_x509_crt_set_extension (gnutls_x509_crt_t cert, 367MHD__gnutls_x509_crt_set_extension (MHD_gnutls_x509_crt_t cert,
368 const char *ext_id, 368 const char *ext_id,
369 const gnutls_datum_t * ext_data, 369 const MHD_gnutls_datum_t * ext_data,
370 unsigned int critical) 370 unsigned int critical)
371{ 371{
372 int result; 372 int result;
@@ -384,7 +384,7 @@ _gnutls_x509_crt_set_extension (gnutls_x509_crt_t cert,
384 snprintf (name, sizeof (name), "tbsCertificate.extensions.?%u", k); 384 snprintf (name, sizeof (name), "tbsCertificate.extensions.?%u", k);
385 385
386 len = sizeof (extnID) - 1; 386 len = sizeof (extnID) - 1;
387 result = asn1_read_value (cert->cert, name, extnID, &len); 387 result = MHD__asn1_read_value (cert->cert, name, extnID, &len);
388 388
389 /* move to next 389 /* move to next
390 */ 390 */
@@ -397,21 +397,21 @@ _gnutls_x509_crt_set_extension (gnutls_x509_crt_t cert,
397 do 397 do
398 { 398 {
399 399
400 mhd_gtls_str_cpy (name2, sizeof (name2), name); 400 MHD_gtls_str_cpy (name2, sizeof (name2), name);
401 mhd_gtls_str_cat (name2, sizeof (name2), ".extnID"); 401 MHD_gtls_str_cat (name2, sizeof (name2), ".extnID");
402 402
403 len = sizeof (extnID) - 1; 403 len = sizeof (extnID) - 1;
404 result = asn1_read_value (cert->cert, name2, extnID, &len); 404 result = MHD__asn1_read_value (cert->cert, name2, extnID, &len);
405 405
406 if (result == ASN1_ELEMENT_NOT_FOUND) 406 if (result == ASN1_ELEMENT_NOT_FOUND)
407 { 407 {
408 gnutls_assert (); 408 MHD_gnutls_assert ();
409 break; 409 break;
410 } 410 }
411 else if (result != ASN1_SUCCESS) 411 else if (result != ASN1_SUCCESS)
412 { 412 {
413 gnutls_assert (); 413 MHD_gnutls_assert ();
414 return mhd_gtls_asn2err (result); 414 return MHD_gtls_asn2err (result);
415 } 415 }
416 416
417 /* Handle Extension 417 /* Handle Extension
@@ -435,8 +435,8 @@ _gnutls_x509_crt_set_extension (gnutls_x509_crt_t cert,
435 } 435 }
436 else 436 else
437 { 437 {
438 gnutls_assert (); 438 MHD_gnutls_assert ();
439 return mhd_gtls_asn2err (result); 439 return MHD_gtls_asn2err (result);
440 } 440 }
441 441
442 442
@@ -448,7 +448,7 @@ _gnutls_x509_crt_set_extension (gnutls_x509_crt_t cert,
448 * extension. 448 * extension.
449 */ 449 */
450int 450int
451_gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage, 451MHD__gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage,
452 opaque * extnValue, int extnValueLen) 452 opaque * extnValue, int extnValueLen)
453{ 453{
454 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 454 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
@@ -458,34 +458,34 @@ _gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage,
458 str[0] = str[1] = 0; 458 str[0] = str[1] = 0;
459 *keyUsage = 0; 459 *keyUsage = 0;
460 460
461 if ((result = asn1_create_element 461 if ((result = MHD__asn1_create_element
462 (_gnutls_get_pkix (), "PKIX1.KeyUsage", &ext)) != ASN1_SUCCESS) 462 (MHD__gnutls_get_pkix (), "PKIX1.KeyUsage", &ext)) != ASN1_SUCCESS)
463 { 463 {
464 gnutls_assert (); 464 MHD_gnutls_assert ();
465 return mhd_gtls_asn2err (result); 465 return MHD_gtls_asn2err (result);
466 } 466 }
467 467
468 result = asn1_der_decoding (&ext, extnValue, extnValueLen, NULL); 468 result = MHD__asn1_der_decoding (&ext, extnValue, extnValueLen, NULL);
469 469
470 if (result != ASN1_SUCCESS) 470 if (result != ASN1_SUCCESS)
471 { 471 {
472 gnutls_assert (); 472 MHD_gnutls_assert ();
473 asn1_delete_structure (&ext); 473 MHD__asn1_delete_structure (&ext);
474 return mhd_gtls_asn2err (result); 474 return MHD_gtls_asn2err (result);
475 } 475 }
476 476
477 len = sizeof (str); 477 len = sizeof (str);
478 result = asn1_read_value (ext, "", str, &len); 478 result = MHD__asn1_read_value (ext, "", str, &len);
479 if (result != ASN1_SUCCESS) 479 if (result != ASN1_SUCCESS)
480 { 480 {
481 gnutls_assert (); 481 MHD_gnutls_assert ();
482 asn1_delete_structure (&ext); 482 MHD__asn1_delete_structure (&ext);
483 return 0; 483 return 0;
484 } 484 }
485 485
486 *keyUsage = str[0] | (str[1] << 8); 486 *keyUsage = str[0] | (str[1] << 8);
487 487
488 asn1_delete_structure (&ext); 488 MHD__asn1_delete_structure (&ext);
489 489
490 return 0; 490 return 0;
491} 491}
@@ -493,7 +493,7 @@ _gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage,
493/* extract the basicConstraints from the DER encoded extension 493/* extract the basicConstraints from the DER encoded extension
494 */ 494 */
495int 495int
496_gnutls_x509_ext_extract_basicConstraints (int *CA, 496MHD__gnutls_x509_ext_extract_basicConstraints (int *CA,
497 int *pathLenConstraint, 497 int *pathLenConstraint,
498 opaque * extnValue, 498 opaque * extnValue,
499 int extnValueLen) 499 int extnValueLen)
@@ -502,45 +502,45 @@ _gnutls_x509_ext_extract_basicConstraints (int *CA,
502 char str[128]; 502 char str[128];
503 int len, result; 503 int len, result;
504 504
505 if ((result = asn1_create_element 505 if ((result = MHD__asn1_create_element
506 (_gnutls_get_pkix (), "PKIX1.BasicConstraints", &ext)) != ASN1_SUCCESS) 506 (MHD__gnutls_get_pkix (), "PKIX1.BasicConstraints", &ext)) != ASN1_SUCCESS)
507 { 507 {
508 gnutls_assert (); 508 MHD_gnutls_assert ();
509 return mhd_gtls_asn2err (result); 509 return MHD_gtls_asn2err (result);
510 } 510 }
511 511
512 result = asn1_der_decoding (&ext, extnValue, extnValueLen, NULL); 512 result = MHD__asn1_der_decoding (&ext, extnValue, extnValueLen, NULL);
513 if (result != ASN1_SUCCESS) 513 if (result != ASN1_SUCCESS)
514 { 514 {
515 gnutls_assert (); 515 MHD_gnutls_assert ();
516 asn1_delete_structure (&ext); 516 MHD__asn1_delete_structure (&ext);
517 return mhd_gtls_asn2err (result); 517 return MHD_gtls_asn2err (result);
518 } 518 }
519 519
520 if (pathLenConstraint) 520 if (pathLenConstraint)
521 { 521 {
522 result = _gnutls_x509_read_uint (ext, "pathLenConstraint", 522 result = MHD__gnutls_x509_read_uint (ext, "pathLenConstraint",
523 pathLenConstraint); 523 pathLenConstraint);
524 if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) 524 if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
525 *pathLenConstraint = -1; 525 *pathLenConstraint = -1;
526 else if (result != GNUTLS_E_SUCCESS) 526 else if (result != GNUTLS_E_SUCCESS)
527 { 527 {
528 gnutls_assert (); 528 MHD_gnutls_assert ();
529 asn1_delete_structure (&ext); 529 MHD__asn1_delete_structure (&ext);
530 return mhd_gtls_asn2err (result); 530 return MHD_gtls_asn2err (result);
531 } 531 }
532 } 532 }
533 533
534 /* the default value of cA is false. 534 /* the default value of cA is false.
535 */ 535 */
536 len = sizeof (str) - 1; 536 len = sizeof (str) - 1;
537 result = asn1_read_value (ext, "cA", str, &len); 537 result = MHD__asn1_read_value (ext, "cA", str, &len);
538 if (result == ASN1_SUCCESS && strcmp (str, "TRUE") == 0) 538 if (result == ASN1_SUCCESS && strcmp (str, "TRUE") == 0)
539 *CA = 1; 539 *CA = 1;
540 else 540 else
541 *CA = 0; 541 *CA = 0;
542 542
543 asn1_delete_structure (&ext); 543 MHD__asn1_delete_structure (&ext);
544 544
545 return 0; 545 return 0;
546} 546}
@@ -551,9 +551,9 @@ _gnutls_x509_ext_extract_basicConstraints (int *CA,
551 * should not be present, >= 0 to indicate set values. 551 * should not be present, >= 0 to indicate set values.
552 */ 552 */
553int 553int
554_gnutls_x509_ext_gen_basicConstraints (int CA, 554MHD__gnutls_x509_ext_gen_basicConstraints (int CA,
555 int pathLenConstraint, 555 int pathLenConstraint,
556 gnutls_datum_t * der_ext) 556 MHD_gnutls_datum_t * der_ext)
557{ 557{
558 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 558 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
559 const char *str; 559 const char *str;
@@ -565,44 +565,44 @@ _gnutls_x509_ext_gen_basicConstraints (int CA,
565 str = "TRUE"; 565 str = "TRUE";
566 566
567 result = 567 result =
568 asn1_create_element (_gnutls_get_pkix (), "PKIX1.BasicConstraints", &ext); 568 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.BasicConstraints", &ext);
569 if (result != ASN1_SUCCESS) 569 if (result != ASN1_SUCCESS)
570 { 570 {
571 gnutls_assert (); 571 MHD_gnutls_assert ();
572 return mhd_gtls_asn2err (result); 572 return MHD_gtls_asn2err (result);
573 } 573 }
574 574
575 result = asn1_write_value (ext, "cA", str, 1); 575 result = MHD__asn1_write_value (ext, "cA", str, 1);
576 if (result != ASN1_SUCCESS) 576 if (result != ASN1_SUCCESS)
577 { 577 {
578 gnutls_assert (); 578 MHD_gnutls_assert ();
579 asn1_delete_structure (&ext); 579 MHD__asn1_delete_structure (&ext);
580 return mhd_gtls_asn2err (result); 580 return MHD_gtls_asn2err (result);
581 } 581 }
582 582
583 if (pathLenConstraint < 0) 583 if (pathLenConstraint < 0)
584 { 584 {
585 result = asn1_write_value (ext, "pathLenConstraint", NULL, 0); 585 result = MHD__asn1_write_value (ext, "pathLenConstraint", NULL, 0);
586 if (result < 0) 586 if (result < 0)
587 result = mhd_gtls_asn2err (result); 587 result = MHD_gtls_asn2err (result);
588 } 588 }
589 else 589 else
590 result = _gnutls_x509_write_uint32 (ext, "pathLenConstraint", 590 result = MHD__gnutls_x509_write_uint32 (ext, "pathLenConstraint",
591 pathLenConstraint); 591 pathLenConstraint);
592 if (result < 0) 592 if (result < 0)
593 { 593 {
594 gnutls_assert (); 594 MHD_gnutls_assert ();
595 asn1_delete_structure (&ext); 595 MHD__asn1_delete_structure (&ext);
596 return result; 596 return result;
597 } 597 }
598 598
599 result = _gnutls_x509_der_encode (ext, "", der_ext, 0); 599 result = MHD__gnutls_x509_der_encode (ext, "", der_ext, 0);
600 600
601 asn1_delete_structure (&ext); 601 MHD__asn1_delete_structure (&ext);
602 602
603 if (result < 0) 603 if (result < 0)
604 { 604 {
605 gnutls_assert (); 605 MHD_gnutls_assert ();
606 return result; 606 return result;
607 } 607 }
608 608
@@ -613,37 +613,37 @@ _gnutls_x509_ext_gen_basicConstraints (int CA,
613 * Use an ORed SEQUENCE of GNUTLS_KEY_* for usage. 613 * Use an ORed SEQUENCE of GNUTLS_KEY_* for usage.
614 */ 614 */
615int 615int
616_gnutls_x509_ext_gen_keyUsage (uint16_t usage, gnutls_datum_t * der_ext) 616MHD__gnutls_x509_ext_gen_keyUsage (uint16_t usage, MHD_gnutls_datum_t * der_ext)
617{ 617{
618 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 618 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
619 int result; 619 int result;
620 uint8_t str[2]; 620 uint8_t str[2];
621 621
622 result = asn1_create_element (_gnutls_get_pkix (), "PKIX1.KeyUsage", &ext); 622 result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.KeyUsage", &ext);
623 if (result != ASN1_SUCCESS) 623 if (result != ASN1_SUCCESS)
624 { 624 {
625 gnutls_assert (); 625 MHD_gnutls_assert ();
626 return mhd_gtls_asn2err (result); 626 return MHD_gtls_asn2err (result);
627 } 627 }
628 628
629 str[0] = usage & 0xff; 629 str[0] = usage & 0xff;
630 str[1] = usage >> 8; 630 str[1] = usage >> 8;
631 631
632 result = asn1_write_value (ext, "", str, 9); 632 result = MHD__asn1_write_value (ext, "", str, 9);
633 if (result != ASN1_SUCCESS) 633 if (result != ASN1_SUCCESS)
634 { 634 {
635 gnutls_assert (); 635 MHD_gnutls_assert ();
636 asn1_delete_structure (&ext); 636 MHD__asn1_delete_structure (&ext);
637 return mhd_gtls_asn2err (result); 637 return MHD_gtls_asn2err (result);
638 } 638 }
639 639
640 result = _gnutls_x509_der_encode (ext, "", der_ext, 0); 640 result = MHD__gnutls_x509_der_encode (ext, "", der_ext, 0);
641 641
642 asn1_delete_structure (&ext); 642 MHD__asn1_delete_structure (&ext);
643 643
644 if (result < 0) 644 if (result < 0)
645 { 645 {
646 gnutls_assert (); 646 MHD_gnutls_assert ();
647 return result; 647 return result;
648 } 648 }
649 649
@@ -652,18 +652,18 @@ _gnutls_x509_ext_gen_keyUsage (uint16_t usage, gnutls_datum_t * der_ext)
652 652
653static int 653static int
654write_new_general_name (ASN1_TYPE ext, const char *ext_name, 654write_new_general_name (ASN1_TYPE ext, const char *ext_name,
655 gnutls_x509_subject_alt_name_t type, 655 MHD_gnutls_x509_subject_alt_name_t type,
656 const char *data_string) 656 const char *data_string)
657{ 657{
658 const char *str; 658 const char *str;
659 int result; 659 int result;
660 char name[128]; 660 char name[128];
661 661
662 result = asn1_write_value (ext, ext_name, "NEW", 1); 662 result = MHD__asn1_write_value (ext, ext_name, "NEW", 1);
663 if (result != ASN1_SUCCESS) 663 if (result != ASN1_SUCCESS)
664 { 664 {
665 gnutls_assert (); 665 MHD_gnutls_assert ();
666 return mhd_gtls_asn2err (result); 666 return MHD_gtls_asn2err (result);
667 } 667 }
668 668
669 switch (type) 669 switch (type)
@@ -681,36 +681,36 @@ write_new_general_name (ASN1_TYPE ext, const char *ext_name,
681 str = "iPAddress"; 681 str = "iPAddress";
682 break; 682 break;
683 default: 683 default:
684 gnutls_assert (); 684 MHD_gnutls_assert ();
685 return GNUTLS_E_INTERNAL_ERROR; 685 return GNUTLS_E_INTERNAL_ERROR;
686 } 686 }
687 687
688 if (ext_name[0] == 0) 688 if (ext_name[0] == 0)
689 { /* no dot */ 689 { /* no dot */
690 mhd_gtls_str_cpy (name, sizeof (name), "?LAST"); 690 MHD_gtls_str_cpy (name, sizeof (name), "?LAST");
691 } 691 }
692 else 692 else
693 { 693 {
694 mhd_gtls_str_cpy (name, sizeof (name), ext_name); 694 MHD_gtls_str_cpy (name, sizeof (name), ext_name);
695 mhd_gtls_str_cat (name, sizeof (name), ".?LAST"); 695 MHD_gtls_str_cat (name, sizeof (name), ".?LAST");
696 } 696 }
697 697
698 result = asn1_write_value (ext, name, str, 1); 698 result = MHD__asn1_write_value (ext, name, str, 1);
699 if (result != ASN1_SUCCESS) 699 if (result != ASN1_SUCCESS)
700 { 700 {
701 gnutls_assert (); 701 MHD_gnutls_assert ();
702 return mhd_gtls_asn2err (result); 702 return MHD_gtls_asn2err (result);
703 } 703 }
704 704
705 mhd_gtls_str_cat (name, sizeof (name), "."); 705 MHD_gtls_str_cat (name, sizeof (name), ".");
706 mhd_gtls_str_cat (name, sizeof (name), str); 706 MHD_gtls_str_cat (name, sizeof (name), str);
707 707
708 result = asn1_write_value (ext, name, data_string, strlen (data_string)); 708 result = MHD__asn1_write_value (ext, name, data_string, strlen (data_string));
709 if (result != ASN1_SUCCESS) 709 if (result != ASN1_SUCCESS)
710 { 710 {
711 gnutls_assert (); 711 MHD_gnutls_assert ();
712 asn1_delete_structure (&ext); 712 MHD__asn1_delete_structure (&ext);
713 return mhd_gtls_asn2err (result); 713 return MHD_gtls_asn2err (result);
714 } 714 }
715 715
716 return 0; 716 return 0;
@@ -720,36 +720,36 @@ write_new_general_name (ASN1_TYPE ext, const char *ext_name,
720 * This is the same as subject alternative name. 720 * This is the same as subject alternative name.
721 */ 721 */
722int 722int
723_gnutls_x509_ext_gen_subject_alt_name (gnutls_x509_subject_alt_name_t 723MHD__gnutls_x509_ext_gen_subject_alt_name (MHD_gnutls_x509_subject_alt_name_t
724 type, const char *data_string, 724 type, const char *data_string,
725 gnutls_datum_t * der_ext) 725 MHD_gnutls_datum_t * der_ext)
726{ 726{
727 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 727 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
728 int result; 728 int result;
729 729
730 result = 730 result =
731 asn1_create_element (_gnutls_get_pkix (), "PKIX1.GeneralNames", &ext); 731 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.GeneralNames", &ext);
732 if (result != ASN1_SUCCESS) 732 if (result != ASN1_SUCCESS)
733 { 733 {
734 gnutls_assert (); 734 MHD_gnutls_assert ();
735 return mhd_gtls_asn2err (result); 735 return MHD_gtls_asn2err (result);
736 } 736 }
737 737
738 result = write_new_general_name (ext, "", type, data_string); 738 result = write_new_general_name (ext, "", type, data_string);
739 if (result < 0) 739 if (result < 0)
740 { 740 {
741 gnutls_assert (); 741 MHD_gnutls_assert ();
742 asn1_delete_structure (&ext); 742 MHD__asn1_delete_structure (&ext);
743 return result; 743 return result;
744 } 744 }
745 745
746 result = _gnutls_x509_der_encode (ext, "", der_ext, 0); 746 result = MHD__gnutls_x509_der_encode (ext, "", der_ext, 0);
747 747
748 asn1_delete_structure (&ext); 748 MHD__asn1_delete_structure (&ext);
749 749
750 if (result < 0) 750 if (result < 0)
751 { 751 {
752 gnutls_assert (); 752 MHD_gnutls_assert ();
753 return result; 753 return result;
754 } 754 }
755 755
@@ -759,36 +759,36 @@ _gnutls_x509_ext_gen_subject_alt_name (gnutls_x509_subject_alt_name_t
759/* generate the SubjectKeyID in a DER encoded extension 759/* generate the SubjectKeyID in a DER encoded extension
760 */ 760 */
761int 761int
762_gnutls_x509_ext_gen_key_id (const void *id, size_t id_size, 762MHD__gnutls_x509_ext_gen_key_id (const void *id, size_t id_size,
763 gnutls_datum_t * der_ext) 763 MHD_gnutls_datum_t * der_ext)
764{ 764{
765 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 765 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
766 int result; 766 int result;
767 767
768 result = 768 result =
769 asn1_create_element (_gnutls_get_pkix (), 769 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
770 "PKIX1.SubjectKeyIdentifier", &ext); 770 "PKIX1.SubjectKeyIdentifier", &ext);
771 if (result != ASN1_SUCCESS) 771 if (result != ASN1_SUCCESS)
772 { 772 {
773 gnutls_assert (); 773 MHD_gnutls_assert ();
774 return mhd_gtls_asn2err (result); 774 return MHD_gtls_asn2err (result);
775 } 775 }
776 776
777 result = asn1_write_value (ext, "", id, id_size); 777 result = MHD__asn1_write_value (ext, "", id, id_size);
778 if (result != ASN1_SUCCESS) 778 if (result != ASN1_SUCCESS)
779 { 779 {
780 gnutls_assert (); 780 MHD_gnutls_assert ();
781 asn1_delete_structure (&ext); 781 MHD__asn1_delete_structure (&ext);
782 return mhd_gtls_asn2err (result); 782 return MHD_gtls_asn2err (result);
783 } 783 }
784 784
785 result = _gnutls_x509_der_encode (ext, "", der_ext, 0); 785 result = MHD__gnutls_x509_der_encode (ext, "", der_ext, 0);
786 786
787 asn1_delete_structure (&ext); 787 MHD__asn1_delete_structure (&ext);
788 788
789 if (result < 0) 789 if (result < 0)
790 { 790 {
791 gnutls_assert (); 791 MHD_gnutls_assert ();
792 return result; 792 return result;
793 } 793 }
794 794
@@ -798,39 +798,39 @@ _gnutls_x509_ext_gen_key_id (const void *id, size_t id_size,
798/* generate the AuthorityKeyID in a DER encoded extension 798/* generate the AuthorityKeyID in a DER encoded extension
799 */ 799 */
800int 800int
801_gnutls_x509_ext_gen_auth_key_id (const void *id, size_t id_size, 801MHD__gnutls_x509_ext_gen_auth_key_id (const void *id, size_t id_size,
802 gnutls_datum_t * der_ext) 802 MHD_gnutls_datum_t * der_ext)
803{ 803{
804 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 804 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
805 int result; 805 int result;
806 806
807 result = 807 result =
808 asn1_create_element (_gnutls_get_pkix (), 808 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
809 "PKIX1.AuthorityKeyIdentifier", &ext); 809 "PKIX1.AuthorityKeyIdentifier", &ext);
810 if (result != ASN1_SUCCESS) 810 if (result != ASN1_SUCCESS)
811 { 811 {
812 gnutls_assert (); 812 MHD_gnutls_assert ();
813 return mhd_gtls_asn2err (result); 813 return MHD_gtls_asn2err (result);
814 } 814 }
815 815
816 result = asn1_write_value (ext, "keyIdentifier", id, id_size); 816 result = MHD__asn1_write_value (ext, "keyIdentifier", id, id_size);
817 if (result != ASN1_SUCCESS) 817 if (result != ASN1_SUCCESS)
818 { 818 {
819 gnutls_assert (); 819 MHD_gnutls_assert ();
820 asn1_delete_structure (&ext); 820 MHD__asn1_delete_structure (&ext);
821 return mhd_gtls_asn2err (result); 821 return MHD_gtls_asn2err (result);
822 } 822 }
823 823
824 asn1_write_value (ext, "authorityCertIssuer", NULL, 0); 824 MHD__asn1_write_value (ext, "authorityCertIssuer", NULL, 0);
825 asn1_write_value (ext, "authorityCertSerialNumber", NULL, 0); 825 MHD__asn1_write_value (ext, "authorityCertSerialNumber", NULL, 0);
826 826
827 result = _gnutls_x509_der_encode (ext, "", der_ext, 0); 827 result = MHD__gnutls_x509_der_encode (ext, "", der_ext, 0);
828 828
829 asn1_delete_structure (&ext); 829 MHD__asn1_delete_structure (&ext);
830 830
831 if (result < 0) 831 if (result < 0)
832 { 832 {
833 gnutls_assert (); 833 MHD_gnutls_assert ();
834 return result; 834 return result;
835 } 835 }
836 836
@@ -844,13 +844,13 @@ _gnutls_x509_ext_gen_auth_key_id (const void *id, size_t id_size,
844 * 844 *
845 */ 845 */
846int 846int
847_gnutls_x509_ext_gen_crl_dist_points (gnutls_x509_subject_alt_name_t 847MHD__gnutls_x509_ext_gen_crl_dist_points (MHD_gnutls_x509_subject_alt_name_t
848 type, const void *data_string, 848 type, const void *data_string,
849 unsigned int reason_flags, 849 unsigned int reason_flags,
850 gnutls_datum_t * der_ext) 850 MHD_gnutls_datum_t * der_ext)
851{ 851{
852 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 852 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
853 gnutls_datum_t gnames = { NULL, 0 }; 853 MHD_gnutls_datum_t gnames = { NULL, 0 };
854 int result; 854 int result;
855 uint8_t reasons[2]; 855 uint8_t reasons[2];
856 856
@@ -858,65 +858,65 @@ _gnutls_x509_ext_gen_crl_dist_points (gnutls_x509_subject_alt_name_t
858 reasons[1] = reason_flags >> 8; 858 reasons[1] = reason_flags >> 8;
859 859
860 result = 860 result =
861 asn1_create_element (_gnutls_get_pkix (), 861 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
862 "PKIX1.CRLDistributionPoints", &ext); 862 "PKIX1.CRLDistributionPoints", &ext);
863 if (result != ASN1_SUCCESS) 863 if (result != ASN1_SUCCESS)
864 { 864 {
865 gnutls_assert (); 865 MHD_gnutls_assert ();
866 result = mhd_gtls_asn2err (result); 866 result = MHD_gtls_asn2err (result);
867 goto cleanup; 867 goto cleanup;
868 } 868 }
869 869
870 result = asn1_write_value (ext, "", "NEW", 1); 870 result = MHD__asn1_write_value (ext, "", "NEW", 1);
871 if (result != ASN1_SUCCESS) 871 if (result != ASN1_SUCCESS)
872 { 872 {
873 gnutls_assert (); 873 MHD_gnutls_assert ();
874 result = mhd_gtls_asn2err (result); 874 result = MHD_gtls_asn2err (result);
875 goto cleanup; 875 goto cleanup;
876 } 876 }
877 877
878 if (reason_flags) 878 if (reason_flags)
879 { 879 {
880 result = asn1_write_value (ext, "?LAST.reasons", reasons, 9); 880 result = MHD__asn1_write_value (ext, "?LAST.reasons", reasons, 9);
881 if (result != ASN1_SUCCESS) 881 if (result != ASN1_SUCCESS)
882 { 882 {
883 gnutls_assert (); 883 MHD_gnutls_assert ();
884 result = mhd_gtls_asn2err (result); 884 result = MHD_gtls_asn2err (result);
885 goto cleanup; 885 goto cleanup;
886 } 886 }
887 } 887 }
888 else 888 else
889 { 889 {
890 result = asn1_write_value (ext, "?LAST.reasons", NULL, 0); 890 result = MHD__asn1_write_value (ext, "?LAST.reasons", NULL, 0);
891 if (result != ASN1_SUCCESS) 891 if (result != ASN1_SUCCESS)
892 { 892 {
893 gnutls_assert (); 893 MHD_gnutls_assert ();
894 result = mhd_gtls_asn2err (result); 894 result = MHD_gtls_asn2err (result);
895 goto cleanup; 895 goto cleanup;
896 } 896 }
897 } 897 }
898 898
899 result = asn1_write_value (ext, "?LAST.cRLIssuer", NULL, 0); 899 result = MHD__asn1_write_value (ext, "?LAST.cRLIssuer", NULL, 0);
900 if (result != ASN1_SUCCESS) 900 if (result != ASN1_SUCCESS)
901 { 901 {
902 gnutls_assert (); 902 MHD_gnutls_assert ();
903 result = mhd_gtls_asn2err (result); 903 result = MHD_gtls_asn2err (result);
904 goto cleanup; 904 goto cleanup;
905 } 905 }
906 906
907 /* When used as type CHOICE. 907 /* When used as type CHOICE.
908 */ 908 */
909 result = asn1_write_value (ext, "?LAST.distributionPoint", "fullName", 1); 909 result = MHD__asn1_write_value (ext, "?LAST.distributionPoint", "fullName", 1);
910 if (result != ASN1_SUCCESS) 910 if (result != ASN1_SUCCESS)
911 { 911 {
912 gnutls_assert (); 912 MHD_gnutls_assert ();
913 result = mhd_gtls_asn2err (result); 913 result = MHD_gtls_asn2err (result);
914 goto cleanup; 914 goto cleanup;
915 } 915 }
916 916
917#if 0 917#if 0
918 /* only needed in old code (where defined as SEQUENCE OF) */ 918 /* only needed in old code (where defined as SEQUENCE OF) */
919 asn1_write_value (ext, 919 MHD__asn1_write_value (ext,
920 "?LAST.distributionPoint.nameRelativeToCRLIssuer", 920 "?LAST.distributionPoint.nameRelativeToCRLIssuer",
921 NULL, 0); 921 NULL, 0);
922#endif 922#endif
@@ -926,23 +926,23 @@ _gnutls_x509_ext_gen_crl_dist_points (gnutls_x509_subject_alt_name_t
926 type, data_string); 926 type, data_string);
927 if (result < 0) 927 if (result < 0)
928 { 928 {
929 gnutls_assert (); 929 MHD_gnutls_assert ();
930 goto cleanup; 930 goto cleanup;
931 } 931 }
932 932
933 result = _gnutls_x509_der_encode (ext, "", der_ext, 0); 933 result = MHD__gnutls_x509_der_encode (ext, "", der_ext, 0);
934 934
935 if (result < 0) 935 if (result < 0)
936 { 936 {
937 gnutls_assert (); 937 MHD_gnutls_assert ();
938 goto cleanup; 938 goto cleanup;
939 } 939 }
940 940
941 result = 0; 941 result = 0;
942 942
943cleanup: 943cleanup:
944 _gnutls_free_datum (&gnames); 944 MHD__gnutls_free_datum (&gnames);
945 asn1_delete_structure (&ext); 945 MHD__asn1_delete_structure (&ext);
946 946
947 return result; 947 return result;
948} 948}
@@ -950,7 +950,7 @@ cleanup:
950/* extract the proxyCertInfo from the DER encoded extension 950/* extract the proxyCertInfo from the DER encoded extension
951 */ 951 */
952int 952int
953_gnutls_x509_ext_extract_proxyCertInfo (int *pathLenConstraint, 953MHD__gnutls_x509_ext_extract_proxyCertInfo (int *pathLenConstraint,
954 char **policyLanguage, 954 char **policyLanguage,
955 char **policy, 955 char **policy,
956 size_t * sizeof_policy, 956 size_t * sizeof_policy,
@@ -958,49 +958,49 @@ _gnutls_x509_ext_extract_proxyCertInfo (int *pathLenConstraint,
958{ 958{
959 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 959 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
960 int result; 960 int result;
961 gnutls_datum_t value; 961 MHD_gnutls_datum_t value;
962 962
963 if ((result = asn1_create_element 963 if ((result = MHD__asn1_create_element
964 (_gnutls_get_pkix (), "PKIX1.ProxyCertInfo", &ext)) != ASN1_SUCCESS) 964 (MHD__gnutls_get_pkix (), "PKIX1.ProxyCertInfo", &ext)) != ASN1_SUCCESS)
965 { 965 {
966 gnutls_assert (); 966 MHD_gnutls_assert ();
967 return mhd_gtls_asn2err (result); 967 return MHD_gtls_asn2err (result);
968 } 968 }
969 969
970 result = asn1_der_decoding (&ext, extnValue, extnValueLen, NULL); 970 result = MHD__asn1_der_decoding (&ext, extnValue, extnValueLen, NULL);
971 if (result != ASN1_SUCCESS) 971 if (result != ASN1_SUCCESS)
972 { 972 {
973 gnutls_assert (); 973 MHD_gnutls_assert ();
974 asn1_delete_structure (&ext); 974 MHD__asn1_delete_structure (&ext);
975 return mhd_gtls_asn2err (result); 975 return MHD_gtls_asn2err (result);
976 } 976 }
977 977
978 if (pathLenConstraint) 978 if (pathLenConstraint)
979 { 979 {
980 result = _gnutls_x509_read_uint (ext, "pCPathLenConstraint", 980 result = MHD__gnutls_x509_read_uint (ext, "pCPathLenConstraint",
981 pathLenConstraint); 981 pathLenConstraint);
982 if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) 982 if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
983 *pathLenConstraint = -1; 983 *pathLenConstraint = -1;
984 else if (result != GNUTLS_E_SUCCESS) 984 else if (result != GNUTLS_E_SUCCESS)
985 { 985 {
986 asn1_delete_structure (&ext); 986 MHD__asn1_delete_structure (&ext);
987 return mhd_gtls_asn2err (result); 987 return MHD_gtls_asn2err (result);
988 } 988 }
989 } 989 }
990 990
991 result = _gnutls_x509_read_value (ext, "proxyPolicy.policyLanguage", 991 result = MHD__gnutls_x509_read_value (ext, "proxyPolicy.policyLanguage",
992 &value, 0); 992 &value, 0);
993 if (result < 0) 993 if (result < 0)
994 { 994 {
995 gnutls_assert (); 995 MHD_gnutls_assert ();
996 asn1_delete_structure (&ext); 996 MHD__asn1_delete_structure (&ext);
997 return result; 997 return result;
998 } 998 }
999 999
1000 if (policyLanguage) 1000 if (policyLanguage)
1001 *policyLanguage = gnutls_strdup (value.data); 1001 *policyLanguage = MHD_gnutls_strdup (value.data);
1002 1002
1003 result = _gnutls_x509_read_value (ext, "proxyPolicy.policy", &value, 0); 1003 result = MHD__gnutls_x509_read_value (ext, "proxyPolicy.policy", &value, 0);
1004 if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) 1004 if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
1005 { 1005 {
1006 if (policy) 1006 if (policy)
@@ -1010,8 +1010,8 @@ _gnutls_x509_ext_extract_proxyCertInfo (int *pathLenConstraint,
1010 } 1010 }
1011 else if (result < 0) 1011 else if (result < 0)
1012 { 1012 {
1013 gnutls_assert (); 1013 MHD_gnutls_assert ();
1014 asn1_delete_structure (&ext); 1014 MHD__asn1_delete_structure (&ext);
1015 return result; 1015 return result;
1016 } 1016 }
1017 else 1017 else
@@ -1022,7 +1022,7 @@ _gnutls_x509_ext_extract_proxyCertInfo (int *pathLenConstraint,
1022 *sizeof_policy = value.size; 1022 *sizeof_policy = value.size;
1023 } 1023 }
1024 1024
1025 asn1_delete_structure (&ext); 1025 MHD__asn1_delete_structure (&ext);
1026 1026
1027 return 0; 1027 return 0;
1028} 1028}
@@ -1030,64 +1030,64 @@ _gnutls_x509_ext_extract_proxyCertInfo (int *pathLenConstraint,
1030/* generate the proxyCertInfo in a DER encoded extension 1030/* generate the proxyCertInfo in a DER encoded extension
1031 */ 1031 */
1032int 1032int
1033_gnutls_x509_ext_gen_proxyCertInfo (int pathLenConstraint, 1033MHD__gnutls_x509_ext_gen_proxyCertInfo (int pathLenConstraint,
1034 const char *policyLanguage, 1034 const char *policyLanguage,
1035 const char *policy, 1035 const char *policy,
1036 size_t sizeof_policy, 1036 size_t sizeof_policy,
1037 gnutls_datum_t * der_ext) 1037 MHD_gnutls_datum_t * der_ext)
1038{ 1038{
1039 ASN1_TYPE ext = ASN1_TYPE_EMPTY; 1039 ASN1_TYPE ext = ASN1_TYPE_EMPTY;
1040 int result; 1040 int result;
1041 1041
1042 result = asn1_create_element (_gnutls_get_pkix (), 1042 result = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1043 "PKIX1.ProxyCertInfo", &ext); 1043 "PKIX1.ProxyCertInfo", &ext);
1044 if (result != ASN1_SUCCESS) 1044 if (result != ASN1_SUCCESS)
1045 { 1045 {
1046 gnutls_assert (); 1046 MHD_gnutls_assert ();
1047 return mhd_gtls_asn2err (result); 1047 return MHD_gtls_asn2err (result);
1048 } 1048 }
1049 1049
1050 if (pathLenConstraint < 0) 1050 if (pathLenConstraint < 0)
1051 { 1051 {
1052 result = asn1_write_value (ext, "pCPathLenConstraint", NULL, 0); 1052 result = MHD__asn1_write_value (ext, "pCPathLenConstraint", NULL, 0);
1053 if (result < 0) 1053 if (result < 0)
1054 result = mhd_gtls_asn2err (result); 1054 result = MHD_gtls_asn2err (result);
1055 } 1055 }
1056 else 1056 else
1057 result = _gnutls_x509_write_uint32 (ext, "pCPathLenConstraint", 1057 result = MHD__gnutls_x509_write_uint32 (ext, "pCPathLenConstraint",
1058 pathLenConstraint); 1058 pathLenConstraint);
1059 if (result < 0) 1059 if (result < 0)
1060 { 1060 {
1061 gnutls_assert (); 1061 MHD_gnutls_assert ();
1062 asn1_delete_structure (&ext); 1062 MHD__asn1_delete_structure (&ext);
1063 return result; 1063 return result;
1064 } 1064 }
1065 1065
1066 result = asn1_write_value (ext, "proxyPolicy.policyLanguage", 1066 result = MHD__asn1_write_value (ext, "proxyPolicy.policyLanguage",
1067 policyLanguage, 1); 1067 policyLanguage, 1);
1068 if (result < 0) 1068 if (result < 0)
1069 { 1069 {
1070 gnutls_assert (); 1070 MHD_gnutls_assert ();
1071 asn1_delete_structure (&ext); 1071 MHD__asn1_delete_structure (&ext);
1072 return mhd_gtls_asn2err (result); 1072 return MHD_gtls_asn2err (result);
1073 } 1073 }
1074 1074
1075 result = asn1_write_value (ext, "proxyPolicy.policy", 1075 result = MHD__asn1_write_value (ext, "proxyPolicy.policy",
1076 policy, sizeof_policy); 1076 policy, sizeof_policy);
1077 if (result < 0) 1077 if (result < 0)
1078 { 1078 {
1079 gnutls_assert (); 1079 MHD_gnutls_assert ();
1080 asn1_delete_structure (&ext); 1080 MHD__asn1_delete_structure (&ext);
1081 return mhd_gtls_asn2err (result); 1081 return MHD_gtls_asn2err (result);
1082 } 1082 }
1083 1083
1084 result = _gnutls_x509_der_encode (ext, "", der_ext, 0); 1084 result = MHD__gnutls_x509_der_encode (ext, "", der_ext, 0);
1085 1085
1086 asn1_delete_structure (&ext); 1086 MHD__asn1_delete_structure (&ext);
1087 1087
1088 if (result < 0) 1088 if (result < 0)
1089 { 1089 {
1090 gnutls_assert (); 1090 MHD_gnutls_assert ();
1091 return result; 1091 return result;
1092 } 1092 }
1093 1093
diff --git a/src/daemon/https/x509/extensions.h b/src/daemon/https/x509/extensions.h
index 143775a6..b314d0a7 100644
--- a/src/daemon/https/x509/extensions.h
+++ b/src/daemon/https/x509/extensions.h
@@ -22,47 +22,47 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_x509_crt_get_extension (gnutls_x509_crt_t cert, 25int MHD__gnutls_x509_crt_get_extension (MHD_gnutls_x509_crt_t cert,
26 const char *extension_id, int indx, 26 const char *extension_id, int indx,
27 gnutls_datum_t * ret, 27 MHD_gnutls_datum_t * ret,
28 unsigned int *critical); 28 unsigned int *critical);
29 29
30int _gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, 30int MHD__gnutls_x509_crt_get_extension_oid (MHD_gnutls_x509_crt_t cert,
31 int indx, void *ret, 31 int indx, void *ret,
32 size_t * ret_size); 32 size_t * ret_size);
33int _gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage, 33int MHD__gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage,
34 opaque * extnValue, int extnValueLen); 34 opaque * extnValue, int extnValueLen);
35int _gnutls_x509_ext_extract_basicConstraints (int *CA, 35int MHD__gnutls_x509_ext_extract_basicConstraints (int *CA,
36 int *pathLenConstraint, 36 int *pathLenConstraint,
37 opaque * extnValue, 37 opaque * extnValue,
38 int extnValueLen); 38 int extnValueLen);
39int _gnutls_x509_crt_set_extension (gnutls_x509_crt_t cert, 39int MHD__gnutls_x509_crt_set_extension (MHD_gnutls_x509_crt_t cert,
40 const char *extension_id, 40 const char *extension_id,
41 const gnutls_datum_t * ext_data, 41 const MHD_gnutls_datum_t * ext_data,
42 unsigned int critical); 42 unsigned int critical);
43int _gnutls_x509_ext_gen_basicConstraints (int CA, int pathLenConstraint, 43int MHD__gnutls_x509_ext_gen_basicConstraints (int CA, int pathLenConstraint,
44 gnutls_datum_t * der_ext); 44 MHD_gnutls_datum_t * der_ext);
45int _gnutls_x509_ext_gen_keyUsage (uint16_t usage, gnutls_datum_t * der_ext); 45int MHD__gnutls_x509_ext_gen_keyUsage (uint16_t usage, MHD_gnutls_datum_t * der_ext);
46int _gnutls_x509_ext_gen_subject_alt_name (gnutls_x509_subject_alt_name_t 46int MHD__gnutls_x509_ext_gen_subject_alt_name (MHD_gnutls_x509_subject_alt_name_t
47 type, const char *data_string, 47 type, const char *data_string,
48 gnutls_datum_t * der_ext); 48 MHD_gnutls_datum_t * der_ext);
49int _gnutls_x509_ext_gen_crl_dist_points (gnutls_x509_subject_alt_name_t 49int MHD__gnutls_x509_ext_gen_crl_dist_points (MHD_gnutls_x509_subject_alt_name_t
50 type, const void *data_string, 50 type, const void *data_string,
51 unsigned int reason_flags, 51 unsigned int reason_flags,
52 gnutls_datum_t * der_ext); 52 MHD_gnutls_datum_t * der_ext);
53int _gnutls_x509_ext_gen_key_id (const void *id, size_t id_size, 53int MHD__gnutls_x509_ext_gen_key_id (const void *id, size_t id_size,
54 gnutls_datum_t * der_data); 54 MHD_gnutls_datum_t * der_data);
55int _gnutls_x509_ext_gen_auth_key_id (const void *id, size_t id_size, 55int MHD__gnutls_x509_ext_gen_auth_key_id (const void *id, size_t id_size,
56 gnutls_datum_t * der_data); 56 MHD_gnutls_datum_t * der_data);
57 57
58int _gnutls_x509_ext_extract_proxyCertInfo (int *pathLenConstraint, 58int MHD__gnutls_x509_ext_extract_proxyCertInfo (int *pathLenConstraint,
59 char **policyLanguage, 59 char **policyLanguage,
60 char **policy, 60 char **policy,
61 size_t * sizeof_policy, 61 size_t * sizeof_policy,
62 opaque * extnValue, 62 opaque * extnValue,
63 int extnValueLen); 63 int extnValueLen);
64int _gnutls_x509_ext_gen_proxyCertInfo (int pathLenConstraint, 64int MHD__gnutls_x509_ext_gen_proxyCertInfo (int pathLenConstraint,
65 const char *policyLanguage, 65 const char *policyLanguage,
66 const char *policy, 66 const char *policy,
67 size_t sizeof_policy, 67 size_t sizeof_policy,
68 gnutls_datum_t * der_ext); 68 MHD_gnutls_datum_t * der_ext);
diff --git a/src/daemon/https/x509/mpi.c b/src/daemon/https/x509/mpi.c
index c43b3dce..4e3c8cd1 100644
--- a/src/daemon/https/x509/mpi.c
+++ b/src/daemon/https/x509/mpi.c
@@ -38,45 +38,45 @@
38 * Returns 2 parameters (m,e). 38 * Returns 2 parameters (m,e).
39 */ 39 */
40int 40int
41_gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params) 41MHD__gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params)
42{ 42{
43 int result; 43 int result;
44 ASN1_TYPE spk = ASN1_TYPE_EMPTY; 44 ASN1_TYPE spk = ASN1_TYPE_EMPTY;
45 45
46 if ((result = 46 if ((result =
47 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.RSAPublicKey", 47 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.RSAPublicKey",
48 &spk)) != ASN1_SUCCESS) 48 &spk)) != ASN1_SUCCESS)
49 { 49 {
50 gnutls_assert (); 50 MHD_gnutls_assert ();
51 return mhd_gtls_asn2err (result); 51 return MHD_gtls_asn2err (result);
52 } 52 }
53 53
54 result = asn1_der_decoding (&spk, der, dersize, NULL); 54 result = MHD__asn1_der_decoding (&spk, der, dersize, NULL);
55 55
56 if (result != ASN1_SUCCESS) 56 if (result != ASN1_SUCCESS)
57 { 57 {
58 gnutls_assert (); 58 MHD_gnutls_assert ();
59 asn1_delete_structure (&spk); 59 MHD__asn1_delete_structure (&spk);
60 return mhd_gtls_asn2err (result); 60 return MHD_gtls_asn2err (result);
61 } 61 }
62 62
63 if ((result = _gnutls_x509_read_int (spk, "modulus", &params[0])) < 0) 63 if ((result = MHD__gnutls_x509_read_int (spk, "modulus", &params[0])) < 0)
64 { 64 {
65 gnutls_assert (); 65 MHD_gnutls_assert ();
66 asn1_delete_structure (&spk); 66 MHD__asn1_delete_structure (&spk);
67 return GNUTLS_E_ASN1_GENERIC_ERROR; 67 return GNUTLS_E_ASN1_GENERIC_ERROR;
68 } 68 }
69 69
70 if ((result = 70 if ((result =
71 _gnutls_x509_read_int (spk, "publicExponent", &params[1])) < 0) 71 MHD__gnutls_x509_read_int (spk, "publicExponent", &params[1])) < 0)
72 { 72 {
73 gnutls_assert (); 73 MHD_gnutls_assert ();
74 mhd_gtls_mpi_release (&params[0]); 74 MHD_gtls_mpi_release (&params[0]);
75 asn1_delete_structure (&spk); 75 MHD__asn1_delete_structure (&spk);
76 return GNUTLS_E_ASN1_GENERIC_ERROR; 76 return GNUTLS_E_ASN1_GENERIC_ERROR;
77 } 77 }
78 78
79 asn1_delete_structure (&spk); 79 MHD__asn1_delete_structure (&spk);
80 80
81 return 0; 81 return 0;
82 82
@@ -87,26 +87,26 @@ _gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params)
87 * params[0-2] 87 * params[0-2]
88 */ 88 */
89int 89int
90_gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params) 90MHD__gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params)
91{ 91{
92 int result; 92 int result;
93 ASN1_TYPE spk = ASN1_TYPE_EMPTY; 93 ASN1_TYPE spk = ASN1_TYPE_EMPTY;
94 94
95 if ((result = 95 if ((result =
96 asn1_create_element (_gnutls_get_pkix (), "PKIX1.Dss-Parms", 96 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.Dss-Parms",
97 &spk)) != ASN1_SUCCESS) 97 &spk)) != ASN1_SUCCESS)
98 { 98 {
99 gnutls_assert (); 99 MHD_gnutls_assert ();
100 return mhd_gtls_asn2err (result); 100 return MHD_gtls_asn2err (result);
101 } 101 }
102 102
103 result = asn1_der_decoding (&spk, der, dersize, NULL); 103 result = MHD__asn1_der_decoding (&spk, der, dersize, NULL);
104 104
105 if (result != ASN1_SUCCESS) 105 if (result != ASN1_SUCCESS)
106 { 106 {
107 gnutls_assert (); 107 MHD_gnutls_assert ();
108 asn1_delete_structure (&spk); 108 MHD__asn1_delete_structure (&spk);
109 return mhd_gtls_asn2err (result); 109 return MHD_gtls_asn2err (result);
110 } 110 }
111 111
112 /* FIXME: If the parameters are not included in the certificate 112 /* FIXME: If the parameters are not included in the certificate
@@ -116,35 +116,35 @@ _gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params)
116 116
117 /* Read p */ 117 /* Read p */
118 118
119 if ((result = _gnutls_x509_read_int (spk, "p", &params[0])) < 0) 119 if ((result = MHD__gnutls_x509_read_int (spk, "p", &params[0])) < 0)
120 { 120 {
121 gnutls_assert (); 121 MHD_gnutls_assert ();
122 asn1_delete_structure (&spk); 122 MHD__asn1_delete_structure (&spk);
123 return GNUTLS_E_ASN1_GENERIC_ERROR; 123 return GNUTLS_E_ASN1_GENERIC_ERROR;
124 } 124 }
125 125
126 /* Read q */ 126 /* Read q */
127 127
128 if ((result = _gnutls_x509_read_int (spk, "q", &params[1])) < 0) 128 if ((result = MHD__gnutls_x509_read_int (spk, "q", &params[1])) < 0)
129 { 129 {
130 gnutls_assert (); 130 MHD_gnutls_assert ();
131 asn1_delete_structure (&spk); 131 MHD__asn1_delete_structure (&spk);
132 mhd_gtls_mpi_release (&params[0]); 132 MHD_gtls_mpi_release (&params[0]);
133 return GNUTLS_E_ASN1_GENERIC_ERROR; 133 return GNUTLS_E_ASN1_GENERIC_ERROR;
134 } 134 }
135 135
136 /* Read g */ 136 /* Read g */
137 137
138 if ((result = _gnutls_x509_read_int (spk, "g", &params[2])) < 0) 138 if ((result = MHD__gnutls_x509_read_int (spk, "g", &params[2])) < 0)
139 { 139 {
140 gnutls_assert (); 140 MHD_gnutls_assert ();
141 asn1_delete_structure (&spk); 141 MHD__asn1_delete_structure (&spk);
142 mhd_gtls_mpi_release (&params[0]); 142 MHD_gtls_mpi_release (&params[0]);
143 mhd_gtls_mpi_release (&params[1]); 143 MHD_gtls_mpi_release (&params[1]);
144 return GNUTLS_E_ASN1_GENERIC_ERROR; 144 return GNUTLS_E_ASN1_GENERIC_ERROR;
145 } 145 }
146 146
147 asn1_delete_structure (&spk); 147 MHD__asn1_delete_structure (&spk);
148 148
149 return 0; 149 return 0;
150 150
@@ -154,39 +154,39 @@ _gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params)
154 */ 154 */
155 155
156int 156int
157_gnutls_x509_read_der_int (opaque * der, int dersize, mpi_t * out) 157MHD__gnutls_x509_read_der_int (opaque * der, int dersize, mpi_t * out)
158{ 158{
159 int result; 159 int result;
160 ASN1_TYPE spk = ASN1_TYPE_EMPTY; 160 ASN1_TYPE spk = ASN1_TYPE_EMPTY;
161 161
162 /* == INTEGER */ 162 /* == INTEGER */
163 if ((result = 163 if ((result =
164 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.DSAPublicKey", 164 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.DSAPublicKey",
165 &spk)) != ASN1_SUCCESS) 165 &spk)) != ASN1_SUCCESS)
166 { 166 {
167 gnutls_assert (); 167 MHD_gnutls_assert ();
168 return mhd_gtls_asn2err (result); 168 return MHD_gtls_asn2err (result);
169 } 169 }
170 170
171 result = asn1_der_decoding (&spk, der, dersize, NULL); 171 result = MHD__asn1_der_decoding (&spk, der, dersize, NULL);
172 172
173 if (result != ASN1_SUCCESS) 173 if (result != ASN1_SUCCESS)
174 { 174 {
175 gnutls_assert (); 175 MHD_gnutls_assert ();
176 asn1_delete_structure (&spk); 176 MHD__asn1_delete_structure (&spk);
177 return mhd_gtls_asn2err (result); 177 return MHD_gtls_asn2err (result);
178 } 178 }
179 179
180 /* Read Y */ 180 /* Read Y */
181 181
182 if ((result = _gnutls_x509_read_int (spk, "", out)) < 0) 182 if ((result = MHD__gnutls_x509_read_int (spk, "", out)) < 0)
183 { 183 {
184 gnutls_assert (); 184 MHD_gnutls_assert ();
185 asn1_delete_structure (&spk); 185 MHD__asn1_delete_structure (&spk);
186 return mhd_gtls_asn2err (result); 186 return MHD_gtls_asn2err (result);
187 } 187 }
188 188
189 asn1_delete_structure (&spk); 189 MHD__asn1_delete_structure (&spk);
190 190
191 return 0; 191 return 0;
192 192
@@ -197,35 +197,35 @@ _gnutls_x509_read_der_int (opaque * der, int dersize, mpi_t * out)
197 * only sets params[3] 197 * only sets params[3]
198 */ 198 */
199int 199int
200_gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params) 200MHD__gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params)
201{ 201{
202 return _gnutls_x509_read_der_int (der, dersize, &params[3]); 202 return MHD__gnutls_x509_read_der_int (der, dersize, &params[3]);
203} 203}
204 204
205/* Extracts DSA and RSA parameters from a certificate. 205/* Extracts DSA and RSA parameters from a certificate.
206 */ 206 */
207int 207int
208_gnutls_x509_crt_get_mpis (gnutls_x509_crt_t cert, 208MHD__gnutls_x509_crt_get_mpis (MHD_gnutls_x509_crt_t cert,
209 mpi_t * params, int *params_size) 209 mpi_t * params, int *params_size)
210{ 210{
211 int result; 211 int result;
212 int pk_algorithm; 212 int pk_algorithm;
213 gnutls_datum_t tmp = { NULL, 0 }; 213 MHD_gnutls_datum_t tmp = { NULL, 0 };
214 214
215 /* Read the algorithm's OID 215 /* Read the algorithm's OID
216 */ 216 */
217 pk_algorithm = gnutls_x509_crt_get_pk_algorithm (cert, NULL); 217 pk_algorithm = MHD_gnutls_x509_crt_get_pk_algorithm (cert, NULL);
218 218
219 /* Read the algorithm's parameters 219 /* Read the algorithm's parameters
220 */ 220 */
221 result 221 result
222 = _gnutls_x509_read_value (cert->cert, 222 = MHD__gnutls_x509_read_value (cert->cert,
223 "tbsCertificate.subjectPublicKeyInfo.subjectPublicKey", 223 "tbsCertificate.subjectPublicKeyInfo.subjectPublicKey",
224 &tmp, 2); 224 &tmp, 2);
225 225
226 if (result < 0) 226 if (result < 0)
227 { 227 {
228 gnutls_assert (); 228 MHD_gnutls_assert ();
229 return result; 229 return result;
230 } 230 }
231 231
@@ -237,16 +237,16 @@ _gnutls_x509_crt_get_mpis (gnutls_x509_crt_t cert,
237 */ 237 */
238 if (*params_size < RSA_PUBLIC_PARAMS) 238 if (*params_size < RSA_PUBLIC_PARAMS)
239 { 239 {
240 gnutls_assert (); 240 MHD_gnutls_assert ();
241 /* internal error. Increase the mpi_ts in params */ 241 /* internal error. Increase the mpi_ts in params */
242 result = GNUTLS_E_INTERNAL_ERROR; 242 result = GNUTLS_E_INTERNAL_ERROR;
243 goto error; 243 goto error;
244 } 244 }
245 245
246 if ((result = 246 if ((result =
247 _gnutls_x509_read_rsa_params (tmp.data, tmp.size, params)) < 0) 247 MHD__gnutls_x509_read_rsa_params (tmp.data, tmp.size, params)) < 0)
248 { 248 {
249 gnutls_assert (); 249 MHD_gnutls_assert ();
250 goto error; 250 goto error;
251 } 251 }
252 *params_size = RSA_PUBLIC_PARAMS; 252 *params_size = RSA_PUBLIC_PARAMS;
@@ -256,14 +256,14 @@ _gnutls_x509_crt_get_mpis (gnutls_x509_crt_t cert,
256 /* other types like DH 256 /* other types like DH
257 * currently not supported 257 * currently not supported
258 */ 258 */
259 gnutls_assert (); 259 MHD_gnutls_assert ();
260 result = GNUTLS_E_X509_CERTIFICATE_ERROR; 260 result = GNUTLS_E_X509_CERTIFICATE_ERROR;
261 goto error; 261 goto error;
262 } 262 }
263 263
264 result = 0; 264 result = 0;
265 265
266error:_gnutls_free_datum (&tmp); 266error:MHD__gnutls_free_datum (&tmp);
267 return result; 267 return result;
268} 268}
269 269
@@ -275,8 +275,8 @@ error:_gnutls_free_datum (&tmp);
275 * Allocates the space used to store the DER data. 275 * Allocates the space used to store the DER data.
276 */ 276 */
277int 277int
278_gnutls_x509_write_rsa_params (mpi_t * params, 278MHD__gnutls_x509_write_rsa_params (mpi_t * params,
279 int params_size, gnutls_datum_t * der) 279 int params_size, MHD_gnutls_datum_t * der)
280{ 280{
281 int result; 281 int result;
282 ASN1_TYPE spk = ASN1_TYPE_EMPTY; 282 ASN1_TYPE spk = ASN1_TYPE_EMPTY;
@@ -286,44 +286,44 @@ _gnutls_x509_write_rsa_params (mpi_t * params,
286 286
287 if (params_size < 2) 287 if (params_size < 2)
288 { 288 {
289 gnutls_assert (); 289 MHD_gnutls_assert ();
290 result = GNUTLS_E_INVALID_REQUEST; 290 result = GNUTLS_E_INVALID_REQUEST;
291 goto cleanup; 291 goto cleanup;
292 } 292 }
293 293
294 if ((result = 294 if ((result =
295 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.RSAPublicKey", 295 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.RSAPublicKey",
296 &spk)) != ASN1_SUCCESS) 296 &spk)) != ASN1_SUCCESS)
297 { 297 {
298 gnutls_assert (); 298 MHD_gnutls_assert ();
299 return mhd_gtls_asn2err (result); 299 return MHD_gtls_asn2err (result);
300 } 300 }
301 301
302 result = _gnutls_x509_write_int (spk, "modulus", params[0], 0); 302 result = MHD__gnutls_x509_write_int (spk, "modulus", params[0], 0);
303 if (result < 0) 303 if (result < 0)
304 { 304 {
305 gnutls_assert (); 305 MHD_gnutls_assert ();
306 goto cleanup; 306 goto cleanup;
307 } 307 }
308 308
309 result = _gnutls_x509_write_int (spk, "publicExponent", params[1], 0); 309 result = MHD__gnutls_x509_write_int (spk, "publicExponent", params[1], 0);
310 if (result < 0) 310 if (result < 0)
311 { 311 {
312 gnutls_assert (); 312 MHD_gnutls_assert ();
313 goto cleanup; 313 goto cleanup;
314 } 314 }
315 315
316 result = _gnutls_x509_der_encode (spk, "", der, 0); 316 result = MHD__gnutls_x509_der_encode (spk, "", der, 0);
317 if (result < 0) 317 if (result < 0)
318 { 318 {
319 gnutls_assert (); 319 MHD_gnutls_assert ();
320 goto cleanup; 320 goto cleanup;
321 } 321 }
322 322
323 asn1_delete_structure (&spk); 323 MHD__asn1_delete_structure (&spk);
324 return 0; 324 return 0;
325 325
326cleanup:asn1_delete_structure (&spk); 326cleanup:MHD__asn1_delete_structure (&spk);
327 327
328 return result; 328 return result;
329} 329}
@@ -333,7 +333,7 @@ cleanup:asn1_delete_structure (&spk);
333 * This is the "signatureAlgorithm" fields. 333 * This is the "signatureAlgorithm" fields.
334 */ 334 */
335int 335int
336_gnutls_x509_write_sig_params (ASN1_TYPE dst, 336MHD__gnutls_x509_write_sig_params (ASN1_TYPE dst,
337 const char *dst_name, 337 const char *dst_name,
338 enum MHD_GNUTLS_PublicKeyAlgorithm 338 enum MHD_GNUTLS_PublicKeyAlgorithm
339 pk_algorithm, 339 pk_algorithm,
@@ -344,39 +344,39 @@ _gnutls_x509_write_sig_params (ASN1_TYPE dst,
344 char name[128]; 344 char name[128];
345 const char *pk; 345 const char *pk;
346 346
347 mhd_gtls_str_cpy (name, sizeof (name), dst_name); 347 MHD_gtls_str_cpy (name, sizeof (name), dst_name);
348 mhd_gtls_str_cat (name, sizeof (name), ".algorithm"); 348 MHD_gtls_str_cat (name, sizeof (name), ".algorithm");
349 349
350 pk = mhd_gtls_x509_sign_to_oid (pk_algorithm, HASH2MAC (dig)); 350 pk = MHD_gtls_x509_sign_to_oid (pk_algorithm, HASH2MAC (dig));
351 if (pk == NULL) 351 if (pk == NULL)
352 { 352 {
353 gnutls_assert (); 353 MHD_gnutls_assert ();
354 return GNUTLS_E_INVALID_REQUEST; 354 return GNUTLS_E_INVALID_REQUEST;
355 } 355 }
356 356
357 /* write the OID. 357 /* write the OID.
358 */ 358 */
359 result = asn1_write_value (dst, name, pk, 1); 359 result = MHD__asn1_write_value (dst, name, pk, 1);
360 if (result != ASN1_SUCCESS) 360 if (result != ASN1_SUCCESS)
361 { 361 {
362 gnutls_assert (); 362 MHD_gnutls_assert ();
363 return mhd_gtls_asn2err (result); 363 return MHD_gtls_asn2err (result);
364 } 364 }
365 365
366 mhd_gtls_str_cpy (name, sizeof (name), dst_name); 366 MHD_gtls_str_cpy (name, sizeof (name), dst_name);
367 mhd_gtls_str_cat (name, sizeof (name), ".parameters"); 367 MHD_gtls_str_cat (name, sizeof (name), ".parameters");
368 368
369 if (pk_algorithm == MHD_GNUTLS_PK_RSA) 369 if (pk_algorithm == MHD_GNUTLS_PK_RSA)
370 { /* RSA */ 370 { /* RSA */
371 result = asn1_write_value (dst, name, NULL, 0); 371 result = MHD__asn1_write_value (dst, name, NULL, 0);
372 372
373 if (result != ASN1_SUCCESS && result != ASN1_ELEMENT_NOT_FOUND) 373 if (result != ASN1_SUCCESS && result != ASN1_ELEMENT_NOT_FOUND)
374 { 374 {
375 /* Here we ignore the element not found error, since this 375 /* Here we ignore the element not found error, since this
376 * may have been disabled before. 376 * may have been disabled before.
377 */ 377 */
378 gnutls_assert (); 378 MHD_gnutls_assert ();
379 return mhd_gtls_asn2err (result); 379 return MHD_gtls_asn2err (result);
380 } 380 }
381 } 381 }
382 382
@@ -390,8 +390,8 @@ _gnutls_x509_write_sig_params (ASN1_TYPE dst,
390 * Allocates the space used to store the DER data. 390 * Allocates the space used to store the DER data.
391 */ 391 */
392int 392int
393_gnutls_x509_write_dsa_params (mpi_t * params, 393MHD__gnutls_x509_write_dsa_params (mpi_t * params,
394 int params_size, gnutls_datum_t * der) 394 int params_size, MHD_gnutls_datum_t * der)
395{ 395{
396 int result; 396 int result;
397 ASN1_TYPE spk = ASN1_TYPE_EMPTY; 397 ASN1_TYPE spk = ASN1_TYPE_EMPTY;
@@ -401,50 +401,50 @@ _gnutls_x509_write_dsa_params (mpi_t * params,
401 401
402 if (params_size < 3) 402 if (params_size < 3)
403 { 403 {
404 gnutls_assert (); 404 MHD_gnutls_assert ();
405 result = GNUTLS_E_INVALID_REQUEST; 405 result = GNUTLS_E_INVALID_REQUEST;
406 goto cleanup; 406 goto cleanup;
407 } 407 }
408 408
409 if ((result = 409 if ((result =
410 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.DSAParameters", 410 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.DSAParameters",
411 &spk)) != ASN1_SUCCESS) 411 &spk)) != ASN1_SUCCESS)
412 { 412 {
413 gnutls_assert (); 413 MHD_gnutls_assert ();
414 return mhd_gtls_asn2err (result); 414 return MHD_gtls_asn2err (result);
415 } 415 }
416 416
417 result = _gnutls_x509_write_int (spk, "p", params[0], 0); 417 result = MHD__gnutls_x509_write_int (spk, "p", params[0], 0);
418 if (result < 0) 418 if (result < 0)
419 { 419 {
420 gnutls_assert (); 420 MHD_gnutls_assert ();
421 goto cleanup; 421 goto cleanup;
422 } 422 }
423 423
424 result = _gnutls_x509_write_int (spk, "q", params[1], 0); 424 result = MHD__gnutls_x509_write_int (spk, "q", params[1], 0);
425 if (result < 0) 425 if (result < 0)
426 { 426 {
427 gnutls_assert (); 427 MHD_gnutls_assert ();
428 goto cleanup; 428 goto cleanup;
429 } 429 }
430 430
431 result = _gnutls_x509_write_int (spk, "g", params[2], 0); 431 result = MHD__gnutls_x509_write_int (spk, "g", params[2], 0);
432 if (result < 0) 432 if (result < 0)
433 { 433 {
434 gnutls_assert (); 434 MHD_gnutls_assert ();
435 goto cleanup; 435 goto cleanup;
436 } 436 }
437 437
438 result = _gnutls_x509_der_encode (spk, "", der, 0); 438 result = MHD__gnutls_x509_der_encode (spk, "", der, 0);
439 if (result < 0) 439 if (result < 0)
440 { 440 {
441 gnutls_assert (); 441 MHD_gnutls_assert ();
442 goto cleanup; 442 goto cleanup;
443 } 443 }
444 444
445 result = 0; 445 result = 0;
446 446
447cleanup:asn1_delete_structure (&spk); 447cleanup:MHD__asn1_delete_structure (&spk);
448 return result; 448 return result;
449} 449}
450 450
@@ -455,8 +455,8 @@ cleanup:asn1_delete_structure (&spk);
455 * Allocates the space used to store the DER data. 455 * Allocates the space used to store the DER data.
456 */ 456 */
457int 457int
458_gnutls_x509_write_dsa_public_key (mpi_t * params, 458MHD__gnutls_x509_write_dsa_public_key (mpi_t * params,
459 int params_size, gnutls_datum_t * der) 459 int params_size, MHD_gnutls_datum_t * der)
460{ 460{
461 int result; 461 int result;
462 ASN1_TYPE spk = ASN1_TYPE_EMPTY; 462 ASN1_TYPE spk = ASN1_TYPE_EMPTY;
@@ -466,37 +466,37 @@ _gnutls_x509_write_dsa_public_key (mpi_t * params,
466 466
467 if (params_size < 3) 467 if (params_size < 3)
468 { 468 {
469 gnutls_assert (); 469 MHD_gnutls_assert ();
470 result = GNUTLS_E_INVALID_REQUEST; 470 result = GNUTLS_E_INVALID_REQUEST;
471 goto cleanup; 471 goto cleanup;
472 } 472 }
473 473
474 if ((result = 474 if ((result =
475 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.DSAPublicKey", 475 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.DSAPublicKey",
476 &spk)) != ASN1_SUCCESS) 476 &spk)) != ASN1_SUCCESS)
477 { 477 {
478 gnutls_assert (); 478 MHD_gnutls_assert ();
479 return mhd_gtls_asn2err (result); 479 return MHD_gtls_asn2err (result);
480 } 480 }
481 481
482 result = _gnutls_x509_write_int (spk, "", params[3], 0); 482 result = MHD__gnutls_x509_write_int (spk, "", params[3], 0);
483 if (result < 0) 483 if (result < 0)
484 { 484 {
485 gnutls_assert (); 485 MHD_gnutls_assert ();
486 goto cleanup; 486 goto cleanup;
487 } 487 }
488 488
489 result = _gnutls_x509_der_encode (spk, "", der, 0); 489 result = MHD__gnutls_x509_der_encode (spk, "", der, 0);
490 if (result < 0) 490 if (result < 0)
491 { 491 {
492 gnutls_assert (); 492 MHD_gnutls_assert ();
493 goto cleanup; 493 goto cleanup;
494 } 494 }
495 495
496 asn1_delete_structure (&spk); 496 MHD__asn1_delete_structure (&spk);
497 return 0; 497 return 0;
498 498
499cleanup:asn1_delete_structure (&spk); 499cleanup:MHD__asn1_delete_structure (&spk);
500 return result; 500 return result;
501} 501}
502 502
@@ -505,51 +505,51 @@ cleanup:asn1_delete_structure (&spk);
505 * steps. 505 * steps.
506 */ 506 */
507int 507int
508_gnutls_x509_read_uint (ASN1_TYPE node, const char *value, unsigned int *ret) 508MHD__gnutls_x509_read_uint (ASN1_TYPE node, const char *value, unsigned int *ret)
509{ 509{
510 int len, result; 510 int len, result;
511 opaque *tmpstr; 511 opaque *tmpstr;
512 512
513 len = 0; 513 len = 0;
514 result = asn1_read_value (node, value, NULL, &len); 514 result = MHD__asn1_read_value (node, value, NULL, &len);
515 if (result != ASN1_MEM_ERROR) 515 if (result != ASN1_MEM_ERROR)
516 { 516 {
517 gnutls_assert (); 517 MHD_gnutls_assert ();
518 return mhd_gtls_asn2err (result); 518 return MHD_gtls_asn2err (result);
519 } 519 }
520 520
521 tmpstr = gnutls_alloca (len); 521 tmpstr = MHD_gnutls_alloca (len);
522 if (tmpstr == NULL) 522 if (tmpstr == NULL)
523 { 523 {
524 gnutls_assert (); 524 MHD_gnutls_assert ();
525 return GNUTLS_E_MEMORY_ERROR; 525 return GNUTLS_E_MEMORY_ERROR;
526 } 526 }
527 527
528 result = asn1_read_value (node, value, tmpstr, &len); 528 result = MHD__asn1_read_value (node, value, tmpstr, &len);
529 529
530 if (result != ASN1_SUCCESS) 530 if (result != ASN1_SUCCESS)
531 { 531 {
532 gnutls_assert (); 532 MHD_gnutls_assert ();
533 gnutls_afree (tmpstr); 533 MHD_gnutls_afree (tmpstr);
534 return mhd_gtls_asn2err (result); 534 return MHD_gtls_asn2err (result);
535 } 535 }
536 536
537 if (len == 1) 537 if (len == 1)
538 *ret = tmpstr[0]; 538 *ret = tmpstr[0];
539 else if (len == 2) 539 else if (len == 2)
540 *ret = mhd_gtls_read_uint16 (tmpstr); 540 *ret = MHD_gtls_read_uint16 (tmpstr);
541 else if (len == 3) 541 else if (len == 3)
542 *ret = mhd_gtls_read_uint24 (tmpstr); 542 *ret = MHD_gtls_read_uint24 (tmpstr);
543 else if (len == 4) 543 else if (len == 4)
544 *ret = mhd_gtls_read_uint32 (tmpstr); 544 *ret = MHD_gtls_read_uint32 (tmpstr);
545 else 545 else
546 { 546 {
547 gnutls_assert (); 547 MHD_gnutls_assert ();
548 gnutls_afree (tmpstr); 548 MHD_gnutls_afree (tmpstr);
549 return GNUTLS_E_INTERNAL_ERROR; 549 return GNUTLS_E_INTERNAL_ERROR;
550 } 550 }
551 551
552 gnutls_afree (tmpstr); 552 MHD_gnutls_afree (tmpstr);
553 553
554 return 0; 554 return 0;
555} 555}
@@ -557,19 +557,19 @@ _gnutls_x509_read_uint (ASN1_TYPE node, const char *value, unsigned int *ret)
557/* Writes the specified integer into the specified node. 557/* Writes the specified integer into the specified node.
558 */ 558 */
559int 559int
560_gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, uint32_t num) 560MHD__gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, uint32_t num)
561{ 561{
562 opaque tmpstr[4]; 562 opaque tmpstr[4];
563 int result; 563 int result;
564 564
565 mhd_gtls_write_uint32 (num, tmpstr); 565 MHD_gtls_write_uint32 (num, tmpstr);
566 566
567 result = asn1_write_value (node, value, tmpstr, 4); 567 result = MHD__asn1_write_value (node, value, tmpstr, 4);
568 568
569 if (result != ASN1_SUCCESS) 569 if (result != ASN1_SUCCESS)
570 { 570 {
571 gnutls_assert (); 571 MHD_gnutls_assert ();
572 return mhd_gtls_asn2err (result); 572 return MHD_gtls_asn2err (result);
573 } 573 }
574 574
575 return 0; 575 return 0;
diff --git a/src/daemon/https/x509/mpi.h b/src/daemon/https/x509/mpi.h
index 69e725bd..6c4534b4 100644
--- a/src/daemon/https/x509/mpi.h
+++ b/src/daemon/https/x509/mpi.h
@@ -25,32 +25,32 @@
25#include <gnutls_int.h> 25#include <gnutls_int.h>
26#include "x509.h" 26#include "x509.h"
27 27
28int _gnutls_x509_crt_get_mpis (gnutls_x509_crt_t cert, 28int MHD__gnutls_x509_crt_get_mpis (MHD_gnutls_x509_crt_t cert,
29 mpi_t * params, int *params_size); 29 mpi_t * params, int *params_size);
30int _gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params); 30int MHD__gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params);
31int _gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params); 31int MHD__gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params);
32int _gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params); 32int MHD__gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params);
33 33
34int _gnutls_x509_write_rsa_params (mpi_t * params, int params_size, 34int MHD__gnutls_x509_write_rsa_params (mpi_t * params, int params_size,
35 gnutls_datum_t * der); 35 MHD_gnutls_datum_t * der);
36int _gnutls_x509_write_dsa_params (mpi_t * params, int params_size, 36int MHD__gnutls_x509_write_dsa_params (mpi_t * params, int params_size,
37 gnutls_datum_t * der); 37 MHD_gnutls_datum_t * der);
38int _gnutls_x509_write_dsa_public_key (mpi_t * params, int params_size, 38int MHD__gnutls_x509_write_dsa_public_key (mpi_t * params, int params_size,
39 gnutls_datum_t * der); 39 MHD_gnutls_datum_t * der);
40 40
41int _gnutls_x509_read_uint (ASN1_TYPE node, const char *value, 41int MHD__gnutls_x509_read_uint (ASN1_TYPE node, const char *value,
42 unsigned int *ret); 42 unsigned int *ret);
43 43
44int _gnutls_x509_read_der_int (opaque * der, int dersize, mpi_t * out); 44int MHD__gnutls_x509_read_der_int (opaque * der, int dersize, mpi_t * out);
45 45
46int _gnutls_x509_read_int (ASN1_TYPE node, const char *value, 46int MHD__gnutls_x509_read_int (ASN1_TYPE node, const char *value,
47 mpi_t * ret_mpi); 47 mpi_t * ret_mpi);
48int _gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, 48int MHD__gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi,
49 int lz); 49 int lz);
50int _gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, 50int MHD__gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value,
51 uint32_t num); 51 uint32_t num);
52 52
53int _gnutls_x509_write_sig_params (ASN1_TYPE dst, const char *dst_name, 53int MHD__gnutls_x509_write_sig_params (ASN1_TYPE dst, const char *dst_name,
54 enum MHD_GNUTLS_PublicKeyAlgorithm 54 enum MHD_GNUTLS_PublicKeyAlgorithm
55 pk_algorithm, 55 pk_algorithm,
56 enum MHD_GNUTLS_HashAlgorithm, 56 enum MHD_GNUTLS_HashAlgorithm,
diff --git a/src/daemon/https/x509/pkcs12.c b/src/daemon/https/x509/pkcs12.c
index 282e006e..af069e0d 100644
--- a/src/daemon/https/x509/pkcs12.c
+++ b/src/daemon/https/x509/pkcs12.c
@@ -46,26 +46,26 @@
46 * which holds them. Returns an ASN1_TYPE of authenticatedSafe. 46 * which holds them. Returns an ASN1_TYPE of authenticatedSafe.
47 */ 47 */
48static int 48static int
49_decode_pkcs12_auth_safe (ASN1_TYPE pkcs12, ASN1_TYPE * authen_safe, 49_decodeMHD_pkcs12_auth_safe (ASN1_TYPE pkcs12, ASN1_TYPE * authen_safe,
50 gnutls_datum_t * raw) 50 MHD_gnutls_datum_t * raw)
51{ 51{
52 char oid[128]; 52 char oid[128];
53 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 53 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
54 gnutls_datum_t auth_safe = { NULL, 0 }; 54 MHD_gnutls_datum_t auth_safe = { NULL, 0 };
55 int tmp_size, len, result; 55 int tmp_size, len, result;
56 56
57 len = sizeof (oid) - 1; 57 len = sizeof (oid) - 1;
58 result = asn1_read_value (pkcs12, "authSafe.contentType", oid, &len); 58 result = MHD__asn1_read_value (pkcs12, "authSafe.contentType", oid, &len);
59 if (result != ASN1_SUCCESS) 59 if (result != ASN1_SUCCESS)
60 { 60 {
61 gnutls_assert (); 61 MHD_gnutls_assert ();
62 return mhd_gtls_asn2err (result); 62 return MHD_gtls_asn2err (result);
63 } 63 }
64 64
65 if (strcmp (oid, DATA_OID) != 0) 65 if (strcmp (oid, DATA_OID) != 0)
66 { 66 {
67 gnutls_assert (); 67 MHD_gnutls_assert ();
68 _gnutls_x509_log ("Unknown PKCS12 Content OID '%s'\n", oid); 68 MHD__gnutls_x509_log ("Unknown PKCS12 Content OID '%s'\n", oid);
69 return GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE; 69 return GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE;
70 } 70 }
71 71
@@ -74,36 +74,36 @@ _decode_pkcs12_auth_safe (ASN1_TYPE pkcs12, ASN1_TYPE * authen_safe,
74 74
75 tmp_size = 0; 75 tmp_size = 0;
76 result = 76 result =
77 _gnutls_x509_read_value (pkcs12, "authSafe.content", &auth_safe, 1); 77 MHD__gnutls_x509_read_value (pkcs12, "authSafe.content", &auth_safe, 1);
78 if (result < 0) 78 if (result < 0)
79 { 79 {
80 gnutls_assert (); 80 MHD_gnutls_assert ();
81 goto cleanup; 81 goto cleanup;
82 } 82 }
83 83
84 /* Step 2. Extract the authenticatedSafe. 84 /* Step 2. Extract the authenticatedSafe.
85 */ 85 */
86 86
87 if ((result = asn1_create_element 87 if ((result = MHD__asn1_create_element
88 (_gnutls_get_pkix (), "PKIX1.pkcs-12-AuthenticatedSafe", 88 (MHD__gnutls_get_pkix (), "PKIX1.pkcs-12-AuthenticatedSafe",
89 &c2)) != ASN1_SUCCESS) 89 &c2)) != ASN1_SUCCESS)
90 { 90 {
91 gnutls_assert (); 91 MHD_gnutls_assert ();
92 result = mhd_gtls_asn2err (result); 92 result = MHD_gtls_asn2err (result);
93 goto cleanup; 93 goto cleanup;
94 } 94 }
95 95
96 result = asn1_der_decoding (&c2, auth_safe.data, auth_safe.size, NULL); 96 result = MHD__asn1_der_decoding (&c2, auth_safe.data, auth_safe.size, NULL);
97 if (result != ASN1_SUCCESS) 97 if (result != ASN1_SUCCESS)
98 { 98 {
99 gnutls_assert (); 99 MHD_gnutls_assert ();
100 result = mhd_gtls_asn2err (result); 100 result = MHD_gtls_asn2err (result);
101 goto cleanup; 101 goto cleanup;
102 } 102 }
103 103
104 if (raw == NULL) 104 if (raw == NULL)
105 { 105 {
106 _gnutls_free_datum (&auth_safe); 106 MHD__gnutls_free_datum (&auth_safe);
107 } 107 }
108 else 108 else
109 { 109 {
@@ -114,19 +114,19 @@ _decode_pkcs12_auth_safe (ASN1_TYPE pkcs12, ASN1_TYPE * authen_safe,
114 if (authen_safe) 114 if (authen_safe)
115 *authen_safe = c2; 115 *authen_safe = c2;
116 else 116 else
117 asn1_delete_structure (&c2); 117 MHD__asn1_delete_structure (&c2);
118 118
119 return 0; 119 return 0;
120 120
121cleanup: 121cleanup:
122 if (c2) 122 if (c2)
123 asn1_delete_structure (&c2); 123 MHD__asn1_delete_structure (&c2);
124 _gnutls_free_datum (&auth_safe); 124 MHD__gnutls_free_datum (&auth_safe);
125 return result; 125 return result;
126} 126}
127 127
128/** 128/**
129 * gnutls_pkcs12_init - This function initializes a gnutls_pkcs12_t structure 129 * MHD_gnutlsMHD_pkcs12_init - This function initializes a MHD_gnutlsMHD_pkcs12_t structure
130 * @pkcs12: The structure to be initialized 130 * @pkcs12: The structure to be initialized
131 * 131 *
132 * This function will initialize a PKCS12 structure. PKCS12 structures 132 * This function will initialize a PKCS12 structure. PKCS12 structures
@@ -137,20 +137,20 @@ cleanup:
137 * 137 *
138 **/ 138 **/
139int 139int
140gnutls_pkcs12_init (gnutls_pkcs12_t * pkcs12) 140MHD_gnutlsMHD_pkcs12_init (MHD_gnutlsMHD_pkcs12_t * pkcs12)
141{ 141{
142 *pkcs12 = gnutls_calloc (1, sizeof (gnutls_pkcs12_int)); 142 *pkcs12 = MHD_gnutls_calloc (1, sizeof (MHD_gnutlsMHD_pkcs12_int));
143 143
144 if (*pkcs12) 144 if (*pkcs12)
145 { 145 {
146 int result = asn1_create_element (_gnutls_get_pkix (), 146 int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
147 "PKIX1.pkcs-12-PFX", 147 "PKIX1.pkcs-12-PFX",
148 &(*pkcs12)->pkcs12); 148 &(*pkcs12)->pkcs12);
149 if (result != ASN1_SUCCESS) 149 if (result != ASN1_SUCCESS)
150 { 150 {
151 gnutls_assert (); 151 MHD_gnutls_assert ();
152 gnutls_free (*pkcs12); 152 MHD_gnutls_free (*pkcs12);
153 return mhd_gtls_asn2err (result); 153 return MHD_gtls_asn2err (result);
154 } 154 }
155 return 0; /* success */ 155 return 0; /* success */
156 } 156 }
@@ -158,33 +158,33 @@ gnutls_pkcs12_init (gnutls_pkcs12_t * pkcs12)
158} 158}
159 159
160/** 160/**
161 * gnutls_pkcs12_deinit - This function deinitializes memory used by a gnutls_pkcs12_t structure 161 * MHD_gnutlsMHD_pkcs12_deinit - This function deinitializes memory used by a MHD_gnutlsMHD_pkcs12_t structure
162 * @pkcs12: The structure to be initialized 162 * @pkcs12: The structure to be initialized
163 * 163 *
164 * This function will deinitialize a PKCS12 structure. 164 * This function will deinitialize a PKCS12 structure.
165 * 165 *
166 **/ 166 **/
167void 167void
168gnutls_pkcs12_deinit (gnutls_pkcs12_t pkcs12) 168MHD_gnutlsMHD_pkcs12_deinit (MHD_gnutlsMHD_pkcs12_t pkcs12)
169{ 169{
170 if (!pkcs12) 170 if (!pkcs12)
171 return; 171 return;
172 172
173 if (pkcs12->pkcs12) 173 if (pkcs12->pkcs12)
174 asn1_delete_structure (&pkcs12->pkcs12); 174 MHD__asn1_delete_structure (&pkcs12->pkcs12);
175 175
176 gnutls_free (pkcs12); 176 MHD_gnutls_free (pkcs12);
177} 177}
178 178
179/** 179/**
180 * gnutls_pkcs12_import - This function will import a DER or PEM encoded PKCS12 structure 180 * MHD_gnutlsMHD_pkcs12_import - This function will import a DER or PEM encoded PKCS12 structure
181 * @pkcs12: The structure to store the parsed PKCS12. 181 * @pkcs12: The structure to store the parsed PKCS12.
182 * @data: The DER or PEM encoded PKCS12. 182 * @data: The DER or PEM encoded PKCS12.
183 * @format: One of DER or PEM 183 * @format: One of DER or PEM
184 * @flags: an ORed sequence of gnutls_privkey_pkcs8_flags 184 * @flags: an ORed sequence of MHD_gnutls_privkey_pkcs8_flags
185 * 185 *
186 * This function will convert the given DER or PEM encoded PKCS12 186 * This function will convert the given DER or PEM encoded PKCS12
187 * to the native gnutls_pkcs12_t format. The output will be stored in 'pkcs12'. 187 * to the native MHD_gnutlsMHD_pkcs12_t format. The output will be stored in 'pkcs12'.
188 * 188 *
189 * If the PKCS12 is PEM encoded it should have a header of "PKCS12". 189 * If the PKCS12 is PEM encoded it should have a header of "PKCS12".
190 * 190 *
@@ -192,19 +192,19 @@ gnutls_pkcs12_deinit (gnutls_pkcs12_t pkcs12)
192 * 192 *
193 **/ 193 **/
194int 194int
195gnutls_pkcs12_import (gnutls_pkcs12_t pkcs12, 195MHD_gnutlsMHD_pkcs12_import (MHD_gnutlsMHD_pkcs12_t pkcs12,
196 const gnutls_datum_t * data, 196 const MHD_gnutls_datum_t * data,
197 gnutls_x509_crt_fmt_t format, unsigned int flags) 197 MHD_gnutls_x509_crt_fmt_t format, unsigned int flags)
198{ 198{
199 int result = 0, need_free = 0; 199 int result = 0, need_free = 0;
200 gnutls_datum_t _data; 200 MHD_gnutls_datum_t _data;
201 201
202 _data.data = data->data; 202 _data.data = data->data;
203 _data.size = data->size; 203 _data.size = data->size;
204 204
205 if (pkcs12 == NULL) 205 if (pkcs12 == NULL)
206 { 206 {
207 gnutls_assert (); 207 MHD_gnutls_assert ();
208 return GNUTLS_E_INVALID_REQUEST; 208 return GNUTLS_E_INVALID_REQUEST;
209 } 209 }
210 210
@@ -214,14 +214,14 @@ gnutls_pkcs12_import (gnutls_pkcs12_t pkcs12,
214 { 214 {
215 opaque *out; 215 opaque *out;
216 216
217 result = _gnutls_fbase64_decode (PEM_PKCS12, data->data, data->size, 217 result = MHD__gnutls_fbase64_decode (PEM_PKCS12, data->data, data->size,
218 &out); 218 &out);
219 219
220 if (result <= 0) 220 if (result <= 0)
221 { 221 {
222 if (result == 0) 222 if (result == 0)
223 result = GNUTLS_E_INTERNAL_ERROR; 223 result = GNUTLS_E_INTERNAL_ERROR;
224 gnutls_assert (); 224 MHD_gnutls_assert ();
225 return result; 225 return result;
226 } 226 }
227 227
@@ -231,28 +231,28 @@ gnutls_pkcs12_import (gnutls_pkcs12_t pkcs12,
231 need_free = 1; 231 need_free = 1;
232 } 232 }
233 233
234 result = asn1_der_decoding (&pkcs12->pkcs12, _data.data, _data.size, NULL); 234 result = MHD__asn1_der_decoding (&pkcs12->pkcs12, _data.data, _data.size, NULL);
235 if (result != ASN1_SUCCESS) 235 if (result != ASN1_SUCCESS)
236 { 236 {
237 result = mhd_gtls_asn2err (result); 237 result = MHD_gtls_asn2err (result);
238 gnutls_assert (); 238 MHD_gnutls_assert ();
239 goto cleanup; 239 goto cleanup;
240 } 240 }
241 241
242 if (need_free) 242 if (need_free)
243 _gnutls_free_datum (&_data); 243 MHD__gnutls_free_datum (&_data);
244 244
245 return 0; 245 return 0;
246 246
247cleanup: 247cleanup:
248 if (need_free) 248 if (need_free)
249 _gnutls_free_datum (&_data); 249 MHD__gnutls_free_datum (&_data);
250 return result; 250 return result;
251} 251}
252 252
253 253
254/** 254/**
255 * gnutls_pkcs12_export - This function will export the pkcs12 structure 255 * MHD_gnutlsMHD_pkcs12_export - This function will export the pkcs12 structure
256 * @pkcs12: Holds the pkcs12 structure 256 * @pkcs12: Holds the pkcs12 structure
257 * @format: the format of output params. One of PEM or DER. 257 * @format: the format of output params. One of PEM or DER.
258 * @output_data: will contain a structure PEM or DER encoded 258 * @output_data: will contain a structure PEM or DER encoded
@@ -273,17 +273,17 @@ cleanup:
273 * 273 *
274 **/ 274 **/
275int 275int
276gnutls_pkcs12_export (gnutls_pkcs12_t pkcs12, 276MHD_gnutlsMHD_pkcs12_export (MHD_gnutlsMHD_pkcs12_t pkcs12,
277 gnutls_x509_crt_fmt_t format, void *output_data, 277 MHD_gnutls_x509_crt_fmt_t format, void *output_data,
278 size_t * output_data_size) 278 size_t * output_data_size)
279{ 279{
280 if (pkcs12 == NULL) 280 if (pkcs12 == NULL)
281 { 281 {
282 gnutls_assert (); 282 MHD_gnutls_assert ();
283 return GNUTLS_E_INVALID_REQUEST; 283 return GNUTLS_E_INVALID_REQUEST;
284 } 284 }
285 285
286 return _gnutls_x509_export_int (pkcs12->pkcs12, format, PEM_PKCS12, 286 return MHD__gnutls_x509_export_int (pkcs12->pkcs12, format, PEM_PKCS12,
287 output_data, output_data_size); 287 output_data, output_data_size);
288} 288}
289 289
@@ -341,44 +341,44 @@ ucs2_to_ascii (char *data, int size)
341 * the given bag. 341 * the given bag.
342 */ 342 */
343int 343int
344_pkcs12_decode_safe_contents (const gnutls_datum_t * content, 344MHD_pkcs12_decode_safe_contents (const MHD_gnutls_datum_t * content,
345 gnutls_pkcs12_bag_t bag) 345 MHD_gnutlsMHD_pkcs12_bag_t bag)
346{ 346{
347 char oid[128], root[MAX_NAME_SIZE]; 347 char oid[128], root[MAX_NAME_SIZE];
348 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 348 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
349 int len, result; 349 int len, result;
350 int bag_type; 350 int bag_type;
351 gnutls_datum_t attr_val; 351 MHD_gnutls_datum_t attr_val;
352 int count = 0, i, attributes, j; 352 int count = 0, i, attributes, j;
353 size_t size; 353 size_t size;
354 354
355 /* Step 1. Extract the SEQUENCE. 355 /* Step 1. Extract the SEQUENCE.
356 */ 356 */
357 357
358 if ((result = asn1_create_element 358 if ((result = MHD__asn1_create_element
359 (_gnutls_get_pkix (), "PKIX1.pkcs-12-SafeContents", 359 (MHD__gnutls_get_pkix (), "PKIX1.pkcs-12-SafeContents",
360 &c2)) != ASN1_SUCCESS) 360 &c2)) != ASN1_SUCCESS)
361 { 361 {
362 gnutls_assert (); 362 MHD_gnutls_assert ();
363 result = mhd_gtls_asn2err (result); 363 result = MHD_gtls_asn2err (result);
364 goto cleanup; 364 goto cleanup;
365 } 365 }
366 366
367 result = asn1_der_decoding (&c2, content->data, content->size, NULL); 367 result = MHD__asn1_der_decoding (&c2, content->data, content->size, NULL);
368 if (result != ASN1_SUCCESS) 368 if (result != ASN1_SUCCESS)
369 { 369 {
370 gnutls_assert (); 370 MHD_gnutls_assert ();
371 result = mhd_gtls_asn2err (result); 371 result = MHD_gtls_asn2err (result);
372 goto cleanup; 372 goto cleanup;
373 } 373 }
374 374
375 /* Count the number of bags 375 /* Count the number of bags
376 */ 376 */
377 result = asn1_number_of_elements (c2, "", &count); 377 result = MHD__asn1_number_of_elements (c2, "", &count);
378 if (result != ASN1_SUCCESS) 378 if (result != ASN1_SUCCESS)
379 { 379 {
380 gnutls_assert (); 380 MHD_gnutls_assert ();
381 result = mhd_gtls_asn2err (result); 381 result = MHD_gtls_asn2err (result);
382 goto cleanup; 382 goto cleanup;
383 } 383 }
384 384
@@ -390,11 +390,11 @@ _pkcs12_decode_safe_contents (const gnutls_datum_t * content,
390 snprintf (root, sizeof (root), "?%u.bagId", i + 1); 390 snprintf (root, sizeof (root), "?%u.bagId", i + 1);
391 391
392 len = sizeof (oid); 392 len = sizeof (oid);
393 result = asn1_read_value (c2, root, oid, &len); 393 result = MHD__asn1_read_value (c2, root, oid, &len);
394 if (result != ASN1_SUCCESS) 394 if (result != ASN1_SUCCESS)
395 { 395 {
396 gnutls_assert (); 396 MHD_gnutls_assert ();
397 result = mhd_gtls_asn2err (result); 397 result = MHD_gtls_asn2err (result);
398 goto cleanup; 398 goto cleanup;
399 } 399 }
400 400
@@ -404,7 +404,7 @@ _pkcs12_decode_safe_contents (const gnutls_datum_t * content,
404 404
405 if (bag_type < 0) 405 if (bag_type < 0)
406 { 406 {
407 gnutls_assert (); 407 MHD_gnutls_assert ();
408 goto cleanup; 408 goto cleanup;
409 } 409 }
410 410
@@ -413,37 +413,37 @@ _pkcs12_decode_safe_contents (const gnutls_datum_t * content,
413 413
414 snprintf (root, sizeof (root), "?%u.bagValue", i + 1); 414 snprintf (root, sizeof (root), "?%u.bagValue", i + 1);
415 415
416 result = _gnutls_x509_read_value (c2, root, &bag->element[i].data, 0); 416 result = MHD__gnutls_x509_read_value (c2, root, &bag->element[i].data, 0);
417 if (result < 0) 417 if (result < 0)
418 { 418 {
419 gnutls_assert (); 419 MHD_gnutls_assert ();
420 goto cleanup; 420 goto cleanup;
421 } 421 }
422 422
423 if (bag_type == GNUTLS_BAG_CERTIFICATE || bag_type == GNUTLS_BAG_CRL) 423 if (bag_type == GNUTLS_BAG_CERTIFICATE || bag_type == GNUTLS_BAG_CRL)
424 { 424 {
425 gnutls_datum_t tmp = bag->element[i].data; 425 MHD_gnutls_datum_t tmp = bag->element[i].data;
426 426
427 result = 427 result =
428 _pkcs12_decode_crt_bag (bag_type, &tmp, &bag->element[i].data); 428 MHD_pkcs12_decode_crt_bag (bag_type, &tmp, &bag->element[i].data);
429 if (result < 0) 429 if (result < 0)
430 { 430 {
431 gnutls_assert (); 431 MHD_gnutls_assert ();
432 goto cleanup; 432 goto cleanup;
433 } 433 }
434 434
435 _gnutls_free_datum (&tmp); 435 MHD__gnutls_free_datum (&tmp);
436 } 436 }
437 437
438 /* read the bag attributes 438 /* read the bag attributes
439 */ 439 */
440 snprintf (root, sizeof (root), "?%u.bagAttributes", i + 1); 440 snprintf (root, sizeof (root), "?%u.bagAttributes", i + 1);
441 441
442 result = asn1_number_of_elements (c2, root, &attributes); 442 result = MHD__asn1_number_of_elements (c2, root, &attributes);
443 if (result != ASN1_SUCCESS && result != ASN1_ELEMENT_NOT_FOUND) 443 if (result != ASN1_SUCCESS && result != ASN1_ELEMENT_NOT_FOUND)
444 { 444 {
445 gnutls_assert (); 445 MHD_gnutls_assert ();
446 result = mhd_gtls_asn2err (result); 446 result = MHD_gtls_asn2err (result);
447 goto cleanup; 447 goto cleanup;
448 } 448 }
449 449
@@ -458,13 +458,13 @@ _pkcs12_decode_safe_contents (const gnutls_datum_t * content,
458 j + 1); 458 j + 1);
459 459
460 result = 460 result =
461 _gnutls_x509_decode_and_read_attribute (c2, root, oid, 461 MHD__gnutls_x509_decode_and_read_attribute (c2, root, oid,
462 sizeof (oid), &attr_val, 462 sizeof (oid), &attr_val,
463 1, 0); 463 1, 0);
464 464
465 if (result < 0) 465 if (result < 0)
466 { 466 {
467 gnutls_assert (); 467 MHD_gnutls_assert ();
468 continue; /* continue in case we find some known attributes */ 468 continue; /* continue in case we find some known attributes */
469 } 469 }
470 470
@@ -473,14 +473,14 @@ _pkcs12_decode_safe_contents (const gnutls_datum_t * content,
473 size = attr_val.size; 473 size = attr_val.size;
474 474
475 result = 475 result =
476 _gnutls_x509_decode_octet_string (NULL, attr_val.data, size, 476 MHD__gnutls_x509_decode_octet_string (NULL, attr_val.data, size,
477 attr_val.data, &size); 477 attr_val.data, &size);
478 attr_val.size = size; 478 attr_val.size = size;
479 if (result < 0) 479 if (result < 0)
480 { 480 {
481 _gnutls_free_datum (&attr_val); 481 MHD__gnutls_free_datum (&attr_val);
482 gnutls_assert (); 482 MHD_gnutls_assert ();
483 _gnutls_x509_log 483 MHD__gnutls_x509_log
484 ("Error decoding PKCS12 Bag Attribute OID '%s'\n", oid); 484 ("Error decoding PKCS12 Bag Attribute OID '%s'\n", oid);
485 continue; 485 continue;
486 } 486 }
@@ -490,15 +490,15 @@ _pkcs12_decode_safe_contents (const gnutls_datum_t * content,
490 { 490 {
491 size = attr_val.size; 491 size = attr_val.size;
492 result = 492 result =
493 _gnutls_x509_decode_octet_string ("BMPString", 493 MHD__gnutls_x509_decode_octet_string ("BMPString",
494 attr_val.data, size, 494 attr_val.data, size,
495 attr_val.data, &size); 495 attr_val.data, &size);
496 attr_val.size = size; 496 attr_val.size = size;
497 if (result < 0) 497 if (result < 0)
498 { 498 {
499 _gnutls_free_datum (&attr_val); 499 MHD__gnutls_free_datum (&attr_val);
500 gnutls_assert (); 500 MHD_gnutls_assert ();
501 _gnutls_x509_log 501 MHD__gnutls_x509_log
502 ("Error decoding PKCS12 Bag Attribute OID '%s'\n", oid); 502 ("Error decoding PKCS12 Bag Attribute OID '%s'\n", oid);
503 continue; 503 continue;
504 } 504 }
@@ -507,8 +507,8 @@ _pkcs12_decode_safe_contents (const gnutls_datum_t * content,
507 } 507 }
508 else 508 else
509 { 509 {
510 _gnutls_free_datum (&attr_val); 510 MHD__gnutls_free_datum (&attr_val);
511 _gnutls_x509_log 511 MHD__gnutls_x509_log
512 ("Unknown PKCS12 Bag Attribute OID '%s'\n", oid); 512 ("Unknown PKCS12 Bag Attribute OID '%s'\n", oid);
513 } 513 }
514 } 514 }
@@ -518,14 +518,14 @@ _pkcs12_decode_safe_contents (const gnutls_datum_t * content,
518 518
519 } 519 }
520 520
521 asn1_delete_structure (&c2); 521 MHD__asn1_delete_structure (&c2);
522 522
523 523
524 return 0; 524 return 0;
525 525
526cleanup: 526cleanup:
527 if (c2) 527 if (c2)
528 asn1_delete_structure (&c2); 528 MHD__asn1_delete_structure (&c2);
529 return result; 529 return result;
530 530
531} 531}
@@ -533,41 +533,41 @@ cleanup:
533 533
534static int 534static int
535_parse_safe_contents (ASN1_TYPE sc, const char *sc_name, 535_parse_safe_contents (ASN1_TYPE sc, const char *sc_name,
536 gnutls_pkcs12_bag_t bag) 536 MHD_gnutlsMHD_pkcs12_bag_t bag)
537{ 537{
538 gnutls_datum_t content = { NULL, 0 }; 538 MHD_gnutls_datum_t content = { NULL, 0 };
539 int result; 539 int result;
540 540
541 /* Step 1. Extract the content. 541 /* Step 1. Extract the content.
542 */ 542 */
543 543
544 result = _gnutls_x509_read_value (sc, sc_name, &content, 1); 544 result = MHD__gnutls_x509_read_value (sc, sc_name, &content, 1);
545 if (result < 0) 545 if (result < 0)
546 { 546 {
547 gnutls_assert (); 547 MHD_gnutls_assert ();
548 goto cleanup; 548 goto cleanup;
549 } 549 }
550 550
551 result = _pkcs12_decode_safe_contents (&content, bag); 551 result = MHD_pkcs12_decode_safe_contents (&content, bag);
552 if (result < 0) 552 if (result < 0)
553 { 553 {
554 gnutls_assert (); 554 MHD_gnutls_assert ();
555 goto cleanup; 555 goto cleanup;
556 } 556 }
557 557
558 _gnutls_free_datum (&content); 558 MHD__gnutls_free_datum (&content);
559 559
560 return 0; 560 return 0;
561 561
562cleanup: 562cleanup:
563 _gnutls_free_datum (&content); 563 MHD__gnutls_free_datum (&content);
564 return result; 564 return result;
565} 565}
566 566
567 567
568/** 568/**
569 * gnutls_pkcs12_get_bag - This function returns a Bag from a PKCS12 structure 569 * MHD_gnutlsMHD_pkcs12_get_bag - This function returns a Bag from a PKCS12 structure
570 * @pkcs12: should contain a gnutls_pkcs12_t structure 570 * @pkcs12: should contain a MHD_gnutlsMHD_pkcs12_t structure
571 * @indx: contains the index of the bag to extract 571 * @indx: contains the index of the bag to extract
572 * @bag: An initialized bag, where the contents of the bag will be copied 572 * @bag: An initialized bag, where the contents of the bag will be copied
573 * 573 *
@@ -579,8 +579,8 @@ cleanup:
579 * 579 *
580 **/ 580 **/
581int 581int
582gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12, 582MHD_gnutlsMHD_pkcs12_get_bag (MHD_gnutlsMHD_pkcs12_t pkcs12,
583 int indx, gnutls_pkcs12_bag_t bag) 583 int indx, MHD_gnutlsMHD_pkcs12_bag_t bag)
584{ 584{
585 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 585 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
586 int result, len; 586 int result, len;
@@ -589,16 +589,16 @@ gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12,
589 589
590 if (pkcs12 == NULL) 590 if (pkcs12 == NULL)
591 { 591 {
592 gnutls_assert (); 592 MHD_gnutls_assert ();
593 return GNUTLS_E_INVALID_REQUEST; 593 return GNUTLS_E_INVALID_REQUEST;
594 } 594 }
595 595
596 /* Step 1. decode the data. 596 /* Step 1. decode the data.
597 */ 597 */
598 result = _decode_pkcs12_auth_safe (pkcs12->pkcs12, &c2, NULL); 598 result = _decodeMHD_pkcs12_auth_safe (pkcs12->pkcs12, &c2, NULL);
599 if (result < 0) 599 if (result < 0)
600 { 600 {
601 gnutls_assert (); 601 MHD_gnutls_assert ();
602 return result; 602 return result;
603 } 603 }
604 604
@@ -608,7 +608,7 @@ gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12,
608 snprintf (root2, sizeof (root2), "?%u.contentType", indx + 1); 608 snprintf (root2, sizeof (root2), "?%u.contentType", indx + 1);
609 609
610 len = sizeof (oid) - 1; 610 len = sizeof (oid) - 1;
611 result = asn1_read_value (c2, root2, oid, &len); 611 result = MHD__asn1_read_value (c2, root2, oid, &len);
612 612
613 if (result == ASN1_ELEMENT_NOT_FOUND) 613 if (result == ASN1_ELEMENT_NOT_FOUND)
614 { 614 {
@@ -618,8 +618,8 @@ gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12,
618 618
619 if (result != ASN1_SUCCESS) 619 if (result != ASN1_SUCCESS)
620 { 620 {
621 gnutls_assert (); 621 MHD_gnutls_assert ();
622 result = mhd_gtls_asn2err (result); 622 result = MHD_gtls_asn2err (result);
623 goto cleanup; 623 goto cleanup;
624 } 624 }
625 625
@@ -639,10 +639,10 @@ gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12,
639 bag->element[0].type = GNUTLS_BAG_ENCRYPTED; 639 bag->element[0].type = GNUTLS_BAG_ENCRYPTED;
640 bag->bag_elements = 1; 640 bag->bag_elements = 1;
641 641
642 result = _gnutls_x509_read_value (c2, root2, &bag->element[0].data, 0); 642 result = MHD__gnutls_x509_read_value (c2, root2, &bag->element[0].data, 0);
643 if (result < 0) 643 if (result < 0)
644 { 644 {
645 gnutls_assert (); 645 MHD_gnutls_assert ();
646 goto cleanup; 646 goto cleanup;
647 } 647 }
648 648
@@ -650,7 +650,7 @@ gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12,
650 650
651cleanup: 651cleanup:
652 if (c2) 652 if (c2)
653 asn1_delete_structure (&c2); 653 MHD__asn1_delete_structure (&c2);
654 return result; 654 return result;
655} 655}
656 656
@@ -665,21 +665,21 @@ create_empty_pfx (ASN1_TYPE pkcs12)
665 665
666 /* Use version 3 666 /* Use version 3
667 */ 667 */
668 result = asn1_write_value (pkcs12, "version", &three, 1); 668 result = MHD__asn1_write_value (pkcs12, "version", &three, 1);
669 if (result != ASN1_SUCCESS) 669 if (result != ASN1_SUCCESS)
670 { 670 {
671 gnutls_assert (); 671 MHD_gnutls_assert ();
672 result = mhd_gtls_asn2err (result); 672 result = MHD_gtls_asn2err (result);
673 goto cleanup; 673 goto cleanup;
674 } 674 }
675 675
676 /* Write the content type of the data 676 /* Write the content type of the data
677 */ 677 */
678 result = asn1_write_value (pkcs12, "authSafe.contentType", DATA_OID, 1); 678 result = MHD__asn1_write_value (pkcs12, "authSafe.contentType", DATA_OID, 1);
679 if (result != ASN1_SUCCESS) 679 if (result != ASN1_SUCCESS)
680 { 680 {
681 gnutls_assert (); 681 MHD_gnutls_assert ();
682 result = mhd_gtls_asn2err (result); 682 result = MHD_gtls_asn2err (result);
683 goto cleanup; 683 goto cleanup;
684 } 684 }
685 685
@@ -687,35 +687,35 @@ create_empty_pfx (ASN1_TYPE pkcs12)
687 * null one in that case. 687 * null one in that case.
688 */ 688 */
689 689
690 if ((result = asn1_create_element 690 if ((result = MHD__asn1_create_element
691 (_gnutls_get_pkix (), "PKIX1.pkcs-12-AuthenticatedSafe", 691 (MHD__gnutls_get_pkix (), "PKIX1.pkcs-12-AuthenticatedSafe",
692 &c2)) != ASN1_SUCCESS) 692 &c2)) != ASN1_SUCCESS)
693 { 693 {
694 gnutls_assert (); 694 MHD_gnutls_assert ();
695 result = mhd_gtls_asn2err (result); 695 result = MHD_gtls_asn2err (result);
696 goto cleanup; 696 goto cleanup;
697 } 697 }
698 698
699 result = 699 result =
700 _gnutls_x509_der_encode_and_copy (c2, "", pkcs12, "authSafe.content", 1); 700 MHD__gnutls_x509_der_encode_and_copy (c2, "", pkcs12, "authSafe.content", 1);
701 if (result < 0) 701 if (result < 0)
702 { 702 {
703 gnutls_assert (); 703 MHD_gnutls_assert ();
704 goto cleanup; 704 goto cleanup;
705 } 705 }
706 asn1_delete_structure (&c2); 706 MHD__asn1_delete_structure (&c2);
707 707
708 return 0; 708 return 0;
709 709
710cleanup: 710cleanup:
711 asn1_delete_structure (&c2); 711 MHD__asn1_delete_structure (&c2);
712 return result; 712 return result;
713 713
714} 714}
715 715
716/** 716/**
717 * gnutls_pkcs12_set_bag - This function inserts a Bag into a PKCS12 structure 717 * MHD_gnutlsMHD_pkcs12_set_bag - This function inserts a Bag into a PKCS12 structure
718 * @pkcs12: should contain a gnutls_pkcs12_t structure 718 * @pkcs12: should contain a MHD_gnutlsMHD_pkcs12_t structure
719 * @bag: An initialized bag 719 * @bag: An initialized bag
720 * 720 *
721 * This function will insert a Bag into the PKCS12 structure. 721 * This function will insert a Bag into the PKCS12 structure.
@@ -723,7 +723,7 @@ cleanup:
723 * 723 *
724 **/ 724 **/
725int 725int
726gnutls_pkcs12_set_bag (gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag) 726MHD_gnutlsMHD_pkcs12_set_bag (MHD_gnutlsMHD_pkcs12_t pkcs12, MHD_gnutlsMHD_pkcs12_bag_t bag)
727{ 727{
728 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 728 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
729 ASN1_TYPE safe_cont = ASN1_TYPE_EMPTY; 729 ASN1_TYPE safe_cont = ASN1_TYPE_EMPTY;
@@ -733,62 +733,62 @@ gnutls_pkcs12_set_bag (gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag)
733 733
734 if (pkcs12 == NULL) 734 if (pkcs12 == NULL)
735 { 735 {
736 gnutls_assert (); 736 MHD_gnutls_assert ();
737 return GNUTLS_E_INVALID_REQUEST; 737 return GNUTLS_E_INVALID_REQUEST;
738 } 738 }
739 739
740 /* Step 1. Check if the pkcs12 structure is empty. In that 740 /* Step 1. Check if the pkcs12 structure is empty. In that
741 * case generate an empty PFX. 741 * case generate an empty PFX.
742 */ 742 */
743 result = asn1_read_value (pkcs12->pkcs12, "authSafe.content", &null, &dum); 743 result = MHD__asn1_read_value (pkcs12->pkcs12, "authSafe.content", &null, &dum);
744 if (result == ASN1_VALUE_NOT_FOUND) 744 if (result == ASN1_VALUE_NOT_FOUND)
745 { 745 {
746 result = create_empty_pfx (pkcs12->pkcs12); 746 result = create_empty_pfx (pkcs12->pkcs12);
747 if (result < 0) 747 if (result < 0)
748 { 748 {
749 gnutls_assert (); 749 MHD_gnutls_assert ();
750 return result; 750 return result;
751 } 751 }
752 } 752 }
753 753
754 /* Step 2. decode the authenticatedSafe. 754 /* Step 2. decode the authenticatedSafe.
755 */ 755 */
756 result = _decode_pkcs12_auth_safe (pkcs12->pkcs12, &c2, NULL); 756 result = _decodeMHD_pkcs12_auth_safe (pkcs12->pkcs12, &c2, NULL);
757 if (result < 0) 757 if (result < 0)
758 { 758 {
759 gnutls_assert (); 759 MHD_gnutls_assert ();
760 return result; 760 return result;
761 } 761 }
762 762
763 /* Step 3. Encode the bag elements into a SafeContents 763 /* Step 3. Encode the bag elements into a SafeContents
764 * structure. 764 * structure.
765 */ 765 */
766 result = _pkcs12_encode_safe_contents (bag, &safe_cont, &enc); 766 result = MHD_pkcs12_encode_safe_contents (bag, &safe_cont, &enc);
767 if (result < 0) 767 if (result < 0)
768 { 768 {
769 gnutls_assert (); 769 MHD_gnutls_assert ();
770 return result; 770 return result;
771 } 771 }
772 772
773 /* Step 4. Insert the encoded SafeContents into the AuthenticatedSafe 773 /* Step 4. Insert the encoded SafeContents into the AuthenticatedSafe
774 * structure. 774 * structure.
775 */ 775 */
776 result = asn1_write_value (c2, "", "NEW", 1); 776 result = MHD__asn1_write_value (c2, "", "NEW", 1);
777 if (result != ASN1_SUCCESS) 777 if (result != ASN1_SUCCESS)
778 { 778 {
779 gnutls_assert (); 779 MHD_gnutls_assert ();
780 result = mhd_gtls_asn2err (result); 780 result = MHD_gtls_asn2err (result);
781 goto cleanup; 781 goto cleanup;
782 } 782 }
783 783
784 if (enc) 784 if (enc)
785 result = asn1_write_value (c2, "?LAST.contentType", ENC_DATA_OID, 1); 785 result = MHD__asn1_write_value (c2, "?LAST.contentType", ENC_DATA_OID, 1);
786 else 786 else
787 result = asn1_write_value (c2, "?LAST.contentType", DATA_OID, 1); 787 result = MHD__asn1_write_value (c2, "?LAST.contentType", DATA_OID, 1);
788 if (result != ASN1_SUCCESS) 788 if (result != ASN1_SUCCESS)
789 { 789 {
790 gnutls_assert (); 790 MHD_gnutls_assert ();
791 result = mhd_gtls_asn2err (result); 791 result = MHD_gtls_asn2err (result);
792 goto cleanup; 792 goto cleanup;
793 } 793 }
794 794
@@ -797,56 +797,56 @@ gnutls_pkcs12_set_bag (gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag)
797 /* Encrypted packets are written directly. 797 /* Encrypted packets are written directly.
798 */ 798 */
799 result = 799 result =
800 asn1_write_value (c2, "?LAST.content", 800 MHD__asn1_write_value (c2, "?LAST.content",
801 bag->element[0].data.data, 801 bag->element[0].data.data,
802 bag->element[0].data.size); 802 bag->element[0].data.size);
803 if (result != ASN1_SUCCESS) 803 if (result != ASN1_SUCCESS)
804 { 804 {
805 gnutls_assert (); 805 MHD_gnutls_assert ();
806 result = mhd_gtls_asn2err (result); 806 result = MHD_gtls_asn2err (result);
807 goto cleanup; 807 goto cleanup;
808 } 808 }
809 } 809 }
810 else 810 else
811 { 811 {
812 result = 812 result =
813 _gnutls_x509_der_encode_and_copy (safe_cont, "", c2, 813 MHD__gnutls_x509_der_encode_and_copy (safe_cont, "", c2,
814 "?LAST.content", 1); 814 "?LAST.content", 1);
815 if (result < 0) 815 if (result < 0)
816 { 816 {
817 gnutls_assert (); 817 MHD_gnutls_assert ();
818 goto cleanup; 818 goto cleanup;
819 } 819 }
820 } 820 }
821 821
822 asn1_delete_structure (&safe_cont); 822 MHD__asn1_delete_structure (&safe_cont);
823 823
824 824
825 /* Step 5. Reencode and copy the AuthenticatedSafe into the pkcs12 825 /* Step 5. Reencode and copy the AuthenticatedSafe into the pkcs12
826 * structure. 826 * structure.
827 */ 827 */
828 result = 828 result =
829 _gnutls_x509_der_encode_and_copy (c2, "", pkcs12->pkcs12, 829 MHD__gnutls_x509_der_encode_and_copy (c2, "", pkcs12->pkcs12,
830 "authSafe.content", 1); 830 "authSafe.content", 1);
831 if (result < 0) 831 if (result < 0)
832 { 832 {
833 gnutls_assert (); 833 MHD_gnutls_assert ();
834 goto cleanup; 834 goto cleanup;
835 } 835 }
836 836
837 asn1_delete_structure (&c2); 837 MHD__asn1_delete_structure (&c2);
838 838
839 return 0; 839 return 0;
840 840
841cleanup: 841cleanup:
842 asn1_delete_structure (&c2); 842 MHD__asn1_delete_structure (&c2);
843 asn1_delete_structure (&safe_cont); 843 MHD__asn1_delete_structure (&safe_cont);
844 return result; 844 return result;
845} 845}
846 846
847/** 847/**
848 * gnutls_pkcs12_generate_mac - This function generates the MAC of the PKCS12 structure 848 * MHD_gnutlsMHD_pkcs12_generate_mac - This function generates the MAC of the PKCS12 structure
849 * @pkcs12: should contain a gnutls_pkcs12_t structure 849 * @pkcs12: should contain a MHD_gnutlsMHD_pkcs12_t structure
850 * @pass: The password for the MAC 850 * @pass: The password for the MAC
851 * 851 *
852 * This function will generate a MAC for the PKCS12 structure. 852 * This function will generate a MAC for the PKCS12 structure.
@@ -854,115 +854,115 @@ cleanup:
854 * 854 *
855 **/ 855 **/
856int 856int
857gnutls_pkcs12_generate_mac (gnutls_pkcs12_t pkcs12, const char *pass) 857MHD_gnutlsMHD_pkcs12_generate_mac (MHD_gnutlsMHD_pkcs12_t pkcs12, const char *pass)
858{ 858{
859 opaque salt[8], key[20]; 859 opaque salt[8], key[20];
860 int result; 860 int result;
861 mac_hd_t td1 = NULL; 861 mac_hd_t td1 = NULL;
862 gnutls_datum_t tmp = { NULL, 0 }; 862 MHD_gnutls_datum_t tmp = { NULL, 0 };
863 opaque sha_mac[20]; 863 opaque sha_mac[20];
864 864
865 if (pkcs12 == NULL) 865 if (pkcs12 == NULL)
866 { 866 {
867 gnutls_assert (); 867 MHD_gnutls_assert ();
868 return GNUTLS_E_INVALID_REQUEST; 868 return GNUTLS_E_INVALID_REQUEST;
869 } 869 }
870 870
871 /* Generate the salt. 871 /* Generate the salt.
872 */ 872 */
873 if (gc_nonce (salt, sizeof (salt)) != GC_OK) 873 if (MHD_gc_nonce (salt, sizeof (salt)) != GC_OK)
874 { 874 {
875 gnutls_assert (); 875 MHD_gnutls_assert ();
876 return GNUTLS_E_RANDOM_FAILED; 876 return GNUTLS_E_RANDOM_FAILED;
877 } 877 }
878 878
879 /* Write the salt into the structure. 879 /* Write the salt into the structure.
880 */ 880 */
881 result = 881 result =
882 asn1_write_value (pkcs12->pkcs12, "macData.macSalt", salt, sizeof (salt)); 882 MHD__asn1_write_value (pkcs12->pkcs12, "macData.macSalt", salt, sizeof (salt));
883 if (result != ASN1_SUCCESS) 883 if (result != ASN1_SUCCESS)
884 { 884 {
885 gnutls_assert (); 885 MHD_gnutls_assert ();
886 result = mhd_gtls_asn2err (result); 886 result = MHD_gtls_asn2err (result);
887 goto cleanup; 887 goto cleanup;
888 } 888 }
889 889
890 /* Generate the key. 890 /* Generate the key.
891 */ 891 */
892 result = _pkcs12_string_to_key (3 /*MAC*/, salt, sizeof (salt), 892 result = MHD_pkcs12_string_to_key (3 /*MAC*/, salt, sizeof (salt),
893 1, pass, sizeof (key), key); 893 1, pass, sizeof (key), key);
894 if (result < 0) 894 if (result < 0)
895 { 895 {
896 gnutls_assert (); 896 MHD_gnutls_assert ();
897 goto cleanup; 897 goto cleanup;
898 } 898 }
899 899
900 /* Get the data to be MACed 900 /* Get the data to be MACed
901 */ 901 */
902 result = _decode_pkcs12_auth_safe (pkcs12->pkcs12, NULL, &tmp); 902 result = _decodeMHD_pkcs12_auth_safe (pkcs12->pkcs12, NULL, &tmp);
903 if (result < 0) 903 if (result < 0)
904 { 904 {
905 gnutls_assert (); 905 MHD_gnutls_assert ();
906 goto cleanup; 906 goto cleanup;
907 } 907 }
908 908
909 /* MAC the data 909 /* MAC the data
910 */ 910 */
911 td1 = mhd_gtls_hmac_init (MHD_GNUTLS_MAC_SHA1, key, sizeof (key)); 911 td1 = MHD_gtls_MHD_hmac_init (MHD_GNUTLS_MAC_SHA1, key, sizeof (key));
912 if (td1 == GNUTLS_MAC_FAILED) 912 if (td1 == GNUTLS_MAC_FAILED)
913 { 913 {
914 gnutls_assert (); 914 MHD_gnutls_assert ();
915 result = GNUTLS_E_INTERNAL_ERROR; 915 result = GNUTLS_E_INTERNAL_ERROR;
916 goto cleanup; 916 goto cleanup;
917 } 917 }
918 918
919 mhd_gnutls_hash (td1, tmp.data, tmp.size); 919 MHD_gnutls_hash (td1, tmp.data, tmp.size);
920 _gnutls_free_datum (&tmp); 920 MHD__gnutls_free_datum (&tmp);
921 921
922 mhd_gnutls_hmac_deinit (td1, sha_mac); 922 MHD_gnutls_MHD_hmac_deinit (td1, sha_mac);
923 923
924 924
925 result = 925 result =
926 asn1_write_value (pkcs12->pkcs12, "macData.mac.digest", sha_mac, 926 MHD__asn1_write_value (pkcs12->pkcs12, "macData.mac.digest", sha_mac,
927 sizeof (sha_mac)); 927 sizeof (sha_mac));
928 if (result != ASN1_SUCCESS) 928 if (result != ASN1_SUCCESS)
929 { 929 {
930 gnutls_assert (); 930 MHD_gnutls_assert ();
931 result = mhd_gtls_asn2err (result); 931 result = MHD_gtls_asn2err (result);
932 goto cleanup; 932 goto cleanup;
933 } 933 }
934 934
935 result = 935 result =
936 asn1_write_value (pkcs12->pkcs12, 936 MHD__asn1_write_value (pkcs12->pkcs12,
937 "macData.mac.digestAlgorithm.parameters", NULL, 0); 937 "macData.mac.digestAlgorithm.parameters", NULL, 0);
938 if (result != ASN1_SUCCESS) 938 if (result != ASN1_SUCCESS)
939 { 939 {
940 gnutls_assert (); 940 MHD_gnutls_assert ();
941 result = mhd_gtls_asn2err (result); 941 result = MHD_gtls_asn2err (result);
942 goto cleanup; 942 goto cleanup;
943 } 943 }
944 944
945 result = 945 result =
946 asn1_write_value (pkcs12->pkcs12, 946 MHD__asn1_write_value (pkcs12->pkcs12,
947 "macData.mac.digestAlgorithm.algorithm", HASH_OID_SHA1, 947 "macData.mac.digestAlgorithm.algorithm", HASH_OID_SHA1,
948 1); 948 1);
949 if (result != ASN1_SUCCESS) 949 if (result != ASN1_SUCCESS)
950 { 950 {
951 gnutls_assert (); 951 MHD_gnutls_assert ();
952 result = mhd_gtls_asn2err (result); 952 result = MHD_gtls_asn2err (result);
953 goto cleanup; 953 goto cleanup;
954 } 954 }
955 955
956 return 0; 956 return 0;
957 957
958cleanup: 958cleanup:
959 _gnutls_free_datum (&tmp); 959 MHD__gnutls_free_datum (&tmp);
960 return result; 960 return result;
961} 961}
962 962
963/** 963/**
964 * gnutls_pkcs12_verify_mac - This function verifies the MAC of the PKCS12 structure 964 * MHD_gnutlsMHD_pkcs12_verify_mac - This function verifies the MAC of the PKCS12 structure
965 * @pkcs12: should contain a gnutls_pkcs12_t structure 965 * @pkcs12: should contain a MHD_gnutlsMHD_pkcs12_t structure
966 * @pass: The password for the MAC 966 * @pass: The password for the MAC
967 * 967 *
968 * This function will verify the MAC for the PKCS12 structure. 968 * This function will verify the MAC for the PKCS12 structure.
@@ -970,14 +970,14 @@ cleanup:
970 * 970 *
971 **/ 971 **/
972int 972int
973gnutls_pkcs12_verify_mac (gnutls_pkcs12_t pkcs12, const char *pass) 973MHD_gnutlsMHD_pkcs12_verify_mac (MHD_gnutlsMHD_pkcs12_t pkcs12, const char *pass)
974{ 974{
975 opaque key[20]; 975 opaque key[20];
976 int result; 976 int result;
977 unsigned int iter; 977 unsigned int iter;
978 int len; 978 int len;
979 mac_hd_t td1 = NULL; 979 mac_hd_t td1 = NULL;
980 gnutls_datum_t tmp = { NULL, 0 }, salt = 980 MHD_gnutls_datum_t tmp = { NULL, 0 }, salt =
981 { 981 {
982 NULL, 0}; 982 NULL, 0};
983 opaque sha_mac[20]; 983 opaque sha_mac[20];
@@ -985,7 +985,7 @@ gnutls_pkcs12_verify_mac (gnutls_pkcs12_t pkcs12, const char *pass)
985 985
986 if (pkcs12 == NULL) 986 if (pkcs12 == NULL)
987 { 987 {
988 gnutls_assert (); 988 MHD_gnutls_assert ();
989 return GNUTLS_E_INVALID_REQUEST; 989 return GNUTLS_E_INVALID_REQUEST;
990 } 990 }
991 991
@@ -993,7 +993,7 @@ gnutls_pkcs12_verify_mac (gnutls_pkcs12_t pkcs12, const char *pass)
993 */ 993 */
994 994
995 result = 995 result =
996 _gnutls_x509_read_uint (pkcs12->pkcs12, "macData.iterations", &iter); 996 MHD__gnutls_x509_read_uint (pkcs12->pkcs12, "macData.iterations", &iter);
997 if (result < 0) 997 if (result < 0)
998 { 998 {
999 iter = 1; /* the default */ 999 iter = 1; /* the default */
@@ -1003,78 +1003,78 @@ gnutls_pkcs12_verify_mac (gnutls_pkcs12_t pkcs12, const char *pass)
1003 /* Read the salt from the structure. 1003 /* Read the salt from the structure.
1004 */ 1004 */
1005 result = 1005 result =
1006 _gnutls_x509_read_value (pkcs12->pkcs12, "macData.macSalt", &salt, 0); 1006 MHD__gnutls_x509_read_value (pkcs12->pkcs12, "macData.macSalt", &salt, 0);
1007 if (result != ASN1_SUCCESS) 1007 if (result != ASN1_SUCCESS)
1008 { 1008 {
1009 gnutls_assert (); 1009 MHD_gnutls_assert ();
1010 result = mhd_gtls_asn2err (result); 1010 result = MHD_gtls_asn2err (result);
1011 goto cleanup; 1011 goto cleanup;
1012 } 1012 }
1013 1013
1014 /* Generate the key. 1014 /* Generate the key.
1015 */ 1015 */
1016 result = _pkcs12_string_to_key (3 /*MAC*/, salt.data, salt.size, 1016 result = MHD_pkcs12_string_to_key (3 /*MAC*/, salt.data, salt.size,
1017 iter, pass, sizeof (key), key); 1017 iter, pass, sizeof (key), key);
1018 if (result < 0) 1018 if (result < 0)
1019 { 1019 {
1020 gnutls_assert (); 1020 MHD_gnutls_assert ();
1021 goto cleanup; 1021 goto cleanup;
1022 } 1022 }
1023 1023
1024 _gnutls_free_datum (&salt); 1024 MHD__gnutls_free_datum (&salt);
1025 1025
1026 /* Get the data to be MACed 1026 /* Get the data to be MACed
1027 */ 1027 */
1028 result = _decode_pkcs12_auth_safe (pkcs12->pkcs12, NULL, &tmp); 1028 result = _decodeMHD_pkcs12_auth_safe (pkcs12->pkcs12, NULL, &tmp);
1029 if (result < 0) 1029 if (result < 0)
1030 { 1030 {
1031 gnutls_assert (); 1031 MHD_gnutls_assert ();
1032 goto cleanup; 1032 goto cleanup;
1033 } 1033 }
1034 1034
1035 /* MAC the data 1035 /* MAC the data
1036 */ 1036 */
1037 td1 = mhd_gtls_hmac_init (MHD_GNUTLS_MAC_SHA1, key, sizeof (key)); 1037 td1 = MHD_gtls_MHD_hmac_init (MHD_GNUTLS_MAC_SHA1, key, sizeof (key));
1038 if (td1 == GNUTLS_MAC_FAILED) 1038 if (td1 == GNUTLS_MAC_FAILED)
1039 { 1039 {
1040 gnutls_assert (); 1040 MHD_gnutls_assert ();
1041 result = GNUTLS_E_INTERNAL_ERROR; 1041 result = GNUTLS_E_INTERNAL_ERROR;
1042 goto cleanup; 1042 goto cleanup;
1043 } 1043 }
1044 1044
1045 mhd_gnutls_hash (td1, tmp.data, tmp.size); 1045 MHD_gnutls_hash (td1, tmp.data, tmp.size);
1046 _gnutls_free_datum (&tmp); 1046 MHD__gnutls_free_datum (&tmp);
1047 1047
1048 mhd_gnutls_hmac_deinit (td1, sha_mac); 1048 MHD_gnutls_MHD_hmac_deinit (td1, sha_mac);
1049 1049
1050 len = sizeof (sha_mac_orig); 1050 len = sizeof (sha_mac_orig);
1051 result = 1051 result =
1052 asn1_read_value (pkcs12->pkcs12, "macData.mac.digest", sha_mac_orig, 1052 MHD__asn1_read_value (pkcs12->pkcs12, "macData.mac.digest", sha_mac_orig,
1053 &len); 1053 &len);
1054 if (result != ASN1_SUCCESS) 1054 if (result != ASN1_SUCCESS)
1055 { 1055 {
1056 gnutls_assert (); 1056 MHD_gnutls_assert ();
1057 result = mhd_gtls_asn2err (result); 1057 result = MHD_gtls_asn2err (result);
1058 goto cleanup; 1058 goto cleanup;
1059 } 1059 }
1060 1060
1061 if (memcmp (sha_mac_orig, sha_mac, sizeof (sha_mac)) != 0) 1061 if (memcmp (sha_mac_orig, sha_mac, sizeof (sha_mac)) != 0)
1062 { 1062 {
1063 gnutls_assert (); 1063 MHD_gnutls_assert ();
1064 return GNUTLS_E_MAC_VERIFY_FAILED; 1064 return GNUTLS_E_MAC_VERIFY_FAILED;
1065 } 1065 }
1066 1066
1067 return 0; 1067 return 0;
1068 1068
1069cleanup: 1069cleanup:
1070 _gnutls_free_datum (&tmp); 1070 MHD__gnutls_free_datum (&tmp);
1071 _gnutls_free_datum (&salt); 1071 MHD__gnutls_free_datum (&salt);
1072 return result; 1072 return result;
1073} 1073}
1074 1074
1075 1075
1076static int 1076static int
1077write_attributes (gnutls_pkcs12_bag_t bag, int elem, 1077write_attributes (MHD_gnutlsMHD_pkcs12_bag_t bag, int elem,
1078 ASN1_TYPE c2, const char *where) 1078 ASN1_TYPE c2, const char *where)
1079{ 1079{
1080 int result; 1080 int result;
@@ -1088,11 +1088,11 @@ write_attributes (gnutls_pkcs12_bag_t bag, int elem,
1088 { 1088 {
1089 /* no attributes 1089 /* no attributes
1090 */ 1090 */
1091 result = asn1_write_value (c2, where, NULL, 0); 1091 result = MHD__asn1_write_value (c2, where, NULL, 0);
1092 if (result != ASN1_SUCCESS) 1092 if (result != ASN1_SUCCESS)
1093 { 1093 {
1094 gnutls_assert (); 1094 MHD_gnutls_assert ();
1095 return mhd_gtls_asn2err (result); 1095 return MHD_gtls_asn2err (result);
1096 } 1096 }
1097 1097
1098 return 0; 1098 return 0;
@@ -1103,25 +1103,25 @@ write_attributes (gnutls_pkcs12_bag_t bag, int elem,
1103 1103
1104 /* Add a new Attribute 1104 /* Add a new Attribute
1105 */ 1105 */
1106 result = asn1_write_value (c2, where, "NEW", 1); 1106 result = MHD__asn1_write_value (c2, where, "NEW", 1);
1107 if (result != ASN1_SUCCESS) 1107 if (result != ASN1_SUCCESS)
1108 { 1108 {
1109 gnutls_assert (); 1109 MHD_gnutls_assert ();
1110 return mhd_gtls_asn2err (result); 1110 return MHD_gtls_asn2err (result);
1111 } 1111 }
1112 1112
1113 mhd_gtls_str_cpy (root, sizeof (root), where); 1113 MHD_gtls_str_cpy (root, sizeof (root), where);
1114 mhd_gtls_str_cat (root, sizeof (root), ".?LAST"); 1114 MHD_gtls_str_cat (root, sizeof (root), ".?LAST");
1115 1115
1116 result = 1116 result =
1117 _gnutls_x509_encode_and_write_attribute (KEY_ID_OID, c2, root, 1117 MHD__gnutls_x509_encode_and_write_attribute (KEY_ID_OID, c2, root,
1118 bag->element[elem]. 1118 bag->element[elem].
1119 local_key_id.data, 1119 local_key_id.data,
1120 bag->element[elem]. 1120 bag->element[elem].
1121 local_key_id.size, 1); 1121 local_key_id.size, 1);
1122 if (result < 0) 1122 if (result < 0)
1123 { 1123 {
1124 gnutls_assert (); 1124 MHD_gnutls_assert ();
1125 return result; 1125 return result;
1126 } 1126 }
1127 } 1127 }
@@ -1134,21 +1134,21 @@ write_attributes (gnutls_pkcs12_bag_t bag, int elem,
1134 1134
1135 /* Add a new Attribute 1135 /* Add a new Attribute
1136 */ 1136 */
1137 result = asn1_write_value (c2, where, "NEW", 1); 1137 result = MHD__asn1_write_value (c2, where, "NEW", 1);
1138 if (result != ASN1_SUCCESS) 1138 if (result != ASN1_SUCCESS)
1139 { 1139 {
1140 gnutls_assert (); 1140 MHD_gnutls_assert ();
1141 return mhd_gtls_asn2err (result); 1141 return MHD_gtls_asn2err (result);
1142 } 1142 }
1143 1143
1144 /* convert name to BMPString 1144 /* convert name to BMPString
1145 */ 1145 */
1146 size = strlen (bag->element[elem].friendly_name) * 2; 1146 size = strlen (bag->element[elem].friendly_name) * 2;
1147 name = gnutls_malloc (size); 1147 name = MHD_gnutls_malloc (size);
1148 1148
1149 if (name == NULL) 1149 if (name == NULL)
1150 { 1150 {
1151 gnutls_assert (); 1151 MHD_gnutls_assert ();
1152 return GNUTLS_E_MEMORY_ERROR; 1152 return GNUTLS_E_MEMORY_ERROR;
1153 } 1153 }
1154 1154
@@ -1160,18 +1160,18 @@ write_attributes (gnutls_pkcs12_bag_t bag, int elem,
1160 p++; 1160 p++;
1161 } 1161 }
1162 1162
1163 mhd_gtls_str_cpy (root, sizeof (root), where); 1163 MHD_gtls_str_cpy (root, sizeof (root), where);
1164 mhd_gtls_str_cat (root, sizeof (root), ".?LAST"); 1164 MHD_gtls_str_cat (root, sizeof (root), ".?LAST");
1165 1165
1166 result = 1166 result =
1167 _gnutls_x509_encode_and_write_attribute (FRIENDLY_NAME_OID, c2, 1167 MHD__gnutls_x509_encode_and_write_attribute (FRIENDLY_NAME_OID, c2,
1168 root, name, size, 1); 1168 root, name, size, 1);
1169 1169
1170 gnutls_free (name); 1170 MHD_gnutls_free (name);
1171 1171
1172 if (result < 0) 1172 if (result < 0)
1173 { 1173 {
1174 gnutls_assert (); 1174 MHD_gnutls_assert ();
1175 return result; 1175 return result;
1176 } 1176 }
1177 } 1177 }
@@ -1184,7 +1184,7 @@ write_attributes (gnutls_pkcs12_bag_t bag, int elem,
1184 * the given datum. Enc is set to non zero if the data are encrypted; 1184 * the given datum. Enc is set to non zero if the data are encrypted;
1185 */ 1185 */
1186int 1186int
1187_pkcs12_encode_safe_contents (gnutls_pkcs12_bag_t bag, ASN1_TYPE * contents, 1187MHD_pkcs12_encode_safe_contents (MHD_gnutlsMHD_pkcs12_bag_t bag, ASN1_TYPE * contents,
1188 int *enc) 1188 int *enc)
1189{ 1189{
1190 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 1190 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
@@ -1203,12 +1203,12 @@ _pkcs12_encode_safe_contents (gnutls_pkcs12_bag_t bag, ASN1_TYPE * contents,
1203 /* Step 1. Create the SEQUENCE. 1203 /* Step 1. Create the SEQUENCE.
1204 */ 1204 */
1205 1205
1206 if ((result = asn1_create_element 1206 if ((result = MHD__asn1_create_element
1207 (_gnutls_get_pkix (), "PKIX1.pkcs-12-SafeContents", 1207 (MHD__gnutls_get_pkix (), "PKIX1.pkcs-12-SafeContents",
1208 &c2)) != ASN1_SUCCESS) 1208 &c2)) != ASN1_SUCCESS)
1209 { 1209 {
1210 gnutls_assert (); 1210 MHD_gnutls_assert ();
1211 result = mhd_gtls_asn2err (result); 1211 result = MHD_gtls_asn2err (result);
1212 goto cleanup; 1212 goto cleanup;
1213 } 1213 }
1214 1214
@@ -1218,25 +1218,25 @@ _pkcs12_encode_safe_contents (gnutls_pkcs12_bag_t bag, ASN1_TYPE * contents,
1218 oid = bag_to_oid (bag->element[i].type); 1218 oid = bag_to_oid (bag->element[i].type);
1219 if (oid == NULL) 1219 if (oid == NULL)
1220 { 1220 {
1221 gnutls_assert (); 1221 MHD_gnutls_assert ();
1222 continue; 1222 continue;
1223 } 1223 }
1224 1224
1225 result = asn1_write_value (c2, "", "NEW", 1); 1225 result = MHD__asn1_write_value (c2, "", "NEW", 1);
1226 if (result != ASN1_SUCCESS) 1226 if (result != ASN1_SUCCESS)
1227 { 1227 {
1228 gnutls_assert (); 1228 MHD_gnutls_assert ();
1229 result = mhd_gtls_asn2err (result); 1229 result = MHD_gtls_asn2err (result);
1230 goto cleanup; 1230 goto cleanup;
1231 } 1231 }
1232 1232
1233 /* Copy the bag type. 1233 /* Copy the bag type.
1234 */ 1234 */
1235 result = asn1_write_value (c2, "?LAST.bagId", oid, 1); 1235 result = MHD__asn1_write_value (c2, "?LAST.bagId", oid, 1);
1236 if (result != ASN1_SUCCESS) 1236 if (result != ASN1_SUCCESS)
1237 { 1237 {
1238 gnutls_assert (); 1238 MHD_gnutls_assert ();
1239 result = mhd_gtls_asn2err (result); 1239 result = MHD_gtls_asn2err (result);
1240 goto cleanup; 1240 goto cleanup;
1241 } 1241 }
1242 1242
@@ -1245,7 +1245,7 @@ _pkcs12_encode_safe_contents (gnutls_pkcs12_bag_t bag, ASN1_TYPE * contents,
1245 result = write_attributes (bag, i, c2, "?LAST.bagAttributes"); 1245 result = write_attributes (bag, i, c2, "?LAST.bagAttributes");
1246 if (result < 0) 1246 if (result < 0)
1247 { 1247 {
1248 gnutls_assert (); 1248 MHD_gnutls_assert ();
1249 goto cleanup; 1249 goto cleanup;
1250 } 1250 }
1251 1251
@@ -1256,37 +1256,37 @@ _pkcs12_encode_safe_contents (gnutls_pkcs12_bag_t bag, ASN1_TYPE * contents,
1256 if (bag->element[i].type == GNUTLS_BAG_CERTIFICATE || 1256 if (bag->element[i].type == GNUTLS_BAG_CERTIFICATE ||
1257 bag->element[i].type == GNUTLS_BAG_CRL) 1257 bag->element[i].type == GNUTLS_BAG_CRL)
1258 { 1258 {
1259 gnutls_datum_t tmp; 1259 MHD_gnutls_datum_t tmp;
1260 1260
1261 /* in that case encode it to a CertBag or 1261 /* in that case encode it to a CertBag or
1262 * a CrlBag. 1262 * a CrlBag.
1263 */ 1263 */
1264 1264
1265 result = 1265 result =
1266 _pkcs12_encode_crt_bag (bag->element[i].type, 1266 MHD_pkcs12_encode_crt_bag (bag->element[i].type,
1267 &bag->element[i].data, &tmp); 1267 &bag->element[i].data, &tmp);
1268 1268
1269 if (result < 0) 1269 if (result < 0)
1270 { 1270 {
1271 gnutls_assert (); 1271 MHD_gnutls_assert ();
1272 goto cleanup; 1272 goto cleanup;
1273 } 1273 }
1274 1274
1275 result = _gnutls_x509_write_value (c2, "?LAST.bagValue", &tmp, 0); 1275 result = MHD__gnutls_x509_write_value (c2, "?LAST.bagValue", &tmp, 0);
1276 1276
1277 _gnutls_free_datum (&tmp); 1277 MHD__gnutls_free_datum (&tmp);
1278 1278
1279 } 1279 }
1280 else 1280 else
1281 { 1281 {
1282 1282
1283 result = _gnutls_x509_write_value (c2, "?LAST.bagValue", 1283 result = MHD__gnutls_x509_write_value (c2, "?LAST.bagValue",
1284 &bag->element[i].data, 0); 1284 &bag->element[i].data, 0);
1285 } 1285 }
1286 1286
1287 if (result < 0) 1287 if (result < 0)
1288 { 1288 {
1289 gnutls_assert (); 1289 MHD_gnutls_assert ();
1290 goto cleanup; 1290 goto cleanup;
1291 } 1291 }
1292 1292
@@ -1300,7 +1300,7 @@ _pkcs12_encode_safe_contents (gnutls_pkcs12_bag_t bag, ASN1_TYPE * contents,
1300 1300
1301cleanup: 1301cleanup:
1302 if (c2) 1302 if (c2)
1303 asn1_delete_structure (&c2); 1303 MHD__asn1_delete_structure (&c2);
1304 return result; 1304 return result;
1305 1305
1306} 1306}
diff --git a/src/daemon/https/x509/pkcs12.h b/src/daemon/https/x509/pkcs12.h
index 38131ece..565ed5e5 100644
--- a/src/daemon/https/x509/pkcs12.h
+++ b/src/daemon/https/x509/pkcs12.h
@@ -37,15 +37,15 @@ extern "C"
37 37
38/* PKCS12 structures handling 38/* PKCS12 structures handling
39 */ 39 */
40 struct gnutls_pkcs12_int; 40 struct MHD_gnutlsMHD_pkcs12_int;
41 41
42 struct gnutls_pkcs12_bag_int; 42 struct MHD_gnutlsMHD_pkcs12_bag_int;
43 typedef struct gnutls_pkcs12_int 43 typedef struct MHD_gnutlsMHD_pkcs12_int
44 { 44 {
45 ASN1_TYPE pkcs12; 45 ASN1_TYPE pkcs12;
46 } gnutls_pkcs12_int; 46 } MHD_gnutlsMHD_pkcs12_int;
47 47
48 typedef enum gnutls_pkcs12_bag_type_t 48 typedef enum MHD_gnutlsMHD_pkcs12_bag_type_t
49 { 49 {
50 GNUTLS_BAG_EMPTY = 0, 50 GNUTLS_BAG_EMPTY = 0,
51 51
@@ -55,73 +55,73 @@ extern "C"
55 GNUTLS_BAG_CRL, 55 GNUTLS_BAG_CRL,
56 GNUTLS_BAG_ENCRYPTED = 10, 56 GNUTLS_BAG_ENCRYPTED = 10,
57 GNUTLS_BAG_UNKNOWN = 20 57 GNUTLS_BAG_UNKNOWN = 20
58 } gnutls_pkcs12_bag_type_t; 58 } MHD_gnutlsMHD_pkcs12_bag_type_t;
59 59
60 struct bag_element 60 struct bag_element
61 { 61 {
62 gnutls_datum_t data; 62 MHD_gnutls_datum_t data;
63 gnutls_pkcs12_bag_type_t type; 63 MHD_gnutlsMHD_pkcs12_bag_type_t type;
64 gnutls_datum_t local_key_id; 64 MHD_gnutls_datum_t local_key_id;
65 char *friendly_name; 65 char *friendly_name;
66 }; 66 };
67 67
68 typedef struct gnutls_pkcs12_bag_int 68 typedef struct MHD_gnutlsMHD_pkcs12_bag_int
69 { 69 {
70 struct bag_element element[MAX_BAG_ELEMENTS]; 70 struct bag_element element[MAX_BAG_ELEMENTS];
71 int bag_elements; 71 int bag_elements;
72 } gnutls_pkcs12_bag_int; 72 } MHD_gnutlsMHD_pkcs12_bag_int;
73 73
74/* Bag attributes */ 74/* Bag attributes */
75#define FRIENDLY_NAME_OID "1.2.840.113549.1.9.20" 75#define FRIENDLY_NAME_OID "1.2.840.113549.1.9.20"
76#define KEY_ID_OID "1.2.840.113549.1.9.21" 76#define KEY_ID_OID "1.2.840.113549.1.9.21"
77 77
78 typedef struct gnutls_pkcs12_int *gnutls_pkcs12_t; 78 typedef struct MHD_gnutlsMHD_pkcs12_int *MHD_gnutlsMHD_pkcs12_t;
79 typedef struct gnutls_pkcs12_bag_int *gnutls_pkcs12_bag_t; 79 typedef struct MHD_gnutlsMHD_pkcs12_bag_int *MHD_gnutlsMHD_pkcs12_bag_t;
80 80
81 int gnutls_pkcs12_init (gnutls_pkcs12_t * pkcs12); 81 int MHD_gnutlsMHD_pkcs12_init (MHD_gnutlsMHD_pkcs12_t * pkcs12);
82 void gnutls_pkcs12_deinit (gnutls_pkcs12_t pkcs12); 82 void MHD_gnutlsMHD_pkcs12_deinit (MHD_gnutlsMHD_pkcs12_t pkcs12);
83 int gnutls_pkcs12_import (gnutls_pkcs12_t pkcs12, 83 int MHD_gnutlsMHD_pkcs12_import (MHD_gnutlsMHD_pkcs12_t pkcs12,
84 const gnutls_datum_t * data, 84 const MHD_gnutls_datum_t * data,
85 gnutls_x509_crt_fmt_t format, unsigned int flags); 85 MHD_gnutls_x509_crt_fmt_t format, unsigned int flags);
86 int gnutls_pkcs12_export (gnutls_pkcs12_t pkcs12, 86 int MHD_gnutlsMHD_pkcs12_export (MHD_gnutlsMHD_pkcs12_t pkcs12,
87 gnutls_x509_crt_fmt_t format, 87 MHD_gnutls_x509_crt_fmt_t format,
88 void *output_data, size_t * output_data_size); 88 void *output_data, size_t * output_data_size);
89 89
90 int gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12, 90 int MHD_gnutlsMHD_pkcs12_get_bag (MHD_gnutlsMHD_pkcs12_t pkcs12,
91 int indx, gnutls_pkcs12_bag_t bag); 91 int indx, MHD_gnutlsMHD_pkcs12_bag_t bag);
92 int gnutls_pkcs12_set_bag (gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag); 92 int MHD_gnutlsMHD_pkcs12_set_bag (MHD_gnutlsMHD_pkcs12_t pkcs12, MHD_gnutlsMHD_pkcs12_bag_t bag);
93 93
94 int gnutls_pkcs12_generate_mac (gnutls_pkcs12_t pkcs12, const char *pass); 94 int MHD_gnutlsMHD_pkcs12_generate_mac (MHD_gnutlsMHD_pkcs12_t pkcs12, const char *pass);
95 int gnutls_pkcs12_verify_mac (gnutls_pkcs12_t pkcs12, const char *pass); 95 int MHD_gnutlsMHD_pkcs12_verify_mac (MHD_gnutlsMHD_pkcs12_t pkcs12, const char *pass);
96 96
97 int gnutls_pkcs12_bag_decrypt (gnutls_pkcs12_bag_t bag, const char *pass); 97 int MHD_gnutlsMHD_pkcs12_bag_decrypt (MHD_gnutlsMHD_pkcs12_bag_t bag, const char *pass);
98 int gnutls_pkcs12_bag_encrypt (gnutls_pkcs12_bag_t bag, 98 int MHD_gnutlsMHD_pkcs12_bag_encrypt (MHD_gnutlsMHD_pkcs12_bag_t bag,
99 const char *pass, unsigned int flags); 99 const char *pass, unsigned int flags);
100 100
101 gnutls_pkcs12_bag_type_t gnutls_pkcs12_bag_get_type (gnutls_pkcs12_bag_t 101 MHD_gnutlsMHD_pkcs12_bag_type_t MHD_gnutlsMHD_pkcs12_bag_get_type (MHD_gnutlsMHD_pkcs12_bag_t
102 bag, int indx); 102 bag, int indx);
103 int gnutls_pkcs12_bag_get_data (gnutls_pkcs12_bag_t bag, 103 int MHD_gnutlsMHD_pkcs12_bag_get_data (MHD_gnutlsMHD_pkcs12_bag_t bag,
104 int indx, gnutls_datum_t * data); 104 int indx, MHD_gnutls_datum_t * data);
105 int gnutls_pkcs12_bag_set_data (gnutls_pkcs12_bag_t bag, 105 int MHD_gnutlsMHD_pkcs12_bag_set_data (MHD_gnutlsMHD_pkcs12_bag_t bag,
106 gnutls_pkcs12_bag_type_t type, 106 MHD_gnutlsMHD_pkcs12_bag_type_t type,
107 const gnutls_datum_t * data); 107 const MHD_gnutls_datum_t * data);
108 int gnutls_pkcs12_bag_set_crl (gnutls_pkcs12_bag_t bag, 108 int MHD_gnutlsMHD_pkcs12_bag_set_crl (MHD_gnutlsMHD_pkcs12_bag_t bag,
109 gnutls_x509_crl_t crl); 109 MHD_gnutls_x509_crl_t crl);
110 int gnutls_pkcs12_bag_set_crt (gnutls_pkcs12_bag_t bag, 110 int MHD_gnutlsMHD_pkcs12_bag_set_crt (MHD_gnutlsMHD_pkcs12_bag_t bag,
111 gnutls_x509_crt_t crt); 111 MHD_gnutls_x509_crt_t crt);
112 112
113 int gnutls_pkcs12_bag_init (gnutls_pkcs12_bag_t * bag); 113 int MHD_gnutlsMHD_pkcs12_bag_init (MHD_gnutlsMHD_pkcs12_bag_t * bag);
114 void gnutls_pkcs12_bag_deinit (gnutls_pkcs12_bag_t bag); 114 void MHD_gnutlsMHD_pkcs12_bag_deinit (MHD_gnutlsMHD_pkcs12_bag_t bag);
115 int gnutls_pkcs12_bag_get_count (gnutls_pkcs12_bag_t bag); 115 int MHD_gnutlsMHD_pkcs12_bag_get_count (MHD_gnutlsMHD_pkcs12_bag_t bag);
116 116
117 int gnutls_pkcs12_bag_get_key_id (gnutls_pkcs12_bag_t bag, 117 int MHD_gnutlsMHD_pkcs12_bag_get_key_id (MHD_gnutlsMHD_pkcs12_bag_t bag,
118 int indx, gnutls_datum_t * id); 118 int indx, MHD_gnutls_datum_t * id);
119 int gnutls_pkcs12_bag_set_key_id (gnutls_pkcs12_bag_t bag, 119 int MHD_gnutlsMHD_pkcs12_bag_set_key_id (MHD_gnutlsMHD_pkcs12_bag_t bag,
120 int indx, const gnutls_datum_t * id); 120 int indx, const MHD_gnutls_datum_t * id);
121 121
122 int gnutls_pkcs12_bag_get_friendly_name (gnutls_pkcs12_bag_t bag, 122 int MHD_gnutlsMHD_pkcs12_bag_get_friendly_name (MHD_gnutlsMHD_pkcs12_bag_t bag,
123 int indx, char **name); 123 int indx, char **name);
124 int gnutls_pkcs12_bag_set_friendly_name (gnutls_pkcs12_bag_t bag, 124 int MHD_gnutlsMHD_pkcs12_bag_set_friendly_name (MHD_gnutlsMHD_pkcs12_bag_t bag,
125 int indx, const char *name); 125 int indx, const char *name);
126 126
127#ifdef __cplusplus 127#ifdef __cplusplus
@@ -138,27 +138,27 @@ extern "C"
138#define DATA_OID "1.2.840.113549.1.7.1" 138#define DATA_OID "1.2.840.113549.1.7.1"
139#define ENC_DATA_OID "1.2.840.113549.1.7.6" 139#define ENC_DATA_OID "1.2.840.113549.1.7.6"
140 140
141int gnutls_pkcs12_init (gnutls_pkcs12_t * pkcs12); 141int MHD_gnutlsMHD_pkcs12_init (MHD_gnutlsMHD_pkcs12_t * pkcs12);
142void gnutls_pkcs12_deinit (gnutls_pkcs12_t pkcs12); 142void MHD_gnutlsMHD_pkcs12_deinit (MHD_gnutlsMHD_pkcs12_t pkcs12);
143int gnutls_pkcs12_import (gnutls_pkcs12_t pkcs12, 143int MHD_gnutlsMHD_pkcs12_import (MHD_gnutlsMHD_pkcs12_t pkcs12,
144 const gnutls_datum_t * data, 144 const MHD_gnutls_datum_t * data,
145 gnutls_x509_crt_fmt_t format, unsigned int flags); 145 MHD_gnutls_x509_crt_fmt_t format, unsigned int flags);
146 146
147int gnutls_pkcs12_get_bag (gnutls_pkcs12_t pkcs12, 147int MHD_gnutlsMHD_pkcs12_get_bag (MHD_gnutlsMHD_pkcs12_t pkcs12,
148 int indx, gnutls_pkcs12_bag_t bag); 148 int indx, MHD_gnutlsMHD_pkcs12_bag_t bag);
149 149
150int gnutls_pkcs12_bag_init (gnutls_pkcs12_bag_t * bag); 150int MHD_gnutlsMHD_pkcs12_bag_init (MHD_gnutlsMHD_pkcs12_bag_t * bag);
151void gnutls_pkcs12_bag_deinit (gnutls_pkcs12_bag_t bag); 151void MHD_gnutlsMHD_pkcs12_bag_deinit (MHD_gnutlsMHD_pkcs12_bag_t bag);
152 152
153int _pkcs12_string_to_key (unsigned int id, 153int MHD_pkcs12_string_to_key (unsigned int id,
154 const opaque * salt, 154 const opaque * salt,
155 unsigned int salt_size, 155 unsigned int salt_size,
156 unsigned int iter, 156 unsigned int iter,
157 const char *pw, 157 const char *pw,
158 unsigned int req_keylen, opaque * keybuf); 158 unsigned int req_keylen, opaque * keybuf);
159 159
160int _gnutls_pkcs7_decrypt_data (const gnutls_datum_t * data, 160int MHD__gnutls_pkcs7_decrypt_data (const MHD_gnutls_datum_t * data,
161 const char *password, gnutls_datum_t * dec); 161 const char *password, MHD_gnutls_datum_t * dec);
162 162
163typedef enum schema_id 163typedef enum schema_id
164{ 164{
@@ -168,18 +168,18 @@ typedef enum schema_id
168 PKCS12_RC2_40_SHA1 168 PKCS12_RC2_40_SHA1
169} schema_id; 169} schema_id;
170 170
171int _gnutls_pkcs7_encrypt_data (schema_id schema, 171int MHD__gnutls_pkcs7_encrypt_data (schema_id schema,
172 const gnutls_datum_t * data, 172 const MHD_gnutls_datum_t * data,
173 const char *password, gnutls_datum_t * enc); 173 const char *password, MHD_gnutls_datum_t * enc);
174int _pkcs12_decode_safe_contents (const gnutls_datum_t * content, 174int MHD_pkcs12_decode_safe_contents (const MHD_gnutls_datum_t * content,
175 gnutls_pkcs12_bag_t bag); 175 MHD_gnutlsMHD_pkcs12_bag_t bag);
176 176
177int _pkcs12_encode_safe_contents (gnutls_pkcs12_bag_t bag, 177int MHD_pkcs12_encode_safe_contents (MHD_gnutlsMHD_pkcs12_bag_t bag,
178 ASN1_TYPE * content, int *enc); 178 ASN1_TYPE * content, int *enc);
179 179
180int _pkcs12_decode_crt_bag (gnutls_pkcs12_bag_type_t type, 180int MHD_pkcs12_decode_crt_bag (MHD_gnutlsMHD_pkcs12_bag_type_t type,
181 const gnutls_datum_t * in, gnutls_datum_t * out); 181 const MHD_gnutls_datum_t * in, MHD_gnutls_datum_t * out);
182int _pkcs12_encode_crt_bag (gnutls_pkcs12_bag_type_t type, 182int MHD_pkcs12_encode_crt_bag (MHD_gnutlsMHD_pkcs12_bag_type_t type,
183 const gnutls_datum_t * raw, gnutls_datum_t * out); 183 const MHD_gnutls_datum_t * raw, MHD_gnutls_datum_t * out);
184 184
185#endif /* GNUTLS_PKCS12_H */ 185#endif /* GNUTLS_PKCS12_H */
diff --git a/src/daemon/https/x509/pkcs12_bag.c b/src/daemon/https/x509/pkcs12_bag.c
index 63b290bc..10529273 100644
--- a/src/daemon/https/x509/pkcs12_bag.c
+++ b/src/daemon/https/x509/pkcs12_bag.c
@@ -37,7 +37,7 @@
37#include <privkey.h> 37#include <privkey.h>
38 38
39/** 39/**
40 * gnutls_pkcs12_bag_init - This function initializes a gnutls_pkcs12_bag_t structure 40 * MHD_gnutlsMHD_pkcs12_bag_init - This function initializes a MHD_gnutlsMHD_pkcs12_bag_t structure
41 * @bag: The structure to be initialized 41 * @bag: The structure to be initialized
42 * 42 *
43 * This function will initialize a PKCS12 bag structure. PKCS12 Bags 43 * This function will initialize a PKCS12 bag structure. PKCS12 Bags
@@ -48,9 +48,9 @@
48 * 48 *
49 **/ 49 **/
50int 50int
51gnutls_pkcs12_bag_init (gnutls_pkcs12_bag_t * bag) 51MHD_gnutlsMHD_pkcs12_bag_init (MHD_gnutlsMHD_pkcs12_bag_t * bag)
52{ 52{
53 *bag = gnutls_calloc (1, sizeof (gnutls_pkcs12_bag_int)); 53 *bag = MHD_gnutls_calloc (1, sizeof (MHD_gnutlsMHD_pkcs12_bag_int));
54 54
55 if (*bag) 55 if (*bag)
56 { 56 {
@@ -60,15 +60,15 @@ gnutls_pkcs12_bag_init (gnutls_pkcs12_bag_t * bag)
60} 60}
61 61
62static inline void 62static inline void
63_pkcs12_bag_free_data (gnutls_pkcs12_bag_t bag) 63MHD_pkcs12_bag_free_data (MHD_gnutlsMHD_pkcs12_bag_t bag)
64{ 64{
65 int i; 65 int i;
66 66
67 for (i = 0; i < bag->bag_elements; i++) 67 for (i = 0; i < bag->bag_elements; i++)
68 { 68 {
69 _gnutls_free_datum (&bag->element[i].data); 69 MHD__gnutls_free_datum (&bag->element[i].data);
70 _gnutls_free_datum (&bag->element[i].local_key_id); 70 MHD__gnutls_free_datum (&bag->element[i].local_key_id);
71 gnutls_free (bag->element[i].friendly_name); 71 MHD_gnutls_free (bag->element[i].friendly_name);
72 bag->element[i].friendly_name = NULL; 72 bag->element[i].friendly_name = NULL;
73 bag->element[i].type = 0; 73 bag->element[i].type = 0;
74 } 74 }
@@ -77,38 +77,38 @@ _pkcs12_bag_free_data (gnutls_pkcs12_bag_t bag)
77 77
78 78
79/** 79/**
80 * gnutls_pkcs12_bag_deinit - This function deinitializes memory used by a gnutls_pkcs12_t structure 80 * MHD_gnutlsMHD_pkcs12_bag_deinit - This function deinitializes memory used by a MHD_gnutlsMHD_pkcs12_t structure
81 * @bag: The structure to be initialized 81 * @bag: The structure to be initialized
82 * 82 *
83 * This function will deinitialize a PKCS12 Bag structure. 83 * This function will deinitialize a PKCS12 Bag structure.
84 * 84 *
85 **/ 85 **/
86void 86void
87gnutls_pkcs12_bag_deinit (gnutls_pkcs12_bag_t bag) 87MHD_gnutlsMHD_pkcs12_bag_deinit (MHD_gnutlsMHD_pkcs12_bag_t bag)
88{ 88{
89 if (!bag) 89 if (!bag)
90 return; 90 return;
91 91
92 _pkcs12_bag_free_data (bag); 92 MHD_pkcs12_bag_free_data (bag);
93 93
94 gnutls_free (bag); 94 MHD_gnutls_free (bag);
95} 95}
96 96
97/** 97/**
98 * gnutls_pkcs12_bag_get_type - This function returns the bag's type 98 * MHD_gnutlsMHD_pkcs12_bag_get_type - This function returns the bag's type
99 * @bag: The bag 99 * @bag: The bag
100 * @indx: The element of the bag to get the type 100 * @indx: The element of the bag to get the type
101 * 101 *
102 * This function will return the bag's type. One of the gnutls_pkcs12_bag_type_t 102 * This function will return the bag's type. One of the MHD_gnutlsMHD_pkcs12_bag_type_t
103 * enumerations. 103 * enumerations.
104 * 104 *
105 **/ 105 **/
106gnutls_pkcs12_bag_type_t 106MHD_gnutlsMHD_pkcs12_bag_type_t
107gnutls_pkcs12_bag_get_type (gnutls_pkcs12_bag_t bag, int indx) 107MHD_gnutlsMHD_pkcs12_bag_get_type (MHD_gnutlsMHD_pkcs12_bag_t bag, int indx)
108{ 108{
109 if (bag == NULL) 109 if (bag == NULL)
110 { 110 {
111 gnutls_assert (); 111 MHD_gnutls_assert ();
112 return GNUTLS_E_INVALID_REQUEST; 112 return GNUTLS_E_INVALID_REQUEST;
113 } 113 }
114 114
@@ -118,18 +118,18 @@ gnutls_pkcs12_bag_get_type (gnutls_pkcs12_bag_t bag, int indx)
118} 118}
119 119
120/** 120/**
121 * gnutls_pkcs12_bag_get_count - This function returns the bag's elements count 121 * MHD_gnutlsMHD_pkcs12_bag_get_count - This function returns the bag's elements count
122 * @bag: The bag 122 * @bag: The bag
123 * 123 *
124 * This function will return the number of the elements withing the bag. 124 * This function will return the number of the elements withing the bag.
125 * 125 *
126 **/ 126 **/
127int 127int
128gnutls_pkcs12_bag_get_count (gnutls_pkcs12_bag_t bag) 128MHD_gnutlsMHD_pkcs12_bag_get_count (MHD_gnutlsMHD_pkcs12_bag_t bag)
129{ 129{
130 if (bag == NULL) 130 if (bag == NULL)
131 { 131 {
132 gnutls_assert (); 132 MHD_gnutls_assert ();
133 return GNUTLS_E_INVALID_REQUEST; 133 return GNUTLS_E_INVALID_REQUEST;
134 } 134 }
135 135
@@ -137,7 +137,7 @@ gnutls_pkcs12_bag_get_count (gnutls_pkcs12_bag_t bag)
137} 137}
138 138
139/** 139/**
140 * gnutls_pkcs12_bag_get_data - This function returns the bag's data 140 * MHD_gnutlsMHD_pkcs12_bag_get_data - This function returns the bag's data
141 * @bag: The bag 141 * @bag: The bag
142 * @indx: The element of the bag to get the data from 142 * @indx: The element of the bag to get the data from
143 * @data: where the bag's data will be. Should be treated as constant. 143 * @data: where the bag's data will be. Should be treated as constant.
@@ -150,12 +150,12 @@ gnutls_pkcs12_bag_get_count (gnutls_pkcs12_bag_t bag)
150 * 150 *
151 **/ 151 **/
152int 152int
153gnutls_pkcs12_bag_get_data (gnutls_pkcs12_bag_t bag, int indx, 153MHD_gnutlsMHD_pkcs12_bag_get_data (MHD_gnutlsMHD_pkcs12_bag_t bag, int indx,
154 gnutls_datum_t * data) 154 MHD_gnutls_datum_t * data)
155{ 155{
156 if (bag == NULL) 156 if (bag == NULL)
157 { 157 {
158 gnutls_assert (); 158 MHD_gnutls_assert ();
159 return GNUTLS_E_INVALID_REQUEST; 159 return GNUTLS_E_INVALID_REQUEST;
160 } 160 }
161 161
@@ -172,161 +172,161 @@ gnutls_pkcs12_bag_get_data (gnutls_pkcs12_bag_t bag, int indx,
172#define X509_CRL_OID "1.2.840.113549.1.9.23.1" 172#define X509_CRL_OID "1.2.840.113549.1.9.23.1"
173 173
174int 174int
175_pkcs12_decode_crt_bag (gnutls_pkcs12_bag_type_t type, 175MHD_pkcs12_decode_crt_bag (MHD_gnutlsMHD_pkcs12_bag_type_t type,
176 const gnutls_datum_t * in, gnutls_datum_t * out) 176 const MHD_gnutls_datum_t * in, MHD_gnutls_datum_t * out)
177{ 177{
178 int ret; 178 int ret;
179 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 179 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
180 180
181 if (type == GNUTLS_BAG_CERTIFICATE) 181 if (type == GNUTLS_BAG_CERTIFICATE)
182 { 182 {
183 if ((ret = asn1_create_element (_gnutls_get_pkix (), 183 if ((ret = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
184 "PKIX1.pkcs-12-CertBag", 184 "PKIX1.pkcs-12-CertBag",
185 &c2)) != ASN1_SUCCESS) 185 &c2)) != ASN1_SUCCESS)
186 { 186 {
187 gnutls_assert (); 187 MHD_gnutls_assert ();
188 ret = mhd_gtls_asn2err (ret); 188 ret = MHD_gtls_asn2err (ret);
189 goto cleanup; 189 goto cleanup;
190 } 190 }
191 191
192 ret = asn1_der_decoding (&c2, in->data, in->size, NULL); 192 ret = MHD__asn1_der_decoding (&c2, in->data, in->size, NULL);
193 if (ret != ASN1_SUCCESS) 193 if (ret != ASN1_SUCCESS)
194 { 194 {
195 gnutls_assert (); 195 MHD_gnutls_assert ();
196 ret = mhd_gtls_asn2err (ret); 196 ret = MHD_gtls_asn2err (ret);
197 goto cleanup; 197 goto cleanup;
198 } 198 }
199 199
200 ret = _gnutls_x509_read_value (c2, "certValue", out, 1); 200 ret = MHD__gnutls_x509_read_value (c2, "certValue", out, 1);
201 if (ret < 0) 201 if (ret < 0)
202 { 202 {
203 gnutls_assert (); 203 MHD_gnutls_assert ();
204 goto cleanup; 204 goto cleanup;
205 } 205 }
206 206
207 } 207 }
208 else 208 else
209 { /* CRL */ 209 { /* CRL */
210 if ((ret = asn1_create_element (_gnutls_get_pkix (), 210 if ((ret = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
211 "PKIX1.pkcs-12-CRLBag", 211 "PKIX1.pkcs-12-CRLBag",
212 &c2)) != ASN1_SUCCESS) 212 &c2)) != ASN1_SUCCESS)
213 { 213 {
214 gnutls_assert (); 214 MHD_gnutls_assert ();
215 ret = mhd_gtls_asn2err (ret); 215 ret = MHD_gtls_asn2err (ret);
216 goto cleanup; 216 goto cleanup;
217 } 217 }
218 218
219 ret = asn1_der_decoding (&c2, in->data, in->size, NULL); 219 ret = MHD__asn1_der_decoding (&c2, in->data, in->size, NULL);
220 if (ret != ASN1_SUCCESS) 220 if (ret != ASN1_SUCCESS)
221 { 221 {
222 gnutls_assert (); 222 MHD_gnutls_assert ();
223 ret = mhd_gtls_asn2err (ret); 223 ret = MHD_gtls_asn2err (ret);
224 goto cleanup; 224 goto cleanup;
225 } 225 }
226 226
227 ret = _gnutls_x509_read_value (c2, "crlValue", out, 1); 227 ret = MHD__gnutls_x509_read_value (c2, "crlValue", out, 1);
228 if (ret < 0) 228 if (ret < 0)
229 { 229 {
230 gnutls_assert (); 230 MHD_gnutls_assert ();
231 goto cleanup; 231 goto cleanup;
232 } 232 }
233 } 233 }
234 234
235 asn1_delete_structure (&c2); 235 MHD__asn1_delete_structure (&c2);
236 236
237 return 0; 237 return 0;
238 238
239 239
240cleanup: 240cleanup:
241 241
242 asn1_delete_structure (&c2); 242 MHD__asn1_delete_structure (&c2);
243 return ret; 243 return ret;
244} 244}
245 245
246 246
247int 247int
248_pkcs12_encode_crt_bag (gnutls_pkcs12_bag_type_t type, 248MHD_pkcs12_encode_crt_bag (MHD_gnutlsMHD_pkcs12_bag_type_t type,
249 const gnutls_datum_t * raw, gnutls_datum_t * out) 249 const MHD_gnutls_datum_t * raw, MHD_gnutls_datum_t * out)
250{ 250{
251 int ret; 251 int ret;
252 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 252 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
253 253
254 if (type == GNUTLS_BAG_CERTIFICATE) 254 if (type == GNUTLS_BAG_CERTIFICATE)
255 { 255 {
256 if ((ret = asn1_create_element (_gnutls_get_pkix (), 256 if ((ret = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
257 "PKIX1.pkcs-12-CertBag", 257 "PKIX1.pkcs-12-CertBag",
258 &c2)) != ASN1_SUCCESS) 258 &c2)) != ASN1_SUCCESS)
259 { 259 {
260 gnutls_assert (); 260 MHD_gnutls_assert ();
261 ret = mhd_gtls_asn2err (ret); 261 ret = MHD_gtls_asn2err (ret);
262 goto cleanup; 262 goto cleanup;
263 } 263 }
264 264
265 ret = asn1_write_value (c2, "certId", X509_CERT_OID, 1); 265 ret = MHD__asn1_write_value (c2, "certId", X509_CERT_OID, 1);
266 if (ret != ASN1_SUCCESS) 266 if (ret != ASN1_SUCCESS)
267 { 267 {
268 gnutls_assert (); 268 MHD_gnutls_assert ();
269 ret = mhd_gtls_asn2err (ret); 269 ret = MHD_gtls_asn2err (ret);
270 goto cleanup; 270 goto cleanup;
271 } 271 }
272 272
273 ret = _gnutls_x509_write_value (c2, "certValue", raw, 1); 273 ret = MHD__gnutls_x509_write_value (c2, "certValue", raw, 1);
274 if (ret < 0) 274 if (ret < 0)
275 { 275 {
276 gnutls_assert (); 276 MHD_gnutls_assert ();
277 goto cleanup; 277 goto cleanup;
278 } 278 }
279 279
280 } 280 }
281 else 281 else
282 { /* CRL */ 282 { /* CRL */
283 if ((ret = asn1_create_element (_gnutls_get_pkix (), 283 if ((ret = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
284 "PKIX1.pkcs-12-CRLBag", 284 "PKIX1.pkcs-12-CRLBag",
285 &c2)) != ASN1_SUCCESS) 285 &c2)) != ASN1_SUCCESS)
286 { 286 {
287 gnutls_assert (); 287 MHD_gnutls_assert ();
288 ret = mhd_gtls_asn2err (ret); 288 ret = MHD_gtls_asn2err (ret);
289 goto cleanup; 289 goto cleanup;
290 } 290 }
291 291
292 ret = asn1_write_value (c2, "crlId", X509_CRL_OID, 1); 292 ret = MHD__asn1_write_value (c2, "crlId", X509_CRL_OID, 1);
293 if (ret != ASN1_SUCCESS) 293 if (ret != ASN1_SUCCESS)
294 { 294 {
295 gnutls_assert (); 295 MHD_gnutls_assert ();
296 ret = mhd_gtls_asn2err (ret); 296 ret = MHD_gtls_asn2err (ret);
297 goto cleanup; 297 goto cleanup;
298 } 298 }
299 299
300 ret = _gnutls_x509_write_value (c2, "crlValue", raw, 1); 300 ret = MHD__gnutls_x509_write_value (c2, "crlValue", raw, 1);
301 if (ret < 0) 301 if (ret < 0)
302 { 302 {
303 gnutls_assert (); 303 MHD_gnutls_assert ();
304 goto cleanup; 304 goto cleanup;
305 } 305 }
306 } 306 }
307 307
308 ret = _gnutls_x509_der_encode (c2, "", out, 0); 308 ret = MHD__gnutls_x509_der_encode (c2, "", out, 0);
309 309
310 if (ret < 0) 310 if (ret < 0)
311 { 311 {
312 gnutls_assert (); 312 MHD_gnutls_assert ();
313 goto cleanup; 313 goto cleanup;
314 } 314 }
315 315
316 asn1_delete_structure (&c2); 316 MHD__asn1_delete_structure (&c2);
317 317
318 return 0; 318 return 0;
319 319
320 320
321cleanup: 321cleanup:
322 322
323 asn1_delete_structure (&c2); 323 MHD__asn1_delete_structure (&c2);
324 return ret; 324 return ret;
325} 325}
326 326
327 327
328/** 328/**
329 * gnutls_pkcs12_bag_set_data - This function inserts data into the bag 329 * MHD_gnutlsMHD_pkcs12_bag_set_data - This function inserts data into the bag
330 * @bag: The bag 330 * @bag: The bag
331 * @type: The data's type 331 * @type: The data's type
332 * @data: the data to be copied. 332 * @data: the data to be copied.
@@ -339,20 +339,20 @@ cleanup:
339 * 339 *
340 **/ 340 **/
341int 341int
342gnutls_pkcs12_bag_set_data (gnutls_pkcs12_bag_t bag, 342MHD_gnutlsMHD_pkcs12_bag_set_data (MHD_gnutlsMHD_pkcs12_bag_t bag,
343 gnutls_pkcs12_bag_type_t type, 343 MHD_gnutlsMHD_pkcs12_bag_type_t type,
344 const gnutls_datum_t * data) 344 const MHD_gnutls_datum_t * data)
345{ 345{
346 int ret; 346 int ret;
347 if (bag == NULL) 347 if (bag == NULL)
348 { 348 {
349 gnutls_assert (); 349 MHD_gnutls_assert ();
350 return GNUTLS_E_INVALID_REQUEST; 350 return GNUTLS_E_INVALID_REQUEST;
351 } 351 }
352 352
353 if (bag->bag_elements == MAX_BAG_ELEMENTS - 1) 353 if (bag->bag_elements == MAX_BAG_ELEMENTS - 1)
354 { 354 {
355 gnutls_assert (); 355 MHD_gnutls_assert ();
356 /* bag is full */ 356 /* bag is full */
357 return GNUTLS_E_MEMORY_ERROR; 357 return GNUTLS_E_MEMORY_ERROR;
358 } 358 }
@@ -367,18 +367,18 @@ gnutls_pkcs12_bag_set_data (gnutls_pkcs12_bag_t bag,
367 bag->element[0].type == GNUTLS_BAG_PKCS8_ENCRYPTED_KEY || 367 bag->element[0].type == GNUTLS_BAG_PKCS8_ENCRYPTED_KEY ||
368 bag->element[0].type == GNUTLS_BAG_ENCRYPTED) 368 bag->element[0].type == GNUTLS_BAG_ENCRYPTED)
369 { 369 {
370 gnutls_assert (); 370 MHD_gnutls_assert ();
371 return GNUTLS_E_INVALID_REQUEST; 371 return GNUTLS_E_INVALID_REQUEST;
372 } 372 }
373 } 373 }
374 374
375 ret = 375 ret =
376 _gnutls_set_datum (&bag->element[bag->bag_elements].data, 376 MHD__gnutls_set_datum (&bag->element[bag->bag_elements].data,
377 data->data, data->size); 377 data->data, data->size);
378 378
379 if (ret < 0) 379 if (ret < 0)
380 { 380 {
381 gnutls_assert (); 381 MHD_gnutls_assert ();
382 return ret; 382 return ret;
383 } 383 }
384 384
@@ -390,84 +390,84 @@ gnutls_pkcs12_bag_set_data (gnutls_pkcs12_bag_t bag,
390} 390}
391 391
392/** 392/**
393 * gnutls_pkcs12_bag_set_crt - This function inserts a certificate into the bag 393 * MHD_gnutlsMHD_pkcs12_bag_set_crt - This function inserts a certificate into the bag
394 * @bag: The bag 394 * @bag: The bag
395 * @crt: the certificate to be copied. 395 * @crt: the certificate to be copied.
396 * 396 *
397 * This function will insert the given certificate into the 397 * This function will insert the given certificate into the
398 * bag. This is just a wrapper over gnutls_pkcs12_bag_set_data(). 398 * bag. This is just a wrapper over MHD_gnutlsMHD_pkcs12_bag_set_data().
399 * 399 *
400 * Returns the index of the added bag on success, or a negative 400 * Returns the index of the added bag on success, or a negative
401 * value on failure. 401 * value on failure.
402 * 402 *
403 **/ 403 **/
404int 404int
405gnutls_pkcs12_bag_set_crt (gnutls_pkcs12_bag_t bag, gnutls_x509_crt_t crt) 405MHD_gnutlsMHD_pkcs12_bag_set_crt (MHD_gnutlsMHD_pkcs12_bag_t bag, MHD_gnutls_x509_crt_t crt)
406{ 406{
407 int ret; 407 int ret;
408 gnutls_datum_t data; 408 MHD_gnutls_datum_t data;
409 409
410 if (bag == NULL) 410 if (bag == NULL)
411 { 411 {
412 gnutls_assert (); 412 MHD_gnutls_assert ();
413 return GNUTLS_E_INVALID_REQUEST; 413 return GNUTLS_E_INVALID_REQUEST;
414 } 414 }
415 415
416 ret = _gnutls_x509_der_encode (crt->cert, "", &data, 0); 416 ret = MHD__gnutls_x509_der_encode (crt->cert, "", &data, 0);
417 if (ret < 0) 417 if (ret < 0)
418 { 418 {
419 gnutls_assert (); 419 MHD_gnutls_assert ();
420 return ret; 420 return ret;
421 } 421 }
422 422
423 ret = gnutls_pkcs12_bag_set_data (bag, GNUTLS_BAG_CERTIFICATE, &data); 423 ret = MHD_gnutlsMHD_pkcs12_bag_set_data (bag, GNUTLS_BAG_CERTIFICATE, &data);
424 424
425 _gnutls_free_datum (&data); 425 MHD__gnutls_free_datum (&data);
426 426
427 return ret; 427 return ret;
428} 428}
429 429
430/** 430/**
431 * gnutls_pkcs12_bag_set_crl - This function inserts the CRL into the bag 431 * MHD_gnutlsMHD_pkcs12_bag_set_crl - This function inserts the CRL into the bag
432 * @bag: The bag 432 * @bag: The bag
433 * @crl: the CRL to be copied. 433 * @crl: the CRL to be copied.
434 * 434 *
435 * This function will insert the given CRL into the 435 * This function will insert the given CRL into the
436 * bag. This is just a wrapper over gnutls_pkcs12_bag_set_data(). 436 * bag. This is just a wrapper over MHD_gnutlsMHD_pkcs12_bag_set_data().
437 * 437 *
438 * Returns the index of the added bag on success, or a negative 438 * Returns the index of the added bag on success, or a negative
439 * value on failure. 439 * value on failure.
440 * 440 *
441 **/ 441 **/
442int 442int
443gnutls_pkcs12_bag_set_crl (gnutls_pkcs12_bag_t bag, gnutls_x509_crl_t crl) 443MHD_gnutlsMHD_pkcs12_bag_set_crl (MHD_gnutlsMHD_pkcs12_bag_t bag, MHD_gnutls_x509_crl_t crl)
444{ 444{
445 int ret; 445 int ret;
446 gnutls_datum_t data; 446 MHD_gnutls_datum_t data;
447 447
448 448
449 if (bag == NULL) 449 if (bag == NULL)
450 { 450 {
451 gnutls_assert (); 451 MHD_gnutls_assert ();
452 return GNUTLS_E_INVALID_REQUEST; 452 return GNUTLS_E_INVALID_REQUEST;
453 } 453 }
454 454
455 ret = _gnutls_x509_der_encode (crl->crl, "", &data, 0); 455 ret = MHD__gnutls_x509_der_encode (crl->crl, "", &data, 0);
456 if (ret < 0) 456 if (ret < 0)
457 { 457 {
458 gnutls_assert (); 458 MHD_gnutls_assert ();
459 return ret; 459 return ret;
460 } 460 }
461 461
462 ret = gnutls_pkcs12_bag_set_data (bag, GNUTLS_BAG_CRL, &data); 462 ret = MHD_gnutlsMHD_pkcs12_bag_set_data (bag, GNUTLS_BAG_CRL, &data);
463 463
464 _gnutls_free_datum (&data); 464 MHD__gnutls_free_datum (&data);
465 465
466 return ret; 466 return ret;
467} 467}
468 468
469/** 469/**
470 * gnutls_pkcs12_bag_set_key_id - This function sets a key ID into the bag element 470 * MHD_gnutlsMHD_pkcs12_bag_set_key_id - This function sets a key ID into the bag element
471 * @bag: The bag 471 * @bag: The bag
472 * @indx: The bag's element to add the id 472 * @indx: The bag's element to add the id
473 * @id: the ID 473 * @id: the ID
@@ -480,30 +480,30 @@ gnutls_pkcs12_bag_set_crl (gnutls_pkcs12_bag_t bag, gnutls_x509_crl_t crl)
480 * 480 *
481 **/ 481 **/
482int 482int
483gnutls_pkcs12_bag_set_key_id (gnutls_pkcs12_bag_t bag, int indx, 483MHD_gnutlsMHD_pkcs12_bag_set_key_id (MHD_gnutlsMHD_pkcs12_bag_t bag, int indx,
484 const gnutls_datum_t * id) 484 const MHD_gnutls_datum_t * id)
485{ 485{
486 int ret; 486 int ret;
487 487
488 488
489 if (bag == NULL) 489 if (bag == NULL)
490 { 490 {
491 gnutls_assert (); 491 MHD_gnutls_assert ();
492 return GNUTLS_E_INVALID_REQUEST; 492 return GNUTLS_E_INVALID_REQUEST;
493 } 493 }
494 494
495 if (indx > bag->bag_elements - 1) 495 if (indx > bag->bag_elements - 1)
496 { 496 {
497 gnutls_assert (); 497 MHD_gnutls_assert ();
498 return GNUTLS_E_INVALID_REQUEST; 498 return GNUTLS_E_INVALID_REQUEST;
499 } 499 }
500 500
501 ret = _gnutls_set_datum (&bag->element[indx].local_key_id, 501 ret = MHD__gnutls_set_datum (&bag->element[indx].local_key_id,
502 id->data, id->size); 502 id->data, id->size);
503 503
504 if (ret < 0) 504 if (ret < 0)
505 { 505 {
506 gnutls_assert (); 506 MHD_gnutls_assert ();
507 return ret; 507 return ret;
508 } 508 }
509 509
@@ -511,7 +511,7 @@ gnutls_pkcs12_bag_set_key_id (gnutls_pkcs12_bag_t bag, int indx,
511} 511}
512 512
513/** 513/**
514 * gnutls_pkcs12_bag_get_key_id - This function gets the key ID from the bag element 514 * MHD_gnutlsMHD_pkcs12_bag_get_key_id - This function gets the key ID from the bag element
515 * @bag: The bag 515 * @bag: The bag
516 * @indx: The bag's element to add the id 516 * @indx: The bag's element to add the id
517 * @id: where the ID will be copied (to be treated as const) 517 * @id: where the ID will be copied (to be treated as const)
@@ -523,18 +523,18 @@ gnutls_pkcs12_bag_set_key_id (gnutls_pkcs12_bag_t bag, int indx,
523 * 523 *
524 **/ 524 **/
525int 525int
526gnutls_pkcs12_bag_get_key_id (gnutls_pkcs12_bag_t bag, int indx, 526MHD_gnutlsMHD_pkcs12_bag_get_key_id (MHD_gnutlsMHD_pkcs12_bag_t bag, int indx,
527 gnutls_datum_t * id) 527 MHD_gnutls_datum_t * id)
528{ 528{
529 if (bag == NULL) 529 if (bag == NULL)
530 { 530 {
531 gnutls_assert (); 531 MHD_gnutls_assert ();
532 return GNUTLS_E_INVALID_REQUEST; 532 return GNUTLS_E_INVALID_REQUEST;
533 } 533 }
534 534
535 if (indx > bag->bag_elements - 1) 535 if (indx > bag->bag_elements - 1)
536 { 536 {
537 gnutls_assert (); 537 MHD_gnutls_assert ();
538 return GNUTLS_E_INVALID_REQUEST; 538 return GNUTLS_E_INVALID_REQUEST;
539 } 539 }
540 540
@@ -545,7 +545,7 @@ gnutls_pkcs12_bag_get_key_id (gnutls_pkcs12_bag_t bag, int indx,
545} 545}
546 546
547/** 547/**
548 * gnutls_pkcs12_bag_get_friendly_name - This function returns the friendly name of the bag element 548 * MHD_gnutlsMHD_pkcs12_bag_get_friendly_name - This function returns the friendly name of the bag element
549 * @bag: The bag 549 * @bag: The bag
550 * @indx: The bag's element to add the id 550 * @indx: The bag's element to add the id
551 * @name: will hold a pointer to the name (to be treated as const) 551 * @name: will hold a pointer to the name (to be treated as const)
@@ -557,18 +557,18 @@ gnutls_pkcs12_bag_get_key_id (gnutls_pkcs12_bag_t bag, int indx,
557 * 557 *
558 **/ 558 **/
559int 559int
560gnutls_pkcs12_bag_get_friendly_name (gnutls_pkcs12_bag_t bag, int indx, 560MHD_gnutlsMHD_pkcs12_bag_get_friendly_name (MHD_gnutlsMHD_pkcs12_bag_t bag, int indx,
561 char **name) 561 char **name)
562{ 562{
563 if (bag == NULL) 563 if (bag == NULL)
564 { 564 {
565 gnutls_assert (); 565 MHD_gnutls_assert ();
566 return GNUTLS_E_INVALID_REQUEST; 566 return GNUTLS_E_INVALID_REQUEST;
567 } 567 }
568 568
569 if (indx > bag->bag_elements - 1) 569 if (indx > bag->bag_elements - 1)
570 { 570 {
571 gnutls_assert (); 571 MHD_gnutls_assert ();
572 return GNUTLS_E_INVALID_REQUEST; 572 return GNUTLS_E_INVALID_REQUEST;
573 } 573 }
574 574
@@ -579,7 +579,7 @@ gnutls_pkcs12_bag_get_friendly_name (gnutls_pkcs12_bag_t bag, int indx,
579 579
580 580
581/** 581/**
582 * gnutls_pkcs12_bag_set_friendly_name - This function sets a friendly name into the bag element 582 * MHD_gnutlsMHD_pkcs12_bag_set_friendly_name - This function sets a friendly name into the bag element
583 * @bag: The bag 583 * @bag: The bag
584 * @indx: The bag's element to add the id 584 * @indx: The bag's element to add the id
585 * @name: the name 585 * @name: the name
@@ -592,26 +592,26 @@ gnutls_pkcs12_bag_get_friendly_name (gnutls_pkcs12_bag_t bag, int indx,
592 * 592 *
593 **/ 593 **/
594int 594int
595gnutls_pkcs12_bag_set_friendly_name (gnutls_pkcs12_bag_t bag, int indx, 595MHD_gnutlsMHD_pkcs12_bag_set_friendly_name (MHD_gnutlsMHD_pkcs12_bag_t bag, int indx,
596 const char *name) 596 const char *name)
597{ 597{
598 if (bag == NULL) 598 if (bag == NULL)
599 { 599 {
600 gnutls_assert (); 600 MHD_gnutls_assert ();
601 return GNUTLS_E_INVALID_REQUEST; 601 return GNUTLS_E_INVALID_REQUEST;
602 } 602 }
603 603
604 if (indx > bag->bag_elements - 1) 604 if (indx > bag->bag_elements - 1)
605 { 605 {
606 gnutls_assert (); 606 MHD_gnutls_assert ();
607 return GNUTLS_E_INVALID_REQUEST; 607 return GNUTLS_E_INVALID_REQUEST;
608 } 608 }
609 609
610 bag->element[indx].friendly_name = gnutls_strdup (name); 610 bag->element[indx].friendly_name = MHD_gnutls_strdup (name);
611 611
612 if (name == NULL) 612 if (name == NULL)
613 { 613 {
614 gnutls_assert (); 614 MHD_gnutls_assert ();
615 return GNUTLS_E_MEMORY_ERROR; 615 return GNUTLS_E_MEMORY_ERROR;
616 } 616 }
617 617
@@ -620,7 +620,7 @@ gnutls_pkcs12_bag_set_friendly_name (gnutls_pkcs12_bag_t bag, int indx,
620 620
621 621
622/** 622/**
623 * gnutls_pkcs12_bag_decrypt - This function will decrypt an encrypted bag 623 * MHD_gnutlsMHD_pkcs12_bag_decrypt - This function will decrypt an encrypted bag
624 * @bag: The bag 624 * @bag: The bag
625 * @pass: The password used for encryption. This can only be ASCII. 625 * @pass: The password used for encryption. This can only be ASCII.
626 * 626 *
@@ -628,28 +628,28 @@ gnutls_pkcs12_bag_set_friendly_name (gnutls_pkcs12_bag_t bag, int indx,
628 * 628 *
629 **/ 629 **/
630int 630int
631gnutls_pkcs12_bag_decrypt (gnutls_pkcs12_bag_t bag, const char *pass) 631MHD_gnutlsMHD_pkcs12_bag_decrypt (MHD_gnutlsMHD_pkcs12_bag_t bag, const char *pass)
632{ 632{
633 int ret; 633 int ret;
634 gnutls_datum_t dec; 634 MHD_gnutls_datum_t dec;
635 635
636 if (bag == NULL) 636 if (bag == NULL)
637 { 637 {
638 gnutls_assert (); 638 MHD_gnutls_assert ();
639 return GNUTLS_E_INVALID_REQUEST; 639 return GNUTLS_E_INVALID_REQUEST;
640 } 640 }
641 641
642 if (bag->element[0].type != GNUTLS_BAG_ENCRYPTED) 642 if (bag->element[0].type != GNUTLS_BAG_ENCRYPTED)
643 { 643 {
644 gnutls_assert (); 644 MHD_gnutls_assert ();
645 return GNUTLS_E_INVALID_REQUEST; 645 return GNUTLS_E_INVALID_REQUEST;
646 } 646 }
647 647
648 ret = _gnutls_pkcs7_decrypt_data (&bag->element[0].data, pass, &dec); 648 ret = MHD__gnutls_pkcs7_decrypt_data (&bag->element[0].data, pass, &dec);
649 649
650 if (ret < 0) 650 if (ret < 0)
651 { 651 {
652 gnutls_assert (); 652 MHD_gnutls_assert ();
653 return ret; 653 return ret;
654 } 654 }
655 655
@@ -657,15 +657,15 @@ gnutls_pkcs12_bag_decrypt (gnutls_pkcs12_bag_t bag, const char *pass)
657 * stuff, and parse it. 657 * stuff, and parse it.
658 */ 658 */
659 659
660 _gnutls_free_datum (&bag->element[0].data); 660 MHD__gnutls_free_datum (&bag->element[0].data);
661 661
662 ret = _pkcs12_decode_safe_contents (&dec, bag); 662 ret = MHD_pkcs12_decode_safe_contents (&dec, bag);
663 663
664 _gnutls_free_datum (&dec); 664 MHD__gnutls_free_datum (&dec);
665 665
666 if (ret < 0) 666 if (ret < 0)
667 { 667 {
668 gnutls_assert (); 668 MHD_gnutls_assert ();
669 return ret; 669 return ret;
670 } 670 }
671 671
@@ -673,61 +673,61 @@ gnutls_pkcs12_bag_decrypt (gnutls_pkcs12_bag_t bag, const char *pass)
673} 673}
674 674
675/** 675/**
676 * gnutls_pkcs12_bag_encrypt - This function will encrypt a bag 676 * MHD_gnutlsMHD_pkcs12_bag_encrypt - This function will encrypt a bag
677 * @bag: The bag 677 * @bag: The bag
678 * @pass: The password used for encryption. This can only be ASCII. 678 * @pass: The password used for encryption. This can only be ASCII.
679 * @flags: should be one of gnutls_pkcs_encrypt_flags_t elements bitwise or'd 679 * @flags: should be one of MHD_gnutls_pkcs_encrypt_flags_t elements bitwise or'd
680 * 680 *
681 * This function will encrypt the given bag and return 0 on success. 681 * This function will encrypt the given bag and return 0 on success.
682 * 682 *
683 **/ 683 **/
684int 684int
685gnutls_pkcs12_bag_encrypt (gnutls_pkcs12_bag_t bag, const char *pass, 685MHD_gnutlsMHD_pkcs12_bag_encrypt (MHD_gnutlsMHD_pkcs12_bag_t bag, const char *pass,
686 unsigned int flags) 686 unsigned int flags)
687{ 687{
688 int ret; 688 int ret;
689 ASN1_TYPE safe_cont = ASN1_TYPE_EMPTY; 689 ASN1_TYPE safe_cont = ASN1_TYPE_EMPTY;
690 gnutls_datum_t der = { NULL, 0 }; 690 MHD_gnutls_datum_t der = { NULL, 0 };
691 gnutls_datum_t enc = { NULL, 0 }; 691 MHD_gnutls_datum_t enc = { NULL, 0 };
692 schema_id id; 692 schema_id id;
693 693
694 if (bag == NULL) 694 if (bag == NULL)
695 { 695 {
696 gnutls_assert (); 696 MHD_gnutls_assert ();
697 return GNUTLS_E_INVALID_REQUEST; 697 return GNUTLS_E_INVALID_REQUEST;
698 } 698 }
699 699
700 if (bag->element[0].type == GNUTLS_BAG_ENCRYPTED) 700 if (bag->element[0].type == GNUTLS_BAG_ENCRYPTED)
701 { 701 {
702 gnutls_assert (); 702 MHD_gnutls_assert ();
703 return GNUTLS_E_INVALID_REQUEST; 703 return GNUTLS_E_INVALID_REQUEST;
704 } 704 }
705 705
706 /* Encode the whole bag to a safe contents 706 /* Encode the whole bag to a safe contents
707 * structure. 707 * structure.
708 */ 708 */
709 ret = _pkcs12_encode_safe_contents (bag, &safe_cont, NULL); 709 ret = MHD_pkcs12_encode_safe_contents (bag, &safe_cont, NULL);
710 if (ret < 0) 710 if (ret < 0)
711 { 711 {
712 gnutls_assert (); 712 MHD_gnutls_assert ();
713 return ret; 713 return ret;
714 } 714 }
715 715
716 /* DER encode the SafeContents. 716 /* DER encode the SafeContents.
717 */ 717 */
718 ret = _gnutls_x509_der_encode (safe_cont, "", &der, 0); 718 ret = MHD__gnutls_x509_der_encode (safe_cont, "", &der, 0);
719 719
720 asn1_delete_structure (&safe_cont); 720 MHD__asn1_delete_structure (&safe_cont);
721 721
722 if (ret < 0) 722 if (ret < 0)
723 { 723 {
724 gnutls_assert (); 724 MHD_gnutls_assert ();
725 return ret; 725 return ret;
726 } 726 }
727 727
728 if (flags & GNUTLS_PKCS_PLAIN) 728 if (flags & GNUTLS_PKCS_PLAIN)
729 { 729 {
730 gnutls_assert (); 730 MHD_gnutls_assert ();
731 return GNUTLS_E_INVALID_REQUEST; 731 return GNUTLS_E_INVALID_REQUEST;
732 } 732 }
733 733
@@ -742,20 +742,20 @@ gnutls_pkcs12_bag_encrypt (gnutls_pkcs12_bag_t bag, const char *pass,
742 742
743 /* Now encrypt them. 743 /* Now encrypt them.
744 */ 744 */
745 ret = _gnutls_pkcs7_encrypt_data (id, &der, pass, &enc); 745 ret = MHD__gnutls_pkcs7_encrypt_data (id, &der, pass, &enc);
746 746
747 _gnutls_free_datum (&der); 747 MHD__gnutls_free_datum (&der);
748 748
749 if (ret < 0) 749 if (ret < 0)
750 { 750 {
751 gnutls_assert (); 751 MHD_gnutls_assert ();
752 return ret; 752 return ret;
753 } 753 }
754 754
755 /* encryption succeeded. 755 /* encryption succeeded.
756 */ 756 */
757 757
758 _pkcs12_bag_free_data (bag); 758 MHD_pkcs12_bag_free_data (bag);
759 759
760 bag->element[0].type = GNUTLS_BAG_ENCRYPTED; 760 bag->element[0].type = GNUTLS_BAG_ENCRYPTED;
761 bag->element[0].data = enc; 761 bag->element[0].data = enc;
diff --git a/src/daemon/https/x509/pkcs12_encr.c b/src/daemon/https/x509/pkcs12_encr.c
index 25a33641..b50520e7 100644
--- a/src/daemon/https/x509/pkcs12_encr.c
+++ b/src/daemon/https/x509/pkcs12_encr.c
@@ -33,7 +33,7 @@
33 * code instead. 33 * code instead.
34 */ 34 */
35static int 35static int
36_pkcs12_check_pass (const char *pass, size_t plen) 36MHD_pkcs12_check_pass (const char *pass, size_t plen)
37{ 37{
38 const unsigned char *p = pass; 38 const unsigned char *p = pass;
39 unsigned int i; 39 unsigned int i;
@@ -54,14 +54,14 @@ _pkcs12_check_pass (const char *pass, size_t plen)
54 * 1 for encryption key 54 * 1 for encryption key
55 */ 55 */
56int 56int
57_pkcs12_string_to_key (unsigned int id, const opaque * salt, 57MHD_pkcs12_string_to_key (unsigned int id, const opaque * salt,
58 unsigned int salt_size, unsigned int iter, 58 unsigned int salt_size, unsigned int iter,
59 const char *pw, unsigned int req_keylen, 59 const char *pw, unsigned int req_keylen,
60 opaque * keybuf) 60 opaque * keybuf)
61{ 61{
62 int rc; 62 int rc;
63 unsigned int i, j; 63 unsigned int i, j;
64 gc_hash_handle md; 64 MHD_gc_hash_handle md;
65 mpi_t num_b1 = NULL; 65 mpi_t num_b1 = NULL;
66 unsigned int pwlen; 66 unsigned int pwlen;
67 opaque hash[20], buf_b[64], buf_i[128], *p; 67 opaque hash[20], buf_b[64], buf_i[128], *p;
@@ -77,13 +77,13 @@ _pkcs12_string_to_key (unsigned int id, const opaque * salt,
77 77
78 if (pwlen > 63 / 2) 78 if (pwlen > 63 / 2)
79 { 79 {
80 gnutls_assert (); 80 MHD_gnutls_assert ();
81 return GNUTLS_E_INVALID_REQUEST; 81 return GNUTLS_E_INVALID_REQUEST;
82 } 82 }
83 83
84 if ((rc = _pkcs12_check_pass (pw, pwlen)) < 0) 84 if ((rc = MHD_pkcs12_check_pass (pw, pwlen)) < 0)
85 { 85 {
86 gnutls_assert (); 86 MHD_gnutls_assert ();
87 return rc; 87 return rc;
88 } 88 }
89 89
@@ -106,22 +106,22 @@ _pkcs12_string_to_key (unsigned int id, const opaque * salt,
106 106
107 for (;;) 107 for (;;)
108 { 108 {
109 rc = gc_hash_open (GC_SHA1, 0, &md); 109 rc = MHD_gc_hash_open (GC_SHA1, 0, &md);
110 if (rc) 110 if (rc)
111 { 111 {
112 gnutls_assert (); 112 MHD_gnutls_assert ();
113 return GNUTLS_E_DECRYPTION_FAILED; 113 return GNUTLS_E_DECRYPTION_FAILED;
114 } 114 }
115 for (i = 0; i < 64; i++) 115 for (i = 0; i < 64; i++)
116 { 116 {
117 unsigned char lid = id & 0xFF; 117 unsigned char lid = id & 0xFF;
118 gc_hash_write (md, 1, &lid); 118 MHD_gc_hash_write (md, 1, &lid);
119 } 119 }
120 gc_hash_write (md, pw ? 128 : 64, buf_i); 120 MHD_gc_hash_write (md, pw ? 128 : 64, buf_i);
121 memcpy (hash, gc_hash_read (md), 20); 121 memcpy (hash, MHD_gc_hash_read (md), 20);
122 gc_hash_close (md); 122 MHD_gc_hash_close (md);
123 for (i = 1; i < iter; i++) 123 for (i = 1; i < iter; i++)
124 gc_hash_buffer (GC_SHA1, hash, 20, hash); 124 MHD_gc_hash_buffer (GC_SHA1, hash, 20, hash);
125 for (i = 0; i < 20 && cur_keylen < req_keylen; i++) 125 for (i = 0; i < 20 && cur_keylen < req_keylen; i++)
126 keybuf[cur_keylen++] = hash[i]; 126 keybuf[cur_keylen++] = hash[i];
127 if (cur_keylen == req_keylen) 127 if (cur_keylen == req_keylen)
@@ -134,10 +134,10 @@ _pkcs12_string_to_key (unsigned int id, const opaque * salt,
134 for (i = 0; i < 64; i++) 134 for (i = 0; i < 64; i++)
135 buf_b[i] = hash[i % 20]; 135 buf_b[i] = hash[i % 20];
136 n = 64; 136 n = 64;
137 rc = mhd_gtls_mpi_scan (&num_b1, buf_b, &n); 137 rc = MHD_gtls_mpi_scan (&num_b1, buf_b, &n);
138 if (rc < 0) 138 if (rc < 0)
139 { 139 {
140 gnutls_assert (); 140 MHD_gnutls_assert ();
141 return rc; 141 return rc;
142 } 142 }
143 gcry_mpi_add_ui (num_b1, num_b1, 1); 143 gcry_mpi_add_ui (num_b1, num_b1, 1);
@@ -146,19 +146,19 @@ _pkcs12_string_to_key (unsigned int id, const opaque * salt,
146 mpi_t num_ij; 146 mpi_t num_ij;
147 147
148 n = 64; 148 n = 64;
149 rc = mhd_gtls_mpi_scan (&num_ij, buf_i + i, &n); 149 rc = MHD_gtls_mpi_scan (&num_ij, buf_i + i, &n);
150 if (rc < 0) 150 if (rc < 0)
151 { 151 {
152 gnutls_assert (); 152 MHD_gnutls_assert ();
153 return rc; 153 return rc;
154 } 154 }
155 gcry_mpi_add (num_ij, num_ij, num_b1); 155 gcry_mpi_add (num_ij, num_ij, num_b1);
156 gcry_mpi_clear_highbit (num_ij, 64 * 8); 156 gcry_mpi_clear_highbit (num_ij, 64 * 8);
157 n = 64; 157 n = 64;
158 rc = mhd_gtls_mpi_print (buf_i + i, &n, num_ij); 158 rc = MHD_gtls_mpi_print (buf_i + i, &n, num_ij);
159 if (rc < 0) 159 if (rc < 0)
160 { 160 {
161 gnutls_assert (); 161 MHD_gnutls_assert ();
162 return rc; 162 return rc;
163 } 163 }
164 gcry_mpi_release (num_ij); 164 gcry_mpi_release (num_ij);
diff --git a/src/daemon/https/x509/pkcs7.c b/src/daemon/https/x509/pkcs7.c
index 6af89425..8b0b6b54 100644
--- a/src/daemon/https/x509/pkcs7.c
+++ b/src/daemon/https/x509/pkcs7.c
@@ -46,7 +46,7 @@
46 */ 46 */
47static int 47static int
48_decode_pkcs7_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata, 48_decode_pkcs7_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata,
49 gnutls_datum_t * raw) 49 MHD_gnutls_datum_t * raw)
50{ 50{
51 char oid[128]; 51 char oid[128];
52 ASN1_TYPE c2; 52 ASN1_TYPE c2;
@@ -54,52 +54,52 @@ _decode_pkcs7_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata,
54 int tmp_size, len, result; 54 int tmp_size, len, result;
55 55
56 len = sizeof (oid) - 1; 56 len = sizeof (oid) - 1;
57 result = asn1_read_value (pkcs7, "contentType", oid, &len); 57 result = MHD__asn1_read_value (pkcs7, "contentType", oid, &len);
58 if (result != ASN1_SUCCESS) 58 if (result != ASN1_SUCCESS)
59 { 59 {
60 gnutls_assert (); 60 MHD_gnutls_assert ();
61 return mhd_gtls_asn2err (result); 61 return MHD_gtls_asn2err (result);
62 } 62 }
63 63
64 if (strcmp (oid, SIGNED_DATA_OID) != 0) 64 if (strcmp (oid, SIGNED_DATA_OID) != 0)
65 { 65 {
66 gnutls_assert (); 66 MHD_gnutls_assert ();
67 _gnutls_x509_log ("Unknown PKCS7 Content OID '%s'\n", oid); 67 MHD__gnutls_x509_log ("Unknown PKCS7 Content OID '%s'\n", oid);
68 return GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE; 68 return GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE;
69 } 69 }
70 70
71 if ((result = asn1_create_element 71 if ((result = MHD__asn1_create_element
72 (_gnutls_get_pkix (), "PKIX1.pkcs-7-SignedData", &c2)) != ASN1_SUCCESS) 72 (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-SignedData", &c2)) != ASN1_SUCCESS)
73 { 73 {
74 gnutls_assert (); 74 MHD_gnutls_assert ();
75 return mhd_gtls_asn2err (result); 75 return MHD_gtls_asn2err (result);
76 } 76 }
77 77
78 /* the Signed-data has been created, so 78 /* the Signed-data has been created, so
79 * decode them. 79 * decode them.
80 */ 80 */
81 tmp_size = 0; 81 tmp_size = 0;
82 result = asn1_read_value (pkcs7, "content", NULL, &tmp_size); 82 result = MHD__asn1_read_value (pkcs7, "content", NULL, &tmp_size);
83 if (result != ASN1_MEM_ERROR) 83 if (result != ASN1_MEM_ERROR)
84 { 84 {
85 gnutls_assert (); 85 MHD_gnutls_assert ();
86 result = mhd_gtls_asn2err (result); 86 result = MHD_gtls_asn2err (result);
87 goto cleanup; 87 goto cleanup;
88 } 88 }
89 89
90 tmp = gnutls_malloc (tmp_size); 90 tmp = MHD_gnutls_malloc (tmp_size);
91 if (tmp == NULL) 91 if (tmp == NULL)
92 { 92 {
93 gnutls_assert (); 93 MHD_gnutls_assert ();
94 result = GNUTLS_E_MEMORY_ERROR; 94 result = GNUTLS_E_MEMORY_ERROR;
95 goto cleanup; 95 goto cleanup;
96 } 96 }
97 97
98 result = asn1_read_value (pkcs7, "content", tmp, &tmp_size); 98 result = MHD__asn1_read_value (pkcs7, "content", tmp, &tmp_size);
99 if (result != ASN1_SUCCESS) 99 if (result != ASN1_SUCCESS)
100 { 100 {
101 gnutls_assert (); 101 MHD_gnutls_assert ();
102 result = mhd_gtls_asn2err (result); 102 result = MHD_gtls_asn2err (result);
103 goto cleanup; 103 goto cleanup;
104 } 104 }
105 105
@@ -110,17 +110,17 @@ _decode_pkcs7_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata,
110 /* Step 1. In case of a signed structure extract certificate set. 110 /* Step 1. In case of a signed structure extract certificate set.
111 */ 111 */
112 112
113 result = asn1_der_decoding (&c2, tmp, tmp_size, NULL); 113 result = MHD__asn1_der_decoding (&c2, tmp, tmp_size, NULL);
114 if (result != ASN1_SUCCESS) 114 if (result != ASN1_SUCCESS)
115 { 115 {
116 gnutls_assert (); 116 MHD_gnutls_assert ();
117 result = mhd_gtls_asn2err (result); 117 result = MHD_gtls_asn2err (result);
118 goto cleanup; 118 goto cleanup;
119 } 119 }
120 120
121 if (raw == NULL) 121 if (raw == NULL)
122 { 122 {
123 gnutls_free (tmp); 123 MHD_gnutls_free (tmp);
124 } 124 }
125 else 125 else
126 { 126 {
@@ -134,13 +134,13 @@ _decode_pkcs7_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata,
134 134
135cleanup: 135cleanup:
136 if (c2) 136 if (c2)
137 asn1_delete_structure (&c2); 137 MHD__asn1_delete_structure (&c2);
138 gnutls_free (tmp); 138 MHD_gnutls_free (tmp);
139 return result; 139 return result;
140} 140}
141 141
142/** 142/**
143 * gnutls_pkcs7_init - This function initializes a gnutls_pkcs7_t structure 143 * MHD_gnutls_pkcs7_init - This function initializes a MHD_gnutls_pkcs7_t structure
144 * @pkcs7: The structure to be initialized 144 * @pkcs7: The structure to be initialized
145 * 145 *
146 * This function will initialize a PKCS7 structure. PKCS7 structures 146 * This function will initialize a PKCS7 structure. PKCS7 structures
@@ -151,20 +151,20 @@ cleanup:
151 * 151 *
152 **/ 152 **/
153int 153int
154gnutls_pkcs7_init (gnutls_pkcs7_t * pkcs7) 154MHD_gnutls_pkcs7_init (MHD_gnutls_pkcs7_t * pkcs7)
155{ 155{
156 *pkcs7 = gnutls_calloc (1, sizeof (gnutls_pkcs7_int)); 156 *pkcs7 = MHD_gnutls_calloc (1, sizeof (MHD_gnutls_pkcs7_int));
157 157
158 if (*pkcs7) 158 if (*pkcs7)
159 { 159 {
160 int result = asn1_create_element (_gnutls_get_pkix (), 160 int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
161 "PKIX1.pkcs-7-ContentInfo", 161 "PKIX1.pkcs-7-ContentInfo",
162 &(*pkcs7)->pkcs7); 162 &(*pkcs7)->pkcs7);
163 if (result != ASN1_SUCCESS) 163 if (result != ASN1_SUCCESS)
164 { 164 {
165 gnutls_assert (); 165 MHD_gnutls_assert ();
166 gnutls_free (*pkcs7); 166 MHD_gnutls_free (*pkcs7);
167 return mhd_gtls_asn2err (result); 167 return MHD_gtls_asn2err (result);
168 } 168 }
169 return 0; /* success */ 169 return 0; /* success */
170 } 170 }
@@ -172,32 +172,32 @@ gnutls_pkcs7_init (gnutls_pkcs7_t * pkcs7)
172} 172}
173 173
174/** 174/**
175 * gnutls_pkcs7_deinit - This function deinitializes memory used by a gnutls_pkcs7_t structure 175 * MHD_gnutls_pkcs7_deinit - This function deinitializes memory used by a MHD_gnutls_pkcs7_t structure
176 * @pkcs7: The structure to be initialized 176 * @pkcs7: The structure to be initialized
177 * 177 *
178 * This function will deinitialize a PKCS7 structure. 178 * This function will deinitialize a PKCS7 structure.
179 * 179 *
180 **/ 180 **/
181void 181void
182gnutls_pkcs7_deinit (gnutls_pkcs7_t pkcs7) 182MHD_gnutls_pkcs7_deinit (MHD_gnutls_pkcs7_t pkcs7)
183{ 183{
184 if (!pkcs7) 184 if (!pkcs7)
185 return; 185 return;
186 186
187 if (pkcs7->pkcs7) 187 if (pkcs7->pkcs7)
188 asn1_delete_structure (&pkcs7->pkcs7); 188 MHD__asn1_delete_structure (&pkcs7->pkcs7);
189 189
190 gnutls_free (pkcs7); 190 MHD_gnutls_free (pkcs7);
191} 191}
192 192
193/** 193/**
194 * gnutls_pkcs7_import - This function will import a DER or PEM encoded PKCS7 194 * MHD_gnutls_pkcs7_import - This function will import a DER or PEM encoded PKCS7
195 * @pkcs7: The structure to store the parsed PKCS7. 195 * @pkcs7: The structure to store the parsed PKCS7.
196 * @data: The DER or PEM encoded PKCS7. 196 * @data: The DER or PEM encoded PKCS7.
197 * @format: One of DER or PEM 197 * @format: One of DER or PEM
198 * 198 *
199 * This function will convert the given DER or PEM encoded PKCS7 199 * This function will convert the given DER or PEM encoded PKCS7
200 * to the native gnutls_pkcs7_t format. The output will be stored in 'pkcs7'. 200 * to the native MHD_gnutls_pkcs7_t format. The output will be stored in 'pkcs7'.
201 * 201 *
202 * If the PKCS7 is PEM encoded it should have a header of "PKCS7". 202 * If the PKCS7 is PEM encoded it should have a header of "PKCS7".
203 * 203 *
@@ -205,11 +205,11 @@ gnutls_pkcs7_deinit (gnutls_pkcs7_t pkcs7)
205 * 205 *
206 **/ 206 **/
207int 207int
208gnutls_pkcs7_import (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * data, 208MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * data,
209 gnutls_x509_crt_fmt_t format) 209 MHD_gnutls_x509_crt_fmt_t format)
210{ 210{
211 int result = 0, need_free = 0; 211 int result = 0, need_free = 0;
212 gnutls_datum_t _data; 212 MHD_gnutls_datum_t _data;
213 213
214 if (pkcs7 == NULL) 214 if (pkcs7 == NULL)
215 return GNUTLS_E_INVALID_REQUEST; 215 return GNUTLS_E_INVALID_REQUEST;
@@ -223,14 +223,14 @@ gnutls_pkcs7_import (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * data,
223 { 223 {
224 opaque *out; 224 opaque *out;
225 225
226 result = _gnutls_fbase64_decode (PEM_PKCS7, data->data, data->size, 226 result = MHD__gnutls_fbase64_decode (PEM_PKCS7, data->data, data->size,
227 &out); 227 &out);
228 228
229 if (result <= 0) 229 if (result <= 0)
230 { 230 {
231 if (result == 0) 231 if (result == 0)
232 result = GNUTLS_E_INTERNAL_ERROR; 232 result = GNUTLS_E_INTERNAL_ERROR;
233 gnutls_assert (); 233 MHD_gnutls_assert ();
234 return result; 234 return result;
235 } 235 }
236 236
@@ -241,28 +241,28 @@ gnutls_pkcs7_import (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * data,
241 } 241 }
242 242
243 243
244 result = asn1_der_decoding (&pkcs7->pkcs7, _data.data, _data.size, NULL); 244 result = MHD__asn1_der_decoding (&pkcs7->pkcs7, _data.data, _data.size, NULL);
245 if (result != ASN1_SUCCESS) 245 if (result != ASN1_SUCCESS)
246 { 246 {
247 result = mhd_gtls_asn2err (result); 247 result = MHD_gtls_asn2err (result);
248 gnutls_assert (); 248 MHD_gnutls_assert ();
249 goto cleanup; 249 goto cleanup;
250 } 250 }
251 251
252 if (need_free) 252 if (need_free)
253 _gnutls_free_datum (&_data); 253 MHD__gnutls_free_datum (&_data);
254 254
255 return 0; 255 return 0;
256 256
257cleanup: 257cleanup:
258 if (need_free) 258 if (need_free)
259 _gnutls_free_datum (&_data); 259 MHD__gnutls_free_datum (&_data);
260 return result; 260 return result;
261} 261}
262 262
263/** 263/**
264 * gnutls_pkcs7_get_crt_raw - This function returns a certificate in a PKCS7 certificate set 264 * MHD_gnutls_pkcs7_get_crt_raw - This function returns a certificate in a PKCS7 certificate set
265 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 265 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
266 * @indx: contains the index of the certificate to extract 266 * @indx: contains the index of the certificate to extract
267 * @certificate: the contents of the certificate will be copied there (may be null) 267 * @certificate: the contents of the certificate will be copied there (may be null)
268 * @certificate_size: should hold the size of the certificate 268 * @certificate_size: should hold the size of the certificate
@@ -276,7 +276,7 @@ cleanup:
276 * 276 *
277 **/ 277 **/
278int 278int
279gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7, 279MHD_gnutls_pkcs7_get_crt_raw (MHD_gnutls_pkcs7_t pkcs7,
280 int indx, void *certificate, 280 int indx, void *certificate,
281 size_t * certificate_size) 281 size_t * certificate_size)
282{ 282{
@@ -284,7 +284,7 @@ gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7,
284 int result, len; 284 int result, len;
285 char root2[MAX_NAME_SIZE]; 285 char root2[MAX_NAME_SIZE];
286 char oid[128]; 286 char oid[128];
287 gnutls_datum_t tmp = { NULL, 0 }; 287 MHD_gnutls_datum_t tmp = { NULL, 0 };
288 288
289 if (certificate_size == NULL || pkcs7 == NULL) 289 if (certificate_size == NULL || pkcs7 == NULL)
290 return GNUTLS_E_INVALID_REQUEST; 290 return GNUTLS_E_INVALID_REQUEST;
@@ -294,7 +294,7 @@ gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7,
294 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, &tmp); 294 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, &tmp);
295 if (result < 0) 295 if (result < 0)
296 { 296 {
297 gnutls_assert (); 297 MHD_gnutls_assert ();
298 return result; 298 return result;
299 } 299 }
300 300
@@ -305,7 +305,7 @@ gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7,
305 305
306 len = sizeof (oid) - 1; 306 len = sizeof (oid) - 1;
307 307
308 result = asn1_read_value (c2, root2, oid, &len); 308 result = MHD__asn1_read_value (c2, root2, oid, &len);
309 309
310 if (result == ASN1_VALUE_NOT_FOUND) 310 if (result == ASN1_VALUE_NOT_FOUND)
311 { 311 {
@@ -315,8 +315,8 @@ gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7,
315 315
316 if (result != ASN1_SUCCESS) 316 if (result != ASN1_SUCCESS)
317 { 317 {
318 gnutls_assert (); 318 MHD_gnutls_assert ();
319 result = mhd_gtls_asn2err (result); 319 result = MHD_gtls_asn2err (result);
320 goto cleanup; 320 goto cleanup;
321 } 321 }
322 322
@@ -326,13 +326,13 @@ gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7,
326 { 326 {
327 int start, end; 327 int start, end;
328 328
329 result = asn1_der_decoding_startEnd (c2, tmp.data, tmp.size, 329 result = MHD__asn1_der_decoding_startEnd (c2, tmp.data, tmp.size,
330 root2, &start, &end); 330 root2, &start, &end);
331 331
332 if (result != ASN1_SUCCESS) 332 if (result != ASN1_SUCCESS)
333 { 333 {
334 gnutls_assert (); 334 MHD_gnutls_assert ();
335 result = mhd_gtls_asn2err (result); 335 result = MHD_gtls_asn2err (result);
336 goto cleanup; 336 goto cleanup;
337 } 337 }
338 338
@@ -359,15 +359,15 @@ gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7,
359 } 359 }
360 360
361cleanup: 361cleanup:
362 _gnutls_free_datum (&tmp); 362 MHD__gnutls_free_datum (&tmp);
363 if (c2) 363 if (c2)
364 asn1_delete_structure (&c2); 364 MHD__asn1_delete_structure (&c2);
365 return result; 365 return result;
366} 366}
367 367
368/** 368/**
369 * gnutls_pkcs7_get_crt_count - This function returns the number of certificates in a PKCS7 certificate set 369 * MHD_gnutls_pkcs7_get_crt_count - This function returns the number of certificates in a PKCS7 certificate set
370 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 370 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
371 * 371 *
372 * This function will return the number of certifcates in the PKCS7 or 372 * This function will return the number of certifcates in the PKCS7 or
373 * RFC2630 certificate set. 373 * RFC2630 certificate set.
@@ -376,7 +376,7 @@ cleanup:
376 * 376 *
377 **/ 377 **/
378int 378int
379gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t pkcs7) 379MHD_gnutls_pkcs7_get_crt_count (MHD_gnutls_pkcs7_t pkcs7)
380{ 380{
381 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 381 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
382 int result, count; 382 int result, count;
@@ -389,19 +389,19 @@ gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t pkcs7)
389 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL); 389 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL);
390 if (result < 0) 390 if (result < 0)
391 { 391 {
392 gnutls_assert (); 392 MHD_gnutls_assert ();
393 return result; 393 return result;
394 } 394 }
395 395
396 /* Step 2. Count the CertificateSet */ 396 /* Step 2. Count the CertificateSet */
397 397
398 result = asn1_number_of_elements (c2, "certificates", &count); 398 result = MHD__asn1_number_of_elements (c2, "certificates", &count);
399 399
400 asn1_delete_structure (&c2); 400 MHD__asn1_delete_structure (&c2);
401 401
402 if (result != ASN1_SUCCESS) 402 if (result != ASN1_SUCCESS)
403 { 403 {
404 gnutls_assert (); 404 MHD_gnutls_assert ();
405 return 0; /* no certificates */ 405 return 0; /* no certificates */
406 } 406 }
407 407
@@ -410,7 +410,7 @@ gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t pkcs7)
410} 410}
411 411
412/** 412/**
413 * gnutls_pkcs7_export - This function will export the pkcs7 structure 413 * MHD_gnutls_pkcs7_export - This function will export the pkcs7 structure
414 * @pkcs7: Holds the pkcs7 structure 414 * @pkcs7: Holds the pkcs7 structure
415 * @format: the format of output params. One of PEM or DER. 415 * @format: the format of output params. One of PEM or DER.
416 * @output_data: will contain a structure PEM or DER encoded 416 * @output_data: will contain a structure PEM or DER encoded
@@ -431,14 +431,14 @@ gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t pkcs7)
431 * 431 *
432 **/ 432 **/
433int 433int
434gnutls_pkcs7_export (gnutls_pkcs7_t pkcs7, 434MHD_gnutls_pkcs7_export (MHD_gnutls_pkcs7_t pkcs7,
435 gnutls_x509_crt_fmt_t format, void *output_data, 435 MHD_gnutls_x509_crt_fmt_t format, void *output_data,
436 size_t * output_data_size) 436 size_t * output_data_size)
437{ 437{
438 if (pkcs7 == NULL) 438 if (pkcs7 == NULL)
439 return GNUTLS_E_INVALID_REQUEST; 439 return GNUTLS_E_INVALID_REQUEST;
440 440
441 return _gnutls_x509_export_int (pkcs7->pkcs7, format, PEM_PKCS7, 441 return MHD__gnutls_x509_export_int (pkcs7->pkcs7, format, PEM_PKCS7,
442 output_data, output_data_size); 442 output_data, output_data_size);
443} 443}
444 444
@@ -453,22 +453,22 @@ create_empty_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata)
453 453
454 *sdata = ASN1_TYPE_EMPTY; 454 *sdata = ASN1_TYPE_EMPTY;
455 455
456 if ((result = asn1_create_element 456 if ((result = MHD__asn1_create_element
457 (_gnutls_get_pkix (), "PKIX1.pkcs-7-SignedData", 457 (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-SignedData",
458 sdata)) != ASN1_SUCCESS) 458 sdata)) != ASN1_SUCCESS)
459 { 459 {
460 gnutls_assert (); 460 MHD_gnutls_assert ();
461 result = mhd_gtls_asn2err (result); 461 result = MHD_gtls_asn2err (result);
462 goto cleanup; 462 goto cleanup;
463 } 463 }
464 464
465 /* Use version 1 465 /* Use version 1
466 */ 466 */
467 result = asn1_write_value (*sdata, "version", &one, 1); 467 result = MHD__asn1_write_value (*sdata, "version", &one, 1);
468 if (result != ASN1_SUCCESS) 468 if (result != ASN1_SUCCESS)
469 { 469 {
470 gnutls_assert (); 470 MHD_gnutls_assert ();
471 result = mhd_gtls_asn2err (result); 471 result = MHD_gtls_asn2err (result);
472 goto cleanup; 472 goto cleanup;
473 } 473 }
474 474
@@ -477,20 +477,20 @@ create_empty_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata)
477 477
478 /* id-data */ 478 /* id-data */
479 result = 479 result =
480 asn1_write_value (*sdata, "encapContentInfo.eContentType", 480 MHD__asn1_write_value (*sdata, "encapContentInfo.eContentType",
481 "1.2.840.113549.1.7.5", 1); 481 "1.2.840.113549.1.7.5", 1);
482 if (result != ASN1_SUCCESS) 482 if (result != ASN1_SUCCESS)
483 { 483 {
484 gnutls_assert (); 484 MHD_gnutls_assert ();
485 result = mhd_gtls_asn2err (result); 485 result = MHD_gtls_asn2err (result);
486 goto cleanup; 486 goto cleanup;
487 } 487 }
488 488
489 result = asn1_write_value (*sdata, "encapContentInfo.eContent", NULL, 0); 489 result = MHD__asn1_write_value (*sdata, "encapContentInfo.eContent", NULL, 0);
490 if (result != ASN1_SUCCESS) 490 if (result != ASN1_SUCCESS)
491 { 491 {
492 gnutls_assert (); 492 MHD_gnutls_assert ();
493 result = mhd_gtls_asn2err (result); 493 result = MHD_gtls_asn2err (result);
494 goto cleanup; 494 goto cleanup;
495 } 495 }
496 496
@@ -505,25 +505,25 @@ create_empty_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata)
505 505
506 /* Write the content type of the signed data 506 /* Write the content type of the signed data
507 */ 507 */
508 result = asn1_write_value (pkcs7, "contentType", SIGNED_DATA_OID, 1); 508 result = MHD__asn1_write_value (pkcs7, "contentType", SIGNED_DATA_OID, 1);
509 if (result != ASN1_SUCCESS) 509 if (result != ASN1_SUCCESS)
510 { 510 {
511 gnutls_assert (); 511 MHD_gnutls_assert ();
512 result = mhd_gtls_asn2err (result); 512 result = MHD_gtls_asn2err (result);
513 goto cleanup; 513 goto cleanup;
514 } 514 }
515 515
516 return 0; 516 return 0;
517 517
518cleanup: 518cleanup:
519 asn1_delete_structure (sdata); 519 MHD__asn1_delete_structure (sdata);
520 return result; 520 return result;
521 521
522} 522}
523 523
524/** 524/**
525 * gnutls_pkcs7_set_crt_raw - This function adds a certificate in a PKCS7 certificate set 525 * MHD_gnutls_pkcs7_set_crt_raw - This function adds a certificate in a PKCS7 certificate set
526 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 526 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
527 * @crt: the DER encoded certificate to be added 527 * @crt: the DER encoded certificate to be added
528 * 528 *
529 * This function will add a certificate to the PKCS7 or RFC2630 certificate set. 529 * This function will add a certificate to the PKCS7 or RFC2630 certificate set.
@@ -531,7 +531,7 @@ cleanup:
531 * 531 *
532 **/ 532 **/
533int 533int
534gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crt) 534MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * crt)
535{ 535{
536 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 536 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
537 int result; 537 int result;
@@ -544,7 +544,7 @@ gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crt)
544 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL); 544 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL);
545 if (result < 0 && result != GNUTLS_E_ASN1_VALUE_NOT_FOUND) 545 if (result < 0 && result != GNUTLS_E_ASN1_VALUE_NOT_FOUND)
546 { 546 {
547 gnutls_assert (); 547 MHD_gnutls_assert ();
548 return result; 548 return result;
549 } 549 }
550 550
@@ -559,7 +559,7 @@ gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crt)
559 result = create_empty_signed_data (pkcs7->pkcs7, &c2); 559 result = create_empty_signed_data (pkcs7->pkcs7, &c2);
560 if (result < 0) 560 if (result < 0)
561 { 561 {
562 gnutls_assert (); 562 MHD_gnutls_assert ();
563 return result; 563 return result;
564 } 564 }
565 } 565 }
@@ -567,86 +567,86 @@ gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crt)
567 /* Step 2. Append the new certificate. 567 /* Step 2. Append the new certificate.
568 */ 568 */
569 569
570 result = asn1_write_value (c2, "certificates", "NEW", 1); 570 result = MHD__asn1_write_value (c2, "certificates", "NEW", 1);
571 if (result != ASN1_SUCCESS) 571 if (result != ASN1_SUCCESS)
572 { 572 {
573 gnutls_assert (); 573 MHD_gnutls_assert ();
574 result = mhd_gtls_asn2err (result); 574 result = MHD_gtls_asn2err (result);
575 goto cleanup; 575 goto cleanup;
576 } 576 }
577 577
578 result = asn1_write_value (c2, "certificates.?LAST", "certificate", 1); 578 result = MHD__asn1_write_value (c2, "certificates.?LAST", "certificate", 1);
579 if (result != ASN1_SUCCESS) 579 if (result != ASN1_SUCCESS)
580 { 580 {
581 gnutls_assert (); 581 MHD_gnutls_assert ();
582 result = mhd_gtls_asn2err (result); 582 result = MHD_gtls_asn2err (result);
583 goto cleanup; 583 goto cleanup;
584 } 584 }
585 585
586 result = 586 result =
587 asn1_write_value (c2, "certificates.?LAST.certificate", crt->data, 587 MHD__asn1_write_value (c2, "certificates.?LAST.certificate", crt->data,
588 crt->size); 588 crt->size);
589 if (result != ASN1_SUCCESS) 589 if (result != ASN1_SUCCESS)
590 { 590 {
591 gnutls_assert (); 591 MHD_gnutls_assert ();
592 result = mhd_gtls_asn2err (result); 592 result = MHD_gtls_asn2err (result);
593 goto cleanup; 593 goto cleanup;
594 } 594 }
595 595
596 /* Step 3. Replace the old content with the new 596 /* Step 3. Replace the old content with the new
597 */ 597 */
598 result = 598 result =
599 _gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0); 599 MHD__gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0);
600 if (result < 0) 600 if (result < 0)
601 { 601 {
602 gnutls_assert (); 602 MHD_gnutls_assert ();
603 goto cleanup; 603 goto cleanup;
604 } 604 }
605 605
606 asn1_delete_structure (&c2); 606 MHD__asn1_delete_structure (&c2);
607 607
608 return 0; 608 return 0;
609 609
610cleanup: 610cleanup:
611 if (c2) 611 if (c2)
612 asn1_delete_structure (&c2); 612 MHD__asn1_delete_structure (&c2);
613 return result; 613 return result;
614} 614}
615 615
616/** 616/**
617 * gnutls_pkcs7_set_crt - This function adds a parsed certificate in a PKCS7 certificate set 617 * MHD_gnutls_pkcs7_set_crt - This function adds a parsed certificate in a PKCS7 certificate set
618 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 618 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
619 * @crt: the certificate to be copied. 619 * @crt: the certificate to be copied.
620 * 620 *
621 * This function will add a parsed certificate to the PKCS7 or RFC2630 certificate set. 621 * This function will add a parsed certificate to the PKCS7 or RFC2630 certificate set.
622 * This is a wrapper function over gnutls_pkcs7_set_crt_raw() . 622 * This is a wrapper function over MHD_gnutls_pkcs7_set_crt_raw() .
623 * 623 *
624 * Returns 0 on success. 624 * Returns 0 on success.
625 * 625 *
626 **/ 626 **/
627int 627int
628gnutls_pkcs7_set_crt (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt) 628MHD_gnutls_pkcs7_set_crt (MHD_gnutls_pkcs7_t pkcs7, MHD_gnutls_x509_crt_t crt)
629{ 629{
630 int ret; 630 int ret;
631 gnutls_datum_t data; 631 MHD_gnutls_datum_t data;
632 632
633 if (pkcs7 == NULL) 633 if (pkcs7 == NULL)
634 return GNUTLS_E_INVALID_REQUEST; 634 return GNUTLS_E_INVALID_REQUEST;
635 635
636 ret = _gnutls_x509_der_encode (crt->cert, "", &data, 0); 636 ret = MHD__gnutls_x509_der_encode (crt->cert, "", &data, 0);
637 if (ret < 0) 637 if (ret < 0)
638 { 638 {
639 gnutls_assert (); 639 MHD_gnutls_assert ();
640 return ret; 640 return ret;
641 } 641 }
642 642
643 ret = gnutls_pkcs7_set_crt_raw (pkcs7, &data); 643 ret = MHD_gnutls_pkcs7_set_crt_raw (pkcs7, &data);
644 644
645 _gnutls_free_datum (&data); 645 MHD__gnutls_free_datum (&data);
646 646
647 if (ret < 0) 647 if (ret < 0)
648 { 648 {
649 gnutls_assert (); 649 MHD_gnutls_assert ();
650 return ret; 650 return ret;
651 } 651 }
652 652
@@ -655,8 +655,8 @@ gnutls_pkcs7_set_crt (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt)
655 655
656 656
657/** 657/**
658 * gnutls_pkcs7_delete_crt - This function deletes a certificate from a PKCS7 certificate set 658 * MHD_gnutls_pkcs7_delete_crt - This function deletes a certificate from a PKCS7 certificate set
659 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 659 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
660 * @indx: the index of the certificate to delete 660 * @indx: the index of the certificate to delete
661 * 661 *
662 * This function will delete a certificate from a PKCS7 or RFC2630 certificate set. 662 * This function will delete a certificate from a PKCS7 or RFC2630 certificate set.
@@ -664,7 +664,7 @@ gnutls_pkcs7_set_crt (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt)
664 * 664 *
665 **/ 665 **/
666int 666int
667gnutls_pkcs7_delete_crt (gnutls_pkcs7_t pkcs7, int indx) 667MHD_gnutls_pkcs7_delete_crt (MHD_gnutls_pkcs7_t pkcs7, int indx)
668{ 668{
669 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 669 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
670 int result; 670 int result;
@@ -678,7 +678,7 @@ gnutls_pkcs7_delete_crt (gnutls_pkcs7_t pkcs7, int indx)
678 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL); 678 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL);
679 if (result < 0) 679 if (result < 0)
680 { 680 {
681 gnutls_assert (); 681 MHD_gnutls_assert ();
682 return result; 682 return result;
683 } 683 }
684 684
@@ -687,31 +687,31 @@ gnutls_pkcs7_delete_crt (gnutls_pkcs7_t pkcs7, int indx)
687 687
688 snprintf (root2, sizeof (root2), "certificates.?%u", indx + 1); 688 snprintf (root2, sizeof (root2), "certificates.?%u", indx + 1);
689 689
690 result = asn1_write_value (c2, root2, NULL, 0); 690 result = MHD__asn1_write_value (c2, root2, NULL, 0);
691 if (result != ASN1_SUCCESS) 691 if (result != ASN1_SUCCESS)
692 { 692 {
693 gnutls_assert (); 693 MHD_gnutls_assert ();
694 result = mhd_gtls_asn2err (result); 694 result = MHD_gtls_asn2err (result);
695 goto cleanup; 695 goto cleanup;
696 } 696 }
697 697
698 /* Step 3. Replace the old content with the new 698 /* Step 3. Replace the old content with the new
699 */ 699 */
700 result = 700 result =
701 _gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0); 701 MHD__gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0);
702 if (result < 0) 702 if (result < 0)
703 { 703 {
704 gnutls_assert (); 704 MHD_gnutls_assert ();
705 goto cleanup; 705 goto cleanup;
706 } 706 }
707 707
708 asn1_delete_structure (&c2); 708 MHD__asn1_delete_structure (&c2);
709 709
710 return 0; 710 return 0;
711 711
712cleanup: 712cleanup:
713 if (c2) 713 if (c2)
714 asn1_delete_structure (&c2); 714 MHD__asn1_delete_structure (&c2);
715 return result; 715 return result;
716} 716}
717 717
@@ -719,8 +719,8 @@ cleanup:
719 */ 719 */
720 720
721/** 721/**
722 * gnutls_pkcs7_get_crl_raw - This function returns a crl in a PKCS7 crl set 722 * MHD_gnutls_pkcs7_get_crl_raw - This function returns a crl in a PKCS7 crl set
723 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 723 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
724 * @indx: contains the index of the crl to extract 724 * @indx: contains the index of the crl to extract
725 * @crl: the contents of the crl will be copied there (may be null) 725 * @crl: the contents of the crl will be copied there (may be null)
726 * @crl_size: should hold the size of the crl 726 * @crl_size: should hold the size of the crl
@@ -734,13 +734,13 @@ cleanup:
734 * 734 *
735 **/ 735 **/
736int 736int
737gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t pkcs7, 737MHD_gnutls_pkcs7_get_crl_raw (MHD_gnutls_pkcs7_t pkcs7,
738 int indx, void *crl, size_t * crl_size) 738 int indx, void *crl, size_t * crl_size)
739{ 739{
740 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 740 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
741 int result; 741 int result;
742 char root2[MAX_NAME_SIZE]; 742 char root2[MAX_NAME_SIZE];
743 gnutls_datum_t tmp = { NULL, 0 }; 743 MHD_gnutls_datum_t tmp = { NULL, 0 };
744 int start, end; 744 int start, end;
745 745
746 if (pkcs7 == NULL || crl_size == NULL) 746 if (pkcs7 == NULL || crl_size == NULL)
@@ -751,7 +751,7 @@ gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t pkcs7,
751 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, &tmp); 751 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, &tmp);
752 if (result < 0) 752 if (result < 0)
753 { 753 {
754 gnutls_assert (); 754 MHD_gnutls_assert ();
755 return result; 755 return result;
756 } 756 }
757 757
@@ -762,13 +762,13 @@ gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t pkcs7,
762 762
763 /* Get the raw CRL 763 /* Get the raw CRL
764 */ 764 */
765 result = asn1_der_decoding_startEnd (c2, tmp.data, tmp.size, 765 result = MHD__asn1_der_decoding_startEnd (c2, tmp.data, tmp.size,
766 root2, &start, &end); 766 root2, &start, &end);
767 767
768 if (result != ASN1_SUCCESS) 768 if (result != ASN1_SUCCESS)
769 { 769 {
770 gnutls_assert (); 770 MHD_gnutls_assert ();
771 result = mhd_gtls_asn2err (result); 771 result = MHD_gtls_asn2err (result);
772 goto cleanup; 772 goto cleanup;
773 } 773 }
774 774
@@ -789,15 +789,15 @@ gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t pkcs7,
789 result = 0; 789 result = 0;
790 790
791cleanup: 791cleanup:
792 _gnutls_free_datum (&tmp); 792 MHD__gnutls_free_datum (&tmp);
793 if (c2) 793 if (c2)
794 asn1_delete_structure (&c2); 794 MHD__asn1_delete_structure (&c2);
795 return result; 795 return result;
796} 796}
797 797
798/** 798/**
799 * gnutls_pkcs7_get_crl_count - This function returns the number of crls in a PKCS7 crl set 799 * MHD_gnutls_pkcs7_get_crl_count - This function returns the number of crls in a PKCS7 crl set
800 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 800 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
801 * 801 *
802 * This function will return the number of certifcates in the PKCS7 or 802 * This function will return the number of certifcates in the PKCS7 or
803 * RFC2630 crl set. 803 * RFC2630 crl set.
@@ -806,7 +806,7 @@ cleanup:
806 * 806 *
807 **/ 807 **/
808int 808int
809gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t pkcs7) 809MHD_gnutls_pkcs7_get_crl_count (MHD_gnutls_pkcs7_t pkcs7)
810{ 810{
811 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 811 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
812 int result, count; 812 int result, count;
@@ -819,19 +819,19 @@ gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t pkcs7)
819 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL); 819 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL);
820 if (result < 0) 820 if (result < 0)
821 { 821 {
822 gnutls_assert (); 822 MHD_gnutls_assert ();
823 return result; 823 return result;
824 } 824 }
825 825
826 /* Step 2. Count the CertificateSet */ 826 /* Step 2. Count the CertificateSet */
827 827
828 result = asn1_number_of_elements (c2, "crls", &count); 828 result = MHD__asn1_number_of_elements (c2, "crls", &count);
829 829
830 asn1_delete_structure (&c2); 830 MHD__asn1_delete_structure (&c2);
831 831
832 if (result != ASN1_SUCCESS) 832 if (result != ASN1_SUCCESS)
833 { 833 {
834 gnutls_assert (); 834 MHD_gnutls_assert ();
835 return 0; /* no crls */ 835 return 0; /* no crls */
836 } 836 }
837 837
@@ -840,8 +840,8 @@ gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t pkcs7)
840} 840}
841 841
842/** 842/**
843 * gnutls_pkcs7_set_crl_raw - This function adds a crl in a PKCS7 crl set 843 * MHD_gnutls_pkcs7_set_crl_raw - This function adds a crl in a PKCS7 crl set
844 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 844 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
845 * @crl: the DER encoded crl to be added 845 * @crl: the DER encoded crl to be added
846 * 846 *
847 * This function will add a crl to the PKCS7 or RFC2630 crl set. 847 * This function will add a crl to the PKCS7 or RFC2630 crl set.
@@ -849,7 +849,7 @@ gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t pkcs7)
849 * 849 *
850 **/ 850 **/
851int 851int
852gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crl) 852MHD_gnutls_pkcs7_set_crl_raw (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * crl)
853{ 853{
854 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 854 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
855 int result; 855 int result;
@@ -862,7 +862,7 @@ gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crl)
862 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL); 862 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL);
863 if (result < 0 && result != GNUTLS_E_ASN1_VALUE_NOT_FOUND) 863 if (result < 0 && result != GNUTLS_E_ASN1_VALUE_NOT_FOUND)
864 { 864 {
865 gnutls_assert (); 865 MHD_gnutls_assert ();
866 return result; 866 return result;
867 } 867 }
868 868
@@ -877,7 +877,7 @@ gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crl)
877 result = create_empty_signed_data (pkcs7->pkcs7, &c2); 877 result = create_empty_signed_data (pkcs7->pkcs7, &c2);
878 if (result < 0) 878 if (result < 0)
879 { 879 {
880 gnutls_assert (); 880 MHD_gnutls_assert ();
881 return result; 881 return result;
882 } 882 }
883 } 883 }
@@ -885,45 +885,45 @@ gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crl)
885 /* Step 2. Append the new crl. 885 /* Step 2. Append the new crl.
886 */ 886 */
887 887
888 result = asn1_write_value (c2, "crls", "NEW", 1); 888 result = MHD__asn1_write_value (c2, "crls", "NEW", 1);
889 if (result != ASN1_SUCCESS) 889 if (result != ASN1_SUCCESS)
890 { 890 {
891 gnutls_assert (); 891 MHD_gnutls_assert ();
892 result = mhd_gtls_asn2err (result); 892 result = MHD_gtls_asn2err (result);
893 goto cleanup; 893 goto cleanup;
894 } 894 }
895 895
896 result = asn1_write_value (c2, "crls.?LAST", crl->data, crl->size); 896 result = MHD__asn1_write_value (c2, "crls.?LAST", crl->data, crl->size);
897 if (result != ASN1_SUCCESS) 897 if (result != ASN1_SUCCESS)
898 { 898 {
899 gnutls_assert (); 899 MHD_gnutls_assert ();
900 result = mhd_gtls_asn2err (result); 900 result = MHD_gtls_asn2err (result);
901 goto cleanup; 901 goto cleanup;
902 } 902 }
903 903
904 /* Step 3. Replace the old content with the new 904 /* Step 3. Replace the old content with the new
905 */ 905 */
906 result = 906 result =
907 _gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0); 907 MHD__gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0);
908 if (result < 0) 908 if (result < 0)
909 { 909 {
910 gnutls_assert (); 910 MHD_gnutls_assert ();
911 goto cleanup; 911 goto cleanup;
912 } 912 }
913 913
914 asn1_delete_structure (&c2); 914 MHD__asn1_delete_structure (&c2);
915 915
916 return 0; 916 return 0;
917 917
918cleanup: 918cleanup:
919 if (c2) 919 if (c2)
920 asn1_delete_structure (&c2); 920 MHD__asn1_delete_structure (&c2);
921 return result; 921 return result;
922} 922}
923 923
924/** 924/**
925 * gnutls_pkcs7_set_crl - This function adds a parsed crl in a PKCS7 crl set 925 * MHD_gnutls_pkcs7_set_crl - This function adds a parsed crl in a PKCS7 crl set
926 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 926 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
927 * @crl: the DER encoded crl to be added 927 * @crl: the DER encoded crl to be added
928 * 928 *
929 * This function will add a parsed crl to the PKCS7 or RFC2630 crl set. 929 * This function will add a parsed crl to the PKCS7 or RFC2630 crl set.
@@ -931,28 +931,28 @@ cleanup:
931 * 931 *
932 **/ 932 **/
933int 933int
934gnutls_pkcs7_set_crl (gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl) 934MHD_gnutls_pkcs7_set_crl (MHD_gnutls_pkcs7_t pkcs7, MHD_gnutls_x509_crl_t crl)
935{ 935{
936 int ret; 936 int ret;
937 gnutls_datum_t data; 937 MHD_gnutls_datum_t data;
938 938
939 if (pkcs7 == NULL) 939 if (pkcs7 == NULL)
940 return GNUTLS_E_INVALID_REQUEST; 940 return GNUTLS_E_INVALID_REQUEST;
941 941
942 ret = _gnutls_x509_der_encode (crl->crl, "", &data, 0); 942 ret = MHD__gnutls_x509_der_encode (crl->crl, "", &data, 0);
943 if (ret < 0) 943 if (ret < 0)
944 { 944 {
945 gnutls_assert (); 945 MHD_gnutls_assert ();
946 return ret; 946 return ret;
947 } 947 }
948 948
949 ret = gnutls_pkcs7_set_crl_raw (pkcs7, &data); 949 ret = MHD_gnutls_pkcs7_set_crl_raw (pkcs7, &data);
950 950
951 _gnutls_free_datum (&data); 951 MHD__gnutls_free_datum (&data);
952 952
953 if (ret < 0) 953 if (ret < 0)
954 { 954 {
955 gnutls_assert (); 955 MHD_gnutls_assert ();
956 return ret; 956 return ret;
957 } 957 }
958 958
@@ -960,8 +960,8 @@ gnutls_pkcs7_set_crl (gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl)
960} 960}
961 961
962/** 962/**
963 * gnutls_pkcs7_delete_crl - This function deletes a crl from a PKCS7 crl set 963 * MHD_gnutls_pkcs7_delete_crl - This function deletes a crl from a PKCS7 crl set
964 * @pkcs7_struct: should contain a gnutls_pkcs7_t structure 964 * @pkcs7_struct: should contain a MHD_gnutls_pkcs7_t structure
965 * @indx: the index of the crl to delete 965 * @indx: the index of the crl to delete
966 * 966 *
967 * This function will delete a crl from a PKCS7 or RFC2630 crl set. 967 * This function will delete a crl from a PKCS7 or RFC2630 crl set.
@@ -969,7 +969,7 @@ gnutls_pkcs7_set_crl (gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl)
969 * 969 *
970 **/ 970 **/
971int 971int
972gnutls_pkcs7_delete_crl (gnutls_pkcs7_t pkcs7, int indx) 972MHD_gnutls_pkcs7_delete_crl (MHD_gnutls_pkcs7_t pkcs7, int indx)
973{ 973{
974 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 974 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
975 int result; 975 int result;
@@ -983,7 +983,7 @@ gnutls_pkcs7_delete_crl (gnutls_pkcs7_t pkcs7, int indx)
983 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL); 983 result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL);
984 if (result < 0) 984 if (result < 0)
985 { 985 {
986 gnutls_assert (); 986 MHD_gnutls_assert ();
987 return result; 987 return result;
988 } 988 }
989 989
@@ -992,31 +992,31 @@ gnutls_pkcs7_delete_crl (gnutls_pkcs7_t pkcs7, int indx)
992 992
993 snprintf (root2, sizeof (root2), "crls.?%u", indx + 1); 993 snprintf (root2, sizeof (root2), "crls.?%u", indx + 1);
994 994
995 result = asn1_write_value (c2, root2, NULL, 0); 995 result = MHD__asn1_write_value (c2, root2, NULL, 0);
996 if (result != ASN1_SUCCESS) 996 if (result != ASN1_SUCCESS)
997 { 997 {
998 gnutls_assert (); 998 MHD_gnutls_assert ();
999 result = mhd_gtls_asn2err (result); 999 result = MHD_gtls_asn2err (result);
1000 goto cleanup; 1000 goto cleanup;
1001 } 1001 }
1002 1002
1003 /* Step 3. Replace the old content with the new 1003 /* Step 3. Replace the old content with the new
1004 */ 1004 */
1005 result = 1005 result =
1006 _gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0); 1006 MHD__gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0);
1007 if (result < 0) 1007 if (result < 0)
1008 { 1008 {
1009 gnutls_assert (); 1009 MHD_gnutls_assert ();
1010 goto cleanup; 1010 goto cleanup;
1011 } 1011 }
1012 1012
1013 asn1_delete_structure (&c2); 1013 MHD__asn1_delete_structure (&c2);
1014 1014
1015 return 0; 1015 return 0;
1016 1016
1017cleanup: 1017cleanup:
1018 if (c2) 1018 if (c2)
1019 asn1_delete_structure (&c2); 1019 MHD__asn1_delete_structure (&c2);
1020 return result; 1020 return result;
1021} 1021}
1022 1022
diff --git a/src/daemon/https/x509/pkcs7.h b/src/daemon/https/x509/pkcs7.h
index ee1990c3..24e4a415 100644
--- a/src/daemon/https/x509/pkcs7.h
+++ b/src/daemon/https/x509/pkcs7.h
@@ -24,7 +24,7 @@
24 24
25#include "x509.h" 25#include "x509.h"
26 26
27typedef struct gnutls_pkcs7_int 27typedef struct MHD_gnutls_pkcs7_int
28{ 28{
29 ASN1_TYPE pkcs7; 29 ASN1_TYPE pkcs7;
30} gnutls_pkcs7_int; 30} MHD_gnutls_pkcs7_int;
diff --git a/src/daemon/https/x509/privkey.h b/src/daemon/https/x509/privkey.h
index 59dc936b..ab29ec1c 100644
--- a/src/daemon/https/x509/privkey.h
+++ b/src/daemon/https/x509/privkey.h
@@ -24,8 +24,8 @@
24 24
25#include "x509.h" 25#include "x509.h"
26 26
27ASN1_TYPE _gnutls_privkey_decode_pkcs1_rsa_key (const gnutls_datum_t * 27ASN1_TYPE MHD__gnutls_privkey_decode_pkcs1_rsa_key (const MHD_gnutls_datum_t *
28 raw_key, 28 raw_key,
29 gnutls_x509_privkey_t pkey); 29 MHD_gnutls_x509_privkey_t pkey);
30 30
31int _gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params); 31int MHD__gnutlsMHD__asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params);
diff --git a/src/daemon/https/x509/privkey_pkcs8.c b/src/daemon/https/x509/privkey_pkcs8.c
index ae2c50dd..447dca15 100644
--- a/src/daemon/https/x509/privkey_pkcs8.c
+++ b/src/daemon/https/x509/privkey_pkcs8.c
@@ -71,31 +71,31 @@ struct pbe_enc_params
71static int generate_key (schema_id schema, const char *password, 71static int generate_key (schema_id schema, const char *password,
72 struct pbkdf2_params *kdf_params, 72 struct pbkdf2_params *kdf_params,
73 struct pbe_enc_params *enc_params, 73 struct pbe_enc_params *enc_params,
74 gnutls_datum_t * key); 74 MHD_gnutls_datum_t * key);
75static int read_pbkdf2_params (ASN1_TYPE pbes2_asn, 75static int read_pbkdf2_params (ASN1_TYPE pbes2_asn,
76 const gnutls_datum_t * der, 76 const MHD_gnutls_datum_t * der,
77 struct pbkdf2_params *params); 77 struct pbkdf2_params *params);
78static int read_pbe_enc_params (ASN1_TYPE pbes2_asn, 78static int read_pbe_enc_params (ASN1_TYPE pbes2_asn,
79 const gnutls_datum_t * der, 79 const MHD_gnutls_datum_t * der,
80 struct pbe_enc_params *params); 80 struct pbe_enc_params *params);
81static int decrypt_data (schema_id, ASN1_TYPE pkcs8_asn, const char *root, 81static int decrypt_data (schema_id, ASN1_TYPE pkcs8_asn, const char *root,
82 const char *password, 82 const char *password,
83 const struct pbkdf2_params *kdf_params, 83 const struct pbkdf2_params *kdf_params,
84 const struct pbe_enc_params *enc_params, 84 const struct pbe_enc_params *enc_params,
85 gnutls_datum_t * decrypted_data); 85 MHD_gnutls_datum_t * decrypted_data);
86static int decode_private_key_info (const gnutls_datum_t * der, 86static int decode_private_key_info (const MHD_gnutls_datum_t * der,
87 gnutls_x509_privkey_t pkey); 87 MHD_gnutls_x509_privkey_t pkey);
88static int write_schema_params (schema_id schema, ASN1_TYPE pkcs8_asn, 88static int write_schema_params (schema_id schema, ASN1_TYPE pkcs8_asn,
89 const char *where, 89 const char *where,
90 const struct pbkdf2_params *kdf_params, 90 const struct pbkdf2_params *kdf_params,
91 const struct pbe_enc_params *enc_params); 91 const struct pbe_enc_params *enc_params);
92static int encrypt_data (const gnutls_datum_t * plain, 92static int encrypt_data (const MHD_gnutls_datum_t * plain,
93 const struct pbe_enc_params *enc_params, 93 const struct pbe_enc_params *enc_params,
94 gnutls_datum_t * key, gnutls_datum_t * encrypted); 94 MHD_gnutls_datum_t * key, MHD_gnutls_datum_t * encrypted);
95 95
96static int read_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, 96static int readMHD_pkcs12_kdf_params (ASN1_TYPE pbes2_asn,
97 struct pbkdf2_params *params); 97 struct pbkdf2_params *params);
98static int write_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, 98static int writeMHD_pkcs12_kdf_params (ASN1_TYPE pbes2_asn,
99 const struct pbkdf2_params *params); 99 const struct pbkdf2_params *params);
100 100
101#define PEM_PKCS8 "ENCRYPTED PRIVATE KEY" 101#define PEM_PKCS8 "ENCRYPTED PRIVATE KEY"
@@ -120,7 +120,7 @@ check_schema (const char *oid)
120 if (strcmp (oid, PKCS12_PBE_RC2_40_SHA1_OID) == 0) 120 if (strcmp (oid, PKCS12_PBE_RC2_40_SHA1_OID) == 0)
121 return PKCS12_RC2_40_SHA1; 121 return PKCS12_RC2_40_SHA1;
122 122
123 _gnutls_x509_log ("PKCS encryption schema OID '%s' is unsupported.\n", oid); 123 MHD__gnutls_x509_log ("PKCS encryption schema OID '%s' is unsupported.\n", oid);
124 124
125 return GNUTLS_E_UNKNOWN_CIPHER_TYPE; 125 return GNUTLS_E_UNKNOWN_CIPHER_TYPE;
126} 126}
@@ -136,7 +136,7 @@ read_pkcs_schema_params (schema_id schema, const char *password,
136{ 136{
137 ASN1_TYPE pbes2_asn = ASN1_TYPE_EMPTY; 137 ASN1_TYPE pbes2_asn = ASN1_TYPE_EMPTY;
138 int result; 138 int result;
139 gnutls_datum_t tmp; 139 MHD_gnutls_datum_t tmp;
140 140
141 switch (schema) 141 switch (schema)
142 { 142 {
@@ -147,22 +147,22 @@ read_pkcs_schema_params (schema_id schema, const char *password,
147 * functions. 147 * functions.
148 */ 148 */
149 if ((result = 149 if ((result =
150 asn1_create_element (_gnutls_get_pkix (), 150 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
151 "PKIX1.pkcs-5-PBES2-params", 151 "PKIX1.pkcs-5-PBES2-params",
152 &pbes2_asn)) != ASN1_SUCCESS) 152 &pbes2_asn)) != ASN1_SUCCESS)
153 { 153 {
154 gnutls_assert (); 154 MHD_gnutls_assert ();
155 result = mhd_gtls_asn2err (result); 155 result = MHD_gtls_asn2err (result);
156 goto error; 156 goto error;
157 } 157 }
158 158
159 /* Decode the parameters. 159 /* Decode the parameters.
160 */ 160 */
161 result = asn1_der_decoding (&pbes2_asn, data, data_size, NULL); 161 result = MHD__asn1_der_decoding (&pbes2_asn, data, data_size, NULL);
162 if (result != ASN1_SUCCESS) 162 if (result != ASN1_SUCCESS)
163 { 163 {
164 gnutls_assert (); 164 MHD_gnutls_assert ();
165 result = mhd_gtls_asn2err (result); 165 result = MHD_gtls_asn2err (result);
166 goto error; 166 goto error;
167 } 167 }
168 168
@@ -172,20 +172,20 @@ read_pkcs_schema_params (schema_id schema, const char *password,
172 result = read_pbkdf2_params (pbes2_asn, &tmp, kdf_params); 172 result = read_pbkdf2_params (pbes2_asn, &tmp, kdf_params);
173 if (result < 0) 173 if (result < 0)
174 { 174 {
175 gnutls_assert (); 175 MHD_gnutls_assert ();
176 result = mhd_gtls_asn2err (result); 176 result = MHD_gtls_asn2err (result);
177 goto error; 177 goto error;
178 } 178 }
179 179
180 result = read_pbe_enc_params (pbes2_asn, &tmp, enc_params); 180 result = read_pbe_enc_params (pbes2_asn, &tmp, enc_params);
181 if (result < 0) 181 if (result < 0)
182 { 182 {
183 gnutls_assert (); 183 MHD_gnutls_assert ();
184 result = mhd_gtls_asn2err (result); 184 result = MHD_gtls_asn2err (result);
185 goto error; 185 goto error;
186 } 186 }
187 187
188 asn1_delete_structure (&pbes2_asn); 188 MHD__asn1_delete_structure (&pbes2_asn);
189 return 0; 189 return 0;
190 break; 190 break;
191 191
@@ -210,48 +210,48 @@ read_pkcs_schema_params (schema_id schema, const char *password,
210 } 210 }
211 211
212 if ((result = 212 if ((result =
213 asn1_create_element (_gnutls_get_pkix (), 213 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
214 "PKIX1.pkcs-12-PbeParams", 214 "PKIX1.pkcs-12-PbeParams",
215 &pbes2_asn)) != ASN1_SUCCESS) 215 &pbes2_asn)) != ASN1_SUCCESS)
216 { 216 {
217 gnutls_assert (); 217 MHD_gnutls_assert ();
218 result = mhd_gtls_asn2err (result); 218 result = MHD_gtls_asn2err (result);
219 goto error; 219 goto error;
220 } 220 }
221 221
222 /* Decode the parameters. 222 /* Decode the parameters.
223 */ 223 */
224 result = asn1_der_decoding (&pbes2_asn, data, data_size, NULL); 224 result = MHD__asn1_der_decoding (&pbes2_asn, data, data_size, NULL);
225 if (result != ASN1_SUCCESS) 225 if (result != ASN1_SUCCESS)
226 { 226 {
227 gnutls_assert (); 227 MHD_gnutls_assert ();
228 result = mhd_gtls_asn2err (result); 228 result = MHD_gtls_asn2err (result);
229 goto error; 229 goto error;
230 } 230 }
231 231
232 result = read_pkcs12_kdf_params (pbes2_asn, kdf_params); 232 result = readMHD_pkcs12_kdf_params (pbes2_asn, kdf_params);
233 if (result < 0) 233 if (result < 0)
234 { 234 {
235 gnutls_assert (); 235 MHD_gnutls_assert ();
236 goto error; 236 goto error;
237 } 237 }
238 238
239 if (enc_params->iv_size) 239 if (enc_params->iv_size)
240 { 240 {
241 result = 241 result =
242 _pkcs12_string_to_key (2 /*IV*/, kdf_params->salt, 242 MHD_pkcs12_string_to_key (2 /*IV*/, kdf_params->salt,
243 kdf_params->salt_size, 243 kdf_params->salt_size,
244 kdf_params->iter_count, password, 244 kdf_params->iter_count, password,
245 enc_params->iv_size, enc_params->iv); 245 enc_params->iv_size, enc_params->iv);
246 if (result < 0) 246 if (result < 0)
247 { 247 {
248 gnutls_assert (); 248 MHD_gnutls_assert ();
249 goto error; 249 goto error;
250 } 250 }
251 251
252 } 252 }
253 253
254 asn1_delete_structure (&pbes2_asn); 254 MHD__asn1_delete_structure (&pbes2_asn);
255 255
256 return 0; 256 return 0;
257 break; 257 break;
@@ -261,21 +261,21 @@ read_pkcs_schema_params (schema_id schema, const char *password,
261 return GNUTLS_E_UNKNOWN_CIPHER_TYPE; 261 return GNUTLS_E_UNKNOWN_CIPHER_TYPE;
262 262
263error: 263error:
264 asn1_delete_structure (&pbes2_asn); 264 MHD__asn1_delete_structure (&pbes2_asn);
265 return result; 265 return result;
266} 266}
267 267
268/* Converts a PKCS #8 key to 268/* Converts a PKCS #8 key to
269 * an internal structure (gnutls_private_key) 269 * an internal structure (MHD_gnutls_private_key)
270 * (normally a PKCS #1 encoded RSA key) 270 * (normally a PKCS #1 encoded RSA key)
271 */ 271 */
272static int 272static int
273decode_pkcs8_key (const gnutls_datum_t * raw_key, 273decode_pkcs8_key (const MHD_gnutls_datum_t * raw_key,
274 const char *password, gnutls_x509_privkey_t pkey) 274 const char *password, MHD_gnutls_x509_privkey_t pkey)
275{ 275{
276 int result, len; 276 int result, len;
277 char enc_oid[64]; 277 char enc_oid[64];
278 gnutls_datum_t tmp; 278 MHD_gnutls_datum_t tmp;
279 ASN1_TYPE pbes2_asn = ASN1_TYPE_EMPTY, pkcs8_asn = ASN1_TYPE_EMPTY; 279 ASN1_TYPE pbes2_asn = ASN1_TYPE_EMPTY, pkcs8_asn = ASN1_TYPE_EMPTY;
280 int params_start, params_end, params_len; 280 int params_start, params_end, params_len;
281 struct pbkdf2_params kdf_params; 281 struct pbkdf2_params kdf_params;
@@ -283,20 +283,20 @@ decode_pkcs8_key (const gnutls_datum_t * raw_key,
283 schema_id schema; 283 schema_id schema;
284 284
285 if ((result = 285 if ((result =
286 asn1_create_element (_gnutls_get_pkix (), 286 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
287 "PKIX1.pkcs-8-EncryptedPrivateKeyInfo", 287 "PKIX1.pkcs-8-EncryptedPrivateKeyInfo",
288 &pkcs8_asn)) != ASN1_SUCCESS) 288 &pkcs8_asn)) != ASN1_SUCCESS)
289 { 289 {
290 gnutls_assert (); 290 MHD_gnutls_assert ();
291 result = mhd_gtls_asn2err (result); 291 result = MHD_gtls_asn2err (result);
292 goto error; 292 goto error;
293 } 293 }
294 294
295 result = asn1_der_decoding (&pkcs8_asn, raw_key->data, raw_key->size, NULL); 295 result = MHD__asn1_der_decoding (&pkcs8_asn, raw_key->data, raw_key->size, NULL);
296 if (result != ASN1_SUCCESS) 296 if (result != ASN1_SUCCESS)
297 { 297 {
298 gnutls_assert (); 298 MHD_gnutls_assert ();
299 result = mhd_gtls_asn2err (result); 299 result = MHD_gtls_asn2err (result);
300 goto error; 300 goto error;
301 } 301 }
302 302
@@ -304,17 +304,17 @@ decode_pkcs8_key (const gnutls_datum_t * raw_key,
304 */ 304 */
305 len = sizeof (enc_oid); 305 len = sizeof (enc_oid);
306 result = 306 result =
307 asn1_read_value (pkcs8_asn, "encryptionAlgorithm.algorithm", 307 MHD__asn1_read_value (pkcs8_asn, "encryptionAlgorithm.algorithm",
308 enc_oid, &len); 308 enc_oid, &len);
309 if (result != ASN1_SUCCESS) 309 if (result != ASN1_SUCCESS)
310 { 310 {
311 gnutls_assert (); 311 MHD_gnutls_assert ();
312 goto error; 312 goto error;
313 } 313 }
314 314
315 if ((result = check_schema (enc_oid)) < 0) 315 if ((result = check_schema (enc_oid)) < 0)
316 { 316 {
317 gnutls_assert (); 317 MHD_gnutls_assert ();
318 goto error; 318 goto error;
319 } 319 }
320 320
@@ -323,14 +323,14 @@ decode_pkcs8_key (const gnutls_datum_t * raw_key,
323 /* Get the DER encoding of the parameters. 323 /* Get the DER encoding of the parameters.
324 */ 324 */
325 result = 325 result =
326 asn1_der_decoding_startEnd (pkcs8_asn, raw_key->data, 326 MHD__asn1_der_decoding_startEnd (pkcs8_asn, raw_key->data,
327 raw_key->size, 327 raw_key->size,
328 "encryptionAlgorithm.parameters", 328 "encryptionAlgorithm.parameters",
329 &params_start, &params_end); 329 &params_start, &params_end);
330 if (result != ASN1_SUCCESS) 330 if (result != ASN1_SUCCESS)
331 { 331 {
332 gnutls_assert (); 332 MHD_gnutls_assert ();
333 result = mhd_gtls_asn2err (result); 333 result = MHD_gtls_asn2err (result);
334 goto error; 334 goto error;
335 } 335 }
336 params_len = params_end - params_start + 1; 336 params_len = params_end - params_start + 1;
@@ -348,14 +348,14 @@ decode_pkcs8_key (const gnutls_datum_t * raw_key,
348 &kdf_params, &enc_params, &tmp); 348 &kdf_params, &enc_params, &tmp);
349 if (result < 0) 349 if (result < 0)
350 { 350 {
351 gnutls_assert (); 351 MHD_gnutls_assert ();
352 goto error; 352 goto error;
353 } 353 }
354 354
355 asn1_delete_structure (&pkcs8_asn); 355 MHD__asn1_delete_structure (&pkcs8_asn);
356 356
357 result = decode_private_key_info (&tmp, pkey); 357 result = decode_private_key_info (&tmp, pkey);
358 _gnutls_free_datum (&tmp); 358 MHD__gnutls_free_datum (&tmp);
359 359
360 if (result < 0) 360 if (result < 0)
361 { 361 {
@@ -378,106 +378,106 @@ decode_pkcs8_key (const gnutls_datum_t * raw_key,
378 result = GNUTLS_E_DECRYPTION_FAILED; 378 result = GNUTLS_E_DECRYPTION_FAILED;
379 } 379 }
380 380
381 gnutls_assert (); 381 MHD_gnutls_assert ();
382 goto error; 382 goto error;
383 } 383 }
384 384
385 return 0; 385 return 0;
386 386
387error: 387error:
388 asn1_delete_structure (&pbes2_asn); 388 MHD__asn1_delete_structure (&pbes2_asn);
389 asn1_delete_structure (&pkcs8_asn); 389 MHD__asn1_delete_structure (&pkcs8_asn);
390 return result; 390 return result;
391} 391}
392 392
393/* Decodes an RSA privateKey from a PKCS8 structure. 393/* Decodes an RSA privateKey from a PKCS8 structure.
394 */ 394 */
395static int 395static int
396_decode_pkcs8_rsa_key (ASN1_TYPE pkcs8_asn, gnutls_x509_privkey_t pkey) 396_decode_pkcs8_rsa_key (ASN1_TYPE pkcs8_asn, MHD_gnutls_x509_privkey_t pkey)
397{ 397{
398 int ret; 398 int ret;
399 gnutls_datum_t tmp; 399 MHD_gnutls_datum_t tmp;
400 400
401 ret = _gnutls_x509_read_value (pkcs8_asn, "privateKey", &tmp, 0); 401 ret = MHD__gnutls_x509_read_value (pkcs8_asn, "privateKey", &tmp, 0);
402 if (ret < 0) 402 if (ret < 0)
403 { 403 {
404 gnutls_assert (); 404 MHD_gnutls_assert ();
405 goto error; 405 goto error;
406 } 406 }
407 407
408 pkey->key = _gnutls_privkey_decode_pkcs1_rsa_key (&tmp, pkey); 408 pkey->key = MHD__gnutls_privkey_decode_pkcs1_rsa_key (&tmp, pkey);
409 _gnutls_free_datum (&tmp); 409 MHD__gnutls_free_datum (&tmp);
410 if (pkey->key == NULL) 410 if (pkey->key == NULL)
411 { 411 {
412 gnutls_assert (); 412 MHD_gnutls_assert ();
413 goto error; 413 goto error;
414 } 414 }
415 415
416 return 0; 416 return 0;
417 417
418error: 418error:
419 gnutls_x509_privkey_deinit (pkey); 419 MHD_gnutls_x509_privkey_deinit (pkey);
420 return ret; 420 return ret;
421} 421}
422 422
423/* TODO rm if unsed - we will probable support only RSA certificates */ 423/* TODO rm if unsed - we will probable support only RSA certificates */
424/* Decodes an DSA privateKey and params from a PKCS8 structure. 424/* Decodes an DSA privateKey and params from a PKCS8 structure.
425static int 425static int
426_decode_pkcs8_dsa_key (ASN1_TYPE pkcs8_asn, gnutls_x509_privkey pkey) 426_decode_pkcs8_dsa_key (ASN1_TYPE pkcs8_asn, MHD_gnutls_x509_privkey pkey)
427 { 427 {
428 int ret; 428 int ret;
429 gnutls_datum tmp; 429 MHD_gnutls_datum tmp;
430 430
431 ret = _gnutls_x509_read_value (pkcs8_asn, "privateKey", &tmp, 0); 431 ret = MHD__gnutls_x509_read_value (pkcs8_asn, "privateKey", &tmp, 0);
432 if (ret < 0) 432 if (ret < 0)
433 { 433 {
434 gnutls_assert (); 434 MHD_gnutls_assert ();
435 goto error; 435 goto error;
436 } 436 }
437 437
438 ret = _gnutls_x509_read_der_int (tmp.data, tmp.size, &pkey->params[4]); 438 ret = MHD__gnutls_x509_read_der_int (tmp.data, tmp.size, &pkey->params[4]);
439 _gnutls_free_datum (&tmp); 439 MHD__gnutls_free_datum (&tmp);
440 440
441 if (ret < 0) 441 if (ret < 0)
442 { 442 {
443 gnutls_assert (); 443 MHD_gnutls_assert ();
444 goto error; 444 goto error;
445 } 445 }
446 446
447 ret = 447 ret =
448 _gnutls_x509_read_value (pkcs8_asn, "privateKeyAlgorithm.parameters", 448 MHD__gnutls_x509_read_value (pkcs8_asn, "privateKeyAlgorithm.parameters",
449 &tmp, 0); 449 &tmp, 0);
450 if (ret < 0) 450 if (ret < 0)
451 { 451 {
452 gnutls_assert (); 452 MHD_gnutls_assert ();
453 goto error; 453 goto error;
454 } 454 }
455 455
456 ret = _gnutls_x509_read_dsa_params (tmp.data, tmp.size, pkey->params); 456 ret = MHD__gnutls_x509_read_dsa_params (tmp.data, tmp.size, pkey->params);
457 _gnutls_free_datum (&tmp); 457 MHD__gnutls_free_datum (&tmp);
458 if (ret < 0) 458 if (ret < 0)
459 { 459 {
460 gnutls_assert (); 460 MHD_gnutls_assert ();
461 goto error; 461 goto error;
462 } 462 }
463 463
464 the public key can be generated as g^x mod p 464 the public key can be generated as g^x mod p
465 pkey->params[3] = _gnutls_mpi_alloc_like (pkey->params[0]); 465 pkey->params[3] = MHD__gnutls_mpi_alloc_like (pkey->params[0]);
466 if (pkey->params[3] == NULL) 466 if (pkey->params[3] == NULL)
467 { 467 {
468 gnutls_assert (); 468 MHD_gnutls_assert ();
469 goto error; 469 goto error;
470 } 470 }
471 471
472 _gnutls_mpi_powm (pkey->params[3], pkey->params[2], pkey->params[4], 472 MHD__gnutls_mpi_powm (pkey->params[3], pkey->params[2], pkey->params[4],
473 pkey->params[0]); 473 pkey->params[0]);
474 474
475 if (!pkey->crippled) 475 if (!pkey->crippled)
476 { 476 {
477 ret = _gnutls_asn1_encode_dsa (&pkey->key, pkey->params); 477 ret = MHD__gnutlsMHD__asn1_encode_dsa (&pkey->key, pkey->params);
478 if (ret < 0) 478 if (ret < 0)
479 { 479 {
480 gnutls_assert (); 480 MHD_gnutls_assert ();
481 goto error; 481 goto error;
482 } 482 }
483 } 483 }
@@ -487,34 +487,34 @@ _decode_pkcs8_dsa_key (ASN1_TYPE pkcs8_asn, gnutls_x509_privkey pkey)
487 return 0; 487 return 0;
488 488
489 error: 489 error:
490 gnutls_x509_privkey_deinit (pkey); 490 MHD_gnutls_x509_privkey_deinit (pkey);
491 return ret; 491 return ret;
492 } 492 }
493*/ 493*/
494 494
495static int 495static int
496decode_private_key_info (const gnutls_datum_t * der, 496decode_private_key_info (const MHD_gnutls_datum_t * der,
497 gnutls_x509_privkey_t pkey) 497 MHD_gnutls_x509_privkey_t pkey)
498{ 498{
499 int result, len; 499 int result, len;
500 opaque oid[64]; 500 opaque oid[64];
501 ASN1_TYPE pkcs8_asn = ASN1_TYPE_EMPTY; 501 ASN1_TYPE pkcs8_asn = ASN1_TYPE_EMPTY;
502 502
503 if ((result = 503 if ((result =
504 asn1_create_element (_gnutls_get_pkix (), 504 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
505 "PKIX1.pkcs-8-PrivateKeyInfo", 505 "PKIX1.pkcs-8-PrivateKeyInfo",
506 &pkcs8_asn)) != ASN1_SUCCESS) 506 &pkcs8_asn)) != ASN1_SUCCESS)
507 { 507 {
508 gnutls_assert (); 508 MHD_gnutls_assert ();
509 result = mhd_gtls_asn2err (result); 509 result = MHD_gtls_asn2err (result);
510 goto error; 510 goto error;
511 } 511 }
512 512
513 result = asn1_der_decoding (&pkcs8_asn, der->data, der->size, NULL); 513 result = MHD__asn1_der_decoding (&pkcs8_asn, der->data, der->size, NULL);
514 if (result != ASN1_SUCCESS) 514 if (result != ASN1_SUCCESS)
515 { 515 {
516 gnutls_assert (); 516 MHD_gnutls_assert ();
517 result = mhd_gtls_asn2err (result); 517 result = MHD_gtls_asn2err (result);
518 goto error; 518 goto error;
519 } 519 }
520 520
@@ -522,11 +522,11 @@ decode_private_key_info (const gnutls_datum_t * der,
522 */ 522 */
523 len = sizeof (oid); 523 len = sizeof (oid);
524 result = 524 result =
525 asn1_read_value (pkcs8_asn, "privateKeyAlgorithm.algorithm", oid, &len); 525 MHD__asn1_read_value (pkcs8_asn, "privateKeyAlgorithm.algorithm", oid, &len);
526 if (result != ASN1_SUCCESS) 526 if (result != ASN1_SUCCESS)
527 { 527 {
528 gnutls_assert (); 528 MHD_gnutls_assert ();
529 result = mhd_gtls_asn2err (result); 529 result = MHD_gtls_asn2err (result);
530 goto error; 530 goto error;
531 } 531 }
532 532
@@ -536,8 +536,8 @@ decode_private_key_info (const gnutls_datum_t * der,
536 pkey->pk_algorithm = MHD_GNUTLS_PK_RSA; 536 pkey->pk_algorithm = MHD_GNUTLS_PK_RSA;
537 else 537 else
538 { 538 {
539 gnutls_assert (); 539 MHD_gnutls_assert ();
540 _gnutls_x509_log 540 MHD__gnutls_x509_log
541 ("PKCS #8 private key OID '%s' is unsupported.\n", oid); 541 ("PKCS #8 private key OID '%s' is unsupported.\n", oid);
542 result = GNUTLS_E_UNKNOWN_PK_ALGORITHM; 542 result = GNUTLS_E_UNKNOWN_PK_ALGORITHM;
543 goto error; 543 goto error;
@@ -550,21 +550,21 @@ decode_private_key_info (const gnutls_datum_t * der,
550 result = _decode_pkcs8_rsa_key (pkcs8_asn, pkey); 550 result = _decode_pkcs8_rsa_key (pkcs8_asn, pkey);
551 if (result < 0) 551 if (result < 0)
552 { 552 {
553 gnutls_assert (); 553 MHD_gnutls_assert ();
554 return result; 554 return result;
555 } 555 }
556 556
557 result = 0; 557 result = 0;
558 558
559error: 559error:
560 asn1_delete_structure (&pkcs8_asn); 560 MHD__asn1_delete_structure (&pkcs8_asn);
561 561
562 return result; 562 return result;
563 563
564} 564}
565 565
566/** 566/**
567 * gnutls_x509_privkey_import_pkcs8 - This function will import a DER or PEM PKCS8 encoded key 567 * MHD_gnutls_x509_privkey_import_pkcs8 - This function will import a DER or PEM PKCS8 encoded key
568 * @key: The structure to store the parsed key 568 * @key: The structure to store the parsed key
569 * @data: The DER or PEM encoded key. 569 * @data: The DER or PEM encoded key.
570 * @format: One of DER or PEM 570 * @format: One of DER or PEM
@@ -572,7 +572,7 @@ error:
572 * @flags: 0 if encrypted or GNUTLS_PKCS_PLAIN if not encrypted. 572 * @flags: 0 if encrypted or GNUTLS_PKCS_PLAIN if not encrypted.
573 * 573 *
574 * This function will convert the given DER or PEM encoded PKCS8 2.0 encrypted key 574 * This function will convert the given DER or PEM encoded PKCS8 2.0 encrypted key
575 * to the native gnutls_x509_privkey_t format. The output will be stored in @key. 575 * to the native MHD_gnutls_x509_privkey_t format. The output will be stored in @key.
576 * Both RSA and DSA keys can be imported, and flags can only be used to indicate 576 * Both RSA and DSA keys can be imported, and flags can only be used to indicate
577 * an unencrypted key. 577 * an unencrypted key.
578 * 578 *
@@ -587,17 +587,17 @@ error:
587 * 587 *
588 **/ 588 **/
589int 589int
590gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key, 590MHD_gnutls_x509_privkey_import_pkcs8 (MHD_gnutls_x509_privkey_t key,
591 const gnutls_datum_t * data, 591 const MHD_gnutls_datum_t * data,
592 gnutls_x509_crt_fmt_t format, 592 MHD_gnutls_x509_crt_fmt_t format,
593 const char *password, unsigned int flags) 593 const char *password, unsigned int flags)
594{ 594{
595 int result = 0, need_free = 0; 595 int result = 0, need_free = 0;
596 gnutls_datum_t _data; 596 MHD_gnutls_datum_t _data;
597 597
598 if (key == NULL) 598 if (key == NULL)
599 { 599 {
600 gnutls_assert (); 600 MHD_gnutls_assert ();
601 return GNUTLS_E_INVALID_REQUEST; 601 return GNUTLS_E_INVALID_REQUEST;
602 } 602 }
603 603
@@ -615,20 +615,20 @@ gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key,
615 /* Try the first header 615 /* Try the first header
616 */ 616 */
617 result = 617 result =
618 _gnutls_fbase64_decode (PEM_UNENCRYPTED_PKCS8, 618 MHD__gnutls_fbase64_decode (PEM_UNENCRYPTED_PKCS8,
619 data->data, data->size, &out); 619 data->data, data->size, &out);
620 620
621 if (result < 0) 621 if (result < 0)
622 { /* Try the encrypted header 622 { /* Try the encrypted header
623 */ 623 */
624 result = 624 result =
625 _gnutls_fbase64_decode (PEM_PKCS8, data->data, data->size, &out); 625 MHD__gnutls_fbase64_decode (PEM_PKCS8, data->data, data->size, &out);
626 626
627 if (result <= 0) 627 if (result <= 0)
628 { 628 {
629 if (result == 0) 629 if (result == 0)
630 result = GNUTLS_E_INTERNAL_ERROR; 630 result = GNUTLS_E_INTERNAL_ERROR;
631 gnutls_assert (); 631 MHD_gnutls_assert ();
632 return result; 632 return result;
633 } 633 }
634 } 634 }
@@ -652,12 +652,12 @@ gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key,
652 652
653 if (result < 0) 653 if (result < 0)
654 { 654 {
655 gnutls_assert (); 655 MHD_gnutls_assert ();
656 goto cleanup; 656 goto cleanup;
657 } 657 }
658 658
659 if (need_free) 659 if (need_free)
660 _gnutls_free_datum (&_data); 660 MHD__gnutls_free_datum (&_data);
661 661
662 /* The key has now been decoded. 662 /* The key has now been decoded.
663 */ 663 */
@@ -667,7 +667,7 @@ gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key,
667cleanup: 667cleanup:
668 key->pk_algorithm = MHD_GNUTLS_PK_UNKNOWN; 668 key->pk_algorithm = MHD_GNUTLS_PK_UNKNOWN;
669 if (need_free) 669 if (need_free)
670 _gnutls_free_datum (&_data); 670 MHD__gnutls_free_datum (&_data);
671 return result; 671 return result;
672} 672}
673 673
@@ -675,7 +675,7 @@ cleanup:
675 */ 675 */
676static int 676static int
677read_pbkdf2_params (ASN1_TYPE pbes2_asn, 677read_pbkdf2_params (ASN1_TYPE pbes2_asn,
678 const gnutls_datum_t * der, struct pbkdf2_params *params) 678 const MHD_gnutls_datum_t * der, struct pbkdf2_params *params)
679{ 679{
680 int params_start, params_end; 680 int params_start, params_end;
681 int params_len, len, result; 681 int params_len, len, result;
@@ -688,30 +688,30 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn,
688 */ 688 */
689 len = sizeof (oid); 689 len = sizeof (oid);
690 result = 690 result =
691 asn1_read_value (pbes2_asn, "keyDerivationFunc.algorithm", oid, &len); 691 MHD__asn1_read_value (pbes2_asn, "keyDerivationFunc.algorithm", oid, &len);
692 if (result != ASN1_SUCCESS) 692 if (result != ASN1_SUCCESS)
693 { 693 {
694 gnutls_assert (); 694 MHD_gnutls_assert ();
695 return mhd_gtls_asn2err (result); 695 return MHD_gtls_asn2err (result);
696 } 696 }
697 _gnutls_hard_log ("keyDerivationFunc.algorithm: %s\n", oid); 697 MHD__gnutls_hard_log ("keyDerivationFunc.algorithm: %s\n", oid);
698 698
699 if (strcmp (oid, PBKDF2_OID) != 0) 699 if (strcmp (oid, PBKDF2_OID) != 0)
700 { 700 {
701 gnutls_assert (); 701 MHD_gnutls_assert ();
702 _gnutls_x509_log 702 MHD__gnutls_x509_log
703 ("PKCS #8 key derivation OID '%s' is unsupported.\n", oid); 703 ("PKCS #8 key derivation OID '%s' is unsupported.\n", oid);
704 return mhd_gtls_asn2err (result); 704 return MHD_gtls_asn2err (result);
705 } 705 }
706 706
707 result = 707 result =
708 asn1_der_decoding_startEnd (pbes2_asn, der->data, der->size, 708 MHD__asn1_der_decoding_startEnd (pbes2_asn, der->data, der->size,
709 "keyDerivationFunc.parameters", 709 "keyDerivationFunc.parameters",
710 &params_start, &params_end); 710 &params_start, &params_end);
711 if (result != ASN1_SUCCESS) 711 if (result != ASN1_SUCCESS)
712 { 712 {
713 gnutls_assert (); 713 MHD_gnutls_assert ();
714 return mhd_gtls_asn2err (result); 714 return MHD_gtls_asn2err (result);
715 } 715 }
716 params_len = params_end - params_start + 1; 716 params_len = params_end - params_start + 1;
717 717
@@ -719,58 +719,58 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn,
719 * functions. 719 * functions.
720 */ 720 */
721 if ((result = 721 if ((result =
722 asn1_create_element (_gnutls_get_pkix (), 722 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
723 "PKIX1.pkcs-5-PBKDF2-params", 723 "PKIX1.pkcs-5-PBKDF2-params",
724 &pbkdf2_asn)) != ASN1_SUCCESS) 724 &pbkdf2_asn)) != ASN1_SUCCESS)
725 { 725 {
726 gnutls_assert (); 726 MHD_gnutls_assert ();
727 return mhd_gtls_asn2err (result); 727 return MHD_gtls_asn2err (result);
728 } 728 }
729 729
730 result = 730 result =
731 asn1_der_decoding (&pbkdf2_asn, &der->data[params_start], 731 MHD__asn1_der_decoding (&pbkdf2_asn, &der->data[params_start],
732 params_len, NULL); 732 params_len, NULL);
733 if (result != ASN1_SUCCESS) 733 if (result != ASN1_SUCCESS)
734 { 734 {
735 gnutls_assert (); 735 MHD_gnutls_assert ();
736 result = mhd_gtls_asn2err (result); 736 result = MHD_gtls_asn2err (result);
737 goto error; 737 goto error;
738 } 738 }
739 739
740 /* read the salt */ 740 /* read the salt */
741 params->salt_size = sizeof (params->salt); 741 params->salt_size = sizeof (params->salt);
742 result = 742 result =
743 asn1_read_value (pbkdf2_asn, "salt.specified", params->salt, 743 MHD__asn1_read_value (pbkdf2_asn, "salt.specified", params->salt,
744 &params->salt_size); 744 &params->salt_size);
745 if (result != ASN1_SUCCESS) 745 if (result != ASN1_SUCCESS)
746 { 746 {
747 gnutls_assert (); 747 MHD_gnutls_assert ();
748 result = mhd_gtls_asn2err (result); 748 result = MHD_gtls_asn2err (result);
749 goto error; 749 goto error;
750 } 750 }
751 _gnutls_hard_log ("salt.specified.size: %d\n", params->salt_size); 751 MHD__gnutls_hard_log ("salt.specified.size: %d\n", params->salt_size);
752 752
753 /* read the iteration count 753 /* read the iteration count
754 */ 754 */
755 result = 755 result =
756 _gnutls_x509_read_uint (pbkdf2_asn, "iterationCount", 756 MHD__gnutls_x509_read_uint (pbkdf2_asn, "iterationCount",
757 &params->iter_count); 757 &params->iter_count);
758 if (result != ASN1_SUCCESS) 758 if (result != ASN1_SUCCESS)
759 { 759 {
760 gnutls_assert (); 760 MHD_gnutls_assert ();
761 goto error; 761 goto error;
762 } 762 }
763 _gnutls_hard_log ("iterationCount: %d\n", params->iter_count); 763 MHD__gnutls_hard_log ("iterationCount: %d\n", params->iter_count);
764 764
765 /* read the keylength, if it is set. 765 /* read the keylength, if it is set.
766 */ 766 */
767 result = 767 result =
768 _gnutls_x509_read_uint (pbkdf2_asn, "keyLength", &params->key_size); 768 MHD__gnutls_x509_read_uint (pbkdf2_asn, "keyLength", &params->key_size);
769 if (result < 0) 769 if (result < 0)
770 { 770 {
771 params->key_size = 0; 771 params->key_size = 0;
772 } 772 }
773 _gnutls_hard_log ("keyLength: %d\n", params->key_size); 773 MHD__gnutls_hard_log ("keyLength: %d\n", params->key_size);
774 774
775 /* We don't read the PRF. We only use the default. 775 /* We don't read the PRF. We only use the default.
776 */ 776 */
@@ -778,7 +778,7 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn,
778 return 0; 778 return 0;
779 779
780error: 780error:
781 asn1_delete_structure (&pbkdf2_asn); 781 MHD__asn1_delete_structure (&pbkdf2_asn);
782 return result; 782 return result;
783 783
784} 784}
@@ -786,7 +786,7 @@ error:
786/* Reads the PBE parameters from PKCS-12 schemas (*&#%*&#% RSA). 786/* Reads the PBE parameters from PKCS-12 schemas (*&#%*&#% RSA).
787 */ 787 */
788static int 788static int
789read_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, struct pbkdf2_params *params) 789readMHD_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, struct pbkdf2_params *params)
790{ 790{
791 int result; 791 int result;
792 792
@@ -795,25 +795,25 @@ read_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, struct pbkdf2_params *params)
795 /* read the salt */ 795 /* read the salt */
796 params->salt_size = sizeof (params->salt); 796 params->salt_size = sizeof (params->salt);
797 result = 797 result =
798 asn1_read_value (pbes2_asn, "salt", params->salt, &params->salt_size); 798 MHD__asn1_read_value (pbes2_asn, "salt", params->salt, &params->salt_size);
799 if (result != ASN1_SUCCESS) 799 if (result != ASN1_SUCCESS)
800 { 800 {
801 gnutls_assert (); 801 MHD_gnutls_assert ();
802 result = mhd_gtls_asn2err (result); 802 result = MHD_gtls_asn2err (result);
803 goto error; 803 goto error;
804 } 804 }
805 _gnutls_hard_log ("salt.size: %d\n", params->salt_size); 805 MHD__gnutls_hard_log ("salt.size: %d\n", params->salt_size);
806 806
807 /* read the iteration count 807 /* read the iteration count
808 */ 808 */
809 result = 809 result =
810 _gnutls_x509_read_uint (pbes2_asn, "iterations", &params->iter_count); 810 MHD__gnutls_x509_read_uint (pbes2_asn, "iterations", &params->iter_count);
811 if (result != ASN1_SUCCESS) 811 if (result != ASN1_SUCCESS)
812 { 812 {
813 gnutls_assert (); 813 MHD_gnutls_assert ();
814 goto error; 814 goto error;
815 } 815 }
816 _gnutls_hard_log ("iterationCount: %d\n", params->iter_count); 816 MHD__gnutls_hard_log ("iterationCount: %d\n", params->iter_count);
817 817
818 params->key_size = 0; 818 params->key_size = 0;
819 819
@@ -827,7 +827,7 @@ error:
827/* Writes the PBE parameters for PKCS-12 schemas. 827/* Writes the PBE parameters for PKCS-12 schemas.
828 */ 828 */
829static int 829static int
830write_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, 830writeMHD_pkcs12_kdf_params (ASN1_TYPE pbes2_asn,
831 const struct pbkdf2_params *kdf_params) 831 const struct pbkdf2_params *kdf_params)
832{ 832{
833 int result; 833 int result;
@@ -835,27 +835,27 @@ write_pkcs12_kdf_params (ASN1_TYPE pbes2_asn,
835 /* write the salt 835 /* write the salt
836 */ 836 */
837 result = 837 result =
838 asn1_write_value (pbes2_asn, "salt", 838 MHD__asn1_write_value (pbes2_asn, "salt",
839 kdf_params->salt, kdf_params->salt_size); 839 kdf_params->salt, kdf_params->salt_size);
840 if (result != ASN1_SUCCESS) 840 if (result != ASN1_SUCCESS)
841 { 841 {
842 gnutls_assert (); 842 MHD_gnutls_assert ();
843 result = mhd_gtls_asn2err (result); 843 result = MHD_gtls_asn2err (result);
844 goto error; 844 goto error;
845 } 845 }
846 _gnutls_hard_log ("salt.size: %d\n", kdf_params->salt_size); 846 MHD__gnutls_hard_log ("salt.size: %d\n", kdf_params->salt_size);
847 847
848 /* write the iteration count 848 /* write the iteration count
849 */ 849 */
850 result = 850 result =
851 _gnutls_x509_write_uint32 (pbes2_asn, "iterations", 851 MHD__gnutls_x509_write_uint32 (pbes2_asn, "iterations",
852 kdf_params->iter_count); 852 kdf_params->iter_count);
853 if (result < 0) 853 if (result < 0)
854 { 854 {
855 gnutls_assert (); 855 MHD_gnutls_assert ();
856 goto error; 856 goto error;
857 } 857 }
858 _gnutls_hard_log ("iterationCount: %d\n", kdf_params->iter_count); 858 MHD__gnutls_hard_log ("iterationCount: %d\n", kdf_params->iter_count);
859 859
860 return 0; 860 return 0;
861 861
@@ -884,13 +884,13 @@ oid2cipher (const char *oid, enum MHD_GNUTLS_CipherAlgorithm *algo)
884 return 0; 884 return 0;
885 } 885 }
886 886
887 _gnutls_x509_log ("PKCS #8 encryption OID '%s' is unsupported.\n", oid); 887 MHD__gnutls_x509_log ("PKCS #8 encryption OID '%s' is unsupported.\n", oid);
888 return GNUTLS_E_UNKNOWN_CIPHER_TYPE; 888 return GNUTLS_E_UNKNOWN_CIPHER_TYPE;
889} 889}
890 890
891static int 891static int
892read_pbe_enc_params (ASN1_TYPE pbes2_asn, 892read_pbe_enc_params (ASN1_TYPE pbes2_asn,
893 const gnutls_datum_t * der, 893 const MHD_gnutls_datum_t * der,
894 struct pbe_enc_params *params) 894 struct pbe_enc_params *params)
895{ 895{
896 int params_start, params_end; 896 int params_start, params_end;
@@ -904,66 +904,66 @@ read_pbe_enc_params (ASN1_TYPE pbes2_asn,
904 */ 904 */
905 len = sizeof (oid); 905 len = sizeof (oid);
906 result = 906 result =
907 asn1_read_value (pbes2_asn, "encryptionScheme.algorithm", oid, &len); 907 MHD__asn1_read_value (pbes2_asn, "encryptionScheme.algorithm", oid, &len);
908 if (result != ASN1_SUCCESS) 908 if (result != ASN1_SUCCESS)
909 { 909 {
910 gnutls_assert (); 910 MHD_gnutls_assert ();
911 goto error; 911 goto error;
912 } 912 }
913 _gnutls_hard_log ("encryptionScheme.algorithm: %s\n", oid); 913 MHD__gnutls_hard_log ("encryptionScheme.algorithm: %s\n", oid);
914 914
915 if ((result = oid2cipher (oid, &params->cipher)) < 0) 915 if ((result = oid2cipher (oid, &params->cipher)) < 0)
916 { 916 {
917 gnutls_assert (); 917 MHD_gnutls_assert ();
918 goto error; 918 goto error;
919 } 919 }
920 920
921 result = 921 result =
922 asn1_der_decoding_startEnd (pbes2_asn, der->data, der->size, 922 MHD__asn1_der_decoding_startEnd (pbes2_asn, der->data, der->size,
923 "encryptionScheme.parameters", 923 "encryptionScheme.parameters",
924 &params_start, &params_end); 924 &params_start, &params_end);
925 if (result != ASN1_SUCCESS) 925 if (result != ASN1_SUCCESS)
926 { 926 {
927 gnutls_assert (); 927 MHD_gnutls_assert ();
928 return mhd_gtls_asn2err (result); 928 return MHD_gtls_asn2err (result);
929 } 929 }
930 params_len = params_end - params_start + 1; 930 params_len = params_end - params_start + 1;
931 931
932 /* Now check the encryption parameters. 932 /* Now check the encryption parameters.
933 */ 933 */
934 if ((result = 934 if ((result =
935 asn1_create_element (_gnutls_get_pkix (), 935 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
936 "PKIX1.pkcs-5-des-EDE3-CBC-params", 936 "PKIX1.pkcs-5-des-EDE3-CBC-params",
937 &pbe_asn)) != ASN1_SUCCESS) 937 &pbe_asn)) != ASN1_SUCCESS)
938 { 938 {
939 gnutls_assert (); 939 MHD_gnutls_assert ();
940 return mhd_gtls_asn2err (result); 940 return MHD_gtls_asn2err (result);
941 } 941 }
942 942
943 result = 943 result =
944 asn1_der_decoding (&pbe_asn, &der->data[params_start], params_len, NULL); 944 MHD__asn1_der_decoding (&pbe_asn, &der->data[params_start], params_len, NULL);
945 if (result != ASN1_SUCCESS) 945 if (result != ASN1_SUCCESS)
946 { 946 {
947 gnutls_assert (); 947 MHD_gnutls_assert ();
948 result = mhd_gtls_asn2err (result); 948 result = MHD_gtls_asn2err (result);
949 goto error; 949 goto error;
950 } 950 }
951 951
952 /* read the IV */ 952 /* read the IV */
953 params->iv_size = sizeof (params->iv); 953 params->iv_size = sizeof (params->iv);
954 result = asn1_read_value (pbe_asn, "", params->iv, &params->iv_size); 954 result = MHD__asn1_read_value (pbe_asn, "", params->iv, &params->iv_size);
955 if (result != ASN1_SUCCESS) 955 if (result != ASN1_SUCCESS)
956 { 956 {
957 gnutls_assert (); 957 MHD_gnutls_assert ();
958 result = mhd_gtls_asn2err (result); 958 result = MHD_gtls_asn2err (result);
959 goto error; 959 goto error;
960 } 960 }
961 _gnutls_hard_log ("IV.size: %d\n", params->iv_size); 961 MHD__gnutls_hard_log ("IV.size: %d\n", params->iv_size);
962 962
963 return 0; 963 return 0;
964 964
965error: 965error:
966 asn1_delete_structure (&pbe_asn); 966 MHD__asn1_delete_structure (&pbe_asn);
967 return result; 967 return result;
968 968
969} 969}
@@ -973,49 +973,49 @@ decrypt_data (schema_id schema, ASN1_TYPE pkcs8_asn,
973 const char *root, const char *password, 973 const char *root, const char *password,
974 const struct pbkdf2_params *kdf_params, 974 const struct pbkdf2_params *kdf_params,
975 const struct pbe_enc_params *enc_params, 975 const struct pbe_enc_params *enc_params,
976 gnutls_datum_t * decrypted_data) 976 MHD_gnutls_datum_t * decrypted_data)
977{ 977{
978 int result; 978 int result;
979 int data_size; 979 int data_size;
980 opaque *data = NULL, *key = NULL; 980 opaque *data = NULL, *key = NULL;
981 gnutls_datum_t dkey, d_iv; 981 MHD_gnutls_datum_t dkey, d_iv;
982 cipher_hd_t ch = NULL; 982 cipher_hd_t ch = NULL;
983 int key_size; 983 int key_size;
984 984
985 data_size = 0; 985 data_size = 0;
986 result = asn1_read_value (pkcs8_asn, root, NULL, &data_size); 986 result = MHD__asn1_read_value (pkcs8_asn, root, NULL, &data_size);
987 if (result != ASN1_MEM_ERROR) 987 if (result != ASN1_MEM_ERROR)
988 { 988 {
989 gnutls_assert (); 989 MHD_gnutls_assert ();
990 return mhd_gtls_asn2err (result); 990 return MHD_gtls_asn2err (result);
991 } 991 }
992 992
993 data = gnutls_malloc (data_size); 993 data = MHD_gnutls_malloc (data_size);
994 if (data == NULL) 994 if (data == NULL)
995 { 995 {
996 gnutls_assert (); 996 MHD_gnutls_assert ();
997 return GNUTLS_E_MEMORY_ERROR; 997 return GNUTLS_E_MEMORY_ERROR;
998 } 998 }
999 999
1000 result = asn1_read_value (pkcs8_asn, root, data, &data_size); 1000 result = MHD__asn1_read_value (pkcs8_asn, root, data, &data_size);
1001 if (result != ASN1_SUCCESS) 1001 if (result != ASN1_SUCCESS)
1002 { 1002 {
1003 gnutls_assert (); 1003 MHD_gnutls_assert ();
1004 result = mhd_gtls_asn2err (result); 1004 result = MHD_gtls_asn2err (result);
1005 goto error; 1005 goto error;
1006 } 1006 }
1007 1007
1008 if (kdf_params->key_size == 0) 1008 if (kdf_params->key_size == 0)
1009 { 1009 {
1010 key_size = MHD_gnutls_cipher_get_key_size (enc_params->cipher); 1010 key_size = MHD__gnutls_cipher_get_key_size (enc_params->cipher);
1011 } 1011 }
1012 else 1012 else
1013 key_size = kdf_params->key_size; 1013 key_size = kdf_params->key_size;
1014 1014
1015 key = gnutls_alloca (key_size); 1015 key = MHD_gnutls_alloca (key_size);
1016 if (key == NULL) 1016 if (key == NULL)
1017 { 1017 {
1018 gnutls_assert (); 1018 MHD_gnutls_assert ();
1019 result = GNUTLS_E_MEMORY_ERROR; 1019 result = GNUTLS_E_MEMORY_ERROR;
1020 goto error; 1020 goto error;
1021 } 1021 }
@@ -1024,13 +1024,13 @@ decrypt_data (schema_id schema, ASN1_TYPE pkcs8_asn,
1024 */ 1024 */
1025 if (schema == PBES2) 1025 if (schema == PBES2)
1026 { 1026 {
1027 result = gc_pbkdf2_sha1 (password, strlen (password), 1027 result = MHD_gc_pbkdf2_sha1 (password, strlen (password),
1028 kdf_params->salt, kdf_params->salt_size, 1028 kdf_params->salt, kdf_params->salt_size,
1029 kdf_params->iter_count, key, key_size); 1029 kdf_params->iter_count, key, key_size);
1030 1030
1031 if (result != GC_OK) 1031 if (result != GC_OK)
1032 { 1032 {
1033 gnutls_assert (); 1033 MHD_gnutls_assert ();
1034 result = GNUTLS_E_DECRYPTION_FAILED; 1034 result = GNUTLS_E_DECRYPTION_FAILED;
1035 goto error; 1035 goto error;
1036 } 1036 }
@@ -1038,14 +1038,14 @@ decrypt_data (schema_id schema, ASN1_TYPE pkcs8_asn,
1038 else 1038 else
1039 { 1039 {
1040 result = 1040 result =
1041 _pkcs12_string_to_key (1 /*KEY*/, kdf_params->salt, 1041 MHD_pkcs12_string_to_key (1 /*KEY*/, kdf_params->salt,
1042 kdf_params->salt_size, 1042 kdf_params->salt_size,
1043 kdf_params->iter_count, password, 1043 kdf_params->iter_count, password,
1044 key_size, key); 1044 key_size, key);
1045 1045
1046 if (result < 0) 1046 if (result < 0)
1047 { 1047 {
1048 gnutls_assert (); 1048 MHD_gnutls_assert ();
1049 goto error; 1049 goto error;
1050 } 1050 }
1051 } 1051 }
@@ -1057,41 +1057,41 @@ decrypt_data (schema_id schema, ASN1_TYPE pkcs8_asn,
1057 1057
1058 d_iv.data = (opaque *) enc_params->iv; 1058 d_iv.data = (opaque *) enc_params->iv;
1059 d_iv.size = enc_params->iv_size; 1059 d_iv.size = enc_params->iv_size;
1060 ch = mhd_gtls_cipher_init (enc_params->cipher, &dkey, &d_iv); 1060 ch = MHD_gtls_cipher_init (enc_params->cipher, &dkey, &d_iv);
1061 1061
1062 gnutls_afree (key); 1062 MHD_gnutls_afree (key);
1063 key = NULL; 1063 key = NULL;
1064 1064
1065 if (ch == NULL) 1065 if (ch == NULL)
1066 { 1066 {
1067 gnutls_assert (); 1067 MHD_gnutls_assert ();
1068 result = GNUTLS_E_DECRYPTION_FAILED; 1068 result = GNUTLS_E_DECRYPTION_FAILED;
1069 goto error; 1069 goto error;
1070 } 1070 }
1071 1071
1072 result = mhd_gtls_cipher_decrypt (ch, data, data_size); 1072 result = MHD_gtls_cipher_decrypt (ch, data, data_size);
1073 if (result < 0) 1073 if (result < 0)
1074 { 1074 {
1075 gnutls_assert (); 1075 MHD_gnutls_assert ();
1076 goto error; 1076 goto error;
1077 } 1077 }
1078 1078
1079 decrypted_data->data = data; 1079 decrypted_data->data = data;
1080 1080
1081 if (mhd_gtls_cipher_get_block_size (enc_params->cipher) != 1) 1081 if (MHD_gtls_cipher_get_block_size (enc_params->cipher) != 1)
1082 decrypted_data->size = data_size - data[data_size - 1]; 1082 decrypted_data->size = data_size - data[data_size - 1];
1083 else 1083 else
1084 decrypted_data->size = data_size; 1084 decrypted_data->size = data_size;
1085 1085
1086 mhd_gnutls_cipher_deinit (ch); 1086 MHD_gnutls_cipher_deinit (ch);
1087 1087
1088 return 0; 1088 return 0;
1089 1089
1090error: 1090error:
1091 gnutls_free (data); 1091 MHD_gnutls_free (data);
1092 gnutls_afree (key); 1092 MHD_gnutls_afree (key);
1093 if (ch != NULL) 1093 if (ch != NULL)
1094 mhd_gnutls_cipher_deinit (ch); 1094 MHD_gnutls_cipher_deinit (ch);
1095 return result; 1095 return result;
1096} 1096}
1097 1097
@@ -1108,97 +1108,97 @@ write_pbkdf2_params (ASN1_TYPE pbes2_asn,
1108 /* Write the key derivation algorithm 1108 /* Write the key derivation algorithm
1109 */ 1109 */
1110 result = 1110 result =
1111 asn1_write_value (pbes2_asn, "keyDerivationFunc.algorithm", 1111 MHD__asn1_write_value (pbes2_asn, "keyDerivationFunc.algorithm",
1112 PBKDF2_OID, 1); 1112 PBKDF2_OID, 1);
1113 if (result != ASN1_SUCCESS) 1113 if (result != ASN1_SUCCESS)
1114 { 1114 {
1115 gnutls_assert (); 1115 MHD_gnutls_assert ();
1116 return mhd_gtls_asn2err (result); 1116 return MHD_gtls_asn2err (result);
1117 } 1117 }
1118 1118
1119 /* Now write the key derivation and the encryption 1119 /* Now write the key derivation and the encryption
1120 * functions. 1120 * functions.
1121 */ 1121 */
1122 if ((result = 1122 if ((result =
1123 asn1_create_element (_gnutls_get_pkix (), 1123 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1124 "PKIX1.pkcs-5-PBKDF2-params", 1124 "PKIX1.pkcs-5-PBKDF2-params",
1125 &pbkdf2_asn)) != ASN1_SUCCESS) 1125 &pbkdf2_asn)) != ASN1_SUCCESS)
1126 { 1126 {
1127 gnutls_assert (); 1127 MHD_gnutls_assert ();
1128 return mhd_gtls_asn2err (result); 1128 return MHD_gtls_asn2err (result);
1129 } 1129 }
1130 1130
1131 result = asn1_write_value (pbkdf2_asn, "salt", "specified", 1); 1131 result = MHD__asn1_write_value (pbkdf2_asn, "salt", "specified", 1);
1132 if (result != ASN1_SUCCESS) 1132 if (result != ASN1_SUCCESS)
1133 { 1133 {
1134 gnutls_assert (); 1134 MHD_gnutls_assert ();
1135 result = mhd_gtls_asn2err (result); 1135 result = MHD_gtls_asn2err (result);
1136 goto error; 1136 goto error;
1137 } 1137 }
1138 1138
1139 /* write the salt 1139 /* write the salt
1140 */ 1140 */
1141 result = 1141 result =
1142 asn1_write_value (pbkdf2_asn, "salt.specified", 1142 MHD__asn1_write_value (pbkdf2_asn, "salt.specified",
1143 kdf_params->salt, kdf_params->salt_size); 1143 kdf_params->salt, kdf_params->salt_size);
1144 if (result != ASN1_SUCCESS) 1144 if (result != ASN1_SUCCESS)
1145 { 1145 {
1146 gnutls_assert (); 1146 MHD_gnutls_assert ();
1147 result = mhd_gtls_asn2err (result); 1147 result = MHD_gtls_asn2err (result);
1148 goto error; 1148 goto error;
1149 } 1149 }
1150 _gnutls_hard_log ("salt.specified.size: %d\n", kdf_params->salt_size); 1150 MHD__gnutls_hard_log ("salt.specified.size: %d\n", kdf_params->salt_size);
1151 1151
1152 /* write the iteration count 1152 /* write the iteration count
1153 */ 1153 */
1154 mhd_gtls_write_uint32 (kdf_params->iter_count, tmp); 1154 MHD_gtls_write_uint32 (kdf_params->iter_count, tmp);
1155 1155
1156 result = asn1_write_value (pbkdf2_asn, "iterationCount", tmp, 4); 1156 result = MHD__asn1_write_value (pbkdf2_asn, "iterationCount", tmp, 4);
1157 if (result != ASN1_SUCCESS) 1157 if (result != ASN1_SUCCESS)
1158 { 1158 {
1159 gnutls_assert (); 1159 MHD_gnutls_assert ();
1160 result = mhd_gtls_asn2err (result); 1160 result = MHD_gtls_asn2err (result);
1161 goto error; 1161 goto error;
1162 } 1162 }
1163 _gnutls_hard_log ("iterationCount: %d\n", kdf_params->iter_count); 1163 MHD__gnutls_hard_log ("iterationCount: %d\n", kdf_params->iter_count);
1164 1164
1165 /* write the keylength, if it is set. 1165 /* write the keylength, if it is set.
1166 */ 1166 */
1167 result = asn1_write_value (pbkdf2_asn, "keyLength", NULL, 0); 1167 result = MHD__asn1_write_value (pbkdf2_asn, "keyLength", NULL, 0);
1168 if (result != ASN1_SUCCESS) 1168 if (result != ASN1_SUCCESS)
1169 { 1169 {
1170 gnutls_assert (); 1170 MHD_gnutls_assert ();
1171 result = mhd_gtls_asn2err (result); 1171 result = MHD_gtls_asn2err (result);
1172 goto error; 1172 goto error;
1173 } 1173 }
1174 1174
1175 /* We write an emptry prf. 1175 /* We write an emptry prf.
1176 */ 1176 */
1177 result = asn1_write_value (pbkdf2_asn, "prf", NULL, 0); 1177 result = MHD__asn1_write_value (pbkdf2_asn, "prf", NULL, 0);
1178 if (result != ASN1_SUCCESS) 1178 if (result != ASN1_SUCCESS)
1179 { 1179 {
1180 gnutls_assert (); 1180 MHD_gnutls_assert ();
1181 result = mhd_gtls_asn2err (result); 1181 result = MHD_gtls_asn2err (result);
1182 goto error; 1182 goto error;
1183 } 1183 }
1184 1184
1185 /* now encode them an put the DER output 1185 /* now encode them an put the DER output
1186 * in the keyDerivationFunc.parameters 1186 * in the keyDerivationFunc.parameters
1187 */ 1187 */
1188 result = _gnutls_x509_der_encode_and_copy (pbkdf2_asn, "", 1188 result = MHD__gnutls_x509_der_encode_and_copy (pbkdf2_asn, "",
1189 pbes2_asn, 1189 pbes2_asn,
1190 "keyDerivationFunc.parameters", 1190 "keyDerivationFunc.parameters",
1191 0); 1191 0);
1192 if (result < 0) 1192 if (result < 0)
1193 { 1193 {
1194 gnutls_assert (); 1194 MHD_gnutls_assert ();
1195 goto error; 1195 goto error;
1196 } 1196 }
1197 1197
1198 return 0; 1198 return 0;
1199 1199
1200error: 1200error:
1201 asn1_delete_structure (&pbkdf2_asn); 1201 MHD__asn1_delete_structure (&pbkdf2_asn);
1202 return result; 1202 return result;
1203 1203
1204} 1204}
@@ -1213,53 +1213,53 @@ write_pbe_enc_params (ASN1_TYPE pbes2_asn,
1213 /* Write the encryption algorithm 1213 /* Write the encryption algorithm
1214 */ 1214 */
1215 result = 1215 result =
1216 asn1_write_value (pbes2_asn, "encryptionScheme.algorithm", 1216 MHD__asn1_write_value (pbes2_asn, "encryptionScheme.algorithm",
1217 DES_EDE3_CBC_OID, 1); 1217 DES_EDE3_CBC_OID, 1);
1218 if (result != ASN1_SUCCESS) 1218 if (result != ASN1_SUCCESS)
1219 { 1219 {
1220 gnutls_assert (); 1220 MHD_gnutls_assert ();
1221 goto error; 1221 goto error;
1222 } 1222 }
1223 _gnutls_hard_log ("encryptionScheme.algorithm: %s\n", DES_EDE3_CBC_OID); 1223 MHD__gnutls_hard_log ("encryptionScheme.algorithm: %s\n", DES_EDE3_CBC_OID);
1224 1224
1225 /* Now check the encryption parameters. 1225 /* Now check the encryption parameters.
1226 */ 1226 */
1227 if ((result = 1227 if ((result =
1228 asn1_create_element (_gnutls_get_pkix (), 1228 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1229 "PKIX1.pkcs-5-des-EDE3-CBC-params", 1229 "PKIX1.pkcs-5-des-EDE3-CBC-params",
1230 &pbe_asn)) != ASN1_SUCCESS) 1230 &pbe_asn)) != ASN1_SUCCESS)
1231 { 1231 {
1232 gnutls_assert (); 1232 MHD_gnutls_assert ();
1233 return mhd_gtls_asn2err (result); 1233 return MHD_gtls_asn2err (result);
1234 } 1234 }
1235 1235
1236 /* read the salt */ 1236 /* read the salt */
1237 result = asn1_write_value (pbe_asn, "", params->iv, params->iv_size); 1237 result = MHD__asn1_write_value (pbe_asn, "", params->iv, params->iv_size);
1238 if (result != ASN1_SUCCESS) 1238 if (result != ASN1_SUCCESS)
1239 { 1239 {
1240 gnutls_assert (); 1240 MHD_gnutls_assert ();
1241 result = mhd_gtls_asn2err (result); 1241 result = MHD_gtls_asn2err (result);
1242 goto error; 1242 goto error;
1243 } 1243 }
1244 _gnutls_hard_log ("IV.size: %d\n", params->iv_size); 1244 MHD__gnutls_hard_log ("IV.size: %d\n", params->iv_size);
1245 1245
1246 /* now encode them an put the DER output 1246 /* now encode them an put the DER output
1247 * in the encryptionScheme.parameters 1247 * in the encryptionScheme.parameters
1248 */ 1248 */
1249 result = _gnutls_x509_der_encode_and_copy (pbe_asn, "", 1249 result = MHD__gnutls_x509_der_encode_and_copy (pbe_asn, "",
1250 pbes2_asn, 1250 pbes2_asn,
1251 "encryptionScheme.parameters", 1251 "encryptionScheme.parameters",
1252 0); 1252 0);
1253 if (result < 0) 1253 if (result < 0)
1254 { 1254 {
1255 gnutls_assert (); 1255 MHD_gnutls_assert ();
1256 goto error; 1256 goto error;
1257 } 1257 }
1258 1258
1259 return 0; 1259 return 0;
1260 1260
1261error: 1261error:
1262 asn1_delete_structure (&pbe_asn); 1262 MHD__asn1_delete_structure (&pbe_asn);
1263 return result; 1263 return result;
1264 1264
1265} 1265}
@@ -1270,7 +1270,7 @@ static int
1270generate_key (schema_id schema, 1270generate_key (schema_id schema,
1271 const char *password, 1271 const char *password,
1272 struct pbkdf2_params *kdf_params, 1272 struct pbkdf2_params *kdf_params,
1273 struct pbe_enc_params *enc_params, gnutls_datum_t * key) 1273 struct pbe_enc_params *enc_params, MHD_gnutls_datum_t * key)
1274{ 1274{
1275 opaque rnd[2]; 1275 opaque rnd[2];
1276 int ret; 1276 int ret;
@@ -1286,9 +1286,9 @@ generate_key (schema_id schema,
1286 else if (schema == PKCS12_RC2_40_SHA1) 1286 else if (schema == PKCS12_RC2_40_SHA1)
1287 enc_params->cipher = MHD_GNUTLS_CIPHER_RC2_40_CBC; 1287 enc_params->cipher = MHD_GNUTLS_CIPHER_RC2_40_CBC;
1288 1288
1289 if (gc_pseudo_random (rnd, 2) != GC_OK) 1289 if (MHD_gc_pseudo_random (rnd, 2) != GC_OK)
1290 { 1290 {
1291 gnutls_assert (); 1291 MHD_gnutls_assert ();
1292 return GNUTLS_E_RANDOM_FAILED; 1292 return GNUTLS_E_RANDOM_FAILED;
1293 } 1293 }
1294 1294
@@ -1302,22 +1302,22 @@ generate_key (schema_id schema,
1302 else 1302 else
1303 kdf_params->salt_size = 8; 1303 kdf_params->salt_size = 8;
1304 1304
1305 if (gc_pseudo_random (kdf_params->salt, kdf_params->salt_size) != GC_OK) 1305 if (MHD_gc_pseudo_random (kdf_params->salt, kdf_params->salt_size) != GC_OK)
1306 { 1306 {
1307 gnutls_assert (); 1307 MHD_gnutls_assert ();
1308 return GNUTLS_E_RANDOM_FAILED; 1308 return GNUTLS_E_RANDOM_FAILED;
1309 } 1309 }
1310 1310
1311 kdf_params->iter_count = 256 + rnd[0]; 1311 kdf_params->iter_count = 256 + rnd[0];
1312 key->size = kdf_params->key_size = 1312 key->size = kdf_params->key_size =
1313 MHD_gnutls_cipher_get_key_size (enc_params->cipher); 1313 MHD__gnutls_cipher_get_key_size (enc_params->cipher);
1314 1314
1315 enc_params->iv_size = mhd_gtls_cipher_get_iv_size (enc_params->cipher); 1315 enc_params->iv_size = MHD_gtls_cipher_get_iv_size (enc_params->cipher);
1316 1316
1317 key->data = gnutls_secure_malloc (key->size); 1317 key->data = MHD_gnutls_secure_malloc (key->size);
1318 if (key->data == NULL) 1318 if (key->data == NULL)
1319 { 1319 {
1320 gnutls_assert (); 1320 MHD_gnutls_assert ();
1321 return GNUTLS_E_MEMORY_ERROR; 1321 return GNUTLS_E_MEMORY_ERROR;
1322 } 1322 }
1323 1323
@@ -1327,33 +1327,33 @@ generate_key (schema_id schema,
1327 if (schema == PBES2) 1327 if (schema == PBES2)
1328 { 1328 {
1329 1329
1330 ret = gc_pbkdf2_sha1 (password, strlen (password), 1330 ret = MHD_gc_pbkdf2_sha1 (password, strlen (password),
1331 kdf_params->salt, kdf_params->salt_size, 1331 kdf_params->salt, kdf_params->salt_size,
1332 kdf_params->iter_count, 1332 kdf_params->iter_count,
1333 key->data, kdf_params->key_size); 1333 key->data, kdf_params->key_size);
1334 if (ret != GC_OK) 1334 if (ret != GC_OK)
1335 { 1335 {
1336 gnutls_assert (); 1336 MHD_gnutls_assert ();
1337 return GNUTLS_E_ENCRYPTION_FAILED; 1337 return GNUTLS_E_ENCRYPTION_FAILED;
1338 } 1338 }
1339 1339
1340 if (enc_params->iv_size && 1340 if (enc_params->iv_size &&
1341 gc_nonce (enc_params->iv, enc_params->iv_size) != GC_OK) 1341 MHD_gc_nonce (enc_params->iv, enc_params->iv_size) != GC_OK)
1342 { 1342 {
1343 gnutls_assert (); 1343 MHD_gnutls_assert ();
1344 return GNUTLS_E_RANDOM_FAILED; 1344 return GNUTLS_E_RANDOM_FAILED;
1345 } 1345 }
1346 } 1346 }
1347 else 1347 else
1348 { /* PKCS12 schemas */ 1348 { /* PKCS12 schemas */
1349 ret = 1349 ret =
1350 _pkcs12_string_to_key (1 /*KEY*/, kdf_params->salt, 1350 MHD_pkcs12_string_to_key (1 /*KEY*/, kdf_params->salt,
1351 kdf_params->salt_size, 1351 kdf_params->salt_size,
1352 kdf_params->iter_count, password, 1352 kdf_params->iter_count, password,
1353 kdf_params->key_size, key->data); 1353 kdf_params->key_size, key->data);
1354 if (ret < 0) 1354 if (ret < 0)
1355 { 1355 {
1356 gnutls_assert (); 1356 MHD_gnutls_assert ();
1357 return ret; 1357 return ret;
1358 } 1358 }
1359 1359
@@ -1362,13 +1362,13 @@ generate_key (schema_id schema,
1362 if (enc_params->iv_size) 1362 if (enc_params->iv_size)
1363 { 1363 {
1364 ret = 1364 ret =
1365 _pkcs12_string_to_key (2 /*IV*/, kdf_params->salt, 1365 MHD_pkcs12_string_to_key (2 /*IV*/, kdf_params->salt,
1366 kdf_params->salt_size, 1366 kdf_params->salt_size,
1367 kdf_params->iter_count, password, 1367 kdf_params->iter_count, password,
1368 enc_params->iv_size, enc_params->iv); 1368 enc_params->iv_size, enc_params->iv);
1369 if (ret < 0) 1369 if (ret < 0)
1370 { 1370 {
1371 gnutls_assert (); 1371 MHD_gnutls_assert ();
1372 return ret; 1372 return ret;
1373 } 1373 }
1374 } 1374 }
@@ -1392,99 +1392,99 @@ write_schema_params (schema_id schema, ASN1_TYPE pkcs8_asn,
1392 if (schema == PBES2) 1392 if (schema == PBES2)
1393 { 1393 {
1394 if ((result = 1394 if ((result =
1395 asn1_create_element (_gnutls_get_pkix (), 1395 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1396 "PKIX1.pkcs-5-PBES2-params", 1396 "PKIX1.pkcs-5-PBES2-params",
1397 &pbes2_asn)) != ASN1_SUCCESS) 1397 &pbes2_asn)) != ASN1_SUCCESS)
1398 { 1398 {
1399 gnutls_assert (); 1399 MHD_gnutls_assert ();
1400 return mhd_gtls_asn2err (result); 1400 return MHD_gtls_asn2err (result);
1401 } 1401 }
1402 1402
1403 result = write_pbkdf2_params (pbes2_asn, kdf_params); 1403 result = write_pbkdf2_params (pbes2_asn, kdf_params);
1404 if (result < 0) 1404 if (result < 0)
1405 { 1405 {
1406 gnutls_assert (); 1406 MHD_gnutls_assert ();
1407 goto error; 1407 goto error;
1408 } 1408 }
1409 1409
1410 result = write_pbe_enc_params (pbes2_asn, enc_params); 1410 result = write_pbe_enc_params (pbes2_asn, enc_params);
1411 if (result < 0) 1411 if (result < 0)
1412 { 1412 {
1413 gnutls_assert (); 1413 MHD_gnutls_assert ();
1414 goto error; 1414 goto error;
1415 } 1415 }
1416 1416
1417 result = _gnutls_x509_der_encode_and_copy (pbes2_asn, "", 1417 result = MHD__gnutls_x509_der_encode_and_copy (pbes2_asn, "",
1418 pkcs8_asn, where, 0); 1418 pkcs8_asn, where, 0);
1419 if (result < 0) 1419 if (result < 0)
1420 { 1420 {
1421 gnutls_assert (); 1421 MHD_gnutls_assert ();
1422 goto error; 1422 goto error;
1423 } 1423 }
1424 1424
1425 asn1_delete_structure (&pbes2_asn); 1425 MHD__asn1_delete_structure (&pbes2_asn);
1426 } 1426 }
1427 else 1427 else
1428 { /* PKCS12 schemas */ 1428 { /* PKCS12 schemas */
1429 1429
1430 if ((result = 1430 if ((result =
1431 asn1_create_element (_gnutls_get_pkix (), 1431 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1432 "PKIX1.pkcs-12-PbeParams", 1432 "PKIX1.pkcs-12-PbeParams",
1433 &pbes2_asn)) != ASN1_SUCCESS) 1433 &pbes2_asn)) != ASN1_SUCCESS)
1434 { 1434 {
1435 gnutls_assert (); 1435 MHD_gnutls_assert ();
1436 result = mhd_gtls_asn2err (result); 1436 result = MHD_gtls_asn2err (result);
1437 goto error; 1437 goto error;
1438 } 1438 }
1439 1439
1440 result = write_pkcs12_kdf_params (pbes2_asn, kdf_params); 1440 result = writeMHD_pkcs12_kdf_params (pbes2_asn, kdf_params);
1441 if (result < 0) 1441 if (result < 0)
1442 { 1442 {
1443 gnutls_assert (); 1443 MHD_gnutls_assert ();
1444 goto error; 1444 goto error;
1445 } 1445 }
1446 1446
1447 result = _gnutls_x509_der_encode_and_copy (pbes2_asn, "", 1447 result = MHD__gnutls_x509_der_encode_and_copy (pbes2_asn, "",
1448 pkcs8_asn, where, 0); 1448 pkcs8_asn, where, 0);
1449 if (result < 0) 1449 if (result < 0)
1450 { 1450 {
1451 gnutls_assert (); 1451 MHD_gnutls_assert ();
1452 goto error; 1452 goto error;
1453 } 1453 }
1454 1454
1455 asn1_delete_structure (&pbes2_asn); 1455 MHD__asn1_delete_structure (&pbes2_asn);
1456 1456
1457 } 1457 }
1458 1458
1459 return 0; 1459 return 0;
1460 1460
1461error: 1461error:
1462 asn1_delete_structure (&pbes2_asn); 1462 MHD__asn1_delete_structure (&pbes2_asn);
1463 return result; 1463 return result;
1464 1464
1465} 1465}
1466 1466
1467static int 1467static int
1468encrypt_data (const gnutls_datum_t * plain, 1468encrypt_data (const MHD_gnutls_datum_t * plain,
1469 const struct pbe_enc_params *enc_params, 1469 const struct pbe_enc_params *enc_params,
1470 gnutls_datum_t * key, gnutls_datum_t * encrypted) 1470 MHD_gnutls_datum_t * key, MHD_gnutls_datum_t * encrypted)
1471{ 1471{
1472 int result; 1472 int result;
1473 int data_size; 1473 int data_size;
1474 opaque *data = NULL; 1474 opaque *data = NULL;
1475 gnutls_datum_t d_iv; 1475 MHD_gnutls_datum_t d_iv;
1476 cipher_hd_t ch = NULL; 1476 cipher_hd_t ch = NULL;
1477 opaque pad, pad_size; 1477 opaque pad, pad_size;
1478 1478
1479 pad_size = mhd_gtls_cipher_get_block_size (enc_params->cipher); 1479 pad_size = MHD_gtls_cipher_get_block_size (enc_params->cipher);
1480 1480
1481 if (pad_size == 1) /* stream */ 1481 if (pad_size == 1) /* stream */
1482 pad_size = 0; 1482 pad_size = 0;
1483 1483
1484 data = gnutls_malloc (plain->size + pad_size); 1484 data = MHD_gnutls_malloc (plain->size + pad_size);
1485 if (data == NULL) 1485 if (data == NULL)
1486 { 1486 {
1487 gnutls_assert (); 1487 MHD_gnutls_assert ();
1488 return GNUTLS_E_MEMORY_ERROR; 1488 return GNUTLS_E_MEMORY_ERROR;
1489 } 1489 }
1490 1490
@@ -1504,33 +1504,33 @@ encrypt_data (const gnutls_datum_t * plain,
1504 1504
1505 d_iv.data = (opaque *) enc_params->iv; 1505 d_iv.data = (opaque *) enc_params->iv;
1506 d_iv.size = enc_params->iv_size; 1506 d_iv.size = enc_params->iv_size;
1507 ch = mhd_gtls_cipher_init (enc_params->cipher, key, &d_iv); 1507 ch = MHD_gtls_cipher_init (enc_params->cipher, key, &d_iv);
1508 1508
1509 if (ch == GNUTLS_CIPHER_FAILED) 1509 if (ch == GNUTLS_CIPHER_FAILED)
1510 { 1510 {
1511 gnutls_assert (); 1511 MHD_gnutls_assert ();
1512 result = GNUTLS_E_ENCRYPTION_FAILED; 1512 result = GNUTLS_E_ENCRYPTION_FAILED;
1513 goto error; 1513 goto error;
1514 } 1514 }
1515 1515
1516 result = mhd_gtls_cipher_encrypt (ch, data, data_size); 1516 result = MHD_gtls_cipher_encrypt (ch, data, data_size);
1517 if (result < 0) 1517 if (result < 0)
1518 { 1518 {
1519 gnutls_assert (); 1519 MHD_gnutls_assert ();
1520 goto error; 1520 goto error;
1521 } 1521 }
1522 1522
1523 encrypted->data = data; 1523 encrypted->data = data;
1524 encrypted->size = data_size; 1524 encrypted->size = data_size;
1525 1525
1526 mhd_gnutls_cipher_deinit (ch); 1526 MHD_gnutls_cipher_deinit (ch);
1527 1527
1528 return 0; 1528 return 0;
1529 1529
1530error: 1530error:
1531 gnutls_free (data); 1531 MHD_gnutls_free (data);
1532 if (ch != NULL) 1532 if (ch != NULL)
1533 mhd_gnutls_cipher_deinit (ch); 1533 MHD_gnutls_cipher_deinit (ch);
1534 return result; 1534 return result;
1535} 1535}
1536 1536
@@ -1538,12 +1538,12 @@ error:
1538 * and stored in dec. 1538 * and stored in dec.
1539 */ 1539 */
1540int 1540int
1541_gnutls_pkcs7_decrypt_data (const gnutls_datum_t * data, 1541MHD__gnutls_pkcs7_decrypt_data (const MHD_gnutls_datum_t * data,
1542 const char *password, gnutls_datum_t * dec) 1542 const char *password, MHD_gnutls_datum_t * dec)
1543{ 1543{
1544 int result, len; 1544 int result, len;
1545 char enc_oid[64]; 1545 char enc_oid[64];
1546 gnutls_datum_t tmp; 1546 MHD_gnutls_datum_t tmp;
1547 ASN1_TYPE pbes2_asn = ASN1_TYPE_EMPTY, pkcs7_asn = ASN1_TYPE_EMPTY; 1547 ASN1_TYPE pbes2_asn = ASN1_TYPE_EMPTY, pkcs7_asn = ASN1_TYPE_EMPTY;
1548 int params_start, params_end, params_len; 1548 int params_start, params_end, params_len;
1549 struct pbkdf2_params kdf_params; 1549 struct pbkdf2_params kdf_params;
@@ -1551,20 +1551,20 @@ _gnutls_pkcs7_decrypt_data (const gnutls_datum_t * data,
1551 schema_id schema; 1551 schema_id schema;
1552 1552
1553 if ((result = 1553 if ((result =
1554 asn1_create_element (_gnutls_get_pkix (), 1554 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1555 "PKIX1.pkcs-7-EncryptedData", 1555 "PKIX1.pkcs-7-EncryptedData",
1556 &pkcs7_asn)) != ASN1_SUCCESS) 1556 &pkcs7_asn)) != ASN1_SUCCESS)
1557 { 1557 {
1558 gnutls_assert (); 1558 MHD_gnutls_assert ();
1559 result = mhd_gtls_asn2err (result); 1559 result = MHD_gtls_asn2err (result);
1560 goto error; 1560 goto error;
1561 } 1561 }
1562 1562
1563 result = asn1_der_decoding (&pkcs7_asn, data->data, data->size, NULL); 1563 result = MHD__asn1_der_decoding (&pkcs7_asn, data->data, data->size, NULL);
1564 if (result != ASN1_SUCCESS) 1564 if (result != ASN1_SUCCESS)
1565 { 1565 {
1566 gnutls_assert (); 1566 MHD_gnutls_assert ();
1567 result = mhd_gtls_asn2err (result); 1567 result = MHD_gtls_asn2err (result);
1568 goto error; 1568 goto error;
1569 } 1569 }
1570 1570
@@ -1572,19 +1572,19 @@ _gnutls_pkcs7_decrypt_data (const gnutls_datum_t * data,
1572 */ 1572 */
1573 len = sizeof (enc_oid); 1573 len = sizeof (enc_oid);
1574 result = 1574 result =
1575 asn1_read_value (pkcs7_asn, 1575 MHD__asn1_read_value (pkcs7_asn,
1576 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm", 1576 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm",
1577 enc_oid, &len); 1577 enc_oid, &len);
1578 if (result != ASN1_SUCCESS) 1578 if (result != ASN1_SUCCESS)
1579 { 1579 {
1580 gnutls_assert (); 1580 MHD_gnutls_assert ();
1581 result = mhd_gtls_asn2err (result); 1581 result = MHD_gtls_asn2err (result);
1582 goto error; 1582 goto error;
1583 } 1583 }
1584 1584
1585 if ((result = check_schema (enc_oid)) < 0) 1585 if ((result = check_schema (enc_oid)) < 0)
1586 { 1586 {
1587 gnutls_assert (); 1587 MHD_gnutls_assert ();
1588 goto error; 1588 goto error;
1589 } 1589 }
1590 schema = result; 1590 schema = result;
@@ -1592,13 +1592,13 @@ _gnutls_pkcs7_decrypt_data (const gnutls_datum_t * data,
1592 /* Get the DER encoding of the parameters. 1592 /* Get the DER encoding of the parameters.
1593 */ 1593 */
1594 result = 1594 result =
1595 asn1_der_decoding_startEnd (pkcs7_asn, data->data, data->size, 1595 MHD__asn1_der_decoding_startEnd (pkcs7_asn, data->data, data->size,
1596 "encryptedContentInfo.contentEncryptionAlgorithm.parameters", 1596 "encryptedContentInfo.contentEncryptionAlgorithm.parameters",
1597 &params_start, &params_end); 1597 &params_start, &params_end);
1598 if (result != ASN1_SUCCESS) 1598 if (result != ASN1_SUCCESS)
1599 { 1599 {
1600 gnutls_assert (); 1600 MHD_gnutls_assert ();
1601 result = mhd_gtls_asn2err (result); 1601 result = MHD_gtls_asn2err (result);
1602 goto error; 1602 goto error;
1603 } 1603 }
1604 params_len = params_end - params_start + 1; 1604 params_len = params_end - params_start + 1;
@@ -1609,8 +1609,8 @@ _gnutls_pkcs7_decrypt_data (const gnutls_datum_t * data,
1609 params_len, &kdf_params, &enc_params); 1609 params_len, &kdf_params, &enc_params);
1610 if (result < ASN1_SUCCESS) 1610 if (result < ASN1_SUCCESS)
1611 { 1611 {
1612 gnutls_assert (); 1612 MHD_gnutls_assert ();
1613 result = mhd_gtls_asn2err (result); 1613 result = MHD_gtls_asn2err (result);
1614 goto error; 1614 goto error;
1615 } 1615 }
1616 1616
@@ -1624,19 +1624,19 @@ _gnutls_pkcs7_decrypt_data (const gnutls_datum_t * data,
1624 &kdf_params, &enc_params, &tmp); 1624 &kdf_params, &enc_params, &tmp);
1625 if (result < 0) 1625 if (result < 0)
1626 { 1626 {
1627 gnutls_assert (); 1627 MHD_gnutls_assert ();
1628 goto error; 1628 goto error;
1629 } 1629 }
1630 1630
1631 asn1_delete_structure (&pkcs7_asn); 1631 MHD__asn1_delete_structure (&pkcs7_asn);
1632 1632
1633 *dec = tmp; 1633 *dec = tmp;
1634 1634
1635 return 0; 1635 return 0;
1636 1636
1637error: 1637error:
1638 asn1_delete_structure (&pbes2_asn); 1638 MHD__asn1_delete_structure (&pbes2_asn);
1639 asn1_delete_structure (&pkcs7_asn); 1639 MHD__asn1_delete_structure (&pkcs7_asn);
1640 return result; 1640 return result;
1641} 1641}
1642 1642
@@ -1644,24 +1644,24 @@ error:
1644 * and stored in enc. 1644 * and stored in enc.
1645 */ 1645 */
1646int 1646int
1647_gnutls_pkcs7_encrypt_data (schema_id schema, 1647MHD__gnutls_pkcs7_encrypt_data (schema_id schema,
1648 const gnutls_datum_t * data, 1648 const MHD_gnutls_datum_t * data,
1649 const char *password, gnutls_datum_t * enc) 1649 const char *password, MHD_gnutls_datum_t * enc)
1650{ 1650{
1651 int result; 1651 int result;
1652 gnutls_datum_t key = { NULL, 0 }; 1652 MHD_gnutls_datum_t key = { NULL, 0 };
1653 gnutls_datum_t tmp = { NULL, 0 }; 1653 MHD_gnutls_datum_t tmp = { NULL, 0 };
1654 ASN1_TYPE pkcs7_asn = ASN1_TYPE_EMPTY; 1654 ASN1_TYPE pkcs7_asn = ASN1_TYPE_EMPTY;
1655 struct pbkdf2_params kdf_params; 1655 struct pbkdf2_params kdf_params;
1656 struct pbe_enc_params enc_params; 1656 struct pbe_enc_params enc_params;
1657 1657
1658 if ((result = 1658 if ((result =
1659 asn1_create_element (_gnutls_get_pkix (), 1659 MHD__asn1_create_element (MHD__gnutls_get_pkix (),
1660 "PKIX1.pkcs-7-EncryptedData", 1660 "PKIX1.pkcs-7-EncryptedData",
1661 &pkcs7_asn)) != ASN1_SUCCESS) 1661 &pkcs7_asn)) != ASN1_SUCCESS)
1662 { 1662 {
1663 gnutls_assert (); 1663 MHD_gnutls_assert ();
1664 result = mhd_gtls_asn2err (result); 1664 result = MHD_gtls_asn2err (result);
1665 goto error; 1665 goto error;
1666 } 1666 }
1667 1667
@@ -1671,25 +1671,25 @@ _gnutls_pkcs7_encrypt_data (schema_id schema,
1671 { 1671 {
1672 case PBES2: 1672 case PBES2:
1673 result = 1673 result =
1674 asn1_write_value (pkcs7_asn, 1674 MHD__asn1_write_value (pkcs7_asn,
1675 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm", 1675 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm",
1676 PBES2_OID, 1); 1676 PBES2_OID, 1);
1677 break; 1677 break;
1678 case PKCS12_3DES_SHA1: 1678 case PKCS12_3DES_SHA1:
1679 result = 1679 result =
1680 asn1_write_value (pkcs7_asn, 1680 MHD__asn1_write_value (pkcs7_asn,
1681 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm", 1681 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm",
1682 PKCS12_PBE_3DES_SHA1_OID, 1); 1682 PKCS12_PBE_3DES_SHA1_OID, 1);
1683 break; 1683 break;
1684 case PKCS12_ARCFOUR_SHA1: 1684 case PKCS12_ARCFOUR_SHA1:
1685 result = 1685 result =
1686 asn1_write_value (pkcs7_asn, 1686 MHD__asn1_write_value (pkcs7_asn,
1687 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm", 1687 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm",
1688 PKCS12_PBE_ARCFOUR_SHA1_OID, 1); 1688 PKCS12_PBE_ARCFOUR_SHA1_OID, 1);
1689 break; 1689 break;
1690 case PKCS12_RC2_40_SHA1: 1690 case PKCS12_RC2_40_SHA1:
1691 result = 1691 result =
1692 asn1_write_value (pkcs7_asn, 1692 MHD__asn1_write_value (pkcs7_asn,
1693 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm", 1693 "encryptedContentInfo.contentEncryptionAlgorithm.algorithm",
1694 PKCS12_PBE_RC2_40_SHA1_OID, 1); 1694 PKCS12_PBE_RC2_40_SHA1_OID, 1);
1695 break; 1695 break;
@@ -1698,8 +1698,8 @@ _gnutls_pkcs7_encrypt_data (schema_id schema,
1698 1698
1699 if (result != ASN1_SUCCESS) 1699 if (result != ASN1_SUCCESS)
1700 { 1700 {
1701 gnutls_assert (); 1701 MHD_gnutls_assert ();
1702 result = mhd_gtls_asn2err (result); 1702 result = MHD_gtls_asn2err (result);
1703 goto error; 1703 goto error;
1704 } 1704 }
1705 1705
@@ -1709,7 +1709,7 @@ _gnutls_pkcs7_encrypt_data (schema_id schema,
1709 result = generate_key (schema, password, &kdf_params, &enc_params, &key); 1709 result = generate_key (schema, password, &kdf_params, &enc_params, &key);
1710 if (result < 0) 1710 if (result < 0)
1711 { 1711 {
1712 gnutls_assert (); 1712 MHD_gnutls_assert ();
1713 goto error; 1713 goto error;
1714 } 1714 }
1715 1715
@@ -1718,7 +1718,7 @@ _gnutls_pkcs7_encrypt_data (schema_id schema,
1718 &kdf_params, &enc_params); 1718 &kdf_params, &enc_params);
1719 if (result < 0) 1719 if (result < 0)
1720 { 1720 {
1721 gnutls_assert (); 1721 MHD_gnutls_assert ();
1722 goto error; 1722 goto error;
1723 } 1723 }
1724 1724
@@ -1728,70 +1728,70 @@ _gnutls_pkcs7_encrypt_data (schema_id schema,
1728 result = encrypt_data (data, &enc_params, &key, &tmp); 1728 result = encrypt_data (data, &enc_params, &key, &tmp);
1729 if (result < 0) 1729 if (result < 0)
1730 { 1730 {
1731 gnutls_assert (); 1731 MHD_gnutls_assert ();
1732 goto error; 1732 goto error;
1733 } 1733 }
1734 1734
1735 /* write the encrypted data. 1735 /* write the encrypted data.
1736 */ 1736 */
1737 result = 1737 result =
1738 asn1_write_value (pkcs7_asn, 1738 MHD__asn1_write_value (pkcs7_asn,
1739 "encryptedContentInfo.encryptedContent", tmp.data, 1739 "encryptedContentInfo.encryptedContent", tmp.data,
1740 tmp.size); 1740 tmp.size);
1741 if (result != ASN1_SUCCESS) 1741 if (result != ASN1_SUCCESS)
1742 { 1742 {
1743 gnutls_assert (); 1743 MHD_gnutls_assert ();
1744 result = mhd_gtls_asn2err (result); 1744 result = MHD_gtls_asn2err (result);
1745 goto error; 1745 goto error;
1746 } 1746 }
1747 1747
1748 _gnutls_free_datum (&tmp); 1748 MHD__gnutls_free_datum (&tmp);
1749 _gnutls_free_datum (&key); 1749 MHD__gnutls_free_datum (&key);
1750 1750
1751 /* Now write the rest of the pkcs-7 stuff. 1751 /* Now write the rest of the pkcs-7 stuff.
1752 */ 1752 */
1753 1753
1754 result = _gnutls_x509_write_uint32 (pkcs7_asn, "version", 0); 1754 result = MHD__gnutls_x509_write_uint32 (pkcs7_asn, "version", 0);
1755 if (result < 0) 1755 if (result < 0)
1756 { 1756 {
1757 gnutls_assert (); 1757 MHD_gnutls_assert ();
1758 goto error; 1758 goto error;
1759 } 1759 }
1760 1760
1761 result = 1761 result =
1762 asn1_write_value (pkcs7_asn, "encryptedContentInfo.contentType", 1762 MHD__asn1_write_value (pkcs7_asn, "encryptedContentInfo.contentType",
1763 DATA_OID, 1); 1763 DATA_OID, 1);
1764 if (result != ASN1_SUCCESS) 1764 if (result != ASN1_SUCCESS)
1765 { 1765 {
1766 gnutls_assert (); 1766 MHD_gnutls_assert ();
1767 result = mhd_gtls_asn2err (result); 1767 result = MHD_gtls_asn2err (result);
1768 goto error; 1768 goto error;
1769 } 1769 }
1770 1770
1771 result = asn1_write_value (pkcs7_asn, "unprotectedAttrs", NULL, 0); 1771 result = MHD__asn1_write_value (pkcs7_asn, "unprotectedAttrs", NULL, 0);
1772 if (result != ASN1_SUCCESS) 1772 if (result != ASN1_SUCCESS)
1773 { 1773 {
1774 gnutls_assert (); 1774 MHD_gnutls_assert ();
1775 result = mhd_gtls_asn2err (result); 1775 result = MHD_gtls_asn2err (result);
1776 goto error; 1776 goto error;
1777 } 1777 }
1778 1778
1779 /* Now encode and copy the DER stuff. 1779 /* Now encode and copy the DER stuff.
1780 */ 1780 */
1781 result = _gnutls_x509_der_encode (pkcs7_asn, "", enc, 0); 1781 result = MHD__gnutls_x509_der_encode (pkcs7_asn, "", enc, 0);
1782 1782
1783 asn1_delete_structure (&pkcs7_asn); 1783 MHD__asn1_delete_structure (&pkcs7_asn);
1784 1784
1785 if (result < 0) 1785 if (result < 0)
1786 { 1786 {
1787 gnutls_assert (); 1787 MHD_gnutls_assert ();
1788 goto error; 1788 goto error;
1789 } 1789 }
1790 1790
1791error: 1791error:
1792 _gnutls_free_datum (&key); 1792 MHD__gnutls_free_datum (&key);
1793 _gnutls_free_datum (&tmp); 1793 MHD__gnutls_free_datum (&tmp);
1794 asn1_delete_structure (&pkcs7_asn); 1794 MHD__asn1_delete_structure (&pkcs7_asn);
1795 return result; 1795 return result;
1796} 1796}
1797 1797
diff --git a/src/daemon/https/x509/rfc2818.h b/src/daemon/https/x509/rfc2818.h
index c3399145..c38bd8a9 100644
--- a/src/daemon/https/x509/rfc2818.h
+++ b/src/daemon/https/x509/rfc2818.h
@@ -22,5 +22,5 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_hostname_compare (const char *certname, const char *hostname); 25int MHD__gnutls_hostname_compare (const char *certname, const char *hostname);
26#define MAX_CN 256 26#define MAX_CN 256
diff --git a/src/daemon/https/x509/rfc2818_hostname.c b/src/daemon/https/x509/rfc2818_hostname.c
index 93a96589..fe03af33 100644
--- a/src/daemon/https/x509/rfc2818_hostname.c
+++ b/src/daemon/https/x509/rfc2818_hostname.c
@@ -32,7 +32,7 @@
32 * return 1 on success or 0 on error 32 * return 1 on success or 0 on error
33 */ 33 */
34int 34int
35_gnutls_hostname_compare (const char *certname, const char *hostname) 35MHD__gnutls_hostname_compare (const char *certname, const char *hostname)
36{ 36{
37 const char *cmpstr1, *cmpstr2; 37 const char *cmpstr1, *cmpstr2;
38 38
@@ -71,8 +71,8 @@ _gnutls_hostname_compare (const char *certname, const char *hostname)
71} 71}
72 72
73/** 73/**
74 * gnutls_x509_crt_check_hostname - This function compares the given hostname with the hostname in the certificate 74 * MHD_gnutls_x509_crt_check_hostname - This function compares the given hostname with the hostname in the certificate
75 * @cert: should contain an gnutls_x509_crt_t structure 75 * @cert: should contain an MHD_gnutls_x509_crt_t structure
76 * @hostname: A null terminated string that contains a DNS name 76 * @hostname: A null terminated string that contains a DNS name
77 * 77 *
78 * This function will check if the given certificate's subject 78 * This function will check if the given certificate's subject
@@ -84,7 +84,7 @@ _gnutls_hostname_compare (const char *certname, const char *hostname)
84 * Returns non zero for a successful match, and zero on failure. 84 * Returns non zero for a successful match, and zero on failure.
85 **/ 85 **/
86int 86int
87gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert, const char *hostname) 87MHD_gnutls_x509_crt_check_hostname (MHD_gnutls_x509_crt_t cert, const char *hostname)
88{ 88{
89 89
90 char dnsname[MAX_CN]; 90 char dnsname[MAX_CN];
@@ -111,14 +111,14 @@ gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert, const char *hostname)
111 { 111 {
112 112
113 dnsnamesize = sizeof (dnsname); 113 dnsnamesize = sizeof (dnsname);
114 ret = gnutls_x509_crt_get_subject_alt_name (cert, i, 114 ret = MHD_gnutls_x509_crt_get_subject_alt_name (cert, i,
115 dnsname, &dnsnamesize, 115 dnsname, &dnsnamesize,
116 NULL); 116 NULL);
117 117
118 if (ret == GNUTLS_SAN_DNSNAME) 118 if (ret == GNUTLS_SAN_DNSNAME)
119 { 119 {
120 found_dnsname = 1; 120 found_dnsname = 1;
121 if (_gnutls_hostname_compare (dnsname, hostname)) 121 if (MHD__gnutls_hostname_compare (dnsname, hostname))
122 { 122 {
123 return 1; 123 return 1;
124 } 124 }
@@ -128,7 +128,7 @@ gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert, const char *hostname)
128 found_dnsname = 1; /* RFC 2818 is unclear whether the CN 128 found_dnsname = 1; /* RFC 2818 is unclear whether the CN
129 should be compared for IP addresses 129 should be compared for IP addresses
130 too, but we won't do it. */ 130 too, but we won't do it. */
131 if (_gnutls_hostname_compare (dnsname, hostname)) 131 if (MHD__gnutls_hostname_compare (dnsname, hostname))
132 { 132 {
133 return 1; 133 return 1;
134 } 134 }
@@ -140,7 +140,7 @@ gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert, const char *hostname)
140 /* not got the necessary extension, use CN instead 140 /* not got the necessary extension, use CN instead
141 */ 141 */
142 dnsnamesize = sizeof (dnsname); 142 dnsnamesize = sizeof (dnsname);
143 if (gnutls_x509_crt_get_dn_by_oid (cert, OID_X520_COMMON_NAME, 0, 143 if (MHD_gnutls_x509_crt_get_dn_by_oid (cert, OID_X520_COMMON_NAME, 0,
144 0, dnsname, &dnsnamesize) < 0) 144 0, dnsname, &dnsnamesize) < 0)
145 { 145 {
146 /* got an error, can't find a name 146 /* got an error, can't find a name
@@ -148,7 +148,7 @@ gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert, const char *hostname)
148 return 0; 148 return 0;
149 } 149 }
150 150
151 if (_gnutls_hostname_compare (dnsname, hostname)) 151 if (MHD__gnutls_hostname_compare (dnsname, hostname))
152 { 152 {
153 return 1; 153 return 1;
154 } 154 }
diff --git a/src/daemon/https/x509/sign.c b/src/daemon/https/x509/sign.c
index 2d367732..8b89b038 100644
--- a/src/daemon/https/x509/sign.c
+++ b/src/daemon/https/x509/sign.c
@@ -50,34 +50,34 @@
50 */ 50 */
51static int 51static int
52encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, 52encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash,
53 const gnutls_datum_t * digest, gnutls_datum_t * info) 53 const MHD_gnutls_datum_t * digest, MHD_gnutls_datum_t * info)
54{ 54{
55 ASN1_TYPE dinfo = ASN1_TYPE_EMPTY; 55 ASN1_TYPE dinfo = ASN1_TYPE_EMPTY;
56 int result; 56 int result;
57 const char *algo; 57 const char *algo;
58 58
59 algo = mhd_gtls_x509_mac_to_oid ((enum MHD_GNUTLS_HashAlgorithm) hash); 59 algo = MHD_gtls_x509_mac_to_oid ((enum MHD_GNUTLS_HashAlgorithm) hash);
60 if (algo == NULL) 60 if (algo == NULL)
61 { 61 {
62 gnutls_assert (); 62 MHD_gnutls_assert ();
63 _gnutls_x509_log ("Hash algorithm: %d\n", hash); 63 MHD__gnutls_x509_log ("Hash algorithm: %d\n", hash);
64 return GNUTLS_E_UNKNOWN_PK_ALGORITHM; 64 return GNUTLS_E_UNKNOWN_PK_ALGORITHM;
65 } 65 }
66 66
67 if ((result = asn1_create_element (_gnutls_get_gnutls_asn (), 67 if ((result = MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (),
68 "GNUTLS.DigestInfo", 68 "GNUTLS.DigestInfo",
69 &dinfo)) != ASN1_SUCCESS) 69 &dinfo)) != ASN1_SUCCESS)
70 { 70 {
71 gnutls_assert (); 71 MHD_gnutls_assert ();
72 return mhd_gtls_asn2err (result); 72 return MHD_gtls_asn2err (result);
73 } 73 }
74 74
75 result = asn1_write_value (dinfo, "digestAlgorithm.algorithm", algo, 1); 75 result = MHD__asn1_write_value (dinfo, "digestAlgorithm.algorithm", algo, 1);
76 if (result != ASN1_SUCCESS) 76 if (result != ASN1_SUCCESS)
77 { 77 {
78 gnutls_assert (); 78 MHD_gnutls_assert ();
79 asn1_delete_structure (&dinfo); 79 MHD__asn1_delete_structure (&dinfo);
80 return mhd_gtls_asn2err (result); 80 return MHD_gtls_asn2err (result);
81 } 81 }
82 82
83 /* Write an ASN.1 NULL in the parameters field. This matches RFC 83 /* Write an ASN.1 NULL in the parameters field. This matches RFC
@@ -85,43 +85,43 @@ encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash,
85 perspective (see those documents for more information). 85 perspective (see those documents for more information).
86 Regardless of what is correct, this appears to be what most 86 Regardless of what is correct, this appears to be what most
87 implementations do. */ 87 implementations do. */
88 result = asn1_write_value (dinfo, "digestAlgorithm.parameters", 88 result = MHD__asn1_write_value (dinfo, "digestAlgorithm.parameters",
89 "\x05\x00", 2); 89 "\x05\x00", 2);
90 if (result != ASN1_SUCCESS) 90 if (result != ASN1_SUCCESS)
91 { 91 {
92 gnutls_assert (); 92 MHD_gnutls_assert ();
93 asn1_delete_structure (&dinfo); 93 MHD__asn1_delete_structure (&dinfo);
94 return mhd_gtls_asn2err (result); 94 return MHD_gtls_asn2err (result);
95 } 95 }
96 96
97 result = asn1_write_value (dinfo, "digest", digest->data, digest->size); 97 result = MHD__asn1_write_value (dinfo, "digest", digest->data, digest->size);
98 if (result != ASN1_SUCCESS) 98 if (result != ASN1_SUCCESS)
99 { 99 {
100 gnutls_assert (); 100 MHD_gnutls_assert ();
101 asn1_delete_structure (&dinfo); 101 MHD__asn1_delete_structure (&dinfo);
102 return mhd_gtls_asn2err (result); 102 return MHD_gtls_asn2err (result);
103 } 103 }
104 104
105 info->size = 0; 105 info->size = 0;
106 asn1_der_coding (dinfo, "", NULL, &info->size, NULL); 106 MHD__asn1_der_coding (dinfo, "", NULL, &info->size, NULL);
107 107
108 info->data = gnutls_malloc (info->size); 108 info->data = MHD_gnutls_malloc (info->size);
109 if (info->data == NULL) 109 if (info->data == NULL)
110 { 110 {
111 gnutls_assert (); 111 MHD_gnutls_assert ();
112 asn1_delete_structure (&dinfo); 112 MHD__asn1_delete_structure (&dinfo);
113 return GNUTLS_E_MEMORY_ERROR; 113 return GNUTLS_E_MEMORY_ERROR;
114 } 114 }
115 115
116 result = asn1_der_coding (dinfo, "", info->data, &info->size, NULL); 116 result = MHD__asn1_der_coding (dinfo, "", info->data, &info->size, NULL);
117 if (result != ASN1_SUCCESS) 117 if (result != ASN1_SUCCESS)
118 { 118 {
119 gnutls_assert (); 119 MHD_gnutls_assert ();
120 asn1_delete_structure (&dinfo); 120 MHD__asn1_delete_structure (&dinfo);
121 return mhd_gtls_asn2err (result); 121 return MHD_gtls_asn2err (result);
122 } 122 }
123 123
124 asn1_delete_structure (&dinfo); 124 MHD__asn1_delete_structure (&dinfo);
125 125
126 return 0; 126 return 0;
127} 127}
@@ -133,45 +133,45 @@ encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash,
133 */ 133 */
134static int 134static int
135pkcs1_rsa_sign (enum MHD_GNUTLS_HashAlgorithm hash, 135pkcs1_rsa_sign (enum MHD_GNUTLS_HashAlgorithm hash,
136 const gnutls_datum_t * text, mpi_t * params, int params_len, 136 const MHD_gnutls_datum_t * text, mpi_t * params, int params_len,
137 gnutls_datum_t * signature) 137 MHD_gnutls_datum_t * signature)
138{ 138{
139 int ret; 139 int ret;
140 opaque _digest[MAX_HASH_SIZE]; 140 opaque _digest[MAX_HASH_SIZE];
141 GNUTLS_HASH_HANDLE hd; 141 GNUTLS_HASH_HANDLE hd;
142 gnutls_datum_t digest, info; 142 MHD_gnutls_datum_t digest, info;
143 143
144 hd = mhd_gtls_hash_init (HASH2MAC (hash)); 144 hd = MHD_gtls_hash_init (HASH2MAC (hash));
145 if (hd == NULL) 145 if (hd == NULL)
146 { 146 {
147 gnutls_assert (); 147 MHD_gnutls_assert ();
148 return GNUTLS_E_HASH_FAILED; 148 return GNUTLS_E_HASH_FAILED;
149 } 149 }
150 150
151 mhd_gnutls_hash (hd, text->data, text->size); 151 MHD_gnutls_hash (hd, text->data, text->size);
152 mhd_gnutls_hash_deinit (hd, _digest); 152 MHD_gnutls_hash_deinit (hd, _digest);
153 153
154 digest.data = _digest; 154 digest.data = _digest;
155 digest.size = mhd_gnutls_hash_get_algo_len (HASH2MAC (hash)); 155 digest.size = MHD_gnutls_hash_get_algo_len (HASH2MAC (hash));
156 156
157 /* Encode the digest as a DigestInfo 157 /* Encode the digest as a DigestInfo
158 */ 158 */
159 if ((ret = encode_ber_digest_info (hash, &digest, &info)) != 0) 159 if ((ret = encode_ber_digest_info (hash, &digest, &info)) != 0)
160 { 160 {
161 gnutls_assert (); 161 MHD_gnutls_assert ();
162 return ret; 162 return ret;
163 } 163 }
164 164
165 if ((ret = 165 if ((ret =
166 mhd_gtls_sign (MHD_GNUTLS_PK_RSA, params, params_len, &info, 166 MHD_gtls_sign (MHD_GNUTLS_PK_RSA, params, params_len, &info,
167 signature)) < 0) 167 signature)) < 0)
168 { 168 {
169 gnutls_assert (); 169 MHD_gnutls_assert ();
170 _gnutls_free_datum (&info); 170 MHD__gnutls_free_datum (&info);
171 return ret; 171 return ret;
172 } 172 }
173 173
174 _gnutls_free_datum (&info); 174 MHD__gnutls_free_datum (&info);
175 175
176 return 0; 176 return 0;
177} 177}
@@ -186,9 +186,9 @@ pkcs1_rsa_sign (enum MHD_GNUTLS_HashAlgorithm hash,
186 * 'hash' is only used in PKCS1 RSA signing. 186 * 'hash' is only used in PKCS1 RSA signing.
187 */ 187 */
188int 188int
189_gnutls_x509_sign (const gnutls_datum_t * tbs, 189MHD__gnutls_x509_sign (const MHD_gnutls_datum_t * tbs,
190 enum MHD_GNUTLS_HashAlgorithm hash, 190 enum MHD_GNUTLS_HashAlgorithm hash,
191 gnutls_x509_privkey_t signer, gnutls_datum_t * signature) 191 MHD_gnutls_x509_privkey_t signer, MHD_gnutls_datum_t * signature)
192{ 192{
193 int ret; 193 int ret;
194 194
@@ -200,63 +200,63 @@ _gnutls_x509_sign (const gnutls_datum_t * tbs,
200 signature); 200 signature);
201 if (ret < 0) 201 if (ret < 0)
202 { 202 {
203 gnutls_assert (); 203 MHD_gnutls_assert ();
204 return ret; 204 return ret;
205 } 205 }
206 return 0; 206 return 0;
207 break; 207 break;
208 default: 208 default:
209 gnutls_assert (); 209 MHD_gnutls_assert ();
210 return GNUTLS_E_INTERNAL_ERROR; 210 return GNUTLS_E_INTERNAL_ERROR;
211 } 211 }
212 212
213} 213}
214 214
215/* This is the same as the _gnutls_x509_sign, but this one will decode 215/* This is the same as the MHD__gnutls_x509_sign, but this one will decode
216 * the ASN1_TYPE given, and sign the DER data. Actually used to get the DER 216 * the ASN1_TYPE given, and sign the DER data. Actually used to get the DER
217 * of the TBS and sign it on the fly. 217 * of the TBS and sign it on the fly.
218 */ 218 */
219int 219int
220_gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name, 220MHD__gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name,
221 enum MHD_GNUTLS_HashAlgorithm hash, 221 enum MHD_GNUTLS_HashAlgorithm hash,
222 gnutls_x509_privkey_t signer, 222 MHD_gnutls_x509_privkey_t signer,
223 gnutls_datum_t * signature) 223 MHD_gnutls_datum_t * signature)
224{ 224{
225 int result; 225 int result;
226 opaque *buf; 226 opaque *buf;
227 int buf_size; 227 int buf_size;
228 gnutls_datum_t tbs; 228 MHD_gnutls_datum_t tbs;
229 229
230 buf_size = 0; 230 buf_size = 0;
231 asn1_der_coding (cert, tbs_name, NULL, &buf_size, NULL); 231 MHD__asn1_der_coding (cert, tbs_name, NULL, &buf_size, NULL);
232 232
233 buf = gnutls_alloca (buf_size); 233 buf = MHD_gnutls_alloca (buf_size);
234 if (buf == NULL) 234 if (buf == NULL)
235 { 235 {
236 gnutls_assert (); 236 MHD_gnutls_assert ();
237 return GNUTLS_E_MEMORY_ERROR; 237 return GNUTLS_E_MEMORY_ERROR;
238 } 238 }
239 239
240 result = asn1_der_coding (cert, tbs_name, buf, &buf_size, NULL); 240 result = MHD__asn1_der_coding (cert, tbs_name, buf, &buf_size, NULL);
241 241
242 if (result != ASN1_SUCCESS) 242 if (result != ASN1_SUCCESS)
243 { 243 {
244 gnutls_assert (); 244 MHD_gnutls_assert ();
245 gnutls_afree (buf); 245 MHD_gnutls_afree (buf);
246 return mhd_gtls_asn2err (result); 246 return MHD_gtls_asn2err (result);
247 } 247 }
248 248
249 tbs.data = buf; 249 tbs.data = buf;
250 tbs.size = buf_size; 250 tbs.size = buf_size;
251 251
252 result = _gnutls_x509_sign (&tbs, hash, signer, signature); 252 result = MHD__gnutls_x509_sign (&tbs, hash, signer, signature);
253 gnutls_afree (buf); 253 MHD_gnutls_afree (buf);
254 254
255 return result; 255 return result;
256} 256}
257 257
258/*- 258/*-
259 * _gnutls_x509_pkix_sign - This function will sign a CRL or a certificate with a key 259 * MHD__gnutls_x509_pkix_sign - This function will sign a CRL or a certificate with a key
260 * @src: should contain an ASN1_TYPE 260 * @src: should contain an ASN1_TYPE
261 * @issuer: is the certificate of the certificate issuer 261 * @issuer: is the certificate of the certificate issuer
262 * @issuer_key: holds the issuer's private key 262 * @issuer_key: holds the issuer's private key
@@ -268,76 +268,76 @@ _gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name,
268 * 268 *
269 -*/ 269 -*/
270int 270int
271_gnutls_x509_pkix_sign (ASN1_TYPE src, const char *src_name, 271MHD__gnutls_x509_pkix_sign (ASN1_TYPE src, const char *src_name,
272 enum MHD_GNUTLS_HashAlgorithm dig, 272 enum MHD_GNUTLS_HashAlgorithm dig,
273 gnutls_x509_crt_t issuer, 273 MHD_gnutls_x509_crt_t issuer,
274 gnutls_x509_privkey_t issuer_key) 274 MHD_gnutls_x509_privkey_t issuer_key)
275{ 275{
276 int result; 276 int result;
277 gnutls_datum_t signature; 277 MHD_gnutls_datum_t signature;
278 char name[128]; 278 char name[128];
279 279
280 /* Step 1. Copy the issuer's name into the certificate. 280 /* Step 1. Copy the issuer's name into the certificate.
281 */ 281 */
282 mhd_gtls_str_cpy (name, sizeof (name), src_name); 282 MHD_gtls_str_cpy (name, sizeof (name), src_name);
283 mhd_gtls_str_cat (name, sizeof (name), ".issuer"); 283 MHD_gtls_str_cat (name, sizeof (name), ".issuer");
284 284
285 result = asn1_copy_node (src, name, issuer->cert, "tbsCertificate.subject"); 285 result = MHD__asn1_copy_node (src, name, issuer->cert, "tbsCertificate.subject");
286 if (result != ASN1_SUCCESS) 286 if (result != ASN1_SUCCESS)
287 { 287 {
288 gnutls_assert (); 288 MHD_gnutls_assert ();
289 return mhd_gtls_asn2err (result); 289 return MHD_gtls_asn2err (result);
290 } 290 }
291 291
292 /* Step 1.5. Write the signature stuff in the tbsCertificate. 292 /* Step 1.5. Write the signature stuff in the tbsCertificate.
293 */ 293 */
294 mhd_gtls_str_cpy (name, sizeof (name), src_name); 294 MHD_gtls_str_cpy (name, sizeof (name), src_name);
295 mhd_gtls_str_cat (name, sizeof (name), ".signature"); 295 MHD_gtls_str_cat (name, sizeof (name), ".signature");
296 296
297 result = _gnutls_x509_write_sig_params (src, name, 297 result = MHD__gnutls_x509_write_sig_params (src, name,
298 issuer_key->pk_algorithm, dig, 298 issuer_key->pk_algorithm, dig,
299 issuer_key->params, 299 issuer_key->params,
300 issuer_key->params_size); 300 issuer_key->params_size);
301 if (result < 0) 301 if (result < 0)
302 { 302 {
303 gnutls_assert (); 303 MHD_gnutls_assert ();
304 return result; 304 return result;
305 } 305 }
306 306
307 /* Step 2. Sign the certificate. 307 /* Step 2. Sign the certificate.
308 */ 308 */
309 result = _gnutls_x509_sign_tbs (src, src_name, dig, issuer_key, &signature); 309 result = MHD__gnutls_x509_sign_tbs (src, src_name, dig, issuer_key, &signature);
310 310
311 if (result < 0) 311 if (result < 0)
312 { 312 {
313 gnutls_assert (); 313 MHD_gnutls_assert ();
314 return result; 314 return result;
315 } 315 }
316 316
317 /* write the signature (bits) 317 /* write the signature (bits)
318 */ 318 */
319 result = 319 result =
320 asn1_write_value (src, "signature", signature.data, signature.size * 8); 320 MHD__asn1_write_value (src, "signature", signature.data, signature.size * 8);
321 321
322 _gnutls_free_datum (&signature); 322 MHD__gnutls_free_datum (&signature);
323 323
324 if (result != ASN1_SUCCESS) 324 if (result != ASN1_SUCCESS)
325 { 325 {
326 gnutls_assert (); 326 MHD_gnutls_assert ();
327 return mhd_gtls_asn2err (result); 327 return MHD_gtls_asn2err (result);
328 } 328 }
329 329
330 /* Step 3. Move up and write the AlgorithmIdentifier, which is also 330 /* Step 3. Move up and write the AlgorithmIdentifier, which is also
331 * the same. 331 * the same.
332 */ 332 */
333 333
334 result = _gnutls_x509_write_sig_params (src, "signatureAlgorithm", 334 result = MHD__gnutls_x509_write_sig_params (src, "signatureAlgorithm",
335 issuer_key->pk_algorithm, dig, 335 issuer_key->pk_algorithm, dig,
336 issuer_key->params, 336 issuer_key->params,
337 issuer_key->params_size); 337 issuer_key->params_size);
338 if (result < 0) 338 if (result < 0)
339 { 339 {
340 gnutls_assert (); 340 MHD_gnutls_assert ();
341 return result; 341 return result;
342 } 342 }
343 343
diff --git a/src/daemon/https/x509/sign.h b/src/daemon/https/x509/sign.h
index 86d9859c..b2f7d939 100644
--- a/src/daemon/https/x509/sign.h
+++ b/src/daemon/https/x509/sign.h
@@ -22,15 +22,15 @@
22 * 22 *
23 */ 23 */
24 24
25int _gnutls_x509_sign (const gnutls_datum_t * tbs, 25int MHD__gnutls_x509_sign (const MHD_gnutls_datum_t * tbs,
26 enum MHD_GNUTLS_HashAlgorithm hash, 26 enum MHD_GNUTLS_HashAlgorithm hash,
27 gnutls_x509_privkey_t signer, 27 MHD_gnutls_x509_privkey_t signer,
28 gnutls_datum_t * signature); 28 MHD_gnutls_datum_t * signature);
29int _gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name, 29int MHD__gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name,
30 enum MHD_GNUTLS_HashAlgorithm hash, 30 enum MHD_GNUTLS_HashAlgorithm hash,
31 gnutls_x509_privkey_t signer, 31 MHD_gnutls_x509_privkey_t signer,
32 gnutls_datum_t * signature); 32 MHD_gnutls_datum_t * signature);
33int _gnutls_x509_pkix_sign (ASN1_TYPE src, const char *src_name, 33int MHD__gnutls_x509_pkix_sign (ASN1_TYPE src, const char *src_name,
34 enum MHD_GNUTLS_HashAlgorithm, 34 enum MHD_GNUTLS_HashAlgorithm,
35 gnutls_x509_crt_t issuer, 35 MHD_gnutls_x509_crt_t issuer,
36 gnutls_x509_privkey_t issuer_key); 36 MHD_gnutls_x509_privkey_t issuer_key);
diff --git a/src/daemon/https/x509/verify.h b/src/daemon/https/x509/verify.h
index c7e3c63d..0a2e020c 100644
--- a/src/daemon/https/x509/verify.h
+++ b/src/daemon/https/x509/verify.h
@@ -24,11 +24,11 @@
24 24
25#include "x509.h" 25#include "x509.h"
26 26
27int gnutls_x509_crt_is_issuer (gnutls_x509_crt_t cert, 27int MHD_gnutls_x509_crt_is_issuer (MHD_gnutls_x509_crt_t cert,
28 gnutls_x509_crt_t issuer); 28 MHD_gnutls_x509_crt_t issuer);
29int _gnutls_x509_verify_signature (const gnutls_datum_t * tbs, 29int MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * tbs,
30 const gnutls_datum_t * signature, 30 const MHD_gnutls_datum_t * signature,
31 gnutls_x509_crt_t issuer); 31 MHD_gnutls_x509_crt_t issuer);
32int _gnutls_x509_privkey_verify_signature (const gnutls_datum_t * tbs, 32int MHD__gnutls_x509_privkey_verify_signature (const MHD_gnutls_datum_t * tbs,
33 const gnutls_datum_t * signature, 33 const MHD_gnutls_datum_t * signature,
34 gnutls_x509_privkey_t issuer); 34 MHD_gnutls_x509_privkey_t issuer);
diff --git a/src/daemon/https/x509/x509.c b/src/daemon/https/x509/x509.c
index 9db24be9..599902ca 100644
--- a/src/daemon/https/x509/x509.c
+++ b/src/daemon/https/x509/x509.c
@@ -40,7 +40,7 @@
40#include <verify.h> 40#include <verify.h>
41 41
42/** 42/**
43 * gnutls_x509_crt_init - This function initializes a gnutls_x509_crt_t structure 43 * MHD_gnutls_x509_crt_init - This function initializes a MHD_gnutls_x509_crt_t structure
44 * @cert: The structure to be initialized 44 * @cert: The structure to be initialized
45 * 45 *
46 * This function will initialize an X.509 certificate structure. 46 * This function will initialize an X.509 certificate structure.
@@ -49,21 +49,21 @@
49 * 49 *
50 **/ 50 **/
51int 51int
52gnutls_x509_crt_init (gnutls_x509_crt_t * cert) 52MHD_gnutls_x509_crt_init (MHD_gnutls_x509_crt_t * cert)
53{ 53{
54 gnutls_x509_crt_t tmp = gnutls_calloc (1, sizeof (gnutls_x509_crt_int)); 54 MHD_gnutls_x509_crt_t tmp = MHD_gnutls_calloc (1, sizeof (MHD_gnutls_x509_crt_int));
55 int result; 55 int result;
56 56
57 if (!tmp) 57 if (!tmp)
58 return GNUTLS_E_MEMORY_ERROR; 58 return GNUTLS_E_MEMORY_ERROR;
59 59
60 result = asn1_create_element (_gnutls_get_pkix (), 60 result = MHD__asn1_create_element (MHD__gnutls_get_pkix (),
61 "PKIX1.Certificate", &tmp->cert); 61 "PKIX1.Certificate", &tmp->cert);
62 if (result != ASN1_SUCCESS) 62 if (result != ASN1_SUCCESS)
63 { 63 {
64 gnutls_assert (); 64 MHD_gnutls_assert ();
65 gnutls_free (tmp); 65 MHD_gnutls_free (tmp);
66 return mhd_gtls_asn2err (result); 66 return MHD_gtls_asn2err (result);
67 } 67 }
68 68
69 *cert = tmp; 69 *cert = tmp;
@@ -72,7 +72,7 @@ gnutls_x509_crt_init (gnutls_x509_crt_t * cert)
72} 72}
73 73
74/*- 74/*-
75 * _gnutls_x509_crt_cpy - This function copies a gnutls_x509_crt_t structure 75 * MHD__gnutls_x509_crt_cpy - This function copies a MHD_gnutls_x509_crt_t structure
76 * @dest: The structure where to copy 76 * @dest: The structure where to copy
77 * @src: The structure to be copied 77 * @src: The structure to be copied
78 * 78 *
@@ -82,44 +82,44 @@ gnutls_x509_crt_init (gnutls_x509_crt_t * cert)
82 * 82 *
83 -*/ 83 -*/
84int 84int
85_gnutls_x509_crt_cpy (gnutls_x509_crt_t dest, gnutls_x509_crt_t src) 85MHD__gnutls_x509_crt_cpy (MHD_gnutls_x509_crt_t dest, MHD_gnutls_x509_crt_t src)
86{ 86{
87 int ret; 87 int ret;
88 size_t der_size; 88 size_t der_size;
89 opaque *der; 89 opaque *der;
90 gnutls_datum_t tmp; 90 MHD_gnutls_datum_t tmp;
91 91
92 ret = gnutls_x509_crt_export (src, GNUTLS_X509_FMT_DER, NULL, &der_size); 92 ret = MHD_gnutls_x509_crt_export (src, GNUTLS_X509_FMT_DER, NULL, &der_size);
93 if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER) 93 if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
94 { 94 {
95 gnutls_assert (); 95 MHD_gnutls_assert ();
96 return ret; 96 return ret;
97 } 97 }
98 98
99 der = gnutls_alloca (der_size); 99 der = MHD_gnutls_alloca (der_size);
100 if (der == NULL) 100 if (der == NULL)
101 { 101 {
102 gnutls_assert (); 102 MHD_gnutls_assert ();
103 return GNUTLS_E_MEMORY_ERROR; 103 return GNUTLS_E_MEMORY_ERROR;
104 } 104 }
105 105
106 ret = gnutls_x509_crt_export (src, GNUTLS_X509_FMT_DER, der, &der_size); 106 ret = MHD_gnutls_x509_crt_export (src, GNUTLS_X509_FMT_DER, der, &der_size);
107 if (ret < 0) 107 if (ret < 0)
108 { 108 {
109 gnutls_assert (); 109 MHD_gnutls_assert ();
110 gnutls_afree (der); 110 MHD_gnutls_afree (der);
111 return ret; 111 return ret;
112 } 112 }
113 113
114 tmp.data = der; 114 tmp.data = der;
115 tmp.size = der_size; 115 tmp.size = der_size;
116 ret = gnutls_x509_crt_import (dest, &tmp, GNUTLS_X509_FMT_DER); 116 ret = MHD_gnutls_x509_crt_import (dest, &tmp, GNUTLS_X509_FMT_DER);
117 117
118 gnutls_afree (der); 118 MHD_gnutls_afree (der);
119 119
120 if (ret < 0) 120 if (ret < 0)
121 { 121 {
122 gnutls_assert (); 122 MHD_gnutls_assert ();
123 return ret; 123 return ret;
124 } 124 }
125 125
@@ -128,32 +128,32 @@ _gnutls_x509_crt_cpy (gnutls_x509_crt_t dest, gnutls_x509_crt_t src)
128} 128}
129 129
130/** 130/**
131 * gnutls_x509_crt_deinit - This function deinitializes memory used by a gnutls_x509_crt_t structure 131 * MHD_gnutls_x509_crt_deinit - This function deinitializes memory used by a MHD_gnutls_x509_crt_t structure
132 * @cert: The structure to be initialized 132 * @cert: The structure to be initialized
133 * 133 *
134 * This function will deinitialize a CRL structure. 134 * This function will deinitialize a CRL structure.
135 * 135 *
136 **/ 136 **/
137void 137void
138gnutls_x509_crt_deinit (gnutls_x509_crt_t cert) 138MHD_gnutls_x509_crt_deinit (MHD_gnutls_x509_crt_t cert)
139{ 139{
140 if (!cert) 140 if (!cert)
141 return; 141 return;
142 142
143 if (cert->cert) 143 if (cert->cert)
144 asn1_delete_structure (&cert->cert); 144 MHD__asn1_delete_structure (&cert->cert);
145 145
146 gnutls_free (cert); 146 MHD_gnutls_free (cert);
147} 147}
148 148
149/** 149/**
150 * gnutls_x509_crt_import - This function will import a DER or PEM encoded Certificate 150 * MHD_gnutls_x509_crt_import - This function will import a DER or PEM encoded Certificate
151 * @cert: The structure to store the parsed certificate. 151 * @cert: The structure to store the parsed certificate.
152 * @data: The DER or PEM encoded certificate. 152 * @data: The DER or PEM encoded certificate.
153 * @format: One of DER or PEM 153 * @format: One of DER or PEM
154 * 154 *
155 * This function will convert the given DER or PEM encoded Certificate 155 * This function will convert the given DER or PEM encoded Certificate
156 * to the native gnutls_x509_crt_t format. The output will be stored in @cert. 156 * to the native MHD_gnutls_x509_crt_t format. The output will be stored in @cert.
157 * 157 *
158 * If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or 158 * If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or
159 * "CERTIFICATE". 159 * "CERTIFICATE".
@@ -162,17 +162,17 @@ gnutls_x509_crt_deinit (gnutls_x509_crt_t cert)
162 * 162 *
163 **/ 163 **/
164int 164int
165gnutls_x509_crt_import (gnutls_x509_crt_t cert, 165MHD_gnutls_x509_crt_import (MHD_gnutls_x509_crt_t cert,
166 const gnutls_datum_t * data, 166 const MHD_gnutls_datum_t * data,
167 gnutls_x509_crt_fmt_t format) 167 MHD_gnutls_x509_crt_fmt_t format)
168{ 168{
169 int result = 0, need_free = 0; 169 int result = 0, need_free = 0;
170 gnutls_datum_t _data; 170 MHD_gnutls_datum_t _data;
171 opaque *signature = NULL; 171 opaque *signature = NULL;
172 172
173 if (cert == NULL) 173 if (cert == NULL)
174 { 174 {
175 gnutls_assert (); 175 MHD_gnutls_assert ();
176 return GNUTLS_E_INVALID_REQUEST; 176 return GNUTLS_E_INVALID_REQUEST;
177 } 177 }
178 178
@@ -186,20 +186,20 @@ gnutls_x509_crt_import (gnutls_x509_crt_t cert,
186 opaque *out; 186 opaque *out;
187 187
188 /* Try the first header */ 188 /* Try the first header */
189 result = _gnutls_fbase64_decode (PEM_X509_CERT2, data->data, data->size, 189 result = MHD__gnutls_fbase64_decode (PEM_X509_CERT2, data->data, data->size,
190 &out); 190 &out);
191 191
192 if (result <= 0) 192 if (result <= 0)
193 { 193 {
194 /* try for the second header */ 194 /* try for the second header */
195 result = _gnutls_fbase64_decode (PEM_X509_CERT, data->data, 195 result = MHD__gnutls_fbase64_decode (PEM_X509_CERT, data->data,
196 data->size, &out); 196 data->size, &out);
197 197
198 if (result <= 0) 198 if (result <= 0)
199 { 199 {
200 if (result == 0) 200 if (result == 0)
201 result = GNUTLS_E_INTERNAL_ERROR; 201 result = GNUTLS_E_INTERNAL_ERROR;
202 gnutls_assert (); 202 MHD_gnutls_assert ();
203 return result; 203 return result;
204 } 204 }
205 } 205 }
@@ -210,11 +210,11 @@ gnutls_x509_crt_import (gnutls_x509_crt_t cert,
210 need_free = 1; 210 need_free = 1;
211 } 211 }
212 212
213 result = asn1_der_decoding (&cert->cert, _data.data, _data.size, NULL); 213 result = MHD__asn1_der_decoding (&cert->cert, _data.data, _data.size, NULL);
214 if (result != ASN1_SUCCESS) 214 if (result != ASN1_SUCCESS)
215 { 215 {
216 result = mhd_gtls_asn2err (result); 216 result = MHD_gtls_asn2err (result);
217 gnutls_assert (); 217 MHD_gnutls_assert ();
218 goto cleanup; 218 goto cleanup;
219 } 219 }
220 220
@@ -222,19 +222,19 @@ gnutls_x509_crt_import (gnutls_x509_crt_t cert,
222 */ 222 */
223 cert->use_extensions = 1; 223 cert->use_extensions = 1;
224 if (need_free) 224 if (need_free)
225 _gnutls_free_datum (&_data); 225 MHD__gnutls_free_datum (&_data);
226 226
227 return 0; 227 return 0;
228 228
229cleanup:gnutls_free (signature); 229cleanup:MHD_gnutls_free (signature);
230 if (need_free) 230 if (need_free)
231 _gnutls_free_datum (&_data); 231 MHD__gnutls_free_datum (&_data);
232 return result; 232 return result;
233} 233}
234 234
235/** 235/**
236 * gnutls_x509_crt_get_issuer_dn - This function returns the Certificate's issuer distinguished name 236 * MHD_gnutls_x509_crt_get_issuer_dn - This function returns the Certificate's issuer distinguished name
237 * @cert: should contain a gnutls_x509_crt_t structure 237 * @cert: should contain a MHD_gnutls_x509_crt_t structure
238 * @buf: a pointer to a structure to hold the name (may be null) 238 * @buf: a pointer to a structure to hold the name (may be null)
239 * @sizeof_buf: initially holds the size of @buf 239 * @sizeof_buf: initially holds the size of @buf
240 * 240 *
@@ -251,23 +251,23 @@ cleanup:gnutls_free (signature);
251 * 251 *
252 **/ 252 **/
253int 253int
254gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t cert, 254MHD_gnutls_x509_crt_get_issuer_dn (MHD_gnutls_x509_crt_t cert,
255 char *buf, size_t * sizeof_buf) 255 char *buf, size_t * sizeof_buf)
256{ 256{
257 if (cert == NULL) 257 if (cert == NULL)
258 { 258 {
259 gnutls_assert (); 259 MHD_gnutls_assert ();
260 return GNUTLS_E_INVALID_REQUEST; 260 return GNUTLS_E_INVALID_REQUEST;
261 } 261 }
262 262
263 return _gnutls_x509_parse_dn (cert->cert, 263 return MHD__gnutls_x509_parse_dn (cert->cert,
264 "tbsCertificate.issuer.rdnSequence", buf, 264 "tbsCertificate.issuer.rdnSequence", buf,
265 sizeof_buf); 265 sizeof_buf);
266} 266}
267 267
268/** 268/**
269 * gnutls_x509_crt_get_issuer_dn_by_oid - This function returns the Certificate's issuer distinguished name 269 * MHD_gnutls_x509_crt_get_issuer_dn_by_oid - This function returns the Certificate's issuer distinguished name
270 * @cert: should contain a gnutls_x509_crt_t structure 270 * @cert: should contain a MHD_gnutls_x509_crt_t structure
271 * @oid: holds an Object Identified in null terminated string 271 * @oid: holds an Object Identified in null terminated string
272 * @indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one. 272 * @indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
273 * @raw_flag: If non zero returns the raw DER data of the DN part. 273 * @raw_flag: If non zero returns the raw DER data of the DN part.
@@ -283,7 +283,7 @@ gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t cert,
283 * If raw flag is zero, this function will only return known OIDs as 283 * If raw flag is zero, this function will only return known OIDs as
284 * text. Other OIDs will be DER encoded, as described in RFC2253 -- 284 * text. Other OIDs will be DER encoded, as described in RFC2253 --
285 * in hex format with a '\#' prefix. You can check about known OIDs 285 * in hex format with a '\#' prefix. You can check about known OIDs
286 * using gnutls_x509_dn_oid_known(). 286 * using MHD_gnutls_x509_dn_oid_known().
287 * 287 *
288 * If @buf is null then only the size will be filled. 288 * If @buf is null then only the size will be filled.
289 * 289 *
@@ -293,7 +293,7 @@ gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t cert,
293 * 293 *
294 **/ 294 **/
295int 295int
296gnutls_x509_crt_get_issuer_dn_by_oid (gnutls_x509_crt_t cert, 296MHD_gnutls_x509_crt_get_issuer_dn_by_oid (MHD_gnutls_x509_crt_t cert,
297 const char *oid, 297 const char *oid,
298 int indx, 298 int indx,
299 unsigned int raw_flag, 299 unsigned int raw_flag,
@@ -301,18 +301,18 @@ gnutls_x509_crt_get_issuer_dn_by_oid (gnutls_x509_crt_t cert,
301{ 301{
302 if (cert == NULL) 302 if (cert == NULL)
303 { 303 {
304 gnutls_assert (); 304 MHD_gnutls_assert ();
305 return GNUTLS_E_INVALID_REQUEST; 305 return GNUTLS_E_INVALID_REQUEST;
306 } 306 }
307 307
308 return _gnutls_x509_parse_dn_oid (cert->cert, 308 return MHD__gnutls_x509_parse_dn_oid (cert->cert,
309 "tbsCertificate.issuer.rdnSequence", oid, 309 "tbsCertificate.issuer.rdnSequence", oid,
310 indx, raw_flag, buf, sizeof_buf); 310 indx, raw_flag, buf, sizeof_buf);
311} 311}
312 312
313/** 313/**
314 * gnutls_x509_crt_get_issuer_dn_oid - This function returns the Certificate's issuer distinguished name OIDs 314 * MHD_gnutls_x509_crt_get_issuer_dn_oid - This function returns the Certificate's issuer distinguished name OIDs
315 * @cert: should contain a gnutls_x509_crt_t structure 315 * @cert: should contain a MHD_gnutls_x509_crt_t structure
316 * @indx: This specifies which OID to return. Use zero to get the first one. 316 * @indx: This specifies which OID to return. Use zero to get the first one.
317 * @oid: a pointer to a buffer to hold the OID (may be null) 317 * @oid: a pointer to a buffer to hold the OID (may be null)
318 * @sizeof_oid: initially holds the size of @oid 318 * @sizeof_oid: initially holds the size of @oid
@@ -328,23 +328,23 @@ gnutls_x509_crt_get_issuer_dn_by_oid (gnutls_x509_crt_t cert,
328 * 328 *
329 **/ 329 **/
330int 330int
331gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t cert, 331MHD_gnutls_x509_crt_get_issuer_dn_oid (MHD_gnutls_x509_crt_t cert,
332 int indx, void *oid, size_t * sizeof_oid) 332 int indx, void *oid, size_t * sizeof_oid)
333{ 333{
334 if (cert == NULL) 334 if (cert == NULL)
335 { 335 {
336 gnutls_assert (); 336 MHD_gnutls_assert ();
337 return GNUTLS_E_INVALID_REQUEST; 337 return GNUTLS_E_INVALID_REQUEST;
338 } 338 }
339 339
340 return _gnutls_x509_get_dn_oid (cert->cert, 340 return MHD__gnutls_x509_get_dn_oid (cert->cert,
341 "tbsCertificate.issuer.rdnSequence", indx, 341 "tbsCertificate.issuer.rdnSequence", indx,
342 oid, sizeof_oid); 342 oid, sizeof_oid);
343} 343}
344 344
345/** 345/**
346 * gnutls_x509_crt_get_dn - This function returns the Certificate's distinguished name 346 * MHD_gnutls_x509_crt_get_dn - This function returns the Certificate's distinguished name
347 * @cert: should contain a gnutls_x509_crt_t structure 347 * @cert: should contain a MHD_gnutls_x509_crt_t structure
348 * @buf: a pointer to a structure to hold the name (may be null) 348 * @buf: a pointer to a structure to hold the name (may be null)
349 * @sizeof_buf: initially holds the size of @buf 349 * @sizeof_buf: initially holds the size of @buf
350 * 350 *
@@ -361,23 +361,23 @@ gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t cert,
361 * 361 *
362 **/ 362 **/
363int 363int
364gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert, 364MHD_gnutls_x509_crt_get_dn (MHD_gnutls_x509_crt_t cert,
365 char *buf, size_t * sizeof_buf) 365 char *buf, size_t * sizeof_buf)
366{ 366{
367 if (cert == NULL) 367 if (cert == NULL)
368 { 368 {
369 gnutls_assert (); 369 MHD_gnutls_assert ();
370 return GNUTLS_E_INVALID_REQUEST; 370 return GNUTLS_E_INVALID_REQUEST;
371 } 371 }
372 372
373 return _gnutls_x509_parse_dn (cert->cert, 373 return MHD__gnutls_x509_parse_dn (cert->cert,
374 "tbsCertificate.subject.rdnSequence", buf, 374 "tbsCertificate.subject.rdnSequence", buf,
375 sizeof_buf); 375 sizeof_buf);
376} 376}
377 377
378/** 378/**
379 * gnutls_x509_crt_get_dn_by_oid - This function returns the Certificate's distinguished name 379 * MHD_gnutls_x509_crt_get_dn_by_oid - This function returns the Certificate's distinguished name
380 * @cert: should contain a gnutls_x509_crt_t structure 380 * @cert: should contain a MHD_gnutls_x509_crt_t structure
381 * @oid: holds an Object Identified in null terminated string 381 * @oid: holds an Object Identified in null terminated string
382 * @indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one. 382 * @indx: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
383 * @raw_flag: If non zero returns the raw DER data of the DN part. 383 * @raw_flag: If non zero returns the raw DER data of the DN part.
@@ -393,7 +393,7 @@ gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert,
393 * If raw flag is zero, this function will only return known OIDs as 393 * If raw flag is zero, this function will only return known OIDs as
394 * text. Other OIDs will be DER encoded, as described in RFC2253 -- 394 * text. Other OIDs will be DER encoded, as described in RFC2253 --
395 * in hex format with a '\#' prefix. You can check about known OIDs 395 * in hex format with a '\#' prefix. You can check about known OIDs
396 * using gnutls_x509_dn_oid_known(). 396 * using MHD_gnutls_x509_dn_oid_known().
397 * 397 *
398 * If @buf is null then only the size will be filled. 398 * If @buf is null then only the size will be filled.
399 * 399 *
@@ -403,7 +403,7 @@ gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert,
403 * 403 *
404 **/ 404 **/
405int 405int
406gnutls_x509_crt_get_dn_by_oid (gnutls_x509_crt_t cert, 406MHD_gnutls_x509_crt_get_dn_by_oid (MHD_gnutls_x509_crt_t cert,
407 const char *oid, 407 const char *oid,
408 int indx, 408 int indx,
409 unsigned int raw_flag, 409 unsigned int raw_flag,
@@ -411,18 +411,18 @@ gnutls_x509_crt_get_dn_by_oid (gnutls_x509_crt_t cert,
411{ 411{
412 if (cert == NULL) 412 if (cert == NULL)
413 { 413 {
414 gnutls_assert (); 414 MHD_gnutls_assert ();
415 return GNUTLS_E_INVALID_REQUEST; 415 return GNUTLS_E_INVALID_REQUEST;
416 } 416 }
417 417
418 return _gnutls_x509_parse_dn_oid (cert->cert, 418 return MHD__gnutls_x509_parse_dn_oid (cert->cert,
419 "tbsCertificate.subject.rdnSequence", oid, 419 "tbsCertificate.subject.rdnSequence", oid,
420 indx, raw_flag, buf, sizeof_buf); 420 indx, raw_flag, buf, sizeof_buf);
421} 421}
422 422
423/** 423/**
424 * gnutls_x509_crt_get_dn_oid - This function returns the Certificate's subject distinguished name OIDs 424 * MHD_gnutls_x509_crt_get_dn_oid - This function returns the Certificate's subject distinguished name OIDs
425 * @cert: should contain a gnutls_x509_crt_t structure 425 * @cert: should contain a MHD_gnutls_x509_crt_t structure
426 * @indx: This specifies which OID to return. Use zero to get the first one. 426 * @indx: This specifies which OID to return. Use zero to get the first one.
427 * @oid: a pointer to a buffer to hold the OID (may be null) 427 * @oid: a pointer to a buffer to hold the OID (may be null)
428 * @sizeof_oid: initially holds the size of @oid 428 * @sizeof_oid: initially holds the size of @oid
@@ -438,39 +438,39 @@ gnutls_x509_crt_get_dn_by_oid (gnutls_x509_crt_t cert,
438 * 438 *
439 **/ 439 **/
440int 440int
441gnutls_x509_crt_get_dn_oid (gnutls_x509_crt_t cert, 441MHD_gnutls_x509_crt_get_dn_oid (MHD_gnutls_x509_crt_t cert,
442 int indx, void *oid, size_t * sizeof_oid) 442 int indx, void *oid, size_t * sizeof_oid)
443{ 443{
444 if (cert == NULL) 444 if (cert == NULL)
445 { 445 {
446 gnutls_assert (); 446 MHD_gnutls_assert ();
447 return GNUTLS_E_INVALID_REQUEST; 447 return GNUTLS_E_INVALID_REQUEST;
448 } 448 }
449 449
450 return _gnutls_x509_get_dn_oid (cert->cert, 450 return MHD__gnutls_x509_get_dn_oid (cert->cert,
451 "tbsCertificate.subject.rdnSequence", indx, 451 "tbsCertificate.subject.rdnSequence", indx,
452 oid, sizeof_oid); 452 oid, sizeof_oid);
453} 453}
454 454
455/** 455/**
456 * gnutls_x509_crt_get_signature_algorithm - This function returns the Certificate's signature algorithm 456 * MHD_gnutls_x509_crt_get_signature_algorithm - This function returns the Certificate's signature algorithm
457 * @cert: should contain a gnutls_x509_crt_t structure 457 * @cert: should contain a MHD_gnutls_x509_crt_t structure
458 * 458 *
459 * This function will return a value of the gnutls_sign_algorithm_t enumeration that 459 * This function will return a value of the MHD_gnutls_sign_algorithm_t enumeration that
460 * is the signature algorithm. 460 * is the signature algorithm.
461 * 461 *
462 * Returns a negative value on error. 462 * Returns a negative value on error.
463 * 463 *
464 **/ 464 **/
465int 465int
466gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t cert) 466MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t cert)
467{ 467{
468 int result; 468 int result;
469 gnutls_datum_t sa; 469 MHD_gnutls_datum_t sa;
470 470
471 if (cert == NULL) 471 if (cert == NULL)
472 { 472 {
473 gnutls_assert (); 473 MHD_gnutls_assert ();
474 return GNUTLS_E_INVALID_REQUEST; 474 return GNUTLS_E_INVALID_REQUEST;
475 } 475 }
476 476
@@ -478,25 +478,25 @@ gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t cert)
478 * read. They will be read from the issuer's certificate if needed. 478 * read. They will be read from the issuer's certificate if needed.
479 */ 479 */
480 result = 480 result =
481 _gnutls_x509_read_value (cert->cert, "signatureAlgorithm.algorithm", &sa, 481 MHD__gnutls_x509_read_value (cert->cert, "signatureAlgorithm.algorithm", &sa,
482 0); 482 0);
483 483
484 if (result < 0) 484 if (result < 0)
485 { 485 {
486 gnutls_assert (); 486 MHD_gnutls_assert ();
487 return result; 487 return result;
488 } 488 }
489 489
490 result = mhd_gtls_x509_oid2sign_algorithm (sa.data); 490 result = MHD_gtls_x509_oid2sign_algorithm (sa.data);
491 491
492 _gnutls_free_datum (&sa); 492 MHD__gnutls_free_datum (&sa);
493 493
494 return result; 494 return result;
495} 495}
496 496
497/** 497/**
498 * gnutls_x509_crt_get_signature - Returns the Certificate's signature 498 * MHD_gnutls_x509_crt_get_signature - Returns the Certificate's signature
499 * @cert: should contain a gnutls_x509_crt_t structure 499 * @cert: should contain a MHD_gnutls_x509_crt_t structure
500 * @sig: a pointer where the signature part will be copied (may be null). 500 * @sig: a pointer where the signature part will be copied (may be null).
501 * @sizeof_sig: initially holds the size of @sig 501 * @sizeof_sig: initially holds the size of @sig
502 * 502 *
@@ -505,7 +505,7 @@ gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t cert)
505 * Returns 0 on success, and a negative value on error. 505 * Returns 0 on success, and a negative value on error.
506 **/ 506 **/
507int 507int
508gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert, 508MHD_gnutls_x509_crt_get_signature (MHD_gnutls_x509_crt_t cert,
509 char *sig, size_t * sizeof_sig) 509 char *sig, size_t * sizeof_sig)
510{ 510{
511 int result; 511 int result;
@@ -513,21 +513,21 @@ gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert,
513 513
514 if (cert == NULL) 514 if (cert == NULL)
515 { 515 {
516 gnutls_assert (); 516 MHD_gnutls_assert ();
517 return GNUTLS_E_INVALID_REQUEST; 517 return GNUTLS_E_INVALID_REQUEST;
518 } 518 }
519 519
520 bits = 0; 520 bits = 0;
521 result = asn1_read_value (cert->cert, "signature", NULL, &bits); 521 result = MHD__asn1_read_value (cert->cert, "signature", NULL, &bits);
522 if (result != ASN1_MEM_ERROR) 522 if (result != ASN1_MEM_ERROR)
523 { 523 {
524 gnutls_assert (); 524 MHD_gnutls_assert ();
525 return mhd_gtls_asn2err (result); 525 return MHD_gtls_asn2err (result);
526 } 526 }
527 527
528 if (bits % 8 != 0) 528 if (bits % 8 != 0)
529 { 529 {
530 gnutls_assert (); 530 MHD_gnutls_assert ();
531 return GNUTLS_E_CERTIFICATE_ERROR; 531 return GNUTLS_E_CERTIFICATE_ERROR;
532 } 532 }
533 533
@@ -539,19 +539,19 @@ gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert,
539 return GNUTLS_E_SHORT_MEMORY_BUFFER; 539 return GNUTLS_E_SHORT_MEMORY_BUFFER;
540 } 540 }
541 541
542 result = asn1_read_value (cert->cert, "signature", sig, &len); 542 result = MHD__asn1_read_value (cert->cert, "signature", sig, &len);
543 if (result != ASN1_SUCCESS) 543 if (result != ASN1_SUCCESS)
544 { 544 {
545 gnutls_assert (); 545 MHD_gnutls_assert ();
546 return mhd_gtls_asn2err (result); 546 return MHD_gtls_asn2err (result);
547 } 547 }
548 548
549 return 0; 549 return 0;
550} 550}
551 551
552/** 552/**
553 * gnutls_x509_crt_get_version - This function returns the Certificate's version number 553 * MHD_gnutls_x509_crt_get_version - This function returns the Certificate's version number
554 * @cert: should contain a gnutls_x509_crt_t structure 554 * @cert: should contain a MHD_gnutls_x509_crt_t structure
555 * 555 *
556 * This function will return the version of the specified Certificate. 556 * This function will return the version of the specified Certificate.
557 * 557 *
@@ -559,35 +559,35 @@ gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert,
559 * 559 *
560 **/ 560 **/
561int 561int
562gnutls_x509_crt_get_version (gnutls_x509_crt_t cert) 562MHD_gnutls_x509_crt_get_version (MHD_gnutls_x509_crt_t cert)
563{ 563{
564 opaque version[5]; 564 opaque version[5];
565 int len, result; 565 int len, result;
566 566
567 if (cert == NULL) 567 if (cert == NULL)
568 { 568 {
569 gnutls_assert (); 569 MHD_gnutls_assert ();
570 return GNUTLS_E_INVALID_REQUEST; 570 return GNUTLS_E_INVALID_REQUEST;
571 } 571 }
572 572
573 len = sizeof (version); 573 len = sizeof (version);
574 if ((result = 574 if ((result =
575 asn1_read_value (cert->cert, "tbsCertificate.version", version, 575 MHD__asn1_read_value (cert->cert, "tbsCertificate.version", version,
576 &len)) != ASN1_SUCCESS) 576 &len)) != ASN1_SUCCESS)
577 { 577 {
578 578
579 if (result == ASN1_ELEMENT_NOT_FOUND) 579 if (result == ASN1_ELEMENT_NOT_FOUND)
580 return 1; /* the DEFAULT version */ 580 return 1; /* the DEFAULT version */
581 gnutls_assert (); 581 MHD_gnutls_assert ();
582 return mhd_gtls_asn2err (result); 582 return MHD_gtls_asn2err (result);
583 } 583 }
584 584
585 return (int) version[0] + 1; 585 return (int) version[0] + 1;
586} 586}
587 587
588/** 588/**
589 * gnutls_x509_crt_get_activation_time - This function returns the Certificate's activation time 589 * MHD_gnutls_x509_crt_get_activation_time - This function returns the Certificate's activation time
590 * @cert: should contain a gnutls_x509_crt_t structure 590 * @cert: should contain a MHD_gnutls_x509_crt_t structure
591 * 591 *
592 * This function will return the time this Certificate was or will be activated. 592 * This function will return the time this Certificate was or will be activated.
593 * 593 *
@@ -595,21 +595,21 @@ gnutls_x509_crt_get_version (gnutls_x509_crt_t cert)
595 * 595 *
596 **/ 596 **/
597time_t 597time_t
598gnutls_x509_crt_get_activation_time (gnutls_x509_crt_t cert) 598MHD_gnutls_x509_crt_get_activation_time (MHD_gnutls_x509_crt_t cert)
599{ 599{
600 if (cert == NULL) 600 if (cert == NULL)
601 { 601 {
602 gnutls_assert (); 602 MHD_gnutls_assert ();
603 return (time_t) - 1; 603 return (time_t) - 1;
604 } 604 }
605 605
606 return _gnutls_x509_get_time (cert->cert, 606 return MHD__gnutls_x509_get_time (cert->cert,
607 "tbsCertificate.validity.notBefore"); 607 "tbsCertificate.validity.notBefore");
608} 608}
609 609
610/** 610/**
611 * gnutls_x509_crt_get_expiration_time - This function returns the Certificate's expiration time 611 * MHD_gnutls_x509_crt_get_expiration_time - This function returns the Certificate's expiration time
612 * @cert: should contain a gnutls_x509_crt_t structure 612 * @cert: should contain a MHD_gnutls_x509_crt_t structure
613 * 613 *
614 * This function will return the time this Certificate was or will be expired. 614 * This function will return the time this Certificate was or will be expired.
615 * 615 *
@@ -617,21 +617,21 @@ gnutls_x509_crt_get_activation_time (gnutls_x509_crt_t cert)
617 * 617 *
618 **/ 618 **/
619time_t 619time_t
620gnutls_x509_crt_get_expiration_time (gnutls_x509_crt_t cert) 620MHD_gnutls_x509_crt_get_expiration_time (MHD_gnutls_x509_crt_t cert)
621{ 621{
622 if (cert == NULL) 622 if (cert == NULL)
623 { 623 {
624 gnutls_assert (); 624 MHD_gnutls_assert ();
625 return (time_t) - 1; 625 return (time_t) - 1;
626 } 626 }
627 627
628 return _gnutls_x509_get_time (cert->cert, 628 return MHD__gnutls_x509_get_time (cert->cert,
629 "tbsCertificate.validity.notAfter"); 629 "tbsCertificate.validity.notAfter");
630} 630}
631 631
632/** 632/**
633 * gnutls_x509_crt_get_serial - This function returns the certificate's serial number 633 * MHD_gnutls_x509_crt_get_serial - This function returns the certificate's serial number
634 * @cert: should contain a gnutls_x509_crt_t structure 634 * @cert: should contain a MHD_gnutls_x509_crt_t structure
635 * @result: The place where the serial number will be copied 635 * @result: The place where the serial number will be copied
636 * @result_size: Holds the size of the result field. 636 * @result_size: Holds the size of the result field.
637 * 637 *
@@ -645,35 +645,35 @@ gnutls_x509_crt_get_expiration_time (gnutls_x509_crt_t cert)
645 * 645 *
646 **/ 646 **/
647int 647int
648gnutls_x509_crt_get_serial (gnutls_x509_crt_t cert, 648MHD_gnutls_x509_crt_get_serial (MHD_gnutls_x509_crt_t cert,
649 void *result, size_t * result_size) 649 void *result, size_t * result_size)
650{ 650{
651 int ret, len; 651 int ret, len;
652 652
653 if (cert == NULL) 653 if (cert == NULL)
654 { 654 {
655 gnutls_assert (); 655 MHD_gnutls_assert ();
656 return GNUTLS_E_INVALID_REQUEST; 656 return GNUTLS_E_INVALID_REQUEST;
657 } 657 }
658 658
659 len = *result_size; 659 len = *result_size;
660 ret 660 ret
661 = 661 =
662 asn1_read_value (cert->cert, "tbsCertificate.serialNumber", result, &len); 662 MHD__asn1_read_value (cert->cert, "tbsCertificate.serialNumber", result, &len);
663 *result_size = len; 663 *result_size = len;
664 664
665 if (ret != ASN1_SUCCESS) 665 if (ret != ASN1_SUCCESS)
666 { 666 {
667 gnutls_assert (); 667 MHD_gnutls_assert ();
668 return mhd_gtls_asn2err (ret); 668 return MHD_gtls_asn2err (ret);
669 } 669 }
670 670
671 return 0; 671 return 0;
672} 672}
673 673
674/** 674/**
675 * gnutls_x509_crt_get_subject_key_id - This function returns the certificate's key identifier 675 * MHD_gnutls_x509_crt_get_subject_key_id - This function returns the certificate's key identifier
676 * @cert: should contain a gnutls_x509_crt_t structure 676 * @cert: should contain a MHD_gnutls_x509_crt_t structure
677 * @ret: The place where the identifier will be copied 677 * @ret: The place where the identifier will be copied
678 * @ret_size: Holds the size of the result field. 678 * @ret_size: Holds the size of the result field.
679 * @critical: will be non zero if the extension is marked as critical (may be null) 679 * @critical: will be non zero if the extension is marked as critical (may be null)
@@ -686,17 +686,17 @@ gnutls_x509_crt_get_serial (gnutls_x509_crt_t cert,
686 * 686 *
687 **/ 687 **/
688int 688int
689gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert, 689MHD_gnutls_x509_crt_get_subject_key_id (MHD_gnutls_x509_crt_t cert,
690 void *ret, 690 void *ret,
691 size_t * ret_size, unsigned int *critical) 691 size_t * ret_size, unsigned int *critical)
692{ 692{
693 int result, len; 693 int result, len;
694 gnutls_datum_t id; 694 MHD_gnutls_datum_t id;
695 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 695 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
696 696
697 if (cert == NULL) 697 if (cert == NULL)
698 { 698 {
699 gnutls_assert (); 699 MHD_gnutls_assert ();
700 return GNUTLS_E_INVALID_REQUEST; 700 return GNUTLS_E_INVALID_REQUEST;
701 } 701 }
702 702
@@ -705,7 +705,7 @@ gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert,
705 else 705 else
706 *ret_size = 0; 706 *ret_size = 0;
707 707
708 if ((result = _gnutls_x509_crt_get_extension (cert, "2.5.29.14", 0, &id, 708 if ((result = MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.14", 0, &id,
709 critical)) < 0) 709 critical)) < 0)
710 { 710 {
711 return result; 711 return result;
@@ -713,35 +713,35 @@ gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert,
713 713
714 if (id.size == 0 || id.data == NULL) 714 if (id.size == 0 || id.data == NULL)
715 { 715 {
716 gnutls_assert (); 716 MHD_gnutls_assert ();
717 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 717 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
718 } 718 }
719 719
720 result = 720 result =
721 asn1_create_element (_gnutls_get_pkix (), "PKIX1.SubjectKeyIdentifier", 721 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.SubjectKeyIdentifier",
722 &c2); 722 &c2);
723 if (result != ASN1_SUCCESS) 723 if (result != ASN1_SUCCESS)
724 { 724 {
725 gnutls_assert (); 725 MHD_gnutls_assert ();
726 _gnutls_free_datum (&id); 726 MHD__gnutls_free_datum (&id);
727 return mhd_gtls_asn2err (result); 727 return MHD_gtls_asn2err (result);
728 } 728 }
729 729
730 result = asn1_der_decoding (&c2, id.data, id.size, NULL); 730 result = MHD__asn1_der_decoding (&c2, id.data, id.size, NULL);
731 _gnutls_free_datum (&id); 731 MHD__gnutls_free_datum (&id);
732 732
733 if (result != ASN1_SUCCESS) 733 if (result != ASN1_SUCCESS)
734 { 734 {
735 gnutls_assert (); 735 MHD_gnutls_assert ();
736 asn1_delete_structure (&c2); 736 MHD__asn1_delete_structure (&c2);
737 return mhd_gtls_asn2err (result); 737 return MHD_gtls_asn2err (result);
738 } 738 }
739 739
740 len = *ret_size; 740 len = *ret_size;
741 result = asn1_read_value (c2, "", ret, &len); 741 result = MHD__asn1_read_value (c2, "", ret, &len);
742 742
743 *ret_size = len; 743 *ret_size = len;
744 asn1_delete_structure (&c2); 744 MHD__asn1_delete_structure (&c2);
745 745
746 if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND) 746 if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
747 { 747 {
@@ -750,16 +750,16 @@ gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert,
750 750
751 if (result != ASN1_SUCCESS) 751 if (result != ASN1_SUCCESS)
752 { 752 {
753 gnutls_assert (); 753 MHD_gnutls_assert ();
754 return mhd_gtls_asn2err (result); 754 return MHD_gtls_asn2err (result);
755 } 755 }
756 756
757 return 0; 757 return 0;
758} 758}
759 759
760/** 760/**
761 * gnutls_x509_crt_get_authority_key_id - This function returns the certificate authority's identifier 761 * MHD_gnutls_x509_crt_get_authority_key_id - This function returns the certificate authority's identifier
762 * @cert: should contain a gnutls_x509_crt_t structure 762 * @cert: should contain a MHD_gnutls_x509_crt_t structure
763 * @result: The place where the identifier will be copied 763 * @result: The place where the identifier will be copied
764 * @result_size: Holds the size of the result field. 764 * @result_size: Holds the size of the result field.
765 * @critical: will be non zero if the extension is marked as critical (may be null) 765 * @critical: will be non zero if the extension is marked as critical (may be null)
@@ -773,18 +773,18 @@ gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert,
773 * 773 *
774 **/ 774 **/
775int 775int
776gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert, 776MHD_gnutls_x509_crt_get_authority_key_id (MHD_gnutls_x509_crt_t cert,
777 void *ret, 777 void *ret,
778 size_t * ret_size, 778 size_t * ret_size,
779 unsigned int *critical) 779 unsigned int *critical)
780{ 780{
781 int result, len; 781 int result, len;
782 gnutls_datum_t id; 782 MHD_gnutls_datum_t id;
783 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 783 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
784 784
785 if (cert == NULL) 785 if (cert == NULL)
786 { 786 {
787 gnutls_assert (); 787 MHD_gnutls_assert ();
788 return GNUTLS_E_INVALID_REQUEST; 788 return GNUTLS_E_INVALID_REQUEST;
789 } 789 }
790 790
@@ -793,7 +793,7 @@ gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert,
793 else 793 else
794 *ret_size = 0; 794 *ret_size = 0;
795 795
796 if ((result = _gnutls_x509_crt_get_extension (cert, "2.5.29.35", 0, &id, 796 if ((result = MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.35", 0, &id,
797 critical)) < 0) 797 critical)) < 0)
798 { 798 {
799 return result; 799 return result;
@@ -801,35 +801,35 @@ gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert,
801 801
802 if (id.size == 0 || id.data == NULL) 802 if (id.size == 0 || id.data == NULL)
803 { 803 {
804 gnutls_assert (); 804 MHD_gnutls_assert ();
805 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 805 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
806 } 806 }
807 807
808 result = 808 result =
809 asn1_create_element (_gnutls_get_pkix (), "PKIX1.AuthorityKeyIdentifier", 809 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.AuthorityKeyIdentifier",
810 &c2); 810 &c2);
811 if (result != ASN1_SUCCESS) 811 if (result != ASN1_SUCCESS)
812 { 812 {
813 gnutls_assert (); 813 MHD_gnutls_assert ();
814 _gnutls_free_datum (&id); 814 MHD__gnutls_free_datum (&id);
815 return mhd_gtls_asn2err (result); 815 return MHD_gtls_asn2err (result);
816 } 816 }
817 817
818 result = asn1_der_decoding (&c2, id.data, id.size, NULL); 818 result = MHD__asn1_der_decoding (&c2, id.data, id.size, NULL);
819 _gnutls_free_datum (&id); 819 MHD__gnutls_free_datum (&id);
820 820
821 if (result != ASN1_SUCCESS) 821 if (result != ASN1_SUCCESS)
822 { 822 {
823 gnutls_assert (); 823 MHD_gnutls_assert ();
824 asn1_delete_structure (&c2); 824 MHD__asn1_delete_structure (&c2);
825 return mhd_gtls_asn2err (result); 825 return MHD_gtls_asn2err (result);
826 } 826 }
827 827
828 len = *ret_size; 828 len = *ret_size;
829 result = asn1_read_value (c2, "keyIdentifier", ret, &len); 829 result = MHD__asn1_read_value (c2, "keyIdentifier", ret, &len);
830 830
831 *ret_size = len; 831 *ret_size = len;
832 asn1_delete_structure (&c2); 832 MHD__asn1_delete_structure (&c2);
833 833
834 if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND) 834 if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
835 { 835 {
@@ -838,16 +838,16 @@ gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert,
838 838
839 if (result != ASN1_SUCCESS) 839 if (result != ASN1_SUCCESS)
840 { 840 {
841 gnutls_assert (); 841 MHD_gnutls_assert ();
842 return mhd_gtls_asn2err (result); 842 return MHD_gtls_asn2err (result);
843 } 843 }
844 844
845 return 0; 845 return 0;
846} 846}
847 847
848/** 848/**
849 * gnutls_x509_crt_get_pk_algorithm - This function returns the certificate's PublicKey algorithm 849 * MHD_gnutls_x509_crt_get_pk_algorithm - This function returns the certificate's PublicKey algorithm
850 * @cert: should contain a gnutls_x509_crt_t structure 850 * @cert: should contain a MHD_gnutls_x509_crt_t structure
851 * @bits: if bits is non null it will hold the size of the parameters' in bits 851 * @bits: if bits is non null it will hold the size of the parameters' in bits
852 * 852 *
853 * This function will return the public key algorithm of an X.509 853 * This function will return the public key algorithm of an X.509
@@ -863,23 +863,23 @@ gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert,
863 * 863 *
864 **/ 864 **/
865int 865int
866gnutls_x509_crt_get_pk_algorithm (gnutls_x509_crt_t cert, unsigned int *bits) 866MHD_gnutls_x509_crt_get_pk_algorithm (MHD_gnutls_x509_crt_t cert, unsigned int *bits)
867{ 867{
868 int result; 868 int result;
869 869
870 if (cert == NULL) 870 if (cert == NULL)
871 { 871 {
872 gnutls_assert (); 872 MHD_gnutls_assert ();
873 return GNUTLS_E_INVALID_REQUEST; 873 return GNUTLS_E_INVALID_REQUEST;
874 } 874 }
875 875
876 result = _gnutls_x509_get_pk_algorithm (cert->cert, 876 result = MHD__gnutls_x509_get_pk_algorithm (cert->cert,
877 "tbsCertificate.subjectPublicKeyInfo", 877 "tbsCertificate.subjectPublicKeyInfo",
878 bits); 878 bits);
879 879
880 if (result < 0) 880 if (result < 0)
881 { 881 {
882 gnutls_assert (); 882 MHD_gnutls_assert ();
883 return result; 883 return result;
884 } 884 }
885 885
@@ -914,7 +914,7 @@ parse_general_name (ASN1_TYPE src,
914 char nptr[MAX_NAME_SIZE]; 914 char nptr[MAX_NAME_SIZE];
915 int result; 915 int result;
916 opaque choice_type[128]; 916 opaque choice_type[128];
917 gnutls_x509_subject_alt_name_t type; 917 MHD_gnutls_x509_subject_alt_name_t type;
918 918
919 seq++; /* 0->1, 1->2 etc */ 919 seq++; /* 0->1, 1->2 etc */
920 920
@@ -924,7 +924,7 @@ parse_general_name (ASN1_TYPE src,
924 snprintf (nptr, sizeof (nptr), "?%u", seq); 924 snprintf (nptr, sizeof (nptr), "?%u", seq);
925 925
926 len = sizeof (choice_type); 926 len = sizeof (choice_type);
927 result = asn1_read_value (src, nptr, choice_type, &len); 927 result = MHD__asn1_read_value (src, nptr, choice_type, &len);
928 928
929 if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND) 929 if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
930 { 930 {
@@ -933,14 +933,14 @@ parse_general_name (ASN1_TYPE src,
933 933
934 if (result != ASN1_SUCCESS) 934 if (result != ASN1_SUCCESS)
935 { 935 {
936 gnutls_assert (); 936 MHD_gnutls_assert ();
937 return mhd_gtls_asn2err (result); 937 return MHD_gtls_asn2err (result);
938 } 938 }
939 939
940 type = _gnutls_x509_san_find_type (choice_type); 940 type = MHD__gnutls_x509_san_find_type (choice_type);
941 if (type == (gnutls_x509_subject_alt_name_t) - 1) 941 if (type == (MHD_gnutls_x509_subject_alt_name_t) - 1)
942 { 942 {
943 gnutls_assert (); 943 MHD_gnutls_assert ();
944 return GNUTLS_E_X509_UNKNOWN_SAN; 944 return GNUTLS_E_X509_UNKNOWN_SAN;
945 } 945 }
946 946
@@ -950,12 +950,12 @@ parse_general_name (ASN1_TYPE src,
950 if (type == GNUTLS_SAN_OTHERNAME) 950 if (type == GNUTLS_SAN_OTHERNAME)
951 { 951 {
952 if (othername_oid) 952 if (othername_oid)
953 mhd_gtls_str_cat (nptr, sizeof (nptr), ".otherName.type-id"); 953 MHD_gtls_str_cat (nptr, sizeof (nptr), ".otherName.type-id");
954 else 954 else
955 mhd_gtls_str_cat (nptr, sizeof (nptr), ".otherName.value"); 955 MHD_gtls_str_cat (nptr, sizeof (nptr), ".otherName.value");
956 956
957 len = *name_size; 957 len = *name_size;
958 result = asn1_read_value (src, nptr, name, &len); 958 result = MHD__asn1_read_value (src, nptr, name, &len);
959 *name_size = len; 959 *name_size = len;
960 960
961 if (result == ASN1_MEM_ERROR) 961 if (result == ASN1_MEM_ERROR)
@@ -963,8 +963,8 @@ parse_general_name (ASN1_TYPE src,
963 963
964 if (result != ASN1_SUCCESS) 964 if (result != ASN1_SUCCESS)
965 { 965 {
966 gnutls_assert (); 966 MHD_gnutls_assert ();
967 return mhd_gtls_asn2err (result); 967 return MHD_gtls_asn2err (result);
968 } 968 }
969 969
970 if (othername_oid) 970 if (othername_oid)
@@ -983,11 +983,11 @@ parse_general_name (ASN1_TYPE src,
983 snprintf (nptr, sizeof (nptr), "?%u.otherName.type-id", seq); 983 snprintf (nptr, sizeof (nptr), "?%u.otherName.type-id", seq);
984 984
985 len = sizeof (oid); 985 len = sizeof (oid);
986 result = asn1_read_value (src, nptr, oid, &len); 986 result = MHD__asn1_read_value (src, nptr, oid, &len);
987 if (result != ASN1_SUCCESS) 987 if (result != ASN1_SUCCESS)
988 { 988 {
989 gnutls_assert (); 989 MHD_gnutls_assert ();
990 return mhd_gtls_asn2err (result); 990 return MHD_gtls_asn2err (result);
991 } 991 }
992 992
993 if (len > strlen (XMPP_OID) && strcmp (oid, XMPP_OID) == 0) 993 if (len > strlen (XMPP_OID) && strcmp (oid, XMPP_OID) == 0)
@@ -995,41 +995,41 @@ parse_general_name (ASN1_TYPE src,
995 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 995 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
996 996
997 result = 997 result =
998 asn1_create_element (_gnutls_get_pkix (), "PKIX1.XmppAddr", 998 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.XmppAddr",
999 &c2); 999 &c2);
1000 if (result != ASN1_SUCCESS) 1000 if (result != ASN1_SUCCESS)
1001 { 1001 {
1002 gnutls_assert (); 1002 MHD_gnutls_assert ();
1003 return mhd_gtls_asn2err (result); 1003 return MHD_gtls_asn2err (result);
1004 } 1004 }
1005 1005
1006 result = asn1_der_decoding (&c2, name, *name_size, NULL); 1006 result = MHD__asn1_der_decoding (&c2, name, *name_size, NULL);
1007 if (result != ASN1_SUCCESS) 1007 if (result != ASN1_SUCCESS)
1008 { 1008 {
1009 gnutls_assert (); 1009 MHD_gnutls_assert ();
1010 asn1_delete_structure (&c2); 1010 MHD__asn1_delete_structure (&c2);
1011 return mhd_gtls_asn2err (result); 1011 return MHD_gtls_asn2err (result);
1012 } 1012 }
1013 1013
1014 result = asn1_read_value (c2, "", name, &len); 1014 result = MHD__asn1_read_value (c2, "", name, &len);
1015 *name_size = len; 1015 *name_size = len;
1016 if (result != ASN1_SUCCESS) 1016 if (result != ASN1_SUCCESS)
1017 { 1017 {
1018 gnutls_assert (); 1018 MHD_gnutls_assert ();
1019 asn1_delete_structure (&c2); 1019 MHD__asn1_delete_structure (&c2);
1020 return mhd_gtls_asn2err (result); 1020 return MHD_gtls_asn2err (result);
1021 } 1021 }
1022 asn1_delete_structure (&c2); 1022 MHD__asn1_delete_structure (&c2);
1023 } 1023 }
1024 } 1024 }
1025 } 1025 }
1026 else if (type == GNUTLS_SAN_DN) 1026 else if (type == GNUTLS_SAN_DN)
1027 { 1027 {
1028 mhd_gtls_str_cat (nptr, sizeof (nptr), ".directoryName"); 1028 MHD_gtls_str_cat (nptr, sizeof (nptr), ".directoryName");
1029 result = _gnutls_x509_parse_dn (src, nptr, name, name_size); 1029 result = MHD__gnutls_x509_parse_dn (src, nptr, name, name_size);
1030 if (result < 0) 1030 if (result < 0)
1031 { 1031 {
1032 gnutls_assert (); 1032 MHD_gnutls_assert ();
1033 return result; 1033 return result;
1034 } 1034 }
1035 } 1035 }
@@ -1039,11 +1039,11 @@ parse_general_name (ASN1_TYPE src,
1039 { 1039 {
1040 size_t orig_name_size = *name_size; 1040 size_t orig_name_size = *name_size;
1041 1041
1042 mhd_gtls_str_cat (nptr, sizeof (nptr), "."); 1042 MHD_gtls_str_cat (nptr, sizeof (nptr), ".");
1043 mhd_gtls_str_cat (nptr, sizeof (nptr), choice_type); 1043 MHD_gtls_str_cat (nptr, sizeof (nptr), choice_type);
1044 1044
1045 len = *name_size; 1045 len = *name_size;
1046 result = asn1_read_value (src, nptr, name, &len); 1046 result = MHD__asn1_read_value (src, nptr, name, &len);
1047 *name_size = len; 1047 *name_size = len;
1048 1048
1049 if (result == ASN1_MEM_ERROR) 1049 if (result == ASN1_MEM_ERROR)
@@ -1055,8 +1055,8 @@ parse_general_name (ASN1_TYPE src,
1055 1055
1056 if (result != ASN1_SUCCESS) 1056 if (result != ASN1_SUCCESS)
1057 { 1057 {
1058 gnutls_assert (); 1058 MHD_gnutls_assert ();
1059 return mhd_gtls_asn2err (result); 1059 return MHD_gtls_asn2err (result);
1060 } 1060 }
1061 1061
1062 if (is_type_printable (type)) 1062 if (is_type_printable (type))
@@ -1064,7 +1064,7 @@ parse_general_name (ASN1_TYPE src,
1064 1064
1065 if (len + 1 > orig_name_size) 1065 if (len + 1 > orig_name_size)
1066 { 1066 {
1067 gnutls_assert (); 1067 MHD_gnutls_assert ();
1068 (*name_size)++; 1068 (*name_size)++;
1069 return GNUTLS_E_SHORT_MEMORY_BUFFER; 1069 return GNUTLS_E_SHORT_MEMORY_BUFFER;
1070 } 1070 }
@@ -1079,7 +1079,7 @@ parse_general_name (ASN1_TYPE src,
1079} 1079}
1080 1080
1081static int 1081static int
1082get_subject_alt_name (gnutls_x509_crt_t cert, 1082get_subject_alt_name (MHD_gnutls_x509_crt_t cert,
1083 unsigned int seq, 1083 unsigned int seq,
1084 void *ret, 1084 void *ret,
1085 size_t * ret_size, 1085 size_t * ret_size,
@@ -1087,13 +1087,13 @@ get_subject_alt_name (gnutls_x509_crt_t cert,
1087 unsigned int *critical, int othername_oid) 1087 unsigned int *critical, int othername_oid)
1088{ 1088{
1089 int result; 1089 int result;
1090 gnutls_datum_t dnsname; 1090 MHD_gnutls_datum_t dnsname;
1091 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 1091 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
1092 gnutls_x509_subject_alt_name_t type; 1092 MHD_gnutls_x509_subject_alt_name_t type;
1093 1093
1094 if (cert == NULL) 1094 if (cert == NULL)
1095 { 1095 {
1096 gnutls_assert (); 1096 MHD_gnutls_assert ();
1097 return GNUTLS_E_INVALID_REQUEST; 1097 return GNUTLS_E_INVALID_REQUEST;
1098 } 1098 }
1099 1099
@@ -1103,7 +1103,7 @@ get_subject_alt_name (gnutls_x509_crt_t cert,
1103 *ret_size = 0; 1103 *ret_size = 0;
1104 1104
1105 if ((result = 1105 if ((result =
1106 _gnutls_x509_crt_get_extension (cert, "2.5.29.17", 0, &dnsname, 1106 MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.17", 0, &dnsname,
1107 critical)) < 0) 1107 critical)) < 0)
1108 { 1108 {
1109 return result; 1109 return result;
@@ -1111,33 +1111,33 @@ get_subject_alt_name (gnutls_x509_crt_t cert,
1111 1111
1112 if (dnsname.size == 0 || dnsname.data == NULL) 1112 if (dnsname.size == 0 || dnsname.data == NULL)
1113 { 1113 {
1114 gnutls_assert (); 1114 MHD_gnutls_assert ();
1115 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 1115 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
1116 } 1116 }
1117 1117
1118 result = 1118 result =
1119 asn1_create_element (_gnutls_get_pkix (), "PKIX1.SubjectAltName", &c2); 1119 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.SubjectAltName", &c2);
1120 if (result != ASN1_SUCCESS) 1120 if (result != ASN1_SUCCESS)
1121 { 1121 {
1122 gnutls_assert (); 1122 MHD_gnutls_assert ();
1123 _gnutls_free_datum (&dnsname); 1123 MHD__gnutls_free_datum (&dnsname);
1124 return mhd_gtls_asn2err (result); 1124 return MHD_gtls_asn2err (result);
1125 } 1125 }
1126 1126
1127 result = asn1_der_decoding (&c2, dnsname.data, dnsname.size, NULL); 1127 result = MHD__asn1_der_decoding (&c2, dnsname.data, dnsname.size, NULL);
1128 _gnutls_free_datum (&dnsname); 1128 MHD__gnutls_free_datum (&dnsname);
1129 1129
1130 if (result != ASN1_SUCCESS) 1130 if (result != ASN1_SUCCESS)
1131 { 1131 {
1132 gnutls_assert (); 1132 MHD_gnutls_assert ();
1133 asn1_delete_structure (&c2); 1133 MHD__asn1_delete_structure (&c2);
1134 return mhd_gtls_asn2err (result); 1134 return MHD_gtls_asn2err (result);
1135 } 1135 }
1136 1136
1137 result = parse_general_name (c2, "", seq, ret, ret_size, ret_type, 1137 result = parse_general_name (c2, "", seq, ret, ret_size, ret_type,
1138 othername_oid); 1138 othername_oid);
1139 1139
1140 asn1_delete_structure (&c2); 1140 MHD__asn1_delete_structure (&c2);
1141 1141
1142 if (result < 0) 1142 if (result < 0)
1143 { 1143 {
@@ -1150,8 +1150,8 @@ get_subject_alt_name (gnutls_x509_crt_t cert,
1150} 1150}
1151 1151
1152/** 1152/**
1153 * gnutls_x509_crt_get_subject_alt_name - Get certificate's alternative name, if any 1153 * MHD_gnutls_x509_crt_get_subject_alt_name - Get certificate's alternative name, if any
1154 * @cert: should contain a gnutls_x509_crt_t structure 1154 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1155 * @seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) 1155 * @seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
1156 * @ret: is the place where the alternative name will be copied to 1156 * @ret: is the place where the alternative name will be copied to
1157 * @ret_size: holds the size of ret. 1157 * @ret_size: holds the size of ret.
@@ -1165,7 +1165,7 @@ get_subject_alt_name (gnutls_x509_crt_t cert,
1165 * 1165 *
1166 * When the SAN type is otherName, it will extract the data in the 1166 * When the SAN type is otherName, it will extract the data in the
1167 * otherName's value field, and %GNUTLS_SAN_OTHERNAME is returned. 1167 * otherName's value field, and %GNUTLS_SAN_OTHERNAME is returned.
1168 * You may use gnutls_x509_crt_get_subject_alt_othername_oid() to get 1168 * You may use MHD_gnutls_x509_crt_get_subject_alt_othername_oid() to get
1169 * the corresponding OID and the "virtual" SAN types (e.g., 1169 * the corresponding OID and the "virtual" SAN types (e.g.,
1170 * %GNUTLS_SAN_OTHERNAME_XMPP). 1170 * %GNUTLS_SAN_OTHERNAME_XMPP).
1171 * 1171 *
@@ -1175,7 +1175,7 @@ get_subject_alt_name (gnutls_x509_crt_t cert,
1175 * recognized. 1175 * recognized.
1176 * 1176 *
1177 * Returns the alternative subject name type on success. The type is 1177 * Returns the alternative subject name type on success. The type is
1178 * one of the enumerated gnutls_x509_subject_alt_name_t. It will 1178 * one of the enumerated MHD_gnutls_x509_subject_alt_name_t. It will
1179 * return %GNUTLS_E_SHORT_MEMORY_BUFFER if @ret_size is not large 1179 * return %GNUTLS_E_SHORT_MEMORY_BUFFER if @ret_size is not large
1180 * enough to hold the value. In that case @ret_size will be updated 1180 * enough to hold the value. In that case @ret_size will be updated
1181 * with the required size. If the certificate does not have an 1181 * with the required size. If the certificate does not have an
@@ -1184,7 +1184,7 @@ get_subject_alt_name (gnutls_x509_crt_t cert,
1184 * 1184 *
1185 **/ 1185 **/
1186int 1186int
1187gnutls_x509_crt_get_subject_alt_name (gnutls_x509_crt_t cert, 1187MHD_gnutls_x509_crt_get_subject_alt_name (MHD_gnutls_x509_crt_t cert,
1188 unsigned int seq, 1188 unsigned int seq,
1189 void *ret, 1189 void *ret,
1190 size_t * ret_size, 1190 size_t * ret_size,
@@ -1194,25 +1194,25 @@ gnutls_x509_crt_get_subject_alt_name (gnutls_x509_crt_t cert,
1194} 1194}
1195 1195
1196/** 1196/**
1197 * gnutls_x509_crt_get_subject_alt_name2 - Get certificate's alternative name, if any 1197 * MHD_gnutls_x509_crt_get_subject_alt_name2 - Get certificate's alternative name, if any
1198 * @cert: should contain a gnutls_x509_crt_t structure 1198 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1199 * @seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) 1199 * @seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
1200 * @ret: is the place where the alternative name will be copied to 1200 * @ret: is the place where the alternative name will be copied to
1201 * @ret_size: holds the size of ret. 1201 * @ret_size: holds the size of ret.
1202 * @ret_type: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t). 1202 * @ret_type: holds the type of the alternative name (one of MHD_gnutls_x509_subject_alt_name_t).
1203 * @critical: will be non zero if the extension is marked as critical (may be null) 1203 * @critical: will be non zero if the extension is marked as critical (may be null)
1204 * 1204 *
1205 * This function will return the alternative names, contained in the 1205 * This function will return the alternative names, contained in the
1206 * given certificate. It is the same as gnutls_x509_crt_get_subject_alt_name() 1206 * given certificate. It is the same as MHD_gnutls_x509_crt_get_subject_alt_name()
1207 * except for the fact that it will return the type of the alternative 1207 * except for the fact that it will return the type of the alternative
1208 * name in @ret_type even if the function fails for some reason (i.e. 1208 * name in @ret_type even if the function fails for some reason (i.e.
1209 * the buffer provided is not enough). 1209 * the buffer provided is not enough).
1210 * 1210 *
1211 * The return values are the same as with gnutls_x509_crt_get_subject_alt_name(). 1211 * The return values are the same as with MHD_gnutls_x509_crt_get_subject_alt_name().
1212 * 1212 *
1213 **/ 1213 **/
1214int 1214int
1215gnutls_x509_crt_get_subject_alt_name2 (gnutls_x509_crt_t cert, 1215MHD_gnutls_x509_crt_get_subject_alt_name2 (MHD_gnutls_x509_crt_t cert,
1216 unsigned int seq, 1216 unsigned int seq,
1217 void *ret, 1217 void *ret,
1218 size_t * ret_size, 1218 size_t * ret_size,
@@ -1224,8 +1224,8 @@ gnutls_x509_crt_get_subject_alt_name2 (gnutls_x509_crt_t cert,
1224} 1224}
1225 1225
1226/** 1226/**
1227 * gnutls_x509_crt_get_subject_alt_othername_oid - Get SAN otherName OID 1227 * MHD_gnutls_x509_crt_get_subject_alt_othername_oid - Get SAN otherName OID
1228 * @cert: should contain a gnutls_x509_crt_t structure 1228 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1229 * @seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.) 1229 * @seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
1230 * @ret: is the place where the otherName OID will be copied to 1230 * @ret: is the place where the otherName OID will be copied to
1231 * @ret_size: holds the size of ret. 1231 * @ret_size: holds the size of ret.
@@ -1235,11 +1235,11 @@ gnutls_x509_crt_get_subject_alt_name2 (gnutls_x509_crt_t cert,
1235 * the type as an enumerated element. 1235 * the type as an enumerated element.
1236 * 1236 *
1237 * This function is only useful if 1237 * This function is only useful if
1238 * gnutls_x509_crt_get_subject_alt_name() returned 1238 * MHD_gnutls_x509_crt_get_subject_alt_name() returned
1239 * %GNUTLS_SAN_OTHERNAME. 1239 * %GNUTLS_SAN_OTHERNAME.
1240 * 1240 *
1241 * Returns the alternative subject name type on success. The type is 1241 * Returns the alternative subject name type on success. The type is
1242 * one of the enumerated gnutls_x509_subject_alt_name_t. For 1242 * one of the enumerated MHD_gnutls_x509_subject_alt_name_t. For
1243 * supported OIDs, it will return one of the virtual 1243 * supported OIDs, it will return one of the virtual
1244 * (GNUTLS_SAN_OTHERNAME_*) types, e.g. %GNUTLS_SAN_OTHERNAME_XMPP, 1244 * (GNUTLS_SAN_OTHERNAME_*) types, e.g. %GNUTLS_SAN_OTHERNAME_XMPP,
1245 * and %GNUTLS_SAN_OTHERNAME for unknown OIDs. It will return 1245 * and %GNUTLS_SAN_OTHERNAME for unknown OIDs. It will return
@@ -1250,7 +1250,7 @@ gnutls_x509_crt_get_subject_alt_name2 (gnutls_x509_crt_t cert,
1250 * then %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned. 1250 * then %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned.
1251 **/ 1251 **/
1252int 1252int
1253gnutls_x509_crt_get_subject_alt_othername_oid (gnutls_x509_crt_t cert, 1253MHD_gnutls_x509_crt_get_subject_alt_othername_oid (MHD_gnutls_x509_crt_t cert,
1254 unsigned int seq, 1254 unsigned int seq,
1255 void *ret, size_t * ret_size) 1255 void *ret, size_t * ret_size)
1256{ 1256{
@@ -1258,8 +1258,8 @@ gnutls_x509_crt_get_subject_alt_othername_oid (gnutls_x509_crt_t cert,
1258} 1258}
1259 1259
1260/** 1260/**
1261 * gnutls_x509_crt_get_basic_constraints - This function returns the certificate basic constraints 1261 * MHD_gnutls_x509_crt_get_basic_constraints - This function returns the certificate basic constraints
1262 * @cert: should contain a gnutls_x509_crt_t structure 1262 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1263 * @critical: will be non zero if the extension is marked as critical 1263 * @critical: will be non zero if the extension is marked as critical
1264 * @ca: pointer to output integer indicating CA status, may be NULL, 1264 * @ca: pointer to output integer indicating CA status, may be NULL,
1265 * value is 1 if the certificate CA flag is set, 0 otherwise. 1265 * value is 1 if the certificate CA flag is set, 0 otherwise.
@@ -1278,21 +1278,21 @@ gnutls_x509_crt_get_subject_alt_othername_oid (gnutls_x509_crt_t cert,
1278 * GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. 1278 * GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
1279 **/ 1279 **/
1280int 1280int
1281gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert, 1281MHD_gnutls_x509_crt_get_basic_constraints (MHD_gnutls_x509_crt_t cert,
1282 unsigned int *critical, 1282 unsigned int *critical,
1283 int *ca, int *pathlen) 1283 int *ca, int *pathlen)
1284{ 1284{
1285 int result; 1285 int result;
1286 gnutls_datum_t basicConstraints; 1286 MHD_gnutls_datum_t basicConstraints;
1287 int tmp_ca; 1287 int tmp_ca;
1288 1288
1289 if (cert == NULL) 1289 if (cert == NULL)
1290 { 1290 {
1291 gnutls_assert (); 1291 MHD_gnutls_assert ();
1292 return GNUTLS_E_INVALID_REQUEST; 1292 return GNUTLS_E_INVALID_REQUEST;
1293 } 1293 }
1294 1294
1295 if ((result = _gnutls_x509_crt_get_extension (cert, "2.5.29.19", 0, 1295 if ((result = MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.19", 0,
1296 &basicConstraints, critical)) 1296 &basicConstraints, critical))
1297 < 0) 1297 < 0)
1298 { 1298 {
@@ -1301,20 +1301,20 @@ gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert,
1301 1301
1302 if (basicConstraints.size == 0 || basicConstraints.data == NULL) 1302 if (basicConstraints.size == 0 || basicConstraints.data == NULL)
1303 { 1303 {
1304 gnutls_assert (); 1304 MHD_gnutls_assert ();
1305 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 1305 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
1306 } 1306 }
1307 1307
1308 result = _gnutls_x509_ext_extract_basicConstraints (&tmp_ca, pathlen, 1308 result = MHD__gnutls_x509_ext_extract_basicConstraints (&tmp_ca, pathlen,
1309 basicConstraints.data, 1309 basicConstraints.data,
1310 basicConstraints.size); 1310 basicConstraints.size);
1311 if (ca) 1311 if (ca)
1312 *ca = tmp_ca; 1312 *ca = tmp_ca;
1313 _gnutls_free_datum (&basicConstraints); 1313 MHD__gnutls_free_datum (&basicConstraints);
1314 1314
1315 if (result < 0) 1315 if (result < 0)
1316 { 1316 {
1317 gnutls_assert (); 1317 MHD_gnutls_assert ();
1318 return result; 1318 return result;
1319 } 1319 }
1320 1320
@@ -1322,8 +1322,8 @@ gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert,
1322} 1322}
1323 1323
1324/** 1324/**
1325 * gnutls_x509_crt_get_ca_status - This function returns the certificate CA status 1325 * MHD_gnutls_x509_crt_get_ca_status - This function returns the certificate CA status
1326 * @cert: should contain a gnutls_x509_crt_t structure 1326 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1327 * @critical: will be non zero if the extension is marked as critical 1327 * @critical: will be non zero if the extension is marked as critical
1328 * 1328 *
1329 * This function will return certificates CA status, by reading the 1329 * This function will return certificates CA status, by reading the
@@ -1331,7 +1331,7 @@ gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert,
1331 * a CA a positive value will be returned, or zero if the certificate 1331 * a CA a positive value will be returned, or zero if the certificate
1332 * does not have CA flag set. 1332 * does not have CA flag set.
1333 * 1333 *
1334 * Use gnutls_x509_crt_get_basic_constraints() if you want to read the 1334 * Use MHD_gnutls_x509_crt_get_basic_constraints() if you want to read the
1335 * pathLenConstraint field too. 1335 * pathLenConstraint field too.
1336 * 1336 *
1337 * A negative value may be returned in case of parsing error. 1337 * A negative value may be returned in case of parsing error.
@@ -1340,16 +1340,16 @@ gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert,
1340 * 1340 *
1341 **/ 1341 **/
1342int 1342int
1343gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t cert, unsigned int *critical) 1343MHD_gnutls_x509_crt_get_ca_status (MHD_gnutls_x509_crt_t cert, unsigned int *critical)
1344{ 1344{
1345 int ca, pathlen; 1345 int ca, pathlen;
1346 return gnutls_x509_crt_get_basic_constraints (cert, critical, &ca, 1346 return MHD_gnutls_x509_crt_get_basic_constraints (cert, critical, &ca,
1347 &pathlen); 1347 &pathlen);
1348} 1348}
1349 1349
1350/** 1350/**
1351 * gnutls_x509_crt_get_key_usage - This function returns the certificate's key usage 1351 * MHD_gnutls_x509_crt_get_key_usage - This function returns the certificate's key usage
1352 * @cert: should contain a gnutls_x509_crt_t structure 1352 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1353 * @key_usage: where the key usage bits will be stored 1353 * @key_usage: where the key usage bits will be stored
1354 * @critical: will be non zero if the extension is marked as critical 1354 * @critical: will be non zero if the extension is marked as critical
1355 * 1355 *
@@ -1367,22 +1367,22 @@ gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t cert, unsigned int *critical)
1367 * 1367 *
1368 **/ 1368 **/
1369int 1369int
1370gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert, 1370MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert,
1371 unsigned int *key_usage, 1371 unsigned int *key_usage,
1372 unsigned int *critical) 1372 unsigned int *critical)
1373{ 1373{
1374 int result; 1374 int result;
1375 gnutls_datum_t keyUsage; 1375 MHD_gnutls_datum_t keyUsage;
1376 uint16_t _usage; 1376 uint16_t _usage;
1377 1377
1378 if (cert == NULL) 1378 if (cert == NULL)
1379 { 1379 {
1380 gnutls_assert (); 1380 MHD_gnutls_assert ();
1381 return GNUTLS_E_INVALID_REQUEST; 1381 return GNUTLS_E_INVALID_REQUEST;
1382 } 1382 }
1383 1383
1384 if ((result = 1384 if ((result =
1385 _gnutls_x509_crt_get_extension (cert, "2.5.29.15", 0, &keyUsage, 1385 MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.15", 0, &keyUsage,
1386 critical)) < 0) 1386 critical)) < 0)
1387 { 1387 {
1388 return result; 1388 return result;
@@ -1390,19 +1390,19 @@ gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert,
1390 1390
1391 if (keyUsage.size == 0 || keyUsage.data == NULL) 1391 if (keyUsage.size == 0 || keyUsage.data == NULL)
1392 { 1392 {
1393 gnutls_assert (); 1393 MHD_gnutls_assert ();
1394 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 1394 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
1395 } 1395 }
1396 1396
1397 result = _gnutls_x509_ext_extract_keyUsage (&_usage, keyUsage.data, 1397 result = MHD__gnutls_x509_ext_extract_keyUsage (&_usage, keyUsage.data,
1398 keyUsage.size); 1398 keyUsage.size);
1399 _gnutls_free_datum (&keyUsage); 1399 MHD__gnutls_free_datum (&keyUsage);
1400 1400
1401 *key_usage = _usage; 1401 *key_usage = _usage;
1402 1402
1403 if (result < 0) 1403 if (result < 0)
1404 { 1404 {
1405 gnutls_assert (); 1405 MHD_gnutls_assert ();
1406 return result; 1406 return result;
1407 } 1407 }
1408 1408
@@ -1410,8 +1410,8 @@ gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert,
1410} 1410}
1411 1411
1412/** 1412/**
1413 * gnutls_x509_crt_get_proxy - This function returns the proxy certificate info 1413 * MHD_gnutls_x509_crt_get_proxy - This function returns the proxy certificate info
1414 * @cert: should contain a gnutls_x509_crt_t structure 1414 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1415 * @critical: will be non zero if the extension is marked as critical 1415 * @critical: will be non zero if the extension is marked as critical
1416 * @pathlen: pointer to output integer indicating path length (may be 1416 * @pathlen: pointer to output integer indicating path length (may be
1417 * NULL), non-negative values indicate a present pCPathLenConstraint 1417 * NULL), non-negative values indicate a present pCPathLenConstraint
@@ -1428,22 +1428,22 @@ gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert,
1428 * GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. 1428 * GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
1429 **/ 1429 **/
1430int 1430int
1431gnutls_x509_crt_get_proxy (gnutls_x509_crt_t cert, 1431MHD_gnutls_x509_crt_get_proxy (MHD_gnutls_x509_crt_t cert,
1432 unsigned int *critical, 1432 unsigned int *critical,
1433 int *pathlen, 1433 int *pathlen,
1434 char **policyLanguage, 1434 char **policyLanguage,
1435 char **policy, size_t * sizeof_policy) 1435 char **policy, size_t * sizeof_policy)
1436{ 1436{
1437 int result; 1437 int result;
1438 gnutls_datum_t proxyCertInfo; 1438 MHD_gnutls_datum_t proxyCertInfo;
1439 1439
1440 if (cert == NULL) 1440 if (cert == NULL)
1441 { 1441 {
1442 gnutls_assert (); 1442 MHD_gnutls_assert ();
1443 return GNUTLS_E_INVALID_REQUEST; 1443 return GNUTLS_E_INVALID_REQUEST;
1444 } 1444 }
1445 1445
1446 if ((result = _gnutls_x509_crt_get_extension (cert, "1.3.6.1.5.5.7.1.14", 0, 1446 if ((result = MHD__gnutls_x509_crt_get_extension (cert, "1.3.6.1.5.5.7.1.14", 0,
1447 &proxyCertInfo, 1447 &proxyCertInfo,
1448 critical)) < 0) 1448 critical)) < 0)
1449 { 1449 {
@@ -1452,18 +1452,18 @@ gnutls_x509_crt_get_proxy (gnutls_x509_crt_t cert,
1452 1452
1453 if (proxyCertInfo.size == 0 || proxyCertInfo.data == NULL) 1453 if (proxyCertInfo.size == 0 || proxyCertInfo.data == NULL)
1454 { 1454 {
1455 gnutls_assert (); 1455 MHD_gnutls_assert ();
1456 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 1456 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
1457 } 1457 }
1458 1458
1459 result = _gnutls_x509_ext_extract_proxyCertInfo (pathlen, policyLanguage, 1459 result = MHD__gnutls_x509_ext_extract_proxyCertInfo (pathlen, policyLanguage,
1460 policy, sizeof_policy, 1460 policy, sizeof_policy,
1461 proxyCertInfo.data, 1461 proxyCertInfo.data,
1462 proxyCertInfo.size); 1462 proxyCertInfo.size);
1463 _gnutls_free_datum (&proxyCertInfo); 1463 MHD__gnutls_free_datum (&proxyCertInfo);
1464 if (result < 0) 1464 if (result < 0)
1465 { 1465 {
1466 gnutls_assert (); 1466 MHD_gnutls_assert ();
1467 return result; 1467 return result;
1468 } 1468 }
1469 1469
@@ -1471,8 +1471,8 @@ gnutls_x509_crt_get_proxy (gnutls_x509_crt_t cert,
1471} 1471}
1472 1472
1473/** 1473/**
1474 * gnutls_x509_crt_get_extension_by_oid - This function returns the specified extension 1474 * MHD_gnutls_x509_crt_get_extension_by_oid - This function returns the specified extension
1475 * @cert: should contain a gnutls_x509_crt_t structure 1475 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1476 * @oid: holds an Object Identified in null terminated string 1476 * @oid: holds an Object Identified in null terminated string
1477 * @indx: In case multiple same OIDs exist in the extensions, this specifies which to send. Use zero to get the first one. 1477 * @indx: In case multiple same OIDs exist in the extensions, this specifies which to send. Use zero to get the first one.
1478 * @buf: a pointer to a structure to hold the name (may be null) 1478 * @buf: a pointer to a structure to hold the name (may be null)
@@ -1489,7 +1489,7 @@ gnutls_x509_crt_get_proxy (gnutls_x509_crt_t cert,
1489 * 1489 *
1490 **/ 1490 **/
1491int 1491int
1492gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t cert, 1492MHD_gnutls_x509_crt_get_extension_by_oid (MHD_gnutls_x509_crt_t cert,
1493 const char *oid, 1493 const char *oid,
1494 int indx, 1494 int indx,
1495 void *buf, 1495 void *buf,
@@ -1497,31 +1497,31 @@ gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t cert,
1497 unsigned int *critical) 1497 unsigned int *critical)
1498{ 1498{
1499 int result; 1499 int result;
1500 gnutls_datum_t output; 1500 MHD_gnutls_datum_t output;
1501 1501
1502 if (cert == NULL) 1502 if (cert == NULL)
1503 { 1503 {
1504 gnutls_assert (); 1504 MHD_gnutls_assert ();
1505 return GNUTLS_E_INVALID_REQUEST; 1505 return GNUTLS_E_INVALID_REQUEST;
1506 } 1506 }
1507 1507
1508 if ((result = _gnutls_x509_crt_get_extension (cert, oid, indx, &output, 1508 if ((result = MHD__gnutls_x509_crt_get_extension (cert, oid, indx, &output,
1509 critical)) < 0) 1509 critical)) < 0)
1510 { 1510 {
1511 gnutls_assert (); 1511 MHD_gnutls_assert ();
1512 return result; 1512 return result;
1513 } 1513 }
1514 1514
1515 if (output.size == 0 || output.data == NULL) 1515 if (output.size == 0 || output.data == NULL)
1516 { 1516 {
1517 gnutls_assert (); 1517 MHD_gnutls_assert ();
1518 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 1518 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
1519 } 1519 }
1520 1520
1521 if (output.size > (unsigned int) *sizeof_buf) 1521 if (output.size > (unsigned int) *sizeof_buf)
1522 { 1522 {
1523 *sizeof_buf = output.size; 1523 *sizeof_buf = output.size;
1524 _gnutls_free_datum (&output); 1524 MHD__gnutls_free_datum (&output);
1525 return GNUTLS_E_SHORT_MEMORY_BUFFER; 1525 return GNUTLS_E_SHORT_MEMORY_BUFFER;
1526 } 1526 }
1527 1527
@@ -1530,15 +1530,15 @@ gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t cert,
1530 if (buf) 1530 if (buf)
1531 memcpy (buf, output.data, output.size); 1531 memcpy (buf, output.data, output.size);
1532 1532
1533 _gnutls_free_datum (&output); 1533 MHD__gnutls_free_datum (&output);
1534 1534
1535 return 0; 1535 return 0;
1536 1536
1537} 1537}
1538 1538
1539/** 1539/**
1540 * gnutls_x509_crt_get_extension_oid - This function returns the specified extension OID 1540 * MHD_gnutls_x509_crt_get_extension_oid - This function returns the specified extension OID
1541 * @cert: should contain a gnutls_x509_crt_t structure 1541 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1542 * @indx: Specifies which extension OID to send. Use zero to get the first one. 1542 * @indx: Specifies which extension OID to send. Use zero to get the first one.
1543 * @oid: a pointer to a structure to hold the OID (may be null) 1543 * @oid: a pointer to a structure to hold the OID (may be null)
1544 * @sizeof_oid: initially holds the size of @oid 1544 * @sizeof_oid: initially holds the size of @oid
@@ -1552,18 +1552,18 @@ gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t cert,
1552 * 1552 *
1553 **/ 1553 **/
1554int 1554int
1555gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, 1555MHD_gnutls_x509_crt_get_extension_oid (MHD_gnutls_x509_crt_t cert,
1556 int indx, void *oid, size_t * sizeof_oid) 1556 int indx, void *oid, size_t * sizeof_oid)
1557{ 1557{
1558 int result; 1558 int result;
1559 1559
1560 if (cert == NULL) 1560 if (cert == NULL)
1561 { 1561 {
1562 gnutls_assert (); 1562 MHD_gnutls_assert ();
1563 return GNUTLS_E_INVALID_REQUEST; 1563 return GNUTLS_E_INVALID_REQUEST;
1564 } 1564 }
1565 1565
1566 result = _gnutls_x509_crt_get_extension_oid (cert, indx, oid, sizeof_oid); 1566 result = MHD__gnutls_x509_crt_get_extension_oid (cert, indx, oid, sizeof_oid);
1567 if (result < 0) 1567 if (result < 0)
1568 { 1568 {
1569 return result; 1569 return result;
@@ -1574,8 +1574,8 @@ gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
1574} 1574}
1575 1575
1576/** 1576/**
1577 * gnutls_x509_crt_get_extension_info - Get extension id and criticality 1577 * MHD_gnutls_x509_crt_get_extension_info - Get extension id and criticality
1578 * @cert: should contain a gnutls_x509_crt_t structure 1578 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1579 * @indx: Specifies which extension OID to send. Use zero to get the first one. 1579 * @indx: Specifies which extension OID to send. Use zero to get the first one.
1580 * @oid: a pointer to a structure to hold the OID 1580 * @oid: a pointer to a structure to hold the OID
1581 * @sizeof_oid: initially holds the size of @oid 1581 * @sizeof_oid: initially holds the size of @oid
@@ -1584,7 +1584,7 @@ gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
1584 * This function will return the requested extension OID in the 1584 * This function will return the requested extension OID in the
1585 * certificate, and the critical flag for it. The extension OID will 1585 * certificate, and the critical flag for it. The extension OID will
1586 * be stored as a string in the provided buffer. Use 1586 * be stored as a string in the provided buffer. Use
1587 * gnutls_x509_crt_get_extension_data() to extract the data. 1587 * MHD_gnutls_x509_crt_get_extension_data() to extract the data.
1588 * 1588 *
1589 * Return 0 on success. A negative value may be returned in case of 1589 * Return 0 on success. A negative value may be returned in case of
1590 * parsing error. If you have reached the last extension available 1590 * parsing error. If you have reached the last extension available
@@ -1592,7 +1592,7 @@ gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert,
1592 * 1592 *
1593 **/ 1593 **/
1594int 1594int
1595gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert, 1595MHD_gnutls_x509_crt_get_extension_info (MHD_gnutls_x509_crt_t cert,
1596 int indx, 1596 int indx,
1597 void *oid, 1597 void *oid,
1598 size_t * sizeof_oid, int *critical) 1598 size_t * sizeof_oid, int *critical)
@@ -1604,7 +1604,7 @@ gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert,
1604 1604
1605 if (!cert) 1605 if (!cert)
1606 { 1606 {
1607 gnutls_assert (); 1607 MHD_gnutls_assert ();
1608 return GNUTLS_E_INVALID_REQUEST; 1608 return GNUTLS_E_INVALID_REQUEST;
1609 } 1609 }
1610 1610
@@ -1612,25 +1612,25 @@ gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert,
1612 indx + 1); 1612 indx + 1);
1613 1613
1614 len = *sizeof_oid; 1614 len = *sizeof_oid;
1615 result = asn1_read_value (cert->cert, name, oid, &len); 1615 result = MHD__asn1_read_value (cert->cert, name, oid, &len);
1616 *sizeof_oid = len; 1616 *sizeof_oid = len;
1617 1617
1618 if (result == ASN1_ELEMENT_NOT_FOUND) 1618 if (result == ASN1_ELEMENT_NOT_FOUND)
1619 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 1619 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
1620 else if (result < 0) 1620 else if (result < 0)
1621 { 1621 {
1622 gnutls_assert (); 1622 MHD_gnutls_assert ();
1623 return mhd_gtls_asn2err (result); 1623 return MHD_gtls_asn2err (result);
1624 } 1624 }
1625 1625
1626 snprintf (name, sizeof (name), "tbsCertificate.extensions.?%u.critical", 1626 snprintf (name, sizeof (name), "tbsCertificate.extensions.?%u.critical",
1627 indx + 1); 1627 indx + 1);
1628 len = sizeof (str_critical); 1628 len = sizeof (str_critical);
1629 result = asn1_read_value (cert->cert, name, str_critical, &len); 1629 result = MHD__asn1_read_value (cert->cert, name, str_critical, &len);
1630 if (result < 0) 1630 if (result < 0)
1631 { 1631 {
1632 gnutls_assert (); 1632 MHD_gnutls_assert ();
1633 return mhd_gtls_asn2err (result); 1633 return MHD_gtls_asn2err (result);
1634 } 1634 }
1635 1635
1636 if (critical) 1636 if (critical)
@@ -1646,8 +1646,8 @@ gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert,
1646} 1646}
1647 1647
1648/** 1648/**
1649 * gnutls_x509_crt_get_extension_data - Get the specified extension data 1649 * MHD_gnutls_x509_crt_get_extension_data - Get the specified extension data
1650 * @cert: should contain a gnutls_x509_crt_t structure 1650 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1651 * @indx: Specifies which extension OID to send. Use zero to get the first one. 1651 * @indx: Specifies which extension OID to send. Use zero to get the first one.
1652 * @data: a pointer to a structure to hold the data (may be null) 1652 * @data: a pointer to a structure to hold the data (may be null)
1653 * @sizeof_data: initially holds the size of @oid 1653 * @sizeof_data: initially holds the size of @oid
@@ -1656,8 +1656,8 @@ gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert,
1656 * certificate. The extension data will be stored as a string in the 1656 * certificate. The extension data will be stored as a string in the
1657 * provided buffer. 1657 * provided buffer.
1658 * 1658 *
1659 * Use gnutls_x509_crt_get_extension_info() to extract the OID and 1659 * Use MHD_gnutls_x509_crt_get_extension_info() to extract the OID and
1660 * critical flag. Use gnutls_x509_crt_get_extension_by_oid() instead, 1660 * critical flag. Use MHD_gnutls_x509_crt_get_extension_by_oid() instead,
1661 * if you want to get data indexed by the extension OID rather than 1661 * if you want to get data indexed by the extension OID rather than
1662 * sequence. 1662 * sequence.
1663 * 1663 *
@@ -1666,7 +1666,7 @@ gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert,
1666 * GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned. 1666 * GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
1667 **/ 1667 **/
1668int 1668int
1669gnutls_x509_crt_get_extension_data (gnutls_x509_crt_t cert, 1669MHD_gnutls_x509_crt_get_extension_data (MHD_gnutls_x509_crt_t cert,
1670 int indx, 1670 int indx,
1671 void *data, size_t * sizeof_data) 1671 void *data, size_t * sizeof_data)
1672{ 1672{
@@ -1675,7 +1675,7 @@ gnutls_x509_crt_get_extension_data (gnutls_x509_crt_t cert,
1675 1675
1676 if (!cert) 1676 if (!cert)
1677 { 1677 {
1678 gnutls_assert (); 1678 MHD_gnutls_assert ();
1679 return GNUTLS_E_INVALID_REQUEST; 1679 return GNUTLS_E_INVALID_REQUEST;
1680 } 1680 }
1681 1681
@@ -1683,82 +1683,82 @@ gnutls_x509_crt_get_extension_data (gnutls_x509_crt_t cert,
1683 indx + 1); 1683 indx + 1);
1684 1684
1685 len = *sizeof_data; 1685 len = *sizeof_data;
1686 result = asn1_read_value (cert->cert, name, data, &len); 1686 result = MHD__asn1_read_value (cert->cert, name, data, &len);
1687 *sizeof_data = len; 1687 *sizeof_data = len;
1688 1688
1689 if (result == ASN1_ELEMENT_NOT_FOUND) 1689 if (result == ASN1_ELEMENT_NOT_FOUND)
1690 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 1690 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
1691 else if (result < 0) 1691 else if (result < 0)
1692 { 1692 {
1693 gnutls_assert (); 1693 MHD_gnutls_assert ();
1694 return mhd_gtls_asn2err (result); 1694 return MHD_gtls_asn2err (result);
1695 } 1695 }
1696 1696
1697 return 0; 1697 return 0;
1698} 1698}
1699 1699
1700static int 1700static int
1701_gnutls_x509_crt_get_raw_dn2 (gnutls_x509_crt_t cert, 1701MHD__gnutls_x509_crt_get_raw_dn2 (MHD_gnutls_x509_crt_t cert,
1702 const char *whom, gnutls_datum_t * start) 1702 const char *whom, MHD_gnutls_datum_t * start)
1703{ 1703{
1704 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 1704 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
1705 int result, len1; 1705 int result, len1;
1706 int start1, end1; 1706 int start1, end1;
1707 gnutls_datum_t signed_data = { NULL, 1707 MHD_gnutls_datum_t signed_data = { NULL,
1708 0 1708 0
1709 }; 1709 };
1710 1710
1711 /* get the issuer of 'cert' 1711 /* get the issuer of 'cert'
1712 */ 1712 */
1713 if ((result = 1713 if ((result =
1714 asn1_create_element (_gnutls_get_pkix (), "PKIX1.TBSCertificate", 1714 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.TBSCertificate",
1715 &c2)) != ASN1_SUCCESS) 1715 &c2)) != ASN1_SUCCESS)
1716 { 1716 {
1717 gnutls_assert (); 1717 MHD_gnutls_assert ();
1718 return mhd_gtls_asn2err (result); 1718 return MHD_gtls_asn2err (result);
1719 } 1719 }
1720 1720
1721 result = _gnutls_x509_get_signed_data (cert->cert, "tbsCertificate", 1721 result = MHD__gnutls_x509_get_signed_data (cert->cert, "tbsCertificate",
1722 &signed_data); 1722 &signed_data);
1723 if (result < 0) 1723 if (result < 0)
1724 { 1724 {
1725 gnutls_assert (); 1725 MHD_gnutls_assert ();
1726 goto cleanup; 1726 goto cleanup;
1727 } 1727 }
1728 1728
1729 result = asn1_der_decoding (&c2, signed_data.data, signed_data.size, NULL); 1729 result = MHD__asn1_der_decoding (&c2, signed_data.data, signed_data.size, NULL);
1730 if (result != ASN1_SUCCESS) 1730 if (result != ASN1_SUCCESS)
1731 { 1731 {
1732 gnutls_assert (); 1732 MHD_gnutls_assert ();
1733 asn1_delete_structure (&c2); 1733 MHD__asn1_delete_structure (&c2);
1734 result = mhd_gtls_asn2err (result); 1734 result = MHD_gtls_asn2err (result);
1735 goto cleanup; 1735 goto cleanup;
1736 } 1736 }
1737 1737
1738 result = asn1_der_decoding_startEnd (c2, signed_data.data, signed_data.size, 1738 result = MHD__asn1_der_decoding_startEnd (c2, signed_data.data, signed_data.size,
1739 whom, &start1, &end1); 1739 whom, &start1, &end1);
1740 1740
1741 if (result != ASN1_SUCCESS) 1741 if (result != ASN1_SUCCESS)
1742 { 1742 {
1743 gnutls_assert (); 1743 MHD_gnutls_assert ();
1744 result = mhd_gtls_asn2err (result); 1744 result = MHD_gtls_asn2err (result);
1745 goto cleanup; 1745 goto cleanup;
1746 } 1746 }
1747 1747
1748 len1 = end1 - start1 + 1; 1748 len1 = end1 - start1 + 1;
1749 1749
1750 _gnutls_set_datum (start, &signed_data.data[start1], len1); 1750 MHD__gnutls_set_datum (start, &signed_data.data[start1], len1);
1751 1751
1752 result = 0; 1752 result = 0;
1753 1753
1754cleanup:asn1_delete_structure (&c2); 1754cleanup:MHD__asn1_delete_structure (&c2);
1755 _gnutls_free_datum (&signed_data); 1755 MHD__gnutls_free_datum (&signed_data);
1756 return result; 1756 return result;
1757} 1757}
1758 1758
1759/** 1759/**
1760 * gnutls_x509_crt_get_raw_issuer_dn - This function returns the issuer's DN DER encoded 1760 * MHD_gnutls_x509_crt_get_raw_issuer_dn - This function returns the issuer's DN DER encoded
1761 * @cert: should contain a gnutls_x509_crt_t structure 1761 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1762 * @start: will hold the starting point of the DN 1762 * @start: will hold the starting point of the DN
1763 * 1763 *
1764 * This function will return a pointer to the DER encoded DN structure 1764 * This function will return a pointer to the DER encoded DN structure
@@ -1768,15 +1768,15 @@ cleanup:asn1_delete_structure (&c2);
1768 * 1768 *
1769 **/ 1769 **/
1770int 1770int
1771gnutls_x509_crt_get_raw_issuer_dn (gnutls_x509_crt_t cert, 1771MHD_gnutls_x509_crt_get_raw_issuer_dn (MHD_gnutls_x509_crt_t cert,
1772 gnutls_datum_t * start) 1772 MHD_gnutls_datum_t * start)
1773{ 1773{
1774 return _gnutls_x509_crt_get_raw_dn2 (cert, "issuer", start); 1774 return MHD__gnutls_x509_crt_get_raw_dn2 (cert, "issuer", start);
1775} 1775}
1776 1776
1777/** 1777/**
1778 * gnutls_x509_crt_get_raw_dn - This function returns the subject's DN DER encoded 1778 * MHD_gnutls_x509_crt_get_raw_dn - This function returns the subject's DN DER encoded
1779 * @cert: should contain a gnutls_x509_crt_t structure 1779 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1780 * @start: will hold the starting point of the DN 1780 * @start: will hold the starting point of the DN
1781 * 1781 *
1782 * This function will return a pointer to the DER encoded DN structure and 1782 * This function will return a pointer to the DER encoded DN structure and
@@ -1786,43 +1786,43 @@ gnutls_x509_crt_get_raw_issuer_dn (gnutls_x509_crt_t cert,
1786 * 1786 *
1787 **/ 1787 **/
1788int 1788int
1789gnutls_x509_crt_get_raw_dn (gnutls_x509_crt_t cert, gnutls_datum_t * start) 1789MHD_gnutls_x509_crt_get_raw_dn (MHD_gnutls_x509_crt_t cert, MHD_gnutls_datum_t * start)
1790{ 1790{
1791 return _gnutls_x509_crt_get_raw_dn2 (cert, "subject", start); 1791 return MHD__gnutls_x509_crt_get_raw_dn2 (cert, "subject", start);
1792} 1792}
1793 1793
1794static int 1794static int
1795get_dn (gnutls_x509_crt_t cert, const char *whom, gnutls_x509_dn_t * dn) 1795get_dn (MHD_gnutls_x509_crt_t cert, const char *whom, MHD_gnutls_x509_dn_t * dn)
1796{ 1796{
1797 *dn = asn1_find_node (cert->cert, whom); 1797 *dn = MHD__asn1_find_node (cert->cert, whom);
1798 if (!*dn) 1798 if (!*dn)
1799 return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND; 1799 return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND;
1800 return 0; 1800 return 0;
1801} 1801}
1802 1802
1803/** 1803/**
1804 * gnutls_x509_crt_get_subject: get opaque subject DN pointer 1804 * MHD_gnutls_x509_crt_get_subject: get opaque subject DN pointer
1805 * @cert: should contain a gnutls_x509_crt_t structure 1805 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1806 * @dn: output variable with pointer to opaque DN. 1806 * @dn: output variable with pointer to opaque DN.
1807 * 1807 *
1808 * Return the Certificate's Subject DN as an opaque data type. You 1808 * Return the Certificate's Subject DN as an opaque data type. You
1809 * may use gnutls_x509_dn_get_rdn_ava() to decode the DN. 1809 * may use MHD_gnutls_x509_dn_get_rdn_ava() to decode the DN.
1810 * 1810 *
1811 * Returns: Returns 0 on success, or an error code. 1811 * Returns: Returns 0 on success, or an error code.
1812 **/ 1812 **/
1813int 1813int
1814gnutls_x509_crt_get_subject (gnutls_x509_crt_t cert, gnutls_x509_dn_t * dn) 1814MHD_gnutls_x509_crt_get_subject (MHD_gnutls_x509_crt_t cert, MHD_gnutls_x509_dn_t * dn)
1815{ 1815{
1816 return get_dn (cert, "tbsCertificate.subject.rdnSequence", dn); 1816 return get_dn (cert, "tbsCertificate.subject.rdnSequence", dn);
1817} 1817}
1818 1818
1819/** 1819/**
1820 * gnutls_x509_crt_get_issuer: get opaque issuer DN pointer 1820 * MHD_gnutls_x509_crt_get_issuer: get opaque issuer DN pointer
1821 * @cert: should contain a gnutls_x509_crt_t structure 1821 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1822 * @dn: output variable with pointer to opaque DN 1822 * @dn: output variable with pointer to opaque DN
1823 * 1823 *
1824 * Return the Certificate's Issuer DN as an opaque data type. You may 1824 * Return the Certificate's Issuer DN as an opaque data type. You may
1825 * use gnutls_x509_dn_get_rdn_ava() to decode the DN. 1825 * use MHD_gnutls_x509_dn_get_rdn_ava() to decode the DN.
1826 * 1826 *
1827 * Note that @dn points into the @cert object, and thus you may not 1827 * Note that @dn points into the @cert object, and thus you may not
1828 * deallocate @cert and continue to access @dn. 1828 * deallocate @cert and continue to access @dn.
@@ -1830,13 +1830,13 @@ gnutls_x509_crt_get_subject (gnutls_x509_crt_t cert, gnutls_x509_dn_t * dn)
1830 * Returns: Returns 0 on success, or an error code. 1830 * Returns: Returns 0 on success, or an error code.
1831 **/ 1831 **/
1832int 1832int
1833gnutls_x509_crt_get_issuer (gnutls_x509_crt_t cert, gnutls_x509_dn_t * dn) 1833MHD_gnutls_x509_crt_get_issuer (MHD_gnutls_x509_crt_t cert, MHD_gnutls_x509_dn_t * dn)
1834{ 1834{
1835 return get_dn (cert, "tbsCertificate.issuer.rdnSequence", dn); 1835 return get_dn (cert, "tbsCertificate.issuer.rdnSequence", dn);
1836} 1836}
1837 1837
1838/** 1838/**
1839 * gnutls_x509_dn_get_rdn_ava: 1839 * MHD_gnutls_x509_dn_get_rdn_ava:
1840 * @dn: input variable with opaque DN pointer 1840 * @dn: input variable with opaque DN pointer
1841 * @irdn: index of RDN 1841 * @irdn: index of RDN
1842 * @iava: index of AVA. 1842 * @iava: index of AVA.
@@ -1852,8 +1852,8 @@ gnutls_x509_crt_get_issuer (gnutls_x509_crt_t cert, gnutls_x509_dn_t * dn)
1852 * Returns: Returns 0 on success, or an error code. 1852 * Returns: Returns 0 on success, or an error code.
1853 **/ 1853 **/
1854int 1854int
1855gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn, 1855MHD_gnutls_x509_dn_get_rdn_ava (MHD_gnutls_x509_dn_t dn,
1856 int irdn, int iava, gnutls_x509_ava_st * ava) 1856 int irdn, int iava, MHD_gnutls_x509_ava_st * ava)
1857{ 1857{
1858 ASN1_TYPE rdn, elem; 1858 ASN1_TYPE rdn, elem;
1859 long len; 1859 long len;
@@ -1865,18 +1865,18 @@ gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn,
1865 irdn++; /* 0->1, 1->2 etc */ 1865 irdn++; /* 0->1, 1->2 etc */
1866 1866
1867 snprintf (rbuf, sizeof (rbuf), "rdnSequence.?%d.?%d", irdn, iava); 1867 snprintf (rbuf, sizeof (rbuf), "rdnSequence.?%d.?%d", irdn, iava);
1868 rdn = asn1_find_node (dn, rbuf); 1868 rdn = MHD__asn1_find_node (dn, rbuf);
1869 if (!rdn) 1869 if (!rdn)
1870 { 1870 {
1871 gnutls_assert (); 1871 MHD_gnutls_assert ();
1872 return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND; 1872 return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND;
1873 } 1873 }
1874 1874
1875 snprintf (rbuf, sizeof (rbuf), "?%d.type", iava); 1875 snprintf (rbuf, sizeof (rbuf), "?%d.type", iava);
1876 elem = asn1_find_node (rdn, rbuf); 1876 elem = MHD__asn1_find_node (rdn, rbuf);
1877 if (!elem) 1877 if (!elem)
1878 { 1878 {
1879 gnutls_assert (); 1879 MHD_gnutls_assert ();
1880 return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND; 1880 return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND;
1881 } 1881 }
1882 1882
@@ -1884,10 +1884,10 @@ gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn,
1884 ava->oid.size = elem->value_len; 1884 ava->oid.size = elem->value_len;
1885 1885
1886 snprintf (rbuf, sizeof (rbuf), "?%d.value", iava); 1886 snprintf (rbuf, sizeof (rbuf), "?%d.value", iava);
1887 elem = asn1_find_node (rdn, rbuf); 1887 elem = MHD__asn1_find_node (rdn, rbuf);
1888 if (!elem) 1888 if (!elem)
1889 { 1889 {
1890 gnutls_assert (); 1890 MHD_gnutls_assert ();
1891 return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND; 1891 return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND;
1892 } 1892 }
1893 1893
@@ -1897,34 +1897,34 @@ gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn,
1897 1897
1898 ptr = elem->value; 1898 ptr = elem->value;
1899 remlen = elem->value_len; 1899 remlen = elem->value_len;
1900 len = asn1_get_length_der (ptr, remlen, &lenlen); 1900 len = MHD__asn1_get_length_der (ptr, remlen, &lenlen);
1901 if (len < 0) 1901 if (len < 0)
1902 { 1902 {
1903 gnutls_assert (); 1903 MHD_gnutls_assert ();
1904 return GNUTLS_E_ASN1_DER_ERROR; 1904 return GNUTLS_E_ASN1_DER_ERROR;
1905 } 1905 }
1906 1906
1907 ptr += lenlen; 1907 ptr += lenlen;
1908 remlen -= lenlen; 1908 remlen -= lenlen;
1909 ret = asn1_get_tag_der (ptr, remlen, &cls, &lenlen, &ava->value_tag); 1909 ret = MHD__asn1_get_tag_der (ptr, remlen, &cls, &lenlen, &ava->value_tag);
1910 if (ret) 1910 if (ret)
1911 { 1911 {
1912 gnutls_assert (); 1912 MHD_gnutls_assert ();
1913 return mhd_gtls_asn2err (ret); 1913 return MHD_gtls_asn2err (ret);
1914 } 1914 }
1915 1915
1916 ptr += lenlen; 1916 ptr += lenlen;
1917 remlen -= lenlen; 1917 remlen -= lenlen;
1918 1918
1919 ava->value.size = asn1_get_length_der (ptr, remlen, &lenlen); 1919 ava->value.size = MHD__asn1_get_length_der (ptr, remlen, &lenlen);
1920 ava->value.data = ptr + lenlen; 1920 ava->value.data = ptr + lenlen;
1921 1921
1922 return 0; 1922 return 0;
1923} 1923}
1924 1924
1925/** 1925/**
1926 * gnutls_x509_crt_get_fingerprint - This function returns the Certificate's fingerprint 1926 * MHD_gnutls_x509_crt_get_fingerprint - This function returns the Certificate's fingerprint
1927 * @cert: should contain a gnutls_x509_crt_t structure 1927 * @cert: should contain a MHD_gnutls_x509_crt_t structure
1928 * @algo: is a digest algorithm 1928 * @algo: is a digest algorithm
1929 * @buf: a pointer to a structure to hold the fingerprint (may be null) 1929 * @buf: a pointer to a structure to hold the fingerprint (may be null)
1930 * @sizeof_buf: initially holds the size of @buf 1930 * @sizeof_buf: initially holds the size of @buf
@@ -1939,14 +1939,14 @@ gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn,
1939 * with the required size. On success 0 is returned. 1939 * with the required size. On success 0 is returned.
1940 **/ 1940 **/
1941int 1941int
1942gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert, 1942MHD_gnutls_x509_crt_get_fingerprint (MHD_gnutls_x509_crt_t cert,
1943 enum MHD_GNUTLS_HashAlgorithm algo, 1943 enum MHD_GNUTLS_HashAlgorithm algo,
1944 void *buf, size_t * sizeof_buf) 1944 void *buf, size_t * sizeof_buf)
1945{ 1945{
1946 opaque *cert_buf; 1946 opaque *cert_buf;
1947 int cert_buf_size; 1947 int cert_buf_size;
1948 int result; 1948 int result;
1949 gnutls_datum_t tmp; 1949 MHD_gnutls_datum_t tmp;
1950 1950
1951 if (sizeof_buf == 0 || cert == NULL) 1951 if (sizeof_buf == 0 || cert == NULL)
1952 { 1952 {
@@ -1954,35 +1954,35 @@ gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert,
1954 } 1954 }
1955 1955
1956 cert_buf_size = 0; 1956 cert_buf_size = 0;
1957 asn1_der_coding (cert->cert, "", NULL, &cert_buf_size, NULL); 1957 MHD__asn1_der_coding (cert->cert, "", NULL, &cert_buf_size, NULL);
1958 1958
1959 cert_buf = gnutls_alloca (cert_buf_size); 1959 cert_buf = MHD_gnutls_alloca (cert_buf_size);
1960 if (cert_buf == NULL) 1960 if (cert_buf == NULL)
1961 { 1961 {
1962 gnutls_assert (); 1962 MHD_gnutls_assert ();
1963 return GNUTLS_E_MEMORY_ERROR; 1963 return GNUTLS_E_MEMORY_ERROR;
1964 } 1964 }
1965 1965
1966 result = asn1_der_coding (cert->cert, "", cert_buf, &cert_buf_size, NULL); 1966 result = MHD__asn1_der_coding (cert->cert, "", cert_buf, &cert_buf_size, NULL);
1967 1967
1968 if (result != ASN1_SUCCESS) 1968 if (result != ASN1_SUCCESS)
1969 { 1969 {
1970 gnutls_assert (); 1970 MHD_gnutls_assert ();
1971 gnutls_afree (cert_buf); 1971 MHD_gnutls_afree (cert_buf);
1972 return mhd_gtls_asn2err (result); 1972 return MHD_gtls_asn2err (result);
1973 } 1973 }
1974 1974
1975 tmp.data = cert_buf; 1975 tmp.data = cert_buf;
1976 tmp.size = cert_buf_size; 1976 tmp.size = cert_buf_size;
1977 1977
1978 result = MHD_gnutls_fingerprint (algo, &tmp, buf, sizeof_buf); 1978 result = MHD__gnutls_fingerprint (algo, &tmp, buf, sizeof_buf);
1979 gnutls_afree (cert_buf); 1979 MHD_gnutls_afree (cert_buf);
1980 1980
1981 return result; 1981 return result;
1982} 1982}
1983 1983
1984/** 1984/**
1985 * gnutls_x509_crt_export - This function will export the certificate 1985 * MHD_gnutls_x509_crt_export - This function will export the certificate
1986 * @cert: Holds the certificate 1986 * @cert: Holds the certificate
1987 * @format: the format of output params. One of PEM or DER. 1987 * @format: the format of output params. One of PEM or DER.
1988 * @output_data: will contain a certificate PEM or DER encoded 1988 * @output_data: will contain a certificate PEM or DER encoded
@@ -2002,82 +2002,82 @@ gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert,
2002 * returned, and 0 on success. 2002 * returned, and 0 on success.
2003 **/ 2003 **/
2004int 2004int
2005gnutls_x509_crt_export (gnutls_x509_crt_t cert, 2005MHD_gnutls_x509_crt_export (MHD_gnutls_x509_crt_t cert,
2006 gnutls_x509_crt_fmt_t format, 2006 MHD_gnutls_x509_crt_fmt_t format,
2007 void *output_data, size_t * output_data_size) 2007 void *output_data, size_t * output_data_size)
2008{ 2008{
2009 if (cert == NULL) 2009 if (cert == NULL)
2010 { 2010 {
2011 gnutls_assert (); 2011 MHD_gnutls_assert ();
2012 return GNUTLS_E_INVALID_REQUEST; 2012 return GNUTLS_E_INVALID_REQUEST;
2013 } 2013 }
2014 2014
2015 return _gnutls_x509_export_int (cert->cert, format, "CERTIFICATE", 2015 return MHD__gnutls_x509_export_int (cert->cert, format, "CERTIFICATE",
2016 output_data, output_data_size); 2016 output_data, output_data_size);
2017} 2017}
2018 2018
2019static int 2019static int
2020rsadsa_get_key_id (gnutls_x509_crt_t crt, 2020rsadsa_get_key_id (MHD_gnutls_x509_crt_t crt,
2021 int pk, 2021 int pk,
2022 unsigned char *output_data, size_t * output_data_size) 2022 unsigned char *output_data, size_t * output_data_size)
2023{ 2023{
2024 mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; 2024 mpi_t params[MAX_PUBLIC_PARAMS_SIZE];
2025 int params_size = MAX_PUBLIC_PARAMS_SIZE; 2025 int params_size = MAX_PUBLIC_PARAMS_SIZE;
2026 int i, result = 0; 2026 int i, result = 0;
2027 gnutls_datum_t der = { NULL, 2027 MHD_gnutls_datum_t der = { NULL,
2028 0 2028 0
2029 }; 2029 };
2030 GNUTLS_HASH_HANDLE hd; 2030 GNUTLS_HASH_HANDLE hd;
2031 2031
2032 result = _gnutls_x509_crt_get_mpis (crt, params, &params_size); 2032 result = MHD__gnutls_x509_crt_get_mpis (crt, params, &params_size);
2033 if (result < 0) 2033 if (result < 0)
2034 { 2034 {
2035 gnutls_assert (); 2035 MHD_gnutls_assert ();
2036 return result; 2036 return result;
2037 } 2037 }
2038 2038
2039 if (pk == MHD_GNUTLS_PK_RSA) 2039 if (pk == MHD_GNUTLS_PK_RSA)
2040 { 2040 {
2041 result = _gnutls_x509_write_rsa_params (params, params_size, &der); 2041 result = MHD__gnutls_x509_write_rsa_params (params, params_size, &der);
2042 if (result < 0) 2042 if (result < 0)
2043 { 2043 {
2044 gnutls_assert (); 2044 MHD_gnutls_assert ();
2045 goto cleanup; 2045 goto cleanup;
2046 } 2046 }
2047 } 2047 }
2048 else 2048 else
2049 return GNUTLS_E_INTERNAL_ERROR; 2049 return GNUTLS_E_INTERNAL_ERROR;
2050 2050
2051 hd = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1); 2051 hd = MHD_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
2052 if (hd == GNUTLS_HASH_FAILED) 2052 if (hd == GNUTLS_HASH_FAILED)
2053 { 2053 {
2054 gnutls_assert (); 2054 MHD_gnutls_assert ();
2055 result = GNUTLS_E_INTERNAL_ERROR; 2055 result = GNUTLS_E_INTERNAL_ERROR;
2056 goto cleanup; 2056 goto cleanup;
2057 } 2057 }
2058 2058
2059 mhd_gnutls_hash (hd, der.data, der.size); 2059 MHD_gnutls_hash (hd, der.data, der.size);
2060 2060
2061 mhd_gnutls_hash_deinit (hd, output_data); 2061 MHD_gnutls_hash_deinit (hd, output_data);
2062 *output_data_size = 20; 2062 *output_data_size = 20;
2063 2063
2064 result = 0; 2064 result = 0;
2065 2065
2066cleanup: 2066cleanup:
2067 2067
2068 _gnutls_free_datum (&der); 2068 MHD__gnutls_free_datum (&der);
2069 2069
2070 /* release all allocated MPIs 2070 /* release all allocated MPIs
2071 */ 2071 */
2072 for (i = 0; i < params_size; i++) 2072 for (i = 0; i < params_size; i++)
2073 { 2073 {
2074 mhd_gtls_mpi_release (&params[i]); 2074 MHD_gtls_mpi_release (&params[i]);
2075 } 2075 }
2076 return result; 2076 return result;
2077} 2077}
2078 2078
2079/** 2079/**
2080 * gnutls_x509_crt_get_key_id - Return unique ID of public key's parameters 2080 * MHD_gnutls_x509_crt_get_key_id - Return unique ID of public key's parameters
2081 * @crt: Holds the certificate 2081 * @crt: Holds the certificate
2082 * @flags: should be 0 for now 2082 * @flags: should be 0 for now
2083 * @output_data: will contain the key ID 2083 * @output_data: will contain the key ID
@@ -2097,31 +2097,31 @@ cleanup:
2097 * returned, and 0 on success. 2097 * returned, and 0 on success.
2098 **/ 2098 **/
2099int 2099int
2100gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt, 2100MHD_gnutls_x509_crt_get_key_id (MHD_gnutls_x509_crt_t crt,
2101 unsigned int flags, 2101 unsigned int flags,
2102 unsigned char *output_data, 2102 unsigned char *output_data,
2103 size_t * output_data_size) 2103 size_t * output_data_size)
2104{ 2104{
2105 int pk, result = 0; 2105 int pk, result = 0;
2106 gnutls_datum_t pubkey; 2106 MHD_gnutls_datum_t pubkey;
2107 2107
2108 if (crt == NULL) 2108 if (crt == NULL)
2109 { 2109 {
2110 gnutls_assert (); 2110 MHD_gnutls_assert ();
2111 return GNUTLS_E_INVALID_REQUEST; 2111 return GNUTLS_E_INVALID_REQUEST;
2112 } 2112 }
2113 2113
2114 if (*output_data_size < 20) 2114 if (*output_data_size < 20)
2115 { 2115 {
2116 gnutls_assert (); 2116 MHD_gnutls_assert ();
2117 *output_data_size = 20; 2117 *output_data_size = 20;
2118 return GNUTLS_E_SHORT_MEMORY_BUFFER; 2118 return GNUTLS_E_SHORT_MEMORY_BUFFER;
2119 } 2119 }
2120 2120
2121 pk = gnutls_x509_crt_get_pk_algorithm (crt, NULL); 2121 pk = MHD_gnutls_x509_crt_get_pk_algorithm (crt, NULL);
2122 if (pk < 0) 2122 if (pk < 0)
2123 { 2123 {
2124 gnutls_assert (); 2124 MHD_gnutls_assert ();
2125 return pk; 2125 return pk;
2126 } 2126 }
2127 2127
@@ -2136,34 +2136,34 @@ gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt,
2136 } 2136 }
2137 2137
2138 pubkey.size = 0; 2138 pubkey.size = 0;
2139 result = asn1_der_coding (crt->cert, "tbsCertificate.subjectPublicKeyInfo", 2139 result = MHD__asn1_der_coding (crt->cert, "tbsCertificate.subjectPublicKeyInfo",
2140 NULL, &pubkey.size, NULL); 2140 NULL, &pubkey.size, NULL);
2141 if (result != ASN1_MEM_ERROR) 2141 if (result != ASN1_MEM_ERROR)
2142 { 2142 {
2143 gnutls_assert (); 2143 MHD_gnutls_assert ();
2144 return mhd_gtls_asn2err (result); 2144 return MHD_gtls_asn2err (result);
2145 } 2145 }
2146 2146
2147 pubkey.data = gnutls_alloca (pubkey.size); 2147 pubkey.data = MHD_gnutls_alloca (pubkey.size);
2148 if (pubkey.data == NULL) 2148 if (pubkey.data == NULL)
2149 { 2149 {
2150 gnutls_assert (); 2150 MHD_gnutls_assert ();
2151 return GNUTLS_E_MEMORY_ERROR; 2151 return GNUTLS_E_MEMORY_ERROR;
2152 } 2152 }
2153 2153
2154 result = asn1_der_coding (crt->cert, "tbsCertificate.subjectPublicKeyInfo", 2154 result = MHD__asn1_der_coding (crt->cert, "tbsCertificate.subjectPublicKeyInfo",
2155 pubkey.data, &pubkey.size, NULL); 2155 pubkey.data, &pubkey.size, NULL);
2156 if (result != ASN1_SUCCESS) 2156 if (result != ASN1_SUCCESS)
2157 { 2157 {
2158 gnutls_assert (); 2158 MHD_gnutls_assert ();
2159 gnutls_afree (pubkey.data); 2159 MHD_gnutls_afree (pubkey.data);
2160 return mhd_gtls_asn2err (result); 2160 return MHD_gtls_asn2err (result);
2161 } 2161 }
2162 2162
2163 result = MHD_gnutls_fingerprint (MHD_GNUTLS_MAC_SHA1, &pubkey, output_data, 2163 result = MHD__gnutls_fingerprint (MHD_GNUTLS_MAC_SHA1, &pubkey, output_data,
2164 output_data_size); 2164 output_data_size);
2165 2165
2166 gnutls_afree (pubkey.data); 2166 MHD_gnutls_afree (pubkey.data);
2167 2167
2168 return result; 2168 return result;
2169} 2169}
@@ -2171,9 +2171,9 @@ gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt,
2171#ifdef ENABLE_PKI 2171#ifdef ENABLE_PKI
2172 2172
2173/** 2173/**
2174 * gnutls_x509_crt_check_revocation - This function checks if the given certificate is revoked 2174 * MHD_gnutls_x509_crt_check_revocation - This function checks if the given certificate is revoked
2175 * @cert: should contain a gnutls_x509_crt_t structure 2175 * @cert: should contain a MHD_gnutls_x509_crt_t structure
2176 * @crl_list: should contain a list of gnutls_x509_crl_t structures 2176 * @crl_list: should contain a list of MHD_gnutls_x509_crl_t structures
2177 * @crl_list_length: the length of the crl_list 2177 * @crl_list_length: the length of the crl_list
2178 * 2178 *
2179 * This function will return check if the given certificate is 2179 * This function will return check if the given certificate is
@@ -2183,19 +2183,19 @@ gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt,
2183 * negative value is returned on error. 2183 * negative value is returned on error.
2184 **/ 2184 **/
2185int 2185int
2186gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert, 2186MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert,
2187 const gnutls_x509_crl_t * crl_list, 2187 const MHD_gnutls_x509_crl_t * crl_list,
2188 int crl_list_length) 2188 int crl_list_length)
2189{ 2189{
2190 opaque serial[64]; 2190 opaque serial[64];
2191 opaque cert_serial[64]; 2191 opaque cert_serial[64];
2192 size_t serial_size, cert_serial_size; 2192 size_t serial_size, cert_serial_size;
2193 int ncerts, ret, i, j; 2193 int ncerts, ret, i, j;
2194 gnutls_datum_t dn1, dn2; 2194 MHD_gnutls_datum_t dn1, dn2;
2195 2195
2196 if (cert == NULL) 2196 if (cert == NULL)
2197 { 2197 {
2198 gnutls_assert (); 2198 MHD_gnutls_assert ();
2199 return GNUTLS_E_INVALID_REQUEST; 2199 return GNUTLS_E_INVALID_REQUEST;
2200 } 2200 }
2201 2201
@@ -2204,23 +2204,23 @@ gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert,
2204 2204
2205 /* Step 1. check if issuer's DN match 2205 /* Step 1. check if issuer's DN match
2206 */ 2206 */
2207 ret = _gnutls_x509_crl_get_raw_issuer_dn (crl_list[j], &dn1); 2207 ret = MHD__gnutls_x509_crl_get_raw_issuer_dn (crl_list[j], &dn1);
2208 if (ret < 0) 2208 if (ret < 0)
2209 { 2209 {
2210 gnutls_assert (); 2210 MHD_gnutls_assert ();
2211 return ret; 2211 return ret;
2212 } 2212 }
2213 2213
2214 ret = gnutls_x509_crt_get_raw_issuer_dn (cert, &dn2); 2214 ret = MHD_gnutls_x509_crt_get_raw_issuer_dn (cert, &dn2);
2215 if (ret < 0) 2215 if (ret < 0)
2216 { 2216 {
2217 gnutls_assert (); 2217 MHD_gnutls_assert ();
2218 return ret; 2218 return ret;
2219 } 2219 }
2220 2220
2221 ret = _gnutls_x509_compare_raw_dn (&dn1, &dn2); 2221 ret = MHD__gnutls_x509_compare_raw_dn (&dn1, &dn2);
2222 _gnutls_free_datum (&dn1); 2222 MHD__gnutls_free_datum (&dn1);
2223 _gnutls_free_datum (&dn2); 2223 MHD__gnutls_free_datum (&dn2);
2224 if (ret == 0) 2224 if (ret == 0)
2225 { 2225 {
2226 /* issuers do not match so don't even 2226 /* issuers do not match so don't even
@@ -2232,10 +2232,10 @@ gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert,
2232 /* Step 2. Read the certificate's serial number 2232 /* Step 2. Read the certificate's serial number
2233 */ 2233 */
2234 cert_serial_size = sizeof (cert_serial); 2234 cert_serial_size = sizeof (cert_serial);
2235 ret = gnutls_x509_crt_get_serial (cert, cert_serial, &cert_serial_size); 2235 ret = MHD_gnutls_x509_crt_get_serial (cert, cert_serial, &cert_serial_size);
2236 if (ret < 0) 2236 if (ret < 0)
2237 { 2237 {
2238 gnutls_assert (); 2238 MHD_gnutls_assert ();
2239 return ret; 2239 return ret;
2240 } 2240 }
2241 2241
@@ -2243,22 +2243,22 @@ gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert,
2243 * certificate serial we have. 2243 * certificate serial we have.
2244 */ 2244 */
2245 2245
2246 ncerts = gnutls_x509_crl_get_crt_count (crl_list[j]); 2246 ncerts = MHD_gnutls_x509_crl_get_crt_count (crl_list[j]);
2247 if (ncerts < 0) 2247 if (ncerts < 0)
2248 { 2248 {
2249 gnutls_assert (); 2249 MHD_gnutls_assert ();
2250 return ncerts; 2250 return ncerts;
2251 } 2251 }
2252 2252
2253 for (i = 0; i < ncerts; i++) 2253 for (i = 0; i < ncerts; i++)
2254 { 2254 {
2255 serial_size = sizeof (serial); 2255 serial_size = sizeof (serial);
2256 ret = gnutls_x509_crl_get_crt_serial (crl_list[j], i, serial, 2256 ret = MHD_gnutls_x509_crl_get_crt_serial (crl_list[j], i, serial,
2257 &serial_size, NULL); 2257 &serial_size, NULL);
2258 2258
2259 if (ret < 0) 2259 if (ret < 0)
2260 { 2260 {
2261 gnutls_assert (); 2261 MHD_gnutls_assert ();
2262 return ret; 2262 return ret;
2263 } 2263 }
2264 2264
@@ -2277,7 +2277,7 @@ gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert,
2277} 2277}
2278 2278
2279/** 2279/**
2280 * gnutls_x509_crt_verify_data - This function will verify the given signed data. 2280 * MHD_gnutls_x509_crt_verify_data - This function will verify the given signed data.
2281 * @crt: Holds the certificate 2281 * @crt: Holds the certificate
2282 * @flags: should be 0 for now 2282 * @flags: should be 0 for now
2283 * @data: holds the data to be signed 2283 * @data: holds the data to be signed
@@ -2290,23 +2290,23 @@ gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert,
2290 * success. 2290 * success.
2291 **/ 2291 **/
2292int 2292int
2293gnutls_x509_crt_verify_data (gnutls_x509_crt_t crt, 2293MHD_gnutls_x509_crt_verify_data (MHD_gnutls_x509_crt_t crt,
2294 unsigned int flags, 2294 unsigned int flags,
2295 const gnutls_datum_t * data, 2295 const MHD_gnutls_datum_t * data,
2296 const gnutls_datum_t * signature) 2296 const MHD_gnutls_datum_t * signature)
2297{ 2297{
2298 int result; 2298 int result;
2299 2299
2300 if (crt == NULL) 2300 if (crt == NULL)
2301 { 2301 {
2302 gnutls_assert (); 2302 MHD_gnutls_assert ();
2303 return GNUTLS_E_INVALID_REQUEST; 2303 return GNUTLS_E_INVALID_REQUEST;
2304 } 2304 }
2305 2305
2306 result = _gnutls_x509_verify_signature (data, signature, crt); 2306 result = MHD__gnutls_x509_verify_signature (data, signature, crt);
2307 if (result < 0) 2307 if (result < 0)
2308 { 2308 {
2309 gnutls_assert (); 2309 MHD_gnutls_assert ();
2310 return 0; 2310 return 0;
2311 } 2311 }
2312 2312
@@ -2314,8 +2314,8 @@ gnutls_x509_crt_verify_data (gnutls_x509_crt_t crt,
2314} 2314}
2315 2315
2316/** 2316/**
2317 * gnutls_x509_crt_get_crl_dist_points - This function returns the CRL distribution points 2317 * MHD_gnutls_x509_crt_get_crl_dist_points - This function returns the CRL distribution points
2318 * @cert: should contain a gnutls_x509_crt_t structure 2318 * @cert: should contain a MHD_gnutls_x509_crt_t structure
2319 * @seq: specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.) 2319 * @seq: specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.)
2320 * @ret: is the place where the distribution point will be copied to 2320 * @ret: is the place where the distribution point will be copied to
2321 * @ret_size: holds the size of ret. 2321 * @ret_size: holds the size of ret.
@@ -2342,13 +2342,13 @@ gnutls_x509_crt_verify_data (gnutls_x509_crt_t crt,
2342 * Returns %GNUTLS_E_SHORT_MEMORY_BUFFER and updates &@ret_size if 2342 * Returns %GNUTLS_E_SHORT_MEMORY_BUFFER and updates &@ret_size if
2343 * &@ret_size is not enough to hold the distribution point, or the 2343 * &@ret_size is not enough to hold the distribution point, or the
2344 * type of the distribution point if everything was ok. The type is 2344 * type of the distribution point if everything was ok. The type is
2345 * one of the enumerated %gnutls_x509_subject_alt_name_t. If the 2345 * one of the enumerated %MHD_gnutls_x509_subject_alt_name_t. If the
2346 * certificate does not have an Alternative name with the specified 2346 * certificate does not have an Alternative name with the specified
2347 * sequence number then %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is 2347 * sequence number then %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is
2348 * returned. 2348 * returned.
2349 **/ 2349 **/
2350int 2350int
2351gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert, 2351MHD_gnutls_x509_crt_get_crl_dist_points (MHD_gnutls_x509_crt_t cert,
2352 unsigned int seq, 2352 unsigned int seq,
2353 void *ret, 2353 void *ret,
2354 size_t * ret_size, 2354 size_t * ret_size,
@@ -2356,18 +2356,18 @@ gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert,
2356 unsigned int *critical) 2356 unsigned int *critical)
2357{ 2357{
2358 int result; 2358 int result;
2359 gnutls_datum_t dist_points = { NULL, 2359 MHD_gnutls_datum_t dist_points = { NULL,
2360 0 2360 0
2361 }; 2361 };
2362 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 2362 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
2363 char name[MAX_NAME_SIZE]; 2363 char name[MAX_NAME_SIZE];
2364 int len; 2364 int len;
2365 gnutls_x509_subject_alt_name_t type; 2365 MHD_gnutls_x509_subject_alt_name_t type;
2366 uint8_t reasons[2]; 2366 uint8_t reasons[2];
2367 2367
2368 if (cert == NULL) 2368 if (cert == NULL)
2369 { 2369 {
2370 gnutls_assert (); 2370 MHD_gnutls_assert ();
2371 return GNUTLS_E_INVALID_REQUEST; 2371 return GNUTLS_E_INVALID_REQUEST;
2372 } 2372 }
2373 2373
@@ -2379,7 +2379,7 @@ gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert,
2379 if (reason_flags) 2379 if (reason_flags)
2380 *reason_flags = 0; 2380 *reason_flags = 0;
2381 2381
2382 result = _gnutls_x509_crt_get_extension (cert, "2.5.29.31", 0, &dist_points, 2382 result = MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.31", 0, &dist_points,
2383 critical); 2383 critical);
2384 if (result < 0) 2384 if (result < 0)
2385 { 2385 {
@@ -2388,39 +2388,39 @@ gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert,
2388 2388
2389 if (dist_points.size == 0 || dist_points.data == NULL) 2389 if (dist_points.size == 0 || dist_points.data == NULL)
2390 { 2390 {
2391 gnutls_assert (); 2391 MHD_gnutls_assert ();
2392 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 2392 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
2393 } 2393 }
2394 2394
2395 result = 2395 result =
2396 asn1_create_element (_gnutls_get_pkix (), "PKIX1.CRLDistributionPoints", 2396 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.CRLDistributionPoints",
2397 &c2); 2397 &c2);
2398 if (result != ASN1_SUCCESS) 2398 if (result != ASN1_SUCCESS)
2399 { 2399 {
2400 gnutls_assert (); 2400 MHD_gnutls_assert ();
2401 _gnutls_free_datum (&dist_points); 2401 MHD__gnutls_free_datum (&dist_points);
2402 return mhd_gtls_asn2err (result); 2402 return MHD_gtls_asn2err (result);
2403 } 2403 }
2404 2404
2405 result = asn1_der_decoding (&c2, dist_points.data, dist_points.size, NULL); 2405 result = MHD__asn1_der_decoding (&c2, dist_points.data, dist_points.size, NULL);
2406 _gnutls_free_datum (&dist_points); 2406 MHD__gnutls_free_datum (&dist_points);
2407 2407
2408 if (result != ASN1_SUCCESS) 2408 if (result != ASN1_SUCCESS)
2409 { 2409 {
2410 gnutls_assert (); 2410 MHD_gnutls_assert ();
2411 asn1_delete_structure (&c2); 2411 MHD__asn1_delete_structure (&c2);
2412 return mhd_gtls_asn2err (result); 2412 return MHD_gtls_asn2err (result);
2413 } 2413 }
2414 2414
2415 /* Return the different names from the first CRLDistr. point. 2415 /* Return the different names from the first CRLDistr. point.
2416 * The whole thing is a mess. 2416 * The whole thing is a mess.
2417 */ 2417 */
2418 mhd_gtls_str_cpy (name, sizeof (name), "?1.distributionPoint.fullName"); 2418 MHD_gtls_str_cpy (name, sizeof (name), "?1.distributionPoint.fullName");
2419 2419
2420 result = parse_general_name (c2, name, seq, ret, ret_size, NULL, 0); 2420 result = parse_general_name (c2, name, seq, ret, ret_size, NULL, 0);
2421 if (result < 0) 2421 if (result < 0)
2422 { 2422 {
2423 asn1_delete_structure (&c2); 2423 MHD__asn1_delete_structure (&c2);
2424 return result; 2424 return result;
2425 } 2425 }
2426 2426
@@ -2430,18 +2430,18 @@ gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert,
2430 */ 2430 */
2431 if (reason_flags) 2431 if (reason_flags)
2432 { 2432 {
2433 mhd_gtls_str_cpy (name, sizeof (name), "?1.reasons"); 2433 MHD_gtls_str_cpy (name, sizeof (name), "?1.reasons");
2434 2434
2435 reasons[0] = reasons[1] = 0; 2435 reasons[0] = reasons[1] = 0;
2436 2436
2437 len = sizeof (reasons); 2437 len = sizeof (reasons);
2438 result = asn1_read_value (c2, name, reasons, &len); 2438 result = MHD__asn1_read_value (c2, name, reasons, &len);
2439 2439
2440 if (result != ASN1_VALUE_NOT_FOUND && result != ASN1_SUCCESS) 2440 if (result != ASN1_VALUE_NOT_FOUND && result != ASN1_SUCCESS)
2441 { 2441 {
2442 gnutls_assert (); 2442 MHD_gnutls_assert ();
2443 asn1_delete_structure (&c2); 2443 MHD__asn1_delete_structure (&c2);
2444 return mhd_gtls_asn2err (result); 2444 return MHD_gtls_asn2err (result);
2445 } 2445 }
2446 2446
2447 *reason_flags = reasons[0] | (reasons[1] << 8); 2447 *reason_flags = reasons[0] | (reasons[1] << 8);
@@ -2451,8 +2451,8 @@ gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert,
2451} 2451}
2452 2452
2453/** 2453/**
2454 * gnutls_x509_crt_get_key_purpose_oid - This function returns the Certificate's key purpose OIDs 2454 * MHD_gnutls_x509_crt_get_key_purpose_oid - This function returns the Certificate's key purpose OIDs
2455 * @cert: should contain a gnutls_x509_crt_t structure 2455 * @cert: should contain a MHD_gnutls_x509_crt_t structure
2456 * @indx: This specifies which OID to return. Use zero to get the first one. 2456 * @indx: This specifies which OID to return. Use zero to get the first one.
2457 * @oid: a pointer to a buffer to hold the OID (may be null) 2457 * @oid: a pointer to a buffer to hold the OID (may be null)
2458 * @sizeof_oid: initially holds the size of @oid 2458 * @sizeof_oid: initially holds the size of @oid
@@ -2469,7 +2469,7 @@ gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert,
2469 * with the required size. On success 0 is returned. 2469 * with the required size. On success 0 is returned.
2470 **/ 2470 **/
2471int 2471int
2472gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert, 2472MHD_gnutls_x509_crt_get_key_purpose_oid (MHD_gnutls_x509_crt_t cert,
2473 int indx, 2473 int indx,
2474 void *oid, 2474 void *oid,
2475 size_t * sizeof_oid, 2475 size_t * sizeof_oid,
@@ -2477,12 +2477,12 @@ gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert,
2477{ 2477{
2478 char tmpstr[MAX_NAME_SIZE]; 2478 char tmpstr[MAX_NAME_SIZE];
2479 int result, len; 2479 int result, len;
2480 gnutls_datum_t id; 2480 MHD_gnutls_datum_t id;
2481 ASN1_TYPE c2 = ASN1_TYPE_EMPTY; 2481 ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
2482 2482
2483 if (cert == NULL) 2483 if (cert == NULL)
2484 { 2484 {
2485 gnutls_assert (); 2485 MHD_gnutls_assert ();
2486 return GNUTLS_E_INVALID_REQUEST; 2486 return GNUTLS_E_INVALID_REQUEST;
2487 } 2487 }
2488 2488
@@ -2491,7 +2491,7 @@ gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert,
2491 else 2491 else
2492 *sizeof_oid = 0; 2492 *sizeof_oid = 0;
2493 2493
2494 if ((result = _gnutls_x509_crt_get_extension (cert, "2.5.29.37", 0, &id, 2494 if ((result = MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.37", 0, &id,
2495 critical)) < 0) 2495 critical)) < 0)
2496 { 2496 {
2497 return result; 2497 return result;
@@ -2499,27 +2499,27 @@ gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert,
2499 2499
2500 if (id.size == 0 || id.data == NULL) 2500 if (id.size == 0 || id.data == NULL)
2501 { 2501 {
2502 gnutls_assert (); 2502 MHD_gnutls_assert ();
2503 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; 2503 return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
2504 } 2504 }
2505 2505
2506 result = 2506 result =
2507 asn1_create_element (_gnutls_get_pkix (), "PKIX1.ExtKeyUsageSyntax", &c2); 2507 MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.ExtKeyUsageSyntax", &c2);
2508 if (result != ASN1_SUCCESS) 2508 if (result != ASN1_SUCCESS)
2509 { 2509 {
2510 gnutls_assert (); 2510 MHD_gnutls_assert ();
2511 _gnutls_free_datum (&id); 2511 MHD__gnutls_free_datum (&id);
2512 return mhd_gtls_asn2err (result); 2512 return MHD_gtls_asn2err (result);
2513 } 2513 }
2514 2514
2515 result = asn1_der_decoding (&c2, id.data, id.size, NULL); 2515 result = MHD__asn1_der_decoding (&c2, id.data, id.size, NULL);
2516 _gnutls_free_datum (&id); 2516 MHD__gnutls_free_datum (&id);
2517 2517
2518 if (result != ASN1_SUCCESS) 2518 if (result != ASN1_SUCCESS)
2519 { 2519 {
2520 gnutls_assert (); 2520 MHD_gnutls_assert ();
2521 asn1_delete_structure (&c2); 2521 MHD__asn1_delete_structure (&c2);
2522 return mhd_gtls_asn2err (result); 2522 return MHD_gtls_asn2err (result);
2523 } 2523 }
2524 2524
2525 indx++; 2525 indx++;
@@ -2528,10 +2528,10 @@ gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert,
2528 snprintf (tmpstr, sizeof (tmpstr), "?%u", indx); 2528 snprintf (tmpstr, sizeof (tmpstr), "?%u", indx);
2529 2529
2530 len = *sizeof_oid; 2530 len = *sizeof_oid;
2531 result = asn1_read_value (c2, tmpstr, oid, &len); 2531 result = MHD__asn1_read_value (c2, tmpstr, oid, &len);
2532 2532
2533 *sizeof_oid = len; 2533 *sizeof_oid = len;
2534 asn1_delete_structure (&c2); 2534 MHD__asn1_delete_structure (&c2);
2535 2535
2536 if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND) 2536 if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
2537 { 2537 {
@@ -2540,8 +2540,8 @@ gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert,
2540 2540
2541 if (result != ASN1_SUCCESS) 2541 if (result != ASN1_SUCCESS)
2542 { 2542 {
2543 gnutls_assert (); 2543 MHD_gnutls_assert ();
2544 return mhd_gtls_asn2err (result); 2544 return MHD_gtls_asn2err (result);
2545 } 2545 }
2546 2546
2547 return 0; 2547 return 0;
@@ -2549,20 +2549,20 @@ gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert,
2549} 2549}
2550 2550
2551/** 2551/**
2552 * gnutls_x509_crt_get_pk_rsa_raw - This function will export the RSA public key 2552 * MHD_gnutls_x509_crt_get_pk_rsa_raw - This function will export the RSA public key
2553 * @crt: Holds the certificate 2553 * @crt: Holds the certificate
2554 * @m: will hold the modulus 2554 * @m: will hold the modulus
2555 * @e: will hold the public exponent 2555 * @e: will hold the public exponent
2556 * 2556 *
2557 * This function will export the RSA public key's parameters found in 2557 * This function will export the RSA public key's parameters found in
2558 * the given structure. The new parameters will be allocated using 2558 * the given structure. The new parameters will be allocated using
2559 * gnutls_malloc() and will be stored in the appropriate datum. 2559 * MHD_gnutls_malloc() and will be stored in the appropriate datum.
2560 * 2560 *
2561 * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error. 2561 * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error.
2562 **/ 2562 **/
2563int 2563int
2564gnutls_x509_crt_get_pk_rsa_raw (gnutls_x509_crt_t crt, 2564MHD_gnutls_x509_crt_get_pk_rsa_raw (MHD_gnutls_x509_crt_t crt,
2565 gnutls_datum_t * m, gnutls_datum_t * e) 2565 MHD_gnutls_datum_t * m, MHD_gnutls_datum_t * e)
2566{ 2566{
2567 int ret; 2567 int ret;
2568 mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; 2568 mpi_t params[MAX_PUBLIC_PARAMS_SIZE];
@@ -2571,36 +2571,36 @@ gnutls_x509_crt_get_pk_rsa_raw (gnutls_x509_crt_t crt,
2571 2571
2572 if (crt == NULL) 2572 if (crt == NULL)
2573 { 2573 {
2574 gnutls_assert (); 2574 MHD_gnutls_assert ();
2575 return GNUTLS_E_INVALID_REQUEST; 2575 return GNUTLS_E_INVALID_REQUEST;
2576 } 2576 }
2577 2577
2578 ret = gnutls_x509_crt_get_pk_algorithm (crt, NULL); 2578 ret = MHD_gnutls_x509_crt_get_pk_algorithm (crt, NULL);
2579 if (ret != MHD_GNUTLS_PK_RSA) 2579 if (ret != MHD_GNUTLS_PK_RSA)
2580 { 2580 {
2581 gnutls_assert (); 2581 MHD_gnutls_assert ();
2582 return GNUTLS_E_INVALID_REQUEST; 2582 return GNUTLS_E_INVALID_REQUEST;
2583 } 2583 }
2584 2584
2585 ret = _gnutls_x509_crt_get_mpis (crt, params, &params_size); 2585 ret = MHD__gnutls_x509_crt_get_mpis (crt, params, &params_size);
2586 if (ret < 0) 2586 if (ret < 0)
2587 { 2587 {
2588 gnutls_assert (); 2588 MHD_gnutls_assert ();
2589 return ret; 2589 return ret;
2590 } 2590 }
2591 2591
2592 ret = mhd_gtls_mpi_dprint (m, params[0]); 2592 ret = MHD_gtls_mpi_dprint (m, params[0]);
2593 if (ret < 0) 2593 if (ret < 0)
2594 { 2594 {
2595 gnutls_assert (); 2595 MHD_gnutls_assert ();
2596 goto cleanup; 2596 goto cleanup;
2597 } 2597 }
2598 2598
2599 ret = mhd_gtls_mpi_dprint (e, params[1]); 2599 ret = MHD_gtls_mpi_dprint (e, params[1]);
2600 if (ret < 0) 2600 if (ret < 0)
2601 { 2601 {
2602 gnutls_assert (); 2602 MHD_gnutls_assert ();
2603 _gnutls_free_datum (m); 2603 MHD__gnutls_free_datum (m);
2604 goto cleanup; 2604 goto cleanup;
2605 } 2605 }
2606 2606
@@ -2608,13 +2608,13 @@ gnutls_x509_crt_get_pk_rsa_raw (gnutls_x509_crt_t crt,
2608 2608
2609cleanup:for (i = 0; i < params_size; i++) 2609cleanup:for (i = 0; i < params_size; i++)
2610 { 2610 {
2611 mhd_gtls_mpi_release (&params[i]); 2611 MHD_gtls_mpi_release (&params[i]);
2612 } 2612 }
2613 return ret; 2613 return ret;
2614} 2614}
2615 2615
2616/** 2616/**
2617 * gnutls_x509_crt_get_pk_dsa_raw - This function will export the DSA public key 2617 * MHD_gnutls_x509_crt_get_pk_dsa_raw - This function will export the DSA public key
2618 * @crt: Holds the certificate 2618 * @crt: Holds the certificate
2619 * @p: will hold the p 2619 * @p: will hold the p
2620 * @q: will hold the q 2620 * @q: will hold the q
@@ -2623,15 +2623,15 @@ cleanup:for (i = 0; i < params_size; i++)
2623 * 2623 *
2624 * This function will export the DSA public key's parameters found in 2624 * This function will export the DSA public key's parameters found in
2625 * the given certificate. The new parameters will be allocated using 2625 * the given certificate. The new parameters will be allocated using
2626 * gnutls_malloc() and will be stored in the appropriate datum. 2626 * MHD_gnutls_malloc() and will be stored in the appropriate datum.
2627 * 2627 *
2628 * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error. 2628 * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error.
2629 **/ 2629 **/
2630int 2630int
2631gnutls_x509_crt_get_pk_dsa_raw (gnutls_x509_crt_t crt, 2631MHD_gnutls_x509_crt_get_pk_dsa_raw (MHD_gnutls_x509_crt_t crt,
2632 gnutls_datum_t * p, 2632 MHD_gnutls_datum_t * p,
2633 gnutls_datum_t * q, 2633 MHD_gnutls_datum_t * q,
2634 gnutls_datum_t * g, gnutls_datum_t * y) 2634 MHD_gnutls_datum_t * g, MHD_gnutls_datum_t * y)
2635{ 2635{
2636 int ret; 2636 int ret;
2637 mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; 2637 mpi_t params[MAX_PUBLIC_PARAMS_SIZE];
@@ -2640,54 +2640,54 @@ gnutls_x509_crt_get_pk_dsa_raw (gnutls_x509_crt_t crt,
2640 2640
2641 if (crt == NULL) 2641 if (crt == NULL)
2642 { 2642 {
2643 gnutls_assert (); 2643 MHD_gnutls_assert ();
2644 return GNUTLS_E_INVALID_REQUEST; 2644 return GNUTLS_E_INVALID_REQUEST;
2645 } 2645 }
2646 2646
2647 ret = gnutls_x509_crt_get_pk_algorithm (crt, NULL); 2647 ret = MHD_gnutls_x509_crt_get_pk_algorithm (crt, NULL);
2648 2648
2649 ret = _gnutls_x509_crt_get_mpis (crt, params, &params_size); 2649 ret = MHD__gnutls_x509_crt_get_mpis (crt, params, &params_size);
2650 if (ret < 0) 2650 if (ret < 0)
2651 { 2651 {
2652 gnutls_assert (); 2652 MHD_gnutls_assert ();
2653 return ret; 2653 return ret;
2654 } 2654 }
2655 2655
2656 /* P */ 2656 /* P */
2657 ret = mhd_gtls_mpi_dprint (p, params[0]); 2657 ret = MHD_gtls_mpi_dprint (p, params[0]);
2658 if (ret < 0) 2658 if (ret < 0)
2659 { 2659 {
2660 gnutls_assert (); 2660 MHD_gnutls_assert ();
2661 goto cleanup; 2661 goto cleanup;
2662 } 2662 }
2663 2663
2664 /* Q */ 2664 /* Q */
2665 ret = mhd_gtls_mpi_dprint (q, params[1]); 2665 ret = MHD_gtls_mpi_dprint (q, params[1]);
2666 if (ret < 0) 2666 if (ret < 0)
2667 { 2667 {
2668 gnutls_assert (); 2668 MHD_gnutls_assert ();
2669 _gnutls_free_datum (p); 2669 MHD__gnutls_free_datum (p);
2670 goto cleanup; 2670 goto cleanup;
2671 } 2671 }
2672 2672
2673 /* G */ 2673 /* G */
2674 ret = mhd_gtls_mpi_dprint (g, params[2]); 2674 ret = MHD_gtls_mpi_dprint (g, params[2]);
2675 if (ret < 0) 2675 if (ret < 0)
2676 { 2676 {
2677 gnutls_assert (); 2677 MHD_gnutls_assert ();
2678 _gnutls_free_datum (p); 2678 MHD__gnutls_free_datum (p);
2679 _gnutls_free_datum (q); 2679 MHD__gnutls_free_datum (q);
2680 goto cleanup; 2680 goto cleanup;
2681 } 2681 }
2682 2682
2683 /* Y */ 2683 /* Y */
2684 ret = mhd_gtls_mpi_dprint (y, params[3]); 2684 ret = MHD_gtls_mpi_dprint (y, params[3]);
2685 if (ret < 0) 2685 if (ret < 0)
2686 { 2686 {
2687 gnutls_assert (); 2687 MHD_gnutls_assert ();
2688 _gnutls_free_datum (p); 2688 MHD__gnutls_free_datum (p);
2689 _gnutls_free_datum (g); 2689 MHD__gnutls_free_datum (g);
2690 _gnutls_free_datum (q); 2690 MHD__gnutls_free_datum (q);
2691 goto cleanup; 2691 goto cleanup;
2692 } 2692 }
2693 2693
@@ -2695,7 +2695,7 @@ gnutls_x509_crt_get_pk_dsa_raw (gnutls_x509_crt_t crt,
2695 2695
2696cleanup:for (i = 0; i < params_size; i++) 2696cleanup:for (i = 0; i < params_size; i++)
2697 { 2697 {
2698 mhd_gtls_mpi_release (&params[i]); 2698 MHD_gtls_mpi_release (&params[i]);
2699 } 2699 }
2700 return ret; 2700 return ret;
2701 2701
@@ -2704,15 +2704,15 @@ cleanup:for (i = 0; i < params_size; i++)
2704#endif 2704#endif
2705 2705
2706/** 2706/**
2707 * gnutls_x509_crt_list_import - This function will import a PEM encoded certificate list 2707 * MHD_gnutls_x509_crt_list_import - This function will import a PEM encoded certificate list
2708 * @certs: The structures to store the parsed certificate. Must not be initialized. 2708 * @certs: The structures to store the parsed certificate. Must not be initialized.
2709 * @cert_max: Initially must hold the maximum number of certs. It will be updated with the number of certs available. 2709 * @cert_max: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
2710 * @data: The PEM encoded certificate. 2710 * @data: The PEM encoded certificate.
2711 * @format: One of DER or PEM. 2711 * @format: One of DER or PEM.
2712 * @flags: must be zero or an OR'd sequence of gnutls_certificate_import_flags. 2712 * @flags: must be zero or an OR'd sequence of MHD_gnutls_certificate_import_flags.
2713 * 2713 *
2714 * This function will convert the given PEM encoded certificate list 2714 * This function will convert the given PEM encoded certificate list
2715 * to the native gnutls_x509_crt_t format. The output will be stored 2715 * to the native MHD_gnutls_x509_crt_t format. The output will be stored
2716 * in @certs. They will be automatically initialized. 2716 * in @certs. They will be automatically initialized.
2717 * 2717 *
2718 * If the Certificate is PEM encoded it should have a header of "X509 2718 * If the Certificate is PEM encoded it should have a header of "X509
@@ -2721,14 +2721,14 @@ cleanup:for (i = 0; i < params_size; i++)
2721 * Returns: the number of certificates read or a negative error value. 2721 * Returns: the number of certificates read or a negative error value.
2722 **/ 2722 **/
2723int 2723int
2724gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs, 2724MHD_gnutls_x509_crt_list_import (MHD_gnutls_x509_crt_t * certs,
2725 unsigned int *cert_max, 2725 unsigned int *cert_max,
2726 const gnutls_datum_t * data, 2726 const MHD_gnutls_datum_t * data,
2727 gnutls_x509_crt_fmt_t format, unsigned int flags) 2727 MHD_gnutls_x509_crt_fmt_t format, unsigned int flags)
2728{ 2728{
2729 int size; 2729 int size;
2730 const char *ptr; 2730 const char *ptr;
2731 gnutls_datum_t tmp; 2731 MHD_gnutls_datum_t tmp;
2732 int ret, nocopy = 0; 2732 int ret, nocopy = 0;
2733 unsigned int count = 0, j; 2733 unsigned int count = 0, j;
2734 2734
@@ -2742,17 +2742,17 @@ gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs,
2742 2742
2743 count = 1; /* import only the first one */ 2743 count = 1; /* import only the first one */
2744 2744
2745 ret = gnutls_x509_crt_init (&certs[0]); 2745 ret = MHD_gnutls_x509_crt_init (&certs[0]);
2746 if (ret < 0) 2746 if (ret < 0)
2747 { 2747 {
2748 gnutls_assert (); 2748 MHD_gnutls_assert ();
2749 goto error; 2749 goto error;
2750 } 2750 }
2751 2751
2752 ret = gnutls_x509_crt_import (certs[0], data, format); 2752 ret = MHD_gnutls_x509_crt_import (certs[0], data, format);
2753 if (ret < 0) 2753 if (ret < 0)
2754 { 2754 {
2755 gnutls_assert (); 2755 MHD_gnutls_assert ();
2756 goto error; 2756 goto error;
2757 } 2757 }
2758 2758
@@ -2762,15 +2762,15 @@ gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs,
2762 2762
2763 /* move to the certificate 2763 /* move to the certificate
2764 */ 2764 */
2765 ptr = memmem (data->data, data->size, 2765 ptr = MHD_memmem (data->data, data->size,
2766 PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1); 2766 PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
2767 if (ptr == NULL) 2767 if (ptr == NULL)
2768 ptr = memmem (data->data, data->size, 2768 ptr = MHD_memmem (data->data, data->size,
2769 PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1); 2769 PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1);
2770 2770
2771 if (ptr == NULL) 2771 if (ptr == NULL)
2772 { 2772 {
2773 gnutls_assert (); 2773 MHD_gnutls_assert ();
2774 return GNUTLS_E_BASE64_DECODING_ERROR; 2774 return GNUTLS_E_BASE64_DECODING_ERROR;
2775 } 2775 }
2776 size = data->size - (ptr - (char *) data->data); 2776 size = data->size - (ptr - (char *) data->data);
@@ -2789,10 +2789,10 @@ gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs,
2789 2789
2790 if (!nocopy) 2790 if (!nocopy)
2791 { 2791 {
2792 ret = gnutls_x509_crt_init (&certs[count]); 2792 ret = MHD_gnutls_x509_crt_init (&certs[count]);
2793 if (ret < 0) 2793 if (ret < 0)
2794 { 2794 {
2795 gnutls_assert (); 2795 MHD_gnutls_assert ();
2796 goto error; 2796 goto error;
2797 } 2797 }
2798 2798
@@ -2800,10 +2800,10 @@ gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs,
2800 tmp.size = size; 2800 tmp.size = size;
2801 2801
2802 ret = 2802 ret =
2803 gnutls_x509_crt_import (certs[count], &tmp, GNUTLS_X509_FMT_PEM); 2803 MHD_gnutls_x509_crt_import (certs[count], &tmp, GNUTLS_X509_FMT_PEM);
2804 if (ret < 0) 2804 if (ret < 0)
2805 { 2805 {
2806 gnutls_assert (); 2806 MHD_gnutls_assert ();
2807 goto error; 2807 goto error;
2808 } 2808 }
2809 } 2809 }
@@ -2819,10 +2819,10 @@ gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs,
2819 { 2819 {
2820 char *ptr2; 2820 char *ptr2;
2821 2821
2822 ptr2 = memmem (ptr, size, PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1); 2822 ptr2 = MHD_memmem (ptr, size, PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
2823 if (ptr2 == NULL) 2823 if (ptr2 == NULL)
2824 ptr2 = 2824 ptr2 =
2825 memmem (ptr, size, PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1); 2825 MHD_memmem (ptr, size, PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1);
2826 2826
2827 ptr = ptr2; 2827 ptr = ptr2;
2828 } 2828 }
@@ -2841,6 +2841,6 @@ gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs,
2841 return GNUTLS_E_SHORT_MEMORY_BUFFER; 2841 return GNUTLS_E_SHORT_MEMORY_BUFFER;
2842 2842
2843error:for (j = 0; j < count; j++) 2843error:for (j = 0; j < count; j++)
2844 gnutls_x509_crt_deinit (certs[j]); 2844 MHD_gnutls_x509_crt_deinit (certs[j]);
2845 return ret; 2845 return ret;
2846} 2846}
diff --git a/src/daemon/https/x509/x509.h b/src/daemon/https/x509/x509.h
index d718767a..90e2aa8c 100644
--- a/src/daemon/https/x509/x509.h
+++ b/src/daemon/https/x509/x509.h
@@ -78,67 +78,67 @@ extern "C"
78 78
79/* Certificate handling functions. 79/* Certificate handling functions.
80 */ 80 */
81 typedef enum gnutls_certificate_import_flags 81 typedef enum MHD_gnutls_certificate_import_flags
82 { 82 {
83 /* Fail if the certificates in the buffer are more than the space 83 /* Fail if the certificates in the buffer are more than the space
84 * allocated for certificates. The error code will be 84 * allocated for certificates. The error code will be
85 * GNUTLS_E_SHORT_MEMORY_BUFFER. 85 * GNUTLS_E_SHORT_MEMORY_BUFFER.
86 */ 86 */
87 GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED = 1 87 GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED = 1
88 } gnutls_certificate_import_flags; 88 } MHD_gnutls_certificate_import_flags;
89 89
90 int gnutls_x509_crt_init (gnutls_x509_crt_t * cert); 90 int MHD_gnutls_x509_crt_init (MHD_gnutls_x509_crt_t * cert);
91 void gnutls_x509_crt_deinit (gnutls_x509_crt_t cert); 91 void MHD_gnutls_x509_crt_deinit (MHD_gnutls_x509_crt_t cert);
92 int gnutls_x509_crt_import (gnutls_x509_crt_t cert, 92 int MHD_gnutls_x509_crt_import (MHD_gnutls_x509_crt_t cert,
93 const gnutls_datum_t * data, 93 const MHD_gnutls_datum_t * data,
94 gnutls_x509_crt_fmt_t format); 94 MHD_gnutls_x509_crt_fmt_t format);
95 int gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs, 95 int MHD_gnutls_x509_crt_list_import (MHD_gnutls_x509_crt_t * certs,
96 unsigned int *cert_max, 96 unsigned int *cert_max,
97 const gnutls_datum_t * data, 97 const MHD_gnutls_datum_t * data,
98 gnutls_x509_crt_fmt_t format, 98 MHD_gnutls_x509_crt_fmt_t format,
99 unsigned int flags); 99 unsigned int flags);
100 int gnutls_x509_crt_export (gnutls_x509_crt_t cert, 100 int MHD_gnutls_x509_crt_export (MHD_gnutls_x509_crt_t cert,
101 gnutls_x509_crt_fmt_t format, 101 MHD_gnutls_x509_crt_fmt_t format,
102 void *output_data, size_t * output_data_size); 102 void *output_data, size_t * output_data_size);
103 int gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t cert, 103 int MHD_gnutls_x509_crt_get_issuer_dn (MHD_gnutls_x509_crt_t cert,
104 char *buf, size_t * sizeof_buf); 104 char *buf, size_t * sizeof_buf);
105 int gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t cert, 105 int MHD_gnutls_x509_crt_get_issuer_dn_oid (MHD_gnutls_x509_crt_t cert,
106 int indx, 106 int indx,
107 void *oid, size_t * sizeof_oid); 107 void *oid, size_t * sizeof_oid);
108 int gnutls_x509_crt_get_issuer_dn_by_oid (gnutls_x509_crt_t cert, 108 int MHD_gnutls_x509_crt_get_issuer_dn_by_oid (MHD_gnutls_x509_crt_t cert,
109 const char *oid, 109 const char *oid,
110 int indx, 110 int indx,
111 unsigned int raw_flag, 111 unsigned int raw_flag,
112 void *buf, size_t * sizeof_buf); 112 void *buf, size_t * sizeof_buf);
113 int gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert, 113 int MHD_gnutls_x509_crt_get_dn (MHD_gnutls_x509_crt_t cert,
114 char *buf, size_t * sizeof_buf); 114 char *buf, size_t * sizeof_buf);
115 int gnutls_x509_crt_get_dn_oid (gnutls_x509_crt_t cert, 115 int MHD_gnutls_x509_crt_get_dn_oid (MHD_gnutls_x509_crt_t cert,
116 int indx, void *oid, size_t * sizeof_oid); 116 int indx, void *oid, size_t * sizeof_oid);
117 int gnutls_x509_crt_get_dn_by_oid (gnutls_x509_crt_t cert, 117 int MHD_gnutls_x509_crt_get_dn_by_oid (MHD_gnutls_x509_crt_t cert,
118 const char *oid, 118 const char *oid,
119 int indx, 119 int indx,
120 unsigned int raw_flag, 120 unsigned int raw_flag,
121 void *buf, size_t * sizeof_buf); 121 void *buf, size_t * sizeof_buf);
122 int gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert, 122 int MHD_gnutls_x509_crt_check_hostname (MHD_gnutls_x509_crt_t cert,
123 const char *hostname); 123 const char *hostname);
124 124
125 int gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t cert); 125 int MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t cert);
126 int gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert, 126 int MHD_gnutls_x509_crt_get_signature (MHD_gnutls_x509_crt_t cert,
127 char *sig, size_t * sizeof_sig); 127 char *sig, size_t * sizeof_sig);
128 int gnutls_x509_crt_get_version (gnutls_x509_crt_t cert); 128 int MHD_gnutls_x509_crt_get_version (MHD_gnutls_x509_crt_t cert);
129 int gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt, 129 int MHD_gnutls_x509_crt_get_key_id (MHD_gnutls_x509_crt_t crt,
130 unsigned int flags, 130 unsigned int flags,
131 unsigned char *output_data, 131 unsigned char *output_data,
132 size_t * output_data_size); 132 size_t * output_data_size);
133 133
134 int gnutls_x509_crt_set_authority_key_id (gnutls_x509_crt_t cert, 134 int MHD_gnutls_x509_crt_set_authority_key_id (MHD_gnutls_x509_crt_t cert,
135 const void *id, size_t id_size); 135 const void *id, size_t id_size);
136 int gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert, 136 int MHD_gnutls_x509_crt_get_authority_key_id (MHD_gnutls_x509_crt_t cert,
137 void *ret, 137 void *ret,
138 size_t * ret_size, 138 size_t * ret_size,
139 unsigned int *critical); 139 unsigned int *critical);
140 140
141 int gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert, 141 int MHD_gnutls_x509_crt_get_subject_key_id (MHD_gnutls_x509_crt_t cert,
142 void *ret, 142 void *ret,
143 size_t * ret_size, 143 size_t * ret_size,
144 unsigned int *critical); 144 unsigned int *critical);
@@ -153,79 +153,79 @@ extern "C"
153#define GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN 1 153#define GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN 1
154#define GNUTLS_CRL_REASON_AA_COMPROMISE 32768 154#define GNUTLS_CRL_REASON_AA_COMPROMISE 32768
155 155
156 int gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert, 156 int MHD_gnutls_x509_crt_get_crl_dist_points (MHD_gnutls_x509_crt_t cert,
157 unsigned int seq, 157 unsigned int seq,
158 void *ret, 158 void *ret,
159 size_t * ret_size, 159 size_t * ret_size,
160 unsigned int *reason_flags, 160 unsigned int *reason_flags,
161 unsigned int *critical); 161 unsigned int *critical);
162 int gnutls_x509_crt_set_crl_dist_points (gnutls_x509_crt_t crt, 162 int MHD_gnutls_x509_crt_set_crl_dist_points (MHD_gnutls_x509_crt_t crt,
163 gnutls_x509_subject_alt_name_t 163 MHD_gnutls_x509_subject_alt_name_t
164 type, 164 type,
165 const void *data_string, 165 const void *data_string,
166 unsigned int reason_flags); 166 unsigned int reason_flags);
167 int gnutls_x509_crt_cpy_crl_dist_points (gnutls_x509_crt_t dst, 167 int MHD_gnutls_x509_crt_cpy_crl_dist_points (MHD_gnutls_x509_crt_t dst,
168 gnutls_x509_crt_t src); 168 MHD_gnutls_x509_crt_t src);
169 169
170 time_t gnutls_x509_crt_get_activation_time (gnutls_x509_crt_t cert); 170 time_t MHD_gnutls_x509_crt_get_activation_time (MHD_gnutls_x509_crt_t cert);
171 time_t gnutls_x509_crt_get_expiration_time (gnutls_x509_crt_t cert); 171 time_t MHD_gnutls_x509_crt_get_expiration_time (MHD_gnutls_x509_crt_t cert);
172 int gnutls_x509_crt_get_serial (gnutls_x509_crt_t cert, 172 int MHD_gnutls_x509_crt_get_serial (MHD_gnutls_x509_crt_t cert,
173 void *result, size_t * result_size); 173 void *result, size_t * result_size);
174 174
175 int gnutls_x509_crt_get_pk_algorithm (gnutls_x509_crt_t cert, 175 int MHD_gnutls_x509_crt_get_pk_algorithm (MHD_gnutls_x509_crt_t cert,
176 unsigned int *bits); 176 unsigned int *bits);
177 int gnutls_x509_crt_get_pk_rsa_raw (gnutls_x509_crt_t crt, 177 int MHD_gnutls_x509_crt_get_pk_rsa_raw (MHD_gnutls_x509_crt_t crt,
178 gnutls_datum_t * m, gnutls_datum_t * e); 178 MHD_gnutls_datum_t * m, MHD_gnutls_datum_t * e);
179 int gnutls_x509_crt_get_pk_dsa_raw (gnutls_x509_crt_t crt, 179 int MHD_gnutls_x509_crt_get_pk_dsa_raw (MHD_gnutls_x509_crt_t crt,
180 gnutls_datum_t * p, 180 MHD_gnutls_datum_t * p,
181 gnutls_datum_t * q, 181 MHD_gnutls_datum_t * q,
182 gnutls_datum_t * g, gnutls_datum_t * y); 182 MHD_gnutls_datum_t * g, MHD_gnutls_datum_t * y);
183 183
184 int gnutls_x509_crt_get_subject_alt_name (gnutls_x509_crt_t cert, 184 int MHD_gnutls_x509_crt_get_subject_alt_name (MHD_gnutls_x509_crt_t cert,
185 unsigned int seq, 185 unsigned int seq,
186 void *ret, 186 void *ret,
187 size_t * ret_size, 187 size_t * ret_size,
188 unsigned int *critical); 188 unsigned int *critical);
189 int gnutls_x509_crt_get_subject_alt_name2 (gnutls_x509_crt_t cert, 189 int MHD_gnutls_x509_crt_get_subject_alt_name2 (MHD_gnutls_x509_crt_t cert,
190 unsigned int seq, 190 unsigned int seq,
191 void *ret, 191 void *ret,
192 size_t * ret_size, 192 size_t * ret_size,
193 unsigned int *ret_type, 193 unsigned int *ret_type,
194 unsigned int *critical); 194 unsigned int *critical);
195 195
196 int gnutls_x509_crt_get_subject_alt_othername_oid (gnutls_x509_crt_t cert, 196 int MHD_gnutls_x509_crt_get_subject_alt_othername_oid (MHD_gnutls_x509_crt_t cert,
197 unsigned int seq, 197 unsigned int seq,
198 void *ret, 198 void *ret,
199 size_t * ret_size); 199 size_t * ret_size);
200 200
201 int gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t cert, 201 int MHD_gnutls_x509_crt_get_ca_status (MHD_gnutls_x509_crt_t cert,
202 unsigned int *critical); 202 unsigned int *critical);
203 int gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert, 203 int MHD_gnutls_x509_crt_get_basic_constraints (MHD_gnutls_x509_crt_t cert,
204 unsigned int *critical, 204 unsigned int *critical,
205 int *ca, int *pathlen); 205 int *ca, int *pathlen);
206 206
207/* The key_usage flags are defined in gnutls.h. They are the 207/* The key_usage flags are defined in gnutls.h. They are the
208 * GNUTLS_KEY_* definitions. 208 * GNUTLS_KEY_* definitions.
209 */ 209 */
210 int gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert, 210 int MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert,
211 unsigned int *key_usage, 211 unsigned int *key_usage,
212 unsigned int *critical); 212 unsigned int *critical);
213 int gnutls_x509_crt_set_key_usage (gnutls_x509_crt_t crt, 213 int MHD_gnutls_x509_crt_set_key_usage (MHD_gnutls_x509_crt_t crt,
214 unsigned int usage); 214 unsigned int usage);
215 215
216 int gnutls_x509_crt_get_proxy (gnutls_x509_crt_t cert, 216 int MHD_gnutls_x509_crt_get_proxy (MHD_gnutls_x509_crt_t cert,
217 unsigned int *critical, 217 unsigned int *critical,
218 int *pathlen, 218 int *pathlen,
219 char **policyLanguage, 219 char **policyLanguage,
220 char **policy, size_t * sizeof_policy); 220 char **policy, size_t * sizeof_policy);
221 221
222 int gnutls_x509_dn_oid_known (const char *oid); 222 int MHD_gnutls_x509_dn_oid_known (const char *oid);
223 223
224/* Read extensions by OID. */ 224/* Read extensions by OID. */
225 int gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, 225 int MHD_gnutls_x509_crt_get_extension_oid (MHD_gnutls_x509_crt_t cert,
226 int indx, 226 int indx,
227 void *oid, size_t * sizeof_oid); 227 void *oid, size_t * sizeof_oid);
228 int gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t cert, 228 int MHD_gnutls_x509_crt_get_extension_by_oid (MHD_gnutls_x509_crt_t cert,
229 const char *oid, 229 const char *oid,
230 int indx, 230 int indx,
231 void *buf, 231 void *buf,
@@ -233,15 +233,15 @@ extern "C"
233 unsigned int *critical); 233 unsigned int *critical);
234 234
235/* Read extensions by sequence number. */ 235/* Read extensions by sequence number. */
236 int gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert, 236 int MHD_gnutls_x509_crt_get_extension_info (MHD_gnutls_x509_crt_t cert,
237 int indx, 237 int indx,
238 void *oid, 238 void *oid,
239 size_t * sizeof_oid, int *critical); 239 size_t * sizeof_oid, int *critical);
240 int gnutls_x509_crt_get_extension_data (gnutls_x509_crt_t cert, 240 int MHD_gnutls_x509_crt_get_extension_data (MHD_gnutls_x509_crt_t cert,
241 int indx, 241 int indx,
242 void *data, size_t * sizeof_data); 242 void *data, size_t * sizeof_data);
243 243
244 int gnutls_x509_crt_set_extension_by_oid (gnutls_x509_crt_t crt, 244 int MHD_gnutls_x509_crt_set_extension_by_oid (MHD_gnutls_x509_crt_t crt,
245 const char *oid, 245 const char *oid,
246 const void *buf, 246 const void *buf,
247 size_t sizeof_buf, 247 size_t sizeof_buf,
@@ -249,207 +249,207 @@ extern "C"
249 249
250/* X.509 Certificate writing. 250/* X.509 Certificate writing.
251 */ 251 */
252 int gnutls_x509_crt_set_dn_by_oid (gnutls_x509_crt_t crt, 252 int MHD_gnutls_x509_crt_set_dn_by_oid (MHD_gnutls_x509_crt_t crt,
253 const char *oid, 253 const char *oid,
254 unsigned int raw_flag, 254 unsigned int raw_flag,
255 const void *name, 255 const void *name,
256 unsigned int sizeof_name); 256 unsigned int sizeof_name);
257 int gnutls_x509_crt_set_issuer_dn_by_oid (gnutls_x509_crt_t crt, 257 int MHD_gnutls_x509_crt_set_issuer_dn_by_oid (MHD_gnutls_x509_crt_t crt,
258 const char *oid, 258 const char *oid,
259 unsigned int raw_flag, 259 unsigned int raw_flag,
260 const void *name, 260 const void *name,
261 unsigned int sizeof_name); 261 unsigned int sizeof_name);
262 int gnutls_x509_crt_set_version (gnutls_x509_crt_t crt, 262 int MHD_gnutls_x509_crt_set_version (MHD_gnutls_x509_crt_t crt,
263 unsigned int version); 263 unsigned int version);
264 int gnutls_x509_crt_set_key (gnutls_x509_crt_t crt, 264 int MHD_gnutls_x509_crt_set_key (MHD_gnutls_x509_crt_t crt,
265 gnutls_x509_privkey_t key); 265 MHD_gnutls_x509_privkey_t key);
266 int gnutls_x509_crt_set_ca_status (gnutls_x509_crt_t crt, unsigned int ca); 266 int MHD_gnutls_x509_crt_set_ca_status (MHD_gnutls_x509_crt_t crt, unsigned int ca);
267 int gnutls_x509_crt_set_basic_constraints (gnutls_x509_crt_t crt, 267 int MHD_gnutls_x509_crt_set_basic_constraints (MHD_gnutls_x509_crt_t crt,
268 unsigned int ca, 268 unsigned int ca,
269 int pathLenConstraint); 269 int pathLenConstraint);
270 int gnutls_x509_crt_set_subject_alternative_name (gnutls_x509_crt_t crt, 270 int MHD_gnutls_x509_crt_set_subject_alternative_name (MHD_gnutls_x509_crt_t crt,
271 gnutls_x509_subject_alt_name_t 271 MHD_gnutls_x509_subject_alt_name_t
272 type, 272 type,
273 const char *data_string); 273 const char *data_string);
274 int gnutls_x509_crt_sign (gnutls_x509_crt_t crt, 274 int MHD_gnutls_x509_crt_sign (MHD_gnutls_x509_crt_t crt,
275 gnutls_x509_crt_t issuer, 275 MHD_gnutls_x509_crt_t issuer,
276 gnutls_x509_privkey_t issuer_key); 276 MHD_gnutls_x509_privkey_t issuer_key);
277 int gnutls_x509_crt_sign2 (gnutls_x509_crt_t crt, 277 int MHD_gnutls_x509_crt_sign2 (MHD_gnutls_x509_crt_t crt,
278 gnutls_x509_crt_t issuer, 278 MHD_gnutls_x509_crt_t issuer,
279 gnutls_x509_privkey_t issuer_key, 279 MHD_gnutls_x509_privkey_t issuer_key,
280 enum MHD_GNUTLS_HashAlgorithm, 280 enum MHD_GNUTLS_HashAlgorithm,
281 unsigned int flags); 281 unsigned int flags);
282 int gnutls_x509_crt_set_activation_time (gnutls_x509_crt_t cert, 282 int MHD_gnutls_x509_crt_set_activation_time (MHD_gnutls_x509_crt_t cert,
283 time_t act_time); 283 time_t act_time);
284 int gnutls_x509_crt_set_expiration_time (gnutls_x509_crt_t cert, 284 int MHD_gnutls_x509_crt_set_expiration_time (MHD_gnutls_x509_crt_t cert,
285 time_t exp_time); 285 time_t exp_time);
286 int gnutls_x509_crt_set_serial (gnutls_x509_crt_t cert, 286 int MHD_gnutls_x509_crt_set_serial (MHD_gnutls_x509_crt_t cert,
287 const void *serial, size_t serial_size); 287 const void *serial, size_t serial_size);
288 288
289 int gnutls_x509_crt_set_subject_key_id (gnutls_x509_crt_t cert, 289 int MHD_gnutls_x509_crt_set_subject_key_id (MHD_gnutls_x509_crt_t cert,
290 const void *id, size_t id_size); 290 const void *id, size_t id_size);
291 291
292 int gnutls_x509_crt_set_proxy_dn (gnutls_x509_crt_t crt, 292 int MHD_gnutls_x509_crt_set_proxy_dn (MHD_gnutls_x509_crt_t crt,
293 gnutls_x509_crt_t eecrt, 293 MHD_gnutls_x509_crt_t eecrt,
294 unsigned int raw_flag, 294 unsigned int raw_flag,
295 const void *name, 295 const void *name,
296 unsigned int sizeof_name); 296 unsigned int sizeof_name);
297 int gnutls_x509_crt_set_proxy (gnutls_x509_crt_t crt, 297 int MHD_gnutls_x509_crt_set_proxy (MHD_gnutls_x509_crt_t crt,
298 int pathLenConstraint, 298 int pathLenConstraint,
299 const char *policyLanguage, 299 const char *policyLanguage,
300 const char *policy, size_t sizeof_policy); 300 const char *policy, size_t sizeof_policy);
301 301
302 typedef enum gnutls_certificate_print_formats 302 typedef enum MHD_gnutls_certificate_print_formats
303 { 303 {
304 GNUTLS_X509_CRT_FULL, 304 GNUTLS_X509_CRT_FULL,
305 GNUTLS_X509_CRT_ONELINE, 305 GNUTLS_X509_CRT_ONELINE,
306 GNUTLS_X509_CRT_UNSIGNED_FULL 306 GNUTLS_X509_CRT_UNSIGNED_FULL
307 } gnutls_certificate_print_formats_t; 307 } MHD_gnutls_certificate_print_formats_t;
308 308
309 int gnutls_x509_crt_print (gnutls_x509_crt_t cert, 309 int MHD_gnutls_x509_crt_print (MHD_gnutls_x509_crt_t cert,
310 gnutls_certificate_print_formats_t format, 310 MHD_gnutls_certificate_print_formats_t format,
311 gnutls_datum_t * out); 311 MHD_gnutls_datum_t * out);
312 int gnutls_x509_crl_print (gnutls_x509_crl_t crl, 312 int MHD_gnutls_x509_crl_print (MHD_gnutls_x509_crl_t crl,
313 gnutls_certificate_print_formats_t format, 313 MHD_gnutls_certificate_print_formats_t format,
314 gnutls_datum_t * out); 314 MHD_gnutls_datum_t * out);
315 315
316/* Access to internal Certificate fields. 316/* Access to internal Certificate fields.
317 */ 317 */
318 int gnutls_x509_crt_get_raw_issuer_dn (gnutls_x509_crt_t cert, 318 int MHD_gnutls_x509_crt_get_raw_issuer_dn (MHD_gnutls_x509_crt_t cert,
319 gnutls_datum_t * start); 319 MHD_gnutls_datum_t * start);
320 int gnutls_x509_crt_get_raw_dn (gnutls_x509_crt_t cert, 320 int MHD_gnutls_x509_crt_get_raw_dn (MHD_gnutls_x509_crt_t cert,
321 gnutls_datum_t * start); 321 MHD_gnutls_datum_t * start);
322 322
323/* RDN handling. 323/* RDN handling.
324 */ 324 */
325 int gnutls_x509_rdn_get (const gnutls_datum_t * idn, 325 int MHD_gnutls_x509_rdn_get (const MHD_gnutls_datum_t * idn,
326 char *buf, size_t * sizeof_buf); 326 char *buf, size_t * sizeof_buf);
327 int gnutls_x509_rdn_get_oid (const gnutls_datum_t * idn, 327 int MHD_gnutls_x509_rdn_get_oid (const MHD_gnutls_datum_t * idn,
328 int indx, void *buf, size_t * sizeof_buf); 328 int indx, void *buf, size_t * sizeof_buf);
329 329
330 int gnutls_x509_rdn_get_by_oid (const gnutls_datum_t * idn, 330 int MHD_gnutls_x509_rdn_get_by_oid (const MHD_gnutls_datum_t * idn,
331 const char *oid, 331 const char *oid,
332 int indx, 332 int indx,
333 unsigned int raw_flag, 333 unsigned int raw_flag,
334 void *buf, size_t * sizeof_buf); 334 void *buf, size_t * sizeof_buf);
335 335
336 typedef void *gnutls_x509_dn_t; 336 typedef void *MHD_gnutls_x509_dn_t;
337 337
338 typedef struct gnutls_x509_ava_st 338 typedef struct MHD_gnutls_x509_ava_st
339 { 339 {
340 gnutls_datum_t oid; 340 MHD_gnutls_datum_t oid;
341 gnutls_datum_t value; 341 MHD_gnutls_datum_t value;
342 unsigned long value_tag; 342 unsigned long value_tag;
343 } gnutls_x509_ava_st; 343 } MHD_gnutls_x509_ava_st;
344 344
345 int gnutls_x509_crt_get_subject (gnutls_x509_crt_t cert, 345 int MHD_gnutls_x509_crt_get_subject (MHD_gnutls_x509_crt_t cert,
346 gnutls_x509_dn_t * dn); 346 MHD_gnutls_x509_dn_t * dn);
347 int gnutls_x509_crt_get_issuer (gnutls_x509_crt_t cert, 347 int MHD_gnutls_x509_crt_get_issuer (MHD_gnutls_x509_crt_t cert,
348 gnutls_x509_dn_t * dn); 348 MHD_gnutls_x509_dn_t * dn);
349 int gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn, 349 int MHD_gnutls_x509_dn_get_rdn_ava (MHD_gnutls_x509_dn_t dn,
350 int irdn, 350 int irdn,
351 int iava, gnutls_x509_ava_st * avast); 351 int iava, MHD_gnutls_x509_ava_st * avast);
352 352
353/* CRL handling functions. 353/* CRL handling functions.
354 */ 354 */
355 int gnutls_x509_crl_init (gnutls_x509_crl_t * crl); 355 int MHD_gnutls_x509_crl_init (MHD_gnutls_x509_crl_t * crl);
356 void gnutls_x509_crl_deinit (gnutls_x509_crl_t crl); 356 void MHD_gnutls_x509_crl_deinit (MHD_gnutls_x509_crl_t crl);
357 357
358 int gnutls_x509_crl_import (gnutls_x509_crl_t crl, 358 int MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl,
359 const gnutls_datum_t * data, 359 const MHD_gnutls_datum_t * data,
360 gnutls_x509_crt_fmt_t format); 360 MHD_gnutls_x509_crt_fmt_t format);
361 int gnutls_x509_crl_export (gnutls_x509_crl_t crl, 361 int MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl,
362 gnutls_x509_crt_fmt_t format, 362 MHD_gnutls_x509_crt_fmt_t format,
363 void *output_data, size_t * output_data_size); 363 void *output_data, size_t * output_data_size);
364 364
365 int gnutls_x509_crl_get_issuer_dn (const gnutls_x509_crl_t crl, 365 int MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl,
366 char *buf, size_t * sizeof_buf); 366 char *buf, size_t * sizeof_buf);
367 int gnutls_x509_crl_get_issuer_dn_by_oid (gnutls_x509_crl_t crl, 367 int MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl,
368 const char *oid, 368 const char *oid,
369 int indx, 369 int indx,
370 unsigned int raw_flag, 370 unsigned int raw_flag,
371 void *buf, size_t * sizeof_buf); 371 void *buf, size_t * sizeof_buf);
372 int gnutls_x509_crl_get_dn_oid (gnutls_x509_crl_t crl, 372 int MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl,
373 int indx, void *oid, size_t * sizeof_oid); 373 int indx, void *oid, size_t * sizeof_oid);
374 374
375 int gnutls_x509_crl_get_signature_algorithm (gnutls_x509_crl_t crl); 375 int MHD_gnutls_x509_crl_get_signature_algorithm (MHD_gnutls_x509_crl_t crl);
376 int gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl, 376 int MHD_gnutls_x509_crl_get_signature (MHD_gnutls_x509_crl_t crl,
377 char *sig, size_t * sizeof_sig); 377 char *sig, size_t * sizeof_sig);
378 int gnutls_x509_crl_get_version (gnutls_x509_crl_t crl); 378 int MHD_gnutls_x509_crl_get_version (MHD_gnutls_x509_crl_t crl);
379 379
380 time_t gnutls_x509_crl_get_this_update (gnutls_x509_crl_t crl); 380 time_t MHD_gnutls_x509_crl_get_this_update (MHD_gnutls_x509_crl_t crl);
381 time_t gnutls_x509_crl_get_next_update (gnutls_x509_crl_t crl); 381 time_t MHD_gnutls_x509_crl_get_next_update (MHD_gnutls_x509_crl_t crl);
382 382
383 int gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t crl); 383 int MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl);
384 int gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, 384 int MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl,
385 int indx, 385 int indx,
386 unsigned char *serial, 386 unsigned char *serial,
387 size_t * serial_size, time_t * t); 387 size_t * serial_size, time_t * t);
388#define gnutls_x509_crl_get_certificate_count gnutls_x509_crl_get_crt_count 388#define MHD_gnutls_x509_crl_get_certificate_count MHD_gnutls_x509_crl_get_crt_count
389#define gnutls_x509_crl_get_certificate gnutls_x509_crl_get_crt_serial 389#define MHD_gnutls_x509_crl_get_certificate MHD_gnutls_x509_crl_get_crt_serial
390 390
391 int gnutls_x509_crl_check_issuer (gnutls_x509_crl_t crl, 391 int MHD_gnutls_x509_crl_check_issuer (MHD_gnutls_x509_crl_t crl,
392 gnutls_x509_crt_t issuer); 392 MHD_gnutls_x509_crt_t issuer);
393 393
394/* CRL writing. 394/* CRL writing.
395 */ 395 */
396 int gnutls_x509_crl_set_version (gnutls_x509_crl_t crl, 396 int MHD_gnutls_x509_crl_set_version (MHD_gnutls_x509_crl_t crl,
397 unsigned int version); 397 unsigned int version);
398 int gnutls_x509_crl_sign (gnutls_x509_crl_t crl, 398 int MHD_gnutls_x509_crl_sign (MHD_gnutls_x509_crl_t crl,
399 gnutls_x509_crt_t issuer, 399 MHD_gnutls_x509_crt_t issuer,
400 gnutls_x509_privkey_t issuer_key); 400 MHD_gnutls_x509_privkey_t issuer_key);
401 int gnutls_x509_crl_sign2 (gnutls_x509_crl_t crl, 401 int MHD_gnutls_x509_crl_sign2 (MHD_gnutls_x509_crl_t crl,
402 gnutls_x509_crt_t issuer, 402 MHD_gnutls_x509_crt_t issuer,
403 gnutls_x509_privkey_t issuer_key, 403 MHD_gnutls_x509_privkey_t issuer_key,
404 enum MHD_GNUTLS_HashAlgorithm, 404 enum MHD_GNUTLS_HashAlgorithm,
405 unsigned int flags); 405 unsigned int flags);
406 int gnutls_x509_crl_set_this_update (gnutls_x509_crl_t crl, 406 int MHD_gnutls_x509_crl_set_this_update (MHD_gnutls_x509_crl_t crl,
407 time_t act_time); 407 time_t act_time);
408 int gnutls_x509_crl_set_next_update (gnutls_x509_crl_t crl, 408 int MHD_gnutls_x509_crl_set_next_update (MHD_gnutls_x509_crl_t crl,
409 time_t exp_time); 409 time_t exp_time);
410 int gnutls_x509_crl_set_crt_serial (gnutls_x509_crl_t crl, 410 int MHD_gnutls_x509_crl_set_crt_serial (MHD_gnutls_x509_crl_t crl,
411 const void *serial, 411 const void *serial,
412 size_t serial_size, 412 size_t serial_size,
413 time_t revocation_time); 413 time_t revocation_time);
414 int gnutls_x509_crl_set_crt (gnutls_x509_crl_t crl, 414 int MHD_gnutls_x509_crl_set_crt (MHD_gnutls_x509_crl_t crl,
415 gnutls_x509_crt_t crt, time_t revocation_time); 415 MHD_gnutls_x509_crt_t crt, time_t revocation_time);
416 416
417/* PKCS7 structures handling 417/* PKCS7 structures handling
418 */ 418 */
419 struct gnutls_pkcs7_int; 419 struct MHD_gnutls_pkcs7_int;
420 typedef struct gnutls_pkcs7_int *gnutls_pkcs7_t; 420 typedef struct MHD_gnutls_pkcs7_int *MHD_gnutls_pkcs7_t;
421 421
422 int gnutls_pkcs7_init (gnutls_pkcs7_t * pkcs7); 422 int MHD_gnutls_pkcs7_init (MHD_gnutls_pkcs7_t * pkcs7);
423 void gnutls_pkcs7_deinit (gnutls_pkcs7_t pkcs7); 423 void MHD_gnutls_pkcs7_deinit (MHD_gnutls_pkcs7_t pkcs7);
424 int gnutls_pkcs7_import (gnutls_pkcs7_t pkcs7, 424 int MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7,
425 const gnutls_datum_t * data, 425 const MHD_gnutls_datum_t * data,
426 gnutls_x509_crt_fmt_t format); 426 MHD_gnutls_x509_crt_fmt_t format);
427 int gnutls_pkcs7_export (gnutls_pkcs7_t pkcs7, 427 int MHD_gnutls_pkcs7_export (MHD_gnutls_pkcs7_t pkcs7,
428 gnutls_x509_crt_fmt_t format, 428 MHD_gnutls_x509_crt_fmt_t format,
429 void *output_data, size_t * output_data_size); 429 void *output_data, size_t * output_data_size);
430 430
431 int gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t pkcs7); 431 int MHD_gnutls_pkcs7_get_crt_count (MHD_gnutls_pkcs7_t pkcs7);
432 int gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7, 432 int MHD_gnutls_pkcs7_get_crt_raw (MHD_gnutls_pkcs7_t pkcs7,
433 int indx, 433 int indx,
434 void *certificate, size_t * certificate_size); 434 void *certificate, size_t * certificate_size);
435 435
436 int gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7, 436 int MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7,
437 const gnutls_datum_t * crt); 437 const MHD_gnutls_datum_t * crt);
438 int gnutls_pkcs7_set_crt (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt); 438 int MHD_gnutls_pkcs7_set_crt (MHD_gnutls_pkcs7_t pkcs7, MHD_gnutls_x509_crt_t crt);
439 int gnutls_pkcs7_delete_crt (gnutls_pkcs7_t pkcs7, int indx); 439 int MHD_gnutls_pkcs7_delete_crt (MHD_gnutls_pkcs7_t pkcs7, int indx);
440 440
441 int gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t pkcs7, 441 int MHD_gnutls_pkcs7_get_crl_raw (MHD_gnutls_pkcs7_t pkcs7,
442 int indx, void *crl, size_t * crl_size); 442 int indx, void *crl, size_t * crl_size);
443 int gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t pkcs7); 443 int MHD_gnutls_pkcs7_get_crl_count (MHD_gnutls_pkcs7_t pkcs7);
444 444
445 int gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7, 445 int MHD_gnutls_pkcs7_set_crl_raw (MHD_gnutls_pkcs7_t pkcs7,
446 const gnutls_datum_t * crt); 446 const MHD_gnutls_datum_t * crt);
447 int gnutls_pkcs7_set_crl (gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl); 447 int MHD_gnutls_pkcs7_set_crl (MHD_gnutls_pkcs7_t pkcs7, MHD_gnutls_x509_crl_t crl);
448 int gnutls_pkcs7_delete_crl (gnutls_pkcs7_t pkcs7, int indx); 448 int MHD_gnutls_pkcs7_delete_crl (MHD_gnutls_pkcs7_t pkcs7, int indx);
449 449
450/* X.509 Certificate verification functions. 450/* X.509 Certificate verification functions.
451 */ 451 */
452 typedef enum gnutls_certificate_verify_flags 452 typedef enum MHD_gnutls_certificate_verify_flags
453 { 453 {
454 /* If set a signer does not have to be a certificate authority. This 454 /* If set a signer does not have to be a certificate authority. This
455 * flag should normaly be disabled, unless you know what this means. 455 * flag should normaly be disabled, unless you know what this means.
@@ -482,51 +482,51 @@ extern "C"
482 /* Allow certificates to be signed using the broken MD5 algorithm. 482 /* Allow certificates to be signed using the broken MD5 algorithm.
483 */ 483 */
484 GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5 = 32 484 GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5 = 32
485 } gnutls_certificate_verify_flags; 485 } MHD_gnutls_certificate_verify_flags;
486 486
487 int gnutls_x509_crt_check_issuer (gnutls_x509_crt_t cert, 487 int MHD_gnutls_x509_crt_check_issuer (MHD_gnutls_x509_crt_t cert,
488 gnutls_x509_crt_t issuer); 488 MHD_gnutls_x509_crt_t issuer);
489 489
490 int gnutls_x509_crt_list_verify (const gnutls_x509_crt_t * cert_list, 490 int MHD_gnutls_x509_crt_list_verify (const MHD_gnutls_x509_crt_t * cert_list,
491 int cert_list_length, 491 int cert_list_length,
492 const gnutls_x509_crt_t * CA_list, 492 const MHD_gnutls_x509_crt_t * CA_list,
493 int CA_list_length, 493 int CA_list_length,
494 const gnutls_x509_crl_t * CRL_list, 494 const MHD_gnutls_x509_crl_t * CRL_list,
495 int CRL_list_length, 495 int CRL_list_length,
496 unsigned int flags, unsigned int *verify); 496 unsigned int flags, unsigned int *verify);
497 497
498 int gnutls_x509_crt_verify (gnutls_x509_crt_t cert, 498 int MHD_gnutls_x509_crt_verify (MHD_gnutls_x509_crt_t cert,
499 const gnutls_x509_crt_t * CA_list, 499 const MHD_gnutls_x509_crt_t * CA_list,
500 int CA_list_length, 500 int CA_list_length,
501 unsigned int flags, unsigned int *verify); 501 unsigned int flags, unsigned int *verify);
502 int gnutls_x509_crl_verify (gnutls_x509_crl_t crl, 502 int MHD_gnutls_x509_crl_verify (MHD_gnutls_x509_crl_t crl,
503 const gnutls_x509_crt_t * CA_list, 503 const MHD_gnutls_x509_crt_t * CA_list,
504 int CA_list_length, 504 int CA_list_length,
505 unsigned int flags, unsigned int *verify); 505 unsigned int flags, unsigned int *verify);
506 506
507 int gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert, 507 int MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert,
508 const gnutls_x509_crl_t * 508 const MHD_gnutls_x509_crl_t *
509 crl_list, int crl_list_length); 509 crl_list, int crl_list_length);
510 510
511 int gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert, 511 int MHD_gnutls_x509_crt_get_fingerprint (MHD_gnutls_x509_crt_t cert,
512 enum MHD_GNUTLS_HashAlgorithm algo, 512 enum MHD_GNUTLS_HashAlgorithm algo,
513 void *buf, size_t * sizeof_buf); 513 void *buf, size_t * sizeof_buf);
514 514
515 int gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert, 515 int MHD_gnutls_x509_crt_get_key_purpose_oid (MHD_gnutls_x509_crt_t cert,
516 int indx, 516 int indx,
517 void *oid, 517 void *oid,
518 size_t * sizeof_oid, 518 size_t * sizeof_oid,
519 unsigned int *critical); 519 unsigned int *critical);
520 int gnutls_x509_crt_set_key_purpose_oid (gnutls_x509_crt_t cert, 520 int MHD_gnutls_x509_crt_set_key_purpose_oid (MHD_gnutls_x509_crt_t cert,
521 const void *oid, 521 const void *oid,
522 unsigned int critical); 522 unsigned int critical);
523 523
524/* Private key handling. 524/* Private key handling.
525 */ 525 */
526 526
527/* Flags for the gnutls_x509_privkey_export_pkcs8() function. 527/* Flags for the MHD_gnutls_x509_privkey_export_pkcs8() function.
528 */ 528 */
529 typedef enum gnutls_pkcs_encrypt_flags_t 529 typedef enum MHD_gnutls_pkcs_encrypt_flags_t
530 { 530 {
531 GNUTLS_PKCS_PLAIN = 1, /* if set the private key will not 531 GNUTLS_PKCS_PLAIN = 1, /* if set the private key will not
532 * be encrypted. 532 * be encrypted.
@@ -535,150 +535,150 @@ extern "C"
535 GNUTLS_PKCS_USE_PKCS12_ARCFOUR = 4, 535 GNUTLS_PKCS_USE_PKCS12_ARCFOUR = 4,
536 GNUTLS_PKCS_USE_PKCS12_RC2_40 = 8, 536 GNUTLS_PKCS_USE_PKCS12_RC2_40 = 8,
537 GNUTLS_PKCS_USE_PBES2_3DES = 16 537 GNUTLS_PKCS_USE_PBES2_3DES = 16
538 } gnutls_pkcs_encrypt_flags_t; 538 } MHD_gnutls_pkcs_encrypt_flags_t;
539 539
540#define GNUTLS_PKCS8_PLAIN GNUTLS_PKCS_PLAIN 540#define GNUTLS_PKCS8_PLAIN GNUTLS_PKCS_PLAIN
541#define GNUTLS_PKCS8_USE_PKCS12_3DES GNUTLS_PKCS_USE_PKCS12_3DES 541#define GNUTLS_PKCS8_USE_PKCS12_3DES GNUTLS_PKCS_USE_PKCS12_3DES
542#define GNUTLS_PKCS8_USE_PKCS12_ARCFOUR GNUTLS_PKCS_USE_PKCS12_ARCFOUR 542#define GNUTLS_PKCS8_USE_PKCS12_ARCFOUR GNUTLS_PKCS_USE_PKCS12_ARCFOUR
543#define GNUTLS_PKCS8_USE_PKCS12_RC2_40 GNUTLS_PKCS_USE_PKCS12_RC2_40 543#define GNUTLS_PKCS8_USE_PKCS12_RC2_40 GNUTLS_PKCS_USE_PKCS12_RC2_40
544 544
545 int gnutls_x509_privkey_init (gnutls_x509_privkey_t * key); 545 int MHD_gnutls_x509_privkey_init (MHD_gnutls_x509_privkey_t * key);
546 void gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key); 546 void MHD_gnutls_x509_privkey_deinit (MHD_gnutls_x509_privkey_t key);
547 int gnutls_x509_privkey_cpy (gnutls_x509_privkey_t dst, 547 int MHD_gnutls_x509_privkey_cpy (MHD_gnutls_x509_privkey_t dst,
548 gnutls_x509_privkey_t src); 548 MHD_gnutls_x509_privkey_t src);
549 int gnutls_x509_privkey_import (gnutls_x509_privkey_t key, 549 int MHD_gnutls_x509_privkey_import (MHD_gnutls_x509_privkey_t key,
550 const gnutls_datum_t * data, 550 const MHD_gnutls_datum_t * data,
551 gnutls_x509_crt_fmt_t format); 551 MHD_gnutls_x509_crt_fmt_t format);
552 int gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key, 552 int MHD_gnutls_x509_privkey_import_pkcs8 (MHD_gnutls_x509_privkey_t key,
553 const gnutls_datum_t * data, 553 const MHD_gnutls_datum_t * data,
554 gnutls_x509_crt_fmt_t format, 554 MHD_gnutls_x509_crt_fmt_t format,
555 const char *pass, unsigned int flags); 555 const char *pass, unsigned int flags);
556 int gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t key, 556 int MHD_gnutls_x509_privkey_import_rsa_raw (MHD_gnutls_x509_privkey_t key,
557 const gnutls_datum_t * m, 557 const MHD_gnutls_datum_t * m,
558 const gnutls_datum_t * e, 558 const MHD_gnutls_datum_t * e,
559 const gnutls_datum_t * d, 559 const MHD_gnutls_datum_t * d,
560 const gnutls_datum_t * p, 560 const MHD_gnutls_datum_t * p,
561 const gnutls_datum_t * q, 561 const MHD_gnutls_datum_t * q,
562 const gnutls_datum_t * u); 562 const MHD_gnutls_datum_t * u);
563 int gnutls_x509_privkey_fix (gnutls_x509_privkey_t key); 563 int MHD_gnutls_x509_privkey_fix (MHD_gnutls_x509_privkey_t key);
564 564
565 int gnutls_x509_privkey_export_dsa_raw (gnutls_x509_privkey_t key, 565 int MHD_gnutls_x509_privkey_export_dsa_raw (MHD_gnutls_x509_privkey_t key,
566 gnutls_datum_t * p, 566 MHD_gnutls_datum_t * p,
567 gnutls_datum_t * q, 567 MHD_gnutls_datum_t * q,
568 gnutls_datum_t * g, 568 MHD_gnutls_datum_t * g,
569 gnutls_datum_t * y, 569 MHD_gnutls_datum_t * y,
570 gnutls_datum_t * x); 570 MHD_gnutls_datum_t * x);
571 int gnutls_x509_privkey_import_dsa_raw (gnutls_x509_privkey_t key, 571 int MHD_gnutls_x509_privkey_import_dsa_raw (MHD_gnutls_x509_privkey_t key,
572 const gnutls_datum_t * p, 572 const MHD_gnutls_datum_t * p,
573 const gnutls_datum_t * q, 573 const MHD_gnutls_datum_t * q,
574 const gnutls_datum_t * g, 574 const MHD_gnutls_datum_t * g,
575 const gnutls_datum_t * y, 575 const MHD_gnutls_datum_t * y,
576 const gnutls_datum_t * x); 576 const MHD_gnutls_datum_t * x);
577 577
578 int gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t key); 578 int MHD_gnutls_x509_privkey_get_pk_algorithm (MHD_gnutls_x509_privkey_t key);
579 int gnutls_x509_privkey_get_key_id (gnutls_x509_privkey_t key, 579 int MHD_gnutls_x509_privkey_get_key_id (MHD_gnutls_x509_privkey_t key,
580 unsigned int flags, 580 unsigned int flags,
581 unsigned char *output_data, 581 unsigned char *output_data,
582 size_t * output_data_size); 582 size_t * output_data_size);
583 583
584 int gnutls_x509_privkey_generate (gnutls_x509_privkey_t key, 584 int MHD_gnutls_x509_privkey_generate (MHD_gnutls_x509_privkey_t key,
585 enum MHD_GNUTLS_PublicKeyAlgorithm algo, 585 enum MHD_GNUTLS_PublicKeyAlgorithm algo,
586 unsigned int bits, unsigned int flags); 586 unsigned int bits, unsigned int flags);
587 587
588 int gnutls_x509_privkey_export (gnutls_x509_privkey_t key, 588 int MHD_gnutls_x509_privkey_export (MHD_gnutls_x509_privkey_t key,
589 gnutls_x509_crt_fmt_t format, 589 MHD_gnutls_x509_crt_fmt_t format,
590 void *output_data, 590 void *output_data,
591 size_t * output_data_size); 591 size_t * output_data_size);
592 int gnutls_x509_privkey_export_pkcs8 (gnutls_x509_privkey_t key, 592 int MHD_gnutls_x509_privkey_export_pkcs8 (MHD_gnutls_x509_privkey_t key,
593 gnutls_x509_crt_fmt_t format, 593 MHD_gnutls_x509_crt_fmt_t format,
594 const char *password, 594 const char *password,
595 unsigned int flags, 595 unsigned int flags,
596 void *output_data, 596 void *output_data,
597 size_t * output_data_size); 597 size_t * output_data_size);
598 int gnutls_x509_privkey_export_rsa_raw (gnutls_x509_privkey_t key, 598 int MHD_gnutls_x509_privkey_export_rsa_raw (MHD_gnutls_x509_privkey_t key,
599 gnutls_datum_t * m, 599 MHD_gnutls_datum_t * m,
600 gnutls_datum_t * e, 600 MHD_gnutls_datum_t * e,
601 gnutls_datum_t * d, 601 MHD_gnutls_datum_t * d,
602 gnutls_datum_t * p, 602 MHD_gnutls_datum_t * p,
603 gnutls_datum_t * q, 603 MHD_gnutls_datum_t * q,
604 gnutls_datum_t * u); 604 MHD_gnutls_datum_t * u);
605 605
606/* Signing stuff. 606/* Signing stuff.
607 */ 607 */
608 int gnutls_x509_privkey_sign_data (gnutls_x509_privkey_t key, 608 int MHD_gnutls_x509_privkey_sign_data (MHD_gnutls_x509_privkey_t key,
609 enum MHD_GNUTLS_HashAlgorithm digest, 609 enum MHD_GNUTLS_HashAlgorithm digest,
610 unsigned int flags, 610 unsigned int flags,
611 const gnutls_datum_t * data, 611 const MHD_gnutls_datum_t * data,
612 void *signature, 612 void *signature,
613 size_t * signature_size); 613 size_t * signature_size);
614 int gnutls_x509_privkey_verify_data (gnutls_x509_privkey_t key, 614 int MHD_gnutls_x509_privkey_verify_data (MHD_gnutls_x509_privkey_t key,
615 unsigned int flags, 615 unsigned int flags,
616 const gnutls_datum_t * data, 616 const MHD_gnutls_datum_t * data,
617 const gnutls_datum_t * signature); 617 const MHD_gnutls_datum_t * signature);
618 int gnutls_x509_crt_verify_data (gnutls_x509_crt_t crt, 618 int MHD_gnutls_x509_crt_verify_data (MHD_gnutls_x509_crt_t crt,
619 unsigned int flags, 619 unsigned int flags,
620 const gnutls_datum_t * data, 620 const MHD_gnutls_datum_t * data,
621 const gnutls_datum_t * signature); 621 const MHD_gnutls_datum_t * signature);
622 622
623 int gnutls_x509_privkey_sign_hash (gnutls_x509_privkey_t key, 623 int MHD_gnutls_x509_privkey_sign_hash (MHD_gnutls_x509_privkey_t key,
624 const gnutls_datum_t * hash, 624 const MHD_gnutls_datum_t * hash,
625 gnutls_datum_t * signature); 625 MHD_gnutls_datum_t * signature);
626 626
627/* Certificate request stuff. 627/* Certificate request stuff.
628 */ 628 */
629 struct gnutls_x509_crq_int; 629 struct MHD_gnutls_x509_crq_int;
630 typedef struct gnutls_x509_crq_int *gnutls_x509_crq_t; 630 typedef struct MHD_gnutls_x509_crq_int *MHD_gnutls_x509_crq_t;
631 631
632 int gnutls_x509_crq_init (gnutls_x509_crq_t * crq); 632 int MHD_gnutls_x509_crq_init (MHD_gnutls_x509_crq_t * crq);
633 void gnutls_x509_crq_deinit (gnutls_x509_crq_t crq); 633 void MHD_gnutls_x509_crq_deinit (MHD_gnutls_x509_crq_t crq);
634 int gnutls_x509_crq_import (gnutls_x509_crq_t crq, 634 int MHD_gnutls_x509_crq_import (MHD_gnutls_x509_crq_t crq,
635 const gnutls_datum_t * data, 635 const MHD_gnutls_datum_t * data,
636 gnutls_x509_crt_fmt_t format); 636 MHD_gnutls_x509_crt_fmt_t format);
637 int gnutls_x509_crq_get_pk_algorithm (gnutls_x509_crq_t crq, 637 int MHD_gnutls_x509_crq_get_pk_algorithm (MHD_gnutls_x509_crq_t crq,
638 unsigned int *bits); 638 unsigned int *bits);
639 int gnutls_x509_crq_get_dn (gnutls_x509_crq_t crq, 639 int MHD_gnutls_x509_crq_get_dn (MHD_gnutls_x509_crq_t crq,
640 char *buf, size_t * sizeof_buf); 640 char *buf, size_t * sizeof_buf);
641 int gnutls_x509_crq_get_dn_oid (gnutls_x509_crq_t crq, 641 int MHD_gnutls_x509_crq_get_dn_oid (MHD_gnutls_x509_crq_t crq,
642 int indx, void *oid, size_t * sizeof_oid); 642 int indx, void *oid, size_t * sizeof_oid);
643 int gnutls_x509_crq_get_dn_by_oid (gnutls_x509_crq_t crq, 643 int MHD_gnutls_x509_crq_get_dn_by_oid (MHD_gnutls_x509_crq_t crq,
644 const char *oid, 644 const char *oid,
645 int indx, 645 int indx,
646 unsigned int raw_flag, 646 unsigned int raw_flag,
647 void *buf, size_t * sizeof_buf); 647 void *buf, size_t * sizeof_buf);
648 int gnutls_x509_crq_set_dn_by_oid (gnutls_x509_crq_t crq, 648 int MHD_gnutls_x509_crq_set_dn_by_oid (MHD_gnutls_x509_crq_t crq,
649 const char *oid, 649 const char *oid,
650 unsigned int raw_flag, 650 unsigned int raw_flag,
651 const void *name, 651 const void *name,
652 unsigned int sizeof_name); 652 unsigned int sizeof_name);
653 int gnutls_x509_crq_set_version (gnutls_x509_crq_t crq, 653 int MHD_gnutls_x509_crq_set_version (MHD_gnutls_x509_crq_t crq,
654 unsigned int version); 654 unsigned int version);
655 int gnutls_x509_crq_set_key (gnutls_x509_crq_t crq, 655 int MHD_gnutls_x509_crq_set_key (MHD_gnutls_x509_crq_t crq,
656 gnutls_x509_privkey_t key); 656 MHD_gnutls_x509_privkey_t key);
657 int gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq, 657 int MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq,
658 gnutls_x509_privkey_t key, 658 MHD_gnutls_x509_privkey_t key,
659 enum MHD_GNUTLS_HashAlgorithm, 659 enum MHD_GNUTLS_HashAlgorithm,
660 unsigned int flags); 660 unsigned int flags);
661 int gnutls_x509_crq_sign (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key); 661 int MHD_gnutls_x509_crq_sign (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t key);
662 662
663 int gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t crq, 663 int MHD_gnutls_x509_crq_set_challenge_password (MHD_gnutls_x509_crq_t crq,
664 const char *pass); 664 const char *pass);
665 int gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq, 665 int MHD_gnutls_x509_crq_get_challenge_password (MHD_gnutls_x509_crq_t crq,
666 char *pass, 666 char *pass,
667 size_t * sizeof_pass); 667 size_t * sizeof_pass);
668 668
669 int gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq, 669 int MHD_gnutls_x509_crq_set_attribute_by_oid (MHD_gnutls_x509_crq_t crq,
670 const char *oid, 670 const char *oid,
671 void *buf, size_t sizeof_buf); 671 void *buf, size_t sizeof_buf);
672 int gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t crq, 672 int MHD_gnutls_x509_crq_get_attribute_by_oid (MHD_gnutls_x509_crq_t crq,
673 const char *oid, 673 const char *oid,
674 int indx, 674 int indx,
675 void *buf, size_t * sizeof_buf); 675 void *buf, size_t * sizeof_buf);
676 676
677 int gnutls_x509_crq_export (gnutls_x509_crq_t crq, 677 int MHD_gnutls_x509_crq_export (MHD_gnutls_x509_crq_t crq,
678 gnutls_x509_crt_fmt_t format, 678 MHD_gnutls_x509_crt_fmt_t format,
679 void *output_data, size_t * output_data_size); 679 void *output_data, size_t * output_data_size);
680 680
681 int gnutls_x509_crt_set_crq (gnutls_x509_crt_t crt, gnutls_x509_crq_t crq); 681 int MHD_gnutls_x509_crt_set_crq (MHD_gnutls_x509_crt_t crt, MHD_gnutls_x509_crq_t crq);
682 682
683#ifdef __cplusplus 683#ifdef __cplusplus
684} 684}
@@ -692,16 +692,16 @@ extern "C"
692#define HASH_OID_SHA384 "2.16.840.1.101.3.4.2.2" 692#define HASH_OID_SHA384 "2.16.840.1.101.3.4.2.2"
693#define HASH_OID_SHA512 "2.16.840.1.101.3.4.2.3" 693#define HASH_OID_SHA512 "2.16.840.1.101.3.4.2.3"
694 694
695typedef struct gnutls_x509_crl_int 695typedef struct MHD_gnutls_x509_crl_int
696{ 696{
697 ASN1_TYPE crl; 697 ASN1_TYPE crl;
698} gnutls_x509_crl_int; 698} MHD_gnutls_x509_crl_int;
699 699
700typedef struct gnutls_x509_crt_int 700typedef struct MHD_gnutls_x509_crt_int
701{ 701{
702 ASN1_TYPE cert; 702 ASN1_TYPE cert;
703 int use_extensions; 703 int use_extensions;
704} gnutls_x509_crt_int; 704} MHD_gnutls_x509_crt_int;
705 705
706#define MAX_PRIV_PARAMS_SIZE 6 /* ok for RSA and DSA */ 706#define MAX_PRIV_PARAMS_SIZE 6 /* ok for RSA and DSA */
707 707
@@ -749,100 +749,100 @@ typedef struct MHD_gtls_x509_privkey_int
749 * the exported API (used internally only). 749 * the exported API (used internally only).
750 */ 750 */
751 ASN1_TYPE key; 751 ASN1_TYPE key;
752} gnutls_x509_privkey_int; 752} MHD_gnutls_x509_privkey_int;
753 753
754int gnutls_x509_crt_get_issuer_dn_by_oid (gnutls_x509_crt_t cert, 754int MHD_gnutls_x509_crt_get_issuer_dn_by_oid (MHD_gnutls_x509_crt_t cert,
755 const char *oid, 755 const char *oid,
756 int indx, 756 int indx,
757 unsigned int raw_flag, 757 unsigned int raw_flag,
758 void *buf, size_t * sizeof_buf); 758 void *buf, size_t * sizeof_buf);
759int gnutls_x509_crt_get_subject_alt_name (gnutls_x509_crt_t cert, 759int MHD_gnutls_x509_crt_get_subject_alt_name (MHD_gnutls_x509_crt_t cert,
760 unsigned int seq, 760 unsigned int seq,
761 void *ret, 761 void *ret,
762 size_t * ret_size, 762 size_t * ret_size,
763 unsigned int *critical); 763 unsigned int *critical);
764int gnutls_x509_crt_get_dn_by_oid (gnutls_x509_crt_t cert, 764int MHD_gnutls_x509_crt_get_dn_by_oid (MHD_gnutls_x509_crt_t cert,
765 const char *oid, 765 const char *oid,
766 int indx, 766 int indx,
767 unsigned int raw_flag, 767 unsigned int raw_flag,
768 void *buf, size_t * sizeof_buf); 768 void *buf, size_t * sizeof_buf);
769int gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t cert, 769int MHD_gnutls_x509_crt_get_ca_status (MHD_gnutls_x509_crt_t cert,
770 unsigned int *critical); 770 unsigned int *critical);
771int gnutls_x509_crt_get_pk_algorithm (gnutls_x509_crt_t cert, 771int MHD_gnutls_x509_crt_get_pk_algorithm (MHD_gnutls_x509_crt_t cert,
772 unsigned int *bits); 772 unsigned int *bits);
773 773
774int _gnutls_x509_crt_cpy (gnutls_x509_crt_t dest, gnutls_x509_crt_t src); 774int MHD__gnutls_x509_crt_cpy (MHD_gnutls_x509_crt_t dest, MHD_gnutls_x509_crt_t src);
775 775
776int gnutls_x509_crt_get_serial (gnutls_x509_crt_t cert, 776int MHD_gnutls_x509_crt_get_serial (MHD_gnutls_x509_crt_t cert,
777 void *result, size_t * result_size); 777 void *result, size_t * result_size);
778 778
779int _gnutls_x509_compare_raw_dn (const gnutls_datum_t * dn1, 779int MHD__gnutls_x509_compare_raw_dn (const MHD_gnutls_datum_t * dn1,
780 const gnutls_datum_t * dn2); 780 const MHD_gnutls_datum_t * dn2);
781 781
782int gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert, 782int MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert,
783 const gnutls_x509_crl_t * crl_list, 783 const MHD_gnutls_x509_crl_t * crl_list,
784 int crl_list_length); 784 int crl_list_length);
785 785
786int _gnutls_x509_crl_cpy (gnutls_x509_crl_t dest, gnutls_x509_crl_t src); 786int MHD__gnutls_x509_crl_cpy (MHD_gnutls_x509_crl_t dest, MHD_gnutls_x509_crl_t src);
787int _gnutls_x509_crl_get_raw_issuer_dn (gnutls_x509_crl_t crl, 787int MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl,
788 gnutls_datum_t * dn); 788 MHD_gnutls_datum_t * dn);
789int gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t crl); 789int MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl);
790int gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, 790int MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl,
791 int indx, 791 int indx,
792 unsigned char *serial, 792 unsigned char *serial,
793 size_t * serial_size, time_t * t); 793 size_t * serial_size, time_t * t);
794 794
795void gnutls_x509_crl_deinit (gnutls_x509_crl_t crl); 795void MHD_gnutls_x509_crl_deinit (MHD_gnutls_x509_crl_t crl);
796int gnutls_x509_crl_init (gnutls_x509_crl_t * crl); 796int MHD_gnutls_x509_crl_init (MHD_gnutls_x509_crl_t * crl);
797int gnutls_x509_crl_import (gnutls_x509_crl_t crl, 797int MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl,
798 const gnutls_datum_t * data, 798 const MHD_gnutls_datum_t * data,
799 gnutls_x509_crt_fmt_t format); 799 MHD_gnutls_x509_crt_fmt_t format);
800int gnutls_x509_crl_export (gnutls_x509_crl_t crl, 800int MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl,
801 gnutls_x509_crt_fmt_t format, 801 MHD_gnutls_x509_crt_fmt_t format,
802 void *output_data, size_t * output_data_size); 802 void *output_data, size_t * output_data_size);
803 803
804int gnutls_x509_crt_init (gnutls_x509_crt_t * cert); 804int MHD_gnutls_x509_crt_init (MHD_gnutls_x509_crt_t * cert);
805void gnutls_x509_crt_deinit (gnutls_x509_crt_t cert); 805void MHD_gnutls_x509_crt_deinit (MHD_gnutls_x509_crt_t cert);
806int gnutls_x509_crt_import (gnutls_x509_crt_t cert, 806int MHD_gnutls_x509_crt_import (MHD_gnutls_x509_crt_t cert,
807 const gnutls_datum_t * data, 807 const MHD_gnutls_datum_t * data,
808 gnutls_x509_crt_fmt_t format); 808 MHD_gnutls_x509_crt_fmt_t format);
809int gnutls_x509_crt_export (gnutls_x509_crt_t cert, 809int MHD_gnutls_x509_crt_export (MHD_gnutls_x509_crt_t cert,
810 gnutls_x509_crt_fmt_t format, 810 MHD_gnutls_x509_crt_fmt_t format,
811 void *output_data, size_t * output_data_size); 811 void *output_data, size_t * output_data_size);
812 812
813int gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert, 813int MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert,
814 unsigned int *key_usage, 814 unsigned int *key_usage,
815 unsigned int *critical); 815 unsigned int *critical);
816int gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t cert); 816int MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t cert);
817int gnutls_x509_crt_get_version (gnutls_x509_crt_t cert); 817int MHD_gnutls_x509_crt_get_version (MHD_gnutls_x509_crt_t cert);
818 818
819int gnutls_x509_privkey_init (gnutls_x509_privkey_t * key); 819int MHD_gnutls_x509_privkey_init (MHD_gnutls_x509_privkey_t * key);
820void gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key); 820void MHD_gnutls_x509_privkey_deinit (MHD_gnutls_x509_privkey_t key);
821 821
822int gnutls_x509_privkey_generate (gnutls_x509_privkey_t key, 822int MHD_gnutls_x509_privkey_generate (MHD_gnutls_x509_privkey_t key,
823 enum MHD_GNUTLS_PublicKeyAlgorithm algo, 823 enum MHD_GNUTLS_PublicKeyAlgorithm algo,
824 unsigned int bits, unsigned int flags); 824 unsigned int bits, unsigned int flags);
825 825
826int gnutls_x509_privkey_import (gnutls_x509_privkey_t key, 826int MHD_gnutls_x509_privkey_import (MHD_gnutls_x509_privkey_t key,
827 const gnutls_datum_t * data, 827 const MHD_gnutls_datum_t * data,
828 gnutls_x509_crt_fmt_t format); 828 MHD_gnutls_x509_crt_fmt_t format);
829int gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t key); 829int MHD_gnutls_x509_privkey_get_pk_algorithm (MHD_gnutls_x509_privkey_t key);
830int gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t key, 830int MHD_gnutls_x509_privkey_import_rsa_raw (MHD_gnutls_x509_privkey_t key,
831 const gnutls_datum_t * m, 831 const MHD_gnutls_datum_t * m,
832 const gnutls_datum_t * e, 832 const MHD_gnutls_datum_t * e,
833 const gnutls_datum_t * d, 833 const MHD_gnutls_datum_t * d,
834 const gnutls_datum_t * p, 834 const MHD_gnutls_datum_t * p,
835 const gnutls_datum_t * q, 835 const MHD_gnutls_datum_t * q,
836 const gnutls_datum_t * u); 836 const MHD_gnutls_datum_t * u);
837int gnutls_x509_privkey_export_rsa_raw (gnutls_x509_privkey_t key, 837int MHD_gnutls_x509_privkey_export_rsa_raw (MHD_gnutls_x509_privkey_t key,
838 gnutls_datum_t * m, 838 MHD_gnutls_datum_t * m,
839 gnutls_datum_t * e, 839 MHD_gnutls_datum_t * e,
840 gnutls_datum_t * d, 840 MHD_gnutls_datum_t * d,
841 gnutls_datum_t * p, 841 MHD_gnutls_datum_t * p,
842 gnutls_datum_t * q, 842 MHD_gnutls_datum_t * q,
843 gnutls_datum_t * u); 843 MHD_gnutls_datum_t * u);
844int gnutls_x509_privkey_export (gnutls_x509_privkey_t key, 844int MHD_gnutls_x509_privkey_export (MHD_gnutls_x509_privkey_t key,
845 gnutls_x509_crt_fmt_t format, 845 MHD_gnutls_x509_crt_fmt_t format,
846 void *output_data, size_t * output_data_size); 846 void *output_data, size_t * output_data_size);
847 847
848#define GNUTLS_CRL_REASON_UNUSED 128 848#define GNUTLS_CRL_REASON_UNUSED 128
diff --git a/src/daemon/https/x509/x509_privkey.c b/src/daemon/https/x509/x509_privkey.c
index 3f168eac..e01861b8 100644
--- a/src/daemon/https/x509/x509_privkey.c
+++ b/src/daemon/https/x509/x509_privkey.c
@@ -39,8 +39,8 @@
39#include <dsa.h> 39#include <dsa.h>
40#include <verify.h> 40#include <verify.h>
41 41
42static int _gnutls_asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params); 42static int MHD__gnutlsMHD__asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params);
43int _gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params); 43int MHD__gnutlsMHD__asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params);
44 44
45/* remove this when libgcrypt can handle the PKCS #1 coefficients from 45/* remove this when libgcrypt can handle the PKCS #1 coefficients from
46 * rsa keys 46 * rsa keys
@@ -48,7 +48,7 @@ int _gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params);
48#define CALC_COEFF 1 48#define CALC_COEFF 1
49 49
50/** 50/**
51 * gnutls_x509_privkey_init - This function initializes a gnutls_crl structure 51 * MHD_gnutls_x509_privkey_init - This function initializes a MHD_gnutls_crl structure
52 * @key: The structure to be initialized 52 * @key: The structure to be initialized
53 * 53 *
54 * This function will initialize an private key structure. 54 * This function will initialize an private key structure.
@@ -57,9 +57,9 @@ int _gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params);
57 * 57 *
58 **/ 58 **/
59int 59int
60gnutls_x509_privkey_init (gnutls_x509_privkey_t * key) 60MHD_gnutls_x509_privkey_init (MHD_gnutls_x509_privkey_t * key)
61{ 61{
62 *key = gnutls_calloc (1, sizeof (gnutls_x509_privkey_int)); 62 *key = MHD_gnutls_calloc (1, sizeof (MHD_gnutls_x509_privkey_int));
63 63
64 if (*key) 64 if (*key)
65 { 65 {
@@ -72,14 +72,14 @@ gnutls_x509_privkey_init (gnutls_x509_privkey_t * key)
72} 72}
73 73
74/** 74/**
75 * gnutls_x509_privkey_deinit - This function deinitializes memory used by a gnutls_x509_privkey_t structure 75 * MHD_gnutls_x509_privkey_deinit - This function deinitializes memory used by a MHD_gnutls_x509_privkey_t structure
76 * @key: The structure to be initialized 76 * @key: The structure to be initialized
77 * 77 *
78 * This function will deinitialize a private key structure. 78 * This function will deinitialize a private key structure.
79 * 79 *
80 **/ 80 **/
81void 81void
82gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key) 82MHD_gnutls_x509_privkey_deinit (MHD_gnutls_x509_privkey_t key)
83{ 83{
84 int i; 84 int i;
85 85
@@ -88,15 +88,15 @@ gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key)
88 88
89 for (i = 0; i < key->params_size; i++) 89 for (i = 0; i < key->params_size; i++)
90 { 90 {
91 mhd_gtls_mpi_release (&key->params[i]); 91 MHD_gtls_mpi_release (&key->params[i]);
92 } 92 }
93 93
94 asn1_delete_structure (&key->key); 94 MHD__asn1_delete_structure (&key->key);
95 gnutls_free (key); 95 MHD_gnutls_free (key);
96} 96}
97 97
98/** 98/**
99 * gnutls_x509_privkey_cpy - This function copies a private key 99 * MHD_gnutls_x509_privkey_cpy - This function copies a private key
100 * @dst: The destination key, which should be initialized. 100 * @dst: The destination key, which should be initialized.
101 * @src: The source key 101 * @src: The source key
102 * 102 *
@@ -104,7 +104,7 @@ gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key)
104 * 104 *
105 **/ 105 **/
106int 106int
107gnutls_x509_privkey_cpy (gnutls_x509_privkey_t dst, gnutls_x509_privkey_t src) 107MHD_gnutls_x509_privkey_cpy (MHD_gnutls_x509_privkey_t dst, MHD_gnutls_x509_privkey_t src)
108{ 108{
109 int i, ret; 109 int i, ret;
110 110
@@ -113,7 +113,7 @@ gnutls_x509_privkey_cpy (gnutls_x509_privkey_t dst, gnutls_x509_privkey_t src)
113 113
114 for (i = 0; i < src->params_size; i++) 114 for (i = 0; i < src->params_size; i++)
115 { 115 {
116 dst->params[i] = _gnutls_mpi_copy (src->params[i]); 116 dst->params[i] = MHD__gnutls_mpi_copy (src->params[i]);
117 if (dst->params[i] == NULL) 117 if (dst->params[i] == NULL)
118 return GNUTLS_E_MEMORY_ERROR; 118 return GNUTLS_E_MEMORY_ERROR;
119 } 119 }
@@ -127,15 +127,15 @@ gnutls_x509_privkey_cpy (gnutls_x509_privkey_t dst, gnutls_x509_privkey_t src)
127 switch (dst->pk_algorithm) 127 switch (dst->pk_algorithm)
128 { 128 {
129 case MHD_GNUTLS_PK_RSA: 129 case MHD_GNUTLS_PK_RSA:
130 ret = _gnutls_asn1_encode_rsa (&dst->key, dst->params); 130 ret = MHD__gnutlsMHD__asn1_encode_rsa (&dst->key, dst->params);
131 if (ret < 0) 131 if (ret < 0)
132 { 132 {
133 gnutls_assert (); 133 MHD_gnutls_assert ();
134 return ret; 134 return ret;
135 } 135 }
136 break; 136 break;
137 default: 137 default:
138 gnutls_assert (); 138 MHD_gnutls_assert ();
139 return GNUTLS_E_INVALID_REQUEST; 139 return GNUTLS_E_INVALID_REQUEST;
140 } 140 }
141 } 141 }
@@ -144,69 +144,69 @@ gnutls_x509_privkey_cpy (gnutls_x509_privkey_t dst, gnutls_x509_privkey_t src)
144} 144}
145 145
146/* Converts an RSA PKCS#1 key to 146/* Converts an RSA PKCS#1 key to
147 * an internal structure (gnutls_private_key) 147 * an internal structure (MHD_gnutls_private_key)
148 */ 148 */
149ASN1_TYPE 149ASN1_TYPE
150_gnutls_privkey_decode_pkcs1_rsa_key (const gnutls_datum_t * raw_key, 150MHD__gnutls_privkey_decode_pkcs1_rsa_key (const MHD_gnutls_datum_t * raw_key,
151 gnutls_x509_privkey_t pkey) 151 MHD_gnutls_x509_privkey_t pkey)
152{ 152{
153 int result; 153 int result;
154 ASN1_TYPE pkey_asn; 154 ASN1_TYPE pkey_asn;
155 155
156 if ((result = asn1_create_element (_gnutls_get_gnutls_asn (), 156 if ((result = MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (),
157 "GNUTLS.RSAPrivateKey", 157 "GNUTLS.RSAPrivateKey",
158 &pkey_asn)) != ASN1_SUCCESS) 158 &pkey_asn)) != ASN1_SUCCESS)
159 { 159 {
160 gnutls_assert (); 160 MHD_gnutls_assert ();
161 return NULL; 161 return NULL;
162 } 162 }
163 163
164 if ((sizeof (pkey->params) / sizeof (mpi_t)) < RSA_PRIVATE_PARAMS) 164 if ((sizeof (pkey->params) / sizeof (mpi_t)) < RSA_PRIVATE_PARAMS)
165 { 165 {
166 gnutls_assert (); 166 MHD_gnutls_assert ();
167 /* internal error. Increase the mpi_ts in params */ 167 /* internal error. Increase the mpi_ts in params */
168 return NULL; 168 return NULL;
169 } 169 }
170 170
171 result = asn1_der_decoding (&pkey_asn, raw_key->data, raw_key->size, NULL); 171 result = MHD__asn1_der_decoding (&pkey_asn, raw_key->data, raw_key->size, NULL);
172 if (result != ASN1_SUCCESS) 172 if (result != ASN1_SUCCESS)
173 { 173 {
174 gnutls_assert (); 174 MHD_gnutls_assert ();
175 goto error; 175 goto error;
176 } 176 }
177 177
178 if ((result = _gnutls_x509_read_int (pkey_asn, "modulus", &pkey->params[0])) 178 if ((result = MHD__gnutls_x509_read_int (pkey_asn, "modulus", &pkey->params[0]))
179 < 0) 179 < 0)
180 { 180 {
181 gnutls_assert (); 181 MHD_gnutls_assert ();
182 goto error; 182 goto error;
183 } 183 }
184 184
185 if ((result = _gnutls_x509_read_int (pkey_asn, "publicExponent", 185 if ((result = MHD__gnutls_x509_read_int (pkey_asn, "publicExponent",
186 &pkey->params[1])) < 0) 186 &pkey->params[1])) < 0)
187 { 187 {
188 gnutls_assert (); 188 MHD_gnutls_assert ();
189 goto error; 189 goto error;
190 } 190 }
191 191
192 if ((result = _gnutls_x509_read_int (pkey_asn, "privateExponent", 192 if ((result = MHD__gnutls_x509_read_int (pkey_asn, "privateExponent",
193 &pkey->params[2])) < 0) 193 &pkey->params[2])) < 0)
194 { 194 {
195 gnutls_assert (); 195 MHD_gnutls_assert ();
196 goto error; 196 goto error;
197 } 197 }
198 198
199 if ((result = _gnutls_x509_read_int (pkey_asn, "prime1", &pkey->params[3])) 199 if ((result = MHD__gnutls_x509_read_int (pkey_asn, "prime1", &pkey->params[3]))
200 < 0) 200 < 0)
201 { 201 {
202 gnutls_assert (); 202 MHD_gnutls_assert ();
203 goto error; 203 goto error;
204 } 204 }
205 205
206 if ((result = _gnutls_x509_read_int (pkey_asn, "prime2", &pkey->params[4])) 206 if ((result = MHD__gnutls_x509_read_int (pkey_asn, "prime2", &pkey->params[4]))
207 < 0) 207 < 0)
208 { 208 {
209 gnutls_assert (); 209 MHD_gnutls_assert ();
210 goto error; 210 goto error;
211 } 211 }
212 212
@@ -215,21 +215,21 @@ _gnutls_privkey_decode_pkcs1_rsa_key (const gnutls_datum_t * raw_key,
215 * library is uses the p,q in the reverse order. 215 * library is uses the p,q in the reverse order.
216 */ 216 */
217 pkey->params[5] = 217 pkey->params[5] =
218 _gnutls_mpi_snew (_gnutls_mpi_get_nbits (pkey->params[0])); 218 MHD__gnutls_mpi_snew (MHD__gnutls_mpi_get_nbits (pkey->params[0]));
219 219
220 if (pkey->params[5] == NULL) 220 if (pkey->params[5] == NULL)
221 { 221 {
222 gnutls_assert (); 222 MHD_gnutls_assert ();
223 goto error; 223 goto error;
224 } 224 }
225 225
226 _gnutls_mpi_invm (pkey->params[5], pkey->params[3], pkey->params[4]); 226 MHD__gnutls_mpi_invm (pkey->params[5], pkey->params[3], pkey->params[4]);
227 /* p, q */ 227 /* p, q */
228#else 228#else
229 if ((result = _gnutls_x509_read_int (pkey_asn, "coefficient", 229 if ((result = MHD__gnutls_x509_read_int (pkey_asn, "coefficient",
230 &pkey->params[5])) < 0) 230 &pkey->params[5])) < 0)
231 { 231 {
232 gnutls_assert (); 232 MHD_gnutls_assert ();
233 goto error; 233 goto error;
234 } 234 }
235#endif 235#endif
@@ -237,13 +237,13 @@ _gnutls_privkey_decode_pkcs1_rsa_key (const gnutls_datum_t * raw_key,
237 237
238 return pkey_asn; 238 return pkey_asn;
239 239
240error:asn1_delete_structure (&pkey_asn); 240error:MHD__asn1_delete_structure (&pkey_asn);
241 mhd_gtls_mpi_release (&pkey->params[0]); 241 MHD_gtls_mpi_release (&pkey->params[0]);
242 mhd_gtls_mpi_release (&pkey->params[1]); 242 MHD_gtls_mpi_release (&pkey->params[1]);
243 mhd_gtls_mpi_release (&pkey->params[2]); 243 MHD_gtls_mpi_release (&pkey->params[2]);
244 mhd_gtls_mpi_release (&pkey->params[3]); 244 MHD_gtls_mpi_release (&pkey->params[3]);
245 mhd_gtls_mpi_release (&pkey->params[4]); 245 MHD_gtls_mpi_release (&pkey->params[4]);
246 mhd_gtls_mpi_release (&pkey->params[5]); 246 MHD_gtls_mpi_release (&pkey->params[5]);
247 return NULL; 247 return NULL;
248 248
249} 249}
@@ -251,13 +251,13 @@ error:asn1_delete_structure (&pkey_asn);
251#define PEM_KEY_RSA "RSA PRIVATE KEY" 251#define PEM_KEY_RSA "RSA PRIVATE KEY"
252 252
253/** 253/**
254 * gnutls_x509_privkey_import - This function will import a DER or PEM encoded key 254 * MHD_gnutls_x509_privkey_import - This function will import a DER or PEM encoded key
255 * @key: The structure to store the parsed key 255 * @key: The structure to store the parsed key
256 * @data: The DER or PEM encoded certificate. 256 * @data: The DER or PEM encoded certificate.
257 * @format: One of DER or PEM 257 * @format: One of DER or PEM
258 * 258 *
259 * This function will convert the given DER or PEM encoded key 259 * This function will convert the given DER or PEM encoded key
260 * to the native gnutls_x509_privkey_t format. The output will be stored in @key . 260 * to the native MHD_gnutls_x509_privkey_t format. The output will be stored in @key .
261 * 261 *
262 * If the key is PEM encoded it should have a header of "RSA PRIVATE KEY", or 262 * If the key is PEM encoded it should have a header of "RSA PRIVATE KEY", or
263 * "DSA PRIVATE KEY". 263 * "DSA PRIVATE KEY".
@@ -266,16 +266,16 @@ error:asn1_delete_structure (&pkey_asn);
266 * 266 *
267 **/ 267 **/
268int 268int
269gnutls_x509_privkey_import (gnutls_x509_privkey_t key, 269MHD_gnutls_x509_privkey_import (MHD_gnutls_x509_privkey_t key,
270 const gnutls_datum_t * data, 270 const MHD_gnutls_datum_t * data,
271 gnutls_x509_crt_fmt_t format) 271 MHD_gnutls_x509_crt_fmt_t format)
272{ 272{
273 int result = 0, need_free = 0; 273 int result = 0, need_free = 0;
274 gnutls_datum_t _data; 274 MHD_gnutls_datum_t _data;
275 275
276 if (key == NULL) 276 if (key == NULL)
277 { 277 {
278 gnutls_assert (); 278 MHD_gnutls_assert ();
279 return GNUTLS_E_INVALID_REQUEST; 279 return GNUTLS_E_INVALID_REQUEST;
280 } 280 }
281 281
@@ -291,7 +291,7 @@ gnutls_x509_privkey_import (gnutls_x509_privkey_t key,
291 291
292 /* Try the first header */ 292 /* Try the first header */
293 result 293 result
294 = _gnutls_fbase64_decode (PEM_KEY_RSA, data->data, data->size, &out); 294 = MHD__gnutls_fbase64_decode (PEM_KEY_RSA, data->data, data->size, &out);
295 key->pk_algorithm = MHD_GNUTLS_PK_RSA; 295 key->pk_algorithm = MHD_GNUTLS_PK_RSA;
296 296
297 _data.data = out; 297 _data.data = out;
@@ -302,15 +302,15 @@ gnutls_x509_privkey_import (gnutls_x509_privkey_t key,
302 302
303 if (key->pk_algorithm == MHD_GNUTLS_PK_RSA) 303 if (key->pk_algorithm == MHD_GNUTLS_PK_RSA)
304 { 304 {
305 key->key = _gnutls_privkey_decode_pkcs1_rsa_key (&_data, key); 305 key->key = MHD__gnutls_privkey_decode_pkcs1_rsa_key (&_data, key);
306 if (key->key == NULL) 306 if (key->key == NULL)
307 gnutls_assert (); 307 MHD_gnutls_assert ();
308 } 308 }
309 else 309 else
310 { 310 {
311 /* Try decoding with both, and accept the one that succeeds. */ 311 /* Try decoding with both, and accept the one that succeeds. */
312 key->pk_algorithm = MHD_GNUTLS_PK_RSA; 312 key->pk_algorithm = MHD_GNUTLS_PK_RSA;
313 key->key = _gnutls_privkey_decode_pkcs1_rsa_key (&_data, key); 313 key->key = MHD__gnutls_privkey_decode_pkcs1_rsa_key (&_data, key);
314 314
315 // TODO rm 315 // TODO rm
316// if (key->key == NULL) 316// if (key->key == NULL)
@@ -318,20 +318,20 @@ gnutls_x509_privkey_import (gnutls_x509_privkey_t key,
318// key->pk_algorithm = GNUTLS_PK_DSA; 318// key->pk_algorithm = GNUTLS_PK_DSA;
319// key->key = decode_dsa_key(&_data, key); 319// key->key = decode_dsa_key(&_data, key);
320// if (key->key == NULL) 320// if (key->key == NULL)
321// gnutls_assert(); 321// MHD_gnutls_assert();
322// } 322// }
323 } 323 }
324 324
325 if (key->key == NULL) 325 if (key->key == NULL)
326 { 326 {
327 gnutls_assert (); 327 MHD_gnutls_assert ();
328 result = GNUTLS_E_ASN1_DER_ERROR; 328 result = GNUTLS_E_ASN1_DER_ERROR;
329 key->pk_algorithm = MHD_GNUTLS_PK_UNKNOWN; 329 key->pk_algorithm = MHD_GNUTLS_PK_UNKNOWN;
330 return result; 330 return result;
331 } 331 }
332 332
333 if (need_free) 333 if (need_free)
334 _gnutls_free_datum (&_data); 334 MHD__gnutls_free_datum (&_data);
335 335
336 /* The key has now been decoded. 336 /* The key has now been decoded.
337 */ 337 */
@@ -340,12 +340,12 @@ gnutls_x509_privkey_import (gnutls_x509_privkey_t key,
340} 340}
341 341
342#define FREE_RSA_PRIVATE_PARAMS for (i=0;i<RSA_PRIVATE_PARAMS;i++) \ 342#define FREE_RSA_PRIVATE_PARAMS for (i=0;i<RSA_PRIVATE_PARAMS;i++) \
343 mhd_gtls_mpi_release(&key->params[i]) 343 MHD_gtls_mpi_release(&key->params[i])
344#define FREE_DSA_PRIVATE_PARAMS for (i=0;i<DSA_PRIVATE_PARAMS;i++) \ 344#define FREE_DSA_PRIVATE_PARAMS for (i=0;i<DSA_PRIVATE_PARAMS;i++) \
345 mhd_gtls_mpi_release(&key->params[i]) 345 MHD_gtls_mpi_release(&key->params[i])
346 346
347/** 347/**
348 * gnutls_x509_privkey_import_rsa_raw - This function will import a raw RSA key 348 * MHD_gnutls_x509_privkey_import_rsa_raw - This function will import a raw RSA key
349 * @key: The structure to store the parsed key 349 * @key: The structure to store the parsed key
350 * @m: holds the modulus 350 * @m: holds the modulus
351 * @e: holds the public exponent 351 * @e: holds the public exponent
@@ -355,83 +355,83 @@ gnutls_x509_privkey_import (gnutls_x509_privkey_t key,
355 * @u: holds the coefficient 355 * @u: holds the coefficient
356 * 356 *
357 * This function will convert the given RSA raw parameters 357 * This function will convert the given RSA raw parameters
358 * to the native gnutls_x509_privkey_t format. The output will be stored in @key. 358 * to the native MHD_gnutls_x509_privkey_t format. The output will be stored in @key.
359 * 359 *
360 **/ 360 **/
361int 361int
362gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t key, 362MHD_gnutls_x509_privkey_import_rsa_raw (MHD_gnutls_x509_privkey_t key,
363 const gnutls_datum_t * m, 363 const MHD_gnutls_datum_t * m,
364 const gnutls_datum_t * e, 364 const MHD_gnutls_datum_t * e,
365 const gnutls_datum_t * d, 365 const MHD_gnutls_datum_t * d,
366 const gnutls_datum_t * p, 366 const MHD_gnutls_datum_t * p,
367 const gnutls_datum_t * q, 367 const MHD_gnutls_datum_t * q,
368 const gnutls_datum_t * u) 368 const MHD_gnutls_datum_t * u)
369{ 369{
370 int i = 0, ret; 370 int i = 0, ret;
371 size_t siz = 0; 371 size_t siz = 0;
372 372
373 if (key == NULL) 373 if (key == NULL)
374 { 374 {
375 gnutls_assert (); 375 MHD_gnutls_assert ();
376 return GNUTLS_E_INVALID_REQUEST; 376 return GNUTLS_E_INVALID_REQUEST;
377 } 377 }
378 378
379 siz = m->size; 379 siz = m->size;
380 if (mhd_gtls_mpi_scan_nz (&key->params[0], m->data, &siz)) 380 if (MHD_gtls_mpi_scan_nz (&key->params[0], m->data, &siz))
381 { 381 {
382 gnutls_assert (); 382 MHD_gnutls_assert ();
383 FREE_RSA_PRIVATE_PARAMS; 383 FREE_RSA_PRIVATE_PARAMS;
384 return GNUTLS_E_MPI_SCAN_FAILED; 384 return GNUTLS_E_MPI_SCAN_FAILED;
385 } 385 }
386 386
387 siz = e->size; 387 siz = e->size;
388 if (mhd_gtls_mpi_scan_nz (&key->params[1], e->data, &siz)) 388 if (MHD_gtls_mpi_scan_nz (&key->params[1], e->data, &siz))
389 { 389 {
390 gnutls_assert (); 390 MHD_gnutls_assert ();
391 FREE_RSA_PRIVATE_PARAMS; 391 FREE_RSA_PRIVATE_PARAMS;
392 return GNUTLS_E_MPI_SCAN_FAILED; 392 return GNUTLS_E_MPI_SCAN_FAILED;
393 } 393 }
394 394
395 siz = d->size; 395 siz = d->size;
396 if (mhd_gtls_mpi_scan_nz (&key->params[2], d->data, &siz)) 396 if (MHD_gtls_mpi_scan_nz (&key->params[2], d->data, &siz))
397 { 397 {
398 gnutls_assert (); 398 MHD_gnutls_assert ();
399 FREE_RSA_PRIVATE_PARAMS; 399 FREE_RSA_PRIVATE_PARAMS;
400 return GNUTLS_E_MPI_SCAN_FAILED; 400 return GNUTLS_E_MPI_SCAN_FAILED;
401 } 401 }
402 402
403 siz = p->size; 403 siz = p->size;
404 if (mhd_gtls_mpi_scan_nz (&key->params[3], p->data, &siz)) 404 if (MHD_gtls_mpi_scan_nz (&key->params[3], p->data, &siz))
405 { 405 {
406 gnutls_assert (); 406 MHD_gnutls_assert ();
407 FREE_RSA_PRIVATE_PARAMS; 407 FREE_RSA_PRIVATE_PARAMS;
408 return GNUTLS_E_MPI_SCAN_FAILED; 408 return GNUTLS_E_MPI_SCAN_FAILED;
409 } 409 }
410 410
411 siz = q->size; 411 siz = q->size;
412 if (mhd_gtls_mpi_scan_nz (&key->params[4], q->data, &siz)) 412 if (MHD_gtls_mpi_scan_nz (&key->params[4], q->data, &siz))
413 { 413 {
414 gnutls_assert (); 414 MHD_gnutls_assert ();
415 FREE_RSA_PRIVATE_PARAMS; 415 FREE_RSA_PRIVATE_PARAMS;
416 return GNUTLS_E_MPI_SCAN_FAILED; 416 return GNUTLS_E_MPI_SCAN_FAILED;
417 } 417 }
418 418
419#ifdef CALC_COEFF 419#ifdef CALC_COEFF
420 key->params[5] = _gnutls_mpi_snew (_gnutls_mpi_get_nbits (key->params[0])); 420 key->params[5] = MHD__gnutls_mpi_snew (MHD__gnutls_mpi_get_nbits (key->params[0]));
421 421
422 if (key->params[5] == NULL) 422 if (key->params[5] == NULL)
423 { 423 {
424 gnutls_assert (); 424 MHD_gnutls_assert ();
425 FREE_RSA_PRIVATE_PARAMS; 425 FREE_RSA_PRIVATE_PARAMS;
426 return GNUTLS_E_MEMORY_ERROR; 426 return GNUTLS_E_MEMORY_ERROR;
427 } 427 }
428 428
429 _gnutls_mpi_invm (key->params[5], key->params[3], key->params[4]); 429 MHD__gnutls_mpi_invm (key->params[5], key->params[3], key->params[4]);
430#else 430#else
431 siz = u->size; 431 siz = u->size;
432 if (mhd_gtls_mpi_scan_nz (&key->params[5], u->data, &siz)) 432 if (MHD_gtls_mpi_scan_nz (&key->params[5], u->data, &siz))
433 { 433 {
434 gnutls_assert (); 434 MHD_gnutls_assert ();
435 FREE_RSA_PRIVATE_PARAMS; 435 FREE_RSA_PRIVATE_PARAMS;
436 return GNUTLS_E_MPI_SCAN_FAILED; 436 return GNUTLS_E_MPI_SCAN_FAILED;
437 } 437 }
@@ -439,10 +439,10 @@ gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t key,
439 439
440 if (!key->crippled) 440 if (!key->crippled)
441 { 441 {
442 ret = _gnutls_asn1_encode_rsa (&key->key, key->params); 442 ret = MHD__gnutlsMHD__asn1_encode_rsa (&key->key, key->params);
443 if (ret < 0) 443 if (ret < 0)
444 { 444 {
445 gnutls_assert (); 445 MHD_gnutls_assert ();
446 FREE_RSA_PRIVATE_PARAMS; 446 FREE_RSA_PRIVATE_PARAMS;
447 return ret; 447 return ret;
448 } 448 }
@@ -456,8 +456,8 @@ gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t key,
456} 456}
457 457
458/** 458/**
459 * gnutls_x509_privkey_get_pk_algorithm - This function returns the key's PublicKey algorithm 459 * MHD_gnutls_x509_privkey_get_pk_algorithm - This function returns the key's PublicKey algorithm
460 * @key: should contain a gnutls_x509_privkey_t structure 460 * @key: should contain a MHD_gnutls_x509_privkey_t structure
461 * 461 *
462 * This function will return the public key algorithm of a private 462 * This function will return the public key algorithm of a private
463 * key. 463 * key.
@@ -467,11 +467,11 @@ gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t key,
467 * 467 *
468 **/ 468 **/
469int 469int
470gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t key) 470MHD_gnutls_x509_privkey_get_pk_algorithm (MHD_gnutls_x509_privkey_t key)
471{ 471{
472 if (key == NULL) 472 if (key == NULL)
473 { 473 {
474 gnutls_assert (); 474 MHD_gnutls_assert ();
475 return GNUTLS_E_INVALID_REQUEST; 475 return GNUTLS_E_INVALID_REQUEST;
476 } 476 }
477 477
@@ -481,7 +481,7 @@ gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t key)
481/* Encodes the RSA parameters into an ASN.1 RSA private key structure. 481/* Encodes the RSA parameters into an ASN.1 RSA private key structure.
482 */ 482 */
483static int 483static int
484_gnutls_asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params) 484MHD__gnutlsMHD__asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params)
485{ 485{
486 int result, i; 486 int result, i;
487 size_t size[8], total; 487 size_t size[8], total;
@@ -495,77 +495,77 @@ _gnutls_asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params)
495 total = 0; 495 total = 0;
496 for (i = 0; i < 5; i++) 496 for (i = 0; i < 5; i++)
497 { 497 {
498 mhd_gtls_mpi_print_lz (NULL, &size[i], params[i]); 498 MHD_gtls_mpi_print_lz (NULL, &size[i], params[i]);
499 total += size[i]; 499 total += size[i];
500 } 500 }
501 501
502 /* Now generate exp1 and exp2 502 /* Now generate exp1 and exp2
503 */ 503 */
504 exp1 = _gnutls_mpi_salloc_like (params[0]); /* like modulus */ 504 exp1 = MHD__gnutls_mpi_salloc_like (params[0]); /* like modulus */
505 if (exp1 == NULL) 505 if (exp1 == NULL)
506 { 506 {
507 gnutls_assert (); 507 MHD_gnutls_assert ();
508 result = GNUTLS_E_MEMORY_ERROR; 508 result = GNUTLS_E_MEMORY_ERROR;
509 goto cleanup; 509 goto cleanup;
510 } 510 }
511 511
512 exp2 = _gnutls_mpi_salloc_like (params[0]); 512 exp2 = MHD__gnutls_mpi_salloc_like (params[0]);
513 if (exp2 == NULL) 513 if (exp2 == NULL)
514 { 514 {
515 gnutls_assert (); 515 MHD_gnutls_assert ();
516 result = GNUTLS_E_MEMORY_ERROR; 516 result = GNUTLS_E_MEMORY_ERROR;
517 goto cleanup; 517 goto cleanup;
518 } 518 }
519 519
520 q1 = _gnutls_mpi_salloc_like (params[4]); 520 q1 = MHD__gnutls_mpi_salloc_like (params[4]);
521 if (q1 == NULL) 521 if (q1 == NULL)
522 { 522 {
523 gnutls_assert (); 523 MHD_gnutls_assert ();
524 result = GNUTLS_E_MEMORY_ERROR; 524 result = GNUTLS_E_MEMORY_ERROR;
525 goto cleanup; 525 goto cleanup;
526 } 526 }
527 527
528 p1 = _gnutls_mpi_salloc_like (params[3]); 528 p1 = MHD__gnutls_mpi_salloc_like (params[3]);
529 if (p1 == NULL) 529 if (p1 == NULL)
530 { 530 {
531 gnutls_assert (); 531 MHD_gnutls_assert ();
532 result = GNUTLS_E_MEMORY_ERROR; 532 result = GNUTLS_E_MEMORY_ERROR;
533 goto cleanup; 533 goto cleanup;
534 } 534 }
535 535
536 u = _gnutls_mpi_salloc_like (params[3]); 536 u = MHD__gnutls_mpi_salloc_like (params[3]);
537 if (u == NULL) 537 if (u == NULL)
538 { 538 {
539 gnutls_assert (); 539 MHD_gnutls_assert ();
540 result = GNUTLS_E_MEMORY_ERROR; 540 result = GNUTLS_E_MEMORY_ERROR;
541 goto cleanup; 541 goto cleanup;
542 } 542 }
543 543
544 _gnutls_mpi_invm (u, params[4], params[3]); 544 MHD__gnutls_mpi_invm (u, params[4], params[3]);
545 /* inverse of q mod p */ 545 /* inverse of q mod p */
546 mhd_gtls_mpi_print_lz (NULL, &size[5], u); 546 MHD_gtls_mpi_print_lz (NULL, &size[5], u);
547 total += size[5]; 547 total += size[5];
548 548
549 _gnutls_mpi_sub_ui (p1, params[3], 1); 549 MHD__gnutls_mpi_sub_ui (p1, params[3], 1);
550 _gnutls_mpi_sub_ui (q1, params[4], 1); 550 MHD__gnutls_mpi_sub_ui (q1, params[4], 1);
551 551
552 _gnutls_mpi_mod (exp1, params[2], p1); 552 MHD__gnutls_mpi_mod (exp1, params[2], p1);
553 _gnutls_mpi_mod (exp2, params[2], q1); 553 MHD__gnutls_mpi_mod (exp2, params[2], q1);
554 554
555 /* calculate exp's size */ 555 /* calculate exp's size */
556 mhd_gtls_mpi_print_lz (NULL, &size[6], exp1); 556 MHD_gtls_mpi_print_lz (NULL, &size[6], exp1);
557 total += size[6]; 557 total += size[6];
558 558
559 mhd_gtls_mpi_print_lz (NULL, &size[7], exp2); 559 MHD_gtls_mpi_print_lz (NULL, &size[7], exp2);
560 total += size[7]; 560 total += size[7];
561 561
562 /* Encoding phase. 562 /* Encoding phase.
563 * allocate data enough to hold everything 563 * allocate data enough to hold everything
564 */ 564 */
565 all_data = gnutls_secure_malloc (total); 565 all_data = MHD_gnutls_secure_malloc (total);
566 if (all_data == NULL) 566 if (all_data == NULL)
567 { 567 {
568 gnutls_assert (); 568 MHD_gnutls_assert ();
569 result = GNUTLS_E_MEMORY_ERROR; 569 result = GNUTLS_E_MEMORY_ERROR;
570 goto cleanup; 570 goto cleanup;
571 } 571 }
@@ -587,124 +587,124 @@ _gnutls_asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params)
587 p += size[6]; 587 p += size[6];
588 exp2_data = p; 588 exp2_data = p;
589 589
590 mhd_gtls_mpi_print_lz (m_data, &size[0], params[0]); 590 MHD_gtls_mpi_print_lz (m_data, &size[0], params[0]);
591 mhd_gtls_mpi_print_lz (pube_data, &size[1], params[1]); 591 MHD_gtls_mpi_print_lz (pube_data, &size[1], params[1]);
592 mhd_gtls_mpi_print_lz (prie_data, &size[2], params[2]); 592 MHD_gtls_mpi_print_lz (prie_data, &size[2], params[2]);
593 mhd_gtls_mpi_print_lz (p1_data, &size[3], params[3]); 593 MHD_gtls_mpi_print_lz (p1_data, &size[3], params[3]);
594 mhd_gtls_mpi_print_lz (p2_data, &size[4], params[4]); 594 MHD_gtls_mpi_print_lz (p2_data, &size[4], params[4]);
595 mhd_gtls_mpi_print_lz (u_data, &size[5], u); 595 MHD_gtls_mpi_print_lz (u_data, &size[5], u);
596 mhd_gtls_mpi_print_lz (exp1_data, &size[6], exp1); 596 MHD_gtls_mpi_print_lz (exp1_data, &size[6], exp1);
597 mhd_gtls_mpi_print_lz (exp2_data, &size[7], exp2); 597 MHD_gtls_mpi_print_lz (exp2_data, &size[7], exp2);
598 598
599 /* Ok. Now we have the data. Create the asn1 structures 599 /* Ok. Now we have the data. Create the asn1 structures
600 */ 600 */
601 601
602 if ((result = 602 if ((result =
603 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.RSAPrivateKey", 603 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.RSAPrivateKey",
604 c2)) != ASN1_SUCCESS) 604 c2)) != ASN1_SUCCESS)
605 { 605 {
606 gnutls_assert (); 606 MHD_gnutls_assert ();
607 result = mhd_gtls_asn2err (result); 607 result = MHD_gtls_asn2err (result);
608 goto cleanup; 608 goto cleanup;
609 } 609 }
610 610
611 /* Write PRIME 611 /* Write PRIME
612 */ 612 */
613 if ((result = asn1_write_value (*c2, "modulus", m_data, size[0])) 613 if ((result = MHD__asn1_write_value (*c2, "modulus", m_data, size[0]))
614 != ASN1_SUCCESS) 614 != ASN1_SUCCESS)
615 { 615 {
616 gnutls_assert (); 616 MHD_gnutls_assert ();
617 result = mhd_gtls_asn2err (result); 617 result = MHD_gtls_asn2err (result);
618 goto cleanup; 618 goto cleanup;
619 } 619 }
620 620
621 if ((result = asn1_write_value (*c2, "publicExponent", pube_data, size[1])) 621 if ((result = MHD__asn1_write_value (*c2, "publicExponent", pube_data, size[1]))
622 != ASN1_SUCCESS) 622 != ASN1_SUCCESS)
623 { 623 {
624 gnutls_assert (); 624 MHD_gnutls_assert ();
625 result = mhd_gtls_asn2err (result); 625 result = MHD_gtls_asn2err (result);
626 goto cleanup; 626 goto cleanup;
627 } 627 }
628 628
629 if ((result = asn1_write_value (*c2, "privateExponent", prie_data, size[2])) 629 if ((result = MHD__asn1_write_value (*c2, "privateExponent", prie_data, size[2]))
630 != ASN1_SUCCESS) 630 != ASN1_SUCCESS)
631 { 631 {
632 gnutls_assert (); 632 MHD_gnutls_assert ();
633 result = mhd_gtls_asn2err (result); 633 result = MHD_gtls_asn2err (result);
634 goto cleanup; 634 goto cleanup;
635 } 635 }
636 636
637 if ((result = asn1_write_value (*c2, "prime1", p1_data, size[3])) 637 if ((result = MHD__asn1_write_value (*c2, "prime1", p1_data, size[3]))
638 != ASN1_SUCCESS) 638 != ASN1_SUCCESS)
639 { 639 {
640 gnutls_assert (); 640 MHD_gnutls_assert ();
641 result = mhd_gtls_asn2err (result); 641 result = MHD_gtls_asn2err (result);
642 goto cleanup; 642 goto cleanup;
643 } 643 }
644 644
645 if ((result = asn1_write_value (*c2, "prime2", p2_data, size[4])) 645 if ((result = MHD__asn1_write_value (*c2, "prime2", p2_data, size[4]))
646 != ASN1_SUCCESS) 646 != ASN1_SUCCESS)
647 { 647 {
648 gnutls_assert (); 648 MHD_gnutls_assert ();
649 result = mhd_gtls_asn2err (result); 649 result = MHD_gtls_asn2err (result);
650 goto cleanup; 650 goto cleanup;
651 } 651 }
652 652
653 if ((result = asn1_write_value (*c2, "exponent1", exp1_data, size[6])) 653 if ((result = MHD__asn1_write_value (*c2, "exponent1", exp1_data, size[6]))
654 != ASN1_SUCCESS) 654 != ASN1_SUCCESS)
655 { 655 {
656 gnutls_assert (); 656 MHD_gnutls_assert ();
657 result = mhd_gtls_asn2err (result); 657 result = MHD_gtls_asn2err (result);
658 goto cleanup; 658 goto cleanup;
659 } 659 }
660 660
661 if ((result = asn1_write_value (*c2, "exponent2", exp2_data, size[7])) 661 if ((result = MHD__asn1_write_value (*c2, "exponent2", exp2_data, size[7]))
662 != ASN1_SUCCESS) 662 != ASN1_SUCCESS)
663 { 663 {
664 gnutls_assert (); 664 MHD_gnutls_assert ();
665 result = mhd_gtls_asn2err (result); 665 result = MHD_gtls_asn2err (result);
666 goto cleanup; 666 goto cleanup;
667 } 667 }
668 668
669 if ((result = asn1_write_value (*c2, "coefficient", u_data, size[5])) 669 if ((result = MHD__asn1_write_value (*c2, "coefficient", u_data, size[5]))
670 != ASN1_SUCCESS) 670 != ASN1_SUCCESS)
671 { 671 {
672 gnutls_assert (); 672 MHD_gnutls_assert ();
673 result = mhd_gtls_asn2err (result); 673 result = MHD_gtls_asn2err (result);
674 goto cleanup; 674 goto cleanup;
675 } 675 }
676 676
677 mhd_gtls_mpi_release (&exp1); 677 MHD_gtls_mpi_release (&exp1);
678 mhd_gtls_mpi_release (&exp2); 678 MHD_gtls_mpi_release (&exp2);
679 mhd_gtls_mpi_release (&q1); 679 MHD_gtls_mpi_release (&q1);
680 mhd_gtls_mpi_release (&p1); 680 MHD_gtls_mpi_release (&p1);
681 mhd_gtls_mpi_release (&u); 681 MHD_gtls_mpi_release (&u);
682 gnutls_free (all_data); 682 MHD_gnutls_free (all_data);
683 683
684 if ((result = asn1_write_value (*c2, "otherPrimeInfos", 684 if ((result = MHD__asn1_write_value (*c2, "otherPrimeInfos",
685 NULL, 0)) != ASN1_SUCCESS) 685 NULL, 0)) != ASN1_SUCCESS)
686 { 686 {
687 gnutls_assert (); 687 MHD_gnutls_assert ();
688 result = mhd_gtls_asn2err (result); 688 result = MHD_gtls_asn2err (result);
689 goto cleanup; 689 goto cleanup;
690 } 690 }
691 691
692 if ((result = asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS) 692 if ((result = MHD__asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS)
693 { 693 {
694 gnutls_assert (); 694 MHD_gnutls_assert ();
695 result = mhd_gtls_asn2err (result); 695 result = MHD_gtls_asn2err (result);
696 goto cleanup; 696 goto cleanup;
697 } 697 }
698 698
699 return 0; 699 return 0;
700 700
701cleanup:mhd_gtls_mpi_release (&u); 701cleanup:MHD_gtls_mpi_release (&u);
702 mhd_gtls_mpi_release (&exp1); 702 MHD_gtls_mpi_release (&exp1);
703 mhd_gtls_mpi_release (&exp2); 703 MHD_gtls_mpi_release (&exp2);
704 mhd_gtls_mpi_release (&q1); 704 MHD_gtls_mpi_release (&q1);
705 mhd_gtls_mpi_release (&p1); 705 MHD_gtls_mpi_release (&p1);
706 asn1_delete_structure (c2); 706 MHD__asn1_delete_structure (c2);
707 gnutls_free (all_data); 707 MHD_gnutls_free (all_data);
708 708
709 return result; 709 return result;
710} 710}
@@ -712,7 +712,7 @@ cleanup:mhd_gtls_mpi_release (&u);
712/* Encodes the DSA parameters into an ASN.1 DSAPrivateKey structure. 712/* Encodes the DSA parameters into an ASN.1 DSAPrivateKey structure.
713 */ 713 */
714int 714int
715_gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params) 715MHD__gnutlsMHD__asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params)
716{ 716{
717 int result, i; 717 int result, i;
718 size_t size[DSA_PRIVATE_PARAMS], total; 718 size_t size[DSA_PRIVATE_PARAMS], total;
@@ -724,17 +724,17 @@ _gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params)
724 total = 0; 724 total = 0;
725 for (i = 0; i < DSA_PRIVATE_PARAMS; i++) 725 for (i = 0; i < DSA_PRIVATE_PARAMS; i++)
726 { 726 {
727 mhd_gtls_mpi_print_lz (NULL, &size[i], params[i]); 727 MHD_gtls_mpi_print_lz (NULL, &size[i], params[i]);
728 total += size[i]; 728 total += size[i];
729 } 729 }
730 730
731 /* Encoding phase. 731 /* Encoding phase.
732 * allocate data enough to hold everything 732 * allocate data enough to hold everything
733 */ 733 */
734 all_data = gnutls_secure_malloc (total); 734 all_data = MHD_gnutls_secure_malloc (total);
735 if (all_data == NULL) 735 if (all_data == NULL)
736 { 736 {
737 gnutls_assert (); 737 MHD_gnutls_assert ();
738 result = GNUTLS_E_MEMORY_ERROR; 738 result = GNUTLS_E_MEMORY_ERROR;
739 goto cleanup; 739 goto cleanup;
740 } 740 }
@@ -750,82 +750,82 @@ _gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params)
750 p += size[3]; 750 p += size[3];
751 x_data = p; 751 x_data = p;
752 752
753 mhd_gtls_mpi_print_lz (p_data, &size[0], params[0]); 753 MHD_gtls_mpi_print_lz (p_data, &size[0], params[0]);
754 mhd_gtls_mpi_print_lz (q_data, &size[1], params[1]); 754 MHD_gtls_mpi_print_lz (q_data, &size[1], params[1]);
755 mhd_gtls_mpi_print_lz (g_data, &size[2], params[2]); 755 MHD_gtls_mpi_print_lz (g_data, &size[2], params[2]);
756 mhd_gtls_mpi_print_lz (y_data, &size[3], params[3]); 756 MHD_gtls_mpi_print_lz (y_data, &size[3], params[3]);
757 mhd_gtls_mpi_print_lz (x_data, &size[4], params[4]); 757 MHD_gtls_mpi_print_lz (x_data, &size[4], params[4]);
758 758
759 /* Ok. Now we have the data. Create the asn1 structures 759 /* Ok. Now we have the data. Create the asn1 structures
760 */ 760 */
761 761
762 if ((result = 762 if ((result =
763 asn1_create_element (_gnutls_get_gnutls_asn (), "GNUTLS.DSAPrivateKey", 763 MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.DSAPrivateKey",
764 c2)) != ASN1_SUCCESS) 764 c2)) != ASN1_SUCCESS)
765 { 765 {
766 gnutls_assert (); 766 MHD_gnutls_assert ();
767 result = mhd_gtls_asn2err (result); 767 result = MHD_gtls_asn2err (result);
768 goto cleanup; 768 goto cleanup;
769 } 769 }
770 770
771 /* Write PRIME 771 /* Write PRIME
772 */ 772 */
773 if ((result = asn1_write_value (*c2, "p", p_data, size[0])) != ASN1_SUCCESS) 773 if ((result = MHD__asn1_write_value (*c2, "p", p_data, size[0])) != ASN1_SUCCESS)
774 { 774 {
775 gnutls_assert (); 775 MHD_gnutls_assert ();
776 result = mhd_gtls_asn2err (result); 776 result = MHD_gtls_asn2err (result);
777 goto cleanup; 777 goto cleanup;
778 } 778 }
779 779
780 if ((result = asn1_write_value (*c2, "q", q_data, size[1])) != ASN1_SUCCESS) 780 if ((result = MHD__asn1_write_value (*c2, "q", q_data, size[1])) != ASN1_SUCCESS)
781 { 781 {
782 gnutls_assert (); 782 MHD_gnutls_assert ();
783 result = mhd_gtls_asn2err (result); 783 result = MHD_gtls_asn2err (result);
784 goto cleanup; 784 goto cleanup;
785 } 785 }
786 786
787 if ((result = asn1_write_value (*c2, "g", g_data, size[2])) != ASN1_SUCCESS) 787 if ((result = MHD__asn1_write_value (*c2, "g", g_data, size[2])) != ASN1_SUCCESS)
788 { 788 {
789 gnutls_assert (); 789 MHD_gnutls_assert ();
790 result = mhd_gtls_asn2err (result); 790 result = MHD_gtls_asn2err (result);
791 goto cleanup; 791 goto cleanup;
792 } 792 }
793 793
794 if ((result = asn1_write_value (*c2, "Y", y_data, size[3])) != ASN1_SUCCESS) 794 if ((result = MHD__asn1_write_value (*c2, "Y", y_data, size[3])) != ASN1_SUCCESS)
795 { 795 {
796 gnutls_assert (); 796 MHD_gnutls_assert ();
797 result = mhd_gtls_asn2err (result); 797 result = MHD_gtls_asn2err (result);
798 goto cleanup; 798 goto cleanup;
799 } 799 }
800 800
801 if ((result = 801 if ((result =
802 asn1_write_value (*c2, "priv", x_data, size[4])) != ASN1_SUCCESS) 802 MHD__asn1_write_value (*c2, "priv", x_data, size[4])) != ASN1_SUCCESS)
803 { 803 {
804 gnutls_assert (); 804 MHD_gnutls_assert ();
805 result = mhd_gtls_asn2err (result); 805 result = MHD_gtls_asn2err (result);
806 goto cleanup; 806 goto cleanup;
807 } 807 }
808 808
809 gnutls_free (all_data); 809 MHD_gnutls_free (all_data);
810 810
811 if ((result = asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS) 811 if ((result = MHD__asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS)
812 { 812 {
813 gnutls_assert (); 813 MHD_gnutls_assert ();
814 result = mhd_gtls_asn2err (result); 814 result = MHD_gtls_asn2err (result);
815 goto cleanup; 815 goto cleanup;
816 } 816 }
817 817
818 return 0; 818 return 0;
819 819
820cleanup:asn1_delete_structure (c2); 820cleanup:MHD__asn1_delete_structure (c2);
821 gnutls_free (all_data); 821 MHD_gnutls_free (all_data);
822 822
823 return result; 823 return result;
824} 824}
825 825
826/** 826/**
827 * gnutls_x509_privkey_generate - This function will generate a private key 827 * MHD_gnutls_x509_privkey_generate - This function will generate a private key
828 * @key: should contain a gnutls_x509_privkey_t structure 828 * @key: should contain a MHD_gnutls_x509_privkey_t structure
829 * @algo: is one of RSA or DSA. 829 * @algo: is one of RSA or DSA.
830 * @bits: the size of the modulus 830 * @bits: the size of the modulus
831 * @flags: unused for now. Must be 0. 831 * @flags: unused for now. Must be 0.
@@ -837,7 +837,7 @@ cleanup:asn1_delete_structure (c2);
837 * 837 *
838 **/ 838 **/
839int 839int
840gnutls_x509_privkey_generate (gnutls_x509_privkey_t key, 840MHD_gnutls_x509_privkey_generate (MHD_gnutls_x509_privkey_t key,
841 enum MHD_GNUTLS_PublicKeyAlgorithm algo, 841 enum MHD_GNUTLS_PublicKeyAlgorithm algo,
842 unsigned int bits, unsigned int flags) 842 unsigned int bits, unsigned int flags)
843{ 843{
@@ -846,26 +846,26 @@ gnutls_x509_privkey_generate (gnutls_x509_privkey_t key,
846 846
847 if (key == NULL) 847 if (key == NULL)
848 { 848 {
849 gnutls_assert (); 849 MHD_gnutls_assert ();
850 return GNUTLS_E_INVALID_REQUEST; 850 return GNUTLS_E_INVALID_REQUEST;
851 } 851 }
852 852
853 switch (algo) 853 switch (algo)
854 { 854 {
855 case MHD_GNUTLS_PK_RSA: 855 case MHD_GNUTLS_PK_RSA:
856 ret = _gnutls_rsa_generate_params (key->params, &params_len, bits); 856 ret = MHD__gnutls_rsa_generate_params (key->params, &params_len, bits);
857 if (ret < 0) 857 if (ret < 0)
858 { 858 {
859 gnutls_assert (); 859 MHD_gnutls_assert ();
860 return ret; 860 return ret;
861 } 861 }
862 862
863 if (!key->crippled) 863 if (!key->crippled)
864 { 864 {
865 ret = _gnutls_asn1_encode_rsa (&key->key, key->params); 865 ret = MHD__gnutlsMHD__asn1_encode_rsa (&key->key, key->params);
866 if (ret < 0) 866 if (ret < 0)
867 { 867 {
868 gnutls_assert (); 868 MHD_gnutls_assert ();
869 goto cleanup; 869 goto cleanup;
870 } 870 }
871 } 871 }
@@ -875,7 +875,7 @@ gnutls_x509_privkey_generate (gnutls_x509_privkey_t key,
875 875
876 break; 876 break;
877 default: 877 default:
878 gnutls_assert (); 878 MHD_gnutls_assert ();
879 return GNUTLS_E_INVALID_REQUEST; 879 return GNUTLS_E_INVALID_REQUEST;
880 } 880 }
881 881
@@ -884,13 +884,13 @@ gnutls_x509_privkey_generate (gnutls_x509_privkey_t key,
884cleanup:key->pk_algorithm = MHD_GNUTLS_PK_UNKNOWN; 884cleanup:key->pk_algorithm = MHD_GNUTLS_PK_UNKNOWN;
885 key->params_size = 0; 885 key->params_size = 0;
886 for (i = 0; i < params_len; i++) 886 for (i = 0; i < params_len; i++)
887 mhd_gtls_mpi_release (&key->params[i]); 887 MHD_gtls_mpi_release (&key->params[i]);
888 888
889 return ret; 889 return ret;
890} 890}
891 891
892/** 892/**
893 * gnutls_x509_privkey_get_key_id - Return unique ID of the key's parameters 893 * MHD_gnutls_x509_privkey_get_key_id - Return unique ID of the key's parameters
894 * @key: Holds the key 894 * @key: Holds the key
895 * @flags: should be 0 for now 895 * @flags: should be 0 for now
896 * @output_data: will contain the key ID 896 * @output_data: will contain the key ID
@@ -911,68 +911,68 @@ cleanup:key->pk_algorithm = MHD_GNUTLS_PK_UNKNOWN;
911 * 911 *
912 **/ 912 **/
913int 913int
914gnutls_x509_privkey_get_key_id (gnutls_x509_privkey_t key, 914MHD_gnutls_x509_privkey_get_key_id (MHD_gnutls_x509_privkey_t key,
915 unsigned int flags, 915 unsigned int flags,
916 unsigned char *output_data, 916 unsigned char *output_data,
917 size_t * output_data_size) 917 size_t * output_data_size)
918{ 918{
919 int result; 919 int result;
920 GNUTLS_HASH_HANDLE hd; 920 GNUTLS_HASH_HANDLE hd;
921 gnutls_datum_t der = { NULL, 921 MHD_gnutls_datum_t der = { NULL,
922 0 922 0
923 }; 923 };
924 924
925 if (key == NULL || key->crippled) 925 if (key == NULL || key->crippled)
926 { 926 {
927 gnutls_assert (); 927 MHD_gnutls_assert ();
928 return GNUTLS_E_INVALID_REQUEST; 928 return GNUTLS_E_INVALID_REQUEST;
929 } 929 }
930 930
931 if (*output_data_size < 20) 931 if (*output_data_size < 20)
932 { 932 {
933 gnutls_assert (); 933 MHD_gnutls_assert ();
934 *output_data_size = 20; 934 *output_data_size = 20;
935 return GNUTLS_E_SHORT_MEMORY_BUFFER; 935 return GNUTLS_E_SHORT_MEMORY_BUFFER;
936 } 936 }
937 937
938 if (key->pk_algorithm == MHD_GNUTLS_PK_RSA) 938 if (key->pk_algorithm == MHD_GNUTLS_PK_RSA)
939 { 939 {
940 result = _gnutls_x509_write_rsa_params (key->params, key->params_size, 940 result = MHD__gnutls_x509_write_rsa_params (key->params, key->params_size,
941 &der); 941 &der);
942 if (result < 0) 942 if (result < 0)
943 { 943 {
944 gnutls_assert (); 944 MHD_gnutls_assert ();
945 goto cleanup; 945 goto cleanup;
946 } 946 }
947 } 947 }
948 else 948 else
949 return GNUTLS_E_INTERNAL_ERROR; 949 return GNUTLS_E_INTERNAL_ERROR;
950 950
951 hd = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1); 951 hd = MHD_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
952 if (hd == GNUTLS_HASH_FAILED) 952 if (hd == GNUTLS_HASH_FAILED)
953 { 953 {
954 gnutls_assert (); 954 MHD_gnutls_assert ();
955 result = GNUTLS_E_INTERNAL_ERROR; 955 result = GNUTLS_E_INTERNAL_ERROR;
956 goto cleanup; 956 goto cleanup;
957 } 957 }
958 958
959 mhd_gnutls_hash (hd, der.data, der.size); 959 MHD_gnutls_hash (hd, der.data, der.size);
960 960
961 mhd_gnutls_hash_deinit (hd, output_data); 961 MHD_gnutls_hash_deinit (hd, output_data);
962 *output_data_size = 20; 962 *output_data_size = 20;
963 963
964 result = 0; 964 result = 0;
965 965
966cleanup: 966cleanup:
967 967
968 _gnutls_free_datum (&der); 968 MHD__gnutls_free_datum (&der);
969 return result; 969 return result;
970} 970}
971 971
972#ifdef ENABLE_PKI 972#ifdef ENABLE_PKI
973 973
974/** 974/**
975 * gnutls_x509_privkey_sign_data - This function will sign the given data using the private key params 975 * MHD_gnutls_x509_privkey_sign_data - This function will sign the given data using the private key params
976 * @key: Holds the key 976 * @key: Holds the key
977 * @digest: should be MD5 or SHA1 977 * @digest: should be MD5 or SHA1
978 * @flags: should be 0 for now 978 * @flags: should be 0 for now
@@ -995,45 +995,45 @@ cleanup:
995 * 995 *
996 **/ 996 **/
997int 997int
998gnutls_x509_privkey_sign_data (gnutls_x509_privkey_t key, 998MHD_gnutls_x509_privkey_sign_data (MHD_gnutls_x509_privkey_t key,
999 enum MHD_GNUTLS_HashAlgorithm digest, 999 enum MHD_GNUTLS_HashAlgorithm digest,
1000 unsigned int flags, 1000 unsigned int flags,
1001 const gnutls_datum_t * data, 1001 const MHD_gnutls_datum_t * data,
1002 void *signature, size_t * signature_size) 1002 void *signature, size_t * signature_size)
1003{ 1003{
1004 int result; 1004 int result;
1005 gnutls_datum_t sig = { NULL, 0 }; 1005 MHD_gnutls_datum_t sig = { NULL, 0 };
1006 1006
1007 if (key == NULL) 1007 if (key == NULL)
1008 { 1008 {
1009 gnutls_assert (); 1009 MHD_gnutls_assert ();
1010 return GNUTLS_E_INVALID_REQUEST; 1010 return GNUTLS_E_INVALID_REQUEST;
1011 } 1011 }
1012 1012
1013 result = _gnutls_x509_sign (data, digest, key, &sig); 1013 result = MHD__gnutls_x509_sign (data, digest, key, &sig);
1014 if (result < 0) 1014 if (result < 0)
1015 { 1015 {
1016 gnutls_assert (); 1016 MHD_gnutls_assert ();
1017 return result; 1017 return result;
1018 } 1018 }
1019 1019
1020 if (*signature_size < sig.size) 1020 if (*signature_size < sig.size)
1021 { 1021 {
1022 *signature_size = sig.size; 1022 *signature_size = sig.size;
1023 _gnutls_free_datum (&sig); 1023 MHD__gnutls_free_datum (&sig);
1024 return GNUTLS_E_SHORT_MEMORY_BUFFER; 1024 return GNUTLS_E_SHORT_MEMORY_BUFFER;
1025 } 1025 }
1026 1026
1027 *signature_size = sig.size; 1027 *signature_size = sig.size;
1028 memcpy (signature, sig.data, sig.size); 1028 memcpy (signature, sig.data, sig.size);
1029 1029
1030 _gnutls_free_datum (&sig); 1030 MHD__gnutls_free_datum (&sig);
1031 1031
1032 return 0; 1032 return 0;
1033} 1033}
1034 1034
1035/** 1035/**
1036 * gnutls_x509_privkey_sign_hash - This function will sign the given data using the private key params 1036 * MHD_gnutls_x509_privkey_sign_hash - This function will sign the given data using the private key params
1037 * @key: Holds the key 1037 * @key: Holds the key
1038 * @hash: holds the data to be signed 1038 * @hash: holds the data to be signed
1039 * @signature: will contain newly allocated signature 1039 * @signature: will contain newly allocated signature
@@ -1044,23 +1044,23 @@ gnutls_x509_privkey_sign_data (gnutls_x509_privkey_t key,
1044 * and 0 on success. 1044 * and 0 on success.
1045 **/ 1045 **/
1046int 1046int
1047gnutls_x509_privkey_sign_hash (gnutls_x509_privkey_t key, 1047MHD_gnutls_x509_privkey_sign_hash (MHD_gnutls_x509_privkey_t key,
1048 const gnutls_datum_t * hash, 1048 const MHD_gnutls_datum_t * hash,
1049 gnutls_datum_t * signature) 1049 MHD_gnutls_datum_t * signature)
1050{ 1050{
1051 int result; 1051 int result;
1052 1052
1053 if (key == NULL) 1053 if (key == NULL)
1054 { 1054 {
1055 gnutls_assert (); 1055 MHD_gnutls_assert ();
1056 return GNUTLS_E_INVALID_REQUEST; 1056 return GNUTLS_E_INVALID_REQUEST;
1057 } 1057 }
1058 1058
1059 result = mhd_gtls_sign (key->pk_algorithm, key->params, 1059 result = MHD_gtls_sign (key->pk_algorithm, key->params,
1060 key->params_size, hash, signature); 1060 key->params_size, hash, signature);
1061 if (result < 0) 1061 if (result < 0)
1062 { 1062 {
1063 gnutls_assert (); 1063 MHD_gnutls_assert ();
1064 return result; 1064 return result;
1065 } 1065 }
1066 1066
@@ -1068,7 +1068,7 @@ gnutls_x509_privkey_sign_hash (gnutls_x509_privkey_t key,
1068} 1068}
1069 1069
1070/** 1070/**
1071 * gnutls_x509_privkey_verify_data - This function will verify the given signed data. 1071 * MHD_gnutls_x509_privkey_verify_data - This function will verify the given signed data.
1072 * @key: Holds the key 1072 * @key: Holds the key
1073 * @flags: should be 0 for now 1073 * @flags: should be 0 for now
1074 * @data: holds the data to be signed 1074 * @data: holds the data to be signed
@@ -1082,23 +1082,23 @@ gnutls_x509_privkey_sign_hash (gnutls_x509_privkey_t key,
1082 * 1082 *
1083 **/ 1083 **/
1084int 1084int
1085gnutls_x509_privkey_verify_data (gnutls_x509_privkey_t key, 1085MHD_gnutls_x509_privkey_verify_data (MHD_gnutls_x509_privkey_t key,
1086 unsigned int flags, 1086 unsigned int flags,
1087 const gnutls_datum_t * data, 1087 const MHD_gnutls_datum_t * data,
1088 const gnutls_datum_t * signature) 1088 const MHD_gnutls_datum_t * signature)
1089{ 1089{
1090 int result; 1090 int result;
1091 1091
1092 if (key == NULL) 1092 if (key == NULL)
1093 { 1093 {
1094 gnutls_assert (); 1094 MHD_gnutls_assert ();
1095 return GNUTLS_E_INVALID_REQUEST; 1095 return GNUTLS_E_INVALID_REQUEST;
1096 } 1096 }
1097 1097
1098 result = _gnutls_x509_privkey_verify_signature (data, signature, key); 1098 result = MHD__gnutls_x509_privkey_verify_signature (data, signature, key);
1099 if (result < 0) 1099 if (result < 0)
1100 { 1100 {
1101 gnutls_assert (); 1101 MHD_gnutls_assert ();
1102 return 0; 1102 return 0;
1103 } 1103 }
1104 1104
@@ -1106,7 +1106,7 @@ gnutls_x509_privkey_verify_data (gnutls_x509_privkey_t key,
1106} 1106}
1107 1107
1108/** 1108/**
1109 * gnutls_x509_privkey_fix - This function will recalculate some parameters of the key. 1109 * MHD_gnutls_x509_privkey_fix - This function will recalculate some parameters of the key.
1110 * @key: Holds the key 1110 * @key: Holds the key
1111 * 1111 *
1112 * This function will recalculate the secondary parameters in a key. 1112 * This function will recalculate the secondary parameters in a key.
@@ -1117,30 +1117,30 @@ gnutls_x509_privkey_verify_data (gnutls_x509_privkey_t key,
1117 * 1117 *
1118 **/ 1118 **/
1119int 1119int
1120gnutls_x509_privkey_fix (gnutls_x509_privkey_t key) 1120MHD_gnutls_x509_privkey_fix (MHD_gnutls_x509_privkey_t key)
1121{ 1121{
1122 int ret; 1122 int ret;
1123 1123
1124 if (key == NULL) 1124 if (key == NULL)
1125 { 1125 {
1126 gnutls_assert (); 1126 MHD_gnutls_assert ();
1127 return GNUTLS_E_INVALID_REQUEST; 1127 return GNUTLS_E_INVALID_REQUEST;
1128 } 1128 }
1129 1129
1130 if (!key->crippled) 1130 if (!key->crippled)
1131 asn1_delete_structure (&key->key); 1131 MHD__asn1_delete_structure (&key->key);
1132 switch (key->pk_algorithm) 1132 switch (key->pk_algorithm)
1133 { 1133 {
1134 case MHD_GNUTLS_PK_RSA: 1134 case MHD_GNUTLS_PK_RSA:
1135 ret = _gnutls_asn1_encode_rsa (&key->key, key->params); 1135 ret = MHD__gnutlsMHD__asn1_encode_rsa (&key->key, key->params);
1136 if (ret < 0) 1136 if (ret < 0)
1137 { 1137 {
1138 gnutls_assert (); 1138 MHD_gnutls_assert ();
1139 return ret; 1139 return ret;
1140 } 1140 }
1141 break; 1141 break;
1142 default: 1142 default:
1143 gnutls_assert (); 1143 MHD_gnutls_assert ();
1144 return GNUTLS_E_INVALID_REQUEST; 1144 return GNUTLS_E_INVALID_REQUEST;
1145 } 1145 }
1146 1146
diff --git a/src/daemon/https/x509/x509_verify.c b/src/daemon/https/x509/x509_verify.c
index e9d784ce..cbeb7670 100644
--- a/src/daemon/https/x509/x509_verify.c
+++ b/src/daemon/https/x509/x509_verify.c
@@ -41,19 +41,19 @@
41#include <common.h> 41#include <common.h>
42#include <verify.h> 42#include <verify.h>
43 43
44static int _gnutls_verify_certificate2 (gnutls_x509_crt_t cert, 44static int MHD__gnutls_verify_certificate2 (MHD_gnutls_x509_crt_t cert,
45 const gnutls_x509_crt_t * trusted_cas, 45 const MHD_gnutls_x509_crt_t * trusted_cas,
46 int tcas_size, 46 int tcas_size,
47 unsigned int flags, 47 unsigned int flags,
48 unsigned int *output); 48 unsigned int *output);
49int _gnutls_x509_verify_signature (const gnutls_datum_t * signed_data, 49int MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * signed_data,
50 const gnutls_datum_t * signature, 50 const MHD_gnutls_datum_t * signature,
51 gnutls_x509_crt_t issuer); 51 MHD_gnutls_x509_crt_t issuer);
52 52
53static 53static
54 int is_crl_issuer (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer_cert); 54 int is_crl_issuer (MHD_gnutls_x509_crl_t crl, MHD_gnutls_x509_crt_t issuer_cert);
55static int _gnutls_verify_crl2 (gnutls_x509_crl_t crl, 55static int MHD__gnutls_verify_crl2 (MHD_gnutls_x509_crl_t crl,
56 const gnutls_x509_crt_t * trusted_cas, 56 const MHD_gnutls_x509_crt_t * trusted_cas,
57 int tcas_size, 57 int tcas_size,
58 unsigned int flags, unsigned int *output); 58 unsigned int flags, unsigned int *output);
59 59
@@ -65,19 +65,19 @@ static int _gnutls_verify_crl2 (gnutls_x509_crl_t crl,
65 * or not. 65 * or not.
66 */ 66 */
67static int 67static int
68check_if_ca (gnutls_x509_crt_t cert, 68check_if_ca (MHD_gnutls_x509_crt_t cert,
69 gnutls_x509_crt_t issuer, unsigned int flags) 69 MHD_gnutls_x509_crt_t issuer, unsigned int flags)
70{ 70{
71 gnutls_datum_t cert_signed_data = { NULL, 71 MHD_gnutls_datum_t cert_signed_data = { NULL,
72 0 72 0
73 }; 73 };
74 gnutls_datum_t issuer_signed_data = { NULL, 74 MHD_gnutls_datum_t issuer_signed_data = { NULL,
75 0 75 0
76 }; 76 };
77 gnutls_datum_t cert_signature = { NULL, 77 MHD_gnutls_datum_t cert_signature = { NULL,
78 0 78 0
79 }; 79 };
80 gnutls_datum_t issuer_signature = { NULL, 80 MHD_gnutls_datum_t issuer_signature = { NULL,
81 0 81 0
82 }; 82 };
83 int result; 83 int result;
@@ -87,35 +87,35 @@ check_if_ca (gnutls_x509_crt_t cert,
87 * certificates to be able to verify themselves. 87 * certificates to be able to verify themselves.
88 */ 88 */
89 89
90 result = _gnutls_x509_get_signed_data (issuer->cert, "tbsCertificate", 90 result = MHD__gnutls_x509_get_signed_data (issuer->cert, "tbsCertificate",
91 &issuer_signed_data); 91 &issuer_signed_data);
92 if (result < 0) 92 if (result < 0)
93 { 93 {
94 gnutls_assert (); 94 MHD_gnutls_assert ();
95 goto cleanup; 95 goto cleanup;
96 } 96 }
97 97
98 result = _gnutls_x509_get_signed_data (cert->cert, "tbsCertificate", 98 result = MHD__gnutls_x509_get_signed_data (cert->cert, "tbsCertificate",
99 &cert_signed_data); 99 &cert_signed_data);
100 if (result < 0) 100 if (result < 0)
101 { 101 {
102 gnutls_assert (); 102 MHD_gnutls_assert ();
103 goto cleanup; 103 goto cleanup;
104 } 104 }
105 105
106 result = _gnutls_x509_get_signature (issuer->cert, "signature", 106 result = MHD__gnutls_x509_get_signature (issuer->cert, "signature",
107 &issuer_signature); 107 &issuer_signature);
108 if (result < 0) 108 if (result < 0)
109 { 109 {
110 gnutls_assert (); 110 MHD_gnutls_assert ();
111 goto cleanup; 111 goto cleanup;
112 } 112 }
113 113
114 result = 114 result =
115 _gnutls_x509_get_signature (cert->cert, "signature", &cert_signature); 115 MHD__gnutls_x509_get_signature (cert->cert, "signature", &cert_signature);
116 if (result < 0) 116 if (result < 0)
117 { 117 {
118 gnutls_assert (); 118 MHD_gnutls_assert ();
119 goto cleanup; 119 goto cleanup;
120 } 120 }
121 121
@@ -139,20 +139,20 @@ check_if_ca (gnutls_x509_crt_t cert,
139 } 139 }
140 } 140 }
141 141
142 if (gnutls_x509_crt_get_ca_status (issuer, NULL) == 1) 142 if (MHD_gnutls_x509_crt_get_ca_status (issuer, NULL) == 1)
143 { 143 {
144 result = 1; 144 result = 1;
145 goto cleanup; 145 goto cleanup;
146 } 146 }
147 else 147 else
148 gnutls_assert (); 148 MHD_gnutls_assert ();
149 149
150 result = 0; 150 result = 0;
151 151
152cleanup:_gnutls_free_datum (&cert_signed_data); 152cleanup:MHD__gnutls_free_datum (&cert_signed_data);
153 _gnutls_free_datum (&issuer_signed_data); 153 MHD__gnutls_free_datum (&issuer_signed_data);
154 _gnutls_free_datum (&cert_signature); 154 MHD__gnutls_free_datum (&cert_signature);
155 _gnutls_free_datum (&issuer_signature); 155 MHD__gnutls_free_datum (&issuer_signature);
156 return result; 156 return result;
157} 157}
158 158
@@ -164,40 +164,40 @@ cleanup:_gnutls_free_datum (&cert_signed_data);
164 * a negative value is returned to indicate error. 164 * a negative value is returned to indicate error.
165 */ 165 */
166static int 166static int
167is_issuer (gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer_cert) 167is_issuer (MHD_gnutls_x509_crt_t cert, MHD_gnutls_x509_crt_t issuer_cert)
168{ 168{
169 gnutls_datum_t dn1 = { NULL, 169 MHD_gnutls_datum_t dn1 = { NULL,
170 0 170 0
171 }, dn2 = 171 }, dn2 =
172 { 172 {
173 NULL, 0}; 173 NULL, 0};
174 int ret; 174 int ret;
175 175
176 ret = gnutls_x509_crt_get_raw_issuer_dn (cert, &dn1); 176 ret = MHD_gnutls_x509_crt_get_raw_issuer_dn (cert, &dn1);
177 if (ret < 0) 177 if (ret < 0)
178 { 178 {
179 gnutls_assert (); 179 MHD_gnutls_assert ();
180 goto cleanup; 180 goto cleanup;
181 } 181 }
182 182
183 ret = gnutls_x509_crt_get_raw_dn (issuer_cert, &dn2); 183 ret = MHD_gnutls_x509_crt_get_raw_dn (issuer_cert, &dn2);
184 if (ret < 0) 184 if (ret < 0)
185 { 185 {
186 gnutls_assert (); 186 MHD_gnutls_assert ();
187 goto cleanup; 187 goto cleanup;
188 } 188 }
189 189
190 ret = _gnutls_x509_compare_raw_dn (&dn1, &dn2); 190 ret = MHD__gnutls_x509_compare_raw_dn (&dn1, &dn2);
191 191
192cleanup:_gnutls_free_datum (&dn1); 192cleanup:MHD__gnutls_free_datum (&dn1);
193 _gnutls_free_datum (&dn2); 193 MHD__gnutls_free_datum (&dn2);
194 return ret; 194 return ret;
195 195
196} 196}
197 197
198static inline gnutls_x509_crt_t 198static inline MHD_gnutls_x509_crt_t
199find_issuer (gnutls_x509_crt_t cert, 199find_issuer (MHD_gnutls_x509_crt_t cert,
200 const gnutls_x509_crt_t * trusted_cas, int tcas_size) 200 const MHD_gnutls_x509_crt_t * trusted_cas, int tcas_size)
201{ 201{
202 int i; 202 int i;
203 203
@@ -210,7 +210,7 @@ find_issuer (gnutls_x509_crt_t cert,
210 return trusted_cas[i]; 210 return trusted_cas[i];
211 } 211 }
212 212
213 gnutls_assert (); 213 MHD_gnutls_assert ();
214 return NULL; 214 return NULL;
215} 215}
216 216
@@ -221,24 +221,24 @@ find_issuer (gnutls_x509_crt_t cert,
221 * Returns only 0 or 1. If 1 it means that the certificate 221 * Returns only 0 or 1. If 1 it means that the certificate
222 * was successfuly verified. 222 * was successfuly verified.
223 * 223 *
224 * 'flags': an OR of the gnutls_certificate_verify_flags enumeration. 224 * 'flags': an OR of the MHD_gnutls_certificate_verify_flags enumeration.
225 * 225 *
226 * Output will hold some extra information about the verification 226 * Output will hold some extra information about the verification
227 * procedure. 227 * procedure.
228 */ 228 */
229static int 229static int
230_gnutls_verify_certificate2 (gnutls_x509_crt_t cert, 230MHD__gnutls_verify_certificate2 (MHD_gnutls_x509_crt_t cert,
231 const gnutls_x509_crt_t * trusted_cas, 231 const MHD_gnutls_x509_crt_t * trusted_cas,
232 int tcas_size, 232 int tcas_size,
233 unsigned int flags, unsigned int *output) 233 unsigned int flags, unsigned int *output)
234{ 234{
235 gnutls_datum_t cert_signed_data = { NULL, 235 MHD_gnutls_datum_t cert_signed_data = { NULL,
236 0 236 0
237 }; 237 };
238 gnutls_datum_t cert_signature = { NULL, 238 MHD_gnutls_datum_t cert_signature = { NULL,
239 0 239 0
240 }; 240 };
241 gnutls_x509_crt_t issuer; 241 MHD_gnutls_x509_crt_t issuer;
242 int ret, issuer_version, result; 242 int ret, issuer_version, result;
243 243
244 if (output) 244 if (output)
@@ -248,7 +248,7 @@ _gnutls_verify_certificate2 (gnutls_x509_crt_t cert,
248 issuer = find_issuer (cert, trusted_cas, tcas_size); 248 issuer = find_issuer (cert, trusted_cas, tcas_size);
249 else 249 else
250 { 250 {
251 gnutls_assert (); 251 MHD_gnutls_assert ();
252 if (output) 252 if (output)
253 *output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID; 253 *output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID;
254 return 0; 254 return 0;
@@ -261,14 +261,14 @@ _gnutls_verify_certificate2 (gnutls_x509_crt_t cert,
261 { 261 {
262 if (output) 262 if (output)
263 *output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID; 263 *output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID;
264 gnutls_assert (); 264 MHD_gnutls_assert ();
265 return 0; 265 return 0;
266 } 266 }
267 267
268 issuer_version = gnutls_x509_crt_get_version (issuer); 268 issuer_version = MHD_gnutls_x509_crt_get_version (issuer);
269 if (issuer_version < 0) 269 if (issuer_version < 0)
270 { 270 {
271 gnutls_assert (); 271 MHD_gnutls_assert ();
272 return issuer_version; 272 return issuer_version;
273 } 273 }
274 274
@@ -279,38 +279,38 @@ _gnutls_verify_certificate2 (gnutls_x509_crt_t cert,
279 { 279 {
280 if (check_if_ca (cert, issuer, flags) == 0) 280 if (check_if_ca (cert, issuer, flags) == 0)
281 { 281 {
282 gnutls_assert (); 282 MHD_gnutls_assert ();
283 if (output) 283 if (output)
284 *output |= GNUTLS_CERT_SIGNER_NOT_CA | GNUTLS_CERT_INVALID; 284 *output |= GNUTLS_CERT_SIGNER_NOT_CA | GNUTLS_CERT_INVALID;
285 return 0; 285 return 0;
286 } 286 }
287 } 287 }
288 288
289 result = _gnutls_x509_get_signed_data (cert->cert, "tbsCertificate", 289 result = MHD__gnutls_x509_get_signed_data (cert->cert, "tbsCertificate",
290 &cert_signed_data); 290 &cert_signed_data);
291 if (result < 0) 291 if (result < 0)
292 { 292 {
293 gnutls_assert (); 293 MHD_gnutls_assert ();
294 goto cleanup; 294 goto cleanup;
295 } 295 }
296 296
297 result = 297 result =
298 _gnutls_x509_get_signature (cert->cert, "signature", &cert_signature); 298 MHD__gnutls_x509_get_signature (cert->cert, "signature", &cert_signature);
299 if (result < 0) 299 if (result < 0)
300 { 300 {
301 gnutls_assert (); 301 MHD_gnutls_assert ();
302 goto cleanup; 302 goto cleanup;
303 } 303 }
304 304
305 ret = _gnutls_x509_verify_signature (&cert_signed_data, &cert_signature, 305 ret = MHD__gnutls_x509_verify_signature (&cert_signed_data, &cert_signature,
306 issuer); 306 issuer);
307 if (ret < 0) 307 if (ret < 0)
308 { 308 {
309 gnutls_assert (); 309 MHD_gnutls_assert ();
310 } 310 }
311 else if (ret == 0) 311 else if (ret == 0)
312 { 312 {
313 gnutls_assert (); 313 MHD_gnutls_assert ();
314 /* error. ignore it */ 314 /* error. ignore it */
315 if (output) 315 if (output)
316 *output |= GNUTLS_CERT_INVALID; 316 *output |= GNUTLS_CERT_INVALID;
@@ -325,7 +325,7 @@ _gnutls_verify_certificate2 (gnutls_x509_crt_t cert,
325 { 325 {
326 int sigalg; 326 int sigalg;
327 327
328 sigalg = gnutls_x509_crt_get_signature_algorithm (cert); 328 sigalg = MHD_gnutls_x509_crt_get_signature_algorithm (cert);
329 329
330 if (((sigalg == GNUTLS_SIGN_RSA_MD2) && !(flags 330 if (((sigalg == GNUTLS_SIGN_RSA_MD2) && !(flags
331 & 331 &
@@ -340,14 +340,14 @@ _gnutls_verify_certificate2 (gnutls_x509_crt_t cert,
340 340
341 result = ret; 341 result = ret;
342 342
343cleanup:_gnutls_free_datum (&cert_signed_data); 343cleanup:MHD__gnutls_free_datum (&cert_signed_data);
344 _gnutls_free_datum (&cert_signature); 344 MHD__gnutls_free_datum (&cert_signature);
345 345
346 return result; 346 return result;
347} 347}
348 348
349/** 349/**
350 * gnutls_x509_crt_check_issuer - This function checks if the certificate given has the given issuer 350 * MHD_gnutls_x509_crt_check_issuer - This function checks if the certificate given has the given issuer
351 * @cert: is the certificate to be checked 351 * @cert: is the certificate to be checked
352 * @issuer: is the certificate of a possible issuer 352 * @issuer: is the certificate of a possible issuer
353 * 353 *
@@ -359,8 +359,8 @@ cleanup:_gnutls_free_datum (&cert_signed_data);
359 * 359 *
360 **/ 360 **/
361int 361int
362gnutls_x509_crt_check_issuer (gnutls_x509_crt_t cert, 362MHD_gnutls_x509_crt_check_issuer (MHD_gnutls_x509_crt_t cert,
363 gnutls_x509_crt_t issuer) 363 MHD_gnutls_x509_crt_t issuer)
364{ 364{
365 return is_issuer (cert, issuer); 365 return is_issuer (cert, issuer);
366} 366}
@@ -377,11 +377,11 @@ gnutls_x509_crt_check_issuer (gnutls_x509_crt_t cert,
377 * lead to a trusted CA in order to be trusted. 377 * lead to a trusted CA in order to be trusted.
378 */ 378 */
379static unsigned int 379static unsigned int
380_gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list, 380MHD__gnutls_x509_verify_certificate (const MHD_gnutls_x509_crt_t * certificate_list,
381 int clist_size, 381 int clist_size,
382 const gnutls_x509_crt_t * trusted_cas, 382 const MHD_gnutls_x509_crt_t * trusted_cas,
383 int tcas_size, 383 int tcas_size,
384 const gnutls_x509_crl_t * CRLs, 384 const MHD_gnutls_x509_crl_t * CRLs,
385 int crls_size, unsigned int flags) 385 int crls_size, unsigned int flags)
386{ 386{
387 int i = 0, ret; 387 int i = 0, ret;
@@ -393,7 +393,7 @@ _gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list,
393 * If no CAs are present returns CERT_INVALID. Thus works 393 * If no CAs are present returns CERT_INVALID. Thus works
394 * in self signed etc certificates. 394 * in self signed etc certificates.
395 */ 395 */
396 ret = _gnutls_verify_certificate2 (certificate_list[clist_size - 1], 396 ret = MHD__gnutls_verify_certificate2 (certificate_list[clist_size - 1],
397 trusted_cas, tcas_size, flags, &output); 397 trusted_cas, tcas_size, flags, &output);
398 398
399 if (ret == 0) 399 if (ret == 0)
@@ -402,7 +402,7 @@ _gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list,
402 * list is invalid, then the certificate is not 402 * list is invalid, then the certificate is not
403 * trusted. 403 * trusted.
404 */ 404 */
405 gnutls_assert (); 405 MHD_gnutls_assert ();
406 status |= output; 406 status |= output;
407 status |= GNUTLS_CERT_INVALID; 407 status |= GNUTLS_CERT_INVALID;
408 return status; 408 return status;
@@ -413,7 +413,7 @@ _gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list,
413#ifdef ENABLE_PKI 413#ifdef ENABLE_PKI
414 for (i = 0; i < clist_size; i++) 414 for (i = 0; i < clist_size; i++)
415 { 415 {
416 ret = gnutls_x509_crt_check_revocation (certificate_list[i], 416 ret = MHD_gnutls_x509_crt_check_revocation (certificate_list[i],
417 CRLs, crls_size); 417 CRLs, crls_size);
418 if (ret == 1) 418 if (ret == 1)
419 { /* revoked */ 419 { /* revoked */
@@ -428,7 +428,7 @@ _gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list,
428 * In that case ignore it (a certificate is trusted only if it 428 * In that case ignore it (a certificate is trusted only if it
429 * leads to a trusted party by us, not the server's). 429 * leads to a trusted party by us, not the server's).
430 */ 430 */
431 if (gnutls_x509_crt_check_issuer (certificate_list[clist_size - 1], 431 if (MHD_gnutls_x509_crt_check_issuer (certificate_list[clist_size - 1],
432 certificate_list[clist_size - 1]) > 0 432 certificate_list[clist_size - 1]) > 0
433 && clist_size > 0) 433 && clist_size > 0)
434 { 434 {
@@ -447,7 +447,7 @@ _gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list,
447 */ 447 */
448 if (!(flags & GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT)) 448 if (!(flags & GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT))
449 flags ^= GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT; 449 flags ^= GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT;
450 if ((ret = _gnutls_verify_certificate2 (certificate_list[i - 1], 450 if ((ret = MHD__gnutls_verify_certificate2 (certificate_list[i - 1],
451 &certificate_list[i], 1, flags, 451 &certificate_list[i], 1, flags,
452 NULL)) == 0) 452 NULL)) == 0)
453 { 453 {
@@ -464,7 +464,7 @@ _gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list,
464 * anyway. 464 * anyway.
465 */ 465 */
466static int 466static int
467decode_ber_digest_info (const gnutls_datum_t * info, 467decode_ber_digest_info (const MHD_gnutls_datum_t * info,
468 enum MHD_GNUTLS_HashAlgorithm *hash, 468 enum MHD_GNUTLS_HashAlgorithm *hash,
469 opaque * digest, int *digest_size) 469 opaque * digest, int *digest_size)
470{ 470{
@@ -473,45 +473,45 @@ decode_ber_digest_info (const gnutls_datum_t * info,
473 char str[1024]; 473 char str[1024];
474 int len; 474 int len;
475 475
476 if ((result = asn1_create_element (_gnutls_get_gnutls_asn (), 476 if ((result = MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (),
477 "GNUTLS.DigestInfo", 477 "GNUTLS.DigestInfo",
478 &dinfo)) != ASN1_SUCCESS) 478 &dinfo)) != ASN1_SUCCESS)
479 { 479 {
480 gnutls_assert (); 480 MHD_gnutls_assert ();
481 return mhd_gtls_asn2err (result); 481 return MHD_gtls_asn2err (result);
482 } 482 }
483 483
484 result = asn1_der_decoding (&dinfo, info->data, info->size, NULL); 484 result = MHD__asn1_der_decoding (&dinfo, info->data, info->size, NULL);
485 if (result != ASN1_SUCCESS) 485 if (result != ASN1_SUCCESS)
486 { 486 {
487 gnutls_assert (); 487 MHD_gnutls_assert ();
488 asn1_delete_structure (&dinfo); 488 MHD__asn1_delete_structure (&dinfo);
489 return mhd_gtls_asn2err (result); 489 return MHD_gtls_asn2err (result);
490 } 490 }
491 491
492 len = sizeof (str) - 1; 492 len = sizeof (str) - 1;
493 result = asn1_read_value (dinfo, "digestAlgorithm.algorithm", str, &len); 493 result = MHD__asn1_read_value (dinfo, "digestAlgorithm.algorithm", str, &len);
494 if (result != ASN1_SUCCESS) 494 if (result != ASN1_SUCCESS)
495 { 495 {
496 gnutls_assert (); 496 MHD_gnutls_assert ();
497 asn1_delete_structure (&dinfo); 497 MHD__asn1_delete_structure (&dinfo);
498 return mhd_gtls_asn2err (result); 498 return MHD_gtls_asn2err (result);
499 } 499 }
500 500
501 *hash = mhd_gtls_x509_oid2mac_algorithm (str); 501 *hash = MHD_gtls_x509_oid2mac_algorithm (str);
502 502
503 if (*hash == MHD_GNUTLS_MAC_UNKNOWN) 503 if (*hash == MHD_GNUTLS_MAC_UNKNOWN)
504 { 504 {
505 505
506 _gnutls_x509_log ("verify.c: HASH OID: %s\n", str); 506 MHD__gnutls_x509_log ("verify.c: HASH OID: %s\n", str);
507 507
508 gnutls_assert (); 508 MHD_gnutls_assert ();
509 asn1_delete_structure (&dinfo); 509 MHD__asn1_delete_structure (&dinfo);
510 return GNUTLS_E_UNKNOWN_ALGORITHM; 510 return GNUTLS_E_UNKNOWN_ALGORITHM;
511 } 511 }
512 512
513 len = sizeof (str) - 1; 513 len = sizeof (str) - 1;
514 result = asn1_read_value (dinfo, "digestAlgorithm.parameters", str, &len); 514 result = MHD__asn1_read_value (dinfo, "digestAlgorithm.parameters", str, &len);
515 /* To avoid permitting garbage in the parameters field, either the 515 /* To avoid permitting garbage in the parameters field, either the
516 parameters field is not present, or it contains 0x05 0x00. */ 516 parameters field is not present, or it contains 0x05 0x00. */
517 if (! 517 if (!
@@ -519,20 +519,20 @@ decode_ber_digest_info (const gnutls_datum_t * info,
519 || (result == ASN1_SUCCESS && len == 2 && str[0] == 0x05 519 || (result == ASN1_SUCCESS && len == 2 && str[0] == 0x05
520 && str[1] == 0x00))) 520 && str[1] == 0x00)))
521 { 521 {
522 gnutls_assert (); 522 MHD_gnutls_assert ();
523 asn1_delete_structure (&dinfo); 523 MHD__asn1_delete_structure (&dinfo);
524 return GNUTLS_E_ASN1_GENERIC_ERROR; 524 return GNUTLS_E_ASN1_GENERIC_ERROR;
525 } 525 }
526 526
527 result = asn1_read_value (dinfo, "digest", digest, digest_size); 527 result = MHD__asn1_read_value (dinfo, "digest", digest, digest_size);
528 if (result != ASN1_SUCCESS) 528 if (result != ASN1_SUCCESS)
529 { 529 {
530 gnutls_assert (); 530 MHD_gnutls_assert ();
531 asn1_delete_structure (&dinfo); 531 MHD__asn1_delete_structure (&dinfo);
532 return mhd_gtls_asn2err (result); 532 return MHD_gtls_asn2err (result);
533 } 533 }
534 534
535 asn1_delete_structure (&dinfo); 535 MHD__asn1_delete_structure (&dinfo);
536 536
537 return 0; 537 return 0;
538} 538}
@@ -543,8 +543,8 @@ decode_ber_digest_info (const gnutls_datum_t * info,
543 * params[1] is public key 543 * params[1] is public key
544 */ 544 */
545static int 545static int
546_pkcs1_rsa_verify_sig (const gnutls_datum_t * text, 546_pkcs1_rsa_verify_sig (const MHD_gnutls_datum_t * text,
547 const gnutls_datum_t * signature, 547 const MHD_gnutls_datum_t * signature,
548 mpi_t * params, int params_len) 548 mpi_t * params, int params_len)
549{ 549{
550 enum MHD_GNUTLS_HashAlgorithm hash = MHD_GNUTLS_MAC_UNKNOWN; 550 enum MHD_GNUTLS_HashAlgorithm hash = MHD_GNUTLS_MAC_UNKNOWN;
@@ -552,13 +552,13 @@ _pkcs1_rsa_verify_sig (const gnutls_datum_t * text,
552 opaque digest[MAX_HASH_SIZE], md[MAX_HASH_SIZE]; 552 opaque digest[MAX_HASH_SIZE], md[MAX_HASH_SIZE];
553 int digest_size; 553 int digest_size;
554 GNUTLS_HASH_HANDLE hd; 554 GNUTLS_HASH_HANDLE hd;
555 gnutls_datum_t decrypted; 555 MHD_gnutls_datum_t decrypted;
556 556
557 ret = 557 ret =
558 mhd_gtls_pkcs1_rsa_decrypt (&decrypted, signature, params, params_len, 1); 558 MHD_gtls_pkcs1_rsa_decrypt (&decrypted, signature, params, params_len, 1);
559 if (ret < 0) 559 if (ret < 0)
560 { 560 {
561 gnutls_assert (); 561 MHD_gnutls_assert ();
562 return ret; 562 return ret;
563 } 563 }
564 564
@@ -569,32 +569,32 @@ _pkcs1_rsa_verify_sig (const gnutls_datum_t * text,
569 if ((ret = decode_ber_digest_info (&decrypted, &hash, digest, &digest_size)) 569 if ((ret = decode_ber_digest_info (&decrypted, &hash, digest, &digest_size))
570 != 0) 570 != 0)
571 { 571 {
572 gnutls_assert (); 572 MHD_gnutls_assert ();
573 _gnutls_free_datum (&decrypted); 573 MHD__gnutls_free_datum (&decrypted);
574 return ret; 574 return ret;
575 } 575 }
576 576
577 _gnutls_free_datum (&decrypted); 577 MHD__gnutls_free_datum (&decrypted);
578 578
579 if (digest_size != mhd_gnutls_hash_get_algo_len (hash)) 579 if (digest_size != MHD_gnutls_hash_get_algo_len (hash))
580 { 580 {
581 gnutls_assert (); 581 MHD_gnutls_assert ();
582 return GNUTLS_E_ASN1_GENERIC_ERROR; 582 return GNUTLS_E_ASN1_GENERIC_ERROR;
583 } 583 }
584 584
585 hd = mhd_gtls_hash_init (hash); 585 hd = MHD_gtls_hash_init (hash);
586 if (hd == NULL) 586 if (hd == NULL)
587 { 587 {
588 gnutls_assert (); 588 MHD_gnutls_assert ();
589 return GNUTLS_E_HASH_FAILED; 589 return GNUTLS_E_HASH_FAILED;
590 } 590 }
591 591
592 mhd_gnutls_hash (hd, text->data, text->size); 592 MHD_gnutls_hash (hd, text->data, text->size);
593 mhd_gnutls_hash_deinit (hd, md); 593 MHD_gnutls_hash_deinit (hd, md);
594 594
595 if (memcmp (md, digest, digest_size) != 0) 595 if (memcmp (md, digest, digest_size) != 0)
596 { 596 {
597 gnutls_assert (); 597 MHD_gnutls_assert ();
598 return GNUTLS_E_PK_SIG_VERIFY_FAILED; 598 return GNUTLS_E_PK_SIG_VERIFY_FAILED;
599 } 599 }
600 600
@@ -604,29 +604,29 @@ _pkcs1_rsa_verify_sig (const gnutls_datum_t * text,
604/* Hashes input data and verifies a DSA signature. 604/* Hashes input data and verifies a DSA signature.
605 */ 605 */
606static int 606static int
607dsa_verify_sig (const gnutls_datum_t * text, 607dsa_verify_sig (const MHD_gnutls_datum_t * text,
608 const gnutls_datum_t * signature, 608 const MHD_gnutls_datum_t * signature,
609 mpi_t * params, int params_len) 609 mpi_t * params, int params_len)
610{ 610{
611 int ret; 611 int ret;
612 opaque _digest[MAX_HASH_SIZE]; 612 opaque _digest[MAX_HASH_SIZE];
613 gnutls_datum_t digest; 613 MHD_gnutls_datum_t digest;
614 GNUTLS_HASH_HANDLE hd; 614 GNUTLS_HASH_HANDLE hd;
615 615
616 hd = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1); 616 hd = MHD_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
617 if (hd == NULL) 617 if (hd == NULL)
618 { 618 {
619 gnutls_assert (); 619 MHD_gnutls_assert ();
620 return GNUTLS_E_HASH_FAILED; 620 return GNUTLS_E_HASH_FAILED;
621 } 621 }
622 622
623 mhd_gnutls_hash (hd, text->data, text->size); 623 MHD_gnutls_hash (hd, text->data, text->size);
624 mhd_gnutls_hash_deinit (hd, _digest); 624 MHD_gnutls_hash_deinit (hd, _digest);
625 625
626 digest.data = _digest; 626 digest.data = _digest;
627 digest.size = 20; 627 digest.size = 20;
628 628
629 ret = mhd_gtls_dsa_verify (&digest, signature, params, params_len); 629 ret = MHD_gtls_dsa_verify (&digest, signature, params, params_len);
630 630
631 return ret; 631 return ret;
632} 632}
@@ -635,8 +635,8 @@ dsa_verify_sig (const gnutls_datum_t * text,
635 * or 1 otherwise. 635 * or 1 otherwise.
636 */ 636 */
637static int 637static int
638verify_sig (const gnutls_datum_t * tbs, 638verify_sig (const MHD_gnutls_datum_t * tbs,
639 const gnutls_datum_t * signature, 639 const MHD_gnutls_datum_t * signature,
640 enum MHD_GNUTLS_PublicKeyAlgorithm pk, 640 enum MHD_GNUTLS_PublicKeyAlgorithm pk,
641 mpi_t * issuer_params, int issuer_params_size) 641 mpi_t * issuer_params, int issuer_params_size)
642{ 642{
@@ -648,7 +648,7 @@ verify_sig (const gnutls_datum_t * tbs,
648 if (_pkcs1_rsa_verify_sig 648 if (_pkcs1_rsa_verify_sig
649 (tbs, signature, issuer_params, issuer_params_size) != 0) 649 (tbs, signature, issuer_params, issuer_params_size) != 0)
650 { 650 {
651 gnutls_assert (); 651 MHD_gnutls_assert ();
652 return 0; 652 return 0;
653 } 653 }
654 654
@@ -656,7 +656,7 @@ verify_sig (const gnutls_datum_t * tbs,
656 break; 656 break;
657 657
658 default: 658 default:
659 gnutls_assert (); 659 MHD_gnutls_assert ();
660 return GNUTLS_E_INTERNAL_ERROR; 660 return GNUTLS_E_INTERNAL_ERROR;
661 661
662 } 662 }
@@ -669,9 +669,9 @@ verify_sig (const gnutls_datum_t * tbs,
669 * 'signature' is the signature! 669 * 'signature' is the signature!
670 */ 670 */
671int 671int
672_gnutls_x509_verify_signature (const gnutls_datum_t * tbs, 672MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * tbs,
673 const gnutls_datum_t * signature, 673 const MHD_gnutls_datum_t * signature,
674 gnutls_x509_crt_t issuer) 674 MHD_gnutls_x509_crt_t issuer)
675{ 675{
676 mpi_t issuer_params[MAX_PUBLIC_PARAMS_SIZE]; 676 mpi_t issuer_params[MAX_PUBLIC_PARAMS_SIZE];
677 int ret, issuer_params_size, i; 677 int ret, issuer_params_size, i;
@@ -680,26 +680,26 @@ _gnutls_x509_verify_signature (const gnutls_datum_t * tbs,
680 */ 680 */
681 issuer_params_size = MAX_PUBLIC_PARAMS_SIZE; 681 issuer_params_size = MAX_PUBLIC_PARAMS_SIZE;
682 ret = 682 ret =
683 _gnutls_x509_crt_get_mpis (issuer, issuer_params, &issuer_params_size); 683 MHD__gnutls_x509_crt_get_mpis (issuer, issuer_params, &issuer_params_size);
684 if (ret < 0) 684 if (ret < 0)
685 { 685 {
686 gnutls_assert (); 686 MHD_gnutls_assert ();
687 return ret; 687 return ret;
688 } 688 }
689 689
690 ret = verify_sig (tbs, signature, gnutls_x509_crt_get_pk_algorithm (issuer, 690 ret = verify_sig (tbs, signature, MHD_gnutls_x509_crt_get_pk_algorithm (issuer,
691 NULL), 691 NULL),
692 issuer_params, issuer_params_size); 692 issuer_params, issuer_params_size);
693 if (ret < 0) 693 if (ret < 0)
694 { 694 {
695 gnutls_assert (); 695 MHD_gnutls_assert ();
696 } 696 }
697 697
698 /* release all allocated MPIs 698 /* release all allocated MPIs
699 */ 699 */
700 for (i = 0; i < issuer_params_size; i++) 700 for (i = 0; i < issuer_params_size; i++)
701 { 701 {
702 mhd_gtls_mpi_release (&issuer_params[i]); 702 MHD_gtls_mpi_release (&issuer_params[i]);
703 } 703 }
704 704
705 return ret; 705 return ret;
@@ -712,9 +712,9 @@ _gnutls_x509_verify_signature (const gnutls_datum_t * tbs,
712 * 'signature' is the signature! 712 * 'signature' is the signature!
713 */ 713 */
714int 714int
715_gnutls_x509_privkey_verify_signature (const gnutls_datum_t * tbs, 715MHD__gnutls_x509_privkey_verify_signature (const MHD_gnutls_datum_t * tbs,
716 const gnutls_datum_t * signature, 716 const MHD_gnutls_datum_t * signature,
717 gnutls_x509_privkey_t issuer) 717 MHD_gnutls_x509_privkey_t issuer)
718{ 718{
719 int ret; 719 int ret;
720 720
@@ -722,21 +722,21 @@ _gnutls_x509_privkey_verify_signature (const gnutls_datum_t * tbs,
722 issuer->params_size); 722 issuer->params_size);
723 if (ret < 0) 723 if (ret < 0)
724 { 724 {
725 gnutls_assert (); 725 MHD_gnutls_assert ();
726 } 726 }
727 727
728 return ret; 728 return ret;
729} 729}
730 730
731/** 731/**
732 * gnutls_x509_crt_list_verify - This function verifies the given certificate list 732 * MHD_gnutls_x509_crt_list_verify - This function verifies the given certificate list
733 * @cert_list: is the certificate list to be verified 733 * @cert_list: is the certificate list to be verified
734 * @cert_list_length: holds the number of certificate in cert_list 734 * @cert_list_length: holds the number of certificate in cert_list
735 * @CA_list: is the CA list which will be used in verification 735 * @CA_list: is the CA list which will be used in verification
736 * @CA_list_length: holds the number of CA certificate in CA_list 736 * @CA_list_length: holds the number of CA certificate in CA_list
737 * @CRL_list: holds a list of CRLs. 737 * @CRL_list: holds a list of CRLs.
738 * @CRL_list_length: the length of CRL list. 738 * @CRL_list_length: the length of CRL list.
739 * @flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. 739 * @flags: Flags that may be used to change the verification algorithm. Use OR of the MHD_gnutls_certificate_verify_flags enumerations.
740 * @verify: will hold the certificate verification output. 740 * @verify: will hold the certificate verification output.
741 * 741 *
742 * This function will try to verify the given certificate list and return its status. 742 * This function will try to verify the given certificate list and return its status.
@@ -751,8 +751,8 @@ _gnutls_x509_privkey_verify_signature (const gnutls_datum_t * tbs,
751 * certificate belongs to the actual peer. 751 * certificate belongs to the actual peer.
752 * 752 *
753 * The certificate verification output will be put in @verify and will be 753 * The certificate verification output will be put in @verify and will be
754 * one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd. 754 * one or more of the MHD_gnutls_certificate_status_t enumerated elements bitwise or'd.
755 * For a more detailed verification status use gnutls_x509_crt_verify() per list 755 * For a more detailed verification status use MHD_gnutls_x509_crt_verify() per list
756 * element. 756 * element.
757 * 757 *
758 * GNUTLS_CERT_INVALID: the certificate chain is not valid. 758 * GNUTLS_CERT_INVALID: the certificate chain is not valid.
@@ -763,11 +763,11 @@ _gnutls_x509_privkey_verify_signature (const gnutls_datum_t * tbs,
763 * 763 *
764 **/ 764 **/
765int 765int
766gnutls_x509_crt_list_verify (const gnutls_x509_crt_t * cert_list, 766MHD_gnutls_x509_crt_list_verify (const MHD_gnutls_x509_crt_t * cert_list,
767 int cert_list_length, 767 int cert_list_length,
768 const gnutls_x509_crt_t * CA_list, 768 const MHD_gnutls_x509_crt_t * CA_list,
769 int CA_list_length, 769 int CA_list_length,
770 const gnutls_x509_crl_t * CRL_list, 770 const MHD_gnutls_x509_crl_t * CRL_list,
771 int CRL_list_length, 771 int CRL_list_length,
772 unsigned int flags, unsigned int *verify) 772 unsigned int flags, unsigned int *verify)
773{ 773{
@@ -776,7 +776,7 @@ gnutls_x509_crt_list_verify (const gnutls_x509_crt_t * cert_list,
776 776
777 /* Verify certificate 777 /* Verify certificate
778 */ 778 */
779 *verify = _gnutls_x509_verify_certificate (cert_list, cert_list_length, 779 *verify = MHD__gnutls_x509_verify_certificate (cert_list, cert_list_length,
780 CA_list, CA_list_length, 780 CA_list, CA_list_length,
781 CRL_list, CRL_list_length, 781 CRL_list, CRL_list_length,
782 flags); 782 flags);
@@ -785,11 +785,11 @@ gnutls_x509_crt_list_verify (const gnutls_x509_crt_t * cert_list,
785} 785}
786 786
787/** 787/**
788 * gnutls_x509_crt_verify - This function verifies the given certificate against a given trusted one 788 * MHD_gnutls_x509_crt_verify - This function verifies the given certificate against a given trusted one
789 * @cert: is the certificate to be verified 789 * @cert: is the certificate to be verified
790 * @CA_list: is one certificate that is considered to be trusted one 790 * @CA_list: is one certificate that is considered to be trusted one
791 * @CA_list_length: holds the number of CA certificate in CA_list 791 * @CA_list_length: holds the number of CA certificate in CA_list
792 * @flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. 792 * @flags: Flags that may be used to change the verification algorithm. Use OR of the MHD_gnutls_certificate_verify_flags enumerations.
793 * @verify: will hold the certificate verification output. 793 * @verify: will hold the certificate verification output.
794 * 794 *
795 * This function will try to verify the given certificate and return its status. 795 * This function will try to verify the given certificate and return its status.
@@ -799,19 +799,19 @@ gnutls_x509_crt_list_verify (const gnutls_x509_crt_t * cert_list,
799 * 799 *
800 **/ 800 **/
801int 801int
802gnutls_x509_crt_verify (gnutls_x509_crt_t cert, 802MHD_gnutls_x509_crt_verify (MHD_gnutls_x509_crt_t cert,
803 const gnutls_x509_crt_t * CA_list, 803 const MHD_gnutls_x509_crt_t * CA_list,
804 int CA_list_length, 804 int CA_list_length,
805 unsigned int flags, unsigned int *verify) 805 unsigned int flags, unsigned int *verify)
806{ 806{
807 int ret; 807 int ret;
808 /* Verify certificate 808 /* Verify certificate
809 */ 809 */
810 ret = _gnutls_verify_certificate2 (cert, CA_list, CA_list_length, flags, 810 ret = MHD__gnutls_verify_certificate2 (cert, CA_list, CA_list_length, flags,
811 verify); 811 verify);
812 if (ret < 0) 812 if (ret < 0)
813 { 813 {
814 gnutls_assert (); 814 MHD_gnutls_assert ();
815 return ret; 815 return ret;
816 } 816 }
817 817
@@ -821,7 +821,7 @@ gnutls_x509_crt_verify (gnutls_x509_crt_t cert,
821#ifdef ENABLE_PKI 821#ifdef ENABLE_PKI
822 822
823/** 823/**
824 * gnutls_x509_crl_check_issuer - This function checks if the CRL given has the given issuer 824 * MHD_gnutls_x509_crl_check_issuer - This function checks if the CRL given has the given issuer
825 * @crl: is the CRL to be checked 825 * @crl: is the CRL to be checked
826 * @issuer: is the certificate of a possible issuer 826 * @issuer: is the certificate of a possible issuer
827 * 827 *
@@ -833,40 +833,40 @@ gnutls_x509_crt_verify (gnutls_x509_crt_t cert,
833 * 833 *
834 **/ 834 **/
835int 835int
836gnutls_x509_crl_check_issuer (gnutls_x509_crl_t cert, 836MHD_gnutls_x509_crl_check_issuer (MHD_gnutls_x509_crl_t cert,
837 gnutls_x509_crt_t issuer) 837 MHD_gnutls_x509_crt_t issuer)
838{ 838{
839 return is_crl_issuer (cert, issuer); 839 return is_crl_issuer (cert, issuer);
840} 840}
841 841
842/** 842/**
843 * gnutls_x509_crl_verify - This function verifies the given crl against a given trusted one 843 * MHD_gnutls_x509_crl_verify - This function verifies the given crl against a given trusted one
844 * @crl: is the crl to be verified 844 * @crl: is the crl to be verified
845 * @CA_list: is a certificate list that is considered to be trusted one 845 * @CA_list: is a certificate list that is considered to be trusted one
846 * @CA_list_length: holds the number of CA certificates in CA_list 846 * @CA_list_length: holds the number of CA certificates in CA_list
847 * @flags: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations. 847 * @flags: Flags that may be used to change the verification algorithm. Use OR of the MHD_gnutls_certificate_verify_flags enumerations.
848 * @verify: will hold the crl verification output. 848 * @verify: will hold the crl verification output.
849 * 849 *
850 * This function will try to verify the given crl and return its status. 850 * This function will try to verify the given crl and return its status.
851 * See gnutls_x509_crt_list_verify() for a detailed description of 851 * See MHD_gnutls_x509_crt_list_verify() for a detailed description of
852 * return values. 852 * return values.
853 * 853 *
854 * Returns 0 on success and a negative value in case of an error. 854 * Returns 0 on success and a negative value in case of an error.
855 * 855 *
856 **/ 856 **/
857int 857int
858gnutls_x509_crl_verify (gnutls_x509_crl_t crl, 858MHD_gnutls_x509_crl_verify (MHD_gnutls_x509_crl_t crl,
859 const gnutls_x509_crt_t * CA_list, 859 const MHD_gnutls_x509_crt_t * CA_list,
860 int CA_list_length, unsigned int flags, 860 int CA_list_length, unsigned int flags,
861 unsigned int *verify) 861 unsigned int *verify)
862{ 862{
863 int ret; 863 int ret;
864 /* Verify crl 864 /* Verify crl
865 */ 865 */
866 ret = _gnutls_verify_crl2 (crl, CA_list, CA_list_length, flags, verify); 866 ret = MHD__gnutls_verify_crl2 (crl, CA_list, CA_list_length, flags, verify);
867 if (ret < 0) 867 if (ret < 0)
868 { 868 {
869 gnutls_assert (); 869 MHD_gnutls_assert ();
870 return ret; 870 return ret;
871 } 871 }
872 872
@@ -876,39 +876,39 @@ gnutls_x509_crl_verify (gnutls_x509_crl_t crl,
876/* The same as above, but here we've got a CRL. 876/* The same as above, but here we've got a CRL.
877 */ 877 */
878static int 878static int
879is_crl_issuer (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer_cert) 879is_crl_issuer (MHD_gnutls_x509_crl_t crl, MHD_gnutls_x509_crt_t issuer_cert)
880{ 880{
881 gnutls_datum_t dn1 = { NULL, 0 }, dn2 = 881 MHD_gnutls_datum_t dn1 = { NULL, 0 }, dn2 =
882 { 882 {
883 NULL, 0}; 883 NULL, 0};
884 int ret; 884 int ret;
885 885
886 ret = _gnutls_x509_crl_get_raw_issuer_dn (crl, &dn1); 886 ret = MHD__gnutls_x509_crl_get_raw_issuer_dn (crl, &dn1);
887 if (ret < 0) 887 if (ret < 0)
888 { 888 {
889 gnutls_assert (); 889 MHD_gnutls_assert ();
890 goto cleanup; 890 goto cleanup;
891 } 891 }
892 892
893 ret = gnutls_x509_crt_get_raw_dn (issuer_cert, &dn2); 893 ret = MHD_gnutls_x509_crt_get_raw_dn (issuer_cert, &dn2);
894 if (ret < 0) 894 if (ret < 0)
895 { 895 {
896 gnutls_assert (); 896 MHD_gnutls_assert ();
897 return ret; 897 return ret;
898 } 898 }
899 899
900 ret = _gnutls_x509_compare_raw_dn (&dn1, &dn2); 900 ret = MHD__gnutls_x509_compare_raw_dn (&dn1, &dn2);
901 901
902cleanup: 902cleanup:
903 _gnutls_free_datum (&dn1); 903 MHD__gnutls_free_datum (&dn1);
904 _gnutls_free_datum (&dn2); 904 MHD__gnutls_free_datum (&dn2);
905 905
906 return ret; 906 return ret;
907} 907}
908 908
909static inline gnutls_x509_crt_t 909static inline MHD_gnutls_x509_crt_t
910find_crl_issuer (gnutls_x509_crl_t crl, 910find_crl_issuer (MHD_gnutls_x509_crl_t crl,
911 const gnutls_x509_crt_t * trusted_cas, int tcas_size) 911 const MHD_gnutls_x509_crt_t * trusted_cas, int tcas_size)
912{ 912{
913 int i; 913 int i;
914 914
@@ -921,7 +921,7 @@ find_crl_issuer (gnutls_x509_crl_t crl,
921 return trusted_cas[i]; 921 return trusted_cas[i];
922 } 922 }
923 923
924 gnutls_assert (); 924 MHD_gnutls_assert ();
925 return NULL; 925 return NULL;
926} 926}
927 927
@@ -929,20 +929,20 @@ find_crl_issuer (gnutls_x509_crl_t crl,
929 * Returns only 0 or 1. If 1 it means that the CRL 929 * Returns only 0 or 1. If 1 it means that the CRL
930 * was successfuly verified. 930 * was successfuly verified.
931 * 931 *
932 * 'flags': an OR of the gnutls_certificate_verify_flags enumeration. 932 * 'flags': an OR of the MHD_gnutls_certificate_verify_flags enumeration.
933 * 933 *
934 * Output will hold information about the verification 934 * Output will hold information about the verification
935 * procedure. 935 * procedure.
936 */ 936 */
937static int 937static int
938_gnutls_verify_crl2 (gnutls_x509_crl_t crl, 938MHD__gnutls_verify_crl2 (MHD_gnutls_x509_crl_t crl,
939 const gnutls_x509_crt_t * trusted_cas, 939 const MHD_gnutls_x509_crt_t * trusted_cas,
940 int tcas_size, unsigned int flags, unsigned int *output) 940 int tcas_size, unsigned int flags, unsigned int *output)
941{ 941{
942 /* CRL is ignored for now */ 942 /* CRL is ignored for now */
943 gnutls_datum_t crl_signed_data = { NULL, 0 }; 943 MHD_gnutls_datum_t crl_signed_data = { NULL, 0 };
944 gnutls_datum_t crl_signature = { NULL, 0 }; 944 MHD_gnutls_datum_t crl_signature = { NULL, 0 };
945 gnutls_x509_crt_t issuer; 945 MHD_gnutls_x509_crt_t issuer;
946 int ret, result; 946 int ret, result;
947 947
948 if (output) 948 if (output)
@@ -952,7 +952,7 @@ _gnutls_verify_crl2 (gnutls_x509_crl_t crl,
952 issuer = find_crl_issuer (crl, trusted_cas, tcas_size); 952 issuer = find_crl_issuer (crl, trusted_cas, tcas_size);
953 else 953 else
954 { 954 {
955 gnutls_assert (); 955 MHD_gnutls_assert ();
956 if (output) 956 if (output)
957 *output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID; 957 *output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID;
958 return 0; 958 return 0;
@@ -963,7 +963,7 @@ _gnutls_verify_crl2 (gnutls_x509_crl_t crl,
963 */ 963 */
964 if (issuer == NULL) 964 if (issuer == NULL)
965 { 965 {
966 gnutls_assert (); 966 MHD_gnutls_assert ();
967 if (output) 967 if (output)
968 *output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID; 968 *output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID;
969 return 0; 969 return 0;
@@ -971,9 +971,9 @@ _gnutls_verify_crl2 (gnutls_x509_crl_t crl,
971 971
972 if (!(flags & GNUTLS_VERIFY_DISABLE_CA_SIGN)) 972 if (!(flags & GNUTLS_VERIFY_DISABLE_CA_SIGN))
973 { 973 {
974 if (gnutls_x509_crt_get_ca_status (issuer, NULL) != 1) 974 if (MHD_gnutls_x509_crt_get_ca_status (issuer, NULL) != 1)
975 { 975 {
976 gnutls_assert (); 976 MHD_gnutls_assert ();
977 if (output) 977 if (output)
978 *output |= GNUTLS_CERT_SIGNER_NOT_CA | GNUTLS_CERT_INVALID; 978 *output |= GNUTLS_CERT_SIGNER_NOT_CA | GNUTLS_CERT_INVALID;
979 return 0; 979 return 0;
@@ -981,29 +981,29 @@ _gnutls_verify_crl2 (gnutls_x509_crl_t crl,
981 } 981 }
982 982
983 result = 983 result =
984 _gnutls_x509_get_signed_data (crl->crl, "tbsCertList", &crl_signed_data); 984 MHD__gnutls_x509_get_signed_data (crl->crl, "tbsCertList", &crl_signed_data);
985 if (result < 0) 985 if (result < 0)
986 { 986 {
987 gnutls_assert (); 987 MHD_gnutls_assert ();
988 goto cleanup; 988 goto cleanup;
989 } 989 }
990 990
991 result = _gnutls_x509_get_signature (crl->crl, "signature", &crl_signature); 991 result = MHD__gnutls_x509_get_signature (crl->crl, "signature", &crl_signature);
992 if (result < 0) 992 if (result < 0)
993 { 993 {
994 gnutls_assert (); 994 MHD_gnutls_assert ();
995 goto cleanup; 995 goto cleanup;
996 } 996 }
997 997
998 ret = 998 ret =
999 _gnutls_x509_verify_signature (&crl_signed_data, &crl_signature, issuer); 999 MHD__gnutls_x509_verify_signature (&crl_signed_data, &crl_signature, issuer);
1000 if (ret < 0) 1000 if (ret < 0)
1001 { 1001 {
1002 gnutls_assert (); 1002 MHD_gnutls_assert ();
1003 } 1003 }
1004 else if (ret == 0) 1004 else if (ret == 0)
1005 { 1005 {
1006 gnutls_assert (); 1006 MHD_gnutls_assert ();
1007 /* error. ignore it */ 1007 /* error. ignore it */
1008 if (output) 1008 if (output)
1009 *output |= GNUTLS_CERT_INVALID; 1009 *output |= GNUTLS_CERT_INVALID;
@@ -1013,7 +1013,7 @@ _gnutls_verify_crl2 (gnutls_x509_crl_t crl,
1013 { 1013 {
1014 int sigalg; 1014 int sigalg;
1015 1015
1016 sigalg = gnutls_x509_crl_get_signature_algorithm (crl); 1016 sigalg = MHD_gnutls_x509_crl_get_signature_algorithm (crl);
1017 1017
1018 if (((sigalg == GNUTLS_SIGN_RSA_MD2) && 1018 if (((sigalg == GNUTLS_SIGN_RSA_MD2) &&
1019 !(flags & GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2)) || 1019 !(flags & GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2)) ||
@@ -1028,8 +1028,8 @@ _gnutls_verify_crl2 (gnutls_x509_crl_t crl,
1028 result = ret; 1028 result = ret;
1029 1029
1030cleanup: 1030cleanup:
1031 _gnutls_free_datum (&crl_signed_data); 1031 MHD__gnutls_free_datum (&crl_signed_data);
1032 _gnutls_free_datum (&crl_signature); 1032 MHD__gnutls_free_datum (&crl_signature);
1033 1033
1034 return result; 1034 return result;
1035} 1035}
diff --git a/src/daemon/internal.h b/src/daemon/internal.h
index 47d2963f..dcd9386d 100644
--- a/src/daemon/internal.h
+++ b/src/daemon/internal.h
@@ -571,7 +571,7 @@ struct MHD_Connection
571 571
572#if HTTPS_SUPPORT 572#if HTTPS_SUPPORT
573 /* TODO rename as this might be an SSL connection */ 573 /* TODO rename as this might be an SSL connection */
574 mhd_gtls_session_t tls_session; 574 MHD_gtls_session_t tls_session;
575#endif 575#endif
576}; 576};
577 577
@@ -652,16 +652,16 @@ struct MHD_Daemon
652 enum MHD_GNUTLS_CredentialsType cred_type; 652 enum MHD_GNUTLS_CredentialsType cred_type;
653 653
654 /* server x509 credintials */ 654 /* server x509 credintials */
655 mhd_gtls_cert_credentials_t x509_cred; 655 MHD_gtls_cert_credentials_t x509_cred;
656 656
657 /* credentials used for anonymous authentication */ 657 /* credentials used for anonymous authentication */
658 mhd_gtls_anon_server_credentials_t anon_cred; 658 MHD_gtls_anon_server_credentials_t anon_cred;
659 659
660 /* cipher priority cache */ 660 /* cipher priority cache */
661 gnutls_priority_t priority_cache; 661 MHD_gnutls_priority_t priority_cache;
662 662
663 /* Diffie-Hellman parameters */ 663 /* Diffie-Hellman parameters */
664 mhd_gtls_dh_params_t dh_params; 664 MHD_gtls_dh_params_t dh_params;
665 665
666 const char *https_mem_key; 666 const char *https_mem_key;
667 667