Przeglądaj źródła

mega-renaming to avoid exporting symbols not starting with MHD

Christian Grothoff 17 lat temu
rodzic
commit
6ff7b62145
100 zmienionych plików z 3968 dodań i 4008 usunięć
  1. 1 1
      src/daemon/connection.c
  2. 5 5
      src/daemon/connection_https.c
  3. 35 35
      src/daemon/daemon.c
  4. 339 339
      src/daemon/https/gnutls.h
  5. 0 1
      src/daemon/https/lgl/Makefile.am
  6. 20 20
      src/daemon/https/lgl/des.c
  7. 14 14
      src/daemon/https/lgl/des.h
  8. 61 61
      src/daemon/https/lgl/gc-gnulib.c
  9. 37 37
      src/daemon/https/lgl/gc-libgcrypt.c
  10. 3 3
      src/daemon/https/lgl/gc-pbkdf2-sha1.c
  11. 39 39
      src/daemon/https/lgl/gc.h
  12. 17 17
      src/daemon/https/lgl/hmac-md5.c
  13. 17 17
      src/daemon/https/lgl/hmac-sha1.c
  14. 2 2
      src/daemon/https/lgl/hmac.h
  15. 29 29
      src/daemon/https/lgl/md5.c
  16. 18 18
      src/daemon/https/lgl/md5.h
  17. 2 2
      src/daemon/https/lgl/memmem.c
  18. 3 3
      src/daemon/https/lgl/memxor.c
  19. 3 3
      src/daemon/https/lgl/memxor.h
  20. 23 23
      src/daemon/https/lgl/sha1.c
  21. 10 10
      src/daemon/https/lgl/sha1.h
  22. 0 46
      src/daemon/https/lgl/time_r.c
  23. 103 103
      src/daemon/https/minitasn1/coding.c
  24. 142 142
      src/daemon/https/minitasn1/decoding.c
  25. 99 99
      src/daemon/https/minitasn1/element.c
  26. 3 3
      src/daemon/https/minitasn1/element.h
  27. 10 10
      src/daemon/https/minitasn1/errors.c
  28. 1 1
      src/daemon/https/minitasn1/errors.h
  29. 2 2
      src/daemon/https/minitasn1/gstr.c
  30. 4 4
      src/daemon/https/minitasn1/gstr.h
  31. 34 34
      src/daemon/https/minitasn1/libtasn1.h
  32. 10 10
      src/daemon/https/minitasn1/mem.h
  33. 112 112
      src/daemon/https/minitasn1/parser_aux.c
  34. 20 20
      src/daemon/https/minitasn1/parser_aux.h
  35. 121 121
      src/daemon/https/minitasn1/structure.c
  36. 5 5
      src/daemon/https/minitasn1/structure.h
  37. 38 38
      src/daemon/https/tls/auth_anon.c
  38. 8 8
      src/daemon/https/tls/auth_anon.h
  39. 185 185
      src/daemon/https/tls/auth_cert.c
  40. 42 42
      src/daemon/https/tls/auth_cert.h
  41. 71 71
      src/daemon/https/tls/auth_dh_common.c
  42. 9 9
      src/daemon/https/tls/auth_dh_common.h
  43. 75 75
      src/daemon/https/tls/auth_dhe.c
  44. 88 81
      src/daemon/https/tls/auth_rsa.c
  45. 79 79
      src/daemon/https/tls/auth_rsa_export.c
  46. 11 11
      src/daemon/https/tls/debug.c
  47. 4 4
      src/daemon/https/tls/debug.h
  48. 24 24
      src/daemon/https/tls/ext_cert_type.c
  49. 2 2
      src/daemon/https/tls/ext_cert_type.h
  50. 14 14
      src/daemon/https/tls/ext_max_record.c
  51. 4 4
      src/daemon/https/tls/ext_max_record.h
  52. 29 29
      src/daemon/https/tls/ext_oprfi.c
  53. 2 2
      src/daemon/https/tls/ext_oprfi.h
  54. 20 20
      src/daemon/https/tls/ext_server_name.c
  55. 2 2
      src/daemon/https/tls/ext_server_name.h
  56. 24 24
      src/daemon/https/tls/gnutls_alert.c
  57. 159 159
      src/daemon/https/tls/gnutls_algorithms.c
  58. 49 49
      src/daemon/https/tls/gnutls_algorithms.h
  59. 24 24
      src/daemon/https/tls/gnutls_anon_cred.c
  60. 1 1
      src/daemon/https/tls/gnutls_asn1_tab.c
  61. 52 52
      src/daemon/https/tls/gnutls_auth.c
  62. 14 14
      src/daemon/https/tls/gnutls_auth.h
  63. 4 4
      src/daemon/https/tls/gnutls_auth_int.h
  64. 144 144
      src/daemon/https/tls/gnutls_buffers.c
  65. 27 27
      src/daemon/https/tls/gnutls_buffers.h
  66. 141 141
      src/daemon/https/tls/gnutls_cert.c
  67. 16 16
      src/daemon/https/tls/gnutls_cert.h
  68. 78 78
      src/daemon/https/tls/gnutls_cipher.c
  69. 6 6
      src/daemon/https/tls/gnutls_cipher.h
  70. 24 24
      src/daemon/https/tls/gnutls_cipher_int.c
  71. 8 8
      src/daemon/https/tls/gnutls_cipher_int.h
  72. 10 10
      src/daemon/https/tls/gnutls_compress.c
  73. 6 6
      src/daemon/https/tls/gnutls_compress.h
  74. 33 33
      src/daemon/https/tls/gnutls_compress_int.c
  75. 4 4
      src/daemon/https/tls/gnutls_compress_int.h
  76. 182 182
      src/daemon/https/tls/gnutls_constate.c
  77. 10 10
      src/daemon/https/tls/gnutls_constate.h
  78. 12 12
      src/daemon/https/tls/gnutls_datum.c
  79. 13 13
      src/daemon/https/tls/gnutls_datum.h
  80. 27 27
      src/daemon/https/tls/gnutls_dh.c
  81. 8 8
      src/daemon/https/tls/gnutls_dh.h
  82. 24 24
      src/daemon/https/tls/gnutls_dh_primes.c
  83. 12 12
      src/daemon/https/tls/gnutls_errors.c
  84. 29 29
      src/daemon/https/tls/gnutls_errors.h
  85. 59 59
      src/daemon/https/tls/gnutls_extensions.c
  86. 12 12
      src/daemon/https/tls/gnutls_extensions.h
  87. 74 74
      src/daemon/https/tls/gnutls_global.c
  88. 7 7
      src/daemon/https/tls/gnutls_global.h
  89. 170 170
      src/daemon/https/tls/gnutls_handshake.c
  90. 19 19
      src/daemon/https/tls/gnutls_handshake.h
  91. 81 81
      src/daemon/https/tls/gnutls_hash_int.c
  92. 13 13
      src/daemon/https/tls/gnutls_hash_int.h
  93. 88 88
      src/daemon/https/tls/gnutls_int.h
  94. 114 114
      src/daemon/https/tls/gnutls_kx.c
  95. 13 13
      src/daemon/https/tls/gnutls_kx.h
  96. 21 21
      src/daemon/https/tls/gnutls_mem.c
  97. 15 15
      src/daemon/https/tls/gnutls_mem.h
  98. 43 43
      src/daemon/https/tls/gnutls_mpi.c
  99. 33 33
      src/daemon/https/tls/gnutls_mpi.h
  100. 14 14
      src/daemon/https/tls/gnutls_num.c

+ 1 - 1
src/daemon/connection.c

@@ -1632,7 +1632,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
 #if HTTPS_SUPPORT
           if (connection->daemon->options & MHD_USE_SSL)
             {
-              ret = MHD_gnutls_record_send (connection->tls_session,
+              ret = MHD__gnutls_record_send (connection->tls_session,
                                             &connection->response->data
                                             [connection->
                                              response_write_position -

+ 5 - 5
src/daemon/connection_https.c

@@ -99,7 +99,7 @@ MHD_tls_connection_close (struct MHD_Connection *connection,
                               enum MHD_RequestTerminationCode
                               termination_code)
 {
-  MHD_gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR);
+  MHD__gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR);
   connection->tls_session->internals.read_eof = 1;
   SHUTDOWN (connection->socket_fd, SHUT_RDWR);
   CLOSE (connection->socket_fd);
@@ -211,7 +211,7 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
       if (connection->state == MHD_TLS_CONNECTION_INIT ||
           connection->state == MHD_TLS_HELLO_REQUEST)
         {
-          ret = MHD_gnutls_handshake (connection->tls_session);
+          ret = MHD__gnutls_handshake (connection->tls_session);
           if (ret == 0)
             {
               /* set connection state to enable HTTP processing */
@@ -249,10 +249,10 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
 
     case GNUTLS_ALERT:
       /*
-       * this call of mhd_gtls_recv_int expects 0 bytes read.
+       * this call of MHD_gtls_recv_int expects 0 bytes read.
        * done to decrypt alert message
        */
-      mhd_gtls_recv_int (connection->tls_session, GNUTLS_ALERT,
+      MHD_gtls_recv_int (connection->tls_session, GNUTLS_ALERT,
                          GNUTLS_HANDSHAKE_FINISHED, 0, 0);
 
       /* CLOSE_NOTIFY */
@@ -269,7 +269,7 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection)
 #if HAVE_MESSAGES
           MHD_DLOG (connection->daemon,
                     "Received TLS alert: %s\n",
-                    MHD_gnutls_alert_get_name ((int) connection->tls_session->
+                    MHD__gnutls_alert_get_name ((int) connection->tls_session->
                                                internals.last_alert));
 #endif
           return MHD_YES;

+ 35 - 35
src/daemon/daemon.c

@@ -67,12 +67,12 @@
 
 #if HTTPS_SUPPORT
 /**
- * Note: code duplication with code in gnutls_priority.c 
+ * Note: code duplication with code in MHD_gnutls_priority.c 
  *
  * @return 0
  */
 static int
-_set_priority (mhd_gtls_priority_st * st, const int *list)
+_set_priority (MHD_gtls_priority_st * st, const int *list)
 {
   int num = 0;
 
@@ -98,7 +98,7 @@ recv_tls_adapter (struct MHD_Connection* connection,
 		  void *other,
 		  size_t i)
 {
-  return MHD_gnutls_record_recv(connection->tls_session,
+  return MHD__gnutls_record_recv(connection->tls_session,
 				other, i);
 }
 
@@ -115,7 +115,7 @@ send_tls_adapter (struct MHD_Connection* connection,
 		  const void *other, 
 		    size_t i)
 {
-  return MHD_gnutls_record_send(connection->tls_session, 
+  return MHD__gnutls_record_send(connection->tls_session, 
 				other, i);
 }
 
@@ -128,8 +128,8 @@ send_tls_adapter (struct MHD_Connection* connection,
 static int
 MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
 {
-  gnutls_datum_t key;
-  gnutls_datum_t cert;
+  MHD_gnutls_datum_t key;
+  MHD_gnutls_datum_t cert;
 
   /* certificate & key loaded from memory */
   if (daemon->https_mem_cert && daemon->https_mem_key)
@@ -139,7 +139,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
       cert.data = (unsigned char *) daemon->https_mem_cert;
       cert.size = strlen (daemon->https_mem_cert);
 
-      return MHD_gnutls_certificate_set_x509_key_mem (daemon->x509_cred,
+      return MHD__gnutls_certificate_set_x509_key_mem (daemon->x509_cred,
                                                       &cert, &key,
                                                       GNUTLS_X509_FMT_PEM);
     }
@@ -160,15 +160,15 @@ MHD_TLS_init (struct MHD_Daemon *daemon)
   switch (daemon->cred_type)
     {
     case MHD_GNUTLS_CRD_ANON:
-      if ( (0 != MHD_gnutls_anon_allocate_server_credentials (&daemon->anon_cred)) ||
-	   (0 != MHD_gnutls_dh_params_init (&daemon->dh_params)) )
+      if ( (0 != MHD__gnutls_anon_allocate_server_credentials (&daemon->anon_cred)) ||
+	   (0 != MHD__gnutls_dh_params_init (&daemon->dh_params)) )
 	return GNUTLS_E_MEMORY_ERROR;        
-      MHD_gnutls_dh_params_generate2 (daemon->dh_params, 1024);
-      MHD_gnutls_anon_set_server_dh_params (daemon->anon_cred,
+      MHD__gnutls_dh_params_generate2 (daemon->dh_params, 1024);
+      MHD__gnutls_anon_set_server_dh_params (daemon->anon_cred,
                                             daemon->dh_params);
       return 0;
     case MHD_GNUTLS_CRD_CERTIFICATE:
-      if (0 != MHD_gnutls_certificate_allocate_credentials (&daemon->x509_cred))
+      if (0 != MHD__gnutls_certificate_allocate_credentials (&daemon->x509_cred))
         return GNUTLS_E_MEMORY_ERROR;
       return MHD_init_daemon_certificate (daemon);
     default:
@@ -491,21 +491,21 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
       connection->send_cls = &send_tls_adapter;
       connection->state = MHD_TLS_CONNECTION_INIT;
       MHD_set_https_calbacks (connection);    
-      MHD_gnutls_init (&connection->tls_session, GNUTLS_SERVER);
-      MHD_gnutls_priority_set (connection->tls_session, connection->daemon->priority_cache);
+      MHD__gnutls_init (&connection->tls_session, GNUTLS_SERVER);
+      MHD__gnutls_priority_set (connection->tls_session, connection->daemon->priority_cache);
       switch (connection->daemon->cred_type)
 	{
 	  /* set needed credentials for certificate authentication. */
 	case MHD_GNUTLS_CRD_CERTIFICATE:
-	  MHD_gnutls_credentials_set (connection->tls_session,
+	  MHD__gnutls_credentials_set (connection->tls_session,
 				      MHD_GNUTLS_CRD_CERTIFICATE,
 				      connection->daemon->x509_cred);
 	  break;
 	case MHD_GNUTLS_CRD_ANON:
 	  /* set needed credentials for anonymous authentication. */
-	  MHD_gnutls_credentials_set (connection->tls_session, MHD_GNUTLS_CRD_ANON,
+	  MHD__gnutls_credentials_set (connection->tls_session, MHD_GNUTLS_CRD_ANON,
 				      connection->daemon->anon_cred);
-	  MHD_gnutls_dh_set_prime_bits (connection->tls_session, 1024);
+	  MHD__gnutls_dh_set_prime_bits (connection->tls_session, 1024);
 	  break;
 	default:
 #if HAVE_MESSAGES
@@ -515,12 +515,12 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
 #endif
 	  abort();
 	}
-      MHD_gnutls_transport_set_ptr (connection->tls_session,
-				    (gnutls_transport_ptr_t) connection);
-      MHD_gnutls_transport_set_pull_function(connection->tls_session, 
-					     (mhd_gtls_pull_func) &recv_param_adapter);
-      MHD_gnutls_transport_set_push_function(connection->tls_session, 
-					     (mhd_gtls_push_func) &send_param_adapter);  
+      MHD__gnutls_transport_set_ptr (connection->tls_session,
+				    (MHD_gnutls_transport_ptr_t) connection);
+      MHD__gnutls_transport_set_pull_function(connection->tls_session, 
+					     (MHD_gtls_pull_func) &recv_param_adapter);
+      MHD__gnutls_transport_set_push_function(connection->tls_session, 
+					     (MHD_gtls_push_func) &send_param_adapter);  
     }
 #endif
 
@@ -583,7 +583,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
 	  MHD_pool_destroy (pos->pool);
 #if HTTPS_SUPPORT
 	  if (pos->tls_session != NULL)            
-	    MHD_gnutls_deinit (pos->tls_session);
+	    MHD__gnutls_deinit (pos->tls_session);
 #endif
 	  free (pos->addr);
 	  free (pos);
@@ -859,10 +859,10 @@ MHD_start_daemon_va (unsigned int options,
 #if HTTPS_SUPPORT
   if (options & MHD_USE_SSL)
     {
-      /* lock gnutls_global mutex since it uses reference counting */
-      pthread_mutex_lock (&gnutls_init_mutex);
-      MHD_gnutls_global_init ();
-      pthread_mutex_unlock (&gnutls_init_mutex);
+      /* lock MHD_gnutls_global mutex since it uses reference counting */
+      pthread_mutex_lock (&MHD_gnutls_init_mutex);
+      MHD__gnutls_global_init ();
+      pthread_mutex_unlock (&MHD_gnutls_init_mutex);
       /* set default priorities */
       MHD_tls_set_default_priority (&retVal->priority_cache, "", NULL);
       retVal->cred_type = MHD_GNUTLS_CRD_CERTIFICATE;
@@ -1104,15 +1104,15 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
 #if HTTPS_SUPPORT
   if (daemon->options & MHD_USE_SSL)
     {
-      MHD_gnutls_priority_deinit (daemon->priority_cache);
+      MHD__gnutls_priority_deinit (daemon->priority_cache);
       if (daemon->x509_cred)
-        MHD_gnutls_certificate_free_credentials (daemon->x509_cred);
+        MHD__gnutls_certificate_free_credentials (daemon->x509_cred);
       if (daemon->anon_cred)
-        MHD_gnutls_anon_free_server_credentials (daemon->anon_cred);
-      /* lock gnutls_global mutex since it uses reference counting */
-      pthread_mutex_lock (&gnutls_init_mutex);
-      MHD_gnutls_global_deinit ();
-      pthread_mutex_unlock (&gnutls_init_mutex);
+        MHD__gnutls_anon_free_server_credentials (daemon->anon_cred);
+      /* lock MHD_gnutls_global mutex since it uses reference counting */
+      pthread_mutex_lock (&MHD_gnutls_init_mutex);
+      MHD__gnutls_global_deinit ();
+      pthread_mutex_unlock (&MHD_gnutls_init_mutex);
     }
 #endif
   free (daemon);

Plik diff jest za duży
+ 339 - 339
src/daemon/https/gnutls.h


+ 0 - 1
src/daemon/https/lgl/Makefile.am

@@ -14,7 +14,6 @@ liblgl_la_LDFLAGS = -lgcrypt
 liblgl_la_SOURCES = \
 sha1.c sha1.h \
 gc-libgcrypt.c \
-time_r.c \
 rijndael-api-fst.c rijndael-api-fst.h \
 gc-pbkdf2-sha1.c gc.h \
 rijndael-alg-fst.c rijndael-alg-fst.h \

+ 20 - 20
src/daemon/https/lgl/des.c

@@ -54,13 +54,13 @@
  *     unsigned char plaintext[8];
  *     unsigned char ciphertext[8];
  *     unsigned char recoverd[8];
- *     gl_des_ctx context;
+ *     MHD_gl_des_ctx context;
  *
  *     // Fill 'key' and 'plaintext' with some data
  *     ....
  *
  *     // Set up the DES encryption context
- *     gl_des_setkey(&context, key);
+ *     MHD_gl_des_setkey(&context, key);
  *
  *     // Encrypt the plaintext
  *     des_ecb_encrypt(&context, plaintext, ciphertext);
@@ -77,20 +77,20 @@
  *     unsigned char plaintext[8];
  *     unsigned char ciphertext[8];
  *     unsigned char recoverd[8];
- *     gl_3des_ctx context;
+ *     MHD_gl_3des_ctx context;
  *
  *     // If you would like to use two 64bit keys, fill 'key1' and'key2'
  *     // then setup the encryption context:
- *     gl_3des_set2keys(&context, key1, key2);
+ *     MHD_gl_3des_set2keys(&context, key1, key2);
  *
  *     // To use three 64bit keys with Triple-DES use:
- *     gl_3des_set3keys(&context, key1, key2, key3);
+ *     MHD_gl_3des_set3keys(&context, key1, key2, key3);
  *
  *     // Encrypting plaintext with Triple-DES
- *     gl_3des_ecb_encrypt(&context, plaintext, ciphertext);
+ *     MHD_gl_3des_ecb_encrypt(&context, plaintext, ciphertext);
  *
  *     // Decrypting ciphertext to recover the plaintext with Triple-DES
- *     gl_3des_ecb_decrypt(&context, ciphertext, recoverd);
+ *     MHD_gl_3des_ecb_decrypt(&context, ciphertext, recoverd);
  */
 
 
@@ -320,7 +320,7 @@ static const unsigned char weak_keys[64][8] = {
 };
 
 bool
-gl_des_is_weak_key (const char *key)
+MHD_gl_des_is_weak_key (const char *key)
 {
   char work[8];
   int i, left, right, middle, cmp_result;
@@ -518,7 +518,7 @@ des_key_schedule (const char *_rawkey, uint32_t * subkey)
 }
 
 void
-gl_des_setkey (gl_des_ctx * ctx, const char *key)
+MHD_gl_des_setkey (MHD_gl_des_ctx * ctx, const char *key)
 {
   int i;
 
@@ -532,18 +532,18 @@ gl_des_setkey (gl_des_ctx * ctx, const char *key)
 }
 
 bool
-gl_des_makekey (gl_des_ctx * ctx, const char *key, size_t keylen)
+MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, size_t keylen)
 {
   if (keylen != 8)
     return false;
 
-  gl_des_setkey (ctx, key);
+  MHD_gl_des_setkey (ctx, key);
 
-  return !gl_des_is_weak_key (key);
+  return !MHD_gl_des_is_weak_key (key);
 }
 
 void
-gl_des_ecb_crypt (gl_des_ctx * ctx, const char *_from, char *_to, int mode)
+MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *_from, char *_to, int mode)
 {
   const unsigned char *from = (const unsigned char *) _from;
   unsigned char *to = (unsigned char *) _to;
@@ -565,7 +565,7 @@ READ_64BIT_DATA (from, left, right)
     FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)}
 
 void
-gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2)
+MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2)
 {
   int i;
 
@@ -589,7 +589,7 @@ gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2)
 }
 
 void
-gl_3des_set3keys (gl_3des_ctx * ctx, const char *key1,
+MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx, const char *key1,
                   const char *key2, const char *key3)
 {
   int i;
@@ -612,7 +612,7 @@ gl_3des_set3keys (gl_3des_ctx * ctx, const char *key1,
 }
 
 void
-gl_3des_ecb_crypt (gl_3des_ctx * ctx, const char *_from, char *_to, int mode)
+MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *_from, char *_to, int mode)
 {
   const unsigned char *from = (const unsigned char *) _from;
   unsigned char *to = (unsigned char *) _to;
@@ -650,13 +650,13 @@ READ_64BIT_DATA (from, left, right)
     FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)}
 
 bool
-gl_3des_makekey (gl_3des_ctx * ctx, const char *key, size_t keylen)
+MHD_gl_3des_makekey (MHD_gl_3des_ctx * ctx, const char *key, size_t keylen)
 {
   if (keylen != 24)
     return false;
 
-  gl_3des_set3keys (ctx, key, key + 8, key + 16);
+  MHD_gl_3des_set3keys (ctx, key, key + 8, key + 16);
 
-  return !(gl_des_is_weak_key (key)
-           || gl_des_is_weak_key (key + 8) || gl_des_is_weak_key (key + 16));
+  return !(MHD_gl_des_is_weak_key (key)
+           || MHD_gl_des_is_weak_key (key + 8) || MHD_gl_des_is_weak_key (key + 16));
 }

+ 14 - 14
src/daemon/https/lgl/des.h

@@ -34,7 +34,7 @@ typedef struct
 {
   uint32_t encrypt_subkeys[32];
   uint32_t decrypt_subkeys[32];
-} gl_des_ctx;
+} MHD_gl_des_ctx;
 
 /*
  * Encryption/Decryption context of Triple-DES
@@ -43,11 +43,11 @@ typedef struct
 {
   uint32_t encrypt_subkeys[96];
   uint32_t decrypt_subkeys[96];
-} gl_3des_ctx;
+} MHD_gl_3des_ctx;
 
 /* Check whether the 8 byte key is weak.  Does not check the parity
  * bits of the key but simple ignore them. */
-extern bool gl_des_is_weak_key (const char *key);
+extern bool MHD_gl_des_is_weak_key (const char *key);
 
 /*
  * DES
@@ -57,20 +57,20 @@ extern bool gl_des_is_weak_key (const char *key);
 /* Fill a DES context CTX with subkeys calculated from 64bit KEY.
  * Does not check parity bits, but simply ignore them.  Does not check
  * for weak keys. */
-extern void gl_des_setkey (gl_des_ctx * ctx, const char *key);
+extern void MHD_gl_des_setkey (MHD_gl_des_ctx * ctx, const char *key);
 
 /* Fill a DES context CTX with subkeys calculated from 64bit KEY, with
  * weak key checking.  Does not check parity bits, but simply ignore
  * them. */
-extern bool gl_des_makekey (gl_des_ctx * ctx, const char *key, size_t keylen);
+extern bool MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, size_t keylen);
 
 /* Electronic Codebook Mode DES encryption/decryption of data
  * according to 'mode'. */
 extern void
-gl_des_ecb_crypt (gl_des_ctx * ctx, const char *from, char *to, int mode);
+MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *from, char *to, int mode);
 
-#define gl_des_ecb_encrypt(ctx, from, to)  gl_des_ecb_crypt(ctx, from, to, 0)
-#define gl_des_ecb_decrypt(ctx, from, to)  gl_des_ecb_crypt(ctx, from, to, 1)
+#define MHD_gl_des_ecb_encrypt(ctx, from, to)  MHD_gl_des_ecb_crypt(ctx, from, to, 0)
+#define MHD_gl_des_ecb_decrypt(ctx, from, to)  MHD_gl_des_ecb_crypt(ctx, from, to, 1)
 
 /* Triple-DES
  * ----------
@@ -80,7 +80,7 @@ gl_des_ecb_crypt (gl_des_ctx * ctx, const char *from, char *to, int mode);
  * 64bit keys in KEY1 and KEY2.  Does not check the parity bits of the
  * keys, but simply ignore them.  Does not check for weak keys. */
 extern void
-gl_3des_set2keys (gl_3des_ctx * ctx, const char *key1, const char *key2);
+MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2);
 
 /*
  * 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);
  * of the keys, but simply ignore them.  Does not check for weak
  * keys. */
 extern void
-gl_3des_set3keys (gl_3des_ctx * ctx,
+MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx,
                   const char *key1, const char *key2, const char *key3);
 
 /* Fill a Triple-DES context CTX with subkeys calculated from three
  * concatenated 64bit keys in KEY, with weak key checking.  Does not
  * check the parity bits of the keys, but simply ignore them. */
 extern bool
-gl_3des_makekey (gl_3des_ctx * ctx, const char *key, size_t keylen);
+MHD_gl_3des_makekey (MHD_gl_3des_ctx * ctx, const char *key, size_t keylen);
 
 /* Electronic Codebook Mode Triple-DES encryption/decryption of data
  * according to 'mode'.  Sometimes this mode is named 'EDE' mode
  * (Encryption-Decryption-Encryption). */
 extern void
-gl_3des_ecb_crypt (gl_3des_ctx * ctx, const char *from, char *to, int mode);
+MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *from, char *to, int mode);
 
-#define gl_3des_ecb_encrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,0)
-#define gl_3des_ecb_decrypt(ctx, from, to) gl_3des_ecb_crypt(ctx,from,to,1)
+#define MHD_gl_3des_ecb_encrypt(ctx, from, to) MHD_gl_3des_ecb_crypt(ctx,from,to,0)
+#define MHD_gl_3des_ecb_decrypt(ctx, from, to) MHD_gl_3des_ecb_crypt(ctx,from,to,1)
 
 #endif /* DES_H */

+ 61 - 61
src/daemon/https/lgl/gc-gnulib.c

@@ -68,13 +68,13 @@
 #undef close
 
 Gc_rc
-gc_init (void)
+MHD_gc_init (void)
 {
   return GC_OK;
 }
 
 void
-gc_done (void)
+MHD_gc_done (void)
 {
   return;
 }
@@ -139,19 +139,19 @@ randomize (int level, char *data, size_t datalen)
 }
 
 Gc_rc
-gc_nonce (char *data, size_t datalen)
+MHD_gc_nonce (char *data, size_t datalen)
 {
   return randomize (0, data, datalen);
 }
 
 Gc_rc
-gc_pseudo_random (char *data, size_t datalen)
+MHD_gc_pseudo_random (char *data, size_t datalen)
 {
   return randomize (1, data, datalen);
 }
 
 Gc_rc
-gc_random (char *data, size_t datalen)
+MHD_gc_random (char *data, size_t datalen)
 {
   return randomize (2, data, datalen);
 }
@@ -160,17 +160,17 @@ gc_random (char *data, size_t datalen)
 
 /* Memory allocation. */
 void
-gc_set_allocators (gc_malloc_t func_malloc,
-                   gc_malloc_t secure_malloc,
-                   gc_secure_check_t secure_check,
-                   gc_realloc_t func_realloc, gc_free_t func_free)
+MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
+                   MHD_gc_malloc_t secure_malloc,
+                   MHD_gc_secure_check_t secure_check,
+                   MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free)
 {
   return;
 }
 
 /* Ciphers. */
 
-typedef struct _gc_cipher_ctx
+typedef struct _MHD_gc_cipher_ctx
 {
   Gc_cipher alg;
   Gc_cipher_mode mode;
@@ -182,20 +182,20 @@ typedef struct _gc_cipher_ctx
   arcfour_context arcfourContext;
 #endif
 #ifdef GNULIB_GC_DES
-  gl_des_ctx desContext;
+  MHD_gl_des_ctx desContext;
 #endif
 #ifdef GNULIB_GC_RIJNDAEL
   rijndaelKeyInstance aesEncKey;
   rijndaelKeyInstance aesDecKey;
   rijndaelCipherInstance aesContext;
 #endif
-} _gc_cipher_ctx;
+} _MHD_gc_cipher_ctx;
 
 Gc_rc
-gc_cipher_open (Gc_cipher alg,
-                Gc_cipher_mode mode, gc_cipher_handle * outhandle)
+MHD_gc_cipher_open (Gc_cipher alg,
+                Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle)
 {
-  _gc_cipher_ctx *ctx;
+  _MHD_gc_cipher_ctx *ctx;
   Gc_rc rc = GC_OK;
 
   ctx = calloc (sizeof (*ctx), 1);
@@ -277,9 +277,9 @@ gc_cipher_open (Gc_cipher alg,
 }
 
 Gc_rc
-gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
+MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *key)
 {
-  _gc_cipher_ctx *ctx = handle;
+  _MHD_gc_cipher_ctx *ctx = handle;
 
   switch (ctx->alg)
     {
@@ -300,7 +300,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
     case GC_DES:
       if (keylen != 8)
         return GC_INVALID_CIPHER;
-      gl_des_setkey (&ctx->desContext, key);
+      MHD_gl_des_setkey (&ctx->desContext, key);
       break;
 #endif
 
@@ -341,9 +341,9 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
 }
 
 Gc_rc
-gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
+MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv)
 {
-  _gc_cipher_ctx *ctx = handle;
+  _MHD_gc_cipher_ctx *ctx = handle;
 
   switch (ctx->alg)
     {
@@ -395,9 +395,9 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
 }
 
 Gc_rc
-gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
 {
-  _gc_cipher_ctx *ctx = handle;
+  _MHD_gc_cipher_ctx *ctx = handle;
 
   switch (ctx->alg)
     {
@@ -438,7 +438,7 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
 #ifdef GNULIB_GC_DES
     case GC_DES:
       for (; len >= 8; len -= 8, data += 8)
-        gl_des_ecb_encrypt (&ctx->desContext, data, data);
+        MHD_gl_des_ecb_encrypt (&ctx->desContext, data, data);
       break;
 #endif
 
@@ -465,9 +465,9 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
 }
 
 Gc_rc
-gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
 {
-  _gc_cipher_ctx *ctx = handle;
+  _MHD_gc_cipher_ctx *ctx = handle;
 
   switch (ctx->alg)
     {
@@ -510,7 +510,7 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
 #ifdef GNULIB_GC_DES
     case GC_DES:
       for (; len >= 8; len -= 8, data += 8)
-        gl_des_ecb_decrypt (&ctx->desContext, data, data);
+        MHD_gl_des_ecb_decrypt (&ctx->desContext, data, data);
       break;
 #endif
 
@@ -537,9 +537,9 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
 }
 
 Gc_rc
-gc_cipher_close (gc_cipher_handle handle)
+MHD_gc_cipher_close (MHD_gc_cipher_handle handle)
 {
-  _gc_cipher_ctx *ctx = handle;
+  _MHD_gc_cipher_ctx *ctx = handle;
 
   if (ctx)
     free (ctx);
@@ -551,23 +551,23 @@ gc_cipher_close (gc_cipher_handle handle)
 
 #define MAX_DIGEST_SIZE 20
 
-typedef struct _gc_hash_ctx
+typedef struct _MHD_gc_hash_ctx
 {
   Gc_hash alg;
   Gc_hash_mode mode;
   char hash[MAX_DIGEST_SIZE];
 #ifdef GNULIB_GC_MD5
-  struct md5_ctx md5Context;
+  struct MHD_md5_ctx md5Context;
 #endif
 #ifdef GNULIB_GC_SHA1
-  struct sha1_ctx sha1Context;
+  struct MHD_sha1_ctx sha1Context;
 #endif
-} _gc_hash_ctx;
+} _MHD_gc_hash_ctx;
 
 Gc_rc
-gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
+MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, MHD_gc_hash_handle * outhandle)
 {
-  _gc_hash_ctx *ctx;
+  _MHD_gc_hash_ctx *ctx;
   Gc_rc rc = GC_OK;
 
   ctx = calloc (sizeof (*ctx), 1);
@@ -581,13 +581,13 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
     {
 #ifdef GNULIB_GC_MD5
     case GC_MD5:
-      md5_init_ctx (&ctx->md5Context);
+      MHD_md5_init_ctx (&ctx->md5Context);
       break;
 #endif
 
 #ifdef GNULIB_GC_SHA1
     case GC_SHA1:
-      sha1_init_ctx (&ctx->sha1Context);
+      MHD_sha1_init_ctx (&ctx->sha1Context);
       break;
 #endif
 
@@ -615,10 +615,10 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
 }
 
 Gc_rc
-gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
+MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle)
 {
-  _gc_hash_ctx *in = handle;
-  _gc_hash_ctx *out;
+  _MHD_gc_hash_ctx *in = handle;
+  _MHD_gc_hash_ctx *out;
 
   *outhandle = out = calloc (sizeof (*out), 1);
   if (!out)
@@ -630,7 +630,7 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
 }
 
 size_t
-gc_hash_digest_length (Gc_hash hash)
+MHD_gc_hash_digest_length (Gc_hash hash)
 {
   size_t len;
 
@@ -664,21 +664,21 @@ gc_hash_digest_length (Gc_hash hash)
 }
 
 void
-gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
+MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data)
 {
-  _gc_hash_ctx *ctx = handle;
+  _MHD_gc_hash_ctx *ctx = handle;
 
   switch (ctx->alg)
     {
 #ifdef GNULIB_GC_MD5
     case GC_MD5:
-      md5_process_bytes (data, len, &ctx->md5Context);
+      MHD_md5_process_bytes (data, len, &ctx->md5Context);
       break;
 #endif
 
 #ifdef GNULIB_GC_SHA1
     case GC_SHA1:
-      sha1_process_bytes (data, len, &ctx->sha1Context);
+      MHD_sha1_process_bytes (data, len, &ctx->sha1Context);
       break;
 #endif
 
@@ -688,23 +688,23 @@ gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
 }
 
 const char *
-gc_hash_read (gc_hash_handle handle)
+MHD_gc_hash_read (MHD_gc_hash_handle handle)
 {
-  _gc_hash_ctx *ctx = handle;
+  _MHD_gc_hash_ctx *ctx = handle;
   const char *ret = NULL;
 
   switch (ctx->alg)
     {
 #ifdef GNULIB_GC_MD5
     case GC_MD5:
-      md5_finish_ctx (&ctx->md5Context, ctx->hash);
+      MHD_md5_finish_ctx (&ctx->md5Context, ctx->hash);
       ret = ctx->hash;
       break;
 #endif
 
 #ifdef GNULIB_GC_SHA1
     case GC_SHA1:
-      sha1_finish_ctx (&ctx->sha1Context, ctx->hash);
+      MHD_sha1_finish_ctx (&ctx->sha1Context, ctx->hash);
       ret = ctx->hash;
       break;
 #endif
@@ -717,27 +717,27 @@ gc_hash_read (gc_hash_handle handle)
 }
 
 void
-gc_hash_close (gc_hash_handle handle)
+MHD_gc_hash_close (MHD_gc_hash_handle handle)
 {
-  _gc_hash_ctx *ctx = handle;
+  _MHD_gc_hash_ctx *ctx = handle;
 
   free (ctx);
 }
 
 Gc_rc
-gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
+MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
 {
   switch (hash)
     {
 #ifdef GNULIB_GC_MD5
     case GC_MD5:
-      md5_buffer (in, inlen, resbuf);
+      MHD_md5_buffer (in, inlen, resbuf);
       break;
 #endif
 
 #ifdef GNULIB_GC_SHA1
     case GC_SHA1:
-      sha1_buffer (in, inlen, resbuf);
+      MHD_sha1_buffer (in, inlen, resbuf);
       break;
 #endif
 
@@ -750,38 +750,38 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
 
 #ifdef GNULIB_GC_MD5
 Gc_rc
-gc_md5 (const void *in, size_t inlen, void *resbuf)
+MHD_gc_md5 (const void *in, size_t inlen, void *resbuf)
 {
-  md5_buffer (in, inlen, resbuf);
+  MHD_md5_buffer (in, inlen, resbuf);
   return GC_OK;
 }
 #endif
 
 #ifdef GNULIB_GC_SHA1
 Gc_rc
-gc_sha1 (const void *in, size_t inlen, void *resbuf)
+MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf)
 {
-  sha1_buffer (in, inlen, resbuf);
+  MHD_sha1_buffer (in, inlen, resbuf);
   return GC_OK;
 }
 #endif
 
 #ifdef GNULIB_GC_HMAC_MD5
 Gc_rc
-gc_hmac_md5 (const void *key, size_t keylen,
+MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen,
              const void *in, size_t inlen, char *resbuf)
 {
-  hmac_md5 (key, keylen, in, inlen, resbuf);
+  MHD_hmac_md5 (key, keylen, in, inlen, resbuf);
   return GC_OK;
 }
 #endif
 
 #ifdef GNULIB_GC_HMAC_SHA1
 Gc_rc
-gc_hmac_sha1 (const void *key,
+MHD_gc_MHD_hmac_sha1 (const void *key,
               size_t keylen, const void *in, size_t inlen, char *resbuf)
 {
-  hmac_sha1 (key, keylen, in, inlen, resbuf);
+  MHD_hmac_sha1 (key, keylen, in, inlen, resbuf);
   return GC_OK;
 }
 #endif

+ 37 - 37
src/daemon/https/lgl/gc-libgcrypt.c

@@ -36,7 +36,7 @@
 /* Initialization. */
 
 Gc_rc
-gc_init (void)
+MHD_gc_init (void)
 {
   gcry_error_t err;
 
@@ -54,7 +54,7 @@ gc_init (void)
 }
 
 void
-gc_done (void)
+MHD_gc_done (void)
 {
   return;
 }
@@ -64,21 +64,21 @@ gc_done (void)
 /* Randomness. */
 
 Gc_rc
-gc_nonce (char *data, size_t datalen)
+MHD_gc_nonce (char *data, size_t datalen)
 {
   gcry_create_nonce ((unsigned char *) data, datalen);
   return GC_OK;
 }
 
 Gc_rc
-gc_pseudo_random (char *data, size_t datalen)
+MHD_gc_pseudo_random (char *data, size_t datalen)
 {
   gcry_randomize ((unsigned char *) data, datalen, GCRY_STRONG_RANDOM);
   return GC_OK;
 }
 
 Gc_rc
-gc_random (char *data, size_t datalen)
+MHD_gc_random (char *data, size_t datalen)
 {
   gcry_randomize ((unsigned char *) data, datalen, GCRY_VERY_STRONG_RANDOM);
   return GC_OK;
@@ -89,10 +89,10 @@ gc_random (char *data, size_t datalen)
 /* Memory allocation. */
 
 void
-gc_set_allocators (gc_malloc_t func_malloc,
-                   gc_malloc_t secure_malloc,
-                   gc_secure_check_t secure_check,
-                   gc_realloc_t func_realloc, gc_free_t func_free)
+MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
+                   MHD_gc_malloc_t secure_malloc,
+                   MHD_gc_secure_check_t secure_check,
+                   MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free)
 {
   gcry_set_allocation_handler (func_malloc, secure_malloc, secure_check,
                                func_realloc, func_free);
@@ -101,8 +101,8 @@ gc_set_allocators (gc_malloc_t func_malloc,
 /* Ciphers. */
 
 Gc_rc
-gc_cipher_open (Gc_cipher alg,
-                Gc_cipher_mode mode, gc_cipher_handle * outhandle)
+MHD_gc_cipher_open (Gc_cipher alg,
+                Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle)
 {
   int gcryalg, gcrymode;
   gcry_error_t err;
@@ -179,7 +179,7 @@ gc_cipher_open (Gc_cipher alg,
 }
 
 Gc_rc
-gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
+MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *key)
 {
   gcry_error_t err;
 
@@ -191,7 +191,7 @@ gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
 }
 
 Gc_rc
-gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
+MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv)
 {
   gcry_error_t err;
 
@@ -203,7 +203,7 @@ gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
 }
 
 Gc_rc
-gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
 {
   if (gcry_cipher_encrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) !=
       0)
@@ -213,7 +213,7 @@ gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
 }
 
 Gc_rc
-gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data)
 {
   if (gcry_cipher_decrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) !=
       0)
@@ -223,7 +223,7 @@ gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
 }
 
 Gc_rc
-gc_cipher_close (gc_cipher_handle handle)
+MHD_gc_cipher_close (MHD_gc_cipher_handle handle)
 {
   gcry_cipher_close (handle);
 
@@ -232,17 +232,17 @@ gc_cipher_close (gc_cipher_handle handle)
 
 /* Hashes. */
 
-typedef struct _gc_hash_ctx
+typedef struct _MHD_gc_hash_ctx
 {
   Gc_hash alg;
   Gc_hash_mode mode;
   gcry_md_hd_t gch;
-} _gc_hash_ctx;
+} _MHD_gc_hash_ctx;
 
 Gc_rc
-gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
+MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, MHD_gc_hash_handle * outhandle)
 {
-  _gc_hash_ctx *ctx;
+  _MHD_gc_hash_ctx *ctx;
   int gcryalg = 0, gcrymode = 0;
   gcry_error_t err;
   Gc_rc rc = GC_OK;
@@ -322,10 +322,10 @@ gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
 }
 
 Gc_rc
-gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
+MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle)
 {
-  _gc_hash_ctx *in = handle;
-  _gc_hash_ctx *out;
+  _MHD_gc_hash_ctx *in = handle;
+  _MHD_gc_hash_ctx *out;
   int err;
 
   *outhandle = out = calloc (sizeof (*out), 1);
@@ -345,7 +345,7 @@ gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
 }
 
 size_t
-gc_hash_digest_length (Gc_hash hash)
+MHD_gc_hash_digest_length (Gc_hash hash)
 {
   size_t len;
 
@@ -391,23 +391,23 @@ gc_hash_digest_length (Gc_hash hash)
 }
 
 void
-gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key)
+MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, const char *key)
 {
-  _gc_hash_ctx *ctx = handle;
+  _MHD_gc_hash_ctx *ctx = handle;
   gcry_md_setkey (ctx->gch, key, len);
 }
 
 void
-gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
+MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data)
 {
-  _gc_hash_ctx *ctx = handle;
+  _MHD_gc_hash_ctx *ctx = handle;
   gcry_md_write (ctx->gch, data, len);
 }
 
 const char *
-gc_hash_read (gc_hash_handle handle)
+MHD_gc_hash_read (MHD_gc_hash_handle handle)
 {
-  _gc_hash_ctx *ctx = handle;
+  _MHD_gc_hash_ctx *ctx = handle;
   const char *digest;
   {
     gcry_md_final (ctx->gch);
@@ -418,9 +418,9 @@ gc_hash_read (gc_hash_handle handle)
 }
 
 void
-gc_hash_close (gc_hash_handle handle)
+MHD_gc_hash_close (MHD_gc_hash_handle handle)
 {
-  _gc_hash_ctx *ctx = handle;
+  _MHD_gc_hash_ctx *ctx = handle;
 
   gcry_md_close (ctx->gch);
 
@@ -428,7 +428,7 @@ gc_hash_close (gc_hash_handle handle)
 }
 
 Gc_rc
-gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
+MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
 {
   int gcryalg;
 
@@ -482,7 +482,7 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
 /* One-call interface. */
 #ifdef GNULIB_GC_MD5
 Gc_rc
-gc_md5 (const void *in, size_t inlen, void *resbuf)
+MHD_gc_md5 (const void *in, size_t inlen, void *resbuf)
 {
   size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
   gcry_md_hd_t hd;
@@ -514,7 +514,7 @@ gc_md5 (const void *in, size_t inlen, void *resbuf)
 
 #ifdef GNULIB_GC_SHA1
 Gc_rc
-gc_sha1 (const void *in, size_t inlen, void *resbuf)
+MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf)
 {
   size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
   gcry_md_hd_t hd;
@@ -546,7 +546,7 @@ gc_sha1 (const void *in, size_t inlen, void *resbuf)
 
 #ifdef GNULIB_GC_HMAC_MD5
 Gc_rc
-gc_hmac_md5 (const void *key, size_t keylen,
+MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen,
              const void *in, size_t inlen, char *resbuf)
 {
   size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
@@ -586,7 +586,7 @@ gc_hmac_md5 (const void *key, size_t keylen,
 
 #ifdef GNULIB_GC_HMAC_SHA1
 Gc_rc
-gc_hmac_sha1 (const void *key,
+MHD_gc_MHD_hmac_sha1 (const void *key,
               size_t keylen, const void *in, size_t inlen, char *resbuf)
 {
   size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);

+ 3 - 3
src/daemon/https/lgl/gc-pbkdf2-sha1.c

@@ -52,7 +52,7 @@
  */
 
 Gc_rc
-gc_pbkdf2_sha1 (const char *P, size_t Plen,
+MHD_gc_pbkdf2_sha1 (const char *P, size_t Plen,
                 const char *S, size_t Slen,
                 unsigned int c, char *DK, size_t dkLen)
 {
@@ -161,10 +161,10 @@ gc_pbkdf2_sha1 (const char *P, size_t Plen,
               tmp[Slen + 2] = (i & 0x0000ff00) >> 8;
               tmp[Slen + 3] = (i & 0x000000ff) >> 0;
 
-              rc = gc_hmac_sha1 (P, Plen, tmp, tmplen, U);
+              rc = MHD_gc_MHD_hmac_sha1 (P, Plen, tmp, tmplen, U);
             }
           else
-            rc = gc_hmac_sha1 (P, Plen, U, hLen, U);
+            rc = MHD_gc_MHD_hmac_sha1 (P, Plen, U, hLen, U);
 
           if (rc != GC_OK)
             {

+ 39 - 39
src/daemon/https/lgl/gc.h

@@ -58,7 +58,7 @@ enum Gc_hash_mode
 };
 typedef enum Gc_hash_mode Gc_hash_mode;
 
-typedef void *gc_hash_handle;
+typedef void *MHD_gc_hash_handle;
 
 #define GC_MD2_DIGEST_SIZE 16
 #define GC_MD4_DIGEST_SIZE 16
@@ -93,49 +93,49 @@ enum Gc_cipher_mode
 };
 typedef enum Gc_cipher_mode Gc_cipher_mode;
 
-typedef void *gc_cipher_handle;
+typedef void *MHD_gc_cipher_handle;
 
 /* Call before respectively after any other functions. */
-Gc_rc gc_init (void);
-void gc_done (void);
+Gc_rc MHD_gc_init (void);
+void MHD_gc_done (void);
 
 /* Memory allocation (avoid). */
-typedef void *(*gc_malloc_t) (size_t n);
-typedef int (*gc_secure_check_t) (const void *);
-typedef void *(*gc_realloc_t) (void *p, size_t n);
-typedef void (*gc_free_t) (void *);
-void gc_set_allocators (gc_malloc_t func_malloc,
-                        gc_malloc_t secure_malloc,
-                        gc_secure_check_t secure_check,
-                        gc_realloc_t func_realloc, gc_free_t func_free);
+typedef void *(*MHD_gc_malloc_t) (size_t n);
+typedef int (*MHD_gc_secure_check_t) (const void *);
+typedef void *(*MHD_gc_realloc_t) (void *p, size_t n);
+typedef void (*MHD_gc_free_t) (void *);
+void MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc,
+                        MHD_gc_malloc_t secure_malloc,
+                        MHD_gc_secure_check_t secure_check,
+                        MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free);
 
 /* Randomness. */
-Gc_rc gc_nonce (char *data, size_t datalen);
-Gc_rc gc_pseudo_random (char *data, size_t datalen);
-Gc_rc gc_random (char *data, size_t datalen);
+Gc_rc MHD_gc_nonce (char *data, size_t datalen);
+Gc_rc MHD_gc_pseudo_random (char *data, size_t datalen);
+Gc_rc MHD_gc_random (char *data, size_t datalen);
 
 /* Ciphers. */
-Gc_rc gc_cipher_open (Gc_cipher cipher,
-                      Gc_cipher_mode mode, gc_cipher_handle * outhandle);
-Gc_rc gc_cipher_setkey (gc_cipher_handle handle,
+Gc_rc MHD_gc_cipher_open (Gc_cipher cipher,
+                      Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle);
+Gc_rc MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle,
                         size_t keylen, const char *key);
-Gc_rc gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv);
-Gc_rc gc_cipher_encrypt_inline (gc_cipher_handle handle,
+Gc_rc MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv);
+Gc_rc MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle,
                                 size_t len, char *data);
-Gc_rc gc_cipher_decrypt_inline (gc_cipher_handle handle,
+Gc_rc MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle,
                                 size_t len, char *data);
-Gc_rc gc_cipher_close (gc_cipher_handle handle);
+Gc_rc MHD_gc_cipher_close (MHD_gc_cipher_handle handle);
 
 /* Hashes. */
 
-Gc_rc gc_hash_open (Gc_hash hash,
-                    Gc_hash_mode mode, gc_hash_handle * outhandle);
-Gc_rc gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle);
-size_t gc_hash_digest_length (Gc_hash hash);
-void gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key);
-void gc_hash_write (gc_hash_handle handle, size_t len, const char *data);
-const char *gc_hash_read (gc_hash_handle handle);
-void gc_hash_close (gc_hash_handle handle);
+Gc_rc MHD_gc_hash_open (Gc_hash hash,
+                    Gc_hash_mode mode, MHD_gc_hash_handle * outhandle);
+Gc_rc MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle);
+size_t MHD_gc_hash_digest_length (Gc_hash hash);
+void MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, const char *key);
+void MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data);
+const char *MHD_gc_hash_read (MHD_gc_hash_handle handle);
+void MHD_gc_hash_close (MHD_gc_hash_handle handle);
 
 /* Compute a hash value over buffer IN of INLEN bytes size using the
  algorithm HASH, placing the result in the pre-allocated buffer OUT.
@@ -143,16 +143,16 @@ void gc_hash_close (gc_hash_handle handle);
  GC_<HASH>_DIGEST_SIZE.  For example, for GC_MD5 the output buffer
  must be 16 bytes.  The return value is 0 (GC_OK) on success, or
  another Gc_rc error code. */
-Gc_rc gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out);
+Gc_rc MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out);
 
 /* One-call interface. */
-Gc_rc gc_md2 (const void *in, size_t inlen, void *resbuf);
-Gc_rc gc_md4 (const void *in, size_t inlen, void *resbuf);
-Gc_rc gc_md5 (const void *in, size_t inlen, void *resbuf);
-Gc_rc gc_sha1 (const void *in, size_t inlen, void *resbuf);
-Gc_rc gc_hmac_md5 (const void *key,
+Gc_rc MHD_gc_md2 (const void *in, size_t inlen, void *resbuf);
+Gc_rc MHD_gc_md4 (const void *in, size_t inlen, void *resbuf);
+Gc_rc MHD_gc_md5 (const void *in, size_t inlen, void *resbuf);
+Gc_rc MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf);
+Gc_rc MHD_gc_MHD_hmac_md5 (const void *key,
                    size_t keylen, const void *in, size_t inlen, char *resbuf);
-Gc_rc gc_hmac_sha1 (const void *key,
+Gc_rc MHD_gc_MHD_hmac_sha1 (const void *key,
                     size_t keylen,
                     const void *in, size_t inlen, char *resbuf);
 
@@ -163,7 +163,7 @@ Gc_rc gc_hmac_sha1 (const void *key,
  counts are 1000-20000).  This function "stretches" the key to be
  exactly dkLen bytes long.  GC_OK is returned on success, otherwise
  an Gc_rc error code is returned.  */
-Gc_rc gc_pbkdf2_sha1 (const char *P,
+Gc_rc MHD_gc_pbkdf2_sha1 (const char *P,
                       size_t Plen,
                       const char *S,
                       size_t Slen, unsigned int c, char *DK, size_t dkLen);
@@ -285,7 +285,7 @@ Gc_rc gc_pbkdf2_sha1 (const char *P,
  requirement, what entropy quality it require, and call the proper API.
  Meeting the implied semantic properties should be the job for gnulib.
 
- >> Perhaps gc_dev_random and gc_dev_urandom?
+ >> Perhaps MHD_gc_dev_random and MHD_gc_dev_urandom?
  >
  > To some extent.  I'd rather insulate the user from the details of
  > where the random numbers come from.  On the other hand we need to

+ 17 - 17
src/daemon/https/lgl/hmac-md5.c

@@ -30,11 +30,11 @@
 #define OPAD 0x5c
 
 int
-hmac_md5 (const void *key, size_t keylen,
+MHD_hmac_md5 (const void *key, size_t keylen,
           const void *in, size_t inlen, void *resbuf)
 {
-  struct md5_ctx inner;
-  struct md5_ctx outer;
+  struct MHD_md5_ctx inner;
+  struct MHD_md5_ctx outer;
   char optkeybuf[16];
   char block[64];
   char innerhash[16];
@@ -43,11 +43,11 @@ hmac_md5 (const void *key, size_t keylen,
 
   if (keylen > 64)
     {
-      struct md5_ctx keyhash;
+      struct MHD_md5_ctx keyhash;
 
-      md5_init_ctx (&keyhash);
-      md5_process_bytes (key, keylen, &keyhash);
-      md5_finish_ctx (&keyhash, optkeybuf);
+      MHD_md5_init_ctx (&keyhash);
+      MHD_md5_process_bytes (key, keylen, &keyhash);
+      MHD_md5_finish_ctx (&keyhash, optkeybuf);
 
       key = optkeybuf;
       keylen = 16;
@@ -55,27 +55,27 @@ hmac_md5 (const void *key, size_t keylen,
 
   /* Compute INNERHASH from KEY and IN.  */
 
-  md5_init_ctx (&inner);
+  MHD_md5_init_ctx (&inner);
 
   memset (block, IPAD, sizeof (block));
-  memxor (block, key, keylen);
+  MHD_memxor (block, key, keylen);
 
-  md5_process_block (block, 64, &inner);
-  md5_process_bytes (in, inlen, &inner);
+  MHD_md5_process_block (block, 64, &inner);
+  MHD_md5_process_bytes (in, inlen, &inner);
 
-  md5_finish_ctx (&inner, innerhash);
+  MHD_md5_finish_ctx (&inner, innerhash);
 
   /* Compute result from KEY and INNERHASH.  */
 
-  md5_init_ctx (&outer);
+  MHD_md5_init_ctx (&outer);
 
   memset (block, OPAD, sizeof (block));
-  memxor (block, key, keylen);
+  MHD_memxor (block, key, keylen);
 
-  md5_process_block (block, 64, &outer);
-  md5_process_bytes (innerhash, 16, &outer);
+  MHD_md5_process_block (block, 64, &outer);
+  MHD_md5_process_bytes (innerhash, 16, &outer);
 
-  md5_finish_ctx (&outer, resbuf);
+  MHD_md5_finish_ctx (&outer, resbuf);
 
   return 0;
 }

+ 17 - 17
src/daemon/https/lgl/hmac-sha1.c

@@ -30,11 +30,11 @@
 #define OPAD 0x5c
 
 int
-hmac_sha1 (const void *key, size_t keylen,
+MHD_hmac_sha1 (const void *key, size_t keylen,
            const void *in, size_t inlen, void *resbuf)
 {
-  struct sha1_ctx inner;
-  struct sha1_ctx outer;
+  struct MHD_sha1_ctx inner;
+  struct MHD_sha1_ctx outer;
   char optkeybuf[20];
   char block[64];
   char innerhash[20];
@@ -43,11 +43,11 @@ hmac_sha1 (const void *key, size_t keylen,
 
   if (keylen > 64)
     {
-      struct sha1_ctx keyhash;
+      struct MHD_sha1_ctx keyhash;
 
-      sha1_init_ctx (&keyhash);
-      sha1_process_bytes (key, keylen, &keyhash);
-      sha1_finish_ctx (&keyhash, optkeybuf);
+      MHD_sha1_init_ctx (&keyhash);
+      MHD_sha1_process_bytes (key, keylen, &keyhash);
+      MHD_sha1_finish_ctx (&keyhash, optkeybuf);
 
       key = optkeybuf;
       keylen = 20;
@@ -55,27 +55,27 @@ hmac_sha1 (const void *key, size_t keylen,
 
   /* Compute INNERHASH from KEY and IN.  */
 
-  sha1_init_ctx (&inner);
+  MHD_sha1_init_ctx (&inner);
 
   memset (block, IPAD, sizeof (block));
-  memxor (block, key, keylen);
+  MHD_memxor (block, key, keylen);
 
-  sha1_process_block (block, 64, &inner);
-  sha1_process_bytes (in, inlen, &inner);
+  MHD_sha1_process_block (block, 64, &inner);
+  MHD_sha1_process_bytes (in, inlen, &inner);
 
-  sha1_finish_ctx (&inner, innerhash);
+  MHD_sha1_finish_ctx (&inner, innerhash);
 
   /* Compute result from KEY and INNERHASH.  */
 
-  sha1_init_ctx (&outer);
+  MHD_sha1_init_ctx (&outer);
 
   memset (block, OPAD, sizeof (block));
-  memxor (block, key, keylen);
+  MHD_memxor (block, key, keylen);
 
-  sha1_process_block (block, 64, &outer);
-  sha1_process_bytes (innerhash, 20, &outer);
+  MHD_sha1_process_block (block, 64, &outer);
+  MHD_sha1_process_bytes (innerhash, 20, &outer);
 
-  sha1_finish_ctx (&outer, resbuf);
+  MHD_sha1_finish_ctx (&outer, resbuf);
 
   return 0;
 }

+ 2 - 2
src/daemon/https/lgl/hmac.h

@@ -27,7 +27,7 @@
    KEYLEN bytes, writing the output to pre-allocated 16 byte minimum
    RESBUF buffer.  Return 0 on success.  */
 int
-hmac_md5 (const void *key, size_t keylen,
+MHD_hmac_md5 (const void *key, size_t keylen,
           const void *buffer, size_t buflen, void *resbuf);
 
 /* Compute Hashed Message Authentication Code with SHA-1, over BUFFER
@@ -35,7 +35,7 @@ hmac_md5 (const void *key, size_t keylen,
    output to pre-allocated 20 byte minimum RESBUF buffer.  Return 0 on
    success.  */
 int
-hmac_sha1 (const void *key, size_t keylen,
+MHD_hmac_sha1 (const void *key, size_t keylen,
            const void *in, size_t inlen, void *resbuf);
 
 #endif /* HMAC_H */

+ 29 - 29
src/daemon/https/lgl/md5.c

@@ -40,13 +40,13 @@
 # endif
 /* We need to keep the namespace clean so define the MD5 function
    protected using leading __ .  */
-# define md5_init_ctx __md5_init_ctx
-# define md5_process_block __md5_process_block
-# define md5_process_bytes __md5_process_bytes
-# define md5_finish_ctx __md5_finish_ctx
-# define md5_read_ctx __md5_read_ctx
-# define md5_stream __md5_stream
-# define md5_buffer __md5_buffer
+# define MHD_md5_init_ctx __MHD_md5_init_ctx
+# define MHD_md5_process_block __MHD_md5_process_block
+# define MHD_md5_process_bytes __MHD_md5_process_bytes
+# define MHD_md5_finish_ctx __MHD_md5_finish_ctx
+# define MHD_md5_read_ctx __MHD_md5_read_ctx
+# define MHD_md5_stream __MHD_md5_stream
+# define MHD_md5_buffer __MHD_md5_buffer
 #endif
 
 #ifdef WORDS_BIGENDIAN
@@ -69,7 +69,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */  };
 /* Initialize structure containing state of computation.
    (RFC 1321, 3.3: Step 3)  */
 void
-md5_init_ctx (struct md5_ctx *ctx)
+MHD_md5_init_ctx (struct MHD_md5_ctx *ctx)
 {
   ctx->A = 0x67452301;
   ctx->B = 0xefcdab89;
@@ -86,7 +86,7 @@ md5_init_ctx (struct md5_ctx *ctx)
    IMPORTANT: On some systems it is required that RESBUF is correctly
    aligned for a 32-bit value.  */
 void *
-md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
+MHD_md5_read_ctx (const struct MHD_md5_ctx *ctx, void *resbuf)
 {
   ((uint32_t *) resbuf)[0] = SWAP (ctx->A);
   ((uint32_t *) resbuf)[1] = SWAP (ctx->B);
@@ -102,7 +102,7 @@ md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
    IMPORTANT: On some systems it is required that RESBUF is correctly
    aligned for a 32-bit value.  */
 void *
-md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
+MHD_md5_finish_ctx (struct MHD_md5_ctx *ctx, void *resbuf)
 {
   /* Take yet unprocessed bytes into account.  */
   uint32_t bytes = ctx->buflen;
@@ -120,23 +120,23 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
   memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
 
   /* Process last bytes.  */
-  md5_process_block (ctx->buffer, size * 4, ctx);
+  MHD_md5_process_block (ctx->buffer, size * 4, ctx);
 
-  return md5_read_ctx (ctx, resbuf);
+  return MHD_md5_read_ctx (ctx, resbuf);
 }
 
 /* Compute MD5 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
 int
-md5_stream (FILE * stream, void *resblock)
+MHD_md5_stream (FILE * stream, void *resblock)
 {
-  struct md5_ctx ctx;
+  struct MHD_md5_ctx ctx;
   char buffer[BLOCKSIZE + 72];
   size_t sum;
 
   /* Initialize the computation context.  */
-  md5_init_ctx (&ctx);
+  MHD_md5_init_ctx (&ctx);
 
   /* Iterate over full file contents.  */
   while (1)
@@ -177,17 +177,17 @@ md5_stream (FILE * stream, void *resblock)
       /* Process buffer with BLOCKSIZE bytes.  Note that
          BLOCKSIZE % 64 == 0
        */
-      md5_process_block (buffer, BLOCKSIZE, &ctx);
+      MHD_md5_process_block (buffer, BLOCKSIZE, &ctx);
     }
 
 process_partial_block:
 
   /* Process any remaining bytes.  */
   if (sum > 0)
-    md5_process_bytes (buffer, sum, &ctx);
+    MHD_md5_process_bytes (buffer, sum, &ctx);
 
   /* Construct result in desired memory.  */
-  md5_finish_ctx (&ctx, resblock);
+  MHD_md5_finish_ctx (&ctx, resblock);
   return 0;
 }
 
@@ -196,23 +196,23 @@ process_partial_block:
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-md5_buffer (const char *buffer, size_t len, void *resblock)
+MHD_md5_buffer (const char *buffer, size_t len, void *resblock)
 {
-  struct md5_ctx ctx;
+  struct MHD_md5_ctx ctx;
 
   /* Initialize the computation context.  */
-  md5_init_ctx (&ctx);
+  MHD_md5_init_ctx (&ctx);
 
   /* Process whole buffer but last len % 64 bytes.  */
-  md5_process_bytes (buffer, len, &ctx);
+  MHD_md5_process_bytes (buffer, len, &ctx);
 
   /* Put result in desired memory area.  */
-  return md5_finish_ctx (&ctx, resblock);
+  return MHD_md5_finish_ctx (&ctx, resblock);
 }
 
 
 void
-md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
+MHD_md5_process_bytes (const void *buffer, size_t len, struct MHD_md5_ctx *ctx)
 {
   /* When we already have some bits in our internal buffer concatenate
      both inputs first.  */
@@ -226,7 +226,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
 
       if (ctx->buflen > 64)
         {
-          md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
+          MHD_md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
 
           ctx->buflen &= 63;
           /* 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)
       if (UNALIGNED_P (buffer))
         while (len > 64)
           {
-            md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
+            MHD_md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
             buffer = (const char *) buffer + 64;
             len -= 64;
           }
       else
 #endif
         {
-          md5_process_block (buffer, len & ~63, ctx);
+          MHD_md5_process_block (buffer, len & ~63, ctx);
           buffer = (const char *) buffer + (len & ~63);
           len &= 63;
         }
@@ -270,7 +270,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
       left_over += len;
       if (left_over >= 64)
         {
-          md5_process_block (ctx->buffer, 64, ctx);
+          MHD_md5_process_block (ctx->buffer, 64, ctx);
           left_over -= 64;
           memcpy (ctx->buffer, &ctx->buffer[16], left_over);
         }
@@ -292,7 +292,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
    It is assumed that LEN % 64 == 0.  */
 
 void
-md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
+MHD_md5_process_block (const void *buffer, size_t len, struct MHD_md5_ctx *ctx)
 {
   uint32_t correct_words[16];
   const uint32_t *words = buffer;

+ 18 - 18
src/daemon/https/lgl/md5.h

@@ -45,17 +45,17 @@
 #endif
 
 #ifndef _LIBC
-# define __md5_buffer md5_buffer
-# define __md5_finish_ctx md5_finish_ctx
-# define __md5_init_ctx md5_init_ctx
-# define __md5_process_block md5_process_block
-# define __md5_process_bytes md5_process_bytes
-# define __md5_read_ctx md5_read_ctx
-# define __md5_stream md5_stream
+# define __MHD_md5_buffer MHD_md5_buffer
+# define __MHD_md5_finish_ctx MHD_md5_finish_ctx
+# define __MHD_md5_init_ctx MHD_md5_init_ctx
+# define __MHD_md5_process_block MHD_md5_process_block
+# define __MHD_md5_process_bytes MHD_md5_process_bytes
+# define __MHD_md5_read_ctx MHD_md5_read_ctx
+# define __MHD_md5_stream MHD_md5_stream
 #endif
 
 /* Structure to save state of computation between the single steps.  */
-struct md5_ctx
+struct MHD_md5_ctx
 {
   uint32_t A;
   uint32_t B;
@@ -69,28 +69,28 @@ struct md5_ctx
 
 /*
  * The following three functions are build up the low level used in
- * the functions `md5_stream' and `md5_buffer'.
+ * the functions `MHD_md5_stream' and `MHD_md5_buffer'.
  */
 
 /* Initialize structure containing state of computation.
    (RFC 1321, 3.3: Step 3)  */
 extern void
-__md5_init_ctx (struct md5_ctx *ctx)
+__MHD_md5_init_ctx (struct MHD_md5_ctx *ctx)
   __THROW;
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 64!!! */
-     extern void __md5_process_block (const void *buffer, size_t len,
-                                      struct md5_ctx *ctx) __THROW;
+     extern void __MHD_md5_process_block (const void *buffer, size_t len,
+                                      struct MHD_md5_ctx *ctx) __THROW;
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-     extern void __md5_process_bytes (const void *buffer, size_t len,
-                                      struct md5_ctx *ctx) __THROW;
+     extern void __MHD_md5_process_bytes (const void *buffer, size_t len,
+                                      struct MHD_md5_ctx *ctx) __THROW;
 
 /* Process the remaining bytes in the buffer and put result from CTX
    in first 16 bytes following RESBUF.  The result is always in little
@@ -99,7 +99,7 @@ __md5_init_ctx (struct md5_ctx *ctx)
 
    IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
    boundary. */
-     extern void *__md5_finish_ctx (struct md5_ctx *ctx,
+     extern void *__MHD_md5_finish_ctx (struct MHD_md5_ctx *ctx,
                                     void *resbuf) __THROW;
 
 
@@ -109,20 +109,20 @@ __md5_init_ctx (struct md5_ctx *ctx)
 
    IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
    boundary. */
-     extern void *__md5_read_ctx (const struct md5_ctx *ctx,
+     extern void *__MHD_md5_read_ctx (const struct MHD_md5_ctx *ctx,
                                   void *resbuf) __THROW;
 
 
 /* Compute MD5 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
-     extern int __md5_stream (FILE * stream, void *resblock) __THROW;
+     extern int __MHD_md5_stream (FILE * stream, void *resblock) __THROW;
 
 /* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
    result is always in little endian byte order, so that a byte-wise
    output yields to the wanted ASCII representation of the message
    digest.  */
-     extern void *__md5_buffer (const char *buffer, size_t len,
+     extern void *__MHD_md5_buffer (const char *buffer, size_t len,
                                 void *resblock) __THROW;
 
 #endif /* md5.h */

+ 2 - 2
src/daemon/https/lgl/memmem.c

@@ -26,11 +26,11 @@
 # define __builtin_expect(expr, val)   (expr)
 #endif
 
-#undef memmem
+#undef MHD_memmem
 
 /* Return the first occurrence of NEEDLE in HAYSTACK.  */
 void *
-memmem (haystack, haystack_len, needle, needle_len)
+MHD_memmem (haystack, haystack_len, needle, needle_len)
      const void *haystack;
      size_t haystack_len;
      const void *needle;

+ 3 - 3
src/daemon/https/lgl/memxor.c

@@ -1,4 +1,4 @@
-/* memxor.c -- perform binary exclusive OR operation of two memory blocks.
+/* MHD_memxor.c -- perform binary exclusive OR operation of two memory blocks.
    Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -15,7 +15,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-/* Written by Simon Josefsson.  The interface was inspired by memxor
+/* Written by Simon Josefsson.  The interface was inspired by MHD_memxor
    in Niels Möller's Nettle. */
 
 #include "MHD_config.h"
@@ -23,7 +23,7 @@
 #include "memxor.h"
 
 void *
-memxor (void *restrict dest, const void *restrict src, size_t n)
+MHD_memxor (void *restrict dest, const void *restrict src, size_t n)
 {
   char const *s = src;
   char *d = dest;

+ 3 - 3
src/daemon/https/lgl/memxor.h

@@ -1,4 +1,4 @@
-/* memxor.h -- perform binary exclusive OR operation on memory blocks.
+/* MHD_memxor.h -- perform binary exclusive OR operation on memory blocks.
    Copyright (C) 2005 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -15,7 +15,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-/* Written by Simon Josefsson.  The interface was inspired by memxor
+/* Written by Simon Josefsson.  The interface was inspired by MHD_memxor
    in Niels Möller's Nettle. */
 
 #ifndef MEMXOR_H
@@ -26,6 +26,6 @@
 /* Compute binary exclusive OR of memory areas DEST and SRC, putting
    the result in DEST, of length N bytes.  Returns a pointer to
    DEST. */
-void *memxor (void *restrict dest, const void *restrict src, size_t n);
+void *MHD_memxor (void *restrict dest, const void *restrict src, size_t n);
 
 #endif /* MEMXOR_H */

+ 23 - 23
src/daemon/https/lgl/sha1.c

@@ -53,9 +53,9 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */  };
 
 /* Take a pointer to a 160 bit block of data (five 32 bit ints) and
    initialize it to the start constants of the SHA1 algorithm.  This
-   must be called before using hash in the call to sha1_hash.  */
+   must be called before using hash in the call to MHD_sha1_hash.  */
 void
-sha1_init_ctx (struct sha1_ctx *ctx)
+MHD_sha1_init_ctx (struct MHD_sha1_ctx *ctx)
 {
   ctx->A = 0x67452301;
   ctx->B = 0xefcdab89;
@@ -73,7 +73,7 @@ sha1_init_ctx (struct sha1_ctx *ctx)
    IMPORTANT: On some systems it is required that RESBUF is correctly
    aligned for a 32-bit value.  */
 void *
-sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
+MHD_sha1_read_ctx (const struct MHD_sha1_ctx *ctx, void *resbuf)
 {
   ((uint32_t *) resbuf)[0] = SWAP (ctx->A);
   ((uint32_t *) resbuf)[1] = SWAP (ctx->B);
@@ -90,7 +90,7 @@ sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
    IMPORTANT: On some systems it is required that RESBUF is correctly
    aligned for a 32-bit value.  */
 void *
-sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
+MHD_sha1_finish_ctx (struct MHD_sha1_ctx *ctx, void *resbuf)
 {
   /* Take yet unprocessed bytes into account.  */
   uint32_t bytes = ctx->buflen;
@@ -108,23 +108,23 @@ sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
   memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
 
   /* Process last bytes.  */
-  sha1_process_block (ctx->buffer, size * 4, ctx);
+  MHD_sha1_process_block (ctx->buffer, size * 4, ctx);
 
-  return sha1_read_ctx (ctx, resbuf);
+  return MHD_sha1_read_ctx (ctx, resbuf);
 }
 
 /* Compute SHA1 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
 int
-sha1_stream (FILE * stream, void *resblock)
+MHD_sha1_stream (FILE * stream, void *resblock)
 {
-  struct sha1_ctx ctx;
+  struct MHD_sha1_ctx ctx;
   char buffer[BLOCKSIZE + 72];
   size_t sum;
 
   /* Initialize the computation context.  */
-  sha1_init_ctx (&ctx);
+  MHD_sha1_init_ctx (&ctx);
 
   /* Iterate over full file contents.  */
   while (1)
@@ -165,17 +165,17 @@ sha1_stream (FILE * stream, void *resblock)
       /* Process buffer with BLOCKSIZE bytes.  Note that
          BLOCKSIZE % 64 == 0
        */
-      sha1_process_block (buffer, BLOCKSIZE, &ctx);
+      MHD_sha1_process_block (buffer, BLOCKSIZE, &ctx);
     }
 
 process_partial_block:;
 
   /* Process any remaining bytes.  */
   if (sum > 0)
-    sha1_process_bytes (buffer, sum, &ctx);
+    MHD_sha1_process_bytes (buffer, sum, &ctx);
 
   /* Construct result in desired memory.  */
-  sha1_finish_ctx (&ctx, resblock);
+  MHD_sha1_finish_ctx (&ctx, resblock);
   return 0;
 }
 
@@ -184,22 +184,22 @@ process_partial_block:;
    output yields to the wanted ASCII representation of the message
    digest.  */
 void *
-sha1_buffer (const char *buffer, size_t len, void *resblock)
+MHD_sha1_buffer (const char *buffer, size_t len, void *resblock)
 {
-  struct sha1_ctx ctx;
+  struct MHD_sha1_ctx ctx;
 
   /* Initialize the computation context.  */
-  sha1_init_ctx (&ctx);
+  MHD_sha1_init_ctx (&ctx);
 
   /* Process whole buffer but last len % 64 bytes.  */
-  sha1_process_bytes (buffer, len, &ctx);
+  MHD_sha1_process_bytes (buffer, len, &ctx);
 
   /* Put result in desired memory area.  */
-  return sha1_finish_ctx (&ctx, resblock);
+  return MHD_sha1_finish_ctx (&ctx, resblock);
 }
 
 void
-sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
+MHD_sha1_process_bytes (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx)
 {
   /* When we already have some bits in our internal buffer concatenate
      both inputs first.  */
@@ -213,7 +213,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
 
       if (ctx->buflen > 64)
         {
-          sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
+          MHD_sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
 
           ctx->buflen &= 63;
           /* 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)
       if (UNALIGNED_P (buffer))
         while (len > 64)
           {
-            sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
+            MHD_sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
             buffer = (const char *) buffer + 64;
             len -= 64;
           }
       else
 #endif
         {
-          sha1_process_block (buffer, len & ~63, ctx);
+          MHD_sha1_process_block (buffer, len & ~63, ctx);
           buffer = (const char *) buffer + (len & ~63);
           len &= 63;
         }
@@ -257,7 +257,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
       left_over += len;
       if (left_over >= 64)
         {
-          sha1_process_block (ctx->buffer, 64, ctx);
+          MHD_sha1_process_block (ctx->buffer, 64, ctx);
           left_over -= 64;
           memcpy (ctx->buffer, &ctx->buffer[16], left_over);
         }
@@ -284,7 +284,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
    Most of this code comes from GnuPG's cipher/sha1.c.  */
 
 void
-sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
+MHD_sha1_process_block (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx)
 {
   const uint32_t *words = buffer;
   size_t nwords = len / sizeof (uint32_t);

+ 10 - 10
src/daemon/https/lgl/sha1.h

@@ -23,7 +23,7 @@
 # include <stdint.h>
 
 /* Structure to save state of computation between the single steps.  */
-struct sha1_ctx
+struct MHD_sha1_ctx
 {
   uint32_t A;
   uint32_t B;
@@ -38,21 +38,21 @@ struct sha1_ctx
 
 
 /* Initialize structure containing state of computation. */
-extern void sha1_init_ctx (struct sha1_ctx *ctx);
+extern void MHD_sha1_init_ctx (struct MHD_sha1_ctx *ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is necessary that LEN is a multiple of 64!!! */
-extern void sha1_process_block (const void *buffer, size_t len,
-                                struct sha1_ctx *ctx);
+extern void MHD_sha1_process_block (const void *buffer, size_t len,
+                                struct MHD_sha1_ctx *ctx);
 
 /* Starting with the result of former calls of this function (or the
    initialization function update the context for the next LEN bytes
    starting at BUFFER.
    It is NOT required that LEN is a multiple of 64.  */
-extern void sha1_process_bytes (const void *buffer, size_t len,
-                                struct sha1_ctx *ctx);
+extern void MHD_sha1_process_bytes (const void *buffer, size_t len,
+                                struct MHD_sha1_ctx *ctx);
 
 /* Process the remaining bytes in the buffer and put result from CTX
    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,
 
    IMPORTANT: On some systems it is required that RESBUF be correctly
    aligned for a 32 bits value.  */
-extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
+extern void *MHD_sha1_finish_ctx (struct MHD_sha1_ctx *ctx, void *resbuf);
 
 
 /* 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);
 
    IMPORTANT: On some systems it is required that RESBUF is correctly
    aligned for a 32 bits value.  */
-extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
+extern void *MHD_sha1_read_ctx (const struct MHD_sha1_ctx *ctx, void *resbuf);
 
 
 /* Compute SHA1 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 20 bytes
    beginning at RESBLOCK.  */
-extern int sha1_stream (FILE * stream, void *resblock);
+extern int MHD_sha1_stream (FILE * stream, void *resblock);
 
 /* Compute SHA1 message digest for LEN bytes beginning at BUFFER.  The
    result is always in little endian byte order, so that a byte-wise
    output yields to the wanted ASCII representation of the message
    digest.  */
-extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
+extern void *MHD_sha1_buffer (const char *buffer, size_t len, void *resblock);
 
 #endif

+ 0 - 46
src/daemon/https/lgl/time_r.c

@@ -1,46 +0,0 @@
-/* Reentrant time functions like localtime_r.
-
- Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License along
- with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-/* Written by Paul Eggert.  */
-
-#include "MHD_config.h"
-
-#include <time.h>
-
-#include <string.h>
-
-static struct tm *
-copy_tm_result (struct tm *dest, struct tm const *src)
-{
-  if (!src)
-    return 0;
-  *dest = *src;
-  return dest;
-}
-
-struct tm *
-gmtime_r (time_t const *restrict t, struct tm *restrict tp)
-{
-  return copy_tm_result (tp, gmtime (t));
-}
-
-struct tm *
-localtime_r (time_t const *restrict t, struct tm *restrict tp)
-{
-  return copy_tm_result (tp, localtime (t));
-}

+ 103 - 103
src/daemon/https/minitasn1/coding.c

@@ -37,7 +37,7 @@
 #define MAX_TAG_LEN 16
 
 /******************************************************/
-/* Function : _asn1_error_description_value_not_found */
+/* Function : MHD__asn1_error_description_value_not_found */
 /* Description: creates the ErrorDescription string   */
 /* for the ASN1_VALUE_NOT_FOUND error.                */
 /* Parameters:                                        */
@@ -46,7 +46,7 @@
 /* Return:                                            */
 /******************************************************/
 void
-_asn1_error_description_value_not_found (node_asn * node,
+MHD__asn1_error_description_value_not_found (node_asn * node,
                                          char *ErrorDescription)
 {
 
@@ -54,14 +54,14 @@ _asn1_error_description_value_not_found (node_asn * node,
     return;
 
   Estrcpy (ErrorDescription, ":: value of element '");
-  _asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
+  MHD__asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
                            MAX_ERROR_DESCRIPTION_SIZE - 40);
   Estrcat (ErrorDescription, "' not found");
 
 }
 
 /**
- * asn1_length_der:
+ * MHD__asn1_length_der:
  * @len: value to convert.
  * @ans: string returned.
  * @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,
  * The @ans buffer is pre-allocated and must have room for the output.
  **/
 void
-asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
+MHD__asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
 {
   int k;
   unsigned char temp[SIZEOF_UNSIGNED_LONG_INT];
@@ -102,7 +102,7 @@ asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
 }
 
 /******************************************************/
-/* Function : _asn1_tag_der                           */
+/* Function : MHD__asn1_tag_der                           */
 /* Description: creates the DER coding for the CLASS  */
 /* and TAG parameters.                                */
 /* Parameters:                                        */
@@ -114,7 +114,7 @@ asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)
 /* Return:                                            */
 /******************************************************/
 void
-_asn1_tag_der (unsigned char class, unsigned int tag_value,
+MHD__asn1_tag_der (unsigned char class, unsigned int tag_value,
                unsigned char *ans, int *ans_len)
 {
   int k;
@@ -144,7 +144,7 @@ _asn1_tag_der (unsigned char class, unsigned int tag_value,
 }
 
 /**
- * asn1_octet_der:
+ * MHD__asn1_octet_der:
  * @str: OCTET string.
  * @str_len: STR length (str[0]..str[str_len-1]).
  * @der: string returned.
@@ -153,20 +153,20 @@ _asn1_tag_der (unsigned char class, unsigned int tag_value,
  * Creates the DER coding for an OCTET type (length included).
  **/
 void
-asn1_octet_der (const unsigned char *str, int str_len,
+MHD__asn1_octet_der (const unsigned char *str, int str_len,
                 unsigned char *der, int *der_len)
 {
   int len_len;
 
   if (der == NULL || str_len < 0)
     return;
-  asn1_length_der (str_len, der, &len_len);
+  MHD__asn1_length_der (str_len, der, &len_len);
   memcpy (der + len_len, str, str_len);
   *der_len = str_len + len_len;
 }
 
 /******************************************************/
-/* Function : _asn1_time_der                          */
+/* Function : MHD__asn1_time_der                          */
 /* Description: creates the DER coding for a TIME     */
 /* type (length included).                            */
 /* Parameters:                                        */
@@ -179,15 +179,15 @@ asn1_octet_der (const unsigned char *str, int str_len,
 /*   ASN1_MEM_ERROR when DER isn't big enough         */
 /*   ASN1_SUCCESS otherwise                           */
 /******************************************************/
-asn1_retCode
-_asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
+MHD__asn1_retCode
+MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
 {
   int len_len;
   int max_len;
 
   max_len = *der_len;
 
-  asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len);
+  MHD__asn1_length_der (strlen (str), (max_len > 0) ? der : NULL, &len_len);
 
   if ((len_len + (int) strlen (str)) <= max_len)
     memcpy (der + len_len, str, strlen (str));
@@ -202,13 +202,13 @@ _asn1_time_der (unsigned char *str, unsigned char *der, int *der_len)
 
 /*
 void
-_asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
+MHD__asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
 {
   int len_len,str_len;
   char temp[20];
 
   if(str==NULL) return;
-  str_len=asn1_get_length_der(der,*der_len,&len_len);
+  str_len=MHD__asn1_get_length_der(der,*der_len,&len_len);
   if (str_len<0) return;
   memcpy(temp,der+len_len,str_len);
   *der_len=str_len+len_len;
@@ -237,7 +237,7 @@ _asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
 */
 
 /******************************************************/
-/* Function : _asn1_objectid_der                      */
+/* Function : MHD__asn1_objectid_der                      */
 /* Description: creates the DER coding for an         */
 /* OBJECT IDENTIFIER  type (length included).         */
 /* Parameters:                                        */
@@ -250,8 +250,8 @@ _asn1_get_utctime_der(unsigned char *der,int *der_len,unsigned char *str)
 /*   ASN1_MEM_ERROR when DER isn't big enough         */
 /*   ASN1_SUCCESS otherwise                           */
 /******************************************************/
-asn1_retCode
-_asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
+MHD__asn1_retCode
+MHD__asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
 {
   int len_len, counter, k, first, max_len;
   char *temp, *n_end, *n_start;
@@ -260,7 +260,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
 
   max_len = *der_len;
 
-  temp = (char *) _asn1_alloca (strlen (str) + 2);
+  temp = (char *) MHD__asn1_alloca (strlen (str) + 2);
   if (temp == NULL)
     return ASN1_MEM_ALLOC_ERROR;
 
@@ -304,15 +304,15 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
       n_start = n_end + 1;
     }
 
-  asn1_length_der (*der_len, NULL, &len_len);
+  MHD__asn1_length_der (*der_len, NULL, &len_len);
   if (max_len >= (*der_len + len_len))
     {
       memmove (der + len_len, der, *der_len);
-      asn1_length_der (*der_len, der, &len_len);
+      MHD__asn1_length_der (*der_len, der, &len_len);
     }
   *der_len += len_len;
 
-  _asn1_afree (temp);
+  MHD__asn1_afree (temp);
 
   if (max_len < (*der_len))
     return ASN1_MEM_ERROR;
@@ -324,7 +324,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
 const char bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 };
 
 /**
- * asn1_bit_der:
+ * MHD__asn1_bit_der:
  * @str: BIT string.
  * @bit_len: number of meaningful bits in STR.
  * @der: string returned.
@@ -335,7 +335,7 @@ const char bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 };
  * included).
  **/
 void
-asn1_bit_der (const unsigned char *str, int bit_len,
+MHD__asn1_bit_der (const unsigned char *str, int bit_len,
               unsigned char *der, int *der_len)
 {
   int len_len, len_byte, len_pad;
@@ -348,7 +348,7 @@ asn1_bit_der (const unsigned char *str, int bit_len,
     len_pad = 0;
   else
     len_byte++;
-  asn1_length_der (len_byte + 1, der, &len_len);
+  MHD__asn1_length_der (len_byte + 1, der, &len_len);
   der[len_len] = len_pad;
   memcpy (der + len_len + 1, str, len_byte);
   der[len_len + len_byte] &= bit_mask[len_pad];
@@ -357,7 +357,7 @@ asn1_bit_der (const unsigned char *str, int bit_len,
 
 
 /******************************************************/
-/* Function : _asn1_complete_explicit_tag             */
+/* Function : MHD__asn1_complete_explicit_tag             */
 /* Description: add the length coding to the EXPLICIT */
 /* tags.                                              */
 /* Parameters:                                        */
@@ -370,8 +370,8 @@ asn1_bit_der (const unsigned char *str, int bit_len,
 /*   ASN1_MEM_ERROR if der vector isn't big enough,   */
 /*   otherwise ASN1_SUCCESS.                          */
 /******************************************************/
-asn1_retCode
-_asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
+MHD__asn1_retCode
+MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
                              int *counter, int *max_len)
 {
   node_asn *p;
@@ -397,8 +397,8 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
               if (p->type & CONST_EXPLICIT)
                 {
                   len2 = strtol (p->name, NULL, 10);
-                  _asn1_set_name (p, NULL);
-                  asn1_length_der (*counter - len2, temp, &len3);
+                  MHD__asn1_set_name (p, NULL);
+                  MHD__asn1_length_der (*counter - len2, temp, &len3);
                   if (len3 <= (*max_len))
                     {
                       memmove (der + len2 + len3, der + len2,
@@ -429,7 +429,7 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
 
 
 /******************************************************/
-/* Function : _asn1_insert_tag_der                    */
+/* Function : MHD__asn1_insert_tag_der                    */
 /* Description: creates the DER coding of tags of one */
 /* NODE.                                              */
 /* Parameters:                                        */
@@ -443,8 +443,8 @@ _asn1_complete_explicit_tag (node_asn * node, unsigned char *der,
 /*   ASN1_MEM_ERROR if der vector isn't big enough,   */
 /*   otherwise ASN1_SUCCESS.                          */
 /******************************************************/
-asn1_retCode
-_asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
+MHD__asn1_retCode
+MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
                       int *max_len)
 {
   node_asn *p;
@@ -474,10 +474,10 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
               if (p->type & CONST_EXPLICIT)
                 {
                   if (is_tag_implicit)
-                    _asn1_tag_der (class_implicit, tag_implicit, tag_der,
+                    MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der,
                                    &tag_len);
                   else
-                    _asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
+                    MHD__asn1_tag_der (class | ASN1_CLASS_STRUCTURED,
                                    strtoul (p->value, NULL, 10), tag_der,
                                    &tag_len);
 
@@ -486,8 +486,8 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
                     memcpy (der + *counter, tag_der, tag_len);
                   *counter += tag_len;
 
-                  _asn1_ltostr (*counter, temp);
-                  _asn1_set_name (p, temp);
+                  MHD__asn1_ltostr (*counter, temp);
+                  MHD__asn1_set_name (p, temp);
 
                   is_tag_implicit = 0;
                 }
@@ -512,62 +512,62 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
 
   if (is_tag_implicit)
     {
-      _asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len);
+      MHD__asn1_tag_der (class_implicit, tag_implicit, tag_der, &tag_len);
     }
   else
     {
       switch (type_field (node->type))
         {
         case TYPE_NULL:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, tag_der,
                          &tag_len);
           break;
         case TYPE_BOOLEAN:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, tag_der,
                          &tag_len);
           break;
         case TYPE_INTEGER:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, tag_der,
                          &tag_len);
           break;
         case TYPE_ENUMERATED:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, tag_der,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, tag_der,
                          &tag_len);
           break;
         case TYPE_OBJECT_ID:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, tag_der,
                          &tag_len);
           break;
         case TYPE_TIME:
           if (node->type & CONST_UTC)
             {
-              _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, tag_der,
+              MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, tag_der,
                              &tag_len);
             }
           else
-            _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime,
+            MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime,
                            tag_der, &tag_len);
           break;
         case TYPE_OCTET_STRING:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, tag_der,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, tag_der,
                          &tag_len);
           break;
         case TYPE_GENERALSTRING:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING,
                          tag_der, &tag_len);
           break;
         case TYPE_BIT_STRING:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, tag_der,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, tag_der,
                          &tag_len);
           break;
         case TYPE_SEQUENCE:
         case TYPE_SEQUENCE_OF:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
                          ASN1_TAG_SEQUENCE, tag_der, &tag_len);
           break;
         case TYPE_SET:
         case TYPE_SET_OF:
-          _asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
+          MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED,
                          ASN1_TAG_SET, tag_der, &tag_len);
           break;
         case TYPE_TAG:
@@ -596,7 +596,7 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
 }
 
 /******************************************************/
-/* Function : _asn1_ordering_set                      */
+/* Function : MHD__asn1_ordering_set                      */
 /* Description: puts the elements of a SET type in    */
 /* the correct order according to DER rules.          */
 /* Parameters:                                        */
@@ -605,7 +605,7 @@ _asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter,
 /* Return:                                            */
 /******************************************************/
 void
-_asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
+MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
 {
   struct vet
   {
@@ -637,7 +637,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
   first = last = NULL;
   while (p)
     {
-      p_vet = (struct vet *) _asn1_alloca (sizeof (struct vet));
+      p_vet = (struct vet *) MHD__asn1_alloca (sizeof (struct vet));
       if (p_vet == NULL)
         return;
 
@@ -650,7 +650,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
       last = p_vet;
 
       /* tag value calculation */
-      if (asn1_get_tag_der
+      if (MHD__asn1_get_tag_der
           (der + counter, der_len - counter, &class, &len2,
            &tag) != ASN1_SUCCESS)
         return;
@@ -658,7 +658,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
       counter += len2;
 
       /* extraction and length */
-      len2 = asn1_get_length_der (der + counter, der_len - counter, &len);
+      len2 = MHD__asn1_get_length_der (der + counter, der_len - counter, &len);
       if (len2 < 0)
         return;
       counter += len + len2;
@@ -678,7 +678,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
           if (p_vet->value > p2_vet->value)
             {
               /* change position */
-              temp = (unsigned char *) _asn1_alloca (p_vet->end - counter);
+              temp = (unsigned char *) MHD__asn1_alloca (p_vet->end - counter);
               if (temp == NULL)
                 return;
 
@@ -687,7 +687,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
                       p2_vet->end - p_vet->end);
               memcpy (der + counter + p2_vet->end - p_vet->end, temp,
                       p_vet->end - counter);
-              _asn1_afree (temp);
+              MHD__asn1_afree (temp);
 
               tag = p_vet->value;
               p_vet->value = p2_vet->value;
@@ -705,13 +705,13 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
         p_vet->prev->next = NULL;
       else
         first = NULL;
-      _asn1_afree (p_vet);
+      MHD__asn1_afree (p_vet);
       p_vet = first;
     }
 }
 
 /******************************************************/
-/* Function : _asn1_ordering_set_of                   */
+/* Function : MHD__asn1_ordering_set_of                   */
 /* Description: puts the elements of a SET OF type in */
 /* the correct order according to DER rules.          */
 /* Parameters:                                        */
@@ -720,7 +720,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node)
 /* Return:                                            */
 /******************************************************/
 void
-_asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
+MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
 {
   struct vet
   {
@@ -751,7 +751,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
   first = last = NULL;
   while (p)
     {
-      p_vet = (struct vet *) _asn1_alloca (sizeof (struct vet));
+      p_vet = (struct vet *) MHD__asn1_alloca (sizeof (struct vet));
       if (p_vet == NULL)
         return;
 
@@ -767,13 +767,13 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
       if (der_len - counter > 0)
         {
 
-          if (asn1_get_tag_der
+          if (MHD__asn1_get_tag_der
               (der + counter, der_len - counter, &class, &len,
                NULL) != ASN1_SUCCESS)
             return;
           counter += len;
 
-          len2 = asn1_get_length_der (der + counter, der_len - counter, &len);
+          len2 = MHD__asn1_get_length_der (der + counter, der_len - counter, &len);
           if (len2 < 0)
             return;
           counter += len + len2;
@@ -816,7 +816,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
           if (change == 1)
             {
               /* change position */
-              temp = (unsigned char *) _asn1_alloca (p_vet->end - counter);
+              temp = (unsigned char *) MHD__asn1_alloca (p_vet->end - counter);
               if (temp == NULL)
                 return;
 
@@ -825,7 +825,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
                       (p2_vet->end) - (p_vet->end));
               memcpy (der + counter + (p2_vet->end) - (p_vet->end), temp,
                       (p_vet->end) - counter);
-              _asn1_afree (temp);
+              MHD__asn1_afree (temp);
 
               p_vet->end = counter + (p2_vet->end - p_vet->end);
             }
@@ -839,13 +839,13 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
         p_vet->prev->next = NULL;
       else
         first = NULL;
-      _asn1_afree (p_vet);
+      MHD__asn1_afree (p_vet);
       p_vet = first;
     }
 }
 
 /**
-  * asn1_der_coding - Creates the DER encoding for the NAME structure
+  * MHD__asn1_der_coding - Creates the DER encoding for the NAME structure
   * @element: pointer to an ASN1 element
   * @name: the name of the structure you want to encode (it must be
   *   inside *POINTER).
@@ -871,17 +871,17 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node)
   *     LEN will contain the length needed.
   *
   **/
-asn1_retCode
-asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
+MHD__asn1_retCode
+MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
                  char *ErrorDescription)
 {
   node_asn *node, *p, *p2;
   char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1];
   int counter, counter_old, len2, len3, tlen, move, max_len, max_len_old;
-  asn1_retCode err;
+  MHD__asn1_retCode err;
   unsigned char *der = ider;
 
-  node = asn1_find_node (element, name);
+  node = MHD__asn1_find_node (element, name);
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
 
@@ -889,7 +889,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
    * That is because in some point we modify the
    * structure, and I don't know why! --nmav
    */
-  node = _asn1_copy_structure3 (node);
+  node = MHD__asn1_copy_structure3 (node);
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
 
@@ -905,7 +905,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
       max_len_old = max_len;
       if (move != UP)
         {
-          err = _asn1_insert_tag_der (p, der, &counter, &max_len);
+          err = MHD__asn1_insert_tag_der (p, der, &counter, &max_len);
           if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
             goto error;
         }
@@ -928,7 +928,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
             {
               if (p->value == NULL)
                 {
-                  _asn1_error_description_value_not_found (p,
+                  MHD__asn1_error_description_value_not_found (p,
                                                            ErrorDescription);
                   err = ASN1_VALUE_NOT_FOUND;
                   goto error;
@@ -958,12 +958,12 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
             {
               if (p->value == NULL)
                 {
-                  _asn1_error_description_value_not_found (p,
+                  MHD__asn1_error_description_value_not_found (p,
                                                            ErrorDescription);
                   err = ASN1_VALUE_NOT_FOUND;
                   goto error;
                 }
-              len2 = asn1_get_length_der (p->value, p->value_len, &len3);
+              len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
               if (len2 < 0)
                 {
                   err = ASN1_DER_ERROR;
@@ -986,13 +986,13 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
             {
               if (p->value == NULL)
                 {
-                  _asn1_error_description_value_not_found (p,
+                  MHD__asn1_error_description_value_not_found (p,
                                                            ErrorDescription);
                   err = ASN1_VALUE_NOT_FOUND;
                   goto error;
                 }
               len2 = max_len;
-              err = _asn1_objectid_der (p->value, der + counter, &len2);
+              err = MHD__asn1_objectid_der (p->value, der + counter, &len2);
               if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
                 goto error;
 
@@ -1004,12 +1004,12 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
         case TYPE_TIME:
           if (p->value == NULL)
             {
-              _asn1_error_description_value_not_found (p, ErrorDescription);
+              MHD__asn1_error_description_value_not_found (p, ErrorDescription);
               err = ASN1_VALUE_NOT_FOUND;
               goto error;
             }
           len2 = max_len;
-          err = _asn1_time_der (p->value, der + counter, &len2);
+          err = MHD__asn1_time_der (p->value, der + counter, &len2);
           if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
             goto error;
 
@@ -1020,11 +1020,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
         case TYPE_OCTET_STRING:
           if (p->value == NULL)
             {
-              _asn1_error_description_value_not_found (p, ErrorDescription);
+              MHD__asn1_error_description_value_not_found (p, ErrorDescription);
               err = ASN1_VALUE_NOT_FOUND;
               goto error;
             }
-          len2 = asn1_get_length_der (p->value, p->value_len, &len3);
+          len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
           if (len2 < 0)
             {
               err = ASN1_DER_ERROR;
@@ -1039,11 +1039,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
         case TYPE_GENERALSTRING:
           if (p->value == NULL)
             {
-              _asn1_error_description_value_not_found (p, ErrorDescription);
+              MHD__asn1_error_description_value_not_found (p, ErrorDescription);
               err = ASN1_VALUE_NOT_FOUND;
               goto error;
             }
-          len2 = asn1_get_length_der (p->value, p->value_len, &len3);
+          len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
           if (len2 < 0)
             {
               err = ASN1_DER_ERROR;
@@ -1058,11 +1058,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
         case TYPE_BIT_STRING:
           if (p->value == NULL)
             {
-              _asn1_error_description_value_not_found (p, ErrorDescription);
+              MHD__asn1_error_description_value_not_found (p, ErrorDescription);
               err = ASN1_VALUE_NOT_FOUND;
               goto error;
             }
-          len2 = asn1_get_length_der (p->value, p->value_len, &len3);
+          len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
           if (len2 < 0)
             {
               err = ASN1_DER_ERROR;
@@ -1078,10 +1078,10 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
         case TYPE_SET:
           if (move != UP)
             {
-              _asn1_ltostr (counter, temp);
+              MHD__asn1_ltostr (counter, temp);
               tlen = strlen (temp);
               if (tlen > 0)
-                _asn1_set_value (p, temp, tlen + 1);
+                MHD__asn1_set_value (p, temp, tlen + 1);
               if (p->down == NULL)
                 {
                   move = UP;
@@ -1105,10 +1105,10 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
           else
             {                   /* move==UP */
               len2 = strtol (p->value, NULL, 10);
-              _asn1_set_value (p, NULL, 0);
+              MHD__asn1_set_value (p, NULL, 0);
               if ((type_field (p->type) == TYPE_SET) && (max_len >= 0))
-                _asn1_ordering_set (der + len2, max_len - len2, p);
-              asn1_length_der (counter - len2, temp, &len3);
+                MHD__asn1_ordering_set (der + len2, max_len - len2, p);
+              MHD__asn1_length_der (counter - len2, temp, &len3);
               max_len -= len3;
               if (max_len >= 0)
                 {
@@ -1123,11 +1123,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
         case TYPE_SET_OF:
           if (move != UP)
             {
-              _asn1_ltostr (counter, temp);
+              MHD__asn1_ltostr (counter, temp);
               tlen = strlen (temp);
 
               if (tlen > 0)
-                _asn1_set_value (p, temp, tlen + 1);
+                MHD__asn1_set_value (p, temp, tlen + 1);
               p = p->down;
               while ((type_field (p->type) == TYPE_TAG)
                      || (type_field (p->type) == TYPE_SIZE))
@@ -1139,19 +1139,19 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
                   continue;
                 }
               else
-                p = _asn1_find_up (p);
+                p = MHD__asn1_find_up (p);
               move = UP;
             }
           if (move == UP)
             {
               len2 = strtol (p->value, NULL, 10);
-              _asn1_set_value (p, NULL, 0);
+              MHD__asn1_set_value (p, NULL, 0);
               if ((type_field (p->type) == TYPE_SET_OF)
                   && (max_len - len2 > 0))
                 {
-                  _asn1_ordering_set_of (der + len2, max_len - len2, p);
+                  MHD__asn1_ordering_set_of (der + len2, max_len - len2, p);
                 }
-              asn1_length_der (counter - len2, temp, &len3);
+              MHD__asn1_length_der (counter - len2, temp, &len3);
               max_len -= len3;
               if (max_len >= 0)
                 {
@@ -1165,11 +1165,11 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
         case TYPE_ANY:
           if (p->value == NULL)
             {
-              _asn1_error_description_value_not_found (p, ErrorDescription);
+              MHD__asn1_error_description_value_not_found (p, ErrorDescription);
               err = ASN1_VALUE_NOT_FOUND;
               goto error;
             }
-          len2 = asn1_get_length_der (p->value, p->value_len, &len3);
+          len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
           if (len2 < 0)
             {
               err = ASN1_DER_ERROR;
@@ -1188,7 +1188,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
 
       if ((move != DOWN) && (counter != counter_old))
         {
-          err = _asn1_complete_explicit_tag (p, der, &counter, &max_len);
+          err = MHD__asn1_complete_explicit_tag (p, der, &counter, &max_len);
           if (err != ASN1_SUCCESS && err != ASN1_MEM_ERROR)
             goto error;
         }
@@ -1211,7 +1211,7 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
             move = UP;
         }
       if (move == UP)
-        p = _asn1_find_up (p);
+        p = MHD__asn1_find_up (p);
     }
 
   *len = counter;
@@ -1225,6 +1225,6 @@ asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len,
   err = ASN1_SUCCESS;
 
 error:
-  asn1_delete_structure (&node);
+  MHD__asn1_delete_structure (&node);
   return err;
 }

Plik diff jest za duży
+ 142 - 142
src/daemon/https/minitasn1/decoding.c


+ 99 - 99
src/daemon/https/minitasn1/element.c

@@ -34,7 +34,7 @@
 #include "structure.h"
 
 void
-_asn1_hierarchical_name (node_asn * node, char *name, int name_size)
+MHD__asn1_hierarchical_name (node_asn * node, char *name, int name_size)
 {
   node_asn *p;
   char tmp_name[64];
@@ -47,21 +47,21 @@ _asn1_hierarchical_name (node_asn * node, char *name, int name_size)
     {
       if (p->name != NULL)
         {
-          _asn1_str_cpy (tmp_name, sizeof (tmp_name), name),
-            _asn1_str_cpy (name, name_size, p->name);
-          _asn1_str_cat (name, name_size, ".");
-          _asn1_str_cat (name, name_size, tmp_name);
+          MHD__asn1_str_cpy (tmp_name, sizeof (tmp_name), name),
+            MHD__asn1_str_cpy (name, name_size, p->name);
+          MHD__asn1_str_cat (name, name_size, ".");
+          MHD__asn1_str_cat (name, name_size, tmp_name);
         }
-      p = _asn1_find_up (p);
+      p = MHD__asn1_find_up (p);
     }
 
   if (name[0] == 0)
-    _asn1_str_cpy (name, name_size, "ROOT");
+    MHD__asn1_str_cpy (name, name_size, "ROOT");
 }
 
 
 /******************************************************************/
-/* Function : _asn1_convert_integer                               */
+/* Function : MHD__asn1_convert_integer                               */
 /* Description: converts an integer from a null terminated string */
 /*              to der decoding. The convertion from a null       */
 /*              terminated string to an integer is made with      */
@@ -74,8 +74,8 @@ _asn1_hierarchical_name (node_asn * node, char *name, int name_size)
 /*   len: number of significant byte of value_out.                */
 /* Return: ASN1_MEM_ERROR or ASN1_SUCCESS                         */
 /******************************************************************/
-asn1_retCode
-_asn1_convert_integer (const char *value, unsigned char *value_out,
+MHD__asn1_retCode
+MHD__asn1_convert_integer (const char *value, unsigned char *value_out,
                        int value_out_size, int *len)
 {
   char negative;
@@ -117,10 +117,10 @@ _asn1_convert_integer (const char *value, unsigned char *value_out,
 
 
 #ifdef LIBTASN1_DEBUG_INTEGER
-  _libtasn1_log ("_asn1_convert_integer: valueIn=%s, lenOut=%d", value, *len);
+  MHD__libtasn1_log ("MHD__asn1_convert_integer: valueIn=%s, lenOut=%d", value, *len);
   for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++)
-    _libtasn1_log (", vOut[%d]=%d", k, value_out[k]);
-  _libtasn1_log ("\n");
+    MHD__libtasn1_log (", vOut[%d]=%d", k, value_out[k]);
+  MHD__libtasn1_log ("\n");
 #endif
 
 
@@ -129,7 +129,7 @@ _asn1_convert_integer (const char *value, unsigned char *value_out,
 
 
 int
-_asn1_append_sequence_set (node_asn * node)
+MHD__asn1_append_sequence_set (node_asn * node)
 {
   node_asn *p, *p2;
   char temp[10];
@@ -142,21 +142,21 @@ _asn1_append_sequence_set (node_asn * node)
   while ((type_field (p->type) == TYPE_TAG)
          || (type_field (p->type) == TYPE_SIZE))
     p = p->right;
-  p2 = _asn1_copy_structure3 (p);
+  p2 = MHD__asn1_copy_structure3 (p);
   while (p->right)
     p = p->right;
-  _asn1_set_right (p, p2);
+  MHD__asn1_set_right (p, p2);
 
   if (p->name == NULL)
-    _asn1_str_cpy (temp, sizeof (temp), "?1");
+    MHD__asn1_str_cpy (temp, sizeof (temp), "?1");
   else
     {
       n = strtol (p->name + 1, NULL, 0);
       n++;
       temp[0] = '?';
-      _asn1_ltostr (n, temp + 1);
+      MHD__asn1_ltostr (n, temp + 1);
     }
-  _asn1_set_name (p2, temp);
+  MHD__asn1_set_name (p2, temp);
   /*  p2->type |= CONST_OPTION; */
 
   return ASN1_SUCCESS;
@@ -164,7 +164,7 @@ _asn1_append_sequence_set (node_asn * node)
 
 
 /**
-  * asn1_write_value - Set the value of one element inside a structure.
+  * MHD__asn1_write_value - Set the value of one element inside a structure.
   * @node_root: pointer to a structure
   * @name: the name of the element inside the structure that you want to set.
   * @ivalue: vector used to specify the value to set. If len is >0,
@@ -178,7 +178,7 @@ _asn1_append_sequence_set (node_asn * node)
   * If an element is OPTIONAL and you want to delete it, you must use
   * the value=NULL and len=0.  Using "pkix.asn":
   *
-  * result=asn1_write_value(cert, "tbsCertificate.issuerUniqueID",
+  * result=MHD__asn1_write_value(cert, "tbsCertificate.issuerUniqueID",
   * NULL, 0);
   *
   * Description for each type:
@@ -244,7 +244,7 @@ _asn1_append_sequence_set (node_asn * node)
   *   the alternatives with a null terminated string. LEN != 0. Using
   *   "pkix.asn"\:
   *
-  *           result=asn1_write_value(cert,
+  *           result=MHD__asn1_write_value(cert,
   *           "certificate1.tbsCertificate.subject", "rdnSequence",
   *           1);
   *
@@ -257,12 +257,12 @@ _asn1_append_sequence_set (node_asn * node)
   *
   *   Using "pkix.asn"\:
   *
-  *   result=asn1_write_value(cert,
+  *   result=MHD__asn1_write_value(cert,
   *   "certificate1.tbsCertificate.subject.rdnSequence", "NEW", 1);
   *
   * SET OF: the same as SEQUENCE OF.  Using "pkix.asn":
   *
-  *           result=asn1_write_value(cert,
+  *           result=MHD__asn1_write_value(cert,
   *           "tbsCertificate.subject.rdnSequence.?LAST", "NEW", 1);
   *
   * Returns:
@@ -274,8 +274,8 @@ _asn1_append_sequence_set (node_asn * node)
   *   ASN1_VALUE_NOT_VALID: VALUE has a wrong format.
   *
   **/
-asn1_retCode
-asn1_write_value (ASN1_TYPE node_root, const char *name,
+MHD__asn1_retCode
+MHD__asn1_write_value (ASN1_TYPE node_root, const char *name,
                   const void *ivalue, int len)
 {
   node_asn *node, *p, *p2;
@@ -283,13 +283,13 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
   int len2, k, k2, negative;
   const unsigned char *value = ivalue;
 
-  node = asn1_find_node (node_root, name);
+  node = MHD__asn1_find_node (node_root, name);
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
 
   if ((node->type & CONST_OPTION) && (value == NULL) && (len == 0))
     {
-      asn1_delete_structure (&node);
+      MHD__asn1_delete_structure (&node);
       return ASN1_SUCCESS;
     }
 
@@ -302,7 +302,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
         p = p->right;
 
       while (p->right)
-        asn1_delete_structure (&p->right);
+        MHD__asn1_delete_structure (&p->right);
 
       return ASN1_SUCCESS;
     }
@@ -318,12 +318,12 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
               while (type_field (p->type) != TYPE_DEFAULT)
                 p = p->right;
               if (p->type & CONST_TRUE)
-                _asn1_set_value (node, NULL, 0);
+                MHD__asn1_set_value (node, NULL, 0);
               else
-                _asn1_set_value (node, "T", 1);
+                MHD__asn1_set_value (node, "T", 1);
             }
           else
-            _asn1_set_value (node, "T", 1);
+            MHD__asn1_set_value (node, "T", 1);
         }
       else if (!strcmp (value, "FALSE"))
         {
@@ -333,12 +333,12 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
               while (type_field (p->type) != TYPE_DEFAULT)
                 p = p->right;
               if (p->type & CONST_FALSE)
-                _asn1_set_value (node, NULL, 0);
+                MHD__asn1_set_value (node, NULL, 0);
               else
-                _asn1_set_value (node, "F", 1);
+                MHD__asn1_set_value (node, "F", 1);
             }
           else
-            _asn1_set_value (node, "F", 1);
+            MHD__asn1_set_value (node, "F", 1);
         }
       else
         return ASN1_VALUE_NOT_VALID;
@@ -350,11 +350,11 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
           if ((isdigit (value[0])) || (value[0] == '-'))
             {
               value_temp =
-                (unsigned char *) _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
+                (unsigned char *) MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
               if (value_temp == NULL)
                 return ASN1_MEM_ALLOC_ERROR;
 
-              _asn1_convert_integer (value, value_temp,
+              MHD__asn1_convert_integer (value, value_temp,
                                      SIZEOF_UNSIGNED_LONG_INT, &len);
             }
           else
@@ -370,11 +370,11 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
                         {
                           value_temp =
                             (unsigned char *)
-                            _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
+                            MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
                           if (value_temp == NULL)
                             return ASN1_MEM_ALLOC_ERROR;
 
-                          _asn1_convert_integer (p->value,
+                          MHD__asn1_convert_integer (p->value,
                                                  value_temp,
                                                  SIZEOF_UNSIGNED_LONG_INT,
                                                  &len);
@@ -389,7 +389,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
         }
       else
         {                       /* len != 0 */
-          value_temp = (unsigned char *) _asn1_alloca (len);
+          value_temp = (unsigned char *) MHD__asn1_alloca (len);
           if (value_temp == NULL)
             return ASN1_MEM_ALLOC_ERROR;
           memcpy (value_temp, value, len);
@@ -403,7 +403,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
 
       if (negative && (type_field (node->type) == TYPE_ENUMERATED))
         {
-          _asn1_afree (value_temp);
+          MHD__asn1_afree (value_temp);
           return ASN1_VALUE_NOT_VALID;
         }
 
@@ -417,18 +417,18 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
           (!negative && (value_temp[k] & 0x80)))
         k--;
 
-      asn1_length_der (len - k, NULL, &len2);
-      temp = (unsigned char *) _asn1_alloca (len - k + len2);
+      MHD__asn1_length_der (len - k, NULL, &len2);
+      temp = (unsigned char *) MHD__asn1_alloca (len - k + len2);
       if (temp == NULL)
 	{
-	  _asn1_afree (value_temp);
+	  MHD__asn1_afree (value_temp);
 	  return ASN1_MEM_ALLOC_ERROR;
 	}
 
-      asn1_octet_der (value_temp + k, len - k, temp, &len2);
-      _asn1_set_value (node, temp, len2);
+      MHD__asn1_octet_der (value_temp + k, len - k, temp, &len2);
+      MHD__asn1_set_value (node, temp, len2);
 
-      _asn1_afree (temp);
+      MHD__asn1_afree (temp);
 
 
       if (node->type & CONST_DEFAULT)
@@ -439,21 +439,21 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
           if ((isdigit (p->value[0])) || (p->value[0] == '-'))
             {
               default_temp =
-                (unsigned char *) _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
+                (unsigned char *) MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
               if (default_temp == NULL)
 		{
-		  _asn1_afree (value_temp);
+		  MHD__asn1_afree (value_temp);
 		  return ASN1_MEM_ALLOC_ERROR;
 		}
 
-              _asn1_convert_integer (p->value, default_temp,
+              MHD__asn1_convert_integer (p->value, default_temp,
                                      SIZEOF_UNSIGNED_LONG_INT, &len2);
             }
           else
             {                   /* is an identifier like v1 */
               if (!(node->type & CONST_LIST))
 		{
-		  _asn1_afree (value_temp);
+		  MHD__asn1_afree (value_temp);
 		  return ASN1_VALUE_NOT_VALID;
 		}
               p2 = node->down;
@@ -465,14 +465,14 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
                         {
                           default_temp =
                             (unsigned char *)
-                            _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
+                            MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT);
                           if (default_temp == NULL)
 			    {
-			      _asn1_afree (value_temp);
+			      MHD__asn1_afree (value_temp);
 			      return ASN1_MEM_ALLOC_ERROR;
 			    }
 
-                          _asn1_convert_integer (p2->value,
+                          MHD__asn1_convert_integer (p2->value,
                                                  default_temp,
                                                  SIZEOF_UNSIGNED_LONG_INT,
                                                  &len2);
@@ -483,7 +483,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
                 }
               if (p2 == NULL)
 		{
-		  _asn1_afree (value_temp);
+		  MHD__asn1_afree (value_temp);
 		  return ASN1_VALUE_NOT_VALID;
 		}
             }
@@ -497,11 +497,11 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
                     break;
                   }
               if (k2 == len2)
-                _asn1_set_value (node, NULL, 0);
+                MHD__asn1_set_value (node, NULL, 0);
             }
-          _asn1_afree (default_temp);
+          MHD__asn1_afree (default_temp);
         }
-      _asn1_afree (value_temp);
+      MHD__asn1_afree (value_temp);
       break;
     case TYPE_OBJECT_ID:
       for (k = 0; k < strlen (value); k++)
@@ -514,11 +514,11 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
             p = p->right;
           if (!strcmp (value, p->value))
             {
-              _asn1_set_value (node, NULL, 0);
+              MHD__asn1_set_value (node, NULL, 0);
               break;
             }
         }
-      _asn1_set_value (node, value, strlen (value) + 1);
+      MHD__asn1_set_value (node, value, strlen (value) + 1);
       break;
     case TYPE_TIME:
       if (node->type & CONST_UTC)
@@ -558,49 +558,49 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
             default:
               return ASN1_VALUE_NOT_FOUND;
             }
-          _asn1_set_value (node, value, strlen (value) + 1);
+          MHD__asn1_set_value (node, value, strlen (value) + 1);
         }
       else
         {                       /* GENERALIZED TIME */
           if (value)
-            _asn1_set_value (node, value, strlen (value) + 1);
+            MHD__asn1_set_value (node, value, strlen (value) + 1);
         }
       break;
     case TYPE_OCTET_STRING:
       if (len == 0)
         len = strlen (value);
-      asn1_length_der (len, NULL, &len2);
-      temp = (unsigned char *) _asn1_alloca (len + len2);
+      MHD__asn1_length_der (len, NULL, &len2);
+      temp = (unsigned char *) MHD__asn1_alloca (len + len2);
       if (temp == NULL)
         return ASN1_MEM_ALLOC_ERROR;
 
-      asn1_octet_der (value, len, temp, &len2);
-      _asn1_set_value (node, temp, len2);
-      _asn1_afree (temp);
+      MHD__asn1_octet_der (value, len, temp, &len2);
+      MHD__asn1_set_value (node, temp, len2);
+      MHD__asn1_afree (temp);
       break;
     case TYPE_GENERALSTRING:
       if (len == 0)
         len = strlen (value);
-      asn1_length_der (len, NULL, &len2);
-      temp = (unsigned char *) _asn1_alloca (len + len2);
+      MHD__asn1_length_der (len, NULL, &len2);
+      temp = (unsigned char *) MHD__asn1_alloca (len + len2);
       if (temp == NULL)
         return ASN1_MEM_ALLOC_ERROR;
 
-      asn1_octet_der (value, len, temp, &len2);
-      _asn1_set_value (node, temp, len2);
-      _asn1_afree (temp);
+      MHD__asn1_octet_der (value, len, temp, &len2);
+      MHD__asn1_set_value (node, temp, len2);
+      MHD__asn1_afree (temp);
       break;
     case TYPE_BIT_STRING:
       if (len == 0)
         len = strlen (value);
-      asn1_length_der ((len >> 3) + 2, NULL, &len2);
-      temp = (unsigned char *) _asn1_alloca ((len >> 3) + 2 + len2);
+      MHD__asn1_length_der ((len >> 3) + 2, NULL, &len2);
+      temp = (unsigned char *) MHD__asn1_alloca ((len >> 3) + 2 + len2);
       if (temp == NULL)
         return ASN1_MEM_ALLOC_ERROR;
 
-      asn1_bit_der (value, len, temp, &len2);
-      _asn1_set_value (node, temp, len2);
-      _asn1_afree (temp);
+      MHD__asn1_bit_der (value, len, temp, &len2);
+      MHD__asn1_set_value (node, temp, len2);
+      MHD__asn1_afree (temp);
       break;
     case TYPE_CHOICE:
       p = node->down;
@@ -613,7 +613,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
                 {
                   if (p2 != p)
                     {
-                      asn1_delete_structure (&p2);
+                      MHD__asn1_delete_structure (&p2);
                       p2 = node->down;
                     }
                   else
@@ -627,20 +627,20 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
         return ASN1_ELEMENT_NOT_FOUND;
       break;
     case TYPE_ANY:
-      asn1_length_der (len, NULL, &len2);
-      temp = (unsigned char *) _asn1_alloca (len + len2);
+      MHD__asn1_length_der (len, NULL, &len2);
+      temp = (unsigned char *) MHD__asn1_alloca (len + len2);
       if (temp == NULL)
         return ASN1_MEM_ALLOC_ERROR;
 
-      asn1_octet_der (value, len, temp, &len2);
-      _asn1_set_value (node, temp, len2);
-      _asn1_afree (temp);
+      MHD__asn1_octet_der (value, len, temp, &len2);
+      MHD__asn1_set_value (node, temp, len2);
+      MHD__asn1_afree (temp);
       break;
     case TYPE_SEQUENCE_OF:
     case TYPE_SET_OF:
       if (strcmp (value, "NEW"))
         return ASN1_VALUE_NOT_VALID;
-      _asn1_append_sequence_set (node);
+      MHD__asn1_append_sequence_set (node);
       break;
     default:
       return ASN1_ELEMENT_NOT_FOUND;
@@ -678,7 +678,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name,
 	}
 
 /**
-  * asn1_read_value - Returns the value of one element inside a structure
+  * MHD__asn1_read_value - Returns the value of one element inside a structure
   * @root: pointer to a structure.
   * @name: the name of the element inside a structure that you want to read.
   * @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,
   *   In this case LEN will contain the number of bytes needed.
   *
   **/
-asn1_retCode
-asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
+MHD__asn1_retCode
+MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
 {
   node_asn *node, *p, *p2;
   int len2, len3;
   int value_size = *len;
   unsigned char *value = ivalue;
 
-  node = asn1_find_node (root, name);
+  node = MHD__asn1_find_node (root, name);
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
 
@@ -800,7 +800,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
           if ((isdigit (p->value[0])) || (p->value[0] == '-')
               || (p->value[0] == '+'))
             {
-              if (_asn1_convert_integer
+              if (MHD__asn1_convert_integer
                   (p->value, value, value_size, len) != ASN1_SUCCESS)
                 return ASN1_MEM_ERROR;
             }
@@ -813,7 +813,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
                     {
                       if ((p2->name) && (!strcmp (p2->name, p->value)))
                         {
-                          if (_asn1_convert_integer
+                          if (MHD__asn1_convert_integer
                               (p2->value, value, value_size,
                                len) != ASN1_SUCCESS)
                             return ASN1_MEM_ERROR;
@@ -827,7 +827,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
       else
         {
           len2 = -1;
-          if (asn1_get_octet_der
+          if (MHD__asn1_get_octet_der
               (node->value, node->value_len, &len2, value, value_size,
                len) != ASN1_SUCCESS)
             return ASN1_MEM_ERROR;
@@ -869,21 +869,21 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
       break;
     case TYPE_OCTET_STRING:
       len2 = -1;
-      if (asn1_get_octet_der
+      if (MHD__asn1_get_octet_der
           (node->value, node->value_len, &len2, value, value_size,
            len) != ASN1_SUCCESS)
         return ASN1_MEM_ERROR;
       break;
     case TYPE_GENERALSTRING:
       len2 = -1;
-      if (asn1_get_octet_der
+      if (MHD__asn1_get_octet_der
           (node->value, node->value_len, &len2, value, value_size,
            len) != ASN1_SUCCESS)
         return ASN1_MEM_ERROR;
       break;
     case TYPE_BIT_STRING:
       len2 = -1;
-      if (asn1_get_bit_der
+      if (MHD__asn1_get_bit_der
           (node->value, node->value_len, &len2, value, value_size,
            len) != ASN1_SUCCESS)
         return ASN1_MEM_ERROR;
@@ -893,7 +893,7 @@ asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len)
       break;
     case TYPE_ANY:
       len3 = -1;
-      len2 = asn1_get_length_der (node->value, node->value_len, &len3);
+      len2 = MHD__asn1_get_length_der (node->value, node->value_len, &len3);
       if (len2 < 0)
         return ASN1_DER_ERROR;
       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)
 
 
 /**
-  * asn1_read_tag - Returns the TAG of one element inside a structure
+  * MHD__asn1_read_tag - Returns the TAG of one element inside a structure
   * @root: pointer to a structure
   * @name: the name of the element inside a structure.
   * @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)
   *   ASN1_ELEMENT_NOT_FOUND: NAME is not a valid element.
   *
   **/
-asn1_retCode
-asn1_read_tag (node_asn * root, const char *name, int *tagValue,
+MHD__asn1_retCode
+MHD__asn1_read_tag (node_asn * root, const char *name, int *tagValue,
                int *classValue)
 {
   node_asn *node, *p, *pTag;
 
-  node = asn1_find_node (root, name);
+  node = MHD__asn1_find_node (root, name);
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
 

+ 3 - 3
src/daemon/https/minitasn1/element.h

@@ -3,12 +3,12 @@
 #define _ELEMENT_H
 
 
-asn1_retCode _asn1_append_sequence_set (node_asn * node);
+MHD__asn1_retCode MHD__asn1_append_sequence_set (node_asn * node);
 
-asn1_retCode _asn1_convert_integer (const char *value,
+MHD__asn1_retCode MHD__asn1_convert_integer (const char *value,
                                     unsigned char *value_out,
                                     int value_out_size, int *len);
 
-void _asn1_hierarchical_name (node_asn * node, char *name, int name_size);
+void MHD__asn1_hierarchical_name (node_asn * node, char *name, int name_size);
 
 #endif

+ 10 - 10
src/daemon/https/minitasn1/errors.c

@@ -30,14 +30,14 @@
 #define LIBTASN1_ERROR_ENTRY(name) \
 	{ #name, name }
 
-struct libtasn1_error_entry
+struct MHD__libtasn1_error_entry
 {
   const char *name;
   int number;
 };
-typedef struct libtasn1_error_entry libtasn1_error_entry;
+typedef struct MHD__libtasn1_error_entry MHD__libtasn1_error_entry;
 
-static const libtasn1_error_entry error_algorithms[] = {
+static const MHD__libtasn1_error_entry error_algorithms[] = {
   LIBTASN1_ERROR_ENTRY (ASN1_SUCCESS),
   LIBTASN1_ERROR_ENTRY (ASN1_FILE_NOT_FOUND),
   LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_FOUND),
@@ -60,7 +60,7 @@ static const libtasn1_error_entry error_algorithms[] = {
 };
 
 #define LIBTASN1_ERROR_LOOP(b) \
-        const libtasn1_error_entry *p; \
+        const MHD__libtasn1_error_entry *p; \
                 for(p = error_algorithms; p->name != NULL; p++) { b ; }
 
 #define LIBTASN1_ERROR_ALG_LOOP(a) \
@@ -69,14 +69,14 @@ static const libtasn1_error_entry error_algorithms[] = {
 
 
 /**
-  * libtasn1_perror - prints a string to stderr with a description of an error
+  * MHD__libtasn1_perror - prints a string to stderr with a description of an error
   * @error: is an error returned by a libtasn1 function.
   *
   * This function is like perror(). The only difference is that it
   * accepts an error returned by a libtasn1 function.
   **/
 void
-libtasn1_perror (asn1_retCode error)
+MHD__libtasn1_perror (MHD__asn1_retCode error)
 {
   const char *ret = NULL;
 
@@ -89,7 +89,7 @@ libtasn1_perror (asn1_retCode error)
 
 
 /**
-  * libtasn1_strerror - Returns a string with a description of an error
+  * MHD__libtasn1_strerror - Returns a string with a description of an error
   * @error: is an error returned by a libtasn1 function.
   *
   * This function is similar to strerror(). The only difference is
@@ -99,7 +99,7 @@ libtasn1_perror (asn1_retCode error)
   *   code.
   **/
 const char *
-libtasn1_strerror (asn1_retCode error)
+MHD__libtasn1_strerror (MHD__asn1_retCode error)
 {
   const char *ret = NULL;
 
@@ -113,7 +113,7 @@ libtasn1_strerror (asn1_retCode error)
  */
 #ifdef LIBTASN1_DEBUG
 void
-_libtasn1_log (const char *fmt, ...)
+MHD__libtasn1_log (const char *fmt, ...)
 {
   va_list args;
   char str[MAX_LOG_SIZE];
@@ -128,7 +128,7 @@ _libtasn1_log (const char *fmt, ...)
 }
 #else /* not DEBUG */
 void
-_libtasn1_log (const char *fmt, ...)
+MHD__libtasn1_log (const char *fmt, ...)
 {
   return;
 }

+ 1 - 1
src/daemon/https/minitasn1/errors.h

@@ -25,6 +25,6 @@
 
 #include "int.h"
 
-void _libtasn1_log (const char *fmt, ...);
+void MHD__libtasn1_log (const char *fmt, ...);
 
 #endif /* ERRORS_H */

+ 2 - 2
src/daemon/https/minitasn1/gstr.c

@@ -29,7 +29,7 @@
  * They should be used only with null terminated strings.
  */
 void
-_asn1_str_cat (char *dest, size_t dest_tot_size, const char *src)
+MHD__asn1_str_cat (char *dest, size_t dest_tot_size, const char *src)
 {
   size_t str_size = strlen (src);
   size_t dest_size = strlen (dest);
@@ -49,7 +49,7 @@ _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src)
 }
 
 void
-_asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src)
+MHD__asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src)
 {
   size_t str_size = strlen (src);
 

+ 4 - 4
src/daemon/https/minitasn1/gstr.h

@@ -1,5 +1,5 @@
-void _asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src);
-void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
+void MHD__asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src);
+void MHD__asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
 
-#define Estrcpy(x,y) _asn1_str_cpy(x,MAX_ERROR_DESCRIPTION_SIZE,y)
-#define Estrcat(x,y) _asn1_str_cat(x,MAX_ERROR_DESCRIPTION_SIZE,y)
+#define Estrcpy(x,y) MHD__asn1_str_cpy(x,MAX_ERROR_DESCRIPTION_SIZE,y)
+#define Estrcat(x,y) MHD__asn1_str_cat(x,MAX_ERROR_DESCRIPTION_SIZE,y)

+ 34 - 34
src/daemon/https/minitasn1/libtasn1.h

@@ -43,7 +43,7 @@ extern "C"
   /* (null character included)    */
 
 
-  typedef int asn1_retCode;     /* type returned by libtasn1 functions */
+  typedef int MHD__asn1_retCode;     /* type returned by libtasn1 functions */
 
   /*****************************************/
   /*  Errors returned by libtasn1 functions */
@@ -68,7 +68,7 @@ extern "C"
 #define ASN1_ELEMENT_NOT_EMPTY     17
 
 /*************************************/
-/* Constants used in asn1_visit_tree */
+/* Constants used in MHD__asn1_visit_tree */
 /*************************************/
 #define ASN1_PRINT_NAME             1
 #define ASN1_PRINT_NAME_TYPE        2
@@ -76,7 +76,7 @@ extern "C"
 #define ASN1_PRINT_ALL              4
 
 /*****************************************/
-/* Constants returned by asn1_read_tag   */
+/* Constants returned by MHD__asn1_read_tag   */
 /*****************************************/
 #define ASN1_CLASS_UNIVERSAL        0x00        /* old: 1 */
 #define ASN1_CLASS_APPLICATION      0x40        /* old: 2 */
@@ -85,7 +85,7 @@ extern "C"
 #define ASN1_CLASS_STRUCTURED       0x20
 
 /*****************************************/
-/* Constants returned by asn1_read_tag   */
+/* Constants returned by MHD__asn1_read_tag   */
 /*****************************************/
 #define ASN1_TAG_BOOLEAN          0x01
 #define ASN1_TAG_INTEGER          0x02
@@ -137,106 +137,106 @@ extern "C"
   /*  Functions definitions          */
   /***********************************/
 
-  asn1_retCode asn1_parser2tree (const char *file_name,
+  MHD__asn1_retCode MHD__asn1_parser2tree (const char *file_name,
                                  ASN1_TYPE * definitions,
                                  char *errorDescription);
 
-  asn1_retCode asn1_parser2array (const char *inputFileName,
+  MHD__asn1_retCode MHD__asn1_parser2array (const char *inputFileName,
                                   const char *outputFileName,
                                   const char *vectorName,
                                   char *errorDescription);
 
-  asn1_retCode asn1_array2tree (const ASN1_ARRAY_TYPE * array,
+  MHD__asn1_retCode MHD__asn1_array2tree (const ASN1_ARRAY_TYPE * array,
                                 ASN1_TYPE * definitions,
                                 char *errorDescription);
 
-  void asn1_print_structure (FILE * out, ASN1_TYPE structure,
+  void MHD__asn1_print_structure (FILE * out, ASN1_TYPE structure,
                              const char *name, int mode);
 
-  asn1_retCode asn1_create_element (ASN1_TYPE definitions,
+  MHD__asn1_retCode MHD__asn1_create_element (ASN1_TYPE definitions,
                                     const char *source_name,
                                     ASN1_TYPE * element);
 
-  asn1_retCode asn1_delete_structure (ASN1_TYPE * structure);
+  MHD__asn1_retCode MHD__asn1_delete_structure (ASN1_TYPE * structure);
 
-  asn1_retCode asn1_delete_element (ASN1_TYPE structure,
+  MHD__asn1_retCode MHD__asn1_delete_element (ASN1_TYPE structure,
                                     const char *element_name);
 
-  asn1_retCode asn1_write_value (ASN1_TYPE node_root, const char *name,
+  MHD__asn1_retCode MHD__asn1_write_value (ASN1_TYPE node_root, const char *name,
                                  const void *ivalue, int len);
 
-  asn1_retCode asn1_read_value (ASN1_TYPE root, const char *name,
+  MHD__asn1_retCode MHD__asn1_read_value (ASN1_TYPE root, const char *name,
                                 void *ivalue, int *len);
 
-  asn1_retCode asn1_number_of_elements (ASN1_TYPE element, const char *name,
+  MHD__asn1_retCode MHD__asn1_number_of_elements (ASN1_TYPE element, const char *name,
                                         int *num);
 
-  asn1_retCode asn1_der_coding (ASN1_TYPE element, const char *name,
+  MHD__asn1_retCode MHD__asn1_der_coding (ASN1_TYPE element, const char *name,
                                 void *ider, int *len, char *ErrorDescription);
 
-  asn1_retCode asn1_der_decoding (ASN1_TYPE * element, const void *ider,
+  MHD__asn1_retCode MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider,
                                   int len, char *errorDescription);
 
-  asn1_retCode asn1_der_decoding_element (ASN1_TYPE * structure,
+  MHD__asn1_retCode MHD__asn1_der_decoding_element (ASN1_TYPE * structure,
                                           const char *elementName,
                                           const void *ider, int len,
                                           char *errorDescription);
 
-  asn1_retCode asn1_der_decoding_startEnd (ASN1_TYPE element,
+  MHD__asn1_retCode MHD__asn1_der_decoding_startEnd (ASN1_TYPE element,
                                            const void *ider, int len,
                                            const char *name_element,
                                            int *start, int *end);
 
-  asn1_retCode asn1_expand_any_defined_by (ASN1_TYPE definitions,
+  MHD__asn1_retCode MHD__asn1_expand_any_defined_by (ASN1_TYPE definitions,
                                            ASN1_TYPE * element);
 
-  asn1_retCode asn1_expand_octet_string (ASN1_TYPE definitions,
+  MHD__asn1_retCode MHD__asn1_expand_octet_string (ASN1_TYPE definitions,
                                          ASN1_TYPE * element,
                                          const char *octetName,
                                          const char *objectName);
 
-  asn1_retCode asn1_read_tag (node_asn * root, const char *name,
+  MHD__asn1_retCode MHD__asn1_read_tag (node_asn * root, const char *name,
                               int *tagValue, int *classValue);
 
-  const char *asn1_find_structure_from_oid (ASN1_TYPE definitions,
+  const char *MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions,
                                             const char *oidValue);
 
-  const char *asn1_check_version (const char *req_version);
+  const char *MHD__asn1_check_version (const char *req_version);
 
-  const char *libtasn1_strerror (asn1_retCode error);
+  const char *MHD__libtasn1_strerror (MHD__asn1_retCode error);
 
-  void libtasn1_perror (asn1_retCode error);
+  void MHD__libtasn1_perror (MHD__asn1_retCode error);
 
   /* DER utility functions. */
 
-  int asn1_get_tag_der (const unsigned char *der, int der_len,
+  int MHD__asn1_get_tag_der (const unsigned char *der, int der_len,
                         unsigned char *cls, int *len, unsigned long *tag);
 
-  void asn1_octet_der (const unsigned char *str, int str_len,
+  void MHD__asn1_octet_der (const unsigned char *str, int str_len,
                        unsigned char *der, int *der_len);
 
-  asn1_retCode asn1_get_octet_der (const unsigned char *der, int der_len,
+  MHD__asn1_retCode MHD__asn1_get_octet_der (const unsigned char *der, int der_len,
                                    int *ret_len, unsigned char *str,
                                    int str_size, int *str_len);
 
-  void asn1_bit_der (const unsigned char *str, int bit_len,
+  void MHD__asn1_bit_der (const unsigned char *str, int bit_len,
                      unsigned char *der, int *der_len);
 
-  asn1_retCode asn1_get_bit_der (const unsigned char *der, int der_len,
+  MHD__asn1_retCode MHD__asn1_get_bit_der (const unsigned char *der, int der_len,
                                  int *ret_len, unsigned char *str,
                                  int str_size, int *bit_len);
 
-  signed long asn1_get_length_der (const unsigned char *der, int der_len,
+  signed long MHD__asn1_get_length_der (const unsigned char *der, int der_len,
                                    int *len);
 
-  void asn1_length_der (unsigned long int len, unsigned char *ans,
+  void MHD__asn1_length_der (unsigned long int len, unsigned char *ans,
                         int *ans_len);
 
   /* Other utility functions. */
 
-  ASN1_TYPE asn1_find_node (ASN1_TYPE pointer, const char *name);
+  ASN1_TYPE MHD__asn1_find_node (ASN1_TYPE pointer, const char *name);
 
-  asn1_retCode asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
+  MHD__asn1_retCode MHD__asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
                                ASN1_TYPE src, const char *src_name);
 
 #ifdef __cplusplus

+ 10 - 10
src/daemon/https/minitasn1/mem.h

@@ -1,7 +1,7 @@
 #ifndef MEM_H
 # define MEM_H
 
-/* Use _asn1_afree() when calling alloca, or
+/* Use MHD__asn1_afree() when calling alloca, or
  * memory leaks may occur in systems which do not
  * support alloca.
  */
@@ -9,17 +9,17 @@
 # ifdef HAVE_ALLOCA_H
 #  include <alloca.h>
 # endif
-# define _asn1_alloca alloca
-# define _asn1_afree(x)
+# define MHD__asn1_alloca alloca
+# define MHD__asn1_afree(x)
 #else
-# define _asn1_alloca _asn1_malloc
-# define _asn1_afree _asn1_free
+# define MHD__asn1_alloca MHD__asn1_malloc
+# define MHD__asn1_afree MHD__asn1_free
 #endif /* HAVE_ALLOCA */
 
-#define _asn1_malloc malloc
-#define _asn1_free free
-#define _asn1_calloc calloc
-#define _asn1_realloc realloc
-#define _asn1_strdup strdup
+#define MHD__asn1_malloc malloc
+#define MHD__asn1_free free
+#define MHD__asn1_calloc calloc
+#define MHD__asn1_realloc realloc
+#define MHD__asn1_strdup strdup
 
 #endif /* MEM_H */

+ 112 - 112
src/daemon/https/minitasn1/parser_aux.c

@@ -27,7 +27,7 @@
 #include "structure.h"
 #include "element.h"
 
-char _asn1_identifierMissing[MAX_NAME_SIZE + 1];        /* identifier name not found */
+char MHD__asn1_identifierMissing[MAX_NAME_SIZE + 1];        /* identifier name not found */
 
 /***********************************************/
 /* Type: list_type                             */
@@ -45,7 +45,7 @@ typedef struct list_struct
 list_type *firstElement = NULL;
 
 /******************************************************/
-/* Function : _asn1_add_node                          */
+/* Function : MHD__asn1_add_node                          */
 /* Description: creates a new NODE_ASN element and    */
 /* puts it in the list pointed by firstElement.       */
 /* Parameters:                                        */
@@ -54,19 +54,19 @@ list_type *firstElement = NULL;
 /* Return: pointer to the new element.                */
 /******************************************************/
 node_asn *
-_asn1_add_node (unsigned int type)
+MHD__asn1_add_node (unsigned int type)
 {
   list_type *listElement;
   node_asn *punt;
 
-  punt = (node_asn *) _asn1_calloc (1, sizeof (node_asn));
+  punt = (node_asn *) MHD__asn1_calloc (1, sizeof (node_asn));
   if (punt == NULL)
     return NULL;
 
-  listElement = (list_type *) _asn1_malloc (sizeof (list_type));
+  listElement = (list_type *) MHD__asn1_malloc (sizeof (list_type));
   if (listElement == NULL)
     {
-      _asn1_free (punt);
+      MHD__asn1_free (punt);
       return NULL;
     }
 
@@ -80,7 +80,7 @@ _asn1_add_node (unsigned int type)
 }
 
 /**
- * asn1_find_node:
+ * MHD__asn1_find_node:
  * @pointer: NODE_ASN element pointer.
  * @name: null terminated string with the element's name to find.
  *
@@ -92,7 +92,7 @@ _asn1_add_node (unsigned int type)
  * Return value: the searching result. NULL if not found.
  **/
 ASN1_TYPE
-asn1_find_node (ASN1_TYPE pointer, const char *name)
+MHD__asn1_find_node (ASN1_TYPE pointer, const char *name)
 {
   node_asn *p;
   char *n_end, n[MAX_NAME_SIZE + 1];
@@ -119,7 +119,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
         }
       else
         {
-          _asn1_str_cpy (n, sizeof (n), n_start);
+          MHD__asn1_str_cpy (n, sizeof (n), n_start);
           n_start = NULL;
         }
 
@@ -152,7 +152,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
         }
       else
         {
-          _asn1_str_cpy (n, sizeof (n), n_start);
+          MHD__asn1_str_cpy (n, sizeof (n), n_start);
           n_start = NULL;
         }
 
@@ -189,7 +189,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
 
 
 /******************************************************************/
-/* Function : _asn1_set_value                                     */
+/* Function : MHD__asn1_set_value                                     */
 /* Description: sets the field VALUE in a NODE_ASN element. The   */
 /*              previous value (if exist) will be lost            */
 /* Parameters:                                                    */
@@ -199,7 +199,7 @@ asn1_find_node (ASN1_TYPE pointer, const char *name)
 /* Return: pointer to the NODE_ASN element.                       */
 /******************************************************************/
 node_asn *
-_asn1_set_value (node_asn * node, const void *_value, unsigned int len)
+MHD__asn1_set_value (node_asn * node, const void *_value, unsigned int len)
 {
   const unsigned char *value = _value;
 
@@ -207,13 +207,13 @@ _asn1_set_value (node_asn * node, const void *_value, unsigned int len)
     return node;
   if (node->value)
     {
-      _asn1_free (node->value);
+      MHD__asn1_free (node->value);
       node->value = NULL;
       node->value_len = 0;
     }
   if (!len)
     return node;
-  node->value = (unsigned char *) _asn1_malloc (len);
+  node->value = (unsigned char *) MHD__asn1_malloc (len);
   if (node->value == NULL)
     return NULL;
   node->value_len = len;
@@ -223,7 +223,7 @@ _asn1_set_value (node_asn * node, const void *_value, unsigned int len)
 }
 
 /******************************************************************/
-/* Function : _asn1_set_name                                      */
+/* Function : MHD__asn1_set_name                                      */
 /* Description: sets the field NAME in a NODE_ASN element. The    */
 /*              previous value (if exist) will be lost            */
 /* Parameters:                                                    */
@@ -233,14 +233,14 @@ _asn1_set_value (node_asn * node, const void *_value, unsigned int len)
 /* Return: pointer to the NODE_ASN element.                       */
 /******************************************************************/
 node_asn *
-_asn1_set_name (node_asn * node, const char *name)
+MHD__asn1_set_name (node_asn * node, const char *name)
 {
   if (node == NULL)
     return node;
 
   if (node->name)
     {
-      _asn1_free (node->name);
+      MHD__asn1_free (node->name);
       node->name = NULL;
     }
 
@@ -249,7 +249,7 @@ _asn1_set_name (node_asn * node, const char *name)
 
   if (strlen (name))
     {
-      node->name = (char *) _asn1_strdup (name);
+      node->name = (char *) MHD__asn1_strdup (name);
       if (node->name == NULL)
         return NULL;
     }
@@ -259,7 +259,7 @@ _asn1_set_name (node_asn * node, const char *name)
 }
 
 /******************************************************************/
-/* Function : _asn1_set_right                                     */
+/* Function : MHD__asn1_set_right                                     */
 /* Description: sets the field RIGHT in a NODE_ASN element.       */
 /* Parameters:                                                    */
 /*   node: element pointer.                                       */
@@ -268,7 +268,7 @@ _asn1_set_name (node_asn * node, const char *name)
 /* Return: pointer to *NODE.                                      */
 /******************************************************************/
 node_asn *
-_asn1_set_right (node_asn * node, node_asn * right)
+MHD__asn1_set_right (node_asn * node, node_asn * right)
 {
   if (node == NULL)
     return node;
@@ -279,7 +279,7 @@ _asn1_set_right (node_asn * node, node_asn * right)
 }
 
 /******************************************************************/
-/* Function : _asn1_get_right                                     */
+/* Function : MHD__asn1_get_right                                     */
 /* Description: returns the element pointed by the RIGHT field of */
 /*              a NODE_ASN element.                               */
 /* Parameters:                                                    */
@@ -287,7 +287,7 @@ _asn1_set_right (node_asn * node, node_asn * right)
 /* Return: field RIGHT of NODE.                                   */
 /******************************************************************/
 node_asn *
-_asn1_get_right (node_asn * node)
+MHD__asn1_get_right (node_asn * node)
 {
   if (node == NULL)
     return NULL;
@@ -295,14 +295,14 @@ _asn1_get_right (node_asn * node)
 }
 
 /******************************************************************/
-/* Function : _asn1_get_last_right                                */
+/* Function : MHD__asn1_get_last_right                                */
 /* Description: return the last element along the right chain.    */
 /* Parameters:                                                    */
 /*   node: starting element pointer.                              */
 /* Return: pointer to the last element along the right chain.     */
 /******************************************************************/
 node_asn *
-_asn1_get_last_right (node_asn * node)
+MHD__asn1_get_last_right (node_asn * node)
 {
   node_asn *p;
 
@@ -315,7 +315,7 @@ _asn1_get_last_right (node_asn * node)
 }
 
 /******************************************************************/
-/* Function : _asn1_set_down                                      */
+/* Function : MHD__asn1_set_down                                      */
 /* Description: sets the field DOWN in a NODE_ASN element.        */
 /* Parameters:                                                    */
 /*   node: element pointer.                                       */
@@ -324,7 +324,7 @@ _asn1_get_last_right (node_asn * node)
 /* Return: pointer to *NODE.                                      */
 /******************************************************************/
 node_asn *
-_asn1_set_down (node_asn * node, node_asn * down)
+MHD__asn1_set_down (node_asn * node, node_asn * down)
 {
   if (node == NULL)
     return node;
@@ -335,7 +335,7 @@ _asn1_set_down (node_asn * node, node_asn * down)
 }
 
 /******************************************************************/
-/* Function : _asn1_get_down                                      */
+/* Function : MHD__asn1_get_down                                      */
 /* Description: returns the element pointed by the DOWN field of  */
 /*              a NODE_ASN element.                               */
 /* Parameters:                                                    */
@@ -343,7 +343,7 @@ _asn1_set_down (node_asn * node, node_asn * down)
 /* Return: field DOWN of NODE.                                    */
 /******************************************************************/
 node_asn *
-_asn1_get_down (node_asn * node)
+MHD__asn1_get_down (node_asn * node)
 {
   if (node == NULL)
     return NULL;
@@ -351,14 +351,14 @@ _asn1_get_down (node_asn * node)
 }
 
 /******************************************************************/
-/* Function : _asn1_get_name                                      */
+/* Function : MHD__asn1_get_name                                      */
 /* Description: returns the name of a NODE_ASN element.           */
 /* Parameters:                                                    */
 /*   node: NODE_ASN element pointer.                              */
 /* Return: a null terminated string.                              */
 /******************************************************************/
 char *
-_asn1_get_name (node_asn * node)
+MHD__asn1_get_name (node_asn * node)
 {
   if (node == NULL)
     return NULL;
@@ -366,7 +366,7 @@ _asn1_get_name (node_asn * node)
 }
 
 /******************************************************************/
-/* Function : _asn1_mod_type                                      */
+/* Function : MHD__asn1_mod_type                                      */
 /* Description: change the field TYPE of an NODE_ASN element.     */
 /*              The new value is the old one | (bitwise or) the   */
 /*              paramener VALUE.                                  */
@@ -377,7 +377,7 @@ _asn1_get_name (node_asn * node)
 /* Return: NODE pointer.                                          */
 /******************************************************************/
 node_asn *
-_asn1_mod_type (node_asn * node, unsigned int value)
+MHD__asn1_mod_type (node_asn * node, unsigned int value)
 {
   if (node == NULL)
     return node;
@@ -387,34 +387,34 @@ _asn1_mod_type (node_asn * node, unsigned int value)
 
 
 /******************************************************************/
-/* Function : _asn1_remove_node                                   */
+/* Function : MHD__asn1_remove_node                                   */
 /* Description: gets free the memory allocated for an NODE_ASN    */
 /*              element (not the elements pointed by it).         */
 /* Parameters:                                                    */
 /*   node: NODE_ASN element pointer.                              */
 /******************************************************************/
 void
-_asn1_remove_node (node_asn * node)
+MHD__asn1_remove_node (node_asn * node)
 {
   if (node == NULL)
     return;
 
   if (node->name != NULL)
-    _asn1_free (node->name);
+    MHD__asn1_free (node->name);
   if (node->value != NULL)
-    _asn1_free (node->value);
-  _asn1_free (node);
+    MHD__asn1_free (node->value);
+  MHD__asn1_free (node);
 }
 
 /******************************************************************/
-/* Function : _asn1_find_up                                       */
+/* Function : MHD__asn1_find_up                                       */
 /* Description: return the father of the NODE_ASN element.        */
 /* Parameters:                                                    */
 /*   node: NODE_ASN element pointer.                              */
 /* Return: Null if not found.                                     */
 /******************************************************************/
 node_asn *
-_asn1_find_up (node_asn * node)
+MHD__asn1_find_up (node_asn * node)
 {
   node_asn *p;
 
@@ -430,12 +430,12 @@ _asn1_find_up (node_asn * node)
 }
 
 /******************************************************************/
-/* Function : _asn1_delete_list                                   */
+/* Function : MHD__asn1_delete_list                                   */
 /* Description: deletes the list elements (not the elements       */
 /*  pointed by them).                                             */
 /******************************************************************/
 void
-_asn1_delete_list (void)
+MHD__asn1_delete_list (void)
 {
   list_type *listElement;
 
@@ -443,17 +443,17 @@ _asn1_delete_list (void)
     {
       listElement = firstElement;
       firstElement = firstElement->next;
-      _asn1_free (listElement);
+      MHD__asn1_free (listElement);
     }
 }
 
 /******************************************************************/
-/* Function : _asn1_delete_list_and nodes                         */
+/* Function : MHD__asn1_delete_list_and nodes                         */
 /* Description: deletes the list elements and the elements        */
 /*  pointed by them.                                              */
 /******************************************************************/
 void
-_asn1_delete_list_and_nodes (void)
+MHD__asn1_delete_list_and_nodes (void)
 {
   list_type *listElement;
 
@@ -461,14 +461,14 @@ _asn1_delete_list_and_nodes (void)
     {
       listElement = firstElement;
       firstElement = firstElement->next;
-      _asn1_remove_node (listElement->node);
-      _asn1_free (listElement);
+      MHD__asn1_remove_node (listElement->node);
+      MHD__asn1_free (listElement);
     }
 }
 
 
 char *
-_asn1_ltostr (long v, char *str)
+MHD__asn1_ltostr (long v, char *str)
 {
   long d, r;
   char temp[20];
@@ -502,7 +502,7 @@ _asn1_ltostr (long v, char *str)
 
 
 /******************************************************************/
-/* Function : _asn1_change_integer_value                          */
+/* Function : MHD__asn1_change_integer_value                          */
 /* Description: converts into DER coding the value assign to an   */
 /*   INTEGER constant.                                            */
 /* Parameters:                                                    */
@@ -511,8 +511,8 @@ _asn1_ltostr (long v, char *str)
 /*   ASN1_ELEMENT_NOT_FOUND if NODE is NULL,                       */
 /*   otherwise ASN1_SUCCESS                                             */
 /******************************************************************/
-asn1_retCode
-_asn1_change_integer_value (ASN1_TYPE node)
+MHD__asn1_retCode
+MHD__asn1_change_integer_value (ASN1_TYPE node)
 {
   node_asn *p;
   unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
@@ -529,9 +529,9 @@ _asn1_change_integer_value (ASN1_TYPE node)
         {
           if (p->value)
             {
-              _asn1_convert_integer (p->value, val, sizeof (val), &len);
-              asn1_octet_der (val, len, val2, &len);
-              _asn1_set_value (p, val2, len);
+              MHD__asn1_convert_integer (p->value, val, sizeof (val), &len);
+              MHD__asn1_octet_der (val, len, val2, &len);
+              MHD__asn1_set_value (p, val2, len);
             }
         }
 
@@ -549,7 +549,7 @@ _asn1_change_integer_value (ASN1_TYPE node)
             {
               while (1)
                 {
-                  p = _asn1_find_up (p);
+                  p = MHD__asn1_find_up (p);
                   if (p == node)
                     {
                       p = NULL;
@@ -570,7 +570,7 @@ _asn1_change_integer_value (ASN1_TYPE node)
 
 
 /******************************************************************/
-/* Function : _asn1_expand_object_id                              */
+/* Function : MHD__asn1_expand_object_id                              */
 /* Description: expand the IDs of an OBJECT IDENTIFIER constant.  */
 /* Parameters:                                                    */
 /*   node: root of an ASN1 element.                               */
@@ -578,8 +578,8 @@ _asn1_change_integer_value (ASN1_TYPE node)
 /*   ASN1_ELEMENT_NOT_FOUND if NODE is NULL,                       */
 /*   otherwise ASN1_SUCCESS                                             */
 /******************************************************************/
-asn1_retCode
-_asn1_expand_object_id (ASN1_TYPE node)
+MHD__asn1_retCode
+MHD__asn1_expand_object_id (ASN1_TYPE node)
 {
   node_asn *p, *p2, *p3, *p4, *p5;
   char name_root[MAX_NAME_SIZE], name2[2 * MAX_NAME_SIZE + 1];
@@ -588,7 +588,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
 
-  _asn1_str_cpy (name_root, sizeof (name_root), node->name);
+  MHD__asn1_str_cpy (name_root, sizeof (name_root), node->name);
 
   p = node;
   move = DOWN;
@@ -605,35 +605,35 @@ _asn1_expand_object_id (ASN1_TYPE node)
                 {
                   if (p2->value && !isdigit (p2->value[0]))
                     {
-                      _asn1_str_cpy (name2, sizeof (name2), name_root);
-                      _asn1_str_cat (name2, sizeof (name2), ".");
-                      _asn1_str_cat (name2, sizeof (name2), p2->value);
-                      p3 = asn1_find_node (node, name2);
+                      MHD__asn1_str_cpy (name2, sizeof (name2), name_root);
+                      MHD__asn1_str_cat (name2, sizeof (name2), ".");
+                      MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
+                      p3 = MHD__asn1_find_node (node, name2);
                       if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
                           !(p3->type & CONST_ASSIGN))
                         return ASN1_ELEMENT_NOT_FOUND;
-                      _asn1_set_down (p, p2->right);
-                      _asn1_remove_node (p2);
+                      MHD__asn1_set_down (p, p2->right);
+                      MHD__asn1_remove_node (p2);
                       p2 = p;
                       p4 = p3->down;
                       while (p4)
                         {
                           if (type_field (p4->type) == TYPE_CONSTANT)
                             {
-                              p5 = _asn1_add_node_only (TYPE_CONSTANT);
-                              _asn1_set_name (p5, p4->name);
+                              p5 = MHD__asn1_add_node_only (TYPE_CONSTANT);
+                              MHD__asn1_set_name (p5, p4->name);
                               tlen = strlen (p4->value);
                               if (tlen > 0)
-                                _asn1_set_value (p5, p4->value, tlen + 1);
+                                MHD__asn1_set_value (p5, p4->value, tlen + 1);
                               if (p2 == p)
                                 {
-                                  _asn1_set_right (p5, p->down);
-                                  _asn1_set_down (p, p5);
+                                  MHD__asn1_set_right (p5, p->down);
+                                  MHD__asn1_set_down (p, p5);
                                 }
                               else
                                 {
-                                  _asn1_set_right (p5, p2->right);
-                                  _asn1_set_right (p2, p5);
+                                  MHD__asn1_set_right (p5, p2->right);
+                                  MHD__asn1_set_right (p2, p5);
                                 }
                               p2 = p5;
                             }
@@ -671,7 +671,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
             move = UP;
         }
       if (move == UP)
-        p = _asn1_find_up (p);
+        p = MHD__asn1_find_up (p);
     }
 
 
@@ -691,10 +691,10 @@ _asn1_expand_object_id (ASN1_TYPE node)
               p2 = p->down;
               if (p2 && (type_field (p2->type) == TYPE_DEFAULT))
                 {
-                  _asn1_str_cpy (name2, sizeof (name2), name_root);
-                  _asn1_str_cat (name2, sizeof (name2), ".");
-                  _asn1_str_cat (name2, sizeof (name2), p2->value);
-                  p3 = asn1_find_node (node, name2);
+                  MHD__asn1_str_cpy (name2, sizeof (name2), name_root);
+                  MHD__asn1_str_cat (name2, sizeof (name2), ".");
+                  MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
+                  p3 = MHD__asn1_find_node (node, name2);
                   if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) ||
                       !(p3->type & CONST_ASSIGN))
                     return ASN1_ELEMENT_NOT_FOUND;
@@ -705,14 +705,14 @@ _asn1_expand_object_id (ASN1_TYPE node)
                       if (type_field (p4->type) == TYPE_CONSTANT)
                         {
                           if (name2[0])
-                            _asn1_str_cat (name2, sizeof (name2), ".");
-                          _asn1_str_cat (name2, sizeof (name2), p4->value);
+                            MHD__asn1_str_cat (name2, sizeof (name2), ".");
+                          MHD__asn1_str_cat (name2, sizeof (name2), p4->value);
                         }
                       p4 = p4->right;
                     }
                   tlen = strlen (name2);
                   if (tlen > 0)
-                    _asn1_set_value (p2, name2, tlen + 1);
+                    MHD__asn1_set_value (p2, name2, tlen + 1);
                 }
             }
           move = DOWN;
@@ -742,7 +742,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
             move = UP;
         }
       if (move == UP)
-        p = _asn1_find_up (p);
+        p = MHD__asn1_find_up (p);
     }
 
   return ASN1_SUCCESS;
@@ -750,7 +750,7 @@ _asn1_expand_object_id (ASN1_TYPE node)
 
 
 /******************************************************************/
-/* Function : _asn1_type_set_config                               */
+/* Function : MHD__asn1_type_set_config                               */
 /* Description: sets the CONST_SET and CONST_NOT_USED properties  */
 /*   in the fields of the SET elements.                           */
 /* Parameters:                                                    */
@@ -759,8 +759,8 @@ _asn1_expand_object_id (ASN1_TYPE node)
 /*   ASN1_ELEMENT_NOT_FOUND if NODE is NULL,                       */
 /*   otherwise ASN1_SUCCESS                                             */
 /******************************************************************/
-asn1_retCode
-_asn1_type_set_config (ASN1_TYPE node)
+MHD__asn1_retCode
+MHD__asn1_type_set_config (ASN1_TYPE node)
 {
   node_asn *p, *p2;
   int move;
@@ -812,7 +812,7 @@ _asn1_type_set_config (ASN1_TYPE node)
             move = UP;
         }
       if (move == UP)
-        p = _asn1_find_up (p);
+        p = MHD__asn1_find_up (p);
     }
 
   return ASN1_SUCCESS;
@@ -820,10 +820,10 @@ _asn1_type_set_config (ASN1_TYPE node)
 
 
 /******************************************************************/
-/* Function : _asn1_check_identifier                              */
+/* Function : MHD__asn1_check_identifier                              */
 /* Description: checks the definitions of all the identifiers     */
 /*   and the first element of an OBJECT_ID (e.g. {pkix 0 4}).     */
-/*   The _asn1_identifierMissing global variable is filled if     */
+/*   The MHD__asn1_identifierMissing global variable is filled if     */
 /*   necessary.                                                   */
 /* Parameters:                                                    */
 /*   node: root of an ASN1 element.                               */
@@ -832,8 +832,8 @@ _asn1_type_set_config (ASN1_TYPE node)
 /*   ASN1_IDENTIFIER_NOT_FOUND   if an identifier is not defined, */
 /*   otherwise ASN1_SUCCESS                                       */
 /******************************************************************/
-asn1_retCode
-_asn1_check_identifier (ASN1_TYPE node)
+MHD__asn1_retCode
+MHD__asn1_check_identifier (ASN1_TYPE node)
 {
   node_asn *p, *p2;
   char name2[MAX_NAME_SIZE * 2 + 2];
@@ -846,13 +846,13 @@ _asn1_check_identifier (ASN1_TYPE node)
     {
       if (type_field (p->type) == TYPE_IDENTIFIER)
         {
-          _asn1_str_cpy (name2, sizeof (name2), node->name);
-          _asn1_str_cat (name2, sizeof (name2), ".");
-          _asn1_str_cat (name2, sizeof (name2), p->value);
-          p2 = asn1_find_node (node, name2);
+          MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
+          MHD__asn1_str_cat (name2, sizeof (name2), ".");
+          MHD__asn1_str_cat (name2, sizeof (name2), p->value);
+          p2 = MHD__asn1_find_node (node, name2);
           if (p2 == NULL)
             {
-              strcpy (_asn1_identifierMissing, p->value);
+              strcpy (MHD__asn1_identifierMissing, p->value);
               return ASN1_IDENTIFIER_NOT_FOUND;
             }
         }
@@ -862,16 +862,16 @@ _asn1_check_identifier (ASN1_TYPE node)
           p2 = p->down;
           if (p2 && (type_field (p2->type) == TYPE_DEFAULT))
             {
-              _asn1_str_cpy (name2, sizeof (name2), node->name);
-              _asn1_str_cat (name2, sizeof (name2), ".");
-              _asn1_str_cat (name2, sizeof (name2), p2->value);
-              strcpy (_asn1_identifierMissing, p2->value);
-              p2 = asn1_find_node (node, name2);
+              MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
+              MHD__asn1_str_cat (name2, sizeof (name2), ".");
+              MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
+              strcpy (MHD__asn1_identifierMissing, p2->value);
+              p2 = MHD__asn1_find_node (node, name2);
               if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
                   !(p2->type & CONST_ASSIGN))
                 return ASN1_IDENTIFIER_NOT_FOUND;
               else
-                _asn1_identifierMissing[0] = 0;
+                MHD__asn1_identifierMissing[0] = 0;
             }
         }
       else if ((type_field (p->type) == TYPE_OBJECT_ID) &&
@@ -882,16 +882,16 @@ _asn1_check_identifier (ASN1_TYPE node)
             {
               if (p2->value && !isdigit (p2->value[0]))
                 {
-                  _asn1_str_cpy (name2, sizeof (name2), node->name);
-                  _asn1_str_cat (name2, sizeof (name2), ".");
-                  _asn1_str_cat (name2, sizeof (name2), p2->value);
-                  strcpy (_asn1_identifierMissing, p2->value);
-                  p2 = asn1_find_node (node, name2);
+                  MHD__asn1_str_cpy (name2, sizeof (name2), node->name);
+                  MHD__asn1_str_cat (name2, sizeof (name2), ".");
+                  MHD__asn1_str_cat (name2, sizeof (name2), p2->value);
+                  strcpy (MHD__asn1_identifierMissing, p2->value);
+                  p2 = MHD__asn1_find_node (node, name2);
                   if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) ||
                       !(p2->type & CONST_ASSIGN))
                     return ASN1_IDENTIFIER_NOT_FOUND;
                   else
-                    _asn1_identifierMissing[0] = 0;
+                    MHD__asn1_identifierMissing[0] = 0;
                 }
             }
         }
@@ -906,7 +906,7 @@ _asn1_check_identifier (ASN1_TYPE node)
         {
           while (1)
             {
-              p = _asn1_find_up (p);
+              p = MHD__asn1_find_up (p);
               if (p == node)
                 {
                   p = NULL;
@@ -926,7 +926,7 @@ _asn1_check_identifier (ASN1_TYPE node)
 
 
 /******************************************************************/
-/* Function : _asn1_set_default_tag                               */
+/* Function : MHD__asn1_set_default_tag                               */
 /* Description: sets the default IMPLICIT or EXPLICIT property in */
 /*   the tagged elements that don't have this declaration.        */
 /* Parameters:                                                    */
@@ -936,8 +936,8 @@ _asn1_check_identifier (ASN1_TYPE node)
 /*     a DEFINITIONS element,                                     */
 /*   otherwise ASN1_SUCCESS                                       */
 /******************************************************************/
-asn1_retCode
-_asn1_set_default_tag (ASN1_TYPE node)
+MHD__asn1_retCode
+MHD__asn1_set_default_tag (ASN1_TYPE node)
 {
   node_asn *p;
 
@@ -966,7 +966,7 @@ _asn1_set_default_tag (ASN1_TYPE node)
         {
           while (1)
             {
-              p = _asn1_find_up (p);
+              p = MHD__asn1_find_up (p);
               if (p == node)
                 {
                   p = NULL;
@@ -1027,7 +1027,7 @@ parse_version_string (const char *s, int *major, int *minor, int *micro)
 }
 
 /**
- * asn1_check_version - check for library version
+ * MHD__asn1_check_version - check for library version
  * @req_version: Required version number, or NULL.
  *
  * 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)
  *   run-time library does not meet the required version number.
  */
 const char *
-asn1_check_version (const char *req_version)
+MHD__asn1_check_version (const char *req_version)
 {
   const char *ver = LIBTASN1_VERSION;
   int my_major, my_minor, my_micro;

+ 20 - 20
src/daemon/https/minitasn1/parser_aux.h

@@ -6,45 +6,45 @@
 /***************************************/
 /*  Functions used by ASN.1 parser     */
 /***************************************/
-node_asn *_asn1_add_node (unsigned int type);
+node_asn *MHD__asn1_add_node (unsigned int type);
 
-node_asn *_asn1_set_value (node_asn * node, const void *value,
+node_asn *MHD__asn1_set_value (node_asn * node, const void *value,
                            unsigned int len);
 
-node_asn *_asn1_set_name (node_asn * node, const char *name);
+node_asn *MHD__asn1_set_name (node_asn * node, const char *name);
 
-node_asn *_asn1_set_right (node_asn * node, node_asn * right);
+node_asn *MHD__asn1_set_right (node_asn * node, node_asn * right);
 
-node_asn *_asn1_get_right (node_asn * node);
+node_asn *MHD__asn1_get_right (node_asn * node);
 
-node_asn *_asn1_get_last_right (node_asn * node);
+node_asn *MHD__asn1_get_last_right (node_asn * node);
 
-node_asn *_asn1_set_down (node_asn * node, node_asn * down);
+node_asn *MHD__asn1_set_down (node_asn * node, node_asn * down);
 
-char *_asn1_get_name (node_asn * node);
+char *MHD__asn1_get_name (node_asn * node);
 
-node_asn *_asn1_get_down (node_asn * node);
+node_asn *MHD__asn1_get_down (node_asn * node);
 
-node_asn *_asn1_mod_type (node_asn * node, unsigned int value);
+node_asn *MHD__asn1_mod_type (node_asn * node, unsigned int value);
 
-void _asn1_remove_node (node_asn * node);
+void MHD__asn1_remove_node (node_asn * node);
 
-void _asn1_delete_list (void);
+void MHD__asn1_delete_list (void);
 
-void _asn1_delete_list_and_nodes (void);
+void MHD__asn1_delete_list_and_nodes (void);
 
-char *_asn1_ltostr (long v, char *str);
+char *MHD__asn1_ltostr (long v, char *str);
 
-node_asn *_asn1_find_up (node_asn * node);
+node_asn *MHD__asn1_find_up (node_asn * node);
 
-asn1_retCode _asn1_change_integer_value (ASN1_TYPE node);
+MHD__asn1_retCode MHD__asn1_change_integer_value (ASN1_TYPE node);
 
-asn1_retCode _asn1_expand_object_id (ASN1_TYPE node);
+MHD__asn1_retCode MHD__asn1_expand_object_id (ASN1_TYPE node);
 
-asn1_retCode _asn1_type_set_config (ASN1_TYPE node);
+MHD__asn1_retCode MHD__asn1_type_set_config (ASN1_TYPE node);
 
-asn1_retCode _asn1_check_identifier (ASN1_TYPE node);
+MHD__asn1_retCode MHD__asn1_check_identifier (ASN1_TYPE node);
 
-asn1_retCode _asn1_set_default_tag (ASN1_TYPE node);
+MHD__asn1_retCode MHD__asn1_set_default_tag (ASN1_TYPE node);
 
 #endif

+ 121 - 121
src/daemon/https/minitasn1/structure.c

@@ -35,11 +35,11 @@
 #include <gstr.h>
 
 
-extern char _asn1_identifierMissing[];
+extern char MHD__asn1_identifierMissing[];
 
 
 /******************************************************/
-/* Function : _asn1_add_node_only                     */
+/* Function : MHD__asn1_add_node_only                     */
 /* Description: creates a new NODE_ASN element.       */
 /* Parameters:                                        */
 /*   type: type of the new element (see TYPE_         */
@@ -47,11 +47,11 @@ extern char _asn1_identifierMissing[];
 /* Return: pointer to the new element.                */
 /******************************************************/
 node_asn *
-_asn1_add_node_only (unsigned int type)
+MHD__asn1_add_node_only (unsigned int type)
 {
   node_asn *punt;
 
-  punt = (node_asn *) _asn1_calloc (1, sizeof (node_asn));
+  punt = (node_asn *) MHD__asn1_calloc (1, sizeof (node_asn));
   if (punt == NULL)
     return NULL;
 
@@ -62,7 +62,7 @@ _asn1_add_node_only (unsigned int type)
 
 
 /******************************************************************/
-/* Function : _asn1_find_left                                     */
+/* Function : MHD__asn1_find_left                                     */
 /* Description: returns the NODE_ASN element with RIGHT field that*/
 /*              points the element NODE.                          */
 /* Parameters:                                                    */
@@ -70,7 +70,7 @@ _asn1_add_node_only (unsigned int type)
 /* Return: NULL if not found.                                     */
 /******************************************************************/
 node_asn *
-_asn1_find_left (node_asn * node)
+MHD__asn1_find_left (node_asn * node)
 {
   if ((node == NULL) || (node->left == NULL) || (node->left->down == node))
     return NULL;
@@ -79,8 +79,8 @@ _asn1_find_left (node_asn * node)
 }
 
 
-asn1_retCode
-_asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
+MHD__asn1_retCode
+MHD__asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
                                char *vector_name)
 {
   FILE *file;
@@ -136,7 +136,7 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
         {
           while (1)
             {
-              p = _asn1_find_up (p);
+              p = MHD__asn1_find_up (p);
               if (p == pointer)
                 {
                   p = NULL;
@@ -160,14 +160,14 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
 
 
 /**
-  * asn1_array2tree - Creates the structures needed to manage the ASN1 definitions.
+  * MHD__asn1_array2tree - Creates the structures needed to manage the ASN1 definitions.
   * @array: specify the array that contains ASN.1 declarations
   * @definitions: return the pointer to the structure created by
   *   *ARRAY ASN.1 declarations
   * @errorDescription: return the error description.
   *
   * Creates the structures needed to manage the ASN.1 definitions.
-  * @array is a vector created by asn1_parser2array().
+  * @array is a vector created by MHD__asn1_parser2array().
   *
   * Returns:
   *
@@ -180,14 +180,14 @@ _asn1_create_static_structure (ASN1_TYPE pointer, char *output_file_name,
   *
   * ASN1_ARRAY_ERROR: The array pointed by @array is wrong.
   **/
-asn1_retCode
-asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
+MHD__asn1_retCode
+MHD__asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
                  char *errorDescription)
 {
   node_asn *p, *p_last = NULL;
   unsigned long k;
   int move;
-  asn1_retCode result;
+  MHD__asn1_retCode result;
 
 
   if (*definitions != ASN1_TYPE_EMPTY)
@@ -198,19 +198,19 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
   k = 0;
   while (array[k].value || array[k].type || array[k].name)
     {
-      p = _asn1_add_node (array[k].type & (~CONST_DOWN));
+      p = MHD__asn1_add_node (array[k].type & (~CONST_DOWN));
       if (array[k].name)
-        _asn1_set_name (p, array[k].name);
+        MHD__asn1_set_name (p, array[k].name);
       if (array[k].value)
-        _asn1_set_value (p, array[k].value, strlen (array[k].value) + 1);
+        MHD__asn1_set_value (p, array[k].value, strlen (array[k].value) + 1);
 
       if (*definitions == NULL)
         *definitions = p;
 
       if (move == DOWN)
-        _asn1_set_down (p_last, p);
+        MHD__asn1_set_down (p_last, p);
       else if (move == RIGHT)
-        _asn1_set_right (p_last, p);
+        MHD__asn1_set_right (p_last, p);
 
       p_last = p;
 
@@ -225,7 +225,7 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
               if (p_last == *definitions)
                 break;
 
-              p_last = _asn1_find_up (p_last);
+              p_last = MHD__asn1_find_up (p_last);
 
               if (p_last == NULL)
                 break;
@@ -243,11 +243,11 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
 
   if (p_last == *definitions)
     {
-      result = _asn1_check_identifier (*definitions);
+      result = MHD__asn1_check_identifier (*definitions);
       if (result == ASN1_SUCCESS)
         {
-          _asn1_change_integer_value (*definitions);
-          _asn1_expand_object_id (*definitions);
+          MHD__asn1_change_integer_value (*definitions);
+          MHD__asn1_expand_object_id (*definitions);
         }
     }
   else
@@ -260,7 +260,7 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
       if (result == ASN1_IDENTIFIER_NOT_FOUND)
         {
           Estrcpy (errorDescription, ":: identifier '");
-          Estrcat (errorDescription, _asn1_identifierMissing);
+          Estrcat (errorDescription, MHD__asn1_identifierMissing);
           Estrcat (errorDescription, "' not found");
         }
       else
@@ -269,17 +269,17 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
 
   if (result != ASN1_SUCCESS)
     {
-      _asn1_delete_list_and_nodes ();
+      MHD__asn1_delete_list_and_nodes ();
       *definitions = ASN1_TYPE_EMPTY;
     }
   else
-    _asn1_delete_list ();
+    MHD__asn1_delete_list ();
 
   return result;
 }
 
 /**
-  * asn1_delete_structure - Deletes the structure pointed by *ROOT.
+  * MHD__asn1_delete_structure - Deletes the structure pointed by *ROOT.
   * @structure: pointer to the structure that you want to delete.
   *
   * Deletes the structure *@structure.  At the end, *@structure is set
@@ -292,8 +292,8 @@ asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions,
   * ASN1_ELEMENT_NOT_FOUND: *@structure was ASN1_TYPE_EMPTY.
   *
   **/
-asn1_retCode
-asn1_delete_structure (ASN1_TYPE * structure)
+MHD__asn1_retCode
+MHD__asn1_delete_structure (ASN1_TYPE * structure)
 {
   node_asn *p, *p2, *p3;
 
@@ -312,19 +312,19 @@ asn1_delete_structure (ASN1_TYPE * structure)
           p2 = p->right;
           if (p != *structure)
             {
-              p3 = _asn1_find_up (p);
-              _asn1_set_down (p3, p2);
-              _asn1_remove_node (p);
+              p3 = MHD__asn1_find_up (p);
+              MHD__asn1_set_down (p3, p2);
+              MHD__asn1_remove_node (p);
               p = p3;
             }
           else
             {                   /* p==root */
-              p3 = _asn1_find_left (p);
+              p3 = MHD__asn1_find_left (p);
               if (!p3)
                 {
-                  p3 = _asn1_find_up (p);
+                  p3 = MHD__asn1_find_up (p);
                   if (p3)
-                    _asn1_set_down (p3, p2);
+                    MHD__asn1_set_down (p3, p2);
                   else
                     {
                       if (p->right)
@@ -332,8 +332,8 @@ asn1_delete_structure (ASN1_TYPE * structure)
                     }
                 }
               else
-                _asn1_set_right (p3, p2);
-              _asn1_remove_node (p);
+                MHD__asn1_set_right (p3, p2);
+              MHD__asn1_remove_node (p);
               p = NULL;
             }
         }
@@ -346,7 +346,7 @@ asn1_delete_structure (ASN1_TYPE * structure)
 
 
 /**
-  * asn1_delete_element - Deletes the element of a structure.
+  * MHD__asn1_delete_element - Deletes the element of a structure.
   * @structure: pointer to the structure that contains the element you
   *   want to delete.
   * @element_name: element's name you want to delete.
@@ -360,34 +360,34 @@ asn1_delete_structure (ASN1_TYPE * structure)
   * ASN1_ELEMENT_NOT_FOUND: The name element was not found.
   *
   **/
-asn1_retCode
-asn1_delete_element (ASN1_TYPE structure, const char *element_name)
+MHD__asn1_retCode
+MHD__asn1_delete_element (ASN1_TYPE structure, const char *element_name)
 {
   node_asn *p2, *p3, *source_node;
 
-  source_node = asn1_find_node (structure, element_name);
+  source_node = MHD__asn1_find_node (structure, element_name);
 
   if (source_node == ASN1_TYPE_EMPTY)
     return ASN1_ELEMENT_NOT_FOUND;
 
   p2 = source_node->right;
-  p3 = _asn1_find_left (source_node);
+  p3 = MHD__asn1_find_left (source_node);
   if (!p3)
     {
-      p3 = _asn1_find_up (source_node);
+      p3 = MHD__asn1_find_up (source_node);
       if (p3)
-        _asn1_set_down (p3, p2);
+        MHD__asn1_set_down (p3, p2);
       else if (source_node->right)
         source_node->right->left = NULL;
     }
   else
-    _asn1_set_right (p3, p2);
+    MHD__asn1_set_right (p3, p2);
 
-  return asn1_delete_structure (&source_node);
+  return MHD__asn1_delete_structure (&source_node);
 }
 
 node_asn *
-_asn1_copy_structure3 (node_asn * source_node)
+MHD__asn1_copy_structure3 (node_asn * source_node)
 {
   node_asn *dest_node, *p_s, *p_d, *p_d_prev;
   int move;
@@ -395,7 +395,7 @@ _asn1_copy_structure3 (node_asn * source_node)
   if (source_node == NULL)
     return NULL;
 
-  dest_node = _asn1_add_node_only (source_node->type);
+  dest_node = MHD__asn1_add_node_only (source_node->type);
 
   p_s = source_node;
   p_d = dest_node;
@@ -407,9 +407,9 @@ _asn1_copy_structure3 (node_asn * source_node)
       if (move != UP)
         {
           if (p_s->name)
-            _asn1_set_name (p_d, p_s->name);
+            MHD__asn1_set_name (p_d, p_s->name);
           if (p_s->value)
-            _asn1_set_value (p_d, p_s->value, p_s->value_len);
+            MHD__asn1_set_value (p_d, p_s->value, p_s->value_len);
           move = DOWN;
         }
       else
@@ -421,8 +421,8 @@ _asn1_copy_structure3 (node_asn * source_node)
             {
               p_s = p_s->down;
               p_d_prev = p_d;
-              p_d = _asn1_add_node_only (p_s->type);
-              _asn1_set_down (p_d_prev, p_d);
+              p_d = MHD__asn1_add_node_only (p_s->type);
+              MHD__asn1_set_down (p_d_prev, p_d);
             }
           else
             move = RIGHT;
@@ -437,16 +437,16 @@ _asn1_copy_structure3 (node_asn * source_node)
             {
               p_s = p_s->right;
               p_d_prev = p_d;
-              p_d = _asn1_add_node_only (p_s->type);
-              _asn1_set_right (p_d_prev, p_d);
+              p_d = MHD__asn1_add_node_only (p_s->type);
+              MHD__asn1_set_right (p_d_prev, p_d);
             }
           else
             move = UP;
         }
       if (move == UP)
         {
-          p_s = _asn1_find_up (p_s);
-          p_d = _asn1_find_up (p_d);
+          p_s = MHD__asn1_find_up (p_s);
+          p_d = MHD__asn1_find_up (p_d);
         }
     }
   while (p_s != source_node);
@@ -456,19 +456,19 @@ _asn1_copy_structure3 (node_asn * source_node)
 
 
 node_asn *
-_asn1_copy_structure2 (node_asn * root, const char *source_name)
+MHD__asn1_copy_structure2 (node_asn * root, const char *source_name)
 {
   node_asn *source_node;
 
-  source_node = asn1_find_node (root, source_name);
+  source_node = MHD__asn1_find_node (root, source_name);
 
-  return _asn1_copy_structure3 (source_node);
+  return MHD__asn1_copy_structure3 (source_node);
 
 }
 
 
-asn1_retCode
-_asn1_type_choice_config (node_asn * node)
+MHD__asn1_retCode
+MHD__asn1_type_choice_config (node_asn * node)
 {
   node_asn *p, *p2, *p3, *p4;
   int move, tlen;
@@ -491,19 +491,19 @@ _asn1_type_choice_config (node_asn * node)
                   if (type_field (p2->type) != TYPE_TAG)
                     {
                       p2->type |= CONST_TAG;
-                      p3 = _asn1_find_left (p2);
+                      p3 = MHD__asn1_find_left (p2);
                       while (p3)
                         {
                           if (type_field (p3->type) == TYPE_TAG)
                             {
-                              p4 = _asn1_add_node_only (p3->type);
+                              p4 = MHD__asn1_add_node_only (p3->type);
                               tlen = strlen (p3->value);
                               if (tlen > 0)
-                                _asn1_set_value (p4, p3->value, tlen + 1);
-                              _asn1_set_right (p4, p2->down);
-                              _asn1_set_down (p2, p4);
+                                MHD__asn1_set_value (p4, p3->value, tlen + 1);
+                              MHD__asn1_set_right (p4, p2->down);
+                              MHD__asn1_set_down (p2, p4);
                             }
-                          p3 = _asn1_find_left (p3);
+                          p3 = MHD__asn1_find_left (p3);
                         }
                     }
                   p2 = p2->right;
@@ -514,7 +514,7 @@ _asn1_type_choice_config (node_asn * node)
                 {
                   p3 = p2->right;
                   if (type_field (p2->type) == TYPE_TAG)
-                    asn1_delete_structure (&p2);
+                    MHD__asn1_delete_structure (&p2);
                   p2 = p3;
                 }
             }
@@ -545,15 +545,15 @@ _asn1_type_choice_config (node_asn * node)
             move = UP;
         }
       if (move == UP)
-        p = _asn1_find_up (p);
+        p = MHD__asn1_find_up (p);
     }
 
   return ASN1_SUCCESS;
 }
 
 
-asn1_retCode
-_asn1_expand_identifier (node_asn ** node, node_asn * root)
+MHD__asn1_retCode
+MHD__asn1_expand_identifier (node_asn ** node, node_asn * root)
 {
   node_asn *p, *p2, *p3;
   char name2[MAX_NAME_SIZE + 2];
@@ -571,15 +571,15 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
         {
           if (type_field (p->type) == TYPE_IDENTIFIER)
             {
-              _asn1_str_cpy (name2, sizeof (name2), root->name);
-              _asn1_str_cat (name2, sizeof (name2), ".");
-              _asn1_str_cat (name2, sizeof (name2), p->value);
-              p2 = _asn1_copy_structure2 (root, name2);
+              MHD__asn1_str_cpy (name2, sizeof (name2), root->name);
+              MHD__asn1_str_cat (name2, sizeof (name2), ".");
+              MHD__asn1_str_cat (name2, sizeof (name2), p->value);
+              p2 = MHD__asn1_copy_structure2 (root, name2);
               if (p2 == NULL)
                 {
                   return ASN1_IDENTIFIER_NOT_FOUND;
                 }
-              _asn1_set_name (p2, p->name);
+              MHD__asn1_set_name (p2, p->name);
               p2->right = p->right;
               p2->left = p->left;
               if (p->right)
@@ -589,18 +589,18 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
                 {
                   while (p3->right)
                     p3 = p3->right;
-                  _asn1_set_right (p3, p2->down);
-                  _asn1_set_down (p2, p->down);
+                  MHD__asn1_set_right (p3, p2->down);
+                  MHD__asn1_set_down (p2, p->down);
                 }
 
-              p3 = _asn1_find_left (p);
+              p3 = MHD__asn1_find_left (p);
               if (p3)
-                _asn1_set_right (p3, p2);
+                MHD__asn1_set_right (p3, p2);
               else
                 {
-                  p3 = _asn1_find_up (p);
+                  p3 = MHD__asn1_find_up (p);
                   if (p3)
-                    _asn1_set_down (p3, p2);
+                    MHD__asn1_set_down (p3, p2);
                   else
                     {
                       p2->left = NULL;
@@ -622,7 +622,7 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
 
               if (p == *node)
                 *node = p2;
-              _asn1_remove_node (p);
+              MHD__asn1_remove_node (p);
               p = p2;
               move = DOWN;
               continue;
@@ -654,7 +654,7 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
             move = UP;
         }
       if (move == UP)
-        p = _asn1_find_up (p);
+        p = MHD__asn1_find_up (p);
     }
 
   return ASN1_SUCCESS;
@@ -662,7 +662,7 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
 
 
 /**
-  * asn1_create_element - Creates a structure of type SOURCE_NAME.
+  * MHD__asn1_create_element - Creates a structure of type SOURCE_NAME.
   * @definitions: pointer to the structure returned by "parser_asn1" function
   * @source_name: the name of the type of the new structure (must be
   *   inside p_structure).
@@ -671,7 +671,7 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
   * Creates a structure of type @source_name.  Example using
   *  "pkix.asn":
   *
-  * rc = asn1_create_structure(cert_def, "PKIX1.Certificate",
+  * rc = MHD__asn1_create_structure(cert_def, "PKIX1.Certificate",
   * certptr);
   *
   * Returns:
@@ -680,22 +680,22 @@ _asn1_expand_identifier (node_asn ** node, node_asn * root)
   *
   * ASN1_ELEMENT_NOT_FOUND: SOURCE_NAME isn't known
   **/
-asn1_retCode
-asn1_create_element (ASN1_TYPE definitions, const char *source_name,
+MHD__asn1_retCode
+MHD__asn1_create_element (ASN1_TYPE definitions, const char *source_name,
                      ASN1_TYPE * element)
 {
   node_asn *dest_node;
   int res;
 
-  dest_node = _asn1_copy_structure2 (definitions, source_name);
+  dest_node = MHD__asn1_copy_structure2 (definitions, source_name);
 
   if (dest_node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
 
-  _asn1_set_name (dest_node, "");
+  MHD__asn1_set_name (dest_node, "");
 
-  res = _asn1_expand_identifier (&dest_node, definitions);
-  _asn1_type_choice_config (dest_node);
+  res = MHD__asn1_expand_identifier (&dest_node, definitions);
+  MHD__asn1_type_choice_config (dest_node);
 
   *element = dest_node;
 
@@ -704,7 +704,7 @@ asn1_create_element (ASN1_TYPE definitions, const char *source_name,
 
 
 /**
-  * asn1_print_structure - Prints on the standard output the structure's tree
+  * MHD__asn1_print_structure - Prints on the standard output the structure's tree
   * @out: pointer to the output file (e.g. stdout).
   * @structure: pointer to the structure that you want to visit.
   * @name: an element of the structure
@@ -716,7 +716,7 @@ asn1_create_element (ASN1_TYPE definitions, const char *source_name,
   * from the @name element inside the structure @structure.
   **/
 void
-asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
+MHD__asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
                       int mode)
 {
   node_asn *p, *root;
@@ -725,7 +725,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
   if (out == NULL)
     return;
 
-  root = asn1_find_node (structure, name);
+  root = MHD__asn1_find_node (structure, name);
 
   if (root == NULL)
     return;
@@ -872,7 +872,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
               if (p->value)
                 {
                   len2 = -1;
-                  len = asn1_get_length_der (p->value, p->value_len, &len2);
+                  len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
                   fprintf (out, "  value:0x");
                   if (len > 0)
                     for (k = 0; k < len; k++)
@@ -883,7 +883,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
               if (p->value)
                 {
                   len2 = -1;
-                  len = asn1_get_length_der (p->value, p->value_len, &len2);
+                  len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
                   fprintf (out, "  value:0x");
                   if (len > 0)
                     for (k = 0; k < len; k++)
@@ -907,7 +907,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
               if (p->value)
                 {
                   len2 = -1;
-                  len = asn1_get_length_der (p->value, p->value_len, &len2);
+                  len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
                   if (len > 0)
                     {
                       fprintf (out, "  value(%i):",
@@ -921,7 +921,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
               if (p->value)
                 {
                   len2 = -1;
-                  len = asn1_get_length_der (p->value, p->value_len, &len2);
+                  len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
                   fprintf (out, "  value:");
                   if (len > 0)
                     for (k = 0; k < len; k++)
@@ -932,7 +932,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
               if (p->value)
                 {
                   len2 = -1;
-                  len = asn1_get_length_der (p->value, p->value_len, &len2);
+                  len = MHD__asn1_get_length_der (p->value, p->value_len, &len2);
                   fprintf (out, "  value:");
                   if (len > 0)
                     for (k = 0; k < len; k++)
@@ -947,7 +947,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
               if (p->value)
                 {
                   len3 = -1;
-                  len2 = asn1_get_length_der (p->value, p->value_len, &len3);
+                  len2 = MHD__asn1_get_length_der (p->value, p->value_len, &len3);
                   fprintf (out, "  value:");
                   if (len2 > 0)
                     for (k = 0; k < len2; k++)
@@ -1048,7 +1048,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
         {
           while (1)
             {
-              p = _asn1_find_up (p);
+              p = MHD__asn1_find_up (p);
               if (p == root)
                 {
                   p = NULL;
@@ -1068,7 +1068,7 @@ asn1_print_structure (FILE * out, ASN1_TYPE structure, const char *name,
 
 
 /**
-  * asn1_number_of_elements - Counts the number of elements of a structure.
+  * MHD__asn1_number_of_elements - Counts the number of elements of a structure.
   * @element: pointer to the root of an ASN1 structure.
   * @name: the name of a sub-structure of ROOT.
   * @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,
   *  ASN1_GENERIC_ERROR: Pointer num equal to NULL.
   *
   **/
-asn1_retCode
-asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
+MHD__asn1_retCode
+MHD__asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
 {
   node_asn *node, *p;
 
@@ -1095,7 +1095,7 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
 
   *num = 0;
 
-  node = asn1_find_node (element, name);
+  node = MHD__asn1_find_node (element, name);
   if (node == NULL)
     return ASN1_ELEMENT_NOT_FOUND;
 
@@ -1113,7 +1113,7 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
 
 
 /**
-  * asn1_find_structure_from_oid - Locate structure defined by a specific OID.
+  * MHD__asn1_find_structure_from_oid - Locate structure defined by a specific OID.
   * @definitions: ASN1 definitions
   * @oidValue: value of the OID to search (e.g. "1.2.3.4").
   *
@@ -1125,13 +1125,13 @@ asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num)
   *
   **/
 const char *
-asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
+MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
 {
   char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1];
   char value[MAX_NAME_SIZE];
   ASN1_TYPE p;
   int len;
-  asn1_retCode result;
+  MHD__asn1_retCode result;
 
   if ((definitions == ASN1_TYPE_EMPTY) || (oidValue == NULL))
     return NULL;                /* ASN1_ELEMENT_NOT_FOUND; */
@@ -1151,7 +1151,7 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
           strcat (name, p->name);
 
           len = MAX_NAME_SIZE;
-          result = asn1_read_value (definitions, name, value, &len);
+          result = MHD__asn1_read_value (definitions, name, value, &len);
 
           if ((result == ASN1_SUCCESS) && (!strcmp (oidValue, value)))
             {
@@ -1169,7 +1169,7 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
 }
 
 /**
- * asn1_copy_node:
+ * MHD__asn1_copy_node:
  * @dst: Destination ASN1_TYPE node.
  * @dst_name: Field name in destination node.
  * @src: Source ASN1_TYPE node.
@@ -1179,8 +1179,8 @@ asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue)
  *
  * Return value: Return ASN1_SUCCESS on success.
  **/
-asn1_retCode
-asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
+MHD__asn1_retCode
+MHD__asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
                 ASN1_TYPE src, const char *src_name)
 {
 /* FIXME: rewrite using copy_structure().
@@ -1191,31 +1191,31 @@ asn1_copy_node (ASN1_TYPE dst, const char *dst_name,
   void *data = NULL;
   int size = 0;
 
-  result = asn1_der_coding (src, src_name, NULL, &size, NULL);
+  result = MHD__asn1_der_coding (src, src_name, NULL, &size, NULL);
   if (result != ASN1_MEM_ERROR)
     return result;
 
-  data = _asn1_malloc (size);
+  data = MHD__asn1_malloc (size);
   if (data == NULL)
     return ASN1_MEM_ERROR;
 
-  result = asn1_der_coding (src, src_name, data, &size, NULL);
+  result = MHD__asn1_der_coding (src, src_name, data, &size, NULL);
   if (result != ASN1_SUCCESS)
     {
-      _asn1_free (data);
+      MHD__asn1_free (data);
       return result;
     }
 
-  dst_node = asn1_find_node (dst, dst_name);
+  dst_node = MHD__asn1_find_node (dst, dst_name);
   if (dst_node == NULL)
     {
-      _asn1_free (data);
+      MHD__asn1_free (data);
       return ASN1_ELEMENT_NOT_FOUND;
     }
 
-  result = asn1_der_decoding (&dst_node, data, size, NULL);
+  result = MHD__asn1_der_decoding (&dst_node, data, size, NULL);
 
-  _asn1_free (data);
+  MHD__asn1_free (data);
 
   return result;
 }

+ 5 - 5
src/daemon/https/minitasn1/structure.h

@@ -8,16 +8,16 @@
 #ifndef _STRUCTURE_H
 #define _STRUCTURE_H
 
-asn1_retCode _asn1_create_static_structure (node_asn * pointer,
+MHD__asn1_retCode MHD__asn1_create_static_structure (node_asn * pointer,
                                             char *output_file_name,
                                             char *vector_name);
 
-node_asn *_asn1_copy_structure3 (node_asn * source_node);
+node_asn *MHD__asn1_copy_structure3 (node_asn * source_node);
 
-node_asn *_asn1_copy_structure2 (node_asn * root, const char *source_name);
+node_asn *MHD__asn1_copy_structure2 (node_asn * root, const char *source_name);
 
-node_asn *_asn1_add_node_only (unsigned int type);
+node_asn *MHD__asn1_add_node_only (unsigned int type);
 
-node_asn *_asn1_find_left (node_asn * node);
+node_asn *MHD__asn1_find_left (node_asn * node);
 
 #endif

+ 38 - 38
src/daemon/https/tls/auth_anon.c

@@ -40,52 +40,52 @@
 #include <gnutls_state.h>
 #include <auth_dh_common.h>
 
-static int mhd_gtls_gen_anon_server_kx (mhd_gtls_session_t, opaque **);
-static int mhd_gtls_proc_anon_client_kx (mhd_gtls_session_t, opaque *,
+static int MHD_gtls_gen_anon_server_kx (MHD_gtls_session_t, opaque **);
+static int MHD_gtls_proc_anon_client_kx (MHD_gtls_session_t, opaque *,
                                          size_t);
-static int mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t, opaque *,
+static int MHD_gtls_proc_anon_server_kx (MHD_gtls_session_t, opaque *,
                                          size_t);
 
-const mhd_gtls_mod_auth_st mhd_gtls_anon_auth_struct = {
+const MHD_gtls_mod_auth_st MHD_gtls_anon_auth_struct = {
   "ANON",
   NULL,
   NULL,
-  mhd_gtls_gen_anon_server_kx,
-  mhd_gtls_gen_dh_common_client_kx,     /* this can be shared */
+  MHD_gtls_gen_anon_server_kx,
+  MHD_gtls_gen_dh_common_client_kx,     /* this can be shared */
   NULL,
   NULL,
 
   NULL,
   NULL,                         /* certificate */
-  mhd_gtls_proc_anon_server_kx,
-  mhd_gtls_proc_anon_client_kx,
+  MHD_gtls_proc_anon_server_kx,
+  MHD_gtls_proc_anon_client_kx,
   NULL,
   NULL
 };
 
 static int
-mhd_gtls_gen_anon_server_kx (mhd_gtls_session_t session, opaque ** data)
+MHD_gtls_gen_anon_server_kx (MHD_gtls_session_t session, opaque ** data)
 {
   mpi_t g, p;
   const mpi_t *mpis;
   int ret;
-  mhd_gtls_dh_params_t dh_params;
-  mhd_gtls_anon_server_credentials_t cred;
+  MHD_gtls_dh_params_t dh_params;
+  MHD_gtls_anon_server_credentials_t cred;
 
-  cred = (mhd_gtls_anon_server_credentials_t)
-    mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
+  cred = (MHD_gtls_anon_server_credentials_t)
+    MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
   if (cred == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
     }
 
   dh_params =
-    mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
-  mpis = mhd_gtls_dh_params_to_mpi (dh_params);
+    MHD_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
+  mpis = MHD_gtls_dh_params_to_mpi (dh_params);
   if (mpis == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
     }
 
@@ -93,19 +93,19 @@ mhd_gtls_gen_anon_server_kx (mhd_gtls_session_t session, opaque ** data)
   g = mpis[1];
 
   if ((ret =
-       mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
+       MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
                                sizeof (anon_auth_info_st), 1)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
-  mhd_gtls_dh_set_group (session, g, p);
+  MHD_gtls_dh_set_group (session, g, p);
 
-  ret = mhd_gtls_dh_common_print_server_kx (session, g, p, data, 0);
+  ret = MHD_gtls_dh_common_print_server_kx (session, g, p, data, 0);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
     }
 
   return ret;
@@ -113,46 +113,46 @@ mhd_gtls_gen_anon_server_kx (mhd_gtls_session_t session, opaque ** data)
 
 
 static int
-mhd_gtls_proc_anon_client_kx (mhd_gtls_session_t session, opaque * data,
+MHD_gtls_proc_anon_client_kx (MHD_gtls_session_t session, opaque * data,
                               size_t _data_size)
 {
-  mhd_gtls_anon_server_credentials_t cred;
+  MHD_gtls_anon_server_credentials_t cred;
   int bits;
   int ret;
   mpi_t p, g;
-  mhd_gtls_dh_params_t dh_params;
+  MHD_gtls_dh_params_t dh_params;
   const mpi_t *mpis;
 
-  bits = mhd_gtls_dh_get_allowed_prime_bits (session);
+  bits = MHD_gtls_dh_get_allowed_prime_bits (session);
 
-  cred = (mhd_gtls_anon_server_credentials_t)
-    mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
+  cred = (MHD_gtls_anon_server_credentials_t)
+    MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_ANON, NULL);
   if (cred == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
     }
 
   dh_params =
-    mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
-  mpis = mhd_gtls_dh_params_to_mpi (dh_params);
+    MHD_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
+  mpis = MHD_gtls_dh_params_to_mpi (dh_params);
   if (mpis == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
     }
 
   p = mpis[0];
   g = mpis[1];
 
-  ret = mhd_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
+  ret = MHD_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
 
   return ret;
 
 }
 
 int
-mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t session, opaque * data,
+MHD_gtls_proc_anon_server_kx (MHD_gtls_session_t session, opaque * data,
                               size_t _data_size)
 {
 
@@ -160,17 +160,17 @@ mhd_gtls_proc_anon_server_kx (mhd_gtls_session_t session, opaque * data,
 
   /* set auth_info */
   if ((ret =
-       mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
+       MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_ANON,
                                sizeof (anon_auth_info_st), 1)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
-  ret = mhd_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
+  ret = MHD_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 

+ 8 - 8
src/daemon/https/tls/auth_anon.h

@@ -22,27 +22,27 @@
  *
  */
 
-/* this is not to be included by gnutls_anon.c */
+/* this is not to be included by MHD_gnutls_anon.c */
 #include <gnutls_auth.h>
 #include <auth_dh_common.h>
 
-typedef struct mhd_gtls_anon_server_credentials_st
+typedef struct MHD_gtls_anon_server_credentials_st
 {
-  mhd_gtls_dh_params_t dh_params;
+  MHD_gtls_dh_params_t dh_params;
   /* this callback is used to retrieve the DH or RSA
    * parameters.
    */
-  gnutls_params_function *params_func;
+  MHD_gnutls_params_function *params_func;
 } mhd_anon_server_credentials_st;
 
-typedef struct mhd_gtls_anon_client_credentials_st
+typedef struct MHD_gtls_anon_client_credentials_st
 {
   int dummy;
 } mhd_anon_client_credentials_st;
 
-typedef struct mhd_gtls_anon_auth_info_st
+typedef struct MHD_gtls_anon_auth_info_st
 {
-  mhd_gtls_dh_info_st dh;
+  MHD_gtls_dh_info_st dh;
 } *mhd_anon_auth_info_t;
 
-typedef struct mhd_gtls_anon_auth_info_st anon_auth_info_st;
+typedef struct MHD_gtls_anon_auth_info_st anon_auth_info_st;

Plik diff jest za duży
+ 185 - 185
src/daemon/https/tls/auth_cert.c


+ 42 - 42
src/daemon/https/tls/auth_cert.h

@@ -34,16 +34,16 @@
  * support a server that has multiple certificates
  */
 
-typedef struct mhd_gtls_certificate_credentials_st
+typedef struct MHD_gtls_certificate_credentials_st
 {
-  mhd_gtls_dh_params_t dh_params;
-  mhd_gtls_rsa_params_t rsa_params;
+  MHD_gtls_dh_params_t dh_params;
+  MHD_gtls_rsa_params_t rsa_params;
   /* this callback is used to retrieve the DH or RSA
    * parameters.
    */
-  gnutls_params_function *params_func;
+  MHD_gnutls_params_function *params_func;
 
-  gnutls_cert **cert_list;
+  MHD_gnutls_cert **cert_list;
   /* contains a list of a list of certificates.
    * eg (X509): [0] certificate1, certificate11, certificate111
    * (if more than one, one certificate certifies the one before)
@@ -57,7 +57,7 @@ typedef struct mhd_gtls_certificate_credentials_st
                                  * This is the same with the number of pkeys.
                                  */
 
-  gnutls_privkey *pkey;
+  MHD_gnutls_privkey *pkey;
   /* private keys. It contains ncerts private
    * keys. pkey[i] corresponds to certificate in
    * cert_list[i][0].
@@ -66,19 +66,19 @@ typedef struct mhd_gtls_certificate_credentials_st
   /* OpenPGP specific stuff */
 
 #ifndef KEYRING_HACK
-  gnutls_openpgp_keyring_t keyring;
+  MHD_gnutls_openpgp_keyring_t keyring;
 #else
-  gnutls_datum_t keyring;
+  MHD_gnutls_datum_t keyring;
   int keyring_format;
 #endif
 
   /* X509 specific stuff */
 
-  gnutls_x509_crt_t *x509_ca_list;
+  MHD_gnutls_x509_crt_t *x509_ca_list;
   unsigned x509_ncas;           /* number of CAs in the ca_list
                                  */
 
-  gnutls_x509_crl_t *x509_crl_list;
+  MHD_gnutls_x509_crl_t *x509_crl_list;
   unsigned x509_ncrls;          /* number of CRLs in the crl_list
                                  */
 
@@ -93,19 +93,19 @@ typedef struct mhd_gtls_certificate_credentials_st
    * This is better than
    * generating on every handshake.
    */
-  gnutls_datum_t x509_rdn_sequence;
+  MHD_gnutls_datum_t x509_rdn_sequence;
 
-  gnutls_certificate_client_retrieve_function *client_get_cert_callback;
-  gnutls_certificate_server_retrieve_function *server_get_cert_callback;
-} mhd_gtls_cert_credentials_st;
+  MHD_gnutls_certificate_client_retrieve_function *client_get_cert_callback;
+  MHD_gnutls_certificate_server_retrieve_function *server_get_cert_callback;
+} MHD_gtls_cert_credentials_st;
 
-typedef struct mhd_gtls_rsa_info_st
+typedef struct MHD_gtls_rsa_info_st
 {
-  gnutls_datum_t modulus;
-  gnutls_datum_t exponent;
+  MHD_gnutls_datum_t modulus;
+  MHD_gnutls_datum_t exponent;
 } rsa_info_st;
 
-typedef struct mhd_gtls_cert_auth_info_st
+typedef struct MHD_gtls_cert_auth_info_st
 {
   int certificate_requested;    /* if the peer requested certificate
                                  * this is non zero;
@@ -114,46 +114,46 @@ typedef struct mhd_gtls_cert_auth_info_st
   /* These (dh/rsa) are just copies from the credentials_t structure.
    * They must be freed.
    */
-  mhd_gtls_dh_info_st dh;
+  MHD_gtls_dh_info_st dh;
   rsa_info_st rsa_export;
 
-  gnutls_datum_t *raw_certificate_list; /* holds the raw certificate of the
+  MHD_gnutls_datum_t *raw_certificate_list; /* holds the raw certificate of the
                                          * peer.
                                          */
   unsigned int ncerts;          /* holds the size of the list above */
 } *cert_auth_info_t;
 
-typedef struct mhd_gtls_cert_auth_info_st cert_auth_info_st;
+typedef struct MHD_gtls_cert_auth_info_st cert_auth_info_st;
 
-void mhd_gtls_free_rsa_info (rsa_info_st * rsa);
+void MHD_gtls_free_rsa_info (rsa_info_st * rsa);
 
 /* AUTH X509 functions */
-int mhd_gtls_gen_cert_server_certificate (mhd_gtls_session_t, opaque **);
-int mhd_gtls_gen_cert_client_certificate (mhd_gtls_session_t, opaque **);
-int mhd_gtls_gen_cert_client_cert_vrfy (mhd_gtls_session_t, opaque **);
-int mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t, opaque **);
-int mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t, opaque *, size_t);
-int mhd_gtls_proc_cert_client_cert_vrfy (mhd_gtls_session_t, opaque *,
+int MHD_gtls_gen_cert_server_certificate (MHD_gtls_session_t, opaque **);
+int MHD_gtls_gen_cert_client_certificate (MHD_gtls_session_t, opaque **);
+int MHD_gtls_gen_cert_client_cert_vrfy (MHD_gtls_session_t, opaque **);
+int MHD_gtls_gen_cert_server_cert_req (MHD_gtls_session_t, opaque **);
+int MHD_gtls_proc_cert_cert_req (MHD_gtls_session_t, opaque *, size_t);
+int MHD_gtls_proc_cert_client_cert_vrfy (MHD_gtls_session_t, opaque *,
                                          size_t);
-int mhd_gtls_proc_cert_server_certificate (mhd_gtls_session_t, opaque *,
+int MHD_gtls_proc_cert_server_certificate (MHD_gtls_session_t, opaque *,
                                            size_t);
-int mhd_gtls_get_selected_cert (mhd_gtls_session_t session,
-                                gnutls_cert ** apr_cert_list,
+int MHD_gtls_get_selected_cert (MHD_gtls_session_t session,
+                                MHD_gnutls_cert ** apr_cert_list,
                                 int *apr_cert_list_length,
-                                gnutls_privkey ** apr_pkey);
+                                MHD_gnutls_privkey ** apr_pkey);
 
-int mhd_gtls_server_select_cert (struct MHD_gtls_session_int *,
+int MHD_gtls_server_select_cert (struct MHD_gtls_session_int *,
                                  enum MHD_GNUTLS_PublicKeyAlgorithm);
-void mhd_gtls_selected_certs_deinit (mhd_gtls_session_t session);
-void mhd_gtls_selected_certs_set (mhd_gtls_session_t session,
-                                  gnutls_cert * certs, int ncerts,
-                                  gnutls_privkey * key, int need_free);
+void MHD_gtls_selected_certs_deinit (MHD_gtls_session_t session);
+void MHD_gtls_selected_certs_set (MHD_gtls_session_t session,
+                                  MHD_gnutls_cert * certs, int ncerts,
+                                  MHD_gnutls_privkey * key, int need_free);
 
-#define _gnutls_proc_cert_client_certificate mhd_gtls_proc_cert_server_certificate
+#define MHD__gnutls_proc_cert_client_certificate MHD_gtls_proc_cert_server_certificate
 
-mhd_gtls_rsa_params_t
-mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params,
-                                     gnutls_params_function * func,
-                                     mhd_gtls_session_t);
+MHD_gtls_rsa_params_t
+MHD_gtls_certificate_get_rsa_params (MHD_gtls_rsa_params_t rsa_params,
+                                     MHD_gnutls_params_function * func,
+                                     MHD_gtls_session_t);
 
 #endif

+ 71 - 71
src/daemon/https/tls/auth_dh_common.c

@@ -39,19 +39,19 @@
 #include <auth_dh_common.h>
 #include <gnutls_algorithms.h>
 
-/* Frees the mhd_gtls_dh_info_st structure.
+/* Frees the MHD_gtls_dh_info_st structure.
  */
 void
-mhd_gtls_free_dh_info (mhd_gtls_dh_info_st * dh)
+MHD_gtls_free_dh_info (MHD_gtls_dh_info_st * dh)
 {
   dh->secret_bits = 0;
-  _gnutls_free_datum (&dh->prime);
-  _gnutls_free_datum (&dh->generator);
-  _gnutls_free_datum (&dh->public_key);
+  MHD__gnutls_free_datum (&dh->prime);
+  MHD__gnutls_free_datum (&dh->generator);
+  MHD__gnutls_free_datum (&dh->public_key);
 }
 
 int
-mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
+MHD_gtls_proc_dh_common_client_kx (MHD_gtls_session_t session,
                                    opaque * data, size_t _data_size,
                                    mpi_t g, mpi_t p)
 {
@@ -62,33 +62,33 @@ mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
 
 
   DECR_LEN (data_size, 2);
-  n_Y = mhd_gtls_read_uint16 (&data[0]);
+  n_Y = MHD_gtls_read_uint16 (&data[0]);
   _n_Y = n_Y;
 
   DECR_LEN (data_size, n_Y);
-  if (mhd_gtls_mpi_scan_nz (&session->key->client_Y, &data[2], &_n_Y))
+  if (MHD_gtls_mpi_scan_nz (&session->key->client_Y, &data[2], &_n_Y))
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
 
-  mhd_gtls_dh_set_peer_public (session, session->key->client_Y);
+  MHD_gtls_dh_set_peer_public (session, session->key->client_Y);
 
   session->key->KEY =
-    mhd_gtls_calc_dh_key (session->key->client_Y, session->key->dh_secret, p);
+    MHD_gtls_calc_dh_key (session->key->client_Y, session->key->dh_secret, p);
 
   if (session->key->KEY == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
-  mhd_gtls_mpi_release (&session->key->client_Y);
-  mhd_gtls_mpi_release (&session->key->dh_secret);
+  MHD_gtls_mpi_release (&session->key->client_Y);
+  MHD_gtls_mpi_release (&session->key->dh_secret);
 
-  ret = mhd_gtls_mpi_dprint (&session->key->key, session->key->KEY);
+  ret = MHD_gtls_mpi_dprint (&session->key->key, session->key->KEY);
 
-  mhd_gtls_mpi_release (&session->key->KEY);
+  MHD_gtls_mpi_release (&session->key->KEY);
 
   if (ret < 0)
     {
@@ -99,7 +99,7 @@ mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
 }
 
 int
-mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t session, opaque ** data)
+MHD_gtls_gen_dh_common_client_kx (MHD_gtls_session_t session, opaque ** data)
 {
   mpi_t x = NULL, X = NULL;
   size_t n_X;
@@ -107,69 +107,69 @@ mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t session, opaque ** data)
 
   *data = NULL;
 
-  X = mhd_gtls_calc_dh_secret (&x, session->key->client_g,
+  X = MHD_gtls_calc_dh_secret (&x, session->key->client_g,
                                session->key->client_p);
   if (X == NULL || x == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       ret = GNUTLS_E_MEMORY_ERROR;
       goto error;
     }
 
-  mhd_gtls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x));
+  MHD_gtls_dh_set_secret_bits (session, MHD__gnutls_mpi_get_nbits (x));
 
-  mhd_gtls_mpi_print (NULL, &n_X, X);
-  (*data) = gnutls_malloc (n_X + 2);
+  MHD_gtls_mpi_print (NULL, &n_X, X);
+  (*data) = MHD_gnutls_malloc (n_X + 2);
   if (*data == NULL)
     {
       ret = GNUTLS_E_MEMORY_ERROR;
       goto error;
     }
 
-  mhd_gtls_mpi_print (&(*data)[2], &n_X, X);
-  mhd_gtls_mpi_release (&X);
+  MHD_gtls_mpi_print (&(*data)[2], &n_X, X);
+  MHD_gtls_mpi_release (&X);
 
-  mhd_gtls_write_uint16 (n_X, &(*data)[0]);
+  MHD_gtls_write_uint16 (n_X, &(*data)[0]);
 
   /* calculate the key after calculating the message */
   session->key->KEY =
-    mhd_gtls_calc_dh_key (session->key->client_Y, x, session->key->client_p);
+    MHD_gtls_calc_dh_key (session->key->client_Y, x, session->key->client_p);
 
-  mhd_gtls_mpi_release (&x);
+  MHD_gtls_mpi_release (&x);
   if (session->key->KEY == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       ret = GNUTLS_E_MEMORY_ERROR;
       goto error;
     }
 
   /* THESE SHOULD BE DISCARDED */
-  mhd_gtls_mpi_release (&session->key->client_Y);
-  mhd_gtls_mpi_release (&session->key->client_p);
-  mhd_gtls_mpi_release (&session->key->client_g);
+  MHD_gtls_mpi_release (&session->key->client_Y);
+  MHD_gtls_mpi_release (&session->key->client_p);
+  MHD_gtls_mpi_release (&session->key->client_g);
 
-  ret = mhd_gtls_mpi_dprint (&session->key->key, session->key->KEY);
+  ret = MHD_gtls_mpi_dprint (&session->key->key, session->key->KEY);
 
-  mhd_gtls_mpi_release (&session->key->KEY);
+  MHD_gtls_mpi_release (&session->key->KEY);
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       goto error;
     }
 
   return n_X + 2;
 
 error:
-  mhd_gtls_mpi_release (&x);
-  mhd_gtls_mpi_release (&X);
-  gnutls_free (*data);
+  MHD_gtls_mpi_release (&x);
+  MHD_gtls_mpi_release (&X);
+  MHD_gnutls_free (*data);
   *data = NULL;
   return ret;
 }
 
 int
-mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
+MHD_gtls_proc_dh_common_server_kx (MHD_gtls_session_t session,
                                    opaque * data, size_t _data_size, int psk)
 {
   uint16_t n_Y, n_g, n_p;
@@ -185,13 +185,13 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
   if (psk != 0)
     {
       DECR_LEN (data_size, 2);
-      psk_size = mhd_gtls_read_uint16 (&data[i]);
+      psk_size = MHD_gtls_read_uint16 (&data[i]);
       DECR_LEN (data_size, psk_size);
       i += 2 + psk_size;
     }
 
   DECR_LEN (data_size, 2);
-  n_p = mhd_gtls_read_uint16 (&data[i]);
+  n_p = MHD_gtls_read_uint16 (&data[i]);
   i += 2;
 
   DECR_LEN (data_size, n_p);
@@ -199,7 +199,7 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
   i += n_p;
 
   DECR_LEN (data_size, 2);
-  n_g = mhd_gtls_read_uint16 (&data[i]);
+  n_g = MHD_gtls_read_uint16 (&data[i]);
   i += 2;
 
   DECR_LEN (data_size, n_g);
@@ -207,7 +207,7 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
   i += n_g;
 
   DECR_LEN (data_size, 2);
-  n_Y = mhd_gtls_read_uint16 (&data[i]);
+  n_Y = MHD_gtls_read_uint16 (&data[i]);
   i += 2;
 
   DECR_LEN (data_size, n_Y);
@@ -218,41 +218,41 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
   _n_g = n_g;
   _n_p = n_p;
 
-  if (mhd_gtls_mpi_scan_nz (&session->key->client_Y, data_Y, &_n_Y) != 0)
+  if (MHD_gtls_mpi_scan_nz (&session->key->client_Y, data_Y, &_n_Y) != 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
 
-  if (mhd_gtls_mpi_scan_nz (&session->key->client_g, data_g, &_n_g) != 0)
+  if (MHD_gtls_mpi_scan_nz (&session->key->client_g, data_g, &_n_g) != 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
-  if (mhd_gtls_mpi_scan_nz (&session->key->client_p, data_p, &_n_p) != 0)
+  if (MHD_gtls_mpi_scan_nz (&session->key->client_p, data_p, &_n_p) != 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
 
-  bits = mhd_gtls_dh_get_allowed_prime_bits (session);
+  bits = MHD_gtls_dh_get_allowed_prime_bits (session);
   if (bits < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return bits;
     }
 
-  if (_gnutls_mpi_get_nbits (session->key->client_p) < (size_t) bits)
+  if (MHD__gnutls_mpi_get_nbits (session->key->client_p) < (size_t) bits)
     {
       /* the prime used by the peer is not acceptable
        */
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_DH_PRIME_UNACCEPTABLE;
     }
 
-  mhd_gtls_dh_set_group (session, session->key->client_g,
+  MHD_gtls_dh_set_group (session, session->key->client_g,
                          session->key->client_p);
-  mhd_gtls_dh_set_peer_public (session, session->key->client_Y);
+  MHD_gtls_dh_set_peer_public (session, session->key->client_Y);
 
   ret = n_Y + n_p + n_g + 6;
   if (psk != 0)
@@ -264,7 +264,7 @@ mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
 /* If the psk flag is set, then an empty psk_identity_hint will
  * be inserted */
 int
-mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t session,
+MHD_gtls_dh_common_print_server_kx (MHD_gtls_session_t session,
                                     mpi_t g, mpi_t p, opaque ** data, int psk)
 {
   mpi_t x, X;
@@ -272,28 +272,28 @@ mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t session,
   int ret, data_size, pos;
   uint8_t *pdata;
 
-  X = mhd_gtls_calc_dh_secret (&x, g, p);
+  X = MHD_gtls_calc_dh_secret (&x, g, p);
   if (X == NULL || x == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
   session->key->dh_secret = x;
-  mhd_gtls_dh_set_secret_bits (session, _gnutls_mpi_get_nbits (x));
+  MHD_gtls_dh_set_secret_bits (session, MHD__gnutls_mpi_get_nbits (x));
 
-  mhd_gtls_mpi_print (NULL, &n_g, g);
-  mhd_gtls_mpi_print (NULL, &n_p, p);
-  mhd_gtls_mpi_print (NULL, &n_X, X);
+  MHD_gtls_mpi_print (NULL, &n_g, g);
+  MHD_gtls_mpi_print (NULL, &n_p, p);
+  MHD_gtls_mpi_print (NULL, &n_X, X);
 
   data_size = n_g + n_p + n_X + 6;
   if (psk != 0)
     data_size += 2;
 
-  (*data) = gnutls_malloc (data_size);
+  (*data) = MHD_gnutls_malloc (data_size);
   if (*data == NULL)
     {
-      mhd_gtls_mpi_release (&X);
+      MHD_gtls_mpi_release (&X);
       return GNUTLS_E_MEMORY_ERROR;
     }
 
@@ -302,24 +302,24 @@ mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t session,
 
   if (psk != 0)
     {
-      mhd_gtls_write_uint16 (0, &pdata[pos]);
+      MHD_gtls_write_uint16 (0, &pdata[pos]);
       pos += 2;
     }
 
-  mhd_gtls_mpi_print (&pdata[pos + 2], &n_p, p);
-  mhd_gtls_write_uint16 (n_p, &pdata[pos]);
+  MHD_gtls_mpi_print (&pdata[pos + 2], &n_p, p);
+  MHD_gtls_write_uint16 (n_p, &pdata[pos]);
 
   pos += n_p + 2;
 
-  mhd_gtls_mpi_print (&pdata[pos + 2], &n_g, g);
-  mhd_gtls_write_uint16 (n_g, &pdata[pos]);
+  MHD_gtls_mpi_print (&pdata[pos + 2], &n_g, g);
+  MHD_gtls_write_uint16 (n_g, &pdata[pos]);
 
   pos += n_g + 2;
 
-  mhd_gtls_mpi_print (&pdata[pos + 2], &n_X, X);
-  mhd_gtls_mpi_release (&X);
+  MHD_gtls_mpi_print (&pdata[pos + 2], &n_X, X);
+  MHD_gtls_mpi_release (&X);
 
-  mhd_gtls_write_uint16 (n_X, &pdata[pos]);
+  MHD_gtls_write_uint16 (n_X, &pdata[pos]);
 
   ret = data_size;
 

+ 9 - 9
src/daemon/https/tls/auth_dh_common.h

@@ -29,19 +29,19 @@ typedef struct
 {
   int secret_bits;
 
-  gnutls_datum_t prime;
-  gnutls_datum_t generator;
-  gnutls_datum_t public_key;
-} mhd_gtls_dh_info_st;
+  MHD_gnutls_datum_t prime;
+  MHD_gnutls_datum_t generator;
+  MHD_gnutls_datum_t public_key;
+} MHD_gtls_dh_info_st;
 
-void mhd_gtls_free_dh_info (mhd_gtls_dh_info_st * dh);
-int mhd_gtls_gen_dh_common_client_kx (mhd_gtls_session_t, opaque **);
-int mhd_gtls_proc_dh_common_client_kx (mhd_gtls_session_t session,
+void MHD_gtls_free_dh_info (MHD_gtls_dh_info_st * dh);
+int MHD_gtls_gen_dh_common_client_kx (MHD_gtls_session_t, opaque **);
+int MHD_gtls_proc_dh_common_client_kx (MHD_gtls_session_t session,
                                        opaque * data, size_t _data_size,
                                        mpi_t p, mpi_t g);
-int mhd_gtls_dh_common_print_server_kx (mhd_gtls_session_t, mpi_t g, mpi_t p,
+int MHD_gtls_dh_common_print_server_kx (MHD_gtls_session_t, mpi_t g, mpi_t p,
                                         opaque ** data, int psk);
-int mhd_gtls_proc_dh_common_server_kx (mhd_gtls_session_t session,
+int MHD_gtls_proc_dh_common_server_kx (MHD_gtls_session_t session,
                                        opaque * data, size_t _data_size,
                                        int psk);
 

+ 75 - 75
src/daemon/https/tls/auth_dhe.c

@@ -39,103 +39,103 @@
 #include <gnutls_state.h>
 #include <auth_dh_common.h>
 
-static int gen_dhe_server_kx (mhd_gtls_session_t, opaque **);
-static int proc_dhe_server_kx (mhd_gtls_session_t, opaque *, size_t);
-static int proc_dhe_client_kx (mhd_gtls_session_t, opaque *, size_t);
+static int gen_dhe_server_kx (MHD_gtls_session_t, opaque **);
+static int proc_dhe_server_kx (MHD_gtls_session_t, opaque *, size_t);
+static int proc_dhe_client_kx (MHD_gtls_session_t, opaque *, size_t);
 
-const mhd_gtls_mod_auth_st mhd_gtls_dhe_rsa_auth_struct = {
+const MHD_gtls_mod_auth_st MHD_gtls_dhe_rsa_auth_struct = {
   "DHE_RSA",
-  mhd_gtls_gen_cert_server_certificate,
-  mhd_gtls_gen_cert_client_certificate,
+  MHD_gtls_gen_cert_server_certificate,
+  MHD_gtls_gen_cert_client_certificate,
   gen_dhe_server_kx,
-  mhd_gtls_gen_dh_common_client_kx,
-  mhd_gtls_gen_cert_client_cert_vrfy,   /* gen client cert vrfy */
-  mhd_gtls_gen_cert_server_cert_req,    /* server cert request */
+  MHD_gtls_gen_dh_common_client_kx,
+  MHD_gtls_gen_cert_client_cert_vrfy,   /* gen client cert vrfy */
+  MHD_gtls_gen_cert_server_cert_req,    /* server cert request */
 
-  mhd_gtls_proc_cert_server_certificate,
-  _gnutls_proc_cert_client_certificate,
+  MHD_gtls_proc_cert_server_certificate,
+  MHD__gnutls_proc_cert_client_certificate,
   proc_dhe_server_kx,
   proc_dhe_client_kx,
-  mhd_gtls_proc_cert_client_cert_vrfy,  /* proc client cert vrfy */
-  mhd_gtls_proc_cert_cert_req   /* proc server cert request */
+  MHD_gtls_proc_cert_client_cert_vrfy,  /* proc client cert vrfy */
+  MHD_gtls_proc_cert_cert_req   /* proc server cert request */
 };
 
-const mhd_gtls_mod_auth_st mhd_gtls_dhe_dss_auth_struct = {
+const MHD_gtls_mod_auth_st MHD_gtls_dhe_dss_auth_struct = {
   "DHE_DSS",
-  mhd_gtls_gen_cert_server_certificate,
-  mhd_gtls_gen_cert_client_certificate,
+  MHD_gtls_gen_cert_server_certificate,
+  MHD_gtls_gen_cert_client_certificate,
   gen_dhe_server_kx,
-  mhd_gtls_gen_dh_common_client_kx,
-  mhd_gtls_gen_cert_client_cert_vrfy,   /* gen client cert vrfy */
-  mhd_gtls_gen_cert_server_cert_req,    /* server cert request */
+  MHD_gtls_gen_dh_common_client_kx,
+  MHD_gtls_gen_cert_client_cert_vrfy,   /* gen client cert vrfy */
+  MHD_gtls_gen_cert_server_cert_req,    /* server cert request */
 
-  mhd_gtls_proc_cert_server_certificate,
-  _gnutls_proc_cert_client_certificate,
+  MHD_gtls_proc_cert_server_certificate,
+  MHD__gnutls_proc_cert_client_certificate,
   proc_dhe_server_kx,
   proc_dhe_client_kx,
-  mhd_gtls_proc_cert_client_cert_vrfy,  /* proc client cert vrfy */
-  mhd_gtls_proc_cert_cert_req   /* proc server cert request */
+  MHD_gtls_proc_cert_client_cert_vrfy,  /* proc client cert vrfy */
+  MHD_gtls_proc_cert_cert_req   /* proc server cert request */
 };
 
 
 static int
-gen_dhe_server_kx (mhd_gtls_session_t session, opaque ** data)
+gen_dhe_server_kx (MHD_gtls_session_t session, opaque ** data)
 {
   mpi_t g, p;
   const mpi_t *mpis;
   int ret = 0, data_size;
   int bits;
-  gnutls_cert *apr_cert_list;
-  gnutls_privkey *apr_pkey;
+  MHD_gnutls_cert *apr_cert_list;
+  MHD_gnutls_privkey *apr_pkey;
   int apr_cert_list_length;
-  gnutls_datum_t signature, ddata;
-  mhd_gtls_cert_credentials_t cred;
-  mhd_gtls_dh_params_t dh_params;
+  MHD_gnutls_datum_t signature, ddata;
+  MHD_gtls_cert_credentials_t cred;
+  MHD_gtls_dh_params_t dh_params;
 
-  cred = (mhd_gtls_cert_credentials_t)
-    mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
+  cred = (MHD_gtls_cert_credentials_t)
+    MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
   if (cred == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
     }
 
-  bits = mhd_gtls_dh_get_allowed_prime_bits (session);
+  bits = MHD_gtls_dh_get_allowed_prime_bits (session);
 
   /* find the appropriate certificate */
   if ((ret =
-       mhd_gtls_get_selected_cert (session, &apr_cert_list,
+       MHD_gtls_get_selected_cert (session, &apr_cert_list,
                                    &apr_cert_list_length, &apr_pkey)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
   dh_params =
-    mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
-  mpis = mhd_gtls_dh_params_to_mpi (dh_params);
+    MHD_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
+  mpis = MHD_gtls_dh_params_to_mpi (dh_params);
   if (mpis == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
     }
 
   p = mpis[0];
   g = mpis[1];
 
-  if ((ret = mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
+  if ((ret = MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
                                      sizeof (cert_auth_info_st), 0)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
-  mhd_gtls_dh_set_group (session, g, p);
+  MHD_gtls_dh_set_group (session, g, p);
 
-  ret = mhd_gtls_dh_common_print_server_kx (session, g, p, data, 0);
+  ret = MHD_gtls_dh_common_print_server_kx (session, g, p, data, 0);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
   data_size = ret;
@@ -148,58 +148,58 @@ gen_dhe_server_kx (mhd_gtls_session_t session, opaque ** data)
   if (apr_cert_list_length > 0)
     {
       if ((ret =
-           mhd_gtls_tls_sign_params (session, &apr_cert_list[0],
+           MHD_gtls_tls_sign_params (session, &apr_cert_list[0],
                                      apr_pkey, &ddata, &signature)) < 0)
         {
-          gnutls_assert ();
-          gnutls_free (*data);
+          MHD_gnutls_assert ();
+          MHD_gnutls_free (*data);
           return ret;
         }
     }
   else
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return data_size;         /* do not put a signature - ILLEGAL! */
     }
 
-  *data = mhd_gtls_realloc_fast (*data, data_size + signature.size + 2);
+  *data = MHD_gtls_realloc_fast (*data, data_size + signature.size + 2);
   if (*data == NULL)
     {
-      _gnutls_free_datum (&signature);
-      gnutls_assert ();
+      MHD__gnutls_free_datum (&signature);
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
-  mhd_gtls_write_datum16 (&(*data)[data_size], signature);
+  MHD_gtls_write_datum16 (&(*data)[data_size], signature);
   data_size += signature.size + 2;
 
-  _gnutls_free_datum (&signature);
+  MHD__gnutls_free_datum (&signature);
 
   return data_size;
 }
 
 static int
-proc_dhe_server_kx (mhd_gtls_session_t session, opaque * data,
+proc_dhe_server_kx (MHD_gtls_session_t session, opaque * data,
                     size_t _data_size)
 {
   int sigsize;
-  gnutls_datum_t vparams, signature;
+  MHD_gnutls_datum_t vparams, signature;
   int ret;
-  cert_auth_info_t info = mhd_gtls_get_auth_info (session);
+  cert_auth_info_t info = MHD_gtls_get_auth_info (session);
   ssize_t data_size = _data_size;
-  gnutls_cert peer_cert;
+  MHD_gnutls_cert peer_cert;
 
   if (info == NULL || info->ncerts == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       /* we need this in order to get peer's certificate */
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
-  ret = mhd_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
+  ret = MHD_gtls_proc_dh_common_server_kx (session, data, _data_size, 0);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
@@ -209,29 +209,29 @@ proc_dhe_server_kx (mhd_gtls_session_t session, opaque * data,
   vparams.data = data;
 
   DECR_LEN (data_size, 2);
-  sigsize = mhd_gtls_read_uint16 (&data[vparams.size]);
+  sigsize = MHD_gtls_read_uint16 (&data[vparams.size]);
 
   DECR_LEN (data_size, sigsize);
   signature.data = &data[vparams.size + 2];
   signature.size = sigsize;
 
   if ((ret =
-       mhd_gtls_raw_cert_to_gcert (&peer_cert,
+       MHD_gtls_raw_cert_to_gcert (&peer_cert,
                                    session->security_parameters.cert_type,
                                    &info->raw_certificate_list[0],
                                    CERT_NO_COPY)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
   ret =
-    mhd_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
+    MHD_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
 
-  mhd_gtls_gcert_deinit (&peer_cert);
+  MHD_gtls_gcert_deinit (&peer_cert);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
@@ -241,36 +241,36 @@ proc_dhe_server_kx (mhd_gtls_session_t session, opaque * data,
 
 
 static int
-proc_dhe_client_kx (mhd_gtls_session_t session, opaque * data,
+proc_dhe_client_kx (MHD_gtls_session_t session, opaque * data,
                     size_t _data_size)
 {
-  mhd_gtls_cert_credentials_t cred;
+  MHD_gtls_cert_credentials_t cred;
   int ret;
   mpi_t p, g;
   const mpi_t *mpis;
-  mhd_gtls_dh_params_t dh_params;
+  MHD_gtls_dh_params_t dh_params;
 
-  cred = (mhd_gtls_cert_credentials_t)
-    mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
+  cred = (MHD_gtls_cert_credentials_t)
+    MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
   if (cred == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
     }
 
   dh_params =
-    mhd_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
-  mpis = mhd_gtls_dh_params_to_mpi (dh_params);
+    MHD_gtls_get_dh_params (cred->dh_params, cred->params_func, session);
+  mpis = MHD_gtls_dh_params_to_mpi (dh_params);
   if (mpis == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
     }
 
   p = mpis[0];
   g = mpis[1];
 
-  ret = mhd_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
+  ret = MHD_gtls_proc_dh_common_client_kx (session, data, _data_size, g, p);
 
   return ret;
 

+ 88 - 81
src/daemon/https/tls/auth_rsa.c

@@ -42,85 +42,85 @@
 #include <gnutls_x509.h>
 #include <gc.h>
 
-int _gnutls_gen_rsa_client_kx (mhd_gtls_session_t, opaque **);
-int _gnutls_proc_rsa_client_kx (mhd_gtls_session_t, opaque *, size_t);
+int MHD__gnutls_gen_rsa_client_kx (MHD_gtls_session_t, opaque **);
+int MHD__gnutls_proc_rsa_client_kx (MHD_gtls_session_t, opaque *, size_t);
 
-const mhd_gtls_mod_auth_st mhd_gtls_rsa_auth_struct = {
+const MHD_gtls_mod_auth_st MHD_gtls_rsa_auth_struct = {
   "RSA",
-  mhd_gtls_gen_cert_server_certificate,
-  mhd_gtls_gen_cert_client_certificate,
+  MHD_gtls_gen_cert_server_certificate,
+  MHD_gtls_gen_cert_client_certificate,
   NULL,                         /* gen server kx */
-  _gnutls_gen_rsa_client_kx,
-  mhd_gtls_gen_cert_client_cert_vrfy,   /* gen client cert vrfy */
-  mhd_gtls_gen_cert_server_cert_req,    /* server cert request */
+  MHD__gnutls_gen_rsa_client_kx,
+  MHD_gtls_gen_cert_client_cert_vrfy,   /* gen client cert vrfy */
+  MHD_gtls_gen_cert_server_cert_req,    /* server cert request */
 
-  mhd_gtls_proc_cert_server_certificate,
-  _gnutls_proc_cert_client_certificate,
+  MHD_gtls_proc_cert_server_certificate,
+  MHD__gnutls_proc_cert_client_certificate,
   NULL,                         /* proc server kx */
-  _gnutls_proc_rsa_client_kx,   /* proc client kx */
-  mhd_gtls_proc_cert_client_cert_vrfy,  /* proc client cert vrfy */
-  mhd_gtls_proc_cert_cert_req   /* proc server cert request */
+  MHD__gnutls_proc_rsa_client_kx,   /* proc client kx */
+  MHD_gtls_proc_cert_client_cert_vrfy,  /* proc client cert vrfy */
+  MHD_gtls_proc_cert_cert_req   /* proc server cert request */
 };
 
 /* This function reads the RSA parameters from peer's certificate;
  */
 int
-_gnutls_get_public_rsa_params (mhd_gtls_session_t session,
+MHD__gnutls_get_public_rsa_params (MHD_gtls_session_t session,
                                mpi_t params[MAX_PUBLIC_PARAMS_SIZE],
                                int *params_len)
 {
   int ret;
   cert_auth_info_t info;
-  gnutls_cert peer_cert;
+  MHD_gnutls_cert peer_cert;
   int i;
 
   /* normal non export case */
 
-  info = mhd_gtls_get_auth_info (session);
+  info = MHD_gtls_get_auth_info (session);
 
   if (info == NULL || info->ncerts == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
   ret =
-    mhd_gtls_raw_cert_to_gcert (&peer_cert,
+    MHD_gtls_raw_cert_to_gcert (&peer_cert,
                                 session->security_parameters.cert_type,
                                 &info->raw_certificate_list[0],
                                 CERT_ONLY_PUBKEY | CERT_NO_COPY);
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
 
   /* EXPORT case: */
-  if (mhd_gtls_cipher_suite_get_kx_algo
+  if (MHD_gtls_cipher_suite_get_kx_algo
       (&session->security_parameters.current_cipher_suite)
       == MHD_GNUTLS_KX_RSA_EXPORT
-      && _gnutls_mpi_get_nbits (peer_cert.params[0]) > 512)
+      && MHD__gnutls_mpi_get_nbits (peer_cert.params[0]) > 512)
     {
 
-      mhd_gtls_gcert_deinit (&peer_cert);
+      MHD_gtls_gcert_deinit (&peer_cert);
 
       if (session->key->rsa[0] == NULL || session->key->rsa[1] == NULL)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_INTERNAL_ERROR;
         }
 
       if (*params_len < 2)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_INTERNAL_ERROR;
         }
       *params_len = 2;
       for (i = 0; i < *params_len; i++)
         {
-          params[i] = _gnutls_mpi_copy (session->key->rsa[i]);
+          params[i] = MHD__gnutls_mpi_copy (session->key->rsa[i]);
         }
 
       return 0;
@@ -130,16 +130,16 @@ _gnutls_get_public_rsa_params (mhd_gtls_session_t session,
 
   if (*params_len < peer_cert.params_size)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
   *params_len = peer_cert.params_size;
 
   for (i = 0; i < *params_len; i++)
     {
-      params[i] = _gnutls_mpi_copy (peer_cert.params[i]);
+      params[i] = MHD__gnutls_mpi_copy (peer_cert.params[i]);
     }
-  mhd_gtls_gcert_deinit (&peer_cert);
+  MHD_gtls_gcert_deinit (&peer_cert);
 
   return 0;
 }
@@ -147,43 +147,43 @@ _gnutls_get_public_rsa_params (mhd_gtls_session_t session,
 /* This function reads the RSA parameters from the private key
  */
 int
-_gnutls_get_private_rsa_params (mhd_gtls_session_t session,
+MHD__gnutls_get_private_rsa_params (MHD_gtls_session_t session,
                                 mpi_t ** params, int *params_size)
 {
   int bits;
-  mhd_gtls_cert_credentials_t cred;
-  mhd_gtls_rsa_params_t rsa_params;
+  MHD_gtls_cert_credentials_t cred;
+  MHD_gtls_rsa_params_t rsa_params;
 
-  cred = (mhd_gtls_cert_credentials_t)
-    mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
+  cred = (MHD_gtls_cert_credentials_t)
+    MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
   if (cred == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
     }
 
   if (session->internals.selected_cert_list == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
     }
 
   bits =
-    _gnutls_mpi_get_nbits (session->internals.selected_cert_list[0].
+    MHD__gnutls_mpi_get_nbits (session->internals.selected_cert_list[0].
                            params[0]);
 
-  if (mhd_gtls_cipher_suite_get_kx_algo
+  if (MHD_gtls_cipher_suite_get_kx_algo
       (&session->security_parameters.current_cipher_suite)
       == MHD_GNUTLS_KX_RSA_EXPORT && bits > 512)
     {
 
       rsa_params =
-        mhd_gtls_certificate_get_rsa_params (cred->rsa_params,
+        MHD_gtls_certificate_get_rsa_params (cred->rsa_params,
                                              cred->params_func, session);
       /* EXPORT case: */
       if (rsa_params == NULL)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS;
         }
 
@@ -206,18 +206,18 @@ _gnutls_get_private_rsa_params (mhd_gtls_session_t session,
 }
 
 int
-_gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
+MHD__gnutls_proc_rsa_client_kx (MHD_gtls_session_t session, opaque * data,
                             size_t _data_size)
 {
-  gnutls_datum_t plaintext;
-  gnutls_datum_t ciphertext;
+  MHD_gnutls_datum_t plaintext;
+  MHD_gnutls_datum_t ciphertext;
   int ret, dsize;
   mpi_t *params;
   int params_len;
   int randomize_key = 0;
   ssize_t data_size = _data_size;
 
-  if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
+  if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
     {
       /* SSL 3.0
        */
@@ -230,24 +230,24 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
        */
       DECR_LEN (data_size, 2);
       ciphertext.data = &data[2];
-      dsize = mhd_gtls_read_uint16 (data);
+      dsize = MHD_gtls_read_uint16 (data);
 
       if (dsize != data_size)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
         }
       ciphertext.size = dsize;
     }
 
-  ret = _gnutls_get_private_rsa_params (session, &params, &params_len);
+  ret = MHD__gnutls_get_private_rsa_params (session, &params, &params_len);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
-  ret = mhd_gtls_pkcs1_rsa_decrypt (&plaintext, &ciphertext, params, params_len, 2);    /* btype==2 */
+  ret = MHD_gtls_pkcs1_rsa_decrypt (&plaintext, &ciphertext, params, params_len, 2);    /* btype==2 */
 
   if (ret < 0 || plaintext.size != TLS_MASTER_SIZE)
     {
@@ -255,8 +255,8 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
        * the peer. Just use a random key. (in order to avoid
        * attack against pkcs-1 formating).
        */
-      gnutls_assert ();
-      _gnutls_x509_log ("auth_rsa: Possible PKCS #1 format attack\n");
+      MHD_gnutls_assert ();
+      MHD__gnutls_x509_log ("auth_rsa: Possible PKCS #1 format attack\n");
       randomize_key = 1;
     }
   else
@@ -264,8 +264,8 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
       /* If the secret was properly formatted, then
        * check the version number.
        */
-      if (_gnutls_get_adv_version_major (session) != plaintext.data[0]
-          || _gnutls_get_adv_version_minor (session) != plaintext.data[1])
+      if (MHD__gnutls_get_adv_version_major (session) != plaintext.data[0]
+          || MHD__gnutls_get_adv_version_minor (session) != plaintext.data[1])
         {
           /* No error is returned here, if the version number check
            * fails. We proceed normally.
@@ -273,8 +273,8 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
            * "Attacking RSA-based sessions in SSL/TLS" by Vlastimil Klima,
            * Ondej Pokorny and Tomas Rosa.
            */
-          gnutls_assert ();
-          _gnutls_x509_log
+          MHD_gnutls_assert ();
+          MHD__gnutls_x509_log
             ("auth_rsa: Possible PKCS #1 version check format attack\n");
         }
     }
@@ -282,18 +282,18 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
   if (randomize_key != 0)
     {
       session->key->key.size = TLS_MASTER_SIZE;
-      session->key->key.data = gnutls_malloc (session->key->key.size);
+      session->key->key.data = MHD_gnutls_malloc (session->key->key.size);
       if (session->key->key.data == NULL)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_MEMORY_ERROR;
         }
 
       /* we do not need strong random numbers here.
        */
-      if (gc_nonce (session->key->key.data, session->key->key.size) != GC_OK)
+      if (MHD_gc_nonce (session->key->key.data, session->key->key.size) != GC_OK)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_RANDOM_FAILED;
         }
 
@@ -307,8 +307,8 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
   /* This is here to avoid the version check attack
    * discussed above.
    */
-  session->key->key.data[0] = _gnutls_get_adv_version_major (session);
-  session->key->key.data[1] = _gnutls_get_adv_version_minor (session);
+  session->key->key.data[0] = MHD__gnutls_get_adv_version_major (session);
+  session->key->key.data[1] = MHD__gnutls_get_adv_version_minor (session);
 
   return 0;
 }
@@ -318,46 +318,53 @@ _gnutls_proc_rsa_client_kx (mhd_gtls_session_t session, opaque * data,
 /* return RSA(random) using the peers public key
  */
 int
-_gnutls_gen_rsa_client_kx (mhd_gtls_session_t session, opaque ** data)
+MHD__gnutls_gen_rsa_client_kx (MHD_gtls_session_t session, opaque ** data)
 {
-  cert_auth_info_t auth = session->key->auth_info;
-  gnutls_datum_t sdata;         /* data to send */
+  cert_auth_info_t auth;
+  MHD_gnutls_datum_t sdata;         /* data to send */
   mpi_t params[MAX_PUBLIC_PARAMS_SIZE];
   int params_len = MAX_PUBLIC_PARAMS_SIZE;
   int ret, i;
   enum MHD_GNUTLS_Protocol ver;
 
+  if (session->key == NULL)
+    {
+      MHD_gnutls_assert ();
+      return GNUTLS_E_INSUFFICIENT_CREDENTIALS;  
+    }
+
+  auth = session->key->auth_info;
   if (auth == NULL)
     {
       /* this shouldn't have happened. The proc_certificate
        * function should have detected that.
        */
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
     }
 
   session->key->key.size = TLS_MASTER_SIZE;
-  session->key->key.data = gnutls_secure_malloc (session->key->key.size);
+  session->key->key.data = MHD_gnutls_secure_malloc (session->key->key.size);
 
   if (session->key->key.data == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
-  if (gc_pseudo_random (session->key->key.data,
+  if (MHD_gc_pseudo_random (session->key->key.data,
                         session->key->key.size) != GC_OK)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_RANDOM_FAILED;
     }
 
-  ver = mhd_gtls_get_adv_version (session);
+  ver = MHD_gtls_get_adv_version (session);
 
   if (session->internals.rsa_pms_version[0] == 0)
     {
-      session->key->key.data[0] = mhd_gtls_version_get_major (ver);
-      session->key->key.data[1] = mhd_gtls_version_get_minor (ver);
+      session->key->key.data[0] = MHD_gtls_version_get_major (ver);
+      session->key->key.data[1] = MHD_gtls_version_get_minor (ver);
     }
   else
     {                           /* use the version provided */
@@ -368,24 +375,24 @@ _gnutls_gen_rsa_client_kx (mhd_gtls_session_t session, opaque ** data)
   /* move RSA parameters to key (session).
    */
   if ((ret =
-       _gnutls_get_public_rsa_params (session, params, &params_len)) < 0)
+       MHD__gnutls_get_public_rsa_params (session, params, &params_len)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
   if ((ret =
-       mhd_gtls_pkcs1_rsa_encrypt (&sdata, &session->key->key,
+       MHD_gtls_pkcs1_rsa_encrypt (&sdata, &session->key->key,
                                    params, params_len, 2)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
   for (i = 0; i < params_len; i++)
-    mhd_gtls_mpi_release (&params[i]);
+    MHD_gtls_mpi_release (&params[i]);
 
-  if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
+  if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
     {
       /* SSL 3.0 */
       *data = sdata.data;
@@ -393,15 +400,15 @@ _gnutls_gen_rsa_client_kx (mhd_gtls_session_t session, opaque ** data)
     }
   else
     {                           /* TLS 1 */
-      *data = gnutls_malloc (sdata.size + 2);
+      *data = MHD_gnutls_malloc (sdata.size + 2);
       if (*data == NULL)
         {
-          _gnutls_free_datum (&sdata);
+          MHD__gnutls_free_datum (&sdata);
           return GNUTLS_E_MEMORY_ERROR;
         }
-      mhd_gtls_write_datum16 (*data, sdata);
+      MHD_gtls_write_datum16 (*data, sdata);
       ret = sdata.size + 2;
-      _gnutls_free_datum (&sdata);
+      MHD__gnutls_free_datum (&sdata);
       return ret;
     }
 

+ 79 - 79
src/daemon/https/tls/auth_rsa_export.c

@@ -43,105 +43,105 @@
 #include <gnutls_rsa_export.h>
 #include <gnutls_state.h>
 
-int _gnutls_gen_rsa_client_kx (mhd_gtls_session_t, opaque **);
-int _gnutls_proc_rsa_client_kx (mhd_gtls_session_t, opaque *, size_t);
-static int gen_rsa_export_server_kx (mhd_gtls_session_t, opaque **);
-static int proc_rsa_export_server_kx (mhd_gtls_session_t, opaque *, size_t);
+int MHD__gnutls_gen_rsa_client_kx (MHD_gtls_session_t, opaque **);
+int MHD__gnutls_proc_rsa_client_kx (MHD_gtls_session_t, opaque *, size_t);
+static int gen_rsa_export_server_kx (MHD_gtls_session_t, opaque **);
+static int proc_rsa_export_server_kx (MHD_gtls_session_t, opaque *, size_t);
 
-const mhd_gtls_mod_auth_st rsa_export_auth_struct = {
+const MHD_gtls_mod_auth_st rsa_export_auth_struct = {
   "RSA EXPORT",
-  mhd_gtls_gen_cert_server_certificate,
-  mhd_gtls_gen_cert_client_certificate,
+  MHD_gtls_gen_cert_server_certificate,
+  MHD_gtls_gen_cert_client_certificate,
   gen_rsa_export_server_kx,
-  _gnutls_gen_rsa_client_kx,
-  mhd_gtls_gen_cert_client_cert_vrfy,   /* gen client cert vrfy */
-  mhd_gtls_gen_cert_server_cert_req,    /* server cert request */
+  MHD__gnutls_gen_rsa_client_kx,
+  MHD_gtls_gen_cert_client_cert_vrfy,   /* gen client cert vrfy */
+  MHD_gtls_gen_cert_server_cert_req,    /* server cert request */
 
-  mhd_gtls_proc_cert_server_certificate,
-  _gnutls_proc_cert_client_certificate,
+  MHD_gtls_proc_cert_server_certificate,
+  MHD__gnutls_proc_cert_client_certificate,
   proc_rsa_export_server_kx,
-  _gnutls_proc_rsa_client_kx,   /* proc client kx */
-  mhd_gtls_proc_cert_client_cert_vrfy,  /* proc client cert vrfy */
-  mhd_gtls_proc_cert_cert_req   /* proc server cert request */
+  MHD__gnutls_proc_rsa_client_kx,   /* proc client kx */
+  MHD_gtls_proc_cert_client_cert_vrfy,  /* proc client cert vrfy */
+  MHD_gtls_proc_cert_cert_req   /* proc server cert request */
 };
 
 static int
-gen_rsa_export_server_kx (mhd_gtls_session_t session, opaque ** data)
+gen_rsa_export_server_kx (MHD_gtls_session_t session, opaque ** data)
 {
-  mhd_gtls_rsa_params_t rsa_params;
+  MHD_gtls_rsa_params_t rsa_params;
   const mpi_t *rsa_mpis;
   size_t n_e, n_m;
   uint8_t *data_e, *data_m;
   int ret = 0, data_size;
-  gnutls_cert *apr_cert_list;
-  gnutls_privkey *apr_pkey;
+  MHD_gnutls_cert *apr_cert_list;
+  MHD_gnutls_privkey *apr_pkey;
   int apr_cert_list_length;
-  gnutls_datum_t signature, ddata;
-  mhd_gtls_cert_credentials_t cred;
+  MHD_gnutls_datum_t signature, ddata;
+  MHD_gtls_cert_credentials_t cred;
 
-  cred = (mhd_gtls_cert_credentials_t)
-    mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
+  cred = (MHD_gtls_cert_credentials_t)
+    MHD_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL);
   if (cred == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
     }
 
   /* find the appropriate certificate */
   if ((ret =
-       mhd_gtls_get_selected_cert (session, &apr_cert_list,
+       MHD_gtls_get_selected_cert (session, &apr_cert_list,
                                    &apr_cert_list_length, &apr_pkey)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
   /* abort sending this message if we have a certificate
    * of 512 bits or less.
    */
-  if (apr_pkey && _gnutls_mpi_get_nbits (apr_pkey->params[0]) <= 512)
+  if (apr_pkey && MHD__gnutls_mpi_get_nbits (apr_pkey->params[0]) <= 512)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INT_RET_0;
     }
 
   rsa_params =
-    mhd_gtls_certificate_get_rsa_params (cred->rsa_params, cred->params_func,
+    MHD_gtls_certificate_get_rsa_params (cred->rsa_params, cred->params_func,
                                          session);
-  rsa_mpis = _gnutls_rsa_params_to_mpi (rsa_params);
+  rsa_mpis = MHD__gnutls_rsa_params_to_mpi (rsa_params);
   if (rsa_mpis == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS;
     }
 
-  if ((ret = mhd_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
+  if ((ret = MHD_gtls_auth_info_set (session, MHD_GNUTLS_CRD_CERTIFICATE,
                                      sizeof (cert_auth_info_st), 0)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
-  mhd_gtls_rsa_export_set_pubkey (session, rsa_mpis[1], rsa_mpis[0]);
+  MHD_gtls_rsa_export_set_pubkey (session, rsa_mpis[1], rsa_mpis[0]);
 
-  mhd_gtls_mpi_print (NULL, &n_m, rsa_mpis[0]);
-  mhd_gtls_mpi_print (NULL, &n_e, rsa_mpis[1]);
+  MHD_gtls_mpi_print (NULL, &n_m, rsa_mpis[0]);
+  MHD_gtls_mpi_print (NULL, &n_e, rsa_mpis[1]);
 
-  (*data) = gnutls_malloc (n_e + n_m + 4);
+  (*data) = MHD_gnutls_malloc (n_e + n_m + 4);
   if (*data == NULL)
     {
       return GNUTLS_E_MEMORY_ERROR;
     }
 
   data_m = &(*data)[0];
-  mhd_gtls_mpi_print (&data_m[2], &n_m, rsa_mpis[0]);
+  MHD_gtls_mpi_print (&data_m[2], &n_m, rsa_mpis[0]);
 
-  mhd_gtls_write_uint16 (n_m, data_m);
+  MHD_gtls_write_uint16 (n_m, data_m);
 
   data_e = &data_m[2 + n_m];
-  mhd_gtls_mpi_print (&data_e[2], &n_e, rsa_mpis[1]);
+  MHD_gtls_mpi_print (&data_e[2], &n_e, rsa_mpis[1]);
 
-  mhd_gtls_write_uint16 (n_e, data_e);
+  MHD_gtls_write_uint16 (n_e, data_e);
 
   data_size = n_m + n_e + 4;
 
@@ -154,33 +154,33 @@ gen_rsa_export_server_kx (mhd_gtls_session_t session, opaque ** data)
   if (apr_cert_list_length > 0)
     {
       if ((ret =
-           mhd_gtls_tls_sign_params (session, &apr_cert_list[0],
+           MHD_gtls_tls_sign_params (session, &apr_cert_list[0],
                                      apr_pkey, &ddata, &signature)) < 0)
         {
-          gnutls_assert ();
-          gnutls_free (*data);
+          MHD_gnutls_assert ();
+          MHD_gnutls_free (*data);
           *data = NULL;
           return ret;
         }
     }
   else
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return data_size;         /* do not put a signature - ILLEGAL! */
     }
 
-  *data = mhd_gtls_realloc_fast (*data, data_size + signature.size + 2);
+  *data = MHD_gtls_realloc_fast (*data, data_size + signature.size + 2);
   if (*data == NULL)
     {
-      _gnutls_free_datum (&signature);
-      gnutls_assert ();
+      MHD__gnutls_free_datum (&signature);
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
-  mhd_gtls_write_datum16 (&((*data)[data_size]), signature);
+  MHD_gtls_write_datum16 (&((*data)[data_size]), signature);
   data_size += signature.size + 2;
 
-  _gnutls_free_datum (&signature);
+  MHD__gnutls_free_datum (&signature);
 
   return data_size;
 }
@@ -188,49 +188,49 @@ gen_rsa_export_server_kx (mhd_gtls_session_t session, opaque ** data)
 /* if the peer's certificate is of 512 bits or less, returns non zero.
  */
 int
-_gnutls_peers_cert_less_512 (mhd_gtls_session_t session)
+MHD__gnutls_peers_cert_less_512 (MHD_gtls_session_t session)
 {
-  gnutls_cert peer_cert;
+  MHD_gnutls_cert peer_cert;
   int ret;
-  cert_auth_info_t info = mhd_gtls_get_auth_info (session);
+  cert_auth_info_t info = MHD_gtls_get_auth_info (session);
 
   if (info == NULL || info->ncerts == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       /* we need this in order to get peer's certificate */
       return 0;
     }
 
   if ((ret =
-       mhd_gtls_raw_cert_to_gcert (&peer_cert,
+       MHD_gtls_raw_cert_to_gcert (&peer_cert,
                                    session->security_parameters.cert_type,
                                    &info->raw_certificate_list[0],
                                    CERT_NO_COPY)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return 0;
     }
 
   if (peer_cert.subject_pk_algorithm != MHD_GNUTLS_PK_RSA)
     {
-      gnutls_assert ();
-      mhd_gtls_gcert_deinit (&peer_cert);
+      MHD_gnutls_assert ();
+      MHD_gtls_gcert_deinit (&peer_cert);
       return 0;
     }
 
-  if (_gnutls_mpi_get_nbits (peer_cert.params[0]) <= 512)
+  if (MHD__gnutls_mpi_get_nbits (peer_cert.params[0]) <= 512)
     {
-      mhd_gtls_gcert_deinit (&peer_cert);
+      MHD_gtls_gcert_deinit (&peer_cert);
       return 1;
     }
 
-  mhd_gtls_gcert_deinit (&peer_cert);
+  MHD_gtls_gcert_deinit (&peer_cert);
 
   return 0;
 }
 
 static int
-proc_rsa_export_server_kx (mhd_gtls_session_t session,
+proc_rsa_export_server_kx (MHD_gtls_session_t session,
                            opaque * data, size_t _data_size)
 {
   uint16_t n_m, n_e;
@@ -238,16 +238,16 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
   uint8_t *data_m;
   uint8_t *data_e;
   int i, sigsize;
-  gnutls_datum_t vparams, signature;
+  MHD_gnutls_datum_t vparams, signature;
   int ret;
   ssize_t data_size = _data_size;
   cert_auth_info_t info;
-  gnutls_cert peer_cert;
+  MHD_gnutls_cert peer_cert;
 
-  info = mhd_gtls_get_auth_info (session);
+  info = MHD_gtls_get_auth_info (session);
   if (info == NULL || info->ncerts == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       /* we need this in order to get peer's certificate */
       return GNUTLS_E_INTERNAL_ERROR;
     }
@@ -256,7 +256,7 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
   i = 0;
 
   DECR_LEN (data_size, 2);
-  n_m = mhd_gtls_read_uint16 (&data[i]);
+  n_m = MHD_gtls_read_uint16 (&data[i]);
   i += 2;
 
   DECR_LEN (data_size, n_m);
@@ -264,7 +264,7 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
   i += n_m;
 
   DECR_LEN (data_size, 2);
-  n_e = mhd_gtls_read_uint16 (&data[i]);
+  n_e = MHD_gtls_read_uint16 (&data[i]);
   i += 2;
 
   DECR_LEN (data_size, n_e);
@@ -274,19 +274,19 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
   _n_e = n_e;
   _n_m = n_m;
 
-  if (mhd_gtls_mpi_scan_nz (&session->key->rsa[0], data_m, &_n_m) != 0)
+  if (MHD_gtls_mpi_scan_nz (&session->key->rsa[0], data_m, &_n_m) != 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
 
-  if (mhd_gtls_mpi_scan_nz (&session->key->rsa[1], data_e, &_n_e) != 0)
+  if (MHD_gtls_mpi_scan_nz (&session->key->rsa[1], data_e, &_n_e) != 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
 
-  mhd_gtls_rsa_export_set_pubkey (session, session->key->rsa[1],
+  MHD_gtls_rsa_export_set_pubkey (session, session->key->rsa[1],
                                   session->key->rsa[0]);
 
   /* VERIFY SIGNATURE */
@@ -295,29 +295,29 @@ proc_rsa_export_server_kx (mhd_gtls_session_t session,
   vparams.data = data;
 
   DECR_LEN (data_size, 2);
-  sigsize = mhd_gtls_read_uint16 (&data[vparams.size]);
+  sigsize = MHD_gtls_read_uint16 (&data[vparams.size]);
 
   DECR_LEN (data_size, sigsize);
   signature.data = &data[vparams.size + 2];
   signature.size = sigsize;
 
   if ((ret =
-       mhd_gtls_raw_cert_to_gcert (&peer_cert,
+       MHD_gtls_raw_cert_to_gcert (&peer_cert,
                                    session->security_parameters.cert_type,
                                    &info->raw_certificate_list[0],
                                    CERT_NO_COPY)) < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
   ret =
-    mhd_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
+    MHD_gtls_verify_sig_params (session, &peer_cert, &vparams, &signature);
 
-  mhd_gtls_gcert_deinit (&peer_cert);
+  MHD_gtls_gcert_deinit (&peer_cert);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
     }
 
   return ret;

+ 11 - 11
src/daemon/https/tls/debug.c

@@ -32,26 +32,26 @@
 
 
 void
-_gnutls_print_state (mhd_gtls_session_t session)
+MHD__gnutls_print_state (MHD_gtls_session_t session)
 {
 
-  _gnutls_debug_log ("GNUTLS State:\n");
-  _gnutls_debug_log ("Connection End: %d\n",
+  MHD__gnutls_debug_log ("GNUTLS State:\n");
+  MHD__gnutls_debug_log ("Connection End: %d\n",
                      session->security_parameters.entity);
-  _gnutls_debug_log ("Cipher Algorithm: %d\n",
+  MHD__gnutls_debug_log ("Cipher Algorithm: %d\n",
                      session->security_parameters.read_bulk_cipher_algorithm);
-  _gnutls_debug_log ("MAC algorithm: %d\n",
+  MHD__gnutls_debug_log ("MAC algorithm: %d\n",
                      session->security_parameters.read_mac_algorithm);
-  _gnutls_debug_log ("Compression Algorithm: %d\n",
+  MHD__gnutls_debug_log ("Compression Algorithm: %d\n",
                      session->security_parameters.read_compression_algorithm);
-  _gnutls_debug_log ("\n");
+  MHD__gnutls_debug_log ("\n");
 
 }
 
 #endif
 
 const char *
-_gnutls_packet2str (content_type_t packet)
+MHD__gnutls_packet2str (content_type_t packet)
 {
   switch (packet)
     {
@@ -72,7 +72,7 @@ _gnutls_packet2str (content_type_t packet)
 }
 
 const char *
-_gnutls_handshake2str (gnutls_handshake_description_t handshake)
+MHD__gnutls_handshake2str (MHD_gnutls_handshake_description_t handshake)
 {
 
   switch (handshake)
@@ -117,12 +117,12 @@ _gnutls_handshake2str (gnutls_handshake_description_t handshake)
 }
 
 void
-_gnutls_dump_mpi (const char *prefix, mpi_t a)
+MHD__gnutls_dump_mpi (const char *prefix, mpi_t a)
 {
   opaque buf[1024];
   size_t n = sizeof buf;
 
   if (gcry_mpi_print (GCRYMPI_FMT_HEX, buf, n, &n, a))
     strcpy (buf, "[can't print value]");        /* Flawfinder: ignore */
-  _gnutls_hard_log ("MPI: length: %d\n\t%s%s\n", (n - 1) / 2, prefix, buf);
+  MHD__gnutls_hard_log ("MPI: length: %d\n\t%s%s\n", (n - 1) / 2, prefix, buf);
 }

+ 4 - 4
src/daemon/https/tls/debug.h

@@ -23,8 +23,8 @@
  */
 
 #ifdef DEBUG
-void _gnutls_print_state (mhd_gtls_session_t session);
+void MHD__gnutls_print_state (MHD_gtls_session_t session);
 #endif
-const char *_gnutls_packet2str (content_type_t packet);
-const char *_gnutls_handshake2str (gnutls_handshake_description_t handshake);
-void _gnutls_dump_mpi (const char *prefix, mpi_t a);
+const char *MHD__gnutls_packet2str (content_type_t packet);
+const char *MHD__gnutls_handshake2str (MHD_gnutls_handshake_description_t handshake);
+void MHD__gnutls_dump_mpi (const char *prefix, mpi_t a);

+ 24 - 24
src/daemon/https/tls/ext_cert_type.c

@@ -33,12 +33,12 @@
 #include "gnutls_state.h"
 #include "gnutls_num.h"
 
-inline static int _gnutls_num2cert_type (int num);
-inline static int _gnutls_cert_type2num (int record_size);
+inline static int MHD__gnutls_num2cert_type (int num);
+inline static int MHD__gnutls_cert_type2num (int record_size);
 
 /*
  * In case of a server: if a CERT_TYPE extension type is received then it stores
- * into the session security parameters the new value. The server may use gnutls_session_certificate_type_get(),
+ * into the session security parameters the new value. The server may use MHD_gnutls_session_certificate_type_get(),
  * to access it.
  *
  * 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);
  */
 
 int
-mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
+MHD_gtls_cert_type_recv_params (MHD_gtls_session_t session,
                                 const opaque * data, size_t _data_size)
 {
   int new_type = -1, ret, i;
@@ -59,27 +59,27 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
         {
           if (data_size != 1)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
             }
 
-          new_type = _gnutls_num2cert_type (data[0]);
+          new_type = MHD__gnutls_num2cert_type (data[0]);
 
           if (new_type < 0)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return new_type;
             }
 
           /* Check if we support this cert_type */
           if ((ret =
-               mhd_gtls_session_cert_type_supported (session, new_type)) < 0)
+               MHD_gtls_session_cert_type_supported (session, new_type)) < 0)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return ret;
             }
 
-          _gnutls_session_cert_type_set (session, new_type);
+          MHD__gnutls_session_cert_type_set (session, new_type);
         }
     }
   else
@@ -96,17 +96,17 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
 
           for (i = 0; i < len; i++)
             {
-              new_type = _gnutls_num2cert_type (data[i + 1]);
+              new_type = MHD__gnutls_num2cert_type (data[i + 1]);
 
               if (new_type < 0)
                 continue;
 
               /* Check if we support this cert_type */
               if ((ret =
-                   mhd_gtls_session_cert_type_supported (session,
+                   MHD_gtls_session_cert_type_supported (session,
                                                          new_type)) < 0)
                 {
-                  gnutls_assert ();
+                  MHD_gnutls_assert ();
                   continue;
                 }
               else
@@ -116,14 +116,14 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
 
           if (new_type < 0)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
             }
 
           if ((ret =
-               mhd_gtls_session_cert_type_supported (session, new_type)) < 0)
+               MHD_gtls_session_cert_type_supported (session, new_type)) < 0)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               /* The peer has requested unsupported certificate
                * types. Instead of failing, procceed normally.
                * (the ciphersuite selection would fail, or a
@@ -132,7 +132,7 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
               return 0;
             }
 
-          _gnutls_session_cert_type_set (session, new_type);
+          MHD__gnutls_session_cert_type_set (session, new_type);
         }
 
 
@@ -144,7 +144,7 @@ mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
 /* returns data_size or a negative number on failure
  */
 int
-mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
+MHD_gtls_cert_type_send_params (MHD_gtls_session_t session, opaque * data,
                                 size_t data_size)
 {
   unsigned len, i;
@@ -171,7 +171,7 @@ mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
 
           if (data_size < len + 1)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_SHORT_MEMORY_BUFFER;
             }
 
@@ -182,7 +182,7 @@ mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
           for (i = 0; i < len; i++)
             {
               data[i + 1] =
-                _gnutls_cert_type2num (session->internals.
+                MHD__gnutls_cert_type2num (session->internals.
                                        priorities.cert_type.priority[i]);
             }
           return len + 1;
@@ -197,12 +197,12 @@ mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
           len = 1;
           if (data_size < len)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_SHORT_MEMORY_BUFFER;
             }
 
           data[0] =
-            _gnutls_cert_type2num (session->security_parameters.cert_type);
+            MHD__gnutls_cert_type2num (session->security_parameters.cert_type);
           return len;
         }
 
@@ -216,7 +216,7 @@ mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
  * extensions draft.
  */
 inline static int
-_gnutls_num2cert_type (int num)
+MHD__gnutls_num2cert_type (int num)
 {
   switch (num)
     {
@@ -231,7 +231,7 @@ _gnutls_num2cert_type (int num)
  * extensions draft.
  */
 inline static int
-_gnutls_cert_type2num (int cert_type)
+MHD__gnutls_cert_type2num (int cert_type)
 {
   switch (cert_type)
     {

+ 2 - 2
src/daemon/https/tls/ext_cert_type.h

@@ -25,7 +25,7 @@
 /* Maps record size to numbers according to the
  * extensions draft.
  */
-int mhd_gtls_cert_type_recv_params (mhd_gtls_session_t session,
+int MHD_gtls_cert_type_recv_params (MHD_gtls_session_t session,
                                     const opaque * data, size_t data_size);
-int mhd_gtls_cert_type_send_params (mhd_gtls_session_t session, opaque * data,
+int MHD_gtls_cert_type_send_params (MHD_gtls_session_t session, opaque * data,
                                     size_t);

+ 14 - 14
src/daemon/https/tls/ext_max_record.c

@@ -32,7 +32,7 @@
 
 /*
  * In case of a server: if a MAX_RECORD_SIZE extension type is received then it stores
- * into the session the new value. The server may use gnutls_get_max_record_size(),
+ * into the session the new value. The server may use MHD_gnutls_get_max_record_size(),
  * in order to access it.
  *
  * In case of a client: If a different max record size (than the default) has
@@ -41,7 +41,7 @@
  */
 
 int
-mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
+MHD_gtls_max_record_recv_params (MHD_gtls_session_t session,
                                  const opaque * data, size_t _data_size)
 {
   ssize_t new_size;
@@ -53,11 +53,11 @@ mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
         {
           DECR_LEN (data_size, 1);
 
-          new_size = mhd_gtls_mre_num2record (data[0]);
+          new_size = MHD_gtls_mre_num2record (data[0]);
 
           if (new_size < 0)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return new_size;
             }
 
@@ -73,16 +73,16 @@ mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
 
           if (data_size != 1)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
             }
 
-          new_size = mhd_gtls_mre_num2record (data[0]);
+          new_size = MHD_gtls_mre_num2record (data[0]);
 
           if (new_size < 0
               || new_size != session->internals.proposed_record_size)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
             }
           else
@@ -102,7 +102,7 @@ mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
 /* returns data_size or a negative number on failure
  */
 int
-mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
+MHD_gtls_max_record_send_params (MHD_gtls_session_t session, opaque * data,
                                  size_t data_size)
 {
   uint16_t len;
@@ -116,12 +116,12 @@ mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
           len = 1;
           if (data_size < len)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_SHORT_MEMORY_BUFFER;
             }
 
           data[0] =
-            (uint8_t) mhd_gtls_mre_record2num (session->internals.
+            (uint8_t) MHD_gtls_mre_record2num (session->internals.
                                                proposed_record_size);
           return len;
         }
@@ -137,13 +137,13 @@ mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
           len = 1;
           if (data_size < len)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_SHORT_MEMORY_BUFFER;
             }
 
           data[0] =
             (uint8_t)
-            mhd_gtls_mre_record2num
+            MHD_gtls_mre_record2num
             (session->security_parameters.max_record_recv_size);
           return len;
         }
@@ -158,7 +158,7 @@ mhd_gtls_max_record_send_params (mhd_gtls_session_t session, opaque * data,
  * extensions draft.
  */
 int
-mhd_gtls_mre_num2record (int num)
+MHD_gtls_mre_num2record (int num)
 {
   switch (num)
     {
@@ -179,7 +179,7 @@ mhd_gtls_mre_num2record (int num)
  * extensions draft.
  */
 int
-mhd_gtls_mre_record2num (uint16_t record_size)
+MHD_gtls_mre_record2num (uint16_t record_size)
 {
   switch (record_size)
     {

+ 4 - 4
src/daemon/https/tls/ext_max_record.h

@@ -25,9 +25,9 @@
 /* Maps record size to numbers according to the
  * extensions draft.
  */
-int mhd_gtls_mre_num2record (int num);
-int mhd_gtls_mre_record2num (uint16_t record_size);
-int mhd_gtls_max_record_recv_params (mhd_gtls_session_t session,
+int MHD_gtls_mre_num2record (int num);
+int MHD_gtls_mre_record2num (uint16_t record_size);
+int MHD_gtls_max_record_recv_params (MHD_gtls_session_t session,
                                      const opaque * data, size_t data_size);
-int mhd_gtls_max_record_send_params (mhd_gtls_session_t session,
+int MHD_gtls_max_record_send_params (MHD_gtls_session_t session,
                                      opaque * data, size_t);

+ 29 - 29
src/daemon/https/tls/ext_oprfi.c

@@ -34,7 +34,7 @@
 #include <gnutls_num.h>
 
 static int
-oprfi_recv_server (mhd_gtls_session_t session,
+oprfi_recv_server (MHD_gtls_session_t session,
                    const opaque * data, size_t _data_size)
 {
   ssize_t data_size = _data_size;
@@ -42,26 +42,26 @@ oprfi_recv_server (mhd_gtls_session_t session,
 
   if (!session->security_parameters.extensions.oprfi_cb)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return 0;
     }
 
   DECR_LEN (data_size, 2);
-  len = mhd_gtls_read_uint16 (data);
+  len = MHD_gtls_read_uint16 (data);
   data += 2;
 
   if (len != data_size)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
     }
 
   /* Store incoming data. */
   session->security_parameters.extensions.oprfi_client_len = len;
-  session->security_parameters.extensions.oprfi_client = gnutls_malloc (len);
+  session->security_parameters.extensions.oprfi_client = MHD_gnutls_malloc (len);
   if (!session->security_parameters.extensions.oprfi_client)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
   memcpy (session->security_parameters.extensions.oprfi_client, data, len);
@@ -70,7 +70,7 @@ oprfi_recv_server (mhd_gtls_session_t session,
 }
 
 static int
-oprfi_recv_client (mhd_gtls_session_t session,
+oprfi_recv_client (MHD_gtls_session_t session,
                    const opaque * data, size_t _data_size)
 {
   ssize_t data_size = _data_size;
@@ -78,32 +78,32 @@ oprfi_recv_client (mhd_gtls_session_t session,
 
   if (session->security_parameters.extensions.oprfi_client == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return 0;
     }
 
   DECR_LEN (data_size, 2);
-  len = mhd_gtls_read_uint16 (data);
+  len = MHD_gtls_read_uint16 (data);
   data += 2;
 
   if (len != data_size)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
     }
 
   if (len != session->security_parameters.extensions.oprfi_client_len)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
     }
 
   /* Store incoming data. */
   session->security_parameters.extensions.oprfi_server_len = len;
-  session->security_parameters.extensions.oprfi_server = gnutls_malloc (len);
+  session->security_parameters.extensions.oprfi_server = MHD_gnutls_malloc (len);
   if (!session->security_parameters.extensions.oprfi_server)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
   memcpy (session->security_parameters.extensions.oprfi_server, data, len);
@@ -112,7 +112,7 @@ oprfi_recv_client (mhd_gtls_session_t session,
 }
 
 int
-mhd_gtls_oprfi_recv_params (mhd_gtls_session_t session,
+MHD_gtls_oprfi_recv_params (MHD_gtls_session_t session,
                             const opaque * data, size_t data_size)
 {
 #if MHD_DEBUG_TLS
@@ -124,7 +124,7 @@ mhd_gtls_oprfi_recv_params (mhd_gtls_session_t session,
 }
 
 static int
-oprfi_send_client (mhd_gtls_session_t session, opaque * data,
+oprfi_send_client (MHD_gtls_session_t session, opaque * data,
                    size_t _data_size)
 {
   opaque *p = data;
@@ -135,7 +135,7 @@ oprfi_send_client (mhd_gtls_session_t session, opaque * data,
     return 0;
 
   DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
-  mhd_gtls_write_uint16 (oprf_size, p);
+  MHD_gtls_write_uint16 (oprf_size, p);
   p += 2;
 
   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,
 }
 
 static int
-oprfi_send_server (mhd_gtls_session_t session, opaque * data,
+oprfi_send_server (MHD_gtls_session_t session, opaque * data,
                    size_t _data_size)
 {
   opaque *p = data;
@@ -161,10 +161,10 @@ oprfi_send_server (mhd_gtls_session_t session, opaque * data,
   session->security_parameters.extensions.oprfi_server_len =
     session->security_parameters.extensions.oprfi_client_len;
   session->security_parameters.extensions.oprfi_server =
-    gnutls_malloc (session->security_parameters.extensions.oprfi_server_len);
+    MHD_gnutls_malloc (session->security_parameters.extensions.oprfi_server_len);
   if (!session->security_parameters.extensions.oprfi_server)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
@@ -176,13 +176,13 @@ oprfi_send_server (mhd_gtls_session_t session, opaque * data,
      session->security_parameters.extensions.oprfi_server);
   if (ret < 0)
     {
-      gnutls_assert ();
-      gnutls_free (session->security_parameters.extensions.oprfi_server);
+      MHD_gnutls_assert ();
+      MHD_gnutls_free (session->security_parameters.extensions.oprfi_server);
       return ret;
     }
 
   DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
-  mhd_gtls_write_uint16 (session->security_parameters.
+  MHD_gtls_write_uint16 (session->security_parameters.
                          extensions.oprfi_server_len, p);
   p += 2;
 
@@ -197,7 +197,7 @@ oprfi_send_server (mhd_gtls_session_t session, opaque * data,
 }
 
 int
-mhd_gtls_oprfi_send_params (mhd_gtls_session_t session,
+MHD_gtls_oprfi_send_params (MHD_gtls_session_t session,
                             opaque * data, size_t data_size)
 {
 #if MHD_DEBUG_TLS
@@ -210,7 +210,7 @@ mhd_gtls_oprfi_send_params (mhd_gtls_session_t session,
 
 /**
  * MHD_gtls_oprfi_enable_client:
- * @session: is a #mhd_gtls_session_t structure.
+ * @session: is a #MHD_gtls_session_t structure.
  * @len: length of Opaque PRF data to use in client.
  * @data: Opaque PRF data to use in client.
  *
@@ -222,7 +222,7 @@ mhd_gtls_oprfi_send_params (mhd_gtls_session_t session,
  * may de-allocate it immediately after calling this function.
  **/
 void
-MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
+MHD_gtls_oprfi_enable_client (MHD_gtls_session_t session,
                               size_t len, unsigned char *data)
 {
   session->security_parameters.extensions.oprfi_client_len = len;
@@ -231,7 +231,7 @@ MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
 
 /**
  * MHD_gtls_oprfi_enable_server:
- * @session: is a #mhd_gtls_session_t structure.
+ * @session: is a #MHD_gtls_session_t structure.
  * @cb: function pointer to Opaque PRF extension server callback.
  * @userdata: hook passed to callback function for passing application state.
  *
@@ -240,7 +240,7 @@ MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
  * provided callback @cb will be invoked.  The callback must have the
  * following prototype:
  *
- * int callback (mhd_gtls_session_t session, void *userdata,
+ * int callback (MHD_gtls_session_t session, void *userdata,
  *               size_t oprfi_len, const unsigned char *in_oprfi,
  *               unsigned char *out_oprfi);
  *
@@ -250,8 +250,8 @@ MHD_gtls_oprfi_enable_client (mhd_gtls_session_t session,
  * handshake will be aborted.
  **/
 void
-MHD_gtls_oprfi_enable_server (mhd_gtls_session_t session,
-                              gnutls_oprfi_callback_func cb, void *userdata)
+MHD_gtls_oprfi_enable_server (MHD_gtls_session_t session,
+                              MHD_gnutls_oprfi_callback_func cb, void *userdata)
 {
   session->security_parameters.extensions.oprfi_cb = cb;
   session->security_parameters.extensions.oprfi_userdata = userdata;

+ 2 - 2
src/daemon/https/tls/ext_oprfi.h

@@ -24,8 +24,8 @@
 
 #include <gnutls_int.h>
 
-int mhd_gtls_oprfi_recv_params (mhd_gtls_session_t state,
+int MHD_gtls_oprfi_recv_params (MHD_gtls_session_t state,
                                 const opaque * data, size_t data_size);
 
-int mhd_gtls_oprfi_send_params (mhd_gtls_session_t state,
+int MHD_gtls_oprfi_send_params (MHD_gtls_session_t state,
                                 opaque * data, size_t data_size);

+ 20 - 20
src/daemon/https/tls/ext_server_name.c

@@ -30,7 +30,7 @@
 
 /*
  * In case of a server: if a NAME_DNS extension type is received then it stores
- * into the session the value of NAME_DNS. The server may use gnutls_ext_get_server_name(),
+ * into the session the value of NAME_DNS. The server may use MHD_gnutls_ext_get_server_name(),
  * in order to access it.
  *
  * In case of a client: If a proper NAME_DNS extension type is found in the session then
@@ -39,7 +39,7 @@
  */
 
 int
-mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
+MHD_gtls_server_name_recv_params (MHD_gtls_session_t session,
                                   const opaque * data, size_t _data_size)
 {
   int i;
@@ -51,14 +51,14 @@ mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
   if (session->security_parameters.entity == GNUTLS_SERVER)
     {
       DECR_LENGTH_RET (data_size, 2, 0);
-      len = mhd_gtls_read_uint16 (data);
+      len = MHD_gtls_read_uint16 (data);
 
       if (len != data_size)
         {
           /* This is unexpected packet length, but
            * just ignore it, for now.
            */
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return 0;
         }
 
@@ -71,7 +71,7 @@ mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
           p++;
 
           DECR_LEN (data_size, 2);
-          len = mhd_gtls_read_uint16 (p);
+          len = MHD_gtls_read_uint16 (p);
           p += 2;
 
           DECR_LENGTH_RET (data_size, len, 0);
@@ -96,7 +96,7 @@ mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
           type = *p;
           p++;
 
-          len = mhd_gtls_read_uint16 (p);
+          len = MHD_gtls_read_uint16 (p);
           p += 2;
 
           switch (type)
@@ -124,7 +124,7 @@ mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
 /* returns data_size or a negative number on failure
  */
 int
-mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
+MHD_gtls_server_name_send_params (MHD_gtls_session_t session,
                                   opaque * data, size_t _data_size)
 {
   int total_size = 0;
@@ -163,7 +163,7 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
       /* UINT16: write total size of all names
        */
       DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
-      mhd_gtls_write_uint16 (total_size - 2, p);
+      MHD_gtls_write_uint16 (total_size - 2, p);
       p += 2;
 
       for (i = 0;
@@ -191,7 +191,7 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
               *p = 0;           /* NAME_DNS type */
               p++;
 
-              mhd_gtls_write_uint16 (len, p);
+              MHD_gtls_write_uint16 (len, p);
               p += 2;
 
               memcpy (p,
@@ -200,7 +200,7 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
               p += len;
               break;
             default:
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_INTERNAL_ERROR;
             }
         }
@@ -210,8 +210,8 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
 }
 
 /**
-  * MHD_gnutls_server_name_get - Used to get the server name indicator send by a client
-  * @session: is a #mhd_gtls_session_t structure.
+  * MHD__gnutls_server_name_get - Used to get the server name indicator send by a client
+  * @session: is a #MHD_gtls_session_t structure.
   * @data: will hold the data
   * @data_length: will hold the data length. Must hold the maximum size of data.
   * @type: will hold the server name indicator type
@@ -219,7 +219,7 @@ mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
   *
   * This function will allow you to get the name indication (if any),
   * a client has sent. The name indication may be any of the enumeration
-  * gnutls_server_name_type_t.
+  * MHD_gnutls_server_name_type_t.
   *
   * If @type is GNUTLS_NAME_DNS, then this function is to be used by servers
   * 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,
   *
   **/
 int
-MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
+MHD__gnutls_server_name_get (MHD_gtls_session_t session, void *data,
                             size_t * data_length,
                             unsigned int *type, unsigned int indx)
 {
@@ -241,7 +241,7 @@ MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
 #if MHD_DEBUG_TLS
   if (session->security_parameters.entity == GNUTLS_CLIENT)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INVALID_REQUEST;
     }
 #endif
@@ -278,8 +278,8 @@ MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
 }
 
 /**
-  * MHD_gnutls_server_name_set - Used to set a name indicator to be sent as an extension
-  * @session: is a #mhd_gtls_session_t structure.
+  * MHD__gnutls_server_name_set - Used to set a name indicator to be sent as an extension
+  * @session: is a #MHD_gtls_session_t structure.
   * @type: specifies the indicator type
   * @name: is a string that contains the server name.
   * @name_length: holds the length of name
@@ -295,15 +295,15 @@ MHD_gnutls_server_name_get (mhd_gtls_session_t session, void *data,
   *
   **/
 int
-MHD_gnutls_server_name_set (mhd_gtls_session_t session,
-                            gnutls_server_name_type_t type,
+MHD__gnutls_server_name_set (MHD_gtls_session_t session,
+                            MHD_gnutls_server_name_type_t type,
                             const void *name, size_t name_length)
 {
   int server_names;
 
   if (session->security_parameters.entity == GNUTLS_SERVER)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INVALID_REQUEST;
     }
 

+ 2 - 2
src/daemon/https/tls/ext_server_name.h

@@ -22,7 +22,7 @@
  *
  */
 
-int mhd_gtls_server_name_recv_params (mhd_gtls_session_t session,
+int MHD_gtls_server_name_recv_params (MHD_gtls_session_t session,
                                       const opaque * data, size_t data_size);
-int mhd_gtls_server_name_send_params (mhd_gtls_session_t session,
+int MHD_gtls_server_name_send_params (MHD_gtls_session_t session,
                                       opaque * data, size_t);

+ 24 - 24
src/daemon/https/tls/gnutls_alert.c

@@ -29,11 +29,11 @@
 
 typedef struct
 {
-  gnutls_alert_description_t alert;
+  MHD_gnutls_alert_description_t alert;
   const char *desc;
-} gnutls_alert_entry;
+} MHD_gnutls_alert_entry;
 
-static const gnutls_alert_entry mhd_gtls_sup_alerts[] = {
+static const MHD_gnutls_alert_entry MHD_gtls_sup_alerts[] = {
   {GNUTLS_A_CLOSE_NOTIFY, "Close notify"},
   {GNUTLS_A_UNEXPECTED_MESSAGE, "Unexpected message"},
   {GNUTLS_A_BAD_RECORD_MAC, "Bad record MAC"},
@@ -67,23 +67,23 @@ static const gnutls_alert_entry mhd_gtls_sup_alerts[] = {
 };
 
 #define GNUTLS_ALERT_LOOP(b) \
-        const gnutls_alert_entry *p; \
-                for(p = mhd_gtls_sup_alerts; p->desc != NULL; p++) { b ; }
+        const MHD_gnutls_alert_entry *p; \
+                for(p = MHD_gtls_sup_alerts; p->desc != NULL; p++) { b ; }
 
 #define GNUTLS_ALERT_ID_LOOP(a) \
                         GNUTLS_ALERT_LOOP( if(p->alert == alert) { a; break; })
 
 
 /**
-  * MHD_gnutls_alert_get_name - Returns a string describing the alert number given
-  * @alert: is an alert number #mhd_gtls_session_t structure.
+  * MHD__gnutls_alert_get_name - Returns a string describing the alert number given
+  * @alert: is an alert number #MHD_gtls_session_t structure.
   *
   * This function will return a string that describes the given alert
-  * number or NULL.  See gnutls_alert_get().
+  * number or NULL.  See MHD_gnutls_alert_get().
   *
   **/
 const char *
-MHD_gnutls_alert_get_name (gnutls_alert_description_t alert)
+MHD__gnutls_alert_get_name (MHD_gnutls_alert_description_t alert)
 {
   const char *ret = NULL;
 
@@ -93,8 +93,8 @@ MHD_gnutls_alert_get_name (gnutls_alert_description_t alert)
 }
 
 /**
-  * MHD_gnutls_alert_send - This function sends an alert message to the peer
-  * @session: is a #mhd_gtls_session_t structure.
+  * MHD__gnutls_alert_send - This function sends an alert message to the peer
+  * @session: is a #MHD_gtls_session_t structure.
   * @level: is the level of the alert
   * @desc: is the alert description
   *
@@ -110,8 +110,8 @@ MHD_gnutls_alert_get_name (gnutls_alert_description_t alert)
   *
   **/
 int
-MHD_gnutls_alert_send (mhd_gtls_session_t session, gnutls_alert_level_t level,
-                       gnutls_alert_description_t desc)
+MHD__gnutls_alert_send (MHD_gtls_session_t session, MHD_gnutls_alert_level_t level,
+                       MHD_gnutls_alert_description_t desc)
 {
   uint8_t data[2];
   int ret;
@@ -120,13 +120,13 @@ MHD_gnutls_alert_send (mhd_gtls_session_t session, gnutls_alert_level_t level,
   data[0] = (uint8_t) level;
   data[1] = (uint8_t) desc;
 
-  name = MHD_gnutls_alert_get_name ((int) data[1]);
+  name = MHD__gnutls_alert_get_name ((int) data[1]);
   if (name == NULL)
     name = "(unknown)";
-  _gnutls_record_log ("REC: Sending Alert[%d|%d] - %s\n", data[0],
+  MHD__gnutls_record_log ("REC: Sending Alert[%d|%d] - %s\n", data[0],
                       data[1], name);
 
-  if ((ret = mhd_gtls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0)
+  if ((ret = MHD_gtls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0)
     return 0;
   else
     return ret;
@@ -245,8 +245,8 @@ MHD_gtls_error_to_alert (int err, int *level)
 
 
 /**
- * MHD_gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code
- * @session: is a #mhd_gtls_session_t structure.
+ * MHD__gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code
+ * @session: is a #MHD_gtls_session_t structure.
  * @err: is an integer
  *
  * 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)
  * Returns zero on success.
  */
 int
-MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err)
+MHD__gnutls_alert_send_appropriate (MHD_gtls_session_t session, int err)
 {
   int alert;
   int level;
@@ -272,12 +272,12 @@ MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err)
       return alert;
     }
 
-  return MHD_gnutls_alert_send (session, level, alert);
+  return MHD__gnutls_alert_send (session, level, alert);
 }
 
 /**
-  * gnutls_alert_get - Returns the last alert number received.
-  * @session: is a #mhd_gtls_session_t structure.
+  * MHD_gnutls_alert_get - Returns the last alert number received.
+  * @session: is a #MHD_gtls_session_t structure.
   *
   * This function will return the last alert number received. This
   * 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)
   * If no alert has been received the returned value is undefined.
   *
   **/
-gnutls_alert_description_t
-gnutls_alert_get (mhd_gtls_session_t session)
+MHD_gnutls_alert_description_t
+MHD_gnutls_alert_get (MHD_gtls_session_t session)
 {
   return session->internals.last_alert;
 }

Plik diff jest za duży
+ 159 - 159
src/daemon/https/tls/gnutls_algorithms.c


+ 49 - 49
src/daemon/https/tls/gnutls_algorithms.h

@@ -28,105 +28,105 @@
 #include "gnutls_auth.h"
 
 /* Functions for version handling. */
-enum MHD_GNUTLS_Protocol mhd_gtls_version_lowest (mhd_gtls_session_t session);
-enum MHD_GNUTLS_Protocol mhd_gtls_version_max (mhd_gtls_session_t session);
-int mhd_gtls_version_priority (mhd_gtls_session_t session,
+enum MHD_GNUTLS_Protocol MHD_gtls_version_lowest (MHD_gtls_session_t session);
+enum MHD_GNUTLS_Protocol MHD_gtls_version_max (MHD_gtls_session_t session);
+int MHD_gtls_version_priority (MHD_gtls_session_t session,
                                enum MHD_GNUTLS_Protocol version);
-int mhd_gtls_version_is_supported (mhd_gtls_session_t session,
+int MHD_gtls_version_is_supported (MHD_gtls_session_t session,
                                    const enum MHD_GNUTLS_Protocol version);
-int mhd_gtls_version_get_major (enum MHD_GNUTLS_Protocol ver);
-int mhd_gtls_version_get_minor (enum MHD_GNUTLS_Protocol ver);
-enum MHD_GNUTLS_Protocol mhd_gtls_version_get (int major, int minor);
+int MHD_gtls_version_get_major (enum MHD_GNUTLS_Protocol ver);
+int MHD_gtls_version_get_minor (enum MHD_GNUTLS_Protocol ver);
+enum MHD_GNUTLS_Protocol MHD_gtls_version_get (int major, int minor);
 
 /* Functions for MACs. */
-int mhd_gnutls_mac_is_ok (enum MHD_GNUTLS_HashAlgorithm algorithm);
-enum MHD_GNUTLS_HashAlgorithm mhd_gtls_x509_oid2mac_algorithm (const char
+int MHD_gnutls_mac_is_ok (enum MHD_GNUTLS_HashAlgorithm algorithm);
+enum MHD_GNUTLS_HashAlgorithm MHD_gtls_x509_oid2mac_algorithm (const char
                                                                *oid);
-const char *mhd_gtls_x509_mac_to_oid (enum MHD_GNUTLS_HashAlgorithm mac);
+const char *MHD_gtls_x509_mac_to_oid (enum MHD_GNUTLS_HashAlgorithm mac);
 
 /* Functions for cipher suites. */
-int mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session,
+int MHD_gtls_supported_ciphersuites (MHD_gtls_session_t session,
                                      cipher_suite_st ** ciphers);
-int mhd_gtls_supported_ciphersuites_sorted (mhd_gtls_session_t session,
+int MHD_gtls_supported_ciphersuites_sorted (MHD_gtls_session_t session,
                                             cipher_suite_st ** ciphers);
-int mhd_gtls_supported_compression_methods (mhd_gtls_session_t session,
+int MHD_gtls_supported_compression_methods (MHD_gtls_session_t session,
                                             uint8_t ** comp);
-const char *mhd_gtls_cipher_suite_get_name (cipher_suite_st * algorithm);
-enum MHD_GNUTLS_CipherAlgorithm mhd_gtls_cipher_suite_get_cipher_algo (const
+const char *MHD_gtls_cipher_suite_get_name (cipher_suite_st * algorithm);
+enum MHD_GNUTLS_CipherAlgorithm MHD_gtls_cipher_suite_get_cipher_algo (const
                                                                        cipher_suite_st
                                                                        *
                                                                        algorithm);
-enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_cipher_suite_get_kx_algo (const
+enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gtls_cipher_suite_get_kx_algo (const
                                                                         cipher_suite_st
                                                                         *
                                                                         algorithm);
-enum MHD_GNUTLS_HashAlgorithm mhd_gtls_cipher_suite_get_mac_algo (const
+enum MHD_GNUTLS_HashAlgorithm MHD_gtls_cipher_suite_get_mac_algo (const
                                                                   cipher_suite_st
                                                                   *
                                                                   algorithm);
-enum MHD_GNUTLS_Protocol mhd_gtls_cipher_suite_get_version (const
+enum MHD_GNUTLS_Protocol MHD_gtls_cipher_suite_get_version (const
                                                             cipher_suite_st *
                                                             algorithm);
-cipher_suite_st mhd_gtls_cipher_suite_get_suite_name (cipher_suite_st *
+cipher_suite_st MHD_gtls_cipher_suite_get_suite_name (cipher_suite_st *
                                                       algorithm);
 
 /* Functions for ciphers. */
-int mhd_gtls_cipher_get_block_size (enum MHD_GNUTLS_CipherAlgorithm
+int MHD_gtls_cipher_get_block_size (enum MHD_GNUTLS_CipherAlgorithm
                                     algorithm);
-int mhd_gtls_cipher_is_block (enum MHD_GNUTLS_CipherAlgorithm algorithm);
-int mhd_gtls_cipher_is_ok (enum MHD_GNUTLS_CipherAlgorithm algorithm);
-int mhd_gtls_cipher_get_iv_size (enum MHD_GNUTLS_CipherAlgorithm algorithm);
-int mhd_gtls_cipher_get_export_flag (enum MHD_GNUTLS_CipherAlgorithm
+int MHD_gtls_cipher_is_block (enum MHD_GNUTLS_CipherAlgorithm algorithm);
+int MHD_gtls_cipher_is_ok (enum MHD_GNUTLS_CipherAlgorithm algorithm);
+int MHD_gtls_cipher_get_iv_size (enum MHD_GNUTLS_CipherAlgorithm algorithm);
+int MHD_gtls_cipher_get_export_flag (enum MHD_GNUTLS_CipherAlgorithm
                                      algorithm);
 
 /* Functions for key exchange. */
-int mhd_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm
+int MHD_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm
                                  algorithm);
-int mhd_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm
+int MHD_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm
                                   algorithm);
-mhd_gtls_mod_auth_st *mhd_gtls_kx_auth_struct (enum
+MHD_gtls_mod_auth_st *MHD_gtls_kx_auth_struct (enum
                                                MHD_GNUTLS_KeyExchangeAlgorithm
                                                algorithm);
-int mhd_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm);
+int MHD_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm);
 
 /* Functions for compression. */
-int mhd_gtls_compression_is_ok (enum MHD_GNUTLS_CompressionMethod algorithm);
-int mhd_gtls_compression_get_num (enum MHD_GNUTLS_CompressionMethod
+int MHD_gtls_compression_is_ok (enum MHD_GNUTLS_CompressionMethod algorithm);
+int MHD_gtls_compression_get_num (enum MHD_GNUTLS_CompressionMethod
                                   algorithm);
-enum MHD_GNUTLS_CompressionMethod mhd_gtls_compression_get_id (int num);
-int mhd_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod
+enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get_id_from_int (int num);
+int MHD_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod
                                         algorithm);
-int mhd_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod
+int MHD_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod
                                          algorithm);
-int mhd_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod
+int MHD_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod
                                     algorithm);
 
 /* Type to KX mappings. */
-enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_map_kx_get_kx (enum
+enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gtls_map_kx_get_kx (enum
                                                              MHD_GNUTLS_CredentialsType
                                                              type,
                                                              int server);
-enum MHD_GNUTLS_CredentialsType mhd_gtls_map_kx_get_cred (enum
+enum MHD_GNUTLS_CredentialsType MHD_gtls_map_kx_get_cred (enum
                                                           MHD_GNUTLS_KeyExchangeAlgorithm
                                                           algorithm,
                                                           int server);
 
 /* KX to PK mapping. */
-enum MHD_GNUTLS_PublicKeyAlgorithm mhd_gtls_map_pk_get_pk (enum
+enum MHD_GNUTLS_PublicKeyAlgorithm MHD_gtls_map_pk_get_pk (enum
                                                            MHD_GNUTLS_KeyExchangeAlgorithm
                                                            kx_algorithm);
-enum MHD_GNUTLS_PublicKeyAlgorithm mhd_gtls_x509_oid2pk_algorithm (const char
+enum MHD_GNUTLS_PublicKeyAlgorithm MHD_gtls_x509_oid2pk_algorithm (const char
                                                                    *oid);
-const char *mhd_gtls_x509_pk_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm pk);
+const char *MHD_gtls_x509_pk_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm pk);
 
 enum encipher_type
 { CIPHER_ENCRYPT = 0, CIPHER_SIGN = 1, CIPHER_IGN };
 
-enum encipher_type mhd_gtls_kx_encipher_type (enum
+enum encipher_type MHD_gtls_kx_encipher_type (enum
                                               MHD_GNUTLS_KeyExchangeAlgorithm
                                               algorithm);
 
-struct mhd_gtls_compression_entry
+struct MHD_gtls_compression_entry
 {
   const char *name;
   enum MHD_GNUTLS_CompressionMethod id;
@@ -137,26 +137,26 @@ struct mhd_gtls_compression_entry
   int mem_level;
   int comp_level;
 };
-typedef struct mhd_gtls_compression_entry gnutls_compression_entry;
+typedef struct MHD_gtls_compression_entry MHD_gnutls_compression_entry;
 
 /* Functions for sign algorithms. */
-gnutls_sign_algorithm_t mhd_gtls_x509_oid2sign_algorithm (const char *oid);
-gnutls_sign_algorithm_t mhd_gtls_x509_pk_to_sign (enum
+MHD_gnutls_sign_algorithm_t MHD_gtls_x509_oid2sign_algorithm (const char *oid);
+MHD_gnutls_sign_algorithm_t MHD_gtls_x509_pk_to_sign (enum
                                                   MHD_GNUTLS_PublicKeyAlgorithm
                                                   pk,
                                                   enum
                                                   MHD_GNUTLS_HashAlgorithm
                                                   mac);
-const char *mhd_gtls_x509_sign_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm,
+const char *MHD_gtls_x509_sign_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm,
                                        enum MHD_GNUTLS_HashAlgorithm mac);
 
-int mhd_gtls_mac_priority (mhd_gtls_session_t session,
+int MHD_gtls_mac_priority (MHD_gtls_session_t session,
                            enum MHD_GNUTLS_HashAlgorithm algorithm);
-int mhd_gtls_cipher_priority (mhd_gtls_session_t session,
+int MHD_gtls_cipher_priority (MHD_gtls_session_t session,
                               enum MHD_GNUTLS_CipherAlgorithm algorithm);
-int mhd_gtls_kx_priority (mhd_gtls_session_t session,
+int MHD_gtls_kx_priority (MHD_gtls_session_t session,
                           enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm);
-int mhd_gtls_compression_priority (mhd_gtls_session_t session,
+int MHD_gtls_compression_priority (MHD_gtls_session_t session,
                                    enum MHD_GNUTLS_CompressionMethod
                                    algorithm);
 

+ 24 - 24
src/daemon/https/tls/gnutls_anon_cred.c

@@ -36,23 +36,23 @@
 static const int anon_dummy;
 
 /**
-  * MHD_gnutls_anon_free_server_credentials - Used to free an allocated mhd_gtls_anon_server_credentials_t structure
-  * @sc: is an #mhd_gtls_anon_server_credentials_t structure.
+  * MHD__gnutls_anon_free_server_credentials - Used to free an allocated MHD_gtls_anon_server_credentials_t structure
+  * @sc: is an #MHD_gtls_anon_server_credentials_t structure.
   *
   * This structure is complex enough to manipulate directly thus this
   * helper function is provided in order to free (deallocate) it.
   **/
 void
-MHD_gnutls_anon_free_server_credentials (mhd_gtls_anon_server_credentials_t
+MHD__gnutls_anon_free_server_credentials (MHD_gtls_anon_server_credentials_t
                                          sc)
 {
 
-  gnutls_free (sc);
+  MHD_gnutls_free (sc);
 }
 
 /**
-  * MHD_gnutls_anon_allocate_server_credentials - Used to allocate an mhd_gtls_anon_server_credentials_t structure
-  * @sc: is a pointer to an #mhd_gtls_anon_server_credentials_t structure.
+  * MHD__gnutls_anon_allocate_server_credentials - Used to allocate an MHD_gtls_anon_server_credentials_t structure
+  * @sc: is a pointer to an #MHD_gtls_anon_server_credentials_t structure.
   *
   * This structure is complex enough to manipulate directly thus this
   * 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
   * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
   **/
 int
-  MHD_gnutls_anon_allocate_server_credentials
-  (mhd_gtls_anon_server_credentials_t * sc)
+  MHD__gnutls_anon_allocate_server_credentials
+  (MHD_gtls_anon_server_credentials_t * sc)
 {
-  *sc = gnutls_calloc (1, sizeof (mhd_anon_server_credentials_st));
+  *sc = MHD_gnutls_calloc (1, sizeof (mhd_anon_server_credentials_st));
   if (*sc == NULL)
     return GNUTLS_E_MEMORY_ERROR;
 
@@ -72,21 +72,21 @@ int
 
 
 /**
-  * MHD_gnutls_anon_free_client_credentials - Used to free an allocated mhd_gtls_anon_client_credentials_t structure
-  * @sc: is an #mhd_gtls_anon_client_credentials_t structure.
+  * MHD__gnutls_anon_free_client_credentials - Used to free an allocated MHD_gtls_anon_client_credentials_t structure
+  * @sc: is an #MHD_gtls_anon_client_credentials_t structure.
   *
   * This structure is complex enough to manipulate directly thus this
   * helper function is provided in order to free (deallocate) it.
   **/
 void
-MHD_gnutls_anon_free_client_credentials (mhd_gtls_anon_client_credentials_t
+MHD__gnutls_anon_free_client_credentials (MHD_gtls_anon_client_credentials_t
                                          sc)
 {
 }
 
 /**
- * MHD_gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure
- * @sc: is a pointer to an #mhd_gtls_anon_client_credentials_t structure.
+ * MHD__gnutls_anon_allocate_client_credentials - Used to allocate a credentials structure
+ * @sc: is a pointer to an #MHD_gtls_anon_client_credentials_t structure.
  *
  * This structure is complex enough to manipulate directly thus
  * 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
  * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
  **/
 int
-  MHD_gnutls_anon_allocate_client_credentials
-  (mhd_gtls_anon_client_credentials_t * sc)
+  MHD__gnutls_anon_allocate_client_credentials
+  (MHD_gtls_anon_client_credentials_t * sc)
 {
   /* anon_dummy is only there for *sc not to be null.
    * it is not used at all;
@@ -106,8 +106,8 @@ int
 }
 
 /**
-  * MHD_gnutls_anon_set_server_dh_params - This function will set the DH parameters for a server to use
-  * @res: is a mhd_gtls_anon_server_credentials_t structure
+  * MHD__gnutls_anon_set_server_dh_params - This function will set the DH parameters for a server to use
+  * @res: is a MHD_gtls_anon_server_credentials_t structure
   * @dh_params: is a structure that holds diffie hellman parameters.
   *
   * This function will set the diffie hellman parameters for an
@@ -115,15 +115,15 @@ int
   * Anonymous Diffie Hellman cipher suites.
   **/
 void
-MHD_gnutls_anon_set_server_dh_params (mhd_gtls_anon_server_credentials_t res,
-                                      mhd_gtls_dh_params_t dh_params)
+MHD__gnutls_anon_set_server_dh_params (MHD_gtls_anon_server_credentials_t res,
+                                      MHD_gtls_dh_params_t dh_params)
 {
   res->dh_params = dh_params;
 }
 
 /**
-  * MHD_gnutls_anon_set_server_params_function - This function will set the DH parameters callback
-  * @res: is a mhd_gtls_cert_credentials_t structure
+  * MHD__gnutls_anon_set_server_params_function - This function will set the DH parameters callback
+  * @res: is a MHD_gtls_cert_credentials_t structure
   * @func: is the function to be called
   *
   * 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,
   * callback should return zero on success.
   **/
 void
-MHD_gnutls_anon_set_server_params_function (mhd_gtls_anon_server_credentials_t
+MHD__gnutls_anon_set_server_params_function (MHD_gtls_anon_server_credentials_t
                                             res,
-                                            gnutls_params_function * func)
+                                            MHD_gnutls_params_function * func)
 {
   res->params_func = func;
 }

+ 1 - 1
src/daemon/https/tls/gnutls_asn1_tab.c

@@ -4,7 +4,7 @@
 
 #include <libtasn1.h>
 
-const ASN1_ARRAY_TYPE gnutls_asn1_tab[] = {
+const ASN1_ARRAY_TYPE MHD_gnutlsMHD__asn1_tab[] = {
   {"GNUTLS", 536872976, 0},
   {0, 1073741836, 0},
   {"RSAPublicKey", 1610612741, 0},

+ 52 - 52
src/daemon/https/tls/gnutls_auth.c

@@ -37,14 +37,14 @@
  */
 
 /**
-  * MHD_gnutls_credentials_clear - Clears all the credentials previously set
-  * @session: is a #mhd_gtls_session_t structure.
+  * MHD__gnutls_credentials_clear - Clears all the credentials previously set
+  * @session: is a #MHD_gtls_session_t structure.
   *
   * Clears all the credentials previously set in this session.
   *
   **/
 void
-MHD_gnutls_credentials_clear (mhd_gtls_session_t session)
+MHD__gnutls_credentials_clear (MHD_gtls_session_t session)
 {
   if (session->key && session->key->cred)
     {                           /* beginning of the list */
@@ -53,7 +53,7 @@ MHD_gnutls_credentials_clear (mhd_gtls_session_t session)
       while (ccred != NULL)
         {
           ncred = ccred->next;
-          gnutls_free (ccred);
+          MHD_gnutls_free (ccred);
           ccred = ncred;
         }
       session->key->cred = NULL;
@@ -65,8 +65,8 @@ MHD_gnutls_credentials_clear (mhd_gtls_session_t session)
  * { algorithm, credentials, pointer to next }
  */
 /**
-  * MHD_gnutls_credentials_set - Sets the needed credentials for the specified authentication algorithm.
-  * @session: is a #mhd_gtls_session_t structure.
+  * MHD__gnutls_credentials_set - Sets the needed credentials for the specified authentication algorithm.
+  * @session: is a #MHD_gtls_session_t structure.
   * @type: is the type of the credentials
   * @cred: is a pointer to a structure.
   *
@@ -77,20 +77,20 @@ MHD_gnutls_credentials_clear (mhd_gtls_session_t session)
   * [ In order to minimize memory usage, and share credentials between
   * several threads gnutls keeps a pointer to cred, and not the whole cred
   * structure. Thus you will have to keep the structure allocated until
-  * you call MHD_gnutls_deinit(). ]
+  * you call MHD__gnutls_deinit(). ]
   *
-  * For GNUTLS_CRD_ANON cred should be mhd_gtls_anon_client_credentials_t in case of a client.
-  * In case of a server it should be mhd_gtls_anon_server_credentials_t.
+  * For GNUTLS_CRD_ANON cred should be MHD_gtls_anon_client_credentials_t in case of a client.
+  * In case of a server it should be MHD_gtls_anon_server_credentials_t.
   *
-  * For GNUTLS_CRD_SRP cred should be gnutls_srp_client_credentials_t
-  * in case of a client, and gnutls_srp_server_credentials_t, in case
+  * For GNUTLS_CRD_SRP cred should be MHD_gnutls_srp_client_credentials_t
+  * in case of a client, and MHD_gnutls_srp_server_credentials_t, in case
   * of a server.
   *
-  * For GNUTLS_CRD_CERTIFICATE cred should be mhd_gtls_cert_credentials_t.
+  * For GNUTLS_CRD_CERTIFICATE cred should be MHD_gtls_cert_credentials_t.
   *
   **/
 int
-MHD_gnutls_credentials_set (mhd_gtls_session_t session,
+MHD__gnutls_credentials_set (MHD_gtls_session_t session,
                             enum MHD_GNUTLS_CredentialsType type, void *cred)
 {
   auth_cred_st *ccred = NULL, *pcred = NULL;
@@ -99,7 +99,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session,
   if (session->key->cred == NULL)
     {                           /* beginning of the list */
 
-      session->key->cred = gnutls_malloc (sizeof (auth_cred_st));
+      session->key->cred = MHD_gnutls_malloc (sizeof (auth_cred_st));
       if (session->key->cred == NULL)
         return GNUTLS_E_MEMORY_ERROR;
 
@@ -127,7 +127,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session,
 
       if (exists == 0)
         {                       /* new entry */
-          pcred->next = gnutls_malloc (sizeof (auth_cred_st));
+          pcred->next = MHD_gnutls_malloc (sizeof (auth_cred_st));
           if (pcred->next == NULL)
             return GNUTLS_E_MEMORY_ERROR;
 
@@ -141,7 +141,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session,
         }
       else
         {                       /* modify existing entry */
-          gnutls_free (ccred->credentials);
+          MHD_gnutls_free (ccred->credentials);
           ccred->credentials = cred;
         }
     }
@@ -151,7 +151,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session,
 
 /**
   * MHD_gtls_auth_get_type - Returns the type of credentials for the current authentication schema.
-  * @session: is a #mhd_gtls_session_t structure.
+  * @session: is a #MHD_gtls_session_t structure.
   *
   * Returns type of credentials for the current authentication schema.
   * 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,
   * the same function are to be used to access the authentication data.
   **/
 enum MHD_GNUTLS_CredentialsType
-MHD_gtls_auth_get_type (mhd_gtls_session_t session)
+MHD_gtls_auth_get_type (MHD_gtls_session_t session)
 {
 /* This is not the credentials we must set, but the authentication data
  * we get by the peer, so it should be reversed.
@@ -169,14 +169,14 @@ MHD_gtls_auth_get_type (mhd_gtls_session_t session)
   int server = session->security_parameters.entity == GNUTLS_SERVER ? 0 : 1;
 
   return
-    mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
+    MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo
                               (&session->security_parameters.
                                current_cipher_suite), server);
 }
 
 /**
   * MHD_gtls_auth_server_get_type - Returns the type of credentials for the server authentication schema.
-  * @session: is a #mhd_gtls_session_t structure.
+  * @session: is a #MHD_gtls_session_t structure.
   *
   * Returns the type of credentials that were used for server authentication.
   * 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)
   *
   **/
 enum MHD_GNUTLS_CredentialsType
-MHD_gtls_auth_server_get_type (mhd_gtls_session_t session)
+MHD_gtls_auth_server_get_type (MHD_gtls_session_t session)
 {
   return
-    mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
+    MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo
                               (&session->security_parameters.
                                current_cipher_suite), 1);
 }
 
 /**
   * MHD_gtls_auth_client_get_type - Returns the type of credentials for the client authentication schema.
-  * @session: is a #mhd_gtls_session_t structure.
+  * @session: is a #MHD_gtls_session_t structure.
   *
   * Returns the type of credentials that were used for client authentication.
   * 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)
   *
   **/
 enum MHD_GNUTLS_CredentialsType
-MHD_gtls_auth_client_get_type (mhd_gtls_session_t session)
+MHD_gtls_auth_client_get_type (MHD_gtls_session_t session)
 {
   return
-    mhd_gtls_map_kx_get_cred (mhd_gtls_cipher_suite_get_kx_algo
+    MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo
                               (&session->security_parameters.
                                current_cipher_suite), 0);
 }
@@ -216,17 +216,17 @@ MHD_gtls_auth_client_get_type (mhd_gtls_session_t session)
  * free that!!!
  */
 const void *
-mhd_gtls_get_kx_cred (mhd_gtls_session_t session,
+MHD_gtls_get_kx_cred (MHD_gtls_session_t session,
                       enum MHD_GNUTLS_KeyExchangeAlgorithm algo, int *err)
 {
   int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0;
 
-  return mhd_gtls_get_cred (session->key,
-                            mhd_gtls_map_kx_get_cred (algo, server), err);
+  return MHD_gtls_get_cred (session->key,
+                            MHD_gtls_map_kx_get_cred (algo, server), err);
 }
 
 const void *
-mhd_gtls_get_cred (mhd_gtls_key_st key, enum MHD_GNUTLS_CredentialsType type,
+MHD_gtls_get_cred (MHD_gtls_key_st key, enum MHD_GNUTLS_CredentialsType type,
                    int *err)
 {
   const void *retval = NULL;
@@ -258,10 +258,10 @@ out:
 }
 
 /*-
-  * mhd_gtls_get_auth_info - Returns a pointer to authentication information.
-  * @session: is a #mhd_gtls_session_t structure.
+  * MHD_gtls_get_auth_info - Returns a pointer to authentication information.
+  * @session: is a #MHD_gtls_session_t structure.
   *
-  * This function must be called after a succesful MHD_gnutls_handshake().
+  * This function must be called after a succesful MHD__gnutls_handshake().
   * Returns a pointer to authentication information. That information
   * is data obtained by the handshake protocol, the key exchange algorithm,
   * and the TLS extensions messages.
@@ -271,28 +271,28 @@ out:
   * In case of GNUTLS_CRD_SRP returns a type of &srp_(server/client)_auth_info_t;
   -*/
 void *
-mhd_gtls_get_auth_info (mhd_gtls_session_t session)
+MHD_gtls_get_auth_info (MHD_gtls_session_t session)
 {
   return session->key->auth_info;
 }
 
 /*-
-  * mhd_gtls_free_auth_info - Frees the auth info structure
-  * @session: is a #mhd_gtls_session_t structure.
+  * MHD_gtls_free_auth_info - Frees the auth info structure
+  * @session: is a #MHD_gtls_session_t structure.
   *
   * This function frees the auth info structure and sets it to
   * null. It must be called since some structures contain malloced
   * elements.
   -*/
 void
-mhd_gtls_free_auth_info (mhd_gtls_session_t session)
+MHD_gtls_free_auth_info (MHD_gtls_session_t session)
 {
-  mhd_gtls_dh_info_st *dh_info;
+  MHD_gtls_dh_info_st *dh_info;
   rsa_info_st *rsa_info;
 
   if (session == NULL || session->key == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return;
     }
 
@@ -302,19 +302,19 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session)
       break;
     case MHD_GNUTLS_CRD_ANON:
       {
-        mhd_anon_auth_info_t info = mhd_gtls_get_auth_info (session);
+        mhd_anon_auth_info_t info = MHD_gtls_get_auth_info (session);
 
         if (info == NULL)
           break;
 
         dh_info = &info->dh;
-        mhd_gtls_free_dh_info (dh_info);
+        MHD_gtls_free_dh_info (dh_info);
       }
       break;
     case MHD_GNUTLS_CRD_CERTIFICATE:
       {
         unsigned int i;
-        cert_auth_info_t info = mhd_gtls_get_auth_info (session);
+        cert_auth_info_t info = MHD_gtls_get_auth_info (session);
 
         if (info == NULL)
           break;
@@ -323,15 +323,15 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session)
         rsa_info = &info->rsa_export;
         for (i = 0; i < info->ncerts; i++)
           {
-            _gnutls_free_datum (&info->raw_certificate_list[i]);
+            MHD__gnutls_free_datum (&info->raw_certificate_list[i]);
           }
 
-        gnutls_free (info->raw_certificate_list);
+        MHD_gnutls_free (info->raw_certificate_list);
         info->raw_certificate_list = NULL;
         info->ncerts = 0;
 
-        mhd_gtls_free_dh_info (dh_info);
-        mhd_gtls_free_rsa_info (rsa_info);
+        MHD_gtls_free_dh_info (dh_info);
+        MHD_gtls_free_rsa_info (rsa_info);
       }
 
 
@@ -341,7 +341,7 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session)
 
     }
 
-  gnutls_free (session->key->auth_info);
+  MHD_gnutls_free (session->key->auth_info);
   session->key->auth_info = NULL;
   session->key->auth_info_size = 0;
   session->key->auth_info_type = 0;
@@ -354,16 +354,16 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session)
  * info structure to a different type.
  */
 int
-mhd_gtls_auth_info_set (mhd_gtls_session_t session,
+MHD_gtls_auth_info_set (MHD_gtls_session_t session,
                         enum MHD_GNUTLS_CredentialsType type, int size,
                         int allow_change)
 {
   if (session->key->auth_info == NULL)
     {
-      session->key->auth_info = gnutls_calloc (1, size);
+      session->key->auth_info = MHD_gnutls_calloc (1, size);
       if (session->key->auth_info == NULL)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_MEMORY_ERROR;
         }
       session->key->auth_info_type = type;
@@ -382,7 +382,7 @@ mhd_gtls_auth_info_set (mhd_gtls_session_t session,
           if (MHD_gtls_auth_get_type (session) !=
               session->key->auth_info_type)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_INVALID_REQUEST;
             }
         }
@@ -398,12 +398,12 @@ mhd_gtls_auth_info_set (mhd_gtls_session_t session,
               session->key->auth_info_type)
             {
 
-              mhd_gtls_free_auth_info (session);
+              MHD_gtls_free_auth_info (session);
 
               session->key->auth_info = calloc (1, size);
               if (session->key->auth_info == NULL)
                 {
-                  gnutls_assert ();
+                  MHD_gnutls_assert ();
                   return GNUTLS_E_MEMORY_ERROR;
                 }
 

+ 14 - 14
src/daemon/https/tls/gnutls_auth.h

@@ -25,27 +25,27 @@
 #ifndef GNUTLS_AUTH_H
 #define GNUTLS_AUTH_H
 
-typedef struct mhd_gtls_mod_auth_st_int
+typedef struct MHD_gtls_mod_auth_st_int
 {
   const char *name;             /* null terminated */
-  int (*mhd_gtls_gen_server_certificate) (mhd_gtls_session_t, opaque **);
-  int (*mhd_gtls_gen_client_certificate) (mhd_gtls_session_t, opaque **);
-  int (*mhd_gtls_gen_server_kx) (mhd_gtls_session_t, opaque **);
-  int (*mhd_gtls_gen_client_kx) (mhd_gtls_session_t, opaque **);        /* used in SRP */
-  int (*mhd_gtls_gen_client_cert_vrfy) (mhd_gtls_session_t, opaque **);
-  int (*mhd_gtls_gen_server_certificate_request) (mhd_gtls_session_t,
+  int (*MHD_gtls_gen_server_certificate) (MHD_gtls_session_t, opaque **);
+  int (*MHD_gtls_gen_client_certificate) (MHD_gtls_session_t, opaque **);
+  int (*MHD_gtls_gen_server_kx) (MHD_gtls_session_t, opaque **);
+  int (*MHD_gtls_gen_client_kx) (MHD_gtls_session_t, opaque **);        /* used in SRP */
+  int (*MHD_gtls_gen_client_cert_vrfy) (MHD_gtls_session_t, opaque **);
+  int (*MHD_gtls_gen_server_certificate_request) (MHD_gtls_session_t,
                                                   opaque **);
 
-  int (*mhd_gtls_process_server_certificate) (mhd_gtls_session_t, opaque *,
+  int (*MHD_gtls_process_server_certificate) (MHD_gtls_session_t, opaque *,
                                               size_t);
-  int (*mhd_gtls_process_client_certificate) (mhd_gtls_session_t, opaque *,
+  int (*MHD_gtls_process_client_certificate) (MHD_gtls_session_t, opaque *,
                                               size_t);
-  int (*mhd_gtls_process_server_kx) (mhd_gtls_session_t, opaque *, size_t);
-  int (*mhd_gtls_process_client_kx) (mhd_gtls_session_t, opaque *, size_t);
-  int (*mhd_gtls_process_client_cert_vrfy) (mhd_gtls_session_t, opaque *,
+  int (*MHD_gtls_process_server_kx) (MHD_gtls_session_t, opaque *, size_t);
+  int (*MHD_gtls_process_client_kx) (MHD_gtls_session_t, opaque *, size_t);
+  int (*MHD_gtls_process_client_cert_vrfy) (MHD_gtls_session_t, opaque *,
                                             size_t);
-  int (*mhd_gtls_process_server_certificate_request) (mhd_gtls_session_t,
+  int (*MHD_gtls_process_server_certificate_request) (MHD_gtls_session_t,
                                                       opaque *, size_t);
-} mhd_gtls_mod_auth_st;
+} MHD_gtls_mod_auth_st;
 
 #endif

+ 4 - 4
src/daemon/https/tls/gnutls_auth_int.h

@@ -22,12 +22,12 @@
  *
  */
 
-const void *mhd_gtls_get_cred (mhd_gtls_key_st key,
+const void *MHD_gtls_get_cred (MHD_gtls_key_st key,
                                enum MHD_GNUTLS_CredentialsType kx, int *err);
-const void *mhd_gtls_get_kx_cred (mhd_gtls_session_t session,
+const void *MHD_gtls_get_kx_cred (MHD_gtls_session_t session,
                                   enum MHD_GNUTLS_KeyExchangeAlgorithm algo,
                                   int *err);
-void *mhd_gtls_get_auth_info (mhd_gtls_session_t session);
-int mhd_gtls_auth_info_set (mhd_gtls_session_t session,
+void *MHD_gtls_get_auth_info (MHD_gtls_session_t session);
+int MHD_gtls_auth_info_set (MHD_gtls_session_t session,
                             enum MHD_GNUTLS_CredentialsType type, int size,
                             int allow_change);

Plik diff jest za duży
+ 144 - 144
src/daemon/https/tls/gnutls_buffers.c


+ 27 - 27
src/daemon/https/tls/gnutls_buffers.h

@@ -22,46 +22,46 @@
  *
  */
 
-int mhd_gnutls_record_buffer_put (content_type_t type,
-                                  mhd_gtls_session_t session, opaque * data,
+int MHD_gnutls_record_buffer_put (content_type_t type,
+                                  MHD_gtls_session_t session, opaque * data,
                                   size_t length);
-int mhd_gnutls_record_buffer_get_size (content_type_t type,
-                                       mhd_gtls_session_t session);
-int mhd_gtls_record_buffer_get (content_type_t type,
-                                mhd_gtls_session_t session, opaque * data,
+int MHD_gnutls_record_buffer_get_size (content_type_t type,
+                                       MHD_gtls_session_t session);
+int MHD_gtls_record_buffer_get (content_type_t type,
+                                MHD_gtls_session_t session, opaque * data,
                                 size_t length);
-ssize_t mhd_gtls_io_read_buffered (mhd_gtls_session_t, opaque ** iptr,
+ssize_t MHD_gtls_io_read_buffered (MHD_gtls_session_t, opaque ** iptr,
                                    size_t n, content_type_t);
-void mhd_gtls_io_clear_read_buffer (mhd_gtls_session_t);
-int mhd_gtls_io_clear_peeked_data (mhd_gtls_session_t session);
+void MHD_gtls_io_clear_read_buffer (MHD_gtls_session_t);
+int MHD_gtls_io_clear_peeked_data (MHD_gtls_session_t session);
 
-ssize_t mhd_gtls_io_write_buffered (mhd_gtls_session_t, const void *iptr,
+ssize_t MHD_gtls_io_write_buffered (MHD_gtls_session_t, const void *iptr,
                                     size_t n);
-ssize_t mhd_gtls_io_write_buffered2 (mhd_gtls_session_t, const void *iptr,
+ssize_t MHD_gtls_io_write_buffered2 (MHD_gtls_session_t, const void *iptr,
                                      size_t n, const void *iptr2, size_t n2);
 
-int mhd_gtls_handshake_buffer_get_size (mhd_gtls_session_t session);
-int mhd_gtls_handshake_buffer_peek (mhd_gtls_session_t session, opaque * data,
+int MHD_gtls_handshake_buffer_get_size (MHD_gtls_session_t session);
+int MHD_gtls_handshake_buffer_peek (MHD_gtls_session_t session, opaque * data,
                                     size_t length);
-int mhd_gtls_handshake_buffer_put (mhd_gtls_session_t session, opaque * data,
+int MHD_gtls_handshake_buffer_put (MHD_gtls_session_t session, opaque * data,
                                    size_t length);
-int mhd_gtls_handshake_buffer_clear (mhd_gtls_session_t session);
-int mhd_gtls_handshake_buffer_empty (mhd_gtls_session_t session);
-int mhd_gtls_handshake_buffer_get_ptr (mhd_gtls_session_t session,
+int MHD_gtls_handshake_buffer_clear (MHD_gtls_session_t session);
+int MHD_gtls_handshake_buffer_empty (MHD_gtls_session_t session);
+int MHD_gtls_handshake_buffer_get_ptr (MHD_gtls_session_t session,
                                        opaque ** data_ptr, size_t * length);
 
-#define _gnutls_handshake_io_buffer_clear( session) \
-        mhd_gtls_buffer_clear( &session->internals.handshake_send_buffer); \
-        mhd_gtls_buffer_clear( &session->internals.handshake_recv_buffer); \
+#define MHD__gnutls_handshake_io_buffer_clear( session) \
+        MHD_gtls_buffer_clear( &session->internals.handshake_send_buffer); \
+        MHD_gtls_buffer_clear( &session->internals.handshake_recv_buffer); \
         session->internals.handshake_send_buffer_prev_size = 0
 
-ssize_t mhd_gtls_handshake_io_recv_int (mhd_gtls_session_t, content_type_t,
-                                        gnutls_handshake_description_t,
+ssize_t MHD_gtls_handshake_io_recv_int (MHD_gtls_session_t, content_type_t,
+                                        MHD_gnutls_handshake_description_t,
                                         void *, size_t);
-ssize_t mhd_gtls_handshake_io_send_int (mhd_gtls_session_t, content_type_t,
-                                        gnutls_handshake_description_t,
+ssize_t MHD_gtls_handshake_io_send_int (MHD_gtls_session_t, content_type_t,
+                                        MHD_gnutls_handshake_description_t,
                                         const void *, size_t);
-ssize_t mhd_gtls_io_write_flush (mhd_gtls_session_t session);
-ssize_t mhd_gtls_handshake_io_write_flush (mhd_gtls_session_t session);
+ssize_t MHD_gtls_io_write_flush (MHD_gtls_session_t session);
+ssize_t MHD_gtls_handshake_io_write_flush (MHD_gtls_session_t session);
 
-size_t MHD_gtls_record_check_pending (mhd_gtls_session_t session);
+size_t MHD_gtls_record_check_pending (MHD_gtls_session_t session);

+ 141 - 141
src/daemon/https/tls/gnutls_cert.c

@@ -45,8 +45,8 @@
 #include "mpi.h"
 
 /**
-  * MHD_gnutls_certificate_free_keys - Used to free all the keys from a mhd_gtls_cert_credentials_t structure
-  * @sc: is an #mhd_gtls_cert_credentials_t structure.
+  * MHD__gnutls_certificate_free_keys - Used to free all the keys from a MHD_gtls_cert_credentials_t structure
+  * @sc: is an #MHD_gtls_cert_credentials_t structure.
   *
   * This function will delete all the keys and the certificates associated
   * with the given credentials. This function must not be called when a
@@ -54,7 +54,7 @@
   *
   **/
 void
-MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
+MHD__gnutls_certificate_free_keys (MHD_gtls_cert_credentials_t sc)
 {
   unsigned i, j;
 
@@ -62,23 +62,23 @@ MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
     {
       for (j = 0; j < sc->cert_list_length[i]; j++)
         {
-          mhd_gtls_gcert_deinit (&sc->cert_list[i][j]);
+          MHD_gtls_gcert_deinit (&sc->cert_list[i][j]);
         }
-      gnutls_free (sc->cert_list[i]);
+      MHD_gnutls_free (sc->cert_list[i]);
     }
 
-  gnutls_free (sc->cert_list_length);
+  MHD_gnutls_free (sc->cert_list_length);
   sc->cert_list_length = NULL;
 
-  gnutls_free (sc->cert_list);
+  MHD_gnutls_free (sc->cert_list);
   sc->cert_list = NULL;
 
   for (i = 0; i < sc->ncerts; i++)
     {
-      mhd_gtls_gkey_deinit (&sc->pkey[i]);
+      MHD_gtls_gkey_deinit (&sc->pkey[i]);
     }
 
-  gnutls_free (sc->pkey);
+  MHD_gnutls_free (sc->pkey);
   sc->pkey = NULL;
 
   sc->ncerts = 0;
@@ -86,8 +86,8 @@ MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
 }
 
 /**
-  * MHD_gnutls_certificate_free_cas - Used to free all the CAs from a mhd_gtls_cert_credentials_t structure
-  * @sc: is an #mhd_gtls_cert_credentials_t structure.
+  * MHD__gnutls_certificate_free_cas - Used to free all the CAs from a MHD_gtls_cert_credentials_t structure
+  * @sc: is an #MHD_gtls_cert_credentials_t structure.
   *
   * This function will delete all the CAs associated
   * with the given credentials. Servers that do not use
@@ -96,25 +96,25 @@ MHD_gnutls_certificate_free_keys (mhd_gtls_cert_credentials_t sc)
   *
   **/
 void
-MHD_gnutls_certificate_free_cas (mhd_gtls_cert_credentials_t sc)
+MHD__gnutls_certificate_free_cas (MHD_gtls_cert_credentials_t sc)
 {
   unsigned j;
 
   for (j = 0; j < sc->x509_ncas; j++)
     {
-      gnutls_x509_crt_deinit (sc->x509_ca_list[j]);
+      MHD_gnutls_x509_crt_deinit (sc->x509_ca_list[j]);
     }
 
   sc->x509_ncas = 0;
 
-  gnutls_free (sc->x509_ca_list);
+  MHD_gnutls_free (sc->x509_ca_list);
   sc->x509_ca_list = NULL;
 
 }
 
 /**
-  * MHD_gnutls_certificate_free_ca_names - Used to free all the CA names from a mhd_gtls_cert_credentials_t structure
-  * @sc: is an #mhd_gtls_cert_credentials_t structure.
+  * MHD__gnutls_certificate_free_ca_names - Used to free all the CA names from a MHD_gtls_cert_credentials_t structure
+  * @sc: is an #MHD_gtls_cert_credentials_t structure.
   *
   * This function will delete all the CA name in the
   * 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)
   *
   **/
 void
-MHD_gnutls_certificate_free_ca_names (mhd_gtls_cert_credentials_t sc)
+MHD__gnutls_certificate_free_ca_names (MHD_gtls_cert_credentials_t sc)
 {
-  _gnutls_free_datum (&sc->x509_rdn_sequence);
+  MHD__gnutls_free_datum (&sc->x509_rdn_sequence);
 }
 
 /*-
-  * mhd_gtls_certificate_get_rsa_params - Returns the RSA parameters pointer
+  * MHD_gtls_certificate_get_rsa_params - Returns the RSA parameters pointer
   * @rsa_params: holds the RSA parameters or NULL.
   * @func: function to retrieve the parameters or NULL.
   * @session: The session.
@@ -139,12 +139,12 @@ MHD_gnutls_certificate_free_ca_names (mhd_gtls_cert_credentials_t sc)
   * This function will return the rsa parameters pointer.
   *
   -*/
-mhd_gtls_rsa_params_t
-mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params,
-                                     gnutls_params_function * func,
-                                     mhd_gtls_session_t session)
+MHD_gtls_rsa_params_t
+MHD_gtls_certificate_get_rsa_params (MHD_gtls_rsa_params_t rsa_params,
+                                     MHD_gnutls_params_function * func,
+                                     MHD_gtls_session_t session)
 {
-  gnutls_params_st params;
+  MHD_gnutls_params_st params;
   int ret;
 
   if (session->internals.params.rsa_params)
@@ -171,8 +171,8 @@ mhd_gtls_certificate_get_rsa_params (mhd_gtls_rsa_params_t rsa_params,
 
 
 /**
-  * MHD_gnutls_certificate_free_credentials - Used to free an allocated mhd_gtls_cert_credentials_t structure
-  * @sc: is an #mhd_gtls_cert_credentials_t structure.
+  * MHD__gnutls_certificate_free_credentials - Used to free an allocated MHD_gtls_cert_credentials_t structure
+  * @sc: is an #MHD_gtls_cert_credentials_t structure.
   *
   * This structure is complex enough to manipulate directly thus
   * 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,
   * this function).
   **/
 void
-MHD_gnutls_certificate_free_credentials (mhd_gtls_cert_credentials_t sc)
+MHD__gnutls_certificate_free_credentials (MHD_gtls_cert_credentials_t sc)
 {
-  MHD_gnutls_certificate_free_keys (sc);
-  MHD_gnutls_certificate_free_cas (sc);
-  MHD_gnutls_certificate_free_ca_names (sc);
+  MHD__gnutls_certificate_free_keys (sc);
+  MHD__gnutls_certificate_free_cas (sc);
+  MHD__gnutls_certificate_free_ca_names (sc);
 #ifdef ENABLE_PKI
-  MHD_gnutls_certificate_free_crls (sc);
+  MHD__gnutls_certificate_free_crls (sc);
 #endif
 
 #ifdef KEYRING_HACK
-  _gnutls_free_datum (&sc->keyring);
+  MHD__gnutls_free_datum (&sc->keyring);
 #endif
 
-  gnutls_free (sc);
+  MHD_gnutls_free (sc);
 }
 
 
 /**
-  * MHD_gnutls_certificate_allocate_credentials - Used to allocate a mhd_gtls_cert_credentials_t structure
-  * @res: is a pointer to an #mhd_gtls_cert_credentials_t structure.
+  * MHD__gnutls_certificate_allocate_credentials - Used to allocate a MHD_gtls_cert_credentials_t structure
+  * @res: is a pointer to an #MHD_gtls_cert_credentials_t structure.
   *
   * This structure is complex enough to manipulate directly thus this
   * helper function is provided in order to allocate it.
@@ -209,10 +209,10 @@ MHD_gnutls_certificate_free_credentials (mhd_gtls_cert_credentials_t sc)
   * Returns: %GNUTLS_E_SUCCESS on success, or an error code.
   **/
 int
-MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t *
+MHD__gnutls_certificate_allocate_credentials (MHD_gtls_cert_credentials_t *
                                              res)
 {
-  *res = gnutls_calloc (1, sizeof (mhd_gtls_cert_credentials_st));
+  *res = MHD_gnutls_calloc (1, sizeof (MHD_gtls_cert_credentials_st));
 
   if (*res == NULL)
     return GNUTLS_E_MEMORY_ERROR;
@@ -231,14 +231,14 @@ MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t *
  * extensions in order to disable unneded algorithms.
  */
 int
-mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
+MHD_gtls_selected_cert_supported_kx (MHD_gtls_session_t session,
                                      enum MHD_GNUTLS_KeyExchangeAlgorithm
                                      **alg, int *alg_size)
 {
   enum MHD_GNUTLS_KeyExchangeAlgorithm kx;
   enum MHD_GNUTLS_PublicKeyAlgorithm pk;
   enum MHD_GNUTLS_KeyExchangeAlgorithm kxlist[MAX_ALGOS];
-  gnutls_cert *cert;
+  MHD_gnutls_cert *cert;
   int i;
 
   if (session->internals.selected_cert_list_length == 0)
@@ -253,11 +253,11 @@ mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
 
   for (kx = 0; kx < MAX_ALGOS; kx++)
     {
-      pk = mhd_gtls_map_pk_get_pk (kx);
+      pk = MHD_gtls_map_pk_get_pk (kx);
       if (pk == cert->subject_pk_algorithm)
         {
           /* then check key usage */
-          if (_gnutls_check_key_usage (cert, kx) == 0)
+          if (MHD__gnutls_check_key_usage (cert, kx) == 0)
             {
               kxlist[i] = kx;
               i++;
@@ -267,11 +267,11 @@ mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
 
   if (i == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INVALID_REQUEST;
     }
 
-  *alg = gnutls_calloc (1, sizeof (enum MHD_GNUTLS_KeyExchangeAlgorithm) * i);
+  *alg = MHD_gnutls_calloc (1, sizeof (enum MHD_GNUTLS_KeyExchangeAlgorithm) * i);
   if (*alg == NULL)
     return GNUTLS_E_MEMORY_ERROR;
 
@@ -285,7 +285,7 @@ mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session,
 
 /**
   * MHD_gtls_certificate_server_set_request - Used to set whether to request a client certificate
-  * @session: is an #mhd_gtls_session_t structure.
+  * @session: is an #MHD_gtls_session_t structure.
   * @req: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE
   *
   * 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,
   * send a certificate.
   **/
 void
-MHD_gtls_certificate_server_set_request (mhd_gtls_session_t session,
-                                         gnutls_certificate_request_t req)
+MHD_gtls_certificate_server_set_request (MHD_gtls_session_t session,
+                                         MHD_gnutls_certificate_request_t req)
 {
   session->internals.send_cert_req = req;
 }
 
 /**
   * MHD_gtls_certificate_client_set_retrieve_function - Used to set a callback to retrieve the certificate
-  * @cred: is a #mhd_gtls_cert_credentials_t structure.
+  * @cred: is a #MHD_gtls_cert_credentials_t structure.
   * @func: is the callback function
   *
   * This function sets a callback to be called in order to retrieve the certificate
   * to be used in the handshake.
   * The callback's function prototype is:
-  * int (*callback)(mhd_gtls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
-  * const enum MHD_GNUTLS_PublicKeyAlgorithm* pk_algos, int pk_algos_length, gnutls_retr_st* st);
+  * int (*callback)(MHD_gtls_session_t, const MHD_gnutls_datum_t* req_ca_dn, int nreqs,
+  * const enum MHD_GNUTLS_PublicKeyAlgorithm* pk_algos, int pk_algos_length, MHD_gnutls_retr_st* st);
   *
   * @req_ca_cert is only used in X.509 certificates.
   * Contains a list with the CA names that the server considers trusted.
   * Normally we should send a certificate that is signed
   * by one of these CAs. These names are DER encoded. To get a more
-  * meaningful value use the function gnutls_x509_rdn_get().
+  * meaningful value use the function MHD_gnutls_x509_rdn_get().
   *
   * @pk_algos contains a list with server's acceptable signature algorithms.
   * 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,
   * will be terminated.
   **/
 void MHD_gtls_certificate_client_set_retrieve_function
-  (mhd_gtls_cert_credentials_t cred,
-   gnutls_certificate_client_retrieve_function * func)
+  (MHD_gtls_cert_credentials_t cred,
+   MHD_gnutls_certificate_client_retrieve_function * func)
 {
   cred->client_get_cert_callback = func;
 }
 
 /**
   * MHD_gtls_certificate_server_set_retrieve_function - Used to set a callback to retrieve the certificate
-  * @cred: is a #mhd_gtls_cert_credentials_t structure.
+  * @cred: is a #MHD_gtls_cert_credentials_t structure.
   * @func: is the callback function
   *
   * This function sets a callback to be called in order to retrieve the certificate
   * to be used in the handshake.
   * The callback's function prototype is:
-  * int (*callback)(mhd_gtls_session_t, gnutls_retr_st* st);
+  * int (*callback)(MHD_gtls_session_t, MHD_gnutls_retr_st* st);
   *
   * @st should contain the certificates and private keys.
   *
@@ -359,14 +359,14 @@ void MHD_gtls_certificate_client_set_retrieve_function
   * will be terminated.
   **/
 void MHD_gtls_certificate_server_set_retrieve_function
-  (mhd_gtls_cert_credentials_t cred,
-   gnutls_certificate_server_retrieve_function * func)
+  (MHD_gtls_cert_credentials_t cred,
+   MHD_gnutls_certificate_server_retrieve_function * func)
 {
   cred->server_get_cert_callback = func;
 }
 
 /*-
- * _gnutls_x509_extract_certificate_activation_time - This function returns the peer's certificate activation time
+ * MHD__gnutls_x509_extract_certificate_activation_time - This function returns the peer's certificate activation time
  * @cert: should contain an X.509 DER encoded certificate
  *
  * This function will return the certificate's activation time in UNIX time
@@ -376,31 +376,31 @@ void MHD_gtls_certificate_server_set_retrieve_function
  *
  -*/
 static time_t
-_gnutls_x509_get_raw_crt_activation_time (const gnutls_datum_t * cert)
+MHD__gnutls_x509_get_raw_crt_activation_time (const MHD_gnutls_datum_t * cert)
 {
-  gnutls_x509_crt_t xcert;
+  MHD_gnutls_x509_crt_t xcert;
   time_t result;
 
-  result = gnutls_x509_crt_init (&xcert);
+  result = MHD_gnutls_x509_crt_init (&xcert);
   if (result < 0)
     return (time_t) - 1;
 
-  result = gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER);
+  result = MHD_gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER);
   if (result < 0)
     {
-      gnutls_x509_crt_deinit (xcert);
+      MHD_gnutls_x509_crt_deinit (xcert);
       return (time_t) - 1;
     }
 
-  result = gnutls_x509_crt_get_activation_time (xcert);
+  result = MHD_gnutls_x509_crt_get_activation_time (xcert);
 
-  gnutls_x509_crt_deinit (xcert);
+  MHD_gnutls_x509_crt_deinit (xcert);
 
   return result;
 }
 
 /*-
- * gnutls_x509_extract_certificate_expiration_time - This function returns the certificate's expiration time
+ * MHD_gnutls_x509_extract_certificate_expiration_time - This function returns the certificate's expiration time
  * @cert: should contain an X.509 DER encoded certificate
  *
  * 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)
  *
  -*/
 static time_t
-_gnutls_x509_get_raw_crt_expiration_time (const gnutls_datum_t * cert)
+MHD__gnutls_x509_get_raw_crt_expiration_time (const MHD_gnutls_datum_t * cert)
 {
-  gnutls_x509_crt_t xcert;
+  MHD_gnutls_x509_crt_t xcert;
   time_t result;
 
-  result = gnutls_x509_crt_init (&xcert);
+  result = MHD_gnutls_x509_crt_init (&xcert);
   if (result < 0)
     return (time_t) - 1;
 
-  result = gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER);
+  result = MHD_gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER);
   if (result < 0)
     {
-      gnutls_x509_crt_deinit (xcert);
+      MHD_gnutls_x509_crt_deinit (xcert);
       return (time_t) - 1;
     }
 
-  result = gnutls_x509_crt_get_expiration_time (xcert);
+  result = MHD_gnutls_x509_crt_get_expiration_time (xcert);
 
-  gnutls_x509_crt_deinit (xcert);
+  MHD_gnutls_x509_crt_deinit (xcert);
 
   return result;
 }
@@ -440,34 +440,34 @@ _gnutls_x509_get_raw_crt_expiration_time (const gnutls_datum_t * cert)
   *
   * This function will try to verify the peer's certificate and return
   * its status (trusted, invalid etc.).  The value of @status should
-  * be one or more of the gnutls_certificate_status_t enumerated
+  * be one or more of the MHD_gnutls_certificate_status_t enumerated
   * elements bitwise or'd. To avoid denial of service attacks some
   * default upper limits regarding the certificate key size and chain
   * size are set. To override them use
-  * MHD_gnutls_certificate_set_verify_limits().
+  * MHD__gnutls_certificate_set_verify_limits().
   *
   * Note that you must also check the peer's name in order to check if
   * the verified certificate belongs to the actual peer.
   *
-  * This is the same as gnutls_x509_crt_list_verify() and uses the
+  * This is the same as MHD_gnutls_x509_crt_list_verify() and uses the
   * loaded CAs in the credentials as trusted CAs.
   *
   * Note that some commonly used X.509 Certificate Authorities are
   * still using Version 1 certificates.  If you want to accept them,
-  * you need to call MHD_gnutls_certificate_set_verify_flags() with, e.g.,
+  * you need to call MHD__gnutls_certificate_set_verify_flags() with, e.g.,
   * %GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT parameter.
   *
   * Returns: a negative error code on error and zero on success.
   **/
 int
-MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session,
+MHD_gtls_certificate_verify_peers2 (MHD_gtls_session_t session,
                                     unsigned int *status)
 {
   cert_auth_info_t info;
 
   CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
 
-  info = mhd_gtls_get_auth_info (session);
+  info = MHD_gtls_get_auth_info (session);
   if (info == NULL)
     {
       return GNUTLS_E_NO_CERTIFICATE_FOUND;
@@ -476,10 +476,10 @@ MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session,
   if (info->raw_certificate_list == NULL || info->ncerts == 0)
     return GNUTLS_E_NO_CERTIFICATE_FOUND;
 
-  switch (gnutls_certificate_type_get (session))
+  switch (MHD_gnutls_certificate_type_get (session))
     {
     case MHD_GNUTLS_CRT_X509:
-      return _gnutls_x509_cert_verify_peers (session, status);
+      return MHD__gnutls_x509_cert_verify_peers (session, status);
     default:
       return GNUTLS_E_INVALID_REQUEST;
     }
@@ -495,15 +495,15 @@ MHD_gtls_certificate_verify_peers2 (mhd_gtls_session_t session,
   * belongs to the actual peer.
   *
   * The return value should be one or more of the
-  * gnutls_certificate_status_t enumerated elements bitwise or'd, or a
+  * MHD_gnutls_certificate_status_t enumerated elements bitwise or'd, or a
   * negative value on error.
   *
-  * This is the same as gnutls_x509_crt_list_verify().
+  * This is the same as MHD_gnutls_x509_crt_list_verify().
   *
   * Deprecated: Use MHD_gtls_certificate_verify_peers2() instead.
   **/
 int
-MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session)
+MHD_gtls_certificate_verify_peers (MHD_gtls_session_t session)
 {
   unsigned int status;
   int ret;
@@ -512,7 +512,7 @@ MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session)
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
@@ -528,13 +528,13 @@ MHD_gtls_certificate_verify_peers (mhd_gtls_session_t session)
   * Returns: (time_t)-1 on error.
   **/
 time_t
-MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session)
+MHD_gtls_certificate_expiration_time_peers (MHD_gtls_session_t session)
 {
   cert_auth_info_t info;
 
   CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
 
-  info = mhd_gtls_get_auth_info (session);
+  info = MHD_gtls_get_auth_info (session);
   if (info == NULL)
     {
       return (time_t) - 1;
@@ -542,15 +542,15 @@ MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session)
 
   if (info->raw_certificate_list == NULL || info->ncerts == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return (time_t) - 1;
     }
 
-  switch (gnutls_certificate_type_get (session))
+  switch (MHD_gnutls_certificate_type_get (session))
     {
     case MHD_GNUTLS_CRT_X509:
       return
-        _gnutls_x509_get_raw_crt_expiration_time (&info->raw_certificate_list
+        MHD__gnutls_x509_get_raw_crt_expiration_time (&info->raw_certificate_list
                                                   [0]);
     default:
       return (time_t) - 1;
@@ -567,13 +567,13 @@ MHD_gtls_certificate_expiration_time_peers (mhd_gtls_session_t session)
   * Returns: (time_t)-1 on error.
   **/
 time_t
-MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session)
+MHD_gtls_certificate_activation_time_peers (MHD_gtls_session_t session)
 {
   cert_auth_info_t info;
 
   CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
 
-  info = mhd_gtls_get_auth_info (session);
+  info = MHD_gtls_get_auth_info (session);
   if (info == NULL)
     {
       return (time_t) - 1;
@@ -581,15 +581,15 @@ MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session)
 
   if (info->raw_certificate_list == NULL || info->ncerts == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return (time_t) - 1;
     }
 
-  switch (gnutls_certificate_type_get (session))
+  switch (MHD_gnutls_certificate_type_get (session))
     {
     case MHD_GNUTLS_CRT_X509:
       return
-        _gnutls_x509_get_raw_crt_activation_time (&info->raw_certificate_list
+        MHD__gnutls_x509_get_raw_crt_activation_time (&info->raw_certificate_list
                                                   [0]);
     default:
       return (time_t) - 1;
@@ -597,33 +597,33 @@ MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session)
 }
 
 int
-mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert,
+MHD_gtls_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
                             enum MHD_GNUTLS_CertificateType type,
-                            const gnutls_datum_t * raw_cert,
+                            const MHD_gnutls_datum_t * raw_cert,
                             int flags /* OR of ConvFlags */ )
 {
   switch (type)
     {
     case MHD_GNUTLS_CRT_X509:
-      return mhd_gtls_x509_raw_cert_to_gcert (gcert, raw_cert, flags);
+      return MHD_gtls_x509_raw_cert_to_gcert (gcert, raw_cert, flags);
     default:
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 }
 
 int
-mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key,
+MHD_gtls_raw_privkey_to_gkey (MHD_gnutls_privkey * key,
                               enum MHD_GNUTLS_CertificateType type,
-                              const gnutls_datum_t * raw_key,
+                              const MHD_gnutls_datum_t * raw_key,
                               int key_enc /* DER or PEM */ )
 {
   switch (type)
     {
     case MHD_GNUTLS_CRT_X509:
-      return _gnutls_x509_raw_privkey_to_gkey (key, raw_key, key_enc);
+      return MHD__gnutls_x509_raw_privkey_to_gkey (key, raw_key, key_enc);
     default:
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 }
@@ -639,30 +639,30 @@ mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key,
  * The critical extensions will be catched by the verification functions.
  */
 int
-mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
-                                 const gnutls_datum_t * derCert,
+MHD_gtls_x509_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
+                                 const MHD_gnutls_datum_t * derCert,
                                  int flags /* OR of ConvFlags */ )
 {
   int ret;
-  gnutls_x509_crt_t cert;
+  MHD_gnutls_x509_crt_t cert;
 
-  ret = gnutls_x509_crt_init (&cert);
+  ret = MHD_gnutls_x509_crt_init (&cert);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
-  ret = gnutls_x509_crt_import (cert, derCert, GNUTLS_X509_FMT_DER);
+  ret = MHD_gnutls_x509_crt_import (cert, derCert, GNUTLS_X509_FMT_DER);
   if (ret < 0)
     {
-      gnutls_assert ();
-      gnutls_x509_crt_deinit (cert);
+      MHD_gnutls_assert ();
+      MHD_gnutls_x509_crt_deinit (cert);
       return ret;
     }
 
-  ret = mhd_gtls_x509_crt_to_gcert (gcert, cert, flags);
-  gnutls_x509_crt_deinit (cert);
+  ret = MHD_gtls_x509_crt_to_gcert (gcert, cert, flags);
+  MHD_gnutls_x509_crt_deinit (cert);
 
   return ret;
 }
@@ -670,12 +670,12 @@ mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
 /* Like above but it accepts a parsed certificate instead.
  */
 int
-mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
-                            gnutls_x509_crt_t cert, unsigned int flags)
+MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert,
+                            MHD_gnutls_x509_crt_t cert, unsigned int flags)
 {
   int ret = 0;
 
-  memset (gcert, 0, sizeof (gnutls_cert));
+  memset (gcert, 0, sizeof (MHD_gnutls_cert));
   gcert->cert_type = MHD_GNUTLS_CRT_X509;
 
   if (!(flags & CERT_NO_COPY))
@@ -687,38 +687,38 @@ mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
       /* initially allocate a bogus size, just in case the certificate
        * fits in it. That way we minimize the DER encodings performed.
        */
-      der = gnutls_malloc (SMALL_DER);
+      der = MHD_gnutls_malloc (SMALL_DER);
       if (der == NULL)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_MEMORY_ERROR;
         }
 
       ret =
-        gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der, &der_size);
+        MHD_gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der, &der_size);
       if (ret < 0 && ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
         {
-          gnutls_assert ();
-          gnutls_free (der);
+          MHD_gnutls_assert ();
+          MHD_gnutls_free (der);
           return ret;
         }
 
       if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER)
         {
-          der = gnutls_realloc (der, der_size);
+          der = MHD_gnutls_realloc (der, der_size);
           if (der == NULL)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_MEMORY_ERROR;
             }
 
           ret =
-            gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der,
+            MHD_gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der,
                                     &der_size);
           if (ret < 0)
             {
-              gnutls_assert ();
-              gnutls_free (der);
+              MHD_gnutls_assert ();
+              MHD_gnutls_free (der);
               return ret;
             }
         }
@@ -733,19 +733,19 @@ mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
 
   if (flags & CERT_ONLY_EXTENSIONS || flags == 0)
     {
-      gnutls_x509_crt_get_key_usage (cert, &gcert->key_usage, NULL);
-      gcert->version = gnutls_x509_crt_get_version (cert);
+      MHD_gnutls_x509_crt_get_key_usage (cert, &gcert->key_usage, NULL);
+      gcert->version = MHD_gnutls_x509_crt_get_version (cert);
     }
-  gcert->subject_pk_algorithm = gnutls_x509_crt_get_pk_algorithm (cert, NULL);
+  gcert->subject_pk_algorithm = MHD_gnutls_x509_crt_get_pk_algorithm (cert, NULL);
 
   if (flags & CERT_ONLY_PUBKEY || flags == 0)
     {
       gcert->params_size = MAX_PUBLIC_PARAMS_SIZE;
       ret =
-        _gnutls_x509_crt_get_mpis (cert, gcert->params, &gcert->params_size);
+        MHD__gnutls_x509_crt_get_mpis (cert, gcert->params, &gcert->params_size);
       if (ret < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
     }
@@ -755,7 +755,7 @@ mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert,
 }
 
 void
-mhd_gtls_gcert_deinit (gnutls_cert * cert)
+MHD_gtls_gcert_deinit (MHD_gnutls_cert * cert)
 {
   int i;
 
@@ -764,10 +764,10 @@ mhd_gtls_gcert_deinit (gnutls_cert * cert)
 
   for (i = 0; i < cert->params_size; i++)
     {
-      mhd_gtls_mpi_release (&cert->params[i]);
+      MHD_gtls_mpi_release (&cert->params[i]);
     }
 
-  _gnutls_free_datum (&cert->raw);
+  MHD__gnutls_free_datum (&cert->raw);
 }
 
 /**
@@ -778,20 +778,20 @@ mhd_gtls_gcert_deinit (gnutls_cert * cert)
  *
  * Set the callback function.  The function must have this prototype:
  *
- * typedef int (*gnutls_sign_func) (mhd_gtls_session_t session,
+ * typedef int (*MHD_gnutls_sign_func) (MHD_gtls_session_t session,
  *                                  void *userdata,
  *                                  enum MHD_GNUTLS_CertificateType cert_type,
- *                                  const gnutls_datum_t * cert,
- *                                  const gnutls_datum_t * hash,
- *                                  gnutls_datum_t * signature);
+ *                                  const MHD_gnutls_datum_t * cert,
+ *                                  const MHD_gnutls_datum_t * hash,
+ *                                  MHD_gnutls_datum_t * signature);
  *
  * The @userdata parameter is passed to the @sign_func verbatim, and
  * can be used to store application-specific data needed in the
  * callback function.  See also MHD_gtls_sign_callback_get().
  **/
 void
-MHD_gtls_sign_callback_set (mhd_gtls_session_t session,
-                            gnutls_sign_func sign_func, void *userdata)
+MHD_gtls_sign_callback_set (MHD_gtls_session_t session,
+                            MHD_gnutls_sign_func sign_func, void *userdata)
 {
   session->internals.sign_func = sign_func;
   session->internals.sign_func_userdata = userdata;
@@ -807,8 +807,8 @@ MHD_gtls_sign_callback_set (mhd_gtls_session_t session,
  * Returns: The function pointer set by MHD_gtls_sign_callback_set(), or
  *   if not set, %NULL.
  **/
-gnutls_sign_func
-MHD_gtls_sign_callback_get (mhd_gtls_session_t session, void **userdata)
+MHD_gnutls_sign_func
+MHD_gtls_sign_callback_get (MHD_gtls_session_t session, void **userdata)
 {
   if (userdata)
     *userdata = session->internals.sign_func_userdata;

+ 16 - 16
src/daemon/https/tls/gnutls_cert.h

@@ -48,7 +48,7 @@
 #define KEY_ENCIPHER_ONLY		1
 #define KEY_DECIPHER_ONLY		32768
 
-typedef struct gnutls_cert
+typedef struct MHD_gnutls_cert
 {
   mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; /* the size of params depends on the public
                                          * key algorithm
@@ -71,11 +71,11 @@ typedef struct gnutls_cert
    */
   enum MHD_GNUTLS_CertificateType cert_type;
 
-  gnutls_datum_t raw;
+  MHD_gnutls_datum_t raw;
 
-} gnutls_cert;
+} MHD_gnutls_cert;
 
-typedef struct gnutls_privkey_int
+typedef struct MHD_gnutls_privkey_int
 {
   mpi_t params[MAX_PRIV_PARAMS_SIZE];   /* the size of params depends on the public
                                          * key algorithm
@@ -96,9 +96,9 @@ typedef struct gnutls_privkey_int
   int params_size;              /* holds the number of params */
 
   enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm;
-} gnutls_privkey;
+} MHD_gnutls_privkey;
 
-struct MHD_gtls_session_int;    /* because mhd_gtls_session_t is not defined when this file is included */
+struct MHD_gtls_session_int;    /* because MHD_gtls_session_t is not defined when this file is included */
 
 typedef enum ConvFlags
 {
@@ -107,26 +107,26 @@ typedef enum ConvFlags
   CERT_ONLY_EXTENSIONS = 16
 } ConvFlags;
 
-int mhd_gtls_x509_raw_cert_to_gcert (gnutls_cert * gcert,
-                                     const gnutls_datum_t * derCert,
+int MHD_gtls_x509_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
+                                     const MHD_gnutls_datum_t * derCert,
                                      int flags);
-int mhd_gtls_x509_crt_to_gcert (gnutls_cert * gcert, gnutls_x509_crt_t cert,
+int MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert, MHD_gnutls_x509_crt_t cert,
                                 unsigned int flags);
 
-void mhd_gtls_gkey_deinit (gnutls_privkey * key);
-void mhd_gtls_gcert_deinit (gnutls_cert * cert);
+void MHD_gtls_gkey_deinit (MHD_gnutls_privkey * key);
+void MHD_gtls_gcert_deinit (MHD_gnutls_cert * cert);
 
-int mhd_gtls_selected_cert_supported_kx (struct MHD_gtls_session_int *session,
+int MHD_gtls_selected_cert_supported_kx (struct MHD_gtls_session_int *session,
                                          enum MHD_GNUTLS_KeyExchangeAlgorithm
                                          **alg, int *alg_size);
 
-int mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert,
+int MHD_gtls_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
                                 enum MHD_GNUTLS_CertificateType type,
-                                const gnutls_datum_t * raw_cert,
+                                const MHD_gnutls_datum_t * raw_cert,
                                 int flags /* OR of ConvFlags */ );
-int mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key,
+int MHD_gtls_raw_privkey_to_gkey (MHD_gnutls_privkey * key,
                                   enum MHD_GNUTLS_CertificateType type,
-                                  const gnutls_datum_t * raw_key,
+                                  const MHD_gnutls_datum_t * raw_key,
                                   int key_enc /* DER or PEM */ );
 
 #endif

+ 78 - 78
src/daemon/https/tls/gnutls_cipher.c

@@ -42,7 +42,7 @@
 #include <gc.h>
 
 inline static int
-is_write_comp_null (mhd_gtls_session_t session)
+is_write_comp_null (MHD_gtls_session_t session)
 {
   if (session->security_parameters.write_compression_algorithm ==
       MHD_GNUTLS_COMP_NULL)
@@ -52,7 +52,7 @@ is_write_comp_null (mhd_gtls_session_t session)
 }
 
 inline static int
-is_read_comp_null (mhd_gtls_session_t session)
+is_read_comp_null (MHD_gtls_session_t session)
 {
   if (session->security_parameters.read_compression_algorithm ==
       MHD_GNUTLS_COMP_NULL)
@@ -68,13 +68,13 @@ is_read_comp_null (mhd_gtls_session_t session)
  * If random pad != 0 then the random pad data will be appended.
  */
 int
-mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
+MHD_gtls_encrypt (MHD_gtls_session_t session, const opaque * headers,
                   size_t headers_size, const opaque * data,
                   size_t data_size, opaque * ciphertext,
                   size_t ciphertext_size, content_type_t type, int random_pad)
 {
-  gnutls_datum_t plain;
-  gnutls_datum_t comp;
+  MHD_gnutls_datum_t plain;
+  MHD_gnutls_datum_t comp;
   int ret;
   int free_comp = 1;
 
@@ -91,31 +91,31 @@ mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
       /* Here comp is allocated and must be
        * freed.
        */
-      ret = _gnutls_m_plaintext2compressed (session, &comp, &plain);
+      ret = MHD__gnutls_m_plaintext2compressed (session, &comp, &plain);
       if (ret < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
     }
 
-  ret = mhd_gtls_compressed2ciphertext (session, &ciphertext[headers_size],
+  ret = MHD_gtls_compressed2ciphertext (session, &ciphertext[headers_size],
                                         ciphertext_size - headers_size,
                                         comp, type, random_pad);
 
   if (free_comp)
-    _gnutls_free_datum (&comp);
+    MHD__gnutls_free_datum (&comp);
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
 
   /* copy the headers */
   memcpy (ciphertext, headers, headers_size);
-  mhd_gtls_write_uint16 (ret, &ciphertext[3]);
+  MHD_gtls_write_uint16 (ret, &ciphertext[3]);
 
   return ret + headers_size;
 }
@@ -124,12 +124,12 @@ mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
  * Returns the decrypted data length.
  */
 int
-mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
+MHD_gtls_decrypt (MHD_gtls_session_t session, opaque * ciphertext,
                   size_t ciphertext_size, uint8_t * data,
                   size_t max_data_size, content_type_t type)
 {
-  gnutls_datum_t gtxt;
-  gnutls_datum_t gcipher;
+  MHD_gnutls_datum_t gtxt;
+  MHD_gnutls_datum_t gcipher;
   int ret;
 
   if (ciphertext_size == 0)
@@ -139,7 +139,7 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
   gcipher.data = ciphertext;
 
   ret =
-    mhd_gtls_ciphertext2compressed (session, data, max_data_size,
+    MHD_gtls_ciphertext2compressed (session, data, max_data_size,
                                     gcipher, type);
   if (ret < 0)
     {
@@ -153,14 +153,14 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
     }
   else
     {
-      gnutls_datum_t gcomp;
+      MHD_gnutls_datum_t gcomp;
 
       /* compression has this malloc overhead.
        */
 
       gcomp.data = data;
       gcomp.size = ret;
-      ret = _gnutls_m_compressed2plaintext (session, &gtxt, &gcomp);
+      ret = MHD__gnutls_m_compressed2plaintext (session, &gtxt, &gcomp);
       if (ret < 0)
         {
           return ret;
@@ -168,8 +168,8 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
 
       if (gtxt.size > MAX_RECORD_RECV_SIZE)
         {
-          gnutls_assert ();
-          _gnutls_free_datum (&gtxt);
+          MHD_gnutls_assert ();
+          MHD__gnutls_free_datum (&gtxt);
           /* This shouldn't have happen and
            * is a TLS fatal error.
            */
@@ -179,15 +179,15 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
       /* This check is not really needed */
       if (max_data_size < MAX_RECORD_RECV_SIZE)
         {
-          gnutls_assert ();
-          _gnutls_free_datum (&gtxt);
+          MHD_gnutls_assert ();
+          MHD__gnutls_free_datum (&gtxt);
           return GNUTLS_E_INTERNAL_ERROR;
         }
 
       memcpy (data, gtxt.data, gtxt.size);
       ret = gtxt.size;
 
-      _gnutls_free_datum (&gtxt);
+      MHD__gnutls_free_datum (&gtxt);
     }
 
   return ret;
@@ -204,11 +204,11 @@ mac_init (enum MHD_GNUTLS_HashAlgorithm mac, opaque * secret, int secret_size,
 
   if (ver == MHD_GNUTLS_PROTOCOL_SSL3)
     {                           /* SSL 3.0 */
-      td = mhd_gnutls_mac_init_ssl3 (mac, secret, secret_size);
+      td = MHD_gnutls_mac_init_ssl3 (mac, secret, secret_size);
     }
   else
     {                           /* TLS 1.x */
-      td = mhd_gtls_hmac_init (mac, secret, secret_size);
+      td = MHD_gtls_MHD_hmac_init (mac, secret, secret_size);
     }
 
   return td;
@@ -219,16 +219,16 @@ mac_deinit (mac_hd_t td, opaque * res, int ver)
 {
   if (ver == MHD_GNUTLS_PROTOCOL_SSL3)
     {                           /* SSL 3.0 */
-      mhd_gnutls_mac_deinit_ssl3 (td, res);
+      MHD_gnutls_mac_deinit_ssl3 (td, res);
     }
   else
     {
-      mhd_gnutls_hmac_deinit (td, res);
+      MHD_gnutls_MHD_hmac_deinit (td, res);
     }
 }
 
 inline static int
-calc_enc_length (mhd_gtls_session_t session, int data_size,
+calc_enc_length (MHD_gtls_session_t session, int data_size,
                  int hash_size, uint8_t * pad, int random_pad,
                  cipher_type_t block_algo, uint16_t blocksize)
 {
@@ -244,9 +244,9 @@ calc_enc_length (mhd_gtls_session_t session, int data_size,
 
       break;
     case CIPHER_BLOCK:
-      if (gc_nonce (&rnd, 1) != GC_OK)
+      if (MHD_gc_nonce (&rnd, 1) != GC_OK)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_RANDOM_FAILED;
         }
 
@@ -276,7 +276,7 @@ calc_enc_length (mhd_gtls_session_t session, int data_size,
 
       break;
     default:
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
@@ -289,9 +289,9 @@ calc_enc_length (mhd_gtls_session_t session, int data_size,
  * return the actual encrypted data length.
  */
 int
-mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
+MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session,
                                 opaque * cipher_data, int cipher_size,
-                                gnutls_datum_t compressed,
+                                MHD_gnutls_datum_t compressed,
                                 content_type_t _type, int random_pad)
 {
   uint8_t MAC[MAX_HASH_SIZE];
@@ -302,21 +302,21 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
   uint8_t type = _type;
   uint8_t major, minor;
   int hash_size =
-    mhd_gnutls_hash_get_algo_len (session->security_parameters.
+    MHD_gnutls_hash_get_algo_len (session->security_parameters.
                                   write_mac_algorithm);
   enum MHD_GNUTLS_Protocol ver;
   int blocksize =
-    mhd_gtls_cipher_get_block_size (session->security_parameters.
+    MHD_gtls_cipher_get_block_size (session->security_parameters.
                                     write_bulk_cipher_algorithm);
   cipher_type_t block_algo =
-    mhd_gtls_cipher_is_block (session->security_parameters.
+    MHD_gtls_cipher_is_block (session->security_parameters.
                               write_bulk_cipher_algorithm);
   opaque *data_ptr;
 
 
-  ver = MHD_gnutls_protocol_get_version (session);
-  minor = mhd_gtls_version_get_minor (ver);
-  major = mhd_gtls_version_get_major (ver);
+  ver = MHD__gnutls_protocol_get_version (session);
+  minor = MHD_gtls_version_get_minor (ver);
+  major = MHD_gtls_version_get_major (ver);
 
 
   /* Initialize MAC */
@@ -328,26 +328,26 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
       && session->security_parameters.write_mac_algorithm !=
       MHD_GNUTLS_MAC_NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
-  c_length = mhd_gtls_conv_uint16 (compressed.size);
+  c_length = MHD_gtls_conv_uint16 (compressed.size);
 
   if (td != GNUTLS_MAC_FAILED)
     {                           /* actually when the algorithm in not the NULL one */
-      mhd_gnutls_hash (td,
+      MHD_gnutls_hash (td,
                        UINT64DATA (session->connection_state.
                                    write_sequence_number), 8);
 
-      mhd_gnutls_hash (td, &type, 1);
+      MHD_gnutls_hash (td, &type, 1);
       if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0)
         {                       /* TLS 1.0 or higher */
-          mhd_gnutls_hash (td, &major, 1);
-          mhd_gnutls_hash (td, &minor, 1);
+          MHD_gnutls_hash (td, &major, 1);
+          MHD_gnutls_hash (td, &minor, 1);
         }
-      mhd_gnutls_hash (td, &c_length, 2);
-      mhd_gnutls_hash (td, compressed.data, compressed.size);
+      MHD_gnutls_hash (td, &c_length, 2);
+      MHD_gnutls_hash (td, compressed.data, compressed.size);
       mac_deinit (td, MAC, ver);
     }
 
@@ -359,7 +359,7 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
                      random_pad, block_algo, blocksize);
   if (length < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return length;
     }
 
@@ -367,7 +367,7 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
    */
   if (cipher_size < length)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
@@ -377,9 +377,9 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
     {
       /* copy the random IV.
        */
-      if (gc_nonce (data_ptr, blocksize) != GC_OK)
+      if (MHD_gc_nonce (data_ptr, blocksize) != GC_OK)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_RANDOM_FAILED;
         }
       data_ptr += blocksize;
@@ -402,11 +402,11 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
   /* Actual encryption (inplace).
    */
   ret =
-    mhd_gtls_cipher_encrypt (session->connection_state.write_cipher_state,
+    MHD_gtls_cipher_encrypt (session->connection_state.write_cipher_state,
                              cipher_data, length);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
@@ -417,10 +417,10 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
  * Returns the actual compressed packet size.
  */
 int
-mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
+MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session,
                                 opaque * compress_data,
                                 int compress_size,
-                                gnutls_datum_t ciphertext, uint8_t type)
+                                MHD_gnutls_datum_t ciphertext, uint8_t type)
 {
   uint8_t MAC[MAX_HASH_SIZE];
   uint16_t c_length;
@@ -432,15 +432,15 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
   uint8_t major, minor;
   enum MHD_GNUTLS_Protocol ver;
   int hash_size =
-    mhd_gnutls_hash_get_algo_len (session->security_parameters.
+    MHD_gnutls_hash_get_algo_len (session->security_parameters.
                                   read_mac_algorithm);
 
-  ver = MHD_gnutls_protocol_get_version (session);
-  minor = mhd_gtls_version_get_minor (ver);
-  major = mhd_gtls_version_get_major (ver);
+  ver = MHD__gnutls_protocol_get_version (session);
+  minor = MHD_gtls_version_get_minor (ver);
+  major = MHD_gtls_version_get_major (ver);
 
   blocksize =
-    mhd_gtls_cipher_get_block_size (session->security_parameters.
+    MHD_gtls_cipher_get_block_size (session->security_parameters.
                                     read_bulk_cipher_algorithm);
 
   /* initialize MAC
@@ -453,23 +453,23 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
       && session->security_parameters.read_mac_algorithm !=
       MHD_GNUTLS_MAC_NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
 
   /* actual decryption (inplace)
    */
-  switch (mhd_gtls_cipher_is_block
+  switch (MHD_gtls_cipher_is_block
           (session->security_parameters.read_bulk_cipher_algorithm))
     {
     case CIPHER_STREAM:
       if ((ret =
-           mhd_gtls_cipher_decrypt (session->connection_state.
+           MHD_gtls_cipher_decrypt (session->connection_state.
                                     read_cipher_state, ciphertext.data,
                                     ciphertext.size)) < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
 
@@ -479,16 +479,16 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
     case CIPHER_BLOCK:
       if ((ciphertext.size < blocksize) || (ciphertext.size % blocksize != 0))
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_DECRYPTION_FAILED;
         }
 
       if ((ret =
-           mhd_gtls_cipher_decrypt (session->connection_state.
+           MHD_gtls_cipher_decrypt (session->connection_state.
                                     read_cipher_state, ciphertext.data,
                                     ciphertext.size)) < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
 
@@ -501,7 +501,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
 
           if (ciphertext.size == 0)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_DECRYPTION_FAILED;
             }
         }
@@ -512,7 +512,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
 
       if (pad > ciphertext.size - hash_size)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           /* We do not fail here. We check below for the
            * the pad_failed. If zero means success.
            */
@@ -530,33 +530,33 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
           }
       break;
     default:
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
   if (length < 0)
     length = 0;
-  c_length = mhd_gtls_conv_uint16 ((uint16_t) length);
+  c_length = MHD_gtls_conv_uint16 ((uint16_t) length);
 
   /* Pass the type, version, length and compressed through
    * MAC.
    */
   if (td != GNUTLS_MAC_FAILED)
     {
-      mhd_gnutls_hash (td,
+      MHD_gnutls_hash (td,
                        UINT64DATA (session->connection_state.
                                    read_sequence_number), 8);
 
-      mhd_gnutls_hash (td, &type, 1);
+      MHD_gnutls_hash (td, &type, 1);
       if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0)
         {                       /* TLS 1.x */
-          mhd_gnutls_hash (td, &major, 1);
-          mhd_gnutls_hash (td, &minor, 1);
+          MHD_gnutls_hash (td, &major, 1);
+          MHD_gnutls_hash (td, &minor, 1);
         }
-      mhd_gnutls_hash (td, &c_length, 2);
+      MHD_gnutls_hash (td, &c_length, 2);
 
       if (length > 0)
-        mhd_gnutls_hash (td, ciphertext.data, length);
+        MHD_gnutls_hash (td, ciphertext.data, length);
 
       mac_deinit (td, MAC, ver);
     }
@@ -571,7 +571,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
    */
   if (memcmp (MAC, &ciphertext.data[length], hash_size) != 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_DECRYPTION_FAILED;
     }
 
@@ -579,7 +579,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
    */
   if (compress_size < length)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_DECOMPRESSION_FAILED;
     }
   memcpy (compress_data, ciphertext.data, length);

+ 6 - 6
src/daemon/https/tls/gnutls_cipher.h

@@ -22,19 +22,19 @@
  *
  */
 
-int mhd_gtls_encrypt (mhd_gtls_session_t session, const opaque * headers,
+int MHD_gtls_encrypt (MHD_gtls_session_t session, const opaque * headers,
                       size_t headers_size, const opaque * data,
                       size_t data_size, opaque * ciphertext,
                       size_t ciphertext_size, content_type_t type,
                       int random_pad);
 
-int mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext,
+int MHD_gtls_decrypt (MHD_gtls_session_t session, opaque * ciphertext,
                       size_t ciphertext_size, uint8_t * data,
                       size_t data_size, content_type_t type);
-int mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session,
+int MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session,
                                     opaque * cipher_data, int cipher_size,
-                                    gnutls_datum_t compressed,
+                                    MHD_gnutls_datum_t compressed,
                                     content_type_t _type, int random_pad);
-int mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session,
+int MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session,
                                     opaque * compress_data, int compress_size,
-                                    gnutls_datum_t ciphertext, uint8_t type);
+                                    MHD_gnutls_datum_t ciphertext, uint8_t type);

+ 24 - 24
src/daemon/https/tls/gnutls_cipher_int.c

@@ -28,8 +28,8 @@
 #include <gnutls_datum.h>
 
 cipher_hd_t
-mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
-                      const gnutls_datum_t * key, const gnutls_datum_t * iv)
+MHD_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
+                      const MHD_gnutls_datum_t * key, const MHD_gnutls_datum_t * iv)
 {
   cipher_hd_t ret = NULL;
   int err = GC_INVALID_CIPHER;  /* doesn't matter */
@@ -37,40 +37,40 @@ mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
   switch (cipher)
     {
     case MHD_GNUTLS_CIPHER_AES_128_CBC:
-      err = gc_cipher_open (GC_AES128, GC_CBC, &ret);
+      err = MHD_gc_cipher_open (GC_AES128, GC_CBC, &ret);
       break;
 
     case MHD_GNUTLS_CIPHER_AES_256_CBC:
-      err = gc_cipher_open (GC_AES256, GC_CBC, &ret);
+      err = MHD_gc_cipher_open (GC_AES256, GC_CBC, &ret);
       break;
 
     case MHD_GNUTLS_CIPHER_3DES_CBC:
-      err = gc_cipher_open (GC_3DES, GC_CBC, &ret);
+      err = MHD_gc_cipher_open (GC_3DES, GC_CBC, &ret);
       break;
 
     case MHD_GNUTLS_CIPHER_DES_CBC:
-      err = gc_cipher_open (GC_DES, GC_CBC, &ret);
+      err = MHD_gc_cipher_open (GC_DES, GC_CBC, &ret);
       break;
 
     case MHD_GNUTLS_CIPHER_ARCFOUR_128:
-      err = gc_cipher_open (GC_ARCFOUR128, GC_STREAM, &ret);
+      err = MHD_gc_cipher_open (GC_ARCFOUR128, GC_STREAM, &ret);
       break;
 
     case MHD_GNUTLS_CIPHER_ARCFOUR_40:
-      err = gc_cipher_open (GC_ARCFOUR40, GC_STREAM, &ret);
+      err = MHD_gc_cipher_open (GC_ARCFOUR40, GC_STREAM, &ret);
       break;
 
     case MHD_GNUTLS_CIPHER_RC2_40_CBC:
-      err = gc_cipher_open (GC_ARCTWO40, GC_CBC, &ret);
+      err = MHD_gc_cipher_open (GC_ARCTWO40, GC_CBC, &ret);
       break;
 
 #ifdef	ENABLE_CAMELLIA
     case MHD_GNUTLS_CIPHER_CAMELLIA_128_CBC:
-      err = gc_cipher_open (GC_CAMELLIA128, GC_CBC, &ret);
+      err = MHD_gc_cipher_open (GC_CAMELLIA128, GC_CBC, &ret);
       break;
 
     case MHD_GNUTLS_CIPHER_CAMELLIA_256_CBC:
-      err = gc_cipher_open (GC_CAMELLIA256, GC_CBC, &ret);
+      err = MHD_gc_cipher_open (GC_CAMELLIA256, GC_CBC, &ret);
       break;
 #endif
 
@@ -80,28 +80,28 @@ mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
 
   if (err == 0)
     {
-      gc_cipher_setkey (ret, key->size, key->data);
+      MHD_gc_cipher_setkey (ret, key->size, key->data);
       if (iv->data != NULL && iv->size > 0)
-        gc_cipher_setiv (ret, iv->size, iv->data);
+        MHD_gc_cipher_setiv (ret, iv->size, iv->data);
     }
   else if (cipher != MHD_GNUTLS_CIPHER_NULL)
     {
-      gnutls_assert ();
-      _gnutls_x509_log ("Crypto cipher[%d] error: %d\n", cipher, err);
-      /* FIXME: gc_strerror */
+      MHD_gnutls_assert ();
+      MHD__gnutls_x509_log ("Crypto cipher[%d] error: %d\n", cipher, err);
+      /* FIXME: MHD_gc_strerror */
     }
 
   return ret;
 }
 
 int
-mhd_gtls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
+MHD_gtls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
 {
   if (handle != GNUTLS_CIPHER_FAILED)
     {
-      if (gc_cipher_encrypt_inline (handle, textlen, text) != 0)
+      if (MHD_gc_cipher_encrypt_inline (handle, textlen, text) != 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_INTERNAL_ERROR;
         }
     }
@@ -109,14 +109,14 @@ mhd_gtls_cipher_encrypt (cipher_hd_t handle, void *text, int textlen)
 }
 
 int
-mhd_gtls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
+MHD_gtls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
                          int ciphertextlen)
 {
   if (handle != GNUTLS_CIPHER_FAILED)
     {
-      if (gc_cipher_decrypt_inline (handle, ciphertextlen, ciphertext) != 0)
+      if (MHD_gc_cipher_decrypt_inline (handle, ciphertextlen, ciphertext) != 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_INTERNAL_ERROR;
         }
     }
@@ -124,10 +124,10 @@ mhd_gtls_cipher_decrypt (cipher_hd_t handle, void *ciphertext,
 }
 
 void
-mhd_gnutls_cipher_deinit (cipher_hd_t handle)
+MHD_gnutls_cipher_deinit (cipher_hd_t handle)
 {
   if (handle != GNUTLS_CIPHER_FAILED)
     {
-      gc_cipher_close (handle);
+      MHD_gc_cipher_close (handle);
     }
 }

+ 8 - 8
src/daemon/https/tls/gnutls_cipher_int.h

@@ -25,19 +25,19 @@
 #ifndef GNUTLS_CIPHER_INT
 # define GNUTLS_CIPHER_INT
 
-#define cipher_hd_t gc_cipher_handle
+#define cipher_hd_t MHD_gc_cipher_handle
 #define GNUTLS_CIPHER_FAILED NULL
 
-// TODO gc_cipher_handle -> void * x3
-void *mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
-                            const gnutls_datum_t * key,
-                            const gnutls_datum_t * iv);
+// TODO MHD_gc_cipher_handle -> void * x3
+void *MHD_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher,
+                            const MHD_gnutls_datum_t * key,
+                            const MHD_gnutls_datum_t * iv);
 
-int mhd_gtls_cipher_encrypt (void *handle, void *text, int textlen);
+int MHD_gtls_cipher_encrypt (void *handle, void *text, int textlen);
 
-int mhd_gtls_cipher_decrypt (void *handle,
+int MHD_gtls_cipher_decrypt (void *handle,
                              void *ciphertext, int ciphertextlen);
 
-void mhd_gnutls_cipher_deinit (void *handle);
+void MHD_gnutls_cipher_deinit (void *handle);
 
 #endif /* GNUTLS_CIPHER_INT */

+ 10 - 10
src/daemon/https/tls/gnutls_compress.c

@@ -34,20 +34,20 @@
 /* These functions allocate the return value internally
  */
 int
-_gnutls_m_plaintext2compressed (mhd_gtls_session_t session,
-                                gnutls_datum_t * compressed,
-                                const gnutls_datum_t * plaintext)
+MHD__gnutls_m_plaintext2compressed (MHD_gtls_session_t session,
+                                MHD_gnutls_datum_t * compressed,
+                                const MHD_gnutls_datum_t * plaintext)
 {
   int size;
   opaque *data;
 
   size =
-    mhd_gtls_compress (session->connection_state.write_compression_state,
+    MHD_gtls_compress (session->connection_state.write_compression_state,
                        plaintext->data, plaintext->size, &data,
                        MAX_RECORD_SEND_SIZE + EXTRA_COMP_SIZE);
   if (size < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_COMPRESSION_FAILED;
     }
   compressed->data = data;
@@ -57,20 +57,20 @@ _gnutls_m_plaintext2compressed (mhd_gtls_session_t session,
 }
 
 int
-_gnutls_m_compressed2plaintext (mhd_gtls_session_t session,
-                                gnutls_datum_t * plain,
-                                const gnutls_datum_t * compressed)
+MHD__gnutls_m_compressed2plaintext (MHD_gtls_session_t session,
+                                MHD_gnutls_datum_t * plain,
+                                const MHD_gnutls_datum_t * compressed)
 {
   int size;
   opaque *data;
 
   size =
-    mhd_gtls_decompress (session->connection_state.read_compression_state,
+    MHD_gtls_decompress (session->connection_state.read_compression_state,
                          compressed->data, compressed->size, &data,
                          MAX_RECORD_RECV_SIZE);
   if (size < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_DECOMPRESSION_FAILED;
     }
   plain->data = data;

+ 6 - 6
src/daemon/https/tls/gnutls_compress.h

@@ -22,9 +22,9 @@
  *
  */
 
-int _gnutls_m_plaintext2compressed (mhd_gtls_session_t session,
-                                    gnutls_datum_t * compressed,
-                                    const gnutls_datum_t * plaintext);
-int _gnutls_m_compressed2plaintext (mhd_gtls_session_t session,
-                                    gnutls_datum_t * plain,
-                                    const gnutls_datum_t * compressed);
+int MHD__gnutls_m_plaintext2compressed (MHD_gtls_session_t session,
+                                    MHD_gnutls_datum_t * compressed,
+                                    const MHD_gnutls_datum_t * plaintext);
+int MHD__gnutls_m_compressed2plaintext (MHD_gtls_session_t session,
+                                    MHD_gnutls_datum_t * plain,
+                                    const MHD_gnutls_datum_t * compressed);

+ 33 - 33
src/daemon/https/tls/gnutls_compress_int.c

@@ -31,14 +31,14 @@
  * decompress.
  */
 comp_hd_t
-mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
+MHD_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
 {
   comp_hd_t ret;
 
-  ret = gnutls_malloc (sizeof (struct comp_hd_t_STRUCT));
+  ret = MHD_gnutls_malloc (sizeof (struct comp_hd_t_STRUCT));
   if (ret == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return NULL;
     }
 
@@ -54,14 +54,14 @@ mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
         int comp_level;
         z_stream *zhandle;
 
-        window_bits = mhd_gtls_compression_get_wbits (method);
-        mem_level = mhd_gtls_compression_get_mem_level (method);
-        comp_level = mhd_gtls_compression_get_comp_level (method);
+        window_bits = MHD_gtls_compression_get_wbits (method);
+        mem_level = MHD_gtls_compression_get_mem_level (method);
+        comp_level = MHD_gtls_compression_get_comp_level (method);
 
-        ret->handle = gnutls_malloc (sizeof (z_stream));
+        ret->handle = MHD_gnutls_malloc (sizeof (z_stream));
         if (ret->handle == NULL)
           {
-            gnutls_assert ();
+            MHD_gnutls_assert ();
             goto cleanup_ret;
           }
 
@@ -81,8 +81,8 @@ mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
           }
         if (err != Z_OK)
           {
-            gnutls_assert ();
-            gnutls_free (ret->handle);
+            MHD_gnutls_assert ();
+            MHD_gnutls_free (ret->handle);
             goto cleanup_ret;
           }
         break;
@@ -94,7 +94,7 @@ mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d)
   return ret;
 
 cleanup_ret:
-  gnutls_free (ret);
+  MHD_gnutls_free (ret);
   return NULL;
 }
 
@@ -102,7 +102,7 @@ cleanup_ret:
  * decompress.
  */
 void
-mhd_gtls_comp_deinit (comp_hd_t handle, int d)
+MHD_gtls_comp_deinit (comp_hd_t handle, int d)
 {
   if (handle != NULL)
     {
@@ -119,8 +119,8 @@ mhd_gtls_comp_deinit (comp_hd_t handle, int d)
         default:
           break;
         }
-      gnutls_free (handle->handle);
-      gnutls_free (handle);
+      MHD_gnutls_free (handle->handle);
+      MHD_gnutls_free (handle);
 
     }
 }
@@ -129,7 +129,7 @@ mhd_gtls_comp_deinit (comp_hd_t handle, int d)
  */
 
 int
-mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
+MHD_gtls_compress (comp_hd_t handle, const opaque * plain,
                    size_t plain_size, opaque ** compressed,
                    size_t max_comp_size)
 {
@@ -139,7 +139,7 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
    */
   if (handle == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
@@ -153,10 +153,10 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
         z_stream *zhandle;
 
         size = (plain_size + plain_size) + 10;
-        *compressed = gnutls_malloc (size);
+        *compressed = MHD_gnutls_malloc (size);
         if (*compressed == NULL)
           {
-            gnutls_assert ();
+            MHD_gnutls_assert ();
             return GNUTLS_E_MEMORY_ERROR;
           }
 
@@ -171,8 +171,8 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
 
         if (err != Z_OK || zhandle->avail_in != 0)
           {
-            gnutls_assert ();
-            gnutls_free (*compressed);
+            MHD_gnutls_assert ();
+            MHD_gnutls_free (*compressed);
             *compressed = NULL;
             return GNUTLS_E_COMPRESSION_FAILED;
           }
@@ -182,18 +182,18 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
       }
 #endif
     default:
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }                           /* switch */
 
 #ifdef COMPRESSION_DEBUG
-  _gnutls_debug_log ("Compression ratio: %f\n",
+  MHD__gnutls_debug_log ("Compression ratio: %f\n",
                      (float) ((float) compressed_size / (float) plain_size));
 #endif
 
   if ((size_t) compressed_size > max_comp_size)
     {
-      gnutls_free (*compressed);
+      MHD_gnutls_free (*compressed);
       *compressed = NULL;
       return GNUTLS_E_COMPRESSION_FAILED;
     }
@@ -204,7 +204,7 @@ mhd_gtls_compress (comp_hd_t handle, const opaque * plain,
 
 
 int
-mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
+MHD_gtls_decompress (comp_hd_t handle, opaque * compressed,
                      size_t compressed_size, opaque ** plain,
                      size_t max_record_size)
 {
@@ -212,7 +212,7 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
 
   if (compressed_size > max_record_size + EXTRA_COMP_SIZE)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_DECOMPRESSION_FAILED;
     }
 
@@ -221,7 +221,7 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
 
   if (handle == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
@@ -247,10 +247,10 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
         do
           {
             out_size += 512;
-            *plain = mhd_gtls_realloc_fast (*plain, out_size);
+            *plain = MHD_gtls_realloc_fast (*plain, out_size);
             if (*plain == NULL)
               {
-                gnutls_assert ();
+                MHD_gnutls_assert ();
                 return GNUTLS_E_MEMORY_ERROR;
               }
 
@@ -268,8 +268,8 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
 
         if (err != Z_OK)
           {
-            gnutls_assert ();
-            gnutls_free (*plain);
+            MHD_gnutls_assert ();
+            MHD_gnutls_free (*plain);
             *plain = NULL;
             return GNUTLS_E_DECOMPRESSION_FAILED;
           }
@@ -279,14 +279,14 @@ mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
       }
 #endif
     default:
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }                           /* switch */
 
   if ((size_t) plain_size > max_record_size)
     {
-      gnutls_assert ();
-      gnutls_free (*plain);
+      MHD_gnutls_assert ();
+      MHD_gnutls_free (*plain);
       *plain = NULL;
       return GNUTLS_E_DECOMPRESSION_FAILED;
     }

+ 4 - 4
src/daemon/https/tls/gnutls_compress_int.h

@@ -37,13 +37,13 @@ typedef struct comp_hd_t_STRUCT
   enum MHD_GNUTLS_CompressionMethod algo;
 } *comp_hd_t;
 
-comp_hd_t mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod, int d);
-void mhd_gtls_comp_deinit (comp_hd_t handle, int d);
+comp_hd_t MHD_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod, int d);
+void MHD_gtls_comp_deinit (comp_hd_t handle, int d);
 
-int mhd_gtls_decompress (comp_hd_t handle, opaque * compressed,
+int MHD_gtls_decompress (comp_hd_t handle, opaque * compressed,
                          size_t compressed_size, opaque ** plain,
                          size_t max_record_size);
-int mhd_gtls_compress (comp_hd_t, const opaque * plain, size_t plain_size,
+int MHD_gtls_compress (comp_hd_t, const opaque * plain, size_t plain_size,
                        opaque ** compressed, size_t max_comp_size);
 
 #endif

Plik diff jest za duży
+ 182 - 182
src/daemon/https/tls/gnutls_constate.c


+ 10 - 10
src/daemon/https/tls/gnutls_constate.h

@@ -22,20 +22,20 @@
  *
  */
 
-int mhd_gtls_connection_state_init (mhd_gtls_session_t session);
-int mhd_gtls_read_connection_state_init (mhd_gtls_session_t session);
-int mhd_gtls_write_connection_state_init (mhd_gtls_session_t session);
-int mhd_gtls_set_write_cipher (mhd_gtls_session_t session,
+int MHD_gtls_connection_state_init (MHD_gtls_session_t session);
+int MHD_gtls_read_connection_state_init (MHD_gtls_session_t session);
+int MHD_gtls_write_connection_state_init (MHD_gtls_session_t session);
+int MHD_gtls_set_write_cipher (MHD_gtls_session_t session,
                                enum MHD_GNUTLS_CipherAlgorithm algo);
-int mhd_gtls_set_write_mac (mhd_gtls_session_t session,
+int MHD_gtls_set_write_mac (MHD_gtls_session_t session,
                             enum MHD_GNUTLS_HashAlgorithm algo);
-int mhd_gtls_set_read_cipher (mhd_gtls_session_t session,
+int MHD_gtls_set_read_cipher (MHD_gtls_session_t session,
                               enum MHD_GNUTLS_CipherAlgorithm algo);
-int mhd_gtls_set_read_mac (mhd_gtls_session_t session,
+int MHD_gtls_set_read_mac (MHD_gtls_session_t session,
                            enum MHD_GNUTLS_HashAlgorithm algo);
-int mhd_gtls_set_read_compression (mhd_gtls_session_t session,
+int MHD_gtls_set_read_compression (MHD_gtls_session_t session,
                                    enum MHD_GNUTLS_CompressionMethod algo);
-int mhd_gtls_set_write_compression (mhd_gtls_session_t session,
+int MHD_gtls_set_write_compression (MHD_gtls_session_t session,
                                     enum MHD_GNUTLS_CompressionMethod algo);
-int mhd_gtls_set_kx (mhd_gtls_session_t session,
+int MHD_gtls_set_kx (MHD_gtls_session_t session,
                      enum MHD_GNUTLS_KeyExchangeAlgorithm algo);

+ 12 - 12
src/daemon/https/tls/gnutls_datum.c

@@ -34,31 +34,31 @@
 
 
 void
-mhd_gtls_write_datum16 (opaque * dest, gnutls_datum_t dat)
+MHD_gtls_write_datum16 (opaque * dest, MHD_gnutls_datum_t dat)
 {
-  mhd_gtls_write_uint16 (dat.size, dest);
+  MHD_gtls_write_uint16 (dat.size, dest);
   if (dat.data != NULL)
     memcpy (&dest[2], dat.data, dat.size);
 }
 
 void
-mhd_gtls_write_datum24 (opaque * dest, gnutls_datum_t dat)
+MHD_gtls_write_datum24 (opaque * dest, MHD_gnutls_datum_t dat)
 {
-  mhd_gtls_write_uint24 (dat.size, dest);
+  MHD_gtls_write_uint24 (dat.size, dest);
   if (dat.data != NULL)
     memcpy (&dest[3], dat.data, dat.size);
 }
 
 void
-mhd_gtls_write_datum32 (opaque * dest, gnutls_datum_t dat)
+MHD_gtls_write_datum32 (opaque * dest, MHD_gnutls_datum_t dat)
 {
-  mhd_gtls_write_uint32 (dat.size, dest);
+  MHD_gtls_write_uint32 (dat.size, dest);
   if (dat.data != NULL)
     memcpy (&dest[4], dat.data, dat.size);
 }
 
 void
-mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat)
+MHD_gtls_write_datum8 (opaque * dest, MHD_gnutls_datum_t dat)
 {
   dest[0] = (uint8_t) dat.size;
   if (dat.data != NULL)
@@ -67,8 +67,8 @@ mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat)
 
 
 int
-mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data,
-                      size_t data_size, gnutls_alloc_function galloc_func)
+MHD_gtls_set_datum_m (MHD_gnutls_datum_t * dat, const void *data,
+                      size_t data_size, MHD_gnutls_alloc_function galloc_func)
 {
   if (data_size == 0 || data == NULL)
     {
@@ -88,9 +88,9 @@ mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data,
 }
 
 int
-mhd_gtls_datum_append_m (gnutls_datum_t * dst, const void *data,
+MHD_gtls_datum_append_m (MHD_gnutls_datum_t * dst, const void *data,
                          size_t data_size,
-                         gnutls_realloc_function grealloc_func)
+                         MHD_gnutls_realloc_function grealloc_func)
 {
 
   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,
 }
 
 void
-mhd_gtls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function gfree_func)
+MHD_gtls_free_datum_m (MHD_gnutls_datum_t * dat, MHD_gnutls_free_function gfree_func)
 {
   if (dat->data != NULL)
     gfree_func (dat->data);

+ 13 - 13
src/daemon/https/tls/gnutls_datum.h

@@ -22,19 +22,19 @@
  *
  */
 
-void mhd_gtls_write_datum16 (opaque * dest, gnutls_datum_t dat);
-void mhd_gtls_write_datum24 (opaque * dest, gnutls_datum_t dat);
-void mhd_gtls_write_datum32 (opaque * dest, gnutls_datum_t dat);
-void mhd_gtls_write_datum8 (opaque * dest, gnutls_datum_t dat);
+void MHD_gtls_write_datum16 (opaque * dest, MHD_gnutls_datum_t dat);
+void MHD_gtls_write_datum24 (opaque * dest, MHD_gnutls_datum_t dat);
+void MHD_gtls_write_datum32 (opaque * dest, MHD_gnutls_datum_t dat);
+void MHD_gtls_write_datum8 (opaque * dest, MHD_gnutls_datum_t dat);
 
-int mhd_gtls_set_datum_m (gnutls_datum_t * dat, const void *data,
-                          size_t data_size, gnutls_alloc_function);
-#define _gnutls_set_datum( x, y, z) mhd_gtls_set_datum_m(x,y,z, gnutls_malloc)
-#define _gnutls_sset_datum( x, y, z) mhd_gtls_set_datum_m(x,y,z, gnutls_secure_malloc)
+int MHD_gtls_set_datum_m (MHD_gnutls_datum_t * dat, const void *data,
+                          size_t data_size, MHD_gnutls_alloc_function);
+#define MHD__gnutls_set_datum( x, y, z) MHD_gtls_set_datum_m(x,y,z, MHD_gnutls_malloc)
+#define MHD__gnutls_sset_datum( x, y, z) MHD_gtls_set_datum_m(x,y,z, MHD_gnutls_secure_malloc)
 
-int mhd_gtls_datum_append_m (gnutls_datum_t * dat, const void *data,
-                             size_t data_size, gnutls_realloc_function);
-#define _gnutls_datum_append(x,y,z) mhd_gtls_datum_append_m(x,y,z, gnutls_realloc)
+int MHD_gtls_datum_append_m (MHD_gnutls_datum_t * dat, const void *data,
+                             size_t data_size, MHD_gnutls_realloc_function);
+#define MHD__gnutls_datum_append(x,y,z) MHD_gtls_datum_append_m(x,y,z, MHD_gnutls_realloc)
 
-void mhd_gtls_free_datum_m (gnutls_datum_t * dat, gnutls_free_function);
-#define _gnutls_free_datum(x) mhd_gtls_free_datum_m(x, gnutls_free)
+void MHD_gtls_free_datum_m (MHD_gnutls_datum_t * dat, MHD_gnutls_free_function);
+#define MHD__gnutls_free_datum(x) MHD_gtls_free_datum_m(x, MHD_gnutls_free)

+ 27 - 27
src/daemon/https/tls/gnutls_dh.c

@@ -35,11 +35,11 @@
 	his_key  = X ^ y mod p;
 
 //      generate our secret and the public value (X) for it
-	X = mhd_gtls_calc_dh_secret(&x, g, p);
+	X = MHD_gtls_calc_dh_secret(&x, g, p);
 //      now we can calculate the shared secret
-	key = mhd_gtls_calc_dh_key(Y, x, g, p);
-	mhd_gtls_mpi_release(x);
-	mhd_gtls_mpi_release(g);
+	key = MHD_gtls_calc_dh_key(Y, x, g, p);
+	MHD_gtls_mpi_release(x);
+	MHD_gtls_mpi_release(g);
 */
 
 #define MAX_BITS 18000
@@ -47,24 +47,24 @@
 /* returns the public value (X), and the secret (ret_x).
  */
 mpi_t
-mhd_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
+MHD_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
 {
   mpi_t e, x;
-  int x_size = _gnutls_mpi_get_nbits (prime) - 1;
+  int x_size = MHD__gnutls_mpi_get_nbits (prime) - 1;
   /* The size of the secret key is less than
    * prime/2
    */
 
   if (x_size > MAX_BITS || x_size <= 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return NULL;
     }
 
-  x = _gnutls_mpi_new (x_size);
+  x = MHD__gnutls_mpi_new (x_size);
   if (x == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       if (ret_x)
         *ret_x = NULL;
 
@@ -76,55 +76,55 @@ mhd_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime)
    */
   do
     {
-      _gnutls_mpi_randomize (x, (x_size / 8) * 8, GCRY_STRONG_RANDOM);
+      MHD__gnutls_mpi_randomize (x, (x_size / 8) * 8, GCRY_STRONG_RANDOM);
       /* Check whether x is zero.
        */
     }
-  while (_gnutls_mpi_cmp_ui (x, 0) == 0);
+  while (MHD__gnutls_mpi_cmp_ui (x, 0) == 0);
 
-  e = _gnutls_mpi_alloc_like (prime);
+  e = MHD__gnutls_mpi_alloc_like (prime);
   if (e == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       if (ret_x)
         *ret_x = NULL;
 
-      mhd_gtls_mpi_release (&x);
+      MHD_gtls_mpi_release (&x);
       return NULL;
     }
 
-  _gnutls_mpi_powm (e, g, x, prime);
+  MHD__gnutls_mpi_powm (e, g, x, prime);
 
   if (ret_x)
     *ret_x = x;
   else
-    mhd_gtls_mpi_release (&x);
+    MHD_gtls_mpi_release (&x);
   return e;
 }
 
 
 mpi_t
-mhd_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
+MHD_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
 {
   mpi_t k;
   int bits;
 
-  bits = _gnutls_mpi_get_nbits (prime);
+  bits = MHD__gnutls_mpi_get_nbits (prime);
   if (bits <= 0 || bits > MAX_BITS)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return NULL;
     }
 
-  k = _gnutls_mpi_alloc_like (prime);
+  k = MHD__gnutls_mpi_alloc_like (prime);
   if (k == NULL)
     return NULL;
-  _gnutls_mpi_powm (k, f, x, prime);
+  MHD__gnutls_mpi_powm (k, f, x, prime);
   return k;
 }
 
 /*-
-  * mhd_gtls_get_dh_params - Returns the DH parameters pointer
+  * MHD_gtls_get_dh_params - Returns the DH parameters pointer
   * @dh_params: is an DH parameters structure, or NULL.
   * @func: is a callback function to receive the parameters or NULL.
   * @session: a gnutls session.
@@ -132,12 +132,12 @@ mhd_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime)
   * This function will return the dh parameters pointer.
   *
   -*/
-mhd_gtls_dh_params_t
-mhd_gtls_get_dh_params (mhd_gtls_dh_params_t dh_params,
-                        gnutls_params_function * func,
-                        mhd_gtls_session_t session)
+MHD_gtls_dh_params_t
+MHD_gtls_get_dh_params (MHD_gtls_dh_params_t dh_params,
+                        MHD_gnutls_params_function * func,
+                        MHD_gtls_session_t session)
 {
-  gnutls_params_st params;
+  MHD_gnutls_params_st params;
   int ret;
 
   /* if cached return the cached */

+ 8 - 8
src/daemon/https/tls/gnutls_dh.h

@@ -25,14 +25,14 @@
 #ifndef GNUTLS_DH_H
 # define GNUTLS_DH_H
 
-const mpi_t *mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t);
-mpi_t mhd_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime);
-mpi_t mhd_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime);
-int mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned bits);
+const mpi_t *MHD_gtls_dh_params_to_mpi (MHD_gtls_dh_params_t);
+mpi_t MHD_gtls_calc_dh_secret (mpi_t * ret_x, mpi_t g, mpi_t prime);
+mpi_t MHD_gtls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime);
+int MHD_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned bits);
 
-mhd_gtls_dh_params_t
-mhd_gtls_get_dh_params (mhd_gtls_dh_params_t dh_params,
-                        gnutls_params_function * func,
-                        mhd_gtls_session_t session);
+MHD_gtls_dh_params_t
+MHD_gtls_get_dh_params (MHD_gtls_dh_params_t dh_params,
+                        MHD_gnutls_params_function * func,
+                        MHD_gtls_session_t session);
 
 #endif

+ 24 - 24
src/daemon/https/tls/gnutls_dh_primes.c

@@ -36,7 +36,7 @@
 /* returns the prime and the generator of DH params.
  */
 const mpi_t *
-mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t dh_primes)
+MHD_gtls_dh_params_to_mpi (MHD_gtls_dh_params_t dh_primes)
 {
   if (dh_primes == NULL || dh_primes->params[1] == NULL
       || dh_primes->params[0] == NULL)
@@ -48,7 +48,7 @@ mhd_gtls_dh_params_to_mpi (mhd_gtls_dh_params_t dh_primes)
 }
 
 int
-mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
+MHD_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
 {
   mpi_t g = NULL, prime = NULL;
   gcry_error_t err;
@@ -75,7 +75,7 @@ mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
 
       if (times)
         {
-          mhd_gtls_mpi_release (&prime);
+          MHD_gtls_mpi_release (&prime);
           gcry_prime_release_factors (factors);
         }
 
@@ -85,7 +85,7 @@ mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
 
       if (err != 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           result = GNUTLS_E_INTERNAL_ERROR;
           goto cleanup;
         }
@@ -98,7 +98,7 @@ mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
 
   if (err != 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       result = GNUTLS_E_INTERNAL_ERROR;
       goto cleanup;
     }
@@ -108,7 +108,7 @@ mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
   err = gcry_prime_group_generator (&g, prime, factors, NULL);
   if (err != 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       result = GNUTLS_E_INTERNAL_ERROR;
       goto cleanup;
     }
@@ -119,17 +119,17 @@ mhd_gtls_dh_generate_prime (mpi_t * ret_g, mpi_t * ret_n, unsigned int bits)
   if (ret_g)
     *ret_g = g;
   else
-    mhd_gtls_mpi_release (&g);
+    MHD_gtls_mpi_release (&g);
   if (ret_n)
     *ret_n = prime;
   else
-    mhd_gtls_mpi_release (&prime);
+    MHD_gtls_mpi_release (&prime);
 
   return 0;
 
 cleanup:gcry_prime_release_factors (factors);
-  mhd_gtls_mpi_release (&g);
-  mhd_gtls_mpi_release (&prime);
+  MHD_gtls_mpi_release (&g);
+  MHD_gtls_mpi_release (&prime);
 
   return result;
 
@@ -139,20 +139,20 @@ cleanup:gcry_prime_release_factors (factors);
  * generated one.
  */
 /**
- * MHD_gnutls_dh_params_init - This function will initialize the DH parameters
+ * MHD__gnutls_dh_params_init - This function will initialize the DH parameters
  * @dh_params: Is a structure that will hold the prime numbers
  *
  * This function will initialize the DH parameters structure.
  *
  **/
 int
-MHD_gnutls_dh_params_init (mhd_gtls_dh_params_t * dh_params)
+MHD__gnutls_dh_params_init (MHD_gtls_dh_params_t * dh_params)
 {
 
-  (*dh_params) = gnutls_calloc (1, sizeof (mhd_gtls_dh_params_st));
+  (*dh_params) = MHD_gnutls_calloc (1, sizeof (MHD_gtls_dh_params_st));
   if (*dh_params == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
@@ -161,33 +161,33 @@ MHD_gnutls_dh_params_init (mhd_gtls_dh_params_t * dh_params)
 }
 
 /**
- * MHD_gnutls_dh_params_deinit - This function will deinitialize the DH parameters
+ * MHD__gnutls_dh_params_deinit - This function will deinitialize the DH parameters
  * @dh_params: Is a structure that holds the prime numbers
  *
  * This function will deinitialize the DH parameters structure.
  *
  **/
 void
-MHD_gnutls_dh_params_deinit (mhd_gtls_dh_params_t dh_params)
+MHD__gnutls_dh_params_deinit (MHD_gtls_dh_params_t dh_params)
 {
   if (dh_params == NULL)
     return;
 
-  mhd_gtls_mpi_release (&dh_params->params[0]);
-  mhd_gtls_mpi_release (&dh_params->params[1]);
+  MHD_gtls_mpi_release (&dh_params->params[0]);
+  MHD_gtls_mpi_release (&dh_params->params[1]);
 
-  gnutls_free (dh_params);
+  MHD_gnutls_free (dh_params);
 
 }
 
 /**
- * MHD_gnutls_dh_params_generate2 - This function will generate new DH parameters
+ * MHD__gnutls_dh_params_generate2 - This function will generate new DH parameters
  * @params: Is the structure that the DH parameters will be stored
  * @bits: is the prime's number of bits
  *
  * This function will generate a new pair of prime and generator for use in
  * the Diffie-Hellman key exchange. The new parameters will be allocated using
- * gnutls_malloc() and will be stored in the appropriate datum.
+ * MHD_gnutls_malloc() and will be stored in the appropriate datum.
  * This function is normally slow.
  *
  * 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)
  *
  **/
 int
-MHD_gnutls_dh_params_generate2 (mhd_gtls_dh_params_t params,
+MHD__gnutls_dh_params_generate2 (MHD_gtls_dh_params_t params,
                                 unsigned int bits)
 {
   int ret;
 
   ret =
-    mhd_gtls_dh_generate_prime (&params->params[1], &params->params[0], bits);
+    MHD_gtls_dh_generate_prime (&params->params[1], &params->params[0], bits);
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 

+ 12 - 12
src/daemon/https/tls/gnutls_errors.c

@@ -33,21 +33,21 @@
 #define _(String) (String)
 #define N_(String) (String)
 
-extern LOG_FUNC _gnutls_log_func;
+extern LOG_FUNC MHD__gnutls_log_func;
 
 #define ERROR_ENTRY(desc, name, fatal) \
 	{ desc, #name, name, fatal}
 
-struct gnutls_error_entry
+struct MHD_gnutls_error_entry
 {
   const char *desc;
   const char *_name;
   int number;
   int fatal;
 };
-typedef struct gnutls_error_entry gnutls_error_entry;
+typedef struct MHD_gnutls_error_entry MHD_gnutls_error_entry;
 
-static const gnutls_error_entry mhd_gtls_error_algorithms[] = {
+static const MHD_gnutls_error_entry MHD_gtls_error_algorithms[] = {
   /* "Short Description", Error code define, critical (0,1) -- 1 in most cases */
   ERROR_ENTRY (N_("Success."), GNUTLS_E_SUCCESS, 0),
   ERROR_ENTRY (N_("Could not negotiate a supported cipher suite."),
@@ -246,8 +246,8 @@ static const gnutls_error_entry mhd_gtls_error_algorithms[] = {
 };
 
 #define GNUTLS_ERROR_LOOP(b) \
-        const gnutls_error_entry *p; \
-                for(p = mhd_gtls_error_algorithms; p->desc != NULL; p++) { b ; }
+        const MHD_gnutls_error_entry *p; \
+                for(p = MHD_gtls_error_algorithms; p->desc != NULL; p++) { b ; }
 
 #define GNUTLS_ERROR_ALG_LOOP(a) \
                         GNUTLS_ERROR_LOOP( if(p->number == error) { a; break; } )
@@ -329,7 +329,7 @@ MHD_gtls_strerror (int error)
  * given error code.
  */
 const char *
-_gnutls_strerror (int error)
+MHD__gnutls_strerror (int error)
 {
   const char *ret = NULL;
 
@@ -340,7 +340,7 @@ _gnutls_strerror (int error)
 }
 
 int
-mhd_gtls_asn2err (int asn_err)
+MHD_gtls_asn2err (int asn_err)
 {
   switch (asn_err)
     {
@@ -382,13 +382,13 @@ mhd_gtls_asn2err (int asn_err)
  * caller provided function
  */
 void
-mhd_gtls_log (int level, const char *fmt, ...)
+MHD_gtls_log (int level, const char *fmt, ...)
 {
   va_list args;
   char str[MAX_LOG_SIZE];
-  void (*log_func) (int, const char *) = _gnutls_log_func;
+  void (*log_func) (int, const char *) = MHD__gnutls_log_func;
 
-  if (_gnutls_log_func == NULL)
+  if (MHD__gnutls_log_func == NULL)
     return;
 
   va_start (args, fmt);
@@ -405,7 +405,7 @@ mhd_gtls_log (int level, const char *fmt, ...)
  * be called. This may affect performance.
  */
 void
-_gnutls_null_log (void *x, ...)
+MHD__gnutls_null_log (void *x, ...)
 {
   return;
 }

+ 29 - 29
src/daemon/https/tls/gnutls_errors.h

@@ -28,46 +28,46 @@
 
 #ifdef __FILE__
 # ifdef __LINE__
-#  define gnutls_assert() _gnutls_debug_log( "ASSERT: %s:%d\n", __FILE__,__LINE__);
+#  define MHD_gnutls_assert() MHD__gnutls_debug_log( "ASSERT: %s:%d\n", __FILE__,__LINE__);
 # else
-#  define gnutls_assert()
+#  define MHD_gnutls_assert()
 # endif
 #else /* __FILE__ not defined */
-# define gnutls_assert()
+# define MHD_gnutls_assert()
 #endif
 
-int mhd_gtls_asn2err (int asn_err);
-void mhd_gtls_log (int, const char *fmt, ...);
+int MHD_gtls_asn2err (int asn_err);
+void MHD_gtls_log (int, const char *fmt, ...);
 
-extern int _gnutls_log_level;
+extern int MHD__gnutls_log_level;
 
 #ifdef C99_MACROS
-#define LEVEL(l, ...) if (_gnutls_log_level >= l || _gnutls_log_level > 9) \
-	mhd_gtls_log( l, __VA_ARGS__)
+#define LEVEL(l, ...) if (MHD__gnutls_log_level >= l || MHD__gnutls_log_level > 9) \
+	MHD_gtls_log( l, __VA_ARGS__)
 
-#define LEVEL_EQ(l, ...) if (_gnutls_log_level == l || _gnutls_log_level > 9) \
-	mhd_gtls_log( l, __VA_ARGS__)
+#define LEVEL_EQ(l, ...) if (MHD__gnutls_log_level == l || MHD__gnutls_log_level > 9) \
+	MHD_gtls_log( l, __VA_ARGS__)
 
-# define _gnutls_debug_log(...) LEVEL(2, __VA_ARGS__)
-# define _gnutls_handshake_log(...) LEVEL(3, __VA_ARGS__)
-# define _gnutls_io_log(...) LEVEL_EQ(5, __VA_ARGS__)
-# define _gnutls_buffers_log(...) LEVEL_EQ(6, __VA_ARGS__)
-# define _gnutls_hard_log(...) LEVEL(9, __VA_ARGS__)
-# define _gnutls_record_log(...) LEVEL(4, __VA_ARGS__)
-# define _gnutls_read_log(...) LEVEL_EQ(7, __VA_ARGS__)
-# define _gnutls_write_log(...) LEVEL_EQ(7, __VA_ARGS__)
-# define _gnutls_x509_log(...) LEVEL(1, __VA_ARGS__)
+# define MHD__gnutls_debug_log(...) LEVEL(2, __VA_ARGS__)
+# define MHD__gnutls_handshake_log(...) LEVEL(3, __VA_ARGS__)
+# define MHD__gnutls_io_log(...) LEVEL_EQ(5, __VA_ARGS__)
+# define MHD__gnutls_buffers_log(...) LEVEL_EQ(6, __VA_ARGS__)
+# define MHD__gnutls_hard_log(...) LEVEL(9, __VA_ARGS__)
+# define MHD__gnutls_record_log(...) LEVEL(4, __VA_ARGS__)
+# define MHD__gnutls_read_log(...) LEVEL_EQ(7, __VA_ARGS__)
+# define MHD__gnutls_write_log(...) LEVEL_EQ(7, __VA_ARGS__)
+# define MHD__gnutls_x509_log(...) LEVEL(1, __VA_ARGS__)
 #else
-# define _gnutls_debug_log _gnutls_null_log
-# define _gnutls_handshake_log _gnutls_null_log
-# define _gnutls_io_log _gnutls_null_log
-# define _gnutls_buffers_log _gnutls_null_log
-# define _gnutls_hard_log _gnutls_null_log
-# define _gnutls_record_log _gnutls_null_log
-# define _gnutls_read_log _gnutls_null_log
-# define _gnutls_write_log _gnutls_null_log
-# define _gnutls_x509_log _gnutls_null_log
+# define MHD__gnutls_debug_log MHD__gnutls_null_log
+# define MHD__gnutls_handshake_log MHD__gnutls_null_log
+# define MHD__gnutls_io_log MHD__gnutls_null_log
+# define MHD__gnutls_buffers_log MHD__gnutls_null_log
+# define MHD__gnutls_hard_log MHD__gnutls_null_log
+# define MHD__gnutls_record_log MHD__gnutls_null_log
+# define MHD__gnutls_read_log MHD__gnutls_null_log
+# define MHD__gnutls_write_log MHD__gnutls_null_log
+# define MHD__gnutls_x509_log MHD__gnutls_null_log
 
-void _gnutls_null_log (void *, ...);
+void MHD__gnutls_null_log (void *, ...);
 
 #endif /* C99_MACROS */

+ 59 - 59
src/daemon/https/tls/gnutls_extensions.c

@@ -43,39 +43,39 @@
 
 
 #define MAX_EXT_SIZE 10
-const int mhd_gtls_extensions_size = MAX_EXT_SIZE;
+const int MHD_gtls_extensions_size = MAX_EXT_SIZE;
 
-mhd_gtls_extension_entry mhd_gtls_extensions[MAX_EXT_SIZE] = {
+MHD_gtls_extension_entry MHD_gtls_extensions[MAX_EXT_SIZE] = {
   GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_MAX_RECORD_SIZE,
                           EXTENSION_TLS,
-                          mhd_gtls_max_record_recv_params,
-                          mhd_gtls_max_record_send_params),
+                          MHD_gtls_max_record_recv_params,
+                          MHD_gtls_max_record_send_params),
   GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_CERT_TYPE,
                           EXTENSION_TLS,
-                          mhd_gtls_cert_type_recv_params,
-                          mhd_gtls_cert_type_send_params),
+                          MHD_gtls_cert_type_recv_params,
+                          MHD_gtls_cert_type_send_params),
   GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SERVER_NAME,
                           EXTENSION_APPLICATION,
-                          mhd_gtls_server_name_recv_params,
-                          mhd_gtls_server_name_send_params),
+                          MHD_gtls_server_name_recv_params,
+                          MHD_gtls_server_name_send_params),
 #ifdef ENABLE_OPRFI
   GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_OPAQUE_PRF_INPUT,
                           EXTENSION_TLS,
-                          mhd_gtls_oprfi_recv_params,
-                          mhd_gtls_oprfi_send_params),
+                          MHD_gtls_oprfi_recv_params,
+                          MHD_gtls_oprfi_send_params),
 #endif
 #ifdef ENABLE_SRP
   GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SRP,
                           EXTENSION_TLS,
-                          _gnutls_srp_recv_params,
-                          _gnutls_srp_send_params),
+                          MHD__gnutls_srp_recv_params,
+                          MHD__gnutls_srp_send_params),
 #endif
   {0, 0, 0, 0}
 };
 
 #define GNUTLS_EXTENSION_LOOP2(b) \
-        mhd_gtls_extension_entry *p; \
-                for(p = mhd_gtls_extensions; p->name != NULL; p++) { b ; }
+        MHD_gtls_extension_entry *p; \
+                for(p = MHD_gtls_extensions; p->name != NULL; p++) { b ; }
 
 #define GNUTLS_EXTENSION_LOOP(a) \
                         GNUTLS_EXTENSION_LOOP2( if(p->type == type) { a; break; } )
@@ -83,29 +83,29 @@ mhd_gtls_extension_entry mhd_gtls_extensions[MAX_EXT_SIZE] = {
 
 /* EXTENSION functions */
 
-mhd_gtls_ext_recv_func
-mhd_gtls_ext_func_recv (uint16_t type, mhd_gtls_ext_parse_type_t parse_type)
+MHD_gtls_ext_recv_func
+MHD_gtls_ext_func_recv (uint16_t type, MHD_gtls_ext_parse_type_t parse_type)
 {
-  mhd_gtls_ext_recv_func ret = NULL;
+  MHD_gtls_ext_recv_func ret = NULL;
   GNUTLS_EXTENSION_LOOP (if
                          (parse_type == EXTENSION_ANY
                           || p->parse_type == parse_type) ret =
-                         p->gnutls_ext_func_recv);
+                         p->MHD_gnutls_ext_func_recv);
   return ret;
 
 }
 
-mhd_gtls_ext_send_func
-mhd_gtls_ext_func_send (uint16_t type)
+MHD_gtls_ext_send_func
+MHD_gtls_ext_func_send (uint16_t type)
 {
-  mhd_gtls_ext_send_func ret = NULL;
-  GNUTLS_EXTENSION_LOOP (ret = p->gnutls_ext_func_send);
+  MHD_gtls_ext_send_func ret = NULL;
+  GNUTLS_EXTENSION_LOOP (ret = p->MHD_gnutls_ext_func_send);
   return ret;
 
 }
 
 const char *
-mhd_gtls_extension_get_name (uint16_t type)
+MHD_gtls_extension_get_name (uint16_t type)
 {
   const char *ret = NULL;
 
@@ -119,7 +119,7 @@ mhd_gtls_extension_get_name (uint16_t type)
  * requested ones. Otherwise it's a fatal error.
  */
 static int
-_gnutls_extension_list_check (mhd_gtls_session_t session, uint16_t type)
+MHD__gnutls_extension_list_check (MHD_gtls_session_t session, uint16_t type)
 {
 #if MHD_DEBUG_TLS
   if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -137,15 +137,15 @@ _gnutls_extension_list_check (mhd_gtls_session_t session, uint16_t type)
 }
 
 int
-mhd_gtls_parse_extensions (mhd_gtls_session_t session,
-                           mhd_gtls_ext_parse_type_t parse_type,
+MHD_gtls_parse_extensions (MHD_gtls_session_t session,
+                           MHD_gtls_ext_parse_type_t parse_type,
                            const opaque * data, int data_size)
 {
   int next, ret;
   int pos = 0;
   uint16_t type;
   const opaque *sdata;
-  mhd_gtls_ext_recv_func ext_recv;
+  MHD_gtls_ext_recv_func ext_recv;
   uint16_t size;
 
 #if MHD_DEBUG_TLS
@@ -153,15 +153,15 @@ mhd_gtls_parse_extensions (mhd_gtls_session_t session,
   if (session->security_parameters.entity == GNUTLS_CLIENT)
     for (i = 0; i < session->internals.extensions_sent_size; i++)
       {
-        _gnutls_debug_log ("EXT[%d]: expecting extension '%s'\n",
+        MHD__gnutls_debug_log ("EXT[%d]: expecting extension '%s'\n",
                            session,
-                           mhd_gtls_extension_get_name
+                           MHD_gtls_extension_get_name
                            (session->internals.extensions_sent[i]));
       }
 #endif
 
   DECR_LENGTH_RET (data_size, 2, 0);
-  next = mhd_gtls_read_uint16 (data);
+  next = MHD_gtls_read_uint16 (data);
   pos += 2;
 
   DECR_LENGTH_RET (data_size, next, 0);
@@ -169,32 +169,32 @@ mhd_gtls_parse_extensions (mhd_gtls_session_t session,
   do
     {
       DECR_LENGTH_RET (next, 2, 0);
-      type = mhd_gtls_read_uint16 (&data[pos]);
+      type = MHD_gtls_read_uint16 (&data[pos]);
       pos += 2;
 
-      _gnutls_debug_log ("EXT[%x]: Received extension '%s/%d'\n", session,
-                         mhd_gtls_extension_get_name (type), type);
+      MHD__gnutls_debug_log ("EXT[%x]: Received extension '%s/%d'\n", session,
+                         MHD_gtls_extension_get_name (type), type);
 
-      if ((ret = _gnutls_extension_list_check (session, type)) < 0)
+      if ((ret = MHD__gnutls_extension_list_check (session, type)) < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
 
       DECR_LENGTH_RET (next, 2, 0);
-      size = mhd_gtls_read_uint16 (&data[pos]);
+      size = MHD_gtls_read_uint16 (&data[pos]);
       pos += 2;
 
       DECR_LENGTH_RET (next, size, 0);
       sdata = &data[pos];
       pos += size;
 
-      ext_recv = mhd_gtls_ext_func_recv (type, parse_type);
+      ext_recv = MHD_gtls_ext_func_recv (type, parse_type);
       if (ext_recv == NULL)
         continue;
       if ((ret = ext_recv (session, sdata, size)) < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
 
@@ -210,7 +210,7 @@ mhd_gtls_parse_extensions (mhd_gtls_session_t session,
  * extensions are the ones we requested.
  */
 static void
-_gnutls_extension_list_add (mhd_gtls_session_t session, uint16_t type)
+MHD__gnutls_extension_list_add (MHD_gtls_session_t session, uint16_t type)
 {
 #if MHD_DEBUG_TLS
   if (session->security_parameters.entity == GNUTLS_CLIENT)
@@ -223,43 +223,43 @@ _gnutls_extension_list_add (mhd_gtls_session_t session, uint16_t type)
         }
       else
         {
-          _gnutls_debug_log ("extensions: Increase MAX_EXT_TYPES\n");
+          MHD__gnutls_debug_log ("extensions: Increase MAX_EXT_TYPES\n");
         }
     }
 #endif
 }
 
 int
-mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
+MHD_gtls_gen_extensions (MHD_gtls_session_t session, opaque * data,
                          size_t data_size)
 {
   int size;
   uint16_t pos = 0;
   opaque *sdata;
   int sdata_size;
-  mhd_gtls_ext_send_func ext_send;
-  mhd_gtls_extension_entry *p;
+  MHD_gtls_ext_send_func ext_send;
+  MHD_gtls_extension_entry *p;
 
   if (data_size < 2)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
   /* allocate enough data for each extension.
    */
   sdata_size = data_size;
-  sdata = gnutls_malloc (sdata_size);
+  sdata = MHD_gnutls_malloc (sdata_size);
   if (sdata == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
   pos += 2;
-  for (p = mhd_gtls_extensions; p->name != NULL; p++)
+  for (p = MHD_gtls_extensions; p->name != NULL; p++)
     {
-      ext_send = mhd_gtls_ext_func_send (p->type);
+      ext_send = MHD_gtls_ext_func_send (p->type);
       if (ext_send == NULL)
         continue;
       size = ext_send (session, sdata, sdata_size);
@@ -267,17 +267,17 @@ mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
         {
           if (data_size < pos + (size_t) size + 4)
             {
-              gnutls_assert ();
-              gnutls_free (sdata);
+              MHD_gnutls_assert ();
+              MHD_gnutls_free (sdata);
               return GNUTLS_E_INTERNAL_ERROR;
             }
 
           /* write extension type */
-          mhd_gtls_write_uint16 (p->type, &data[pos]);
+          MHD_gtls_write_uint16 (p->type, &data[pos]);
           pos += 2;
 
           /* write size */
-          mhd_gtls_write_uint16 (size, &data[pos]);
+          MHD_gtls_write_uint16 (size, &data[pos]);
           pos += 2;
 
           memcpy (&data[pos], sdata, size);
@@ -285,15 +285,15 @@ mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
 
           /* add this extension to the extension list
            */
-          _gnutls_extension_list_add (session, p->type);
+          MHD__gnutls_extension_list_add (session, p->type);
 
-          _gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session,
-                             mhd_gtls_extension_get_name (p->type));
+          MHD__gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session,
+                             MHD_gtls_extension_get_name (p->type));
         }
       else if (size < 0)
         {
-          gnutls_assert ();
-          gnutls_free (sdata);
+          MHD_gnutls_assert ();
+          MHD_gnutls_free (sdata);
           return size;
         }
     }
@@ -301,14 +301,14 @@ mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
   size = pos;
   pos -= 2;                     /* remove the size of the size header! */
 
-  mhd_gtls_write_uint16 (pos, data);
+  MHD_gtls_write_uint16 (pos, data);
 
   if (size == 2)
     {                           /* empty */
       size = 0;
     }
 
-  gnutls_free (sdata);
+  MHD_gnutls_free (sdata);
   return size;
 
 }

+ 12 - 12
src/daemon/https/tls/gnutls_extensions.h

@@ -24,24 +24,24 @@
 
 #include <gnutls_int.h>
 
-const char *mhd_gtls_extension_get_name (uint16_t type);
-int mhd_gtls_parse_extensions (mhd_gtls_session_t, mhd_gtls_ext_parse_type_t,
+const char *MHD_gtls_extension_get_name (uint16_t type);
+int MHD_gtls_parse_extensions (MHD_gtls_session_t, MHD_gtls_ext_parse_type_t,
                                const opaque *, int);
-int mhd_gtls_gen_extensions (mhd_gtls_session_t session, opaque * data,
+int MHD_gtls_gen_extensions (MHD_gtls_session_t session, opaque * data,
                              size_t data_size);
 
-typedef int (*mhd_gtls_ext_recv_func) (mhd_gtls_session_t, const opaque *, size_t);     /* recv data */
-typedef int (*mhd_gtls_ext_send_func) (mhd_gtls_session_t, opaque *, size_t);   /* send data */
+typedef int (*MHD_gtls_ext_recv_func) (MHD_gtls_session_t, const opaque *, size_t);     /* recv data */
+typedef int (*MHD_gtls_ext_send_func) (MHD_gtls_session_t, opaque *, size_t);   /* send data */
 
-mhd_gtls_ext_send_func mhd_gtls_ext_func_send (uint16_t type);
-mhd_gtls_ext_recv_func mhd_gtls_ext_func_recv (uint16_t type,
-                                               mhd_gtls_ext_parse_type_t);
+MHD_gtls_ext_send_func MHD_gtls_ext_func_send (uint16_t type);
+MHD_gtls_ext_recv_func MHD_gtls_ext_func_recv (uint16_t type,
+                                               MHD_gtls_ext_parse_type_t);
 
 typedef struct
 {
   const char *name;
   uint16_t type;
-  mhd_gtls_ext_parse_type_t parse_type;
-  mhd_gtls_ext_recv_func gnutls_ext_func_recv;
-  mhd_gtls_ext_send_func gnutls_ext_func_send;
-} mhd_gtls_extension_entry;
+  MHD_gtls_ext_parse_type_t parse_type;
+  MHD_gtls_ext_recv_func MHD_gnutls_ext_func_recv;
+  MHD_gtls_ext_send_func MHD_gnutls_ext_func_send;
+} MHD_gtls_extension_entry;

+ 74 - 74
src/daemon/https/tls/gnutls_global.c

@@ -44,17 +44,17 @@
 
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
 
-#define gnutls_log_func LOG_FUNC
+#define MHD_gnutls_log_func LOG_FUNC
 
 /* created by asn1c */
-extern const ASN1_ARRAY_TYPE gnutls_asn1_tab[];
-extern const ASN1_ARRAY_TYPE pkix_asn1_tab[];
+extern const ASN1_ARRAY_TYPE MHD_gnutlsMHD__asn1_tab[];
+extern const ASN1_ARRAY_TYPE MHD_pkix_asn1_tab[];
 
-LOG_FUNC _gnutls_log_func;
-int _gnutls_log_level = 0;      /* default log level */
+LOG_FUNC MHD__gnutls_log_func;
+int MHD__gnutls_log_level = 0;      /* default log level */
 
-ASN1_TYPE _gnutls_pkix1_asn;
-ASN1_TYPE _gnutls_gnutls_asn;
+ASN1_TYPE MHD__gnutls_pkix1_asn;
+ASN1_TYPE MHD__gnutlsMHD__gnutls_asn;
 
 /**
  * MHD_gtls_global_set_log_function - This function sets the logging function
@@ -65,13 +65,13 @@ ASN1_TYPE _gnutls_gnutls_asn;
  * Normally you may not use this function since it is only used
  * for debugging purposes.
  *
- * gnutls_log_func is of the form,
- * void (*gnutls_log_func)( int level, const char*);
+ * MHD_gnutls_log_func is of the form,
+ * void (*MHD_gnutls_log_func)( int level, const char*);
  **/
 void
-MHD_gtls_global_set_log_function (gnutls_log_func log_func)
+MHD_gtls_global_set_log_function (MHD_gnutls_log_func log_func)
 {
-  _gnutls_log_func = log_func;
+  MHD__gnutls_log_func = log_func;
 }
 
 /**
@@ -89,10 +89,10 @@ MHD_gtls_global_set_log_function (gnutls_log_func log_func)
 void
 MHD_gtls_global_set_log_level (int level)
 {
-  _gnutls_log_level = level;
+  MHD__gnutls_log_level = level;
 }
 
-int _gnutls_is_secure_mem_null (const void *);
+int MHD__gnutls_is_secure_mem_null (const void *);
 
 /**
  * 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 *);
  * This function is provided to set the memory allocation functions to
  * something other than the defaults (ie the gcrypt allocation functions).
  *
- * This function must be called before MHD_gnutls_global_init() is called.
+ * This function must be called before MHD__gnutls_global_init() is called.
  *
  **/
 void
-MHD_gtls_global_set_mem_functions (gnutls_alloc_function alloc_func,
-                                   gnutls_alloc_function
+MHD_gtls_global_set_mem_functions (MHD_gnutls_alloc_function alloc_func,
+                                   MHD_gnutls_alloc_function
                                    secure_alloc_func,
-                                   gnutls_is_secure_function
+                                   MHD_gnutls_is_secure_function
                                    is_secure_func,
-                                   gnutls_realloc_function realloc_func,
-                                   gnutls_free_function free_func)
+                                   MHD_gnutls_realloc_function realloc_func,
+                                   MHD_gnutls_free_function free_func)
 {
-  gnutls_secure_malloc = secure_alloc_func;
-  gnutls_malloc = alloc_func;
-  gnutls_realloc = realloc_func;
-  gnutls_free = free_func;
+  MHD_gnutls_secure_malloc = secure_alloc_func;
+  MHD_gnutls_malloc = alloc_func;
+  MHD_gnutls_realloc = realloc_func;
+  MHD_gnutls_free = free_func;
 
   if (is_secure_func != NULL)
-    _gnutls_is_secure_memory = is_secure_func;
+    MHD__gnutls_is_secure_memory = is_secure_func;
   else
-    _gnutls_is_secure_memory = _gnutls_is_secure_mem_null;
+    MHD__gnutls_is_secure_memory = MHD__gnutls_is_secure_mem_null;
 
   /* if using the libc's default malloc
    * use libc's calloc as well.
    */
-  if (gnutls_malloc == malloc)
+  if (MHD_gnutls_malloc == malloc)
     {
-      gnutls_calloc = calloc;
+      MHD_gnutls_calloc = calloc;
     }
   else
     {                           /* use the included ones */
-      gnutls_calloc = mhd_gtls_calloc;
+      MHD_gnutls_calloc = MHD_gtls_calloc;
     }
-  gnutls_strdup = mhd_gtls_strdup;
+  MHD_gnutls_strdup = MHD_gtls_strdup;
 
 }
 
 #ifdef DEBUG
 static void
-_gnutls_gcry_log_handler (void *dummy, int level,
+MHD__gnutls_gcry_log_handler (void *dummy, int level,
                           const char *fmt, va_list list)
 {
-  mhd_gtls_log (level, fmt, list);
+  MHD_gtls_log (level, fmt, list);
 }
 #endif
 
-static int _gnutls_init = 0;
+static int MHD__gnutls_init_level = 0;
 
 /**
- * MHD_gnutls_global_init - This function initializes the global data to defaults.
+ * MHD__gnutls_global_init - This function initializes the global data to defaults.
  *
  * This function initializes the global data to defaults.
  * Every gnutls application has a global data which holds common parameters
  * shared by gnutls session structures.
- * You must call MHD_gnutls_global_deinit() when gnutls usage is no longer needed
+ * You must call MHD__gnutls_global_deinit() when gnutls usage is no longer needed
  * Returns zero on success.
  *
  * Note that this function will also initialize libgcrypt, if it has not
@@ -171,8 +171,8 @@ static int _gnutls_init = 0;
  * want to disable libgcrypt's internal lockings etc.
  *
  * This function increment a global counter, so that
- * MHD_gnutls_global_deinit() only releases resources when it has been
- * called as many times as MHD_gnutls_global_init().  This is useful when
+ * MHD__gnutls_global_deinit() only releases resources when it has been
+ * called as many times as MHD__gnutls_global_init().  This is useful when
  * GnuTLS is used by more than one library in an application.  This
  * function can be called many times, but will only do something the
  * first time.
@@ -187,13 +187,13 @@ static int _gnutls_init = 0;
  *
  **/
 int
-MHD_gnutls_global_init (void)
+MHD__gnutls_global_init (void)
 {
   int result = 0;
   int res;
   char c;
 
-  if (_gnutls_init++)
+  if (MHD__gnutls_init_level++)
     return 0;
 
 #if HAVE_WINSOCK
@@ -206,13 +206,13 @@ MHD_gnutls_global_init (void)
     err = WSAStartup (requested, &data);
     if (err != 0)
       {
-        _gnutls_debug_log ("WSAStartup failed: %d.\n", err);
+        MHD__gnutls_debug_log ("WSAStartup failed: %d.\n", err);
         return GNUTLS_E_LIBRARY_VERSION_MISMATCH;
       }
 
     if (data.wVersion < requested)
       {
-        _gnutls_debug_log ("WSAStartup version check failed (%d < %d).\n",
+        MHD__gnutls_debug_log ("WSAStartup version check failed (%d < %d).\n",
                            data.wVersion, requested);
         WSACleanup ();
         return GNUTLS_E_LIBRARY_VERSION_MISMATCH;
@@ -239,15 +239,15 @@ MHD_gnutls_global_init (void)
       /* this call initializes libgcrypt */
       if (gcry_check_version (p) == NULL)
         {
-          gnutls_assert ();
-          _gnutls_debug_log ("Checking for libgcrypt failed '%s'\n", p);
+          MHD_gnutls_assert ();
+          MHD__gnutls_debug_log ("Checking for libgcrypt failed '%s'\n", p);
           return GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY;
         }
 
       /* for gcrypt in order to be able to allocate memory */
-      gcry_set_allocation_handler (gnutls_malloc, gnutls_secure_malloc,
-                                   _gnutls_is_secure_memory, gnutls_realloc,
-                                   gnutls_free);
+      gcry_set_allocation_handler (MHD_gnutls_malloc, MHD_gnutls_secure_malloc,
+                                   MHD__gnutls_is_secure_memory, MHD_gnutls_realloc,
+                                   MHD_gnutls_free);
 
       /* gcry_control (GCRYCTL_DISABLE_INTERNAL_LOCKING, NULL, 0); */
 
@@ -257,14 +257,14 @@ MHD_gnutls_global_init (void)
       /* applications may want to override that, so we only use
        * it in debugging mode.
        */
-      gcry_set_log_handler (_gnutls_gcry_log_handler, NULL);
+      gcry_set_log_handler (MHD__gnutls_gcry_log_handler, NULL);
 #endif
     }
 
-  if (gc_init () != GC_OK)
+  if (MHD_gc_init () != GC_OK)
     {
-      gnutls_assert ();
-      _gnutls_debug_log ("Initializing crypto backend failed\n");
+      MHD_gnutls_assert ();
+      MHD__gnutls_debug_log ("Initializing crypto backend failed\n");
       return GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY;
     }
 
@@ -276,50 +276,50 @@ MHD_gnutls_global_init (void)
    * This should not deal with files in the final
    * version.
    */
-  res = asn1_array2tree (pkix_asn1_tab, &_gnutls_pkix1_asn, NULL);
+  res = MHD__asn1_array2tree (MHD_pkix_asn1_tab, &MHD__gnutls_pkix1_asn, NULL);
   if (res != ASN1_SUCCESS)
     {
-      result = mhd_gtls_asn2err (res);
+      result = MHD_gtls_asn2err (res);
       return result;
     }
 
-  res = asn1_array2tree (gnutls_asn1_tab, &_gnutls_gnutls_asn, NULL);
+  res = MHD__asn1_array2tree (MHD_gnutlsMHD__asn1_tab, &MHD__gnutlsMHD__gnutls_asn, NULL);
   if (res != ASN1_SUCCESS)
     {
-      asn1_delete_structure (&_gnutls_pkix1_asn);
-      result = mhd_gtls_asn2err (res);
+      MHD__asn1_delete_structure (&MHD__gnutls_pkix1_asn);
+      result = MHD_gtls_asn2err (res);
       return result;
     }
 
   /* Initialize the gcrypt (if used random generator) */
-  gc_pseudo_random (&c, 1);
+  MHD_gc_pseudo_random (&c, 1);
 
   return result;
 }
 
 /**
- * MHD_gnutls_global_deinit - This function deinitializes the global data
+ * MHD__gnutls_global_deinit - This function deinitializes the global data
  *
  * This function deinitializes the global data, that were initialized
- * using MHD_gnutls_global_init().
+ * using MHD__gnutls_global_init().
  *
  * Note!  This function is not thread safe.  See the discussion for
- * MHD_gnutls_global_init() for more information.
+ * MHD__gnutls_global_init() for more information.
  *
  **/
 void
-MHD_gnutls_global_deinit (void)
+MHD__gnutls_global_deinit (void)
 {
-  if (_gnutls_init == 1)
+  if (MHD__gnutls_init_level == 1)
     {
 #if HAVE_WINSOCK
       WSACleanup ();
 #endif
-      asn1_delete_structure (&_gnutls_gnutls_asn);
-      asn1_delete_structure (&_gnutls_pkix1_asn);
-      gc_done ();
+      MHD__asn1_delete_structure (&MHD__gnutlsMHD__gnutls_asn);
+      MHD__asn1_delete_structure (&MHD__gnutls_pkix1_asn);
+      MHD_gc_done ();
     }
-  _gnutls_init--;
+  MHD__gnutls_init_level--;
 }
 
 /* These functions should be elsewere. Kept here for
@@ -327,7 +327,7 @@ MHD_gnutls_global_deinit (void)
  */
 
 /**
- * MHD_gnutls_transport_set_pull_function - This function sets a read like function
+ * MHD__gnutls_transport_set_pull_function - This function sets a read like function
  * @pull_func: a callback function similar to read()
  * @session: gnutls session
  *
@@ -337,17 +337,17 @@ MHD_gnutls_global_deinit (void)
  * probably be ok.
  *
  * PULL_FUNC is of the form,
- * ssize_t (*mhd_gtls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
+ * ssize_t (*MHD_gtls_pull_func)(MHD_gnutls_transport_ptr_t, void*, size_t);
  **/
 void
-MHD_gnutls_transport_set_pull_function (mhd_gtls_session_t session,
-                                        mhd_gtls_pull_func pull_func)
+MHD__gnutls_transport_set_pull_function (MHD_gtls_session_t session,
+                                        MHD_gtls_pull_func pull_func)
 {
-  session->internals._gnutls_pull_func = pull_func;
+  session->internals.MHD__gnutls_pull_func = pull_func;
 }
 
 /**
- * MHD_gnutls_transport_set_push_function - This function sets the function to send data
+ * MHD__gnutls_transport_set_push_function - This function sets the function to send data
  * @push_func: a callback function similar to write()
  * @session: gnutls session
  *
@@ -358,11 +358,11 @@ MHD_gnutls_transport_set_pull_function (mhd_gtls_session_t session,
  * specify this function for gnutls to be able to send data.
  *
  * PUSH_FUNC is of the form,
- * ssize_t (*mhd_gtls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
+ * ssize_t (*MHD_gtls_push_func)(MHD_gnutls_transport_ptr_t, const void*, size_t);
  **/
 void
-MHD_gnutls_transport_set_push_function (mhd_gtls_session_t session,
-                                        mhd_gtls_push_func push_func)
+MHD__gnutls_transport_set_push_function (MHD_gtls_session_t session,
+                                        MHD_gtls_push_func push_func)
 {
-  session->internals._gnutls_push_func = push_func;
+  session->internals.MHD__gnutls_push_func = push_func;
 }

+ 7 - 7
src/daemon/https/tls/gnutls_global.h

@@ -27,19 +27,19 @@
 
 #include <libtasn1.h>
 
-/* this mutex is used to synchronize threads attemting call MHD_gnutls_global_init / MHD_gnutls_global_deinit */
-pthread_mutex_t gnutls_init_mutex;
+/* this mutex is used to synchronize threads attemting call MHD__gnutls_global_init / MHD__gnutls_global_deinit */
+pthread_mutex_t MHD_gnutls_init_mutex;
 
-int gnutls_is_secure_memory (const void *mem);
+int MHD_gnutls_is_secure_memory (const void *mem);
 
-extern ASN1_TYPE _gnutls_pkix1_asn;
-extern ASN1_TYPE _gnutls_gnutls_asn;
+extern ASN1_TYPE MHD__gnutls_pkix1_asn;
+extern ASN1_TYPE MHD__gnutlsMHD__gnutls_asn;
 
 /* removed const from node_asn* to
  * prevent warnings, since libtasn1 doesn't
  * use the const keywork in its functions.
  */
-#define _gnutls_get_gnutls_asn() ((node_asn*) _gnutls_gnutls_asn)
-#define _gnutls_get_pkix() ((node_asn*) _gnutls_pkix1_asn)
+#define MHD__gnutls_getMHD__gnutls_asn() ((node_asn*) MHD__gnutlsMHD__gnutls_asn)
+#define MHD__gnutls_get_pkix() ((node_asn*) MHD__gnutls_pkix1_asn)
 
 #endif

Plik diff jest za duży
+ 170 - 170
src/daemon/https/tls/gnutls_handshake.c


+ 19 - 19
src/daemon/https/tls/gnutls_handshake.h

@@ -25,39 +25,39 @@
 typedef enum Optional
 { OPTIONAL_PACKET, MANDATORY_PACKET } Optional;
 
-int mhd_gtls_send_handshake (mhd_gtls_session_t session, void *i_data,
+int MHD_gtls_send_handshake (MHD_gtls_session_t session, void *i_data,
                              uint32_t i_datasize,
-                             gnutls_handshake_description_t type);
-int mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data,
+                             MHD_gnutls_handshake_description_t type);
+int MHD_gtls_recv_hello_request (MHD_gtls_session_t session, void *data,
                                  uint32_t data_size);
-int mhd_gtls_send_hello (mhd_gtls_session_t session, int again);
-int mhd_gtls_recv_hello (mhd_gtls_session_t session, opaque * data,
+int MHD_gtls_send_hello (MHD_gtls_session_t session, int again);
+int MHD_gtls_recv_hello (MHD_gtls_session_t session, opaque * data,
                          int datalen);
-int mhd_gtls_recv_handshake (mhd_gtls_session_t session, uint8_t **, int *,
-                             gnutls_handshake_description_t,
+int MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t **, int *,
+                             MHD_gnutls_handshake_description_t,
                              Optional optional);
-int mhd_gtls_generate_session_id (opaque * session_id, uint8_t * len);
-int mhd_gtls_handshake_common (mhd_gtls_session_t session);
-int mhd_gtls_handshake_server (mhd_gtls_session_t session);
-void mhd_gtls_set_server_random (mhd_gtls_session_t session, uint8_t * rnd);
-void mhd_gtls_set_client_random (mhd_gtls_session_t session, uint8_t * rnd);
-int mhd_gtls_tls_create_random (opaque * dst);
-int mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session,
+int MHD_gtls_generate_session_id (opaque * session_id, uint8_t * len);
+int MHD_gtls_handshake_common (MHD_gtls_session_t session);
+int MHD_gtls_handshake_server (MHD_gtls_session_t session);
+void MHD_gtls_set_server_random (MHD_gtls_session_t session, uint8_t * rnd);
+void MHD_gtls_set_client_random (MHD_gtls_session_t session, uint8_t * rnd);
+int MHD_gtls_tls_create_random (opaque * dst);
+int MHD_gtls_remove_unwanted_ciphersuites (MHD_gtls_session_t session,
                                            cipher_suite_st ** cipherSuites,
                                            int numCipherSuites,
                                            enum
                                            MHD_GNUTLS_PublicKeyAlgorithm);
-int mhd_gtls_find_pk_algos_in_ciphersuites (opaque * data, int datalen);
-int mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data,
+int MHD_gtls_find_pk_algos_in_ciphersuites (opaque * data, int datalen);
+int MHD_gtls_server_select_suite (MHD_gtls_session_t session, opaque * data,
                                   int datalen);
 
-int mhd_gtls_negotiate_version (mhd_gtls_session_t session,
+int MHD_gtls_negotiate_version (MHD_gtls_session_t session,
                                 enum MHD_GNUTLS_Protocol adv_version);
-int mhd_gtls_user_hello_func (mhd_gtls_session_t,
+int MHD_gtls_user_hello_func (MHD_gtls_session_t,
                               enum MHD_GNUTLS_Protocol adv_version);
 
 #if MHD_DEBUG_TLS
-int mhd_gtls_handshake_client (mhd_gtls_session_t session);
+int MHD_gtls_handshake_client (MHD_gtls_session_t session);
 #endif
 
 #define STATE session->internals.handshake_state

+ 81 - 81
src/daemon/https/tls/gnutls_hash_int.c

@@ -31,7 +31,7 @@
 #include <gnutls_errors.h>
 
 static inline Gc_hash
-_gnutls_mac2gc (enum MHD_GNUTLS_HashAlgorithm mac)
+MHD__gnutls_mac2gc (enum MHD_GNUTLS_HashAlgorithm mac)
 {
   switch (mac)
     {
@@ -48,32 +48,32 @@ _gnutls_mac2gc (enum MHD_GNUTLS_HashAlgorithm mac)
       return GC_MD5;
       break;
     default:
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return -1;
     }
   return -1;
 }
 
 GNUTLS_HASH_HANDLE
-mhd_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm algorithm)
+MHD_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm algorithm)
 {
   mac_hd_t ret;
   int result;
 
-  ret = gnutls_malloc (sizeof (mac_hd_st));
+  ret = MHD_gnutls_malloc (sizeof (mac_hd_st));
   if (ret == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_HASH_FAILED;
     }
 
   ret->algorithm = algorithm;
 
-  result = gc_hash_open (_gnutls_mac2gc (algorithm), 0, &ret->handle);
+  result = MHD_gc_hash_open (MHD__gnutls_mac2gc (algorithm), 0, &ret->handle);
   if (result)
     {
-      gnutls_assert ();
-      gnutls_free (ret);
+      MHD_gnutls_assert ();
+      MHD_gnutls_free (ret);
       ret = GNUTLS_HASH_FAILED;
     }
 
@@ -81,31 +81,31 @@ mhd_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm algorithm)
 }
 
 int
-mhd_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm)
+MHD_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm)
 {
   int ret;
 
-  ret = gc_hash_digest_length (_gnutls_mac2gc (algorithm));
+  ret = MHD_gc_hash_digest_length (MHD__gnutls_mac2gc (algorithm));
 
   return ret;
 
 }
 
 int
-mhd_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, size_t textlen)
+MHD_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text, size_t textlen)
 {
   if (textlen > 0)
-    gc_hash_write (handle->handle, textlen, text);
+    MHD_gc_hash_write (handle->handle, textlen, text);
   return 0;
 }
 
 GNUTLS_HASH_HANDLE
-mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
+MHD_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
 {
   GNUTLS_HASH_HANDLE ret;
   int result;
 
-  ret = gnutls_malloc (sizeof (mac_hd_st));
+  ret = MHD_gnutls_malloc (sizeof (mac_hd_st));
 
   if (ret == NULL)
     return GNUTLS_HASH_FAILED;
@@ -114,11 +114,11 @@ mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
   ret->key = NULL;              /* it's a hash anyway */
   ret->keysize = 0;
 
-  result = gc_hash_clone (handle->handle, &ret->handle);
+  result = MHD_gc_hash_clone (handle->handle, &ret->handle);
 
   if (result)
     {
-      gnutls_free (ret);
+      MHD_gnutls_free (ret);
       return GNUTLS_HASH_FAILED;
     }
 
@@ -126,42 +126,42 @@ mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle)
 }
 
 void
-mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest)
+MHD_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest)
 {
   const opaque *mac;
   int maclen;
 
-  maclen = mhd_gnutls_hash_get_algo_len (handle->algorithm);
+  maclen = MHD_gnutls_hash_get_algo_len (handle->algorithm);
 
-  mac = gc_hash_read (handle->handle);
+  mac = MHD_gc_hash_read (handle->handle);
   if (digest != NULL)
     memcpy (digest, mac, maclen);
 
-  gc_hash_close (handle->handle);
+  MHD_gc_hash_close (handle->handle);
 
-  gnutls_free (handle);
+  MHD_gnutls_free (handle);
 }
 
 
 mac_hd_t
-mhd_gtls_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm,
+MHD_gtls_MHD_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm,
                     const void *key, int keylen)
 {
   mac_hd_t ret;
   int result;
 
-  ret = gnutls_malloc (sizeof (mac_hd_st));
+  ret = MHD_gnutls_malloc (sizeof (mac_hd_st));
   if (ret == NULL)
     return GNUTLS_MAC_FAILED;
 
-  result = gc_hash_open (_gnutls_mac2gc (algorithm), GC_HMAC, &ret->handle);
+  result = MHD_gc_hash_open (MHD__gnutls_mac2gc (algorithm), GC_HMAC, &ret->handle);
   if (result)
     {
-      gnutls_free (ret);
+      MHD_gnutls_free (ret);
       return GNUTLS_MAC_FAILED;
     }
 
-  gc_hash_hmac_setkey (ret->handle, keylen, key);
+  MHD_gc_hash_MHD_hmac_setkey (ret->handle, keylen, key);
 
   ret->algorithm = algorithm;
   ret->key = key;
@@ -171,21 +171,21 @@ mhd_gtls_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm,
 }
 
 void
-mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest)
+MHD_gnutls_MHD_hmac_deinit (mac_hd_t handle, void *digest)
 {
   const opaque *mac;
   int maclen;
 
-  maclen = mhd_gnutls_hash_get_algo_len (handle->algorithm);
+  maclen = MHD_gnutls_hash_get_algo_len (handle->algorithm);
 
-  mac = gc_hash_read (handle->handle);
+  mac = MHD_gc_hash_read (handle->handle);
 
   if (digest != NULL)
     memcpy (digest, mac, maclen);
 
-  gc_hash_close (handle->handle);
+  MHD_gc_hash_close (handle->handle);
 
-  gnutls_free (handle);
+  MHD_gnutls_free (handle);
 }
 
 inline static int
@@ -203,7 +203,7 @@ get_padsize (enum MHD_GNUTLS_HashAlgorithm algorithm)
 }
 
 mac_hd_t
-mhd_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm, void *key,
+MHD_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm, void *key,
                           int keylen)
 {
   mac_hd_t ret;
@@ -213,28 +213,28 @@ mhd_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm, void *key,
   padsize = get_padsize (algorithm);
   if (padsize == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_MAC_FAILED;
     }
 
   memset (ipad, 0x36, padsize);
 
-  ret = mhd_gtls_hash_init (algorithm);
+  ret = MHD_gtls_hash_init (algorithm);
   if (ret != GNUTLS_HASH_FAILED)
     {
       ret->key = key;
       ret->keysize = keylen;
 
       if (keylen > 0)
-        mhd_gnutls_hash (ret, key, keylen);
-      mhd_gnutls_hash (ret, ipad, padsize);
+        MHD_gnutls_hash (ret, key, keylen);
+      MHD_gnutls_hash (ret, ipad, padsize);
     }
 
   return ret;
 }
 
 void
-mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
+MHD_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
 {
   opaque ret[MAX_HASH_SIZE];
   mac_hd_t td;
@@ -245,29 +245,29 @@ mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest)
   padsize = get_padsize (handle->algorithm);
   if (padsize == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return;
     }
 
   memset (opad, 0x5C, padsize);
 
-  td = mhd_gtls_hash_init (handle->algorithm);
+  td = MHD_gtls_hash_init (handle->algorithm);
   if (td != GNUTLS_MAC_FAILED)
     {
       if (handle->keysize > 0)
-        mhd_gnutls_hash (td, handle->key, handle->keysize);
+        MHD_gnutls_hash (td, handle->key, handle->keysize);
 
-      mhd_gnutls_hash (td, opad, padsize);
-      block = mhd_gnutls_hash_get_algo_len (handle->algorithm);
-      mhd_gnutls_hash_deinit (handle, ret);     /* get the previous hash */
-      mhd_gnutls_hash (td, ret, block);
+      MHD_gnutls_hash (td, opad, padsize);
+      block = MHD_gnutls_hash_get_algo_len (handle->algorithm);
+      MHD_gnutls_hash_deinit (handle, ret);     /* get the previous hash */
+      MHD_gnutls_hash (td, ret, block);
 
-      mhd_gnutls_hash_deinit (td, digest);
+      MHD_gnutls_hash_deinit (td, digest);
     }
 }
 
 void
-mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
+MHD_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
                                       void *digest, opaque * key,
                                       uint32_t key_size)
 {
@@ -281,30 +281,30 @@ mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle,
   padsize = get_padsize (handle->algorithm);
   if (padsize == 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return;
     }
 
   memset (opad, 0x5C, padsize);
   memset (ipad, 0x36, padsize);
 
-  td = mhd_gtls_hash_init (handle->algorithm);
+  td = MHD_gtls_hash_init (handle->algorithm);
   if (td != GNUTLS_HASH_FAILED)
     {
       if (key_size > 0)
-        mhd_gnutls_hash (td, key, key_size);
+        MHD_gnutls_hash (td, key, key_size);
 
-      mhd_gnutls_hash (td, opad, padsize);
-      block = mhd_gnutls_hash_get_algo_len (handle->algorithm);
+      MHD_gnutls_hash (td, opad, padsize);
+      block = MHD_gnutls_hash_get_algo_len (handle->algorithm);
 
       if (key_size > 0)
-        mhd_gnutls_hash (handle, key, key_size);
-      mhd_gnutls_hash (handle, ipad, padsize);
-      mhd_gnutls_hash_deinit (handle, ret);     /* get the previous hash */
+        MHD_gnutls_hash (handle, key, key_size);
+      MHD_gnutls_hash (handle, ipad, padsize);
+      MHD_gnutls_hash_deinit (handle, ret);     /* get the previous hash */
 
-      mhd_gnutls_hash (td, ret, block);
+      MHD_gnutls_hash (td, ret, block);
 
-      mhd_gnutls_hash_deinit (td, digest);
+      MHD_gnutls_hash_deinit (td, digest);
     }
 }
 
@@ -322,18 +322,18 @@ ssl3_sha (int i, opaque * secret, int secret_len,
       text1[j] = 65 + i;        /* A==65 */
     }
 
-  td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
+  td = MHD_gtls_hash_init (MHD_GNUTLS_MAC_SHA1);
   if (td == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_HASH_FAILED;
     }
 
-  mhd_gnutls_hash (td, text1, i + 1);
-  mhd_gnutls_hash (td, secret, secret_len);
-  mhd_gnutls_hash (td, rnd, rnd_len);
+  MHD_gnutls_hash (td, text1, i + 1);
+  MHD_gnutls_hash (td, secret, secret_len);
+  MHD_gnutls_hash (td, rnd, rnd_len);
 
-  mhd_gnutls_hash_deinit (td, digest);
+  MHD_gnutls_hash_deinit (td, digest);
   return 0;
 }
 
@@ -345,54 +345,54 @@ ssl3_md5 (int i, opaque * secret, int secret_len,
   mac_hd_t td;
   int ret;
 
-  td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
+  td = MHD_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
   if (td == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_HASH_FAILED;
     }
 
-  mhd_gnutls_hash (td, secret, secret_len);
+  MHD_gnutls_hash (td, secret, secret_len);
 
   ret = ssl3_sha (i, secret, secret_len, rnd, rnd_len, tmp);
   if (ret < 0)
     {
-      gnutls_assert ();
-      mhd_gnutls_hash_deinit (td, digest);
+      MHD_gnutls_assert ();
+      MHD_gnutls_hash_deinit (td, digest);
       return ret;
     }
 
-  mhd_gnutls_hash (td, tmp,
-                   mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_SHA1));
+  MHD_gnutls_hash (td, tmp,
+                   MHD_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_SHA1));
 
-  mhd_gnutls_hash_deinit (td, digest);
+  MHD_gnutls_hash_deinit (td, digest);
   return 0;
 }
 
 int
-mhd_gnutls_ssl3_hash_md5 (void *first, int first_len,
+MHD_gnutls_ssl3_hash_md5 (void *first, int first_len,
                           void *second, int second_len, int ret_len,
                           opaque * ret)
 {
   opaque digest[MAX_HASH_SIZE];
   mac_hd_t td;
-  int block = mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
+  int block = MHD_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
 
-  td = mhd_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
+  td = MHD_gtls_hash_init (MHD_GNUTLS_MAC_MD5);
   if (td == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_HASH_FAILED;
     }
 
-  mhd_gnutls_hash (td, first, first_len);
-  mhd_gnutls_hash (td, second, second_len);
+  MHD_gnutls_hash (td, first, first_len);
+  MHD_gnutls_hash (td, second, second_len);
 
-  mhd_gnutls_hash_deinit (td, digest);
+  MHD_gnutls_hash_deinit (td, digest);
 
   if (ret_len > block)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_INTERNAL_ERROR;
     }
 
@@ -403,13 +403,13 @@ mhd_gnutls_ssl3_hash_md5 (void *first, int first_len,
 }
 
 int
-mhd_gnutls_ssl3_generate_random (void *secret, int secret_len,
+MHD_gnutls_ssl3_generate_random (void *secret, int secret_len,
                                  void *rnd, int rnd_len,
                                  int ret_bytes, opaque * ret)
 {
   int i = 0, copy, output_bytes;
   opaque digest[MAX_HASH_SIZE];
-  int block = mhd_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
+  int block = MHD_gnutls_hash_get_algo_len (MHD_GNUTLS_MAC_MD5);
   int result, times;
 
   output_bytes = 0;
@@ -427,7 +427,7 @@ mhd_gnutls_ssl3_generate_random (void *secret, int secret_len,
       result = ssl3_md5 (i, secret, secret_len, rnd, rnd_len, digest);
       if (result < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return result;
         }
 

+ 13 - 13
src/daemon/https/tls/gnutls_hash_int.h

@@ -31,7 +31,7 @@
 
 typedef struct
 {
-  gc_hash_handle handle;
+  MHD_gc_hash_handle handle;
   enum MHD_GNUTLS_HashAlgorithm algorithm;
   const void *key;
   int keysize;
@@ -42,31 +42,31 @@ typedef mac_hd_t GNUTLS_HASH_HANDLE;
 #define GNUTLS_HASH_FAILED NULL
 #define GNUTLS_MAC_FAILED NULL
 
-mac_hd_t mhd_gtls_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm,
+mac_hd_t MHD_gtls_MHD_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm,
                              const void *key, int keylen);
 
-void mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest);
+void MHD_gnutls_MHD_hmac_deinit (mac_hd_t handle, void *digest);
 
-mac_hd_t mhd_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm,
+mac_hd_t MHD_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm,
                                    void *key, int keylen);
-void mhd_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest);
+void MHD_gnutls_mac_deinit_ssl3 (mac_hd_t handle, void *digest);
 
-GNUTLS_HASH_HANDLE mhd_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm
+GNUTLS_HASH_HANDLE MHD_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm
                                        algorithm);
-int mhd_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm);
-int mhd_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text,
+int MHD_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm);
+int MHD_gnutls_hash (GNUTLS_HASH_HANDLE handle, const void *text,
                      size_t textlen);
-void mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest);
+void MHD_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest);
 
-int mhd_gnutls_ssl3_generate_random (void *secret, int secret_len,
+int MHD_gnutls_ssl3_generate_random (void *secret, int secret_len,
                                      void *rnd, int random_len, int bytes,
                                      opaque * ret);
-int mhd_gnutls_ssl3_hash_md5 (void *first, int first_len, void *second,
+int MHD_gnutls_ssl3_hash_md5 (void *first, int first_len, void *second,
                               int second_len, int ret_len, opaque * ret);
 
-void mhd_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, void *digest,
+void MHD_gnutls_mac_deinit_ssl3_handshake (mac_hd_t handle, void *digest,
                                            opaque * key, uint32_t key_size);
 
-GNUTLS_HASH_HANDLE mhd_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle);
+GNUTLS_HASH_HANDLE MHD_gnutls_hash_copy (GNUTLS_HASH_HANDLE handle);
 
 #endif /* GNUTLS_HASH_INT_H */

+ 88 - 88
src/daemon/https/tls/gnutls_int.h

@@ -92,9 +92,9 @@
 #define DEFAULT_VERIFY_DEPTH 32
 #define DEFAULT_VERIFY_BITS 16*1024
 
-#define DECR_LEN(len, x) do { len-=x; if (len<0) {gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;} } while (0)
-#define DECR_LENGTH_RET(len, x, RET) do { len-=x; if (len<0) {gnutls_assert(); return RET;} } while (0)
-#define DECR_LENGTH_COM(len, x, COM) do { len-=x; if (len<0) {gnutls_assert(); COM;} } while (0)
+#define DECR_LEN(len, x) do { len-=x; if (len<0) {MHD_gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;} } while (0)
+#define DECR_LENGTH_RET(len, x, RET) do { len-=x; if (len<0) {MHD_gnutls_assert(); return RET;} } while (0)
+#define DECR_LENGTH_COM(len, x, COM) do { len-=x; if (len<0) {MHD_gnutls_assert(); COM;} } while (0)
 
 #define HASH2MAC(x) ((enum MHD_GNUTLS_HashAlgorithm)x)
 
@@ -129,11 +129,11 @@ typedef enum handshake_state_t
 
 #include <gnutls_str.h>
 
-typedef mhd_gtls_string mhd_gtls_buffer;
+typedef MHD_gtls_string MHD_gtls_buffer;
 
-#define mhd_gtls_buffer_init(buf) mhd_gtls_string_init(buf, gnutls_malloc, gnutls_realloc, gnutls_free);
-#define mhd_gtls_buffer_clear mhd_gtls_string_clear
-#define mhd_gtls_buffer_append mhd_gtls_string_append_data
+#define MHD_gtls_buffer_init(buf) MHD_gtls_string_init(buf, MHD_gnutls_malloc, MHD_gnutls_realloc, MHD_gnutls_free);
+#define MHD_gtls_buffer_clear MHD_gtls_string_clear
+#define MHD_gtls_buffer_append MHD_gtls_string_append_data
 
 /* This is the maximum number of algorithms (ciphers or macs etc).
  * keep it synced with GNUTLS_MAX_ALGORITHM_NUM in gnutls.h
@@ -179,20 +179,20 @@ typedef enum content_type_t
 typedef void (*LOG_FUNC) (int, const char *);
 
 /* Store & Retrieve functions defines:  */
-typedef struct mhd_gtls_auth_cred_st
+typedef struct MHD_gtls_auth_cred_st
 {
   enum MHD_GNUTLS_CredentialsType algorithm;
 
   /* the type of credentials depends on algorithm
    */
   void *credentials;
-  struct mhd_gtls_auth_cred_st *next;
+  struct MHD_gtls_auth_cred_st *next;
 } auth_cred_st;
 
-struct mhd_gtls_key
+struct MHD_gtls_key
 {
   /* For DH KX */
-  gnutls_datum_t key;
+  MHD_gnutls_datum_t key;
   mpi_t KEY;
   mpi_t client_Y;
   mpi_t client_g;
@@ -212,7 +212,7 @@ struct mhd_gtls_key
   /* this is used to hold the peers authentication data
    */
   /* auth_info_t structures SHOULD NOT contain malloced
-   * elements. Check gnutls_session_pack.c, and gnutls_auth.c.
+   * elements. Check MHD_gnutls_session_pack.c, and MHD_gnutls_auth.c.
    * Rememember that this should be calloced!
    */
   void *auth_info;
@@ -233,7 +233,7 @@ struct mhd_gtls_key
    * for a client certificate verify
    */
 };
-typedef struct mhd_gtls_key *mhd_gtls_key_st;
+typedef struct MHD_gtls_key *MHD_gtls_key_st;
 
 /* STATE (cont) */
 #include <gnutls_hash_int.h>
@@ -254,7 +254,7 @@ typedef struct
 {
   opaque name[MAX_SERVER_NAME_SIZE];
   unsigned name_length;
-  gnutls_server_name_type_t type;
+  MHD_gnutls_server_name_type_t type;
 } server_name_st;
 
 #define MAX_SERVER_NAME_EXTENSIONS 3
@@ -267,20 +267,20 @@ typedef struct
   opaque srp_username[MAX_SRP_USERNAME + 1];
 
   /* TLS/IA data. */
-  int gnutls_ia_enable, gnutls_ia_peer_enable;
-  int gnutls_ia_allowskip, gnutls_ia_peer_allowskip;
+  int MHD_gnutls_ia_enable, MHD_gnutls_ia_peer_enable;
+  int MHD_gnutls_ia_allowskip, MHD_gnutls_ia_peer_allowskip;
 
   /* Used by extensions that enable supplemental data. */
   int do_recv_supplemental, do_send_supplemental;
 
   /* Opaque PRF input. */
-  gnutls_oprfi_callback_func oprfi_cb;
+  MHD_gnutls_oprfi_callback_func oprfi_cb;
   void *oprfi_userdata;
   opaque *oprfi_client;
   uint16_t oprfi_client_len;
   opaque *oprfi_server;
   uint16_t oprfi_server_len;
-} mhd_gtls_ext_st;
+} MHD_gtls_ext_st;
 
 /* This flag indicates for an extension whether
  * it is useful to application level or TLS level only.
@@ -292,7 +292,7 @@ typedef enum tls_ext_parse_type_t
   EXTENSION_ANY,
   EXTENSION_APPLICATION,
   EXTENSION_TLS
-} mhd_gtls_ext_parse_type_t;
+} MHD_gtls_ext_parse_type_t;
 
 /* auth_info_t structures now MAY contain malloced
  * elements.
@@ -305,7 +305,7 @@ typedef enum tls_ext_parse_type_t
  */
 
 /* if you add anything in Security_Parameters struct, then
- * also modify CPY_COMMON in gnutls_constate.c
+ * also modify CPY_COMMON in MHD_gnutls_constate.c
  */
 
 /* Note that the security parameters structure is set up after the
@@ -314,7 +314,7 @@ typedef enum tls_ext_parse_type_t
  */
 typedef struct
 {
-  gnutls_connection_end_t entity;
+  MHD_gnutls_connection_end_t entity;
   enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm;
   /* we've got separate write/read bulk/macs because
    * there is a time in handshake where the peer has
@@ -339,7 +339,7 @@ typedef struct
   opaque session_id[TLS_MAX_SESSION_ID_SIZE];
   uint8_t session_id_size;
   time_t timestamp;
-  mhd_gtls_ext_st extensions;
+  MHD_gtls_ext_st extensions;
 
   /* The send size is the one requested by the programmer.
    * The recv size is the one negotiated with the peer.
@@ -351,23 +351,23 @@ typedef struct
   enum MHD_GNUTLS_Protocol version;     /* moved here */
   /* For TLS/IA.  XXX: Move to IA credential? */
   opaque inner_secret[TLS_MASTER_SIZE];
-} mhd_gtls_security_param_st;
+} MHD_gtls_security_param_st;
 
 /* This structure holds the generated keys
  */
 typedef struct
 {
-  gnutls_datum_t server_write_mac_secret;
-  gnutls_datum_t client_write_mac_secret;
-  gnutls_datum_t server_write_IV;
-  gnutls_datum_t client_write_IV;
-  gnutls_datum_t server_write_key;
-  gnutls_datum_t client_write_key;
+  MHD_gnutls_datum_t server_write_mac_secret;
+  MHD_gnutls_datum_t client_write_mac_secret;
+  MHD_gnutls_datum_t server_write_IV;
+  MHD_gnutls_datum_t client_write_IV;
+  MHD_gnutls_datum_t server_write_key;
+  MHD_gnutls_datum_t client_write_key;
   int generated_keys;           /* zero if keys have not
                                  * been generated. Non zero
                                  * otherwise.
                                  */
-} mhd_gtls_cipher_specs_st;
+} MHD_gtls_cipher_specs_st;
 
 typedef struct
 {
@@ -375,29 +375,29 @@ typedef struct
   cipher_hd_t read_cipher_state;
   comp_hd_t read_compression_state;
   comp_hd_t write_compression_state;
-  gnutls_datum_t read_mac_secret;
-  gnutls_datum_t write_mac_secret;
+  MHD_gnutls_datum_t read_mac_secret;
+  MHD_gnutls_datum_t write_mac_secret;
   uint64 read_sequence_number;
   uint64 write_sequence_number;
-} mhd_gtls_conn_stat_st;
+} MHD_gtls_conn_stat_st;
 
 typedef struct
 {
   unsigned int priority[MAX_ALGOS];
   unsigned int num_algorithms;
-} mhd_gtls_priority_st;
+} MHD_gtls_priority_st;
 
 /* For the external api */
 struct MHD_gtls_priority_st
 {
-  mhd_gtls_priority_st cipher;
-  mhd_gtls_priority_st mac;
-  mhd_gtls_priority_st kx;
-  mhd_gtls_priority_st compression;
-  mhd_gtls_priority_st protocol;
+  MHD_gtls_priority_st cipher;
+  MHD_gtls_priority_st mac;
+  MHD_gtls_priority_st kx;
+  MHD_gtls_priority_st compression;
+  MHD_gtls_priority_st protocol;
 
   /* certificate type : x509, OpenPGP, etc. */
-  mhd_gtls_priority_st cert_type;
+  MHD_gtls_priority_st cert_type;
 
   /* to disable record padding */
   int no_padding;
@@ -410,15 +410,15 @@ typedef struct MHD_gtls_dh_params_int
   /* [0] is the prime, [1] is the generator.
    */
   mpi_t params[2];
-} mhd_gtls_dh_params_st;
+} MHD_gtls_dh_params_st;
 
 typedef struct
 {
-  mhd_gtls_dh_params_t dh_params;
+  MHD_gtls_dh_params_t dh_params;
   int free_dh_params;
-  mhd_gtls_rsa_params_t rsa_params;
+  MHD_gtls_rsa_params_t rsa_params;
   int free_rsa_params;
-} mhd_gtls_internal_params_st;
+} MHD_gtls_internal_params_st;
 
 typedef struct
 {
@@ -427,19 +427,19 @@ typedef struct
   size_t header_size;
   /* this holds the length of the handshake packet */
   size_t packet_length;
-  gnutls_handshake_description_t recv_type;
-} mhd_gtls_handshake_header_buffer_st;
+  MHD_gnutls_handshake_description_t recv_type;
+} MHD_gtls_handshake_header_buffer_st;
 
 typedef struct
 {
-  mhd_gtls_buffer application_data_buffer;      /* holds data to be delivered to application layer */
-  mhd_gtls_buffer handshake_hash_buffer;        /* used to keep the last received handshake
+  MHD_gtls_buffer application_data_buffer;      /* holds data to be delivered to application layer */
+  MHD_gtls_buffer handshake_hash_buffer;        /* used to keep the last received handshake
                                                  * message */
   mac_hd_t handshake_mac_handle_sha;    /* hash of the handshake messages */
   mac_hd_t handshake_mac_handle_md5;    /* hash of the handshake messages */
 
-  mhd_gtls_buffer handshake_data_buffer;        /* this is a buffer that holds the current handshake message */
-  mhd_gtls_buffer ia_data_buffer;       /* holds inner application data (TLS/IA) */
+  MHD_gtls_buffer handshake_data_buffer;        /* this is a buffer that holds the current handshake message */
+  MHD_gtls_buffer ia_data_buffer;       /* holds inner application data (TLS/IA) */
   resumable_session_t resumable;        /* TRUE or FALSE - if we can resume that session */
   handshake_state_t handshake_state;    /* holds
                                          * a number which indicates where
@@ -471,28 +471,28 @@ typedef struct
 
   /* resumed session */
   resumable_session_t resumed;  /* RESUME_TRUE or FALSE - if we are resuming a session */
-  mhd_gtls_security_param_st resumed_security_parameters;
+  MHD_gtls_security_param_st resumed_security_parameters;
 
   /* sockets internals */
   int lowat;
 
   /* These buffers are used in the handshake
-   * protocol only. freed using _gnutls_handshake_io_buffer_clear();
+   * protocol only. freed using MHD__gnutls_handshake_io_buffer_clear();
    */
-  mhd_gtls_buffer handshake_send_buffer;
+  MHD_gtls_buffer handshake_send_buffer;
   size_t handshake_send_buffer_prev_size;
   content_type_t handshake_send_buffer_type;
-  gnutls_handshake_description_t handshake_send_buffer_htype;
+  MHD_gnutls_handshake_description_t handshake_send_buffer_htype;
   content_type_t handshake_recv_buffer_type;
-  gnutls_handshake_description_t handshake_recv_buffer_htype;
-  mhd_gtls_buffer handshake_recv_buffer;
+  MHD_gnutls_handshake_description_t handshake_recv_buffer_htype;
+  MHD_gtls_buffer handshake_recv_buffer;
 
   /* this buffer holds a record packet -mostly used for
    * non blocking IO.
    */
-  mhd_gtls_buffer record_recv_buffer;
-  mhd_gtls_buffer record_send_buffer;   /* holds cached data
-                                         * for the gnutls_io_write_buffered()
+  MHD_gtls_buffer record_recv_buffer;
+  MHD_gtls_buffer record_send_buffer;   /* holds cached data
+                                         * for the MHD_gnutls_io_write_buffered()
                                          * function.
                                          */
   size_t record_send_buffer_prev_size;  /* holds the
@@ -508,7 +508,7 @@ typedef struct
   int have_peeked_data;
 
   int expire_time;              /* after expire_time seconds this session will expire */
-  struct mhd_gtls_mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */
+  struct MHD_gtls_mod_auth_st_int *auth_struct; /* used in handshake packets and KX algorithms */
 
   /* TODO rm */
   int v2_hello;                 /* 0 if the client hello is v3+.
@@ -516,7 +516,7 @@ typedef struct
                                  */
   /* keeps the headers of the handshake packet
    */
-  mhd_gtls_handshake_header_buffer_st handshake_header_buffer;
+  MHD_gtls_handshake_header_buffer_st handshake_header_buffer;
 
   /* this is the highest version available
    * to the peer. (advertized version).
@@ -533,7 +533,7 @@ typedef struct
   int send_cert_req;
 
   /* bits to use for DHE and DHA
-   * use _gnutls_dh_get_prime_bits() and MHD_gnutls_dh_set_prime_bits()
+   * use MHD__gnutls_dh_get_prime_bits() and MHD__gnutls_dh_set_prime_bits()
    * to access it.
    */
   uint16_t dh_prime_bits;
@@ -542,17 +542,17 @@ typedef struct
 
   /* PUSH & PULL functions.
    */
-  mhd_gtls_pull_func _gnutls_pull_func;
-  mhd_gtls_push_func _gnutls_push_func;
+  MHD_gtls_pull_func MHD__gnutls_pull_func;
+  MHD_gtls_push_func MHD__gnutls_push_func;
   /* Holds the first argument of PUSH and PULL
    * functions;
    */
-  gnutls_transport_ptr_t transport_recv_ptr;
-  gnutls_transport_ptr_t transport_send_ptr;
+  MHD_gnutls_transport_ptr_t transport_recv_ptr;
+  MHD_gnutls_transport_ptr_t transport_send_ptr;
 
   /* post client hello callback (server side only)
    */
-  gnutls_handshake_post_client_hello_func user_hello_func;
+  MHD_gnutls_handshake_post_client_hello_func user_hello_func;
 
   /* Holds the record size requested by the
    * user.
@@ -560,12 +560,12 @@ typedef struct
   uint16_t proposed_record_size;
 
   /* holds the selected certificate and key.
-   * use mhd_gtls_selected_certs_deinit() and mhd_gtls_selected_certs_set()
+   * use MHD_gtls_selected_certs_deinit() and MHD_gtls_selected_certs_set()
    * to change them.
    */
-  gnutls_cert *selected_cert_list;
+  MHD_gnutls_cert *selected_cert_list;
   int selected_cert_list_length;
-  gnutls_privkey *selected_key;
+  MHD_gnutls_privkey *selected_key;
   int selected_need_free;
 
   /* holds the extensions we sent to the peer
@@ -615,16 +615,16 @@ typedef struct
    * credentials structure, or from a callback. That is to
    * minimize external calls.
    */
-  mhd_gtls_internal_params_st params;
+  MHD_gtls_internal_params_st params;
 
   /* This buffer is used by the record recv functions,
    * as a temporary store buffer.
    */
-  gnutls_datum_t recv_buffer;
+  MHD_gnutls_datum_t recv_buffer;
 
   /* To avoid using global variables, and especially on Windows where
    * the application may use a different errno variable than GnuTLS,
-   * it is possible to use MHD_gnutls_transport_set_errno to set a
+   * it is possible to use MHD__gnutls_transport_set_errno to set a
    * session-specific errno variable in the user-replaceable push/pull
    * functions.  This value is used by the send/recv functions.  (The
    * strange name of this variable is because 'errno' is typically
@@ -633,44 +633,44 @@ typedef struct
   int errnum;
 
   /* Function used to perform public-key signing operation during
-     handshake.  Used by gnutls_sig.c:_gnutls_tls_sign(), see also
+     handshake.  Used by MHD_gnutls_sig.c:MHD__gnutls_tls_sign(), see also
      MHD_gtls_sign_callback_set(). */
-  gnutls_sign_func sign_func;
+  MHD_gnutls_sign_func sign_func;
   void *sign_func_userdata;
 
-  /* If you add anything here, check mhd_gtls_handshake_internal_state_clear().
+  /* If you add anything here, check MHD_gtls_handshake_internal_state_clear().
    */
-} mhd_gtls_internals_st;
+} MHD_gtls_internals_st;
 
 struct MHD_gtls_session_int
 {
-  mhd_gtls_security_param_st security_parameters;
-  mhd_gtls_cipher_specs_st cipher_specs;
-  mhd_gtls_conn_stat_st connection_state;
-  mhd_gtls_internals_st internals;
-  mhd_gtls_key_st key;
+  MHD_gtls_security_param_st security_parameters;
+  MHD_gtls_cipher_specs_st cipher_specs;
+  MHD_gtls_conn_stat_st connection_state;
+  MHD_gtls_internals_st internals;
+  MHD_gtls_key_st key;
 };
 
 /* functions */
-void mhd_gtls_set_current_version (mhd_gtls_session_t session,
+void MHD_gtls_set_current_version (MHD_gtls_session_t session,
                                    enum MHD_GNUTLS_Protocol version);
 
-void mhd_gtls_free_auth_info (mhd_gtls_session_t session);
+void MHD_gtls_free_auth_info (MHD_gtls_session_t session);
 
 /* These two macros return the advertized TLS version of
  * the peer.
  */
-#define _gnutls_get_adv_version_major( session) \
+#define MHD__gnutls_get_adv_version_major( session) \
 	session->internals.adv_version_major
 
-#define _gnutls_get_adv_version_minor( session) \
+#define MHD__gnutls_get_adv_version_minor( session) \
 	session->internals.adv_version_minor
 
 #define set_adv_version( session, major, minor) \
 	session->internals.adv_version_major = major; \
 	session->internals.adv_version_minor = minor
 
-void mhd_gtls_set_adv_version (mhd_gtls_session_t, enum MHD_GNUTLS_Protocol);
-enum MHD_GNUTLS_Protocol mhd_gtls_get_adv_version (mhd_gtls_session_t);
+void MHD_gtls_set_adv_version (MHD_gtls_session_t, enum MHD_GNUTLS_Protocol);
+enum MHD_GNUTLS_Protocol MHD_gtls_get_adv_version (MHD_gtls_session_t);
 
 #endif /* GNUTLS_INT_H */

+ 114 - 114
src/daemon/https/tls/gnutls_kx.c

@@ -23,7 +23,7 @@
  */
 
 /* This file contains functions which are wrappers for the key exchange
- * part of TLS. They are called by the handshake functions (MHD_gnutls_handshake)
+ * part of TLS. They are called by the handshake functions (MHD__gnutls_handshake)
  */
 
 #include "gnutls_int.h"
@@ -42,10 +42,10 @@
  */
 
 #define MASTER_SECRET "master secret"
-static int generate_normal_master (mhd_gtls_session_t session, int);
+static int generate_normal_master (MHD_gtls_session_t session, int);
 
 int
-mhd_gtls_generate_master (mhd_gtls_session_t session, int keep_premaster)
+MHD_gtls_generate_master (MHD_gtls_session_t session, int keep_premaster)
 {
   if (session->internals.resumed == RESUME_FALSE)
     return generate_normal_master (session, keep_premaster);
@@ -56,22 +56,22 @@ mhd_gtls_generate_master (mhd_gtls_session_t session, int keep_premaster)
  */
 #define PREMASTER session->key->key
 static int
-generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
+generate_normal_master (MHD_gtls_session_t session, int keep_premaster)
 {
   int ret = 0;
   char buf[512];
 
-  _gnutls_hard_log ("INT: PREMASTER SECRET[%d]: %s\n", PREMASTER.size,
-                    mhd_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf,
+  MHD__gnutls_hard_log ("INT: PREMASTER SECRET[%d]: %s\n", PREMASTER.size,
+                    MHD_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf,
                                       sizeof (buf)));
-  _gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32,
-                    mhd_gtls_bin2hex (session->security_parameters.
+  MHD__gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32,
+                    MHD_gtls_bin2hex (session->security_parameters.
                                       client_random, 32, buf, sizeof (buf)));
-  _gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32,
-                    mhd_gtls_bin2hex (session->security_parameters.
+  MHD__gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32,
+                    MHD_gtls_bin2hex (session->security_parameters.
                                       server_random, 32, buf, sizeof (buf)));
 
-  if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
+  if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3)
     {
       opaque rnd[2 * TLS_RANDOM_SIZE + 1];
 
@@ -81,7 +81,7 @@ generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
               session->security_parameters.server_random, TLS_RANDOM_SIZE);
 
       ret =
-        mhd_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size,
+        MHD_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size,
                                          rnd, 2 * TLS_RANDOM_SIZE,
                                          TLS_MASTER_SIZE,
                                          session->security_parameters.
@@ -97,25 +97,25 @@ generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
       rndlen += session->security_parameters.extensions.oprfi_client_len;
       rndlen += session->security_parameters.extensions.oprfi_server_len;
 
-      rnd = gnutls_malloc (rndlen + 1);
+      rnd = MHD_gnutls_malloc (rndlen + 1);
       if (!rnd)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_MEMORY_ERROR;
         }
 
-      _gnutls_hard_log ("INT: CLIENT OPRFI[%d]: %s\n",
+      MHD__gnutls_hard_log ("INT: CLIENT OPRFI[%d]: %s\n",
                         session->security_parameters.
                         extensions.oprfi_server_len,
-                        mhd_gtls_bin2hex (session->security_parameters.
+                        MHD_gtls_bin2hex (session->security_parameters.
                                           extensions.oprfi_client,
                                           session->security_parameters.
                                           extensions.oprfi_client_len, buf,
                                           sizeof (buf)));
-      _gnutls_hard_log ("INT: SERVER OPRFI[%d]: %s\n",
+      MHD__gnutls_hard_log ("INT: SERVER OPRFI[%d]: %s\n",
                         session->security_parameters.
                         extensions.oprfi_server_len,
-                        mhd_gtls_bin2hex (session->security_parameters.
+                        MHD_gtls_bin2hex (session->security_parameters.
                                           extensions.oprfi_server,
                                           session->security_parameters.
                                           extensions.oprfi_server_len, buf,
@@ -135,12 +135,12 @@ generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
               session->security_parameters.extensions.oprfi_server,
               session->security_parameters.extensions.oprfi_server_len);
 
-      ret = mhd_gtls_PRF (session, PREMASTER.data, PREMASTER.size,
+      ret = MHD_gtls_PRF (session, PREMASTER.data, PREMASTER.size,
                           MASTER_SECRET, strlen (MASTER_SECRET),
                           rnd, rndlen, TLS_MASTER_SIZE,
                           session->security_parameters.master_secret);
 
-      gnutls_free (rnd);
+      MHD_gnutls_free (rnd);
     }
   else
     {
@@ -152,7 +152,7 @@ generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
               session->security_parameters.server_random, TLS_RANDOM_SIZE);
 
       ret =
-        mhd_gtls_PRF (session, PREMASTER.data, PREMASTER.size,
+        MHD_gtls_PRF (session, PREMASTER.data, PREMASTER.size,
                       MASTER_SECRET, strlen (MASTER_SECRET),
                       rnd, 2 * TLS_RANDOM_SIZE, TLS_MASTER_SIZE,
                       session->security_parameters.master_secret);
@@ -163,13 +163,13 @@ generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
           session->security_parameters.master_secret, TLS_MASTER_SIZE);
 
   if (!keep_premaster)
-    _gnutls_free_datum (&PREMASTER);
+    MHD__gnutls_free_datum (&PREMASTER);
 
   if (ret < 0)
     return ret;
 
-  _gnutls_hard_log ("INT: MASTER SECRET: %s\n",
-                    mhd_gtls_bin2hex (session->security_parameters.
+  MHD__gnutls_hard_log ("INT: MASTER SECRET: %s\n",
+                    MHD_gtls_bin2hex (session->security_parameters.
                                       master_secret, TLS_MASTER_SIZE, buf,
                                       sizeof (buf)));
 
@@ -182,13 +182,13 @@ generate_normal_master (mhd_gtls_session_t session, int keep_premaster)
  * by the selected ciphersuite.
  */
 int
-mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again)
+MHD_gtls_send_server_kx_message (MHD_gtls_session_t session, int again)
 {
   uint8_t *data = NULL;
   int data_size = 0;
   int ret = 0;
 
-  if (session->internals.auth_struct->mhd_gtls_gen_server_kx == NULL)
+  if (session->internals.auth_struct->MHD_gtls_gen_server_kx == NULL)
     return 0;
 
   data = NULL;
@@ -197,30 +197,30 @@ mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again)
   if (again == 0)
     {
       data_size =
-        session->internals.auth_struct->mhd_gtls_gen_server_kx (session,
+        session->internals.auth_struct->MHD_gtls_gen_server_kx (session,
                                                                 &data);
 
       if (data_size == GNUTLS_E_INT_RET_0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return 0;
         }
 
       if (data_size < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return data_size;
         }
     }
 
   ret =
-    mhd_gtls_send_handshake (session, data, data_size,
+    MHD_gtls_send_handshake (session, data, data_size,
                              GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE);
-  gnutls_free (data);
+  MHD_gnutls_free (data);
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
   return data_size;
@@ -230,7 +230,7 @@ mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again)
  * client.
  */
 int
-mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
+MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session,
                                           int again)
 {
   uint8_t *data = NULL;
@@ -238,7 +238,7 @@ mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
   int ret = 0;
 
   if (session->internals.auth_struct->
-      mhd_gtls_gen_server_certificate_request == NULL)
+      MHD_gtls_gen_server_certificate_request == NULL)
     return 0;
 
   if (session->internals.send_cert_req <= 0)
@@ -251,22 +251,22 @@ mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
     {
       data_size =
         session->internals.auth_struct->
-        mhd_gtls_gen_server_certificate_request (session, &data);
+        MHD_gtls_gen_server_certificate_request (session, &data);
 
       if (data_size < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return data_size;
         }
     }
   ret =
-    mhd_gtls_send_handshake (session, data, data_size,
+    MHD_gtls_send_handshake (session, data, data_size,
                              GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST);
-  gnutls_free (data);
+  MHD_gnutls_free (data);
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
   return data_size;
@@ -277,13 +277,13 @@ mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
  * exchange message
  */
 int
-mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again)
+MHD_gtls_send_client_kx_message (MHD_gtls_session_t session, int again)
 {
   uint8_t *data;
   int data_size;
   int ret = 0;
 
-  if (session->internals.auth_struct->mhd_gtls_gen_client_kx == NULL)
+  if (session->internals.auth_struct->MHD_gtls_gen_client_kx == NULL)
     return 0;
 
 
@@ -293,22 +293,22 @@ mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again)
   if (again == 0)
     {
       data_size =
-        session->internals.auth_struct->mhd_gtls_gen_client_kx (session,
+        session->internals.auth_struct->MHD_gtls_gen_client_kx (session,
                                                                 &data);
       if (data_size < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return data_size;
         }
     }
   ret =
-    mhd_gtls_send_handshake (session, data, data_size,
+    MHD_gtls_send_handshake (session, data, data_size,
                              GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE);
-  gnutls_free (data);
+  MHD_gnutls_free (data);
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
@@ -320,7 +320,7 @@ mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again)
  * verify message
  */
 int
-mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
+MHD_gtls_send_client_certificate_verify (MHD_gtls_session_t session,
                                          int again)
 {
   uint8_t *data;
@@ -337,9 +337,9 @@ mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
   if (session->key->certificate_requested == 0)
     return 0;
 
-  if (session->internals.auth_struct->mhd_gtls_gen_client_cert_vrfy == NULL)
+  if (session->internals.auth_struct->MHD_gtls_gen_client_cert_vrfy == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return 0;                 /* this algorithm does not support cli_cert_vrfy
                                  */
     }
@@ -351,10 +351,10 @@ mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
     {
       data_size =
         session->internals.auth_struct->
-        mhd_gtls_gen_client_cert_vrfy (session, &data);
+        MHD_gtls_gen_client_cert_vrfy (session, &data);
       if (data_size < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return data_size;
         }
       if (data_size == 0)
@@ -362,53 +362,53 @@ mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
 
     }
   ret =
-    mhd_gtls_send_handshake (session, data,
+    MHD_gtls_send_handshake (session, data,
                              data_size, GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY);
-  gnutls_free (data);
+  MHD_gnutls_free (data);
 
   return ret;
 }
 
 
 int
-mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session)
+MHD_gtls_recv_server_kx_message (MHD_gtls_session_t session)
 {
   uint8_t *data = NULL;
   int datasize;
   int ret = 0;
 
-  if (session->internals.auth_struct->mhd_gtls_process_server_kx != NULL)
+  if (session->internals.auth_struct->MHD_gtls_process_server_kx != NULL)
     {
 
       /* EXCEPTION FOR RSA_EXPORT cipher suite
        */
-      if (mhd_gtls_session_is_export (session) != 0 &&
-          _gnutls_peers_cert_less_512 (session) != 0)
+      if (MHD_gtls_session_is_export (session) != 0 &&
+          MHD__gnutls_peers_cert_less_512 (session) != 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return 0;
         }
 
       ret =
-        mhd_gtls_recv_handshake (session, &data,
+        MHD_gtls_recv_handshake (session, &data,
                                  &datasize,
                                  GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE,
                                  MANDATORY_PACKET);
       if (ret < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
 
       ret =
-        session->internals.auth_struct->mhd_gtls_process_server_kx (session,
+        session->internals.auth_struct->MHD_gtls_process_server_kx (session,
                                                                     data,
                                                                     datasize);
-      gnutls_free (data);
+      MHD_gnutls_free (data);
 
       if (ret < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
 
@@ -417,18 +417,18 @@ mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session)
 }
 
 int
-mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session)
+MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session)
 {
   uint8_t *data;
   int datasize;
   int ret = 0;
 
   if (session->internals.auth_struct->
-      mhd_gtls_process_server_certificate_request != NULL)
+      MHD_gtls_process_server_certificate_request != NULL)
     {
 
       ret =
-        mhd_gtls_recv_handshake (session, &data,
+        MHD_gtls_recv_handshake (session, &data,
                                  &datasize,
                                  GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST,
                                  OPTIONAL_PACKET);
@@ -440,8 +440,8 @@ mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session)
 
       ret =
         session->internals.auth_struct->
-        mhd_gtls_process_server_certificate_request (session, data, datasize);
-      gnutls_free (data);
+        MHD_gtls_process_server_certificate_request (session, data, datasize);
+      MHD_gnutls_free (data);
       if (ret < 0)
         return ret;
 
@@ -450,7 +450,7 @@ mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session)
 }
 
 int
-mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
+MHD_gtls_recv_client_kx_message (MHD_gtls_session_t session)
 {
   uint8_t *data;
   int datasize;
@@ -458,11 +458,11 @@ mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
 
 
   /* Do key exchange only if the algorithm permits it */
-  if (session->internals.auth_struct->mhd_gtls_process_client_kx != NULL)
+  if (session->internals.auth_struct->MHD_gtls_process_client_kx != NULL)
     {
 
       ret =
-        mhd_gtls_recv_handshake (session, &data,
+        MHD_gtls_recv_handshake (session, &data,
                                  &datasize,
                                  GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE,
                                  MANDATORY_PACKET);
@@ -470,10 +470,10 @@ mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
         return ret;
 
       ret =
-        session->internals.auth_struct->mhd_gtls_process_client_kx (session,
+        session->internals.auth_struct->MHD_gtls_process_client_kx (session,
                                                                     data,
                                                                     datasize);
-      gnutls_free (data);
+      MHD_gnutls_free (data);
       if (ret < 0)
         return ret;
 
@@ -486,7 +486,7 @@ mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session)
 /* This is called when we want send our certificate
  */
 int
-mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
+MHD_gtls_send_client_certificate (MHD_gtls_session_t session, int again)
 {
   uint8_t *data = NULL;
   int data_size = 0;
@@ -496,7 +496,7 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
   if (session->key->certificate_requested == 0)
     return 0;
 
-  if (session->internals.auth_struct->mhd_gtls_gen_client_certificate == NULL)
+  if (session->internals.auth_struct->MHD_gtls_gen_client_certificate == NULL)
     return 0;
 
   data = NULL;
@@ -504,18 +504,18 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
 
   if (again == 0)
     {
-      if (MHD_gnutls_protocol_get_version (session) != MHD_GNUTLS_PROTOCOL_SSL3 ||
+      if (MHD__gnutls_protocol_get_version (session) != MHD_GNUTLS_PROTOCOL_SSL3 ||
           session->internals.selected_cert_list_length > 0)
         {
           /* TLS 1.0 or SSL 3.0 with a valid certificate
            */
           data_size =
             session->internals.auth_struct->
-            mhd_gtls_gen_client_certificate (session, &data);
+            MHD_gtls_gen_client_certificate (session, &data);
 
           if (data_size < 0)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return data_size;
             }
         }
@@ -525,11 +525,11 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
    * no certificate alert instead of an
    * empty certificate.
    */
-  if (MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 &&
+  if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 &&
       session->internals.selected_cert_list_length == 0)
     {
       ret =
-        MHD_gnutls_alert_send (session, GNUTLS_AL_WARNING,
+        MHD__gnutls_alert_send (session, GNUTLS_AL_WARNING,
                                GNUTLS_A_SSL3_NO_CERTIFICATE);
 
     }
@@ -537,14 +537,14 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
     {                           /* TLS 1.0 or SSL 3.0 with a valid certificate
                                  */
       ret =
-        mhd_gtls_send_handshake (session, data, data_size,
+        MHD_gtls_send_handshake (session, data, data_size,
                                  GNUTLS_HANDSHAKE_CERTIFICATE_PKT);
-      gnutls_free (data);
+      MHD_gnutls_free (data);
     }
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
@@ -555,14 +555,14 @@ mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again)
 /* This is called when we want send our certificate
  */
 int
-mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again)
+MHD_gtls_send_server_certificate (MHD_gtls_session_t session, int again)
 {
   uint8_t *data = NULL;
   int data_size = 0;
   int ret = 0;
 
 
-  if (session->internals.auth_struct->mhd_gtls_gen_server_certificate == NULL)
+  if (session->internals.auth_struct->MHD_gtls_gen_server_certificate == NULL)
     return 0;
 
   data = NULL;
@@ -572,22 +572,22 @@ mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again)
     {
       data_size =
         session->internals.auth_struct->
-        mhd_gtls_gen_server_certificate (session, &data);
+        MHD_gtls_gen_server_certificate (session, &data);
 
       if (data_size < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return data_size;
         }
     }
   ret =
-    mhd_gtls_send_handshake (session, data, data_size,
+    MHD_gtls_send_handshake (session, data, data_size,
                              GNUTLS_HANDSHAKE_CERTIFICATE_PKT);
-  gnutls_free (data);
+  MHD_gnutls_free (data);
 
   if (ret < 0)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return ret;
     }
 
@@ -596,14 +596,14 @@ mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again)
 
 
 int
-mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
+MHD_gtls_recv_client_certificate (MHD_gtls_session_t session)
 {
   int datasize;
   opaque *data;
   int ret = 0;
   int optional;
 
-  if (session->internals.auth_struct->mhd_gtls_process_client_certificate !=
+  if (session->internals.auth_struct->MHD_gtls_process_client_certificate !=
       NULL)
     {
 
@@ -620,7 +620,7 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
         optional = OPTIONAL_PACKET;
 
       ret =
-        mhd_gtls_recv_handshake (session, &data,
+        MHD_gtls_recv_handshake (session, &data,
                                  &datasize,
                                  GNUTLS_HANDSHAKE_CERTIFICATE_PKT, optional);
 
@@ -632,14 +632,14 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
            */
           if (optional == OPTIONAL_PACKET &&
               ret == GNUTLS_E_WARNING_ALERT_RECEIVED &&
-              MHD_gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 &&
-              gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE)
+              MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 &&
+              MHD_gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE)
             {
 
               /* SSL3 does not send an empty certificate,
                * but this alert. So we just ignore it.
                */
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return 0;
             }
 
@@ -649,7 +649,7 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
                || ret == GNUTLS_E_FATAL_ALERT_RECEIVED)
               && optional == MANDATORY_PACKET)
             {
-              gnutls_assert ();
+              MHD_gnutls_assert ();
               return GNUTLS_E_NO_CERTIFICATE_FOUND;
             }
 
@@ -662,17 +662,17 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
            * well I'm not sure we should accept this
            * behaviour.
            */
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return 0;
         }
       ret =
         session->internals.auth_struct->
-        mhd_gtls_process_client_certificate (session, data, datasize);
+        MHD_gtls_process_client_certificate (session, data, datasize);
 
-      gnutls_free (data);
+      MHD_gnutls_free (data);
       if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
 
@@ -689,34 +689,34 @@ mhd_gtls_recv_client_certificate (mhd_gtls_session_t session)
 }
 
 int
-mhd_gtls_recv_server_certificate (mhd_gtls_session_t session)
+MHD_gtls_recv_server_certificate (MHD_gtls_session_t session)
 {
   int datasize;
   opaque *data;
   int ret = 0;
 
-  if (session->internals.auth_struct->mhd_gtls_process_server_certificate !=
+  if (session->internals.auth_struct->MHD_gtls_process_server_certificate !=
       NULL)
     {
 
       ret =
-        mhd_gtls_recv_handshake (session, &data,
+        MHD_gtls_recv_handshake (session, &data,
                                  &datasize,
                                  GNUTLS_HANDSHAKE_CERTIFICATE_PKT,
                                  MANDATORY_PACKET);
       if (ret < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
 
       ret =
         session->internals.auth_struct->
-        mhd_gtls_process_server_certificate (session, data, datasize);
-      gnutls_free (data);
+        MHD_gtls_process_server_certificate (session, data, datasize);
+      MHD_gnutls_free (data);
       if (ret < 0)
         {
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return ret;
         }
     }
@@ -729,14 +729,14 @@ mhd_gtls_recv_server_certificate (mhd_gtls_session_t session)
  * arrive if the peer did not send us a certificate.
  */
 int
-mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session)
+MHD_gtls_recv_client_certificate_verify_message (MHD_gtls_session_t session)
 {
   uint8_t *data;
   int datasize;
   int ret = 0;
 
 
-  if (session->internals.auth_struct->mhd_gtls_process_client_cert_vrfy !=
+  if (session->internals.auth_struct->MHD_gtls_process_client_cert_vrfy !=
       NULL)
     {
 
@@ -747,7 +747,7 @@ mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session)
         }
 
       ret =
-        mhd_gtls_recv_handshake (session, &data,
+        MHD_gtls_recv_handshake (session, &data,
                                  &datasize,
                                  GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY,
                                  OPTIONAL_PACKET);
@@ -758,14 +758,14 @@ mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t session)
           && session->internals.send_cert_req == GNUTLS_CERT_REQUIRE)
         {
           /* certificate was required */
-          gnutls_assert ();
+          MHD_gnutls_assert ();
           return GNUTLS_E_NO_CERTIFICATE_FOUND;
         }
 
       ret =
         session->internals.auth_struct->
-        mhd_gtls_process_client_cert_vrfy (session, data, datasize);
-      gnutls_free (data);
+        MHD_gtls_process_client_cert_vrfy (session, data, datasize);
+      MHD_gnutls_free (data);
       if (ret < 0)
         return ret;
 

+ 13 - 13
src/daemon/https/tls/gnutls_kx.h

@@ -22,19 +22,19 @@
  *
  */
 
-int mhd_gtls_send_server_kx_message (mhd_gtls_session_t session, int again);
-int mhd_gtls_send_client_kx_message (mhd_gtls_session_t session, int again);
-int mhd_gtls_recv_server_kx_message (mhd_gtls_session_t session);
-int mhd_gtls_recv_client_kx_message (mhd_gtls_session_t session);
-int mhd_gtls_send_client_certificate_verify (mhd_gtls_session_t session,
+int MHD_gtls_send_server_kx_message (MHD_gtls_session_t session, int again);
+int MHD_gtls_send_client_kx_message (MHD_gtls_session_t session, int again);
+int MHD_gtls_recv_server_kx_message (MHD_gtls_session_t session);
+int MHD_gtls_recv_client_kx_message (MHD_gtls_session_t session);
+int MHD_gtls_send_client_certificate_verify (MHD_gtls_session_t session,
                                              int again);
-int mhd_gtls_send_server_certificate (mhd_gtls_session_t session, int again);
-int mhd_gtls_generate_master (mhd_gtls_session_t session, int keep_premaster);
-int mhd_gtls_recv_client_certificate (mhd_gtls_session_t session);
-int mhd_gtls_recv_server_certificate (mhd_gtls_session_t session);
-int mhd_gtls_send_client_certificate (mhd_gtls_session_t session, int again);
-int mhd_gtls_recv_server_certificate_request (mhd_gtls_session_t session);
-int mhd_gtls_send_server_certificate_request (mhd_gtls_session_t session,
+int MHD_gtls_send_server_certificate (MHD_gtls_session_t session, int again);
+int MHD_gtls_generate_master (MHD_gtls_session_t session, int keep_premaster);
+int MHD_gtls_recv_client_certificate (MHD_gtls_session_t session);
+int MHD_gtls_recv_server_certificate (MHD_gtls_session_t session);
+int MHD_gtls_send_client_certificate (MHD_gtls_session_t session, int again);
+int MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session);
+int MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session,
                                               int again);
-int mhd_gtls_recv_client_certificate_verify_message (mhd_gtls_session_t
+int MHD_gtls_recv_client_certificate_verify_message (MHD_gtls_session_t
                                                      session);

+ 21 - 21
src/daemon/https/tls/gnutls_mem.c

@@ -26,40 +26,40 @@
 #include <gnutls_errors.h>
 #include <gnutls_num.h>
 
-gnutls_alloc_function gnutls_secure_malloc = malloc;
-gnutls_alloc_function gnutls_malloc = malloc;
-gnutls_free_function gnutls_free = free;
-gnutls_realloc_function gnutls_realloc = realloc;
+MHD_gnutls_alloc_function MHD_gnutls_secure_malloc = malloc;
+MHD_gnutls_alloc_function MHD_gnutls_malloc = malloc;
+MHD_gnutls_free_function MHD_gnutls_free = free;
+MHD_gnutls_realloc_function MHD_gnutls_realloc = realloc;
 
-void *(*gnutls_calloc) (size_t, size_t) = calloc;
-char *(*gnutls_strdup) (const char *) = mhd_gtls_strdup;
+void *(*MHD_gnutls_calloc) (size_t, size_t) = calloc;
+char *(*MHD_gnutls_strdup) (const char *) = MHD_gtls_strdup;
 
 int
-_gnutls_is_secure_mem_null (const void *ign)
+MHD__gnutls_is_secure_mem_null (const void *ign)
 {
   return 0;
 }
 
-int (*_gnutls_is_secure_memory) (const void *) = _gnutls_is_secure_mem_null;
+int (*MHD__gnutls_is_secure_memory) (const void *) = MHD__gnutls_is_secure_mem_null;
 
 
 void *
-mhd_gtls_calloc (size_t nmemb, size_t size)
+MHD_gtls_calloc (size_t nmemb, size_t size)
 {
   void *ret;
   size *= nmemb;
-  ret = gnutls_malloc (size);
+  ret = MHD_gnutls_malloc (size);
   if (ret != NULL)
     memset (ret, 0, size);
   return ret;
 }
 
 svoid *
-mhd_gtls_secure_calloc (size_t nmemb, size_t size)
+MHD_gtls_secure_calloc (size_t nmemb, size_t size)
 {
   svoid *ret;
   size *= nmemb;
-  ret = gnutls_secure_malloc (size);
+  ret = MHD_gnutls_secure_malloc (size);
   if (ret != NULL)
     memset (ret, 0, size);
   return ret;
@@ -69,29 +69,29 @@ mhd_gtls_secure_calloc (size_t nmemb, size_t size)
  * fails.
  */
 void *
-mhd_gtls_realloc_fast (void *ptr, size_t size)
+MHD_gtls_realloc_fast (void *ptr, size_t size)
 {
   void *ret;
 
   if (size == 0)
     return ptr;
 
-  ret = gnutls_realloc (ptr, size);
+  ret = MHD_gnutls_realloc (ptr, size);
   if (ret == NULL)
     {
-      gnutls_free (ptr);
+      MHD_gnutls_free (ptr);
     }
 
   return ret;
 }
 
 char *
-mhd_gtls_strdup (const char *str)
+MHD_gtls_strdup (const char *str)
 {
   size_t siz = strlen (str) + 1;
   char *ret;
 
-  ret = gnutls_malloc (siz);
+  ret = MHD_gnutls_malloc (siz);
   if (ret != NULL)
     memcpy (ret, str, siz);
   return ret;
@@ -103,7 +103,7 @@ mhd_gtls_strdup (const char *str)
  */
 
 /**
-  * gnutls_malloc - Allocates and returns data
+  * MHD_gnutls_malloc - Allocates and returns data
   *
   * This function will allocate 's' bytes data, and
   * return a pointer to memory. This function is supposed
@@ -113,12 +113,12 @@ mhd_gtls_strdup (const char *str)
   *
   **/
 void *
-gnutls_malloc (size_t s)
+MHD_gnutls_malloc (size_t s)
 {
 }
 
 /**
-  * gnutls_free - Returns a free() like function
+  * MHD_gnutls_free - Returns a free() like function
   * @d: pointer to memory
   *
   * This function will free data pointed by ptr.
@@ -127,7 +127,7 @@ gnutls_malloc (size_t s)
   *
   **/
 void
-gnutls_free (void *ptr)
+MHD_gnutls_free (void *ptr)
 {
 }
 

+ 15 - 15
src/daemon/https/tls/gnutls_mem.h

@@ -29,42 +29,42 @@
 # include <dmalloc.h>
 #endif
 
-typedef void svoid;             /* for functions that allocate using gnutls_secure_malloc */
+typedef void svoid;             /* for functions that allocate using MHD_gnutls_secure_malloc */
 
-/* Use gnutls_afree() when calling alloca, or
+/* Use MHD_gnutls_afree() when calling alloca, or
  * memory leaks may occur in systems which do not
  * support alloca.
  */
 #ifdef USE_EFENCE
-# define gnutls_alloca gnutls_malloc
-# define gnutls_afree gnutls_free
+# define MHD_gnutls_alloca MHD_gnutls_malloc
+# define MHD_gnutls_afree MHD_gnutls_free
 #endif
 
 #ifdef HAVE_ALLOCA
 # ifdef HAVE_ALLOCA_H
 #  include <alloca.h>
 # endif
-# ifndef gnutls_alloca
-#  define gnutls_alloca alloca
-#  define gnutls_afree(x)
+# ifndef MHD_gnutls_alloca
+#  define MHD_gnutls_alloca alloca
+#  define MHD_gnutls_afree(x)
 # endif
 #else
-# ifndef gnutls_alloca
-#  define gnutls_alloca gnutls_malloc
-#  define gnutls_afree gnutls_free
+# ifndef MHD_gnutls_alloca
+#  define MHD_gnutls_alloca MHD_gnutls_malloc
+#  define MHD_gnutls_afree MHD_gnutls_free
 # endif
 #endif /* HAVE_ALLOCA */
 
-extern int (*_gnutls_is_secure_memory) (const void *);
+extern int (*MHD__gnutls_is_secure_memory) (const void *);
 
 /* this realloc function will return ptr if size==0, and
  * will free the ptr if the new allocation failed.
  */
-void *mhd_gtls_realloc_fast (void *ptr, size_t size);
+void *MHD_gtls_realloc_fast (void *ptr, size_t size);
 
-svoid *mhd_gtls_secure_calloc (size_t nmemb, size_t size);
+svoid *MHD_gtls_secure_calloc (size_t nmemb, size_t size);
 
-void *mhd_gtls_calloc (size_t nmemb, size_t size);
-char *mhd_gtls_strdup (const char *);
+void *MHD_gtls_calloc (size_t nmemb, size_t size);
+char *MHD_gtls_strdup (const char *);
 
 #endif /* GNUTLS_MEM_H */

+ 43 - 43
src/daemon/https/tls/gnutls_mpi.c

@@ -35,7 +35,7 @@
  */
 
 void
-mhd_gtls_mpi_release (mpi_t * x)
+MHD_gtls_mpi_release (mpi_t * x)
 {
   if (*x == NULL)
     return;
@@ -46,7 +46,7 @@ mhd_gtls_mpi_release (mpi_t * x)
 /* returns zero on success
  */
 int
-mhd_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
+MHD_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
 {
   int ret;
 
@@ -60,7 +60,7 @@ mhd_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
 /* returns zero on success. Fails if the number is zero.
  */
 int
-mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
+MHD_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
 {
   int ret;
 
@@ -70,9 +70,9 @@ mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
 
   /* MPIs with 0 bits are illegal
    */
-  if (_gnutls_mpi_get_nbits (*ret_mpi) == 0)
+  if (MHD__gnutls_mpi_get_nbits (*ret_mpi) == 0)
     {
-      mhd_gtls_mpi_release (ret_mpi);
+      MHD_gtls_mpi_release (ret_mpi);
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
 
@@ -80,7 +80,7 @@ mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer, size_t * nbytes)
 }
 
 int
-mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
+MHD_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
                        size_t * nbytes)
 {
   int ret;
@@ -90,9 +90,9 @@ mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
 
   /* MPIs with 0 bits are illegal
    */
-  if (_gnutls_mpi_get_nbits (*ret_mpi) == 0)
+  if (MHD__gnutls_mpi_get_nbits (*ret_mpi) == 0)
     {
-      mhd_gtls_mpi_release (ret_mpi);
+      MHD_gtls_mpi_release (ret_mpi);
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
 
@@ -100,7 +100,7 @@ mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
 }
 
 int
-mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
+MHD_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
 {
   int ret;
 
@@ -116,7 +116,7 @@ mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a)
 
 /* Always has the first bit zero */
 int
-mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
+MHD_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
 {
   int ret;
 
@@ -132,7 +132,7 @@ mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a)
 
 /* Always has the first bit zero */
 int
-mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
+MHD_gtls_mpi_dprint_lz (MHD_gnutls_datum_t * dest, const mpi_t a)
 {
   int ret;
   opaque *buf = NULL;
@@ -144,7 +144,7 @@ mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
   gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &bytes, a);
 
   if (bytes != 0)
-    buf = gnutls_malloc (bytes);
+    buf = MHD_gnutls_malloc (bytes);
   if (buf == NULL)
     return GNUTLS_E_MEMORY_ERROR;
 
@@ -156,12 +156,12 @@ mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a)
       return 0;
     }
 
-  gnutls_free (buf);
+  MHD_gnutls_free (buf);
   return GNUTLS_E_MPI_PRINT_FAILED;
 }
 
 int
-mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
+MHD_gtls_mpi_dprint (MHD_gnutls_datum_t * dest, const mpi_t a)
 {
   int ret;
   opaque *buf = NULL;
@@ -173,7 +173,7 @@ mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
   gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, &bytes, a);
 
   if (bytes != 0)
-    buf = gnutls_malloc (bytes);
+    buf = MHD_gnutls_malloc (bytes);
   if (buf == NULL)
     return GNUTLS_E_MEMORY_ERROR;
 
@@ -185,7 +185,7 @@ mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
       return 0;
     }
 
-  gnutls_free (buf);
+  MHD_gnutls_free (buf);
   return GNUTLS_E_MPI_PRINT_FAILED;
 }
 
@@ -195,7 +195,7 @@ mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a)
  * steps.
  */
 int
-_gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
+MHD__gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
 {
   int result;
   size_t s_len;
@@ -203,37 +203,37 @@ _gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
   int tmpstr_size;
 
   tmpstr_size = 0;
-  result = asn1_read_value (node, value, NULL, &tmpstr_size);
+  result = MHD__asn1_read_value (node, value, NULL, &tmpstr_size);
   if (result != ASN1_MEM_ERROR)
     {
-      gnutls_assert ();
-      return mhd_gtls_asn2err (result);
+      MHD_gnutls_assert ();
+      return MHD_gtls_asn2err (result);
     }
 
-  tmpstr = gnutls_alloca (tmpstr_size);
+  tmpstr = MHD_gnutls_alloca (tmpstr_size);
   if (tmpstr == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
-  result = asn1_read_value (node, value, tmpstr, &tmpstr_size);
+  result = MHD__asn1_read_value (node, value, tmpstr, &tmpstr_size);
   if (result != ASN1_SUCCESS)
     {
-      gnutls_assert ();
-      gnutls_afree (tmpstr);
-      return mhd_gtls_asn2err (result);
+      MHD_gnutls_assert ();
+      MHD_gnutls_afree (tmpstr);
+      return MHD_gtls_asn2err (result);
     }
 
   s_len = tmpstr_size;
-  if (mhd_gtls_mpi_scan (ret_mpi, tmpstr, &s_len) != 0)
+  if (MHD_gtls_mpi_scan (ret_mpi, tmpstr, &s_len) != 0)
     {
-      gnutls_assert ();
-      gnutls_afree (tmpstr);
+      MHD_gnutls_assert ();
+      MHD_gnutls_afree (tmpstr);
       return GNUTLS_E_MPI_SCAN_FAILED;
     }
 
-  gnutls_afree (tmpstr);
+  MHD_gnutls_afree (tmpstr);
 
   return 0;
 }
@@ -241,7 +241,7 @@ _gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi)
 /* Writes the specified integer into the specified node.
  */
 int
-_gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
+MHD__gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
 {
   opaque *tmpstr;
   size_t s_len;
@@ -249,37 +249,37 @@ _gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz)
 
   s_len = 0;
   if (lz)
-    result = mhd_gtls_mpi_print_lz (NULL, &s_len, mpi);
+    result = MHD_gtls_mpi_print_lz (NULL, &s_len, mpi);
   else
-    result = mhd_gtls_mpi_print (NULL, &s_len, mpi);
+    result = MHD_gtls_mpi_print (NULL, &s_len, mpi);
 
-  tmpstr = gnutls_alloca (s_len);
+  tmpstr = MHD_gnutls_alloca (s_len);
   if (tmpstr == NULL)
     {
-      gnutls_assert ();
+      MHD_gnutls_assert ();
       return GNUTLS_E_MEMORY_ERROR;
     }
 
   if (lz)
-    result = mhd_gtls_mpi_print_lz (tmpstr, &s_len, mpi);
+    result = MHD_gtls_mpi_print_lz (tmpstr, &s_len, mpi);
   else
-    result = mhd_gtls_mpi_print (tmpstr, &s_len, mpi);
+    result = MHD_gtls_mpi_print (tmpstr, &s_len, mpi);
 
   if (result != 0)
     {
-      gnutls_assert ();
-      gnutls_afree (tmpstr);
+      MHD_gnutls_assert ();
+      MHD_gnutls_afree (tmpstr);
       return GNUTLS_E_MPI_PRINT_FAILED;
     }
 
-  result = asn1_write_value (node, value, tmpstr, s_len);
+  result = MHD__asn1_write_value (node, value, tmpstr, s_len);
 
-  gnutls_afree (tmpstr);
+  MHD_gnutls_afree (tmpstr);
 
   if (result != ASN1_SUCCESS)
     {
-      gnutls_assert ();
-      return mhd_gtls_asn2err (result);
+      MHD_gnutls_assert ();
+      return MHD_gtls_asn2err (result);
     }
 
   return 0;

+ 33 - 33
src/daemon/https/tls/gnutls_mpi.h

@@ -33,46 +33,46 @@
 
 typedef gcry_mpi_t mpi_t;
 
-#define _gnutls_mpi_cmp gcry_mpi_cmp
-#define _gnutls_mpi_cmp_ui gcry_mpi_cmp_ui
-#define _gnutls_mpi_mod gcry_mpi_mod
-#define _gnutls_mpi_new gcry_mpi_new
-#define _gnutls_mpi_snew gcry_mpi_snew
-#define _gnutls_mpi_copy gcry_mpi_copy
-#define _gnutls_mpi_set_ui gcry_mpi_set_ui
-#define _gnutls_mpi_set gcry_mpi_set
-#define _gnutls_mpi_randomize gcry_mpi_randomize
-#define _gnutls_mpi_get_nbits gcry_mpi_get_nbits
-#define _gnutls_mpi_powm gcry_mpi_powm
-#define _gnutls_mpi_invm gcry_mpi_invm
-#define _gnutls_mpi_addm gcry_mpi_addm
-#define _gnutls_mpi_subm gcry_mpi_subm
-#define _gnutls_mpi_sub_ui gcry_mpi_sub_ui
-#define _gnutls_mpi_mulm gcry_mpi_mulm
-#define _gnutls_mpi_mul gcry_mpi_mul
-#define _gnutls_mpi_add gcry_mpi_add
-#define _gnutls_mpi_add_ui gcry_mpi_add_ui
-#define _gnutls_mpi_sub_ui gcry_mpi_sub_ui
-#define _gnutls_mpi_mul_ui gcry_mpi_mul_ui
-#define _gnutls_prime_check gcry_prime_check
-#define _gnutls_mpi_div gcry_mpi_div
+#define MHD__gnutls_mpi_cmp gcry_mpi_cmp
+#define MHD__gnutls_mpi_cmp_ui gcry_mpi_cmp_ui
+#define MHD__gnutls_mpi_mod gcry_mpi_mod
+#define MHD__gnutls_mpi_new gcry_mpi_new
+#define MHD__gnutls_mpi_snew gcry_mpi_snew
+#define MHD__gnutls_mpi_copy gcry_mpi_copy
+#define MHD__gnutls_mpi_set_ui gcry_mpi_set_ui
+#define MHD__gnutls_mpi_set gcry_mpi_set
+#define MHD__gnutls_mpi_randomize gcry_mpi_randomize
+#define MHD__gnutls_mpi_get_nbits gcry_mpi_get_nbits
+#define MHD__gnutls_mpi_powm gcry_mpi_powm
+#define MHD__gnutls_mpi_invm gcry_mpi_invm
+#define MHD__gnutls_mpi_addm gcry_mpi_addm
+#define MHD__gnutls_mpi_subm gcry_mpi_subm
+#define MHD__gnutls_mpi_sub_ui gcry_mpi_sub_ui
+#define MHD__gnutls_mpi_mulm gcry_mpi_mulm
+#define MHD__gnutls_mpi_mul gcry_mpi_mul
+#define MHD__gnutls_mpi_add gcry_mpi_add
+#define MHD__gnutls_mpi_add_ui gcry_mpi_add_ui
+#define MHD__gnutls_mpi_sub_ui gcry_mpi_sub_ui
+#define MHD__gnutls_mpi_mul_ui gcry_mpi_mul_ui
+#define MHD__gnutls_prime_check gcry_prime_check
+#define MHD__gnutls_mpi_div gcry_mpi_div
 
-#define _gnutls_mpi_alloc_like(x) _gnutls_mpi_new(_gnutls_mpi_get_nbits(x))
-#define _gnutls_mpi_salloc_like(x) _gnutls_mpi_snew(_gnutls_mpi_get_nbits(x))
+#define MHD__gnutls_mpi_alloc_like(x) MHD__gnutls_mpi_new(MHD__gnutls_mpi_get_nbits(x))
+#define MHD__gnutls_mpi_salloc_like(x) MHD__gnutls_mpi_snew(MHD__gnutls_mpi_get_nbits(x))
 
-void mhd_gtls_mpi_release (mpi_t * x);
+void MHD_gtls_mpi_release (mpi_t * x);
 
-int mhd_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer,
+int MHD_gtls_mpi_scan_nz (mpi_t * ret_mpi, const opaque * buffer,
                           size_t * nbytes);
-int mhd_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer,
+int MHD_gtls_mpi_scan (mpi_t * ret_mpi, const opaque * buffer,
                        size_t * nbytes);
-int mhd_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
+int MHD_gtls_mpi_scan_pgp (mpi_t * ret_mpi, const opaque * buffer,
                            size_t * nbytes);
 
-int mhd_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a);
-int mhd_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a);
+int MHD_gtls_mpi_print (void *buffer, size_t * nbytes, const mpi_t a);
+int MHD_gtls_mpi_print_lz (void *buffer, size_t * nbytes, const mpi_t a);
 
-int mhd_gtls_mpi_dprint_lz (gnutls_datum_t * dest, const mpi_t a);
-int mhd_gtls_mpi_dprint (gnutls_datum_t * dest, const mpi_t a);
+int MHD_gtls_mpi_dprint_lz (MHD_gnutls_datum_t * dest, const mpi_t a);
+int MHD_gtls_mpi_dprint (MHD_gnutls_datum_t * dest, const mpi_t a);
 
 #endif

+ 14 - 14
src/daemon/https/tls/gnutls_num.c

@@ -35,7 +35,7 @@
  * has been reached.
  */
 int
-mhd_gtls_uint64pp (uint64 * x)
+MHD_gtls_uint64pp (uint64 * x)
 {
   register int i, y = 0;
 
@@ -60,7 +60,7 @@ mhd_gtls_uint64pp (uint64 * x)
 }
 
 uint32_t
-mhd_gtls_uint24touint32 (uint24 num)
+MHD_gtls_uint24touint32 (uint24 num)
 {
   uint32_t ret = 0;
 
@@ -71,7 +71,7 @@ mhd_gtls_uint24touint32 (uint24 num)
 }
 
 uint24
-mhd_gtls_uint32touint24 (uint32_t num)
+MHD_gtls_uint32touint24 (uint32_t num)
 {
   uint24 ret;
 
@@ -84,7 +84,7 @@ mhd_gtls_uint32touint24 (uint32_t num)
 
 /* data should be at least 3 bytes */
 uint32_t
-mhd_gtls_read_uint24 (const opaque * data)
+MHD_gtls_read_uint24 (const opaque * data)
 {
   uint32_t res;
   uint24 num;
@@ -93,7 +93,7 @@ mhd_gtls_read_uint24 (const opaque * data)
   num.pint[1] = data[1];
   num.pint[2] = data[2];
 
-  res = mhd_gtls_uint24touint32 (num);
+  res = MHD_gtls_uint24touint32 (num);
 #ifndef WORDS_BIGENDIAN
   res = byteswap32 (res);
 #endif
@@ -101,14 +101,14 @@ mhd_gtls_read_uint24 (const opaque * data)
 }
 
 void
-mhd_gtls_write_uint24 (uint32_t num, opaque * data)
+MHD_gtls_write_uint24 (uint32_t num, opaque * data)
 {
   uint24 tmp;
 
 #ifndef WORDS_BIGENDIAN
   num = byteswap32 (num);
 #endif
-  tmp = mhd_gtls_uint32touint24 (num);
+  tmp = MHD_gtls_uint32touint24 (num);
 
   data[0] = tmp.pint[0];
   data[1] = tmp.pint[1];
@@ -116,7 +116,7 @@ mhd_gtls_write_uint24 (uint32_t num, opaque * data)
 }
 
 uint32_t
-mhd_gtls_read_uint32 (const opaque * data)
+MHD_gtls_read_uint32 (const opaque * data)
 {
   uint32_t res;
 
@@ -128,7 +128,7 @@ mhd_gtls_read_uint32 (const opaque * data)
 }
 
 void
-mhd_gtls_write_uint32 (uint32_t num, opaque * data)
+MHD_gtls_write_uint32 (uint32_t num, opaque * data)
 {
 
 #ifndef WORDS_BIGENDIAN
@@ -138,7 +138,7 @@ mhd_gtls_write_uint32 (uint32_t num, opaque * data)
 }
 
 uint16_t
-mhd_gtls_read_uint16 (const opaque * data)
+MHD_gtls_read_uint16 (const opaque * data)
 {
   uint16_t res;
   memcpy (&res, data, sizeof (uint16_t));
@@ -149,7 +149,7 @@ mhd_gtls_read_uint16 (const opaque * data)
 }
 
 void
-mhd_gtls_write_uint16 (uint16_t num, opaque * data)
+MHD_gtls_write_uint16 (uint16_t num, opaque * data)
 {
 
 #ifndef WORDS_BIGENDIAN
@@ -159,7 +159,7 @@ mhd_gtls_write_uint16 (uint16_t num, opaque * data)
 }
 
 uint32_t
-mhd_gtls_conv_uint32 (uint32_t data)
+MHD_gtls_conv_uint32 (uint32_t data)
 {
 #ifndef WORDS_BIGENDIAN
   return byteswap32 (data);
@@ -169,7 +169,7 @@ mhd_gtls_conv_uint32 (uint32_t data)
 }
 
 uint16_t
-mhd_gtls_conv_uint16 (uint16_t data)
+MHD_gtls_conv_uint16 (uint16_t data)
 {
 #ifndef WORDS_BIGENDIAN
   return byteswap16 (data);
@@ -179,7 +179,7 @@ mhd_gtls_conv_uint16 (uint16_t data)
 }
 
 uint32_t
-mhd_gtls_uint64touint32 (const uint64 * num)
+MHD_gtls_uint64touint32 (const uint64 * num)
 {
   uint32_t ret;
 

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików