libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 46622f6b02b8ac3138cd2ef57fc8b1a5e7d893fd
parent bb5fc0ba651bafc59a429853eb965518d436d82a
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 24 Aug 2008 17:53:48 +0000

renaming enums to have MHD_ prefix always, removing a few redundant values

Diffstat:
Msrc/daemon/connection.c | 7++-----
Msrc/daemon/connection_https.c | 43+++++++++++++++++++------------------------
Msrc/daemon/daemon.c | 98++++++++++++++++++++++++++++++++++++-------------------------------------------
Msrc/daemon/https/gnutls.h | 68++++++++++++++++++++++++++++++++++----------------------------------
Msrc/daemon/https/tls/auth_cert.c | 24++++++++++++------------
Msrc/daemon/https/tls/auth_cert.h | 2+-
Msrc/daemon/https/tls/auth_rsa.c | 2+-
Msrc/daemon/https/tls/gnutls_algorithms.c | 230++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/daemon/https/tls/gnutls_algorithms.h | 98++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/daemon/https/tls/gnutls_auth.c | 14+++++++-------
Msrc/daemon/https/tls/gnutls_auth_int.h | 6+++---
Msrc/daemon/https/tls/gnutls_cert.c | 20++++++++++----------
Msrc/daemon/https/tls/gnutls_cert.h | 12++++++------
Msrc/daemon/https/tls/gnutls_cipher.c | 6+++---
Msrc/daemon/https/tls/gnutls_cipher_int.c | 2+-
Msrc/daemon/https/tls/gnutls_cipher_int.h | 2+-
Msrc/daemon/https/tls/gnutls_compress_int.c | 2+-
Msrc/daemon/https/tls/gnutls_compress_int.h | 4++--
Msrc/daemon/https/tls/gnutls_constate.c | 22+++++++++++-----------
Msrc/daemon/https/tls/gnutls_constate.h | 14+++++++-------
Msrc/daemon/https/tls/gnutls_handshake.c | 36++++++++++++++++++------------------
Msrc/daemon/https/tls/gnutls_handshake.h | 6+++---
Msrc/daemon/https/tls/gnutls_hash_int.c | 12++++++------
Msrc/daemon/https/tls/gnutls_hash_int.h | 10+++++-----
Msrc/daemon/https/tls/gnutls_int.h | 36++++++++++++++++++------------------
Msrc/daemon/https/tls/gnutls_priority.c | 12++++++------
Msrc/daemon/https/tls/gnutls_record.c | 6+++---
Msrc/daemon/https/tls/gnutls_sig.c | 10+++++-----
Msrc/daemon/https/tls/gnutls_sig.h | 2+-
Msrc/daemon/https/tls/gnutls_state.c | 24++++++++++++------------
Msrc/daemon/https/tls/gnutls_state.h | 10+++++-----
Msrc/daemon/https/tls/gnutls_ui.c | 2+-
Msrc/daemon/https/tls/gnutls_x509.c | 4++--
Msrc/daemon/https/tls/gnutls_x509.h | 2+-
Msrc/daemon/https/x509/common.c | 2+-
Msrc/daemon/https/x509/common.h | 2+-
Msrc/daemon/https/x509/crl_write.c | 4++--
Msrc/daemon/https/x509/crq.c | 6+++---
Msrc/daemon/https/x509/mpi.c | 4++--
Msrc/daemon/https/x509/mpi.h | 4++--
Msrc/daemon/https/x509/privkey_pkcs8.c | 4++--
Msrc/daemon/https/x509/sign.c | 12++++++------
Msrc/daemon/https/x509/sign.h | 6+++---
Msrc/daemon/https/x509/x509.c | 6+++---
Msrc/daemon/https/x509/x509.h | 16++++++++--------
Msrc/daemon/https/x509/x509_privkey.c | 6+++---
Msrc/daemon/https/x509/x509_verify.c | 6+++---
Msrc/daemon/https/x509/x509_write.c | 4++--
Msrc/daemon/internal.h | 2+-
Msrc/include/microhttpd.h | 474++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
Msrc/testcurl/daemon_options_test.c | 3---
Msrc/testcurl/https/Makefile.am | 4++--
52 files changed, 751 insertions(+), 662 deletions(-)

diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -590,10 +590,7 @@ build_header_response (struct MHD_Connection *connection) while (pos != NULL) { if (pos->kind == kind) - { - SPRINTF (&data[off], "%s: %s\r\n", pos->header, pos->value); - off += strlen (pos->header) + strlen (pos->value) + 4; - } + off += SPRINTF (&data[off], "%s: %s\r\n", pos->header, pos->value); pos = pos->next; } if (connection->state == MHD_CONNECTION_FOOTERS_RECEIVED) @@ -601,7 +598,7 @@ build_header_response (struct MHD_Connection *connection) strcpy (&data[off], date); off += strlen (date); } - sprintf (&data[off], "\r\n"); + memcpy (&data[off], "\r\n", 2); off += 2; if (off != size) abort (); diff --git a/src/daemon/connection_https.c b/src/daemon/connection_https.c @@ -45,46 +45,41 @@ int MHD_connection_handle_write (struct MHD_Connection *connection); int MHD_connection_handle_idle (struct MHD_Connection *connection); /** - * retrieve session info + * Obtain information about the given connection. * - * @param connection: from which to retrieve data - * @return: an appropriate 'union MHD_SessionInfo' with the requested connection data or 'null_info' in an invalid request has been received. + * @param connection what connection to get information about + * @param infoType what information is desired? + * @param ... depends on infoType + * @return NULL if this information is not available + * (or if the infoType is unknown) */ -union MHD_SessionInfo -MHD_get_session_info ( struct MHD_Connection * connection, enum MHD_InfoType infoType) +const union MHD_ConnectionInfo * +MHD_get_connection_info (struct MHD_Connection * connection, + enum MHD_InfoType infoType, + ...) { - /* return NULL if this isn't a SSL/TLS type connection */ if (connection->tls_session == NULL) - { - /* TODO clean */ - return (union MHD_SessionInfo) 0; - } + return NULL; switch (infoType) { #if HTTPS_SUPPORT case MHS_INFO_CIPHER_ALGO: - return (union MHD_SessionInfo) connection->tls_session->security_parameters. - read_bulk_cipher_algorithm; + return &connection->tls_session->security_parameters.read_bulk_cipher_algorithm; case MHD_INFO_KX_ALGO: - return (union MHD_SessionInfo) connection->tls_session->security_parameters. - kx_algorithm; + return &connection->tls_session->security_parameters.kx_algorithm; case MHD_INFO_CREDENTIALS_TYPE: - return (union MHD_SessionInfo) connection->tls_session->key->cred->algorithm; + return &connection->tls_session->key->cred->algorithm; case MHD_INFO_MAC_ALGO: - return (union MHD_SessionInfo) connection->tls_session->security_parameters. - read_mac_algorithm; + return &connection->tls_session->security_parameters.read_mac_algorithm; case MHD_INFO_COMPRESSION_METHOD: - return (union MHD_SessionInfo) connection->tls_session->security_parameters. - read_compression_algorithm; + return &connection->tls_session->security_parameters.read_compression_algorithm; case MHD_INFO_PROTOCOL: - return (union MHD_SessionInfo) connection->tls_session->security_parameters. - version; + return &connection->tls_session->security_parameters.version; case MHD_INFO_CERT_TYPE: - return (union MHD_SessionInfo) connection->tls_session->security_parameters. - cert_type; + return &connection->tls_session->security_parameters.cert_type; #endif }; - return (union MHD_SessionInfo) 0; + return NULL; } /** diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -74,8 +74,6 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) #if HAVE_MESSAGES MHD_DLOG (daemon, "Missing X.509 certificate file\n"); #endif - free (daemon); - CLOSE (daemon->socket_fd); return -1; } @@ -84,8 +82,6 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) #if HAVE_MESSAGES MHD_DLOG (daemon, "Missing X.509 key file\n"); #endif - free (daemon); - CLOSE (daemon->socket_fd); return -1; } return MHD_gnutls_certificate_set_x509_key_file (daemon->x509_cred, @@ -132,9 +128,8 @@ MHD_TLS_init (struct MHD_Daemon *daemon) return 0; case MHD_GNUTLS_CRD_CERTIFICATE: ret = MHD_gnutls_certificate_allocate_credentials (&daemon->x509_cred) ; - if (ret != 0) { - return GNUTLS_E_MEMORY_ERROR; - } + if (ret != 0) + return GNUTLS_E_MEMORY_ERROR; return MHD_init_daemon_certificate (daemon); default: #if HAVE_MESSAGES @@ -780,6 +775,17 @@ MHD_select_thread (void *cls) return NULL; } +/** + * Start a webserver on the given port. + * + * @param port port to bind to + * @param apc callback to call to check which clients + * will be allowed to connect + * @param apc_cls extra argument to apc + * @param dh default handler for all URIs + * @param dh_cls extra argument to dh + * @return NULL on error, handle to daemon on success + */ struct MHD_Daemon * MHD_start_daemon (unsigned int options, unsigned short port, @@ -790,9 +796,7 @@ MHD_start_daemon (unsigned int options, struct MHD_Daemon *ret; va_list ap; - /* initializes argument pointer */ va_start (ap, dh_cls); - ret = MHD_start_daemon_va (options, port, apc, apc_cls, dh, dh_cls, ap); va_end (ap); return ret; @@ -834,12 +838,8 @@ MHD_start_daemon_va (unsigned int options, /* allocate the mhd daemon */ retVal = malloc (sizeof (struct MHD_Daemon)); - if (retVal == NULL) - { - CLOSE (socket_fd); - return NULL; - } + return NULL; /* set default daemon values */ memset (retVal, 0, sizeof (struct MHD_Daemon)); @@ -891,7 +891,7 @@ MHD_start_daemon_va (unsigned int options, retVal->per_ip_connection_limit = va_arg (ap, unsigned int); break; case MHD_OPTION_SOCK_ADDR: - servaddr = va_arg (ap, struct sockaddr *); + servaddr = va_arg (ap, struct sockaddr *); break; #if HTTPS_SUPPORT case MHD_OPTION_PROTOCOL_VERSION: @@ -931,13 +931,14 @@ MHD_start_daemon_va (unsigned int options, if (opt > MHD_HTTPS_OPTION_START && opt < MHD_HTTPS_OPTION_END) { fprintf (stderr, - "Error: HTTPS option %d passed to non HTTPS daemon\n", + "MHD HTTPS option %d passed to MHD compiled without HTTPS support\n", opt); } else { fprintf (stderr, - "Invalid MHD_OPTION argument! (Did you terminate the list with MHD_OPTION_END?)\n"); + "Invalid option %d! (Did you terminate the list with MHD_OPTION_END?)\n", + opt); } #endif abort (); @@ -954,6 +955,7 @@ MHD_start_daemon_va (unsigned int options, if ((options & MHD_USE_DEBUG) != 0) fprintf (stderr, "Call to socket failed: %s\n", STRERROR (errno)); #endif + free(retVal); return NULL; } if ((SETSOCKOPT (socket_fd, @@ -967,33 +969,32 @@ MHD_start_daemon_va (unsigned int options, } /* check for user supplied sockaddr */ - if (servaddr) { - if (options & MHD_USE_IPv6){ - addrlen = sizeof (struct sockaddr_in6); - } - else{ - addrlen = sizeof (struct sockaddr_in); - } - } - else if ((options & MHD_USE_IPv6) != 0) + if ((options & MHD_USE_IPv6) != 0) { - memset (&servaddr6, 0, sizeof (struct sockaddr_in6)); - servaddr6.sin6_family = AF_INET6; - servaddr6.sin6_port = htons (port); - servaddr = (struct sockaddr *) &servaddr6; addrlen = sizeof (struct sockaddr_in6); } else { - memset (&servaddr4, 0, sizeof (struct sockaddr_in)); - servaddr4.sin_family = AF_INET; - servaddr4.sin_port = htons (port); - servaddr = (struct sockaddr *) &servaddr4; addrlen = sizeof (struct sockaddr_in); } - + if (NULL == servaddr) + { + if ((options & MHD_USE_IPv6) != 0) + { + memset (&servaddr6, 0, sizeof (struct sockaddr_in6)); + servaddr6.sin6_family = AF_INET6; + servaddr6.sin6_port = htons (port); + servaddr = (struct sockaddr *) &servaddr6; + } + else + { + memset (&servaddr4, 0, sizeof (struct sockaddr_in)); + servaddr4.sin_family = AF_INET; + servaddr4.sin_port = htons (port); + servaddr = (struct sockaddr *) &servaddr4; + } + } retVal->socket_fd = socket_fd; - if (BIND (socket_fd, servaddr, addrlen) < 0) { #if HAVE_MESSAGES @@ -1002,6 +1003,7 @@ MHD_start_daemon_va (unsigned int options, "Failed to bind to port %u: %s\n", port, STRERROR (errno)); #endif CLOSE (socket_fd); + free(retVal); return NULL; } @@ -1014,6 +1016,7 @@ MHD_start_daemon_va (unsigned int options, "Failed to listen for connections: %s\n", STRERROR (errno)); #endif CLOSE (socket_fd); + free(retVal); return NULL; } @@ -1024,40 +1027,29 @@ MHD_start_daemon_va (unsigned int options, #if HAVE_MESSAGES MHD_DLOG (retVal, "Failed to initialize HTTPS daemon\n"); #endif + CLOSE (socket_fd); free (retVal); return NULL; } #endif - if (((0 != (options & MHD_USE_THREAD_PER_CONNECTION)) || (0 != (options - & - MHD_USE_SELECT_INTERNALLY))) + if (((0 != (options & MHD_USE_THREAD_PER_CONNECTION)) || + (0 != (options & MHD_USE_SELECT_INTERNALLY))) && (0 != pthread_create (&retVal->pid, NULL, &MHD_select_thread, retVal))) { #if HAVE_MESSAGES - MHD_DLOG (retVal, "Failed to create listen thread: %s\n", + MHD_DLOG (retVal, + "Failed to create listen thread: %s\n", STRERROR (errno)); #endif free (retVal); CLOSE (socket_fd); return NULL; - } - + } return retVal; } /** - * Start a webserver on the given port. - * - * @param port port to bind to - * @param apc callback to call to check which clients - * will be allowed to connect - * @param apc_cls extra argument to apc - * @param dh default handler for all URIs - * @param dh_cls extra argument to dh - * @return NULL on error, handle to daemon on success - */ -/** * Shutdown an http daemon. */ void diff --git a/src/daemon/https/gnutls.h b/src/daemon/https/gnutls.h @@ -233,40 +233,40 @@ extern "C" int MHD_gnutls_alert_send_appropriate (mhd_gtls_session_t session, int err); const char * MHD_gnutls_alert_get_name (gnutls_alert_description_t alert); -// gnutls_cipher_algorithm_t gnutls_cipher_get (mhd_gtls_session_t session); -// gnutls_kx_algorithm_t gnutls_kx_get (mhd_gtls_session_t session); -// gnutls_mac_algorithm_t gnutls_mac_get (mhd_gtls_session_t session); -// gnutls_compression_method_t gnutls_compression_get (mhd_gtls_session_t +// enum MHD_GNUTLS_CipherAlgorithm gnutls_cipher_get (mhd_gtls_session_t session); +// enum MHD_GNUTLS_KeyExchangeAlgorithm gnutls_kx_get (mhd_gtls_session_t session); +// enum MHD_GNUTLS_HashAlgorithm gnutls_mac_get (mhd_gtls_session_t session); +// enum MHD_GNUTLS_CompressionMethod gnutls_compression_get (mhd_gtls_session_t // session); -// gnutls_certificate_type_t gnutls_certificate_type_get (mhd_gtls_session_t +// enum MHD_GNUTLS_CertificateType gnutls_certificate_type_get (mhd_gtls_session_t // session); - size_t MHD_gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm); - size_t MHD_gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm); + size_t MHD_gnutls_cipher_get_key_size (enum MHD_GNUTLS_CipherAlgorithm algorithm); + size_t MHD_gnutls_mac_get_key_size (enum MHD_GNUTLS_HashAlgorithm algorithm); /* the name of the specified algorithms */ - const char * MHD_gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm); - const char * MHD_gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm); - const char * MHD_gnutls_compression_get_name (gnutls_compression_method_t + const char * MHD_gnutls_cipher_get_name (enum MHD_GNUTLS_CipherAlgorithm algorithm); + const char * MHD_gnutls_mac_get_name (enum MHD_GNUTLS_HashAlgorithm algorithm); + const char * MHD_gnutls_compression_get_name (enum MHD_GNUTLS_CompressionMethod algorithm); - const char * MHD_gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm); - const char * MHD_gnutls_certificate_type_get_name (gnutls_certificate_type_t + const char * MHD_gnutls_kx_get_name (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm); + const char * MHD_gnutls_certificate_type_get_name (enum MHD_GNUTLS_CertificateType type); - gnutls_mac_algorithm_t MHD_gtls_mac_get_id (const char *name); - gnutls_compression_method_t MHD_gtls_compression_get_id (const char *name); - gnutls_cipher_algorithm_t MHD_gtls_cipher_get_id (const char *name); - gnutls_kx_algorithm_t MHD_gtls_kx_get_id (const char *name); - gnutls_protocol_t MHD_gtls_protocol_get_id (const char *name); - gnutls_certificate_type_t MHD_gtls_certificate_type_get_id (const char *name); + enum MHD_GNUTLS_HashAlgorithm MHD_gtls_mac_get_id (const char *name); + enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get_id (const char *name); + enum MHD_GNUTLS_CipherAlgorithm MHD_gtls_cipher_get_id (const char *name); + enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gtls_kx_get_id (const char *name); + enum MHD_GNUTLS_Protocol MHD_gtls_protocol_get_id (const char *name); + enum MHD_GNUTLS_CertificateType MHD_gtls_certificate_type_get_id (const char *name); /* list supported algorithms */ - const gnutls_cipher_algorithm_t * MHD_gtls_cipher_list (void); - const gnutls_mac_algorithm_t * MHD_gtls_mac_list (void); - const gnutls_compression_method_t * MHD_gtls_compression_list (void); - const gnutls_protocol_t * MHD_gtls_protocol_list (void); - const gnutls_certificate_type_t * MHD_gtls_certificate_type_list (void); - const gnutls_kx_algorithm_t * MHD_gtls_kx_list (void); + const enum MHD_GNUTLS_CipherAlgorithm * MHD_gtls_cipher_list (void); + const enum MHD_GNUTLS_HashAlgorithm * MHD_gtls_mac_list (void); + const enum MHD_GNUTLS_CompressionMethod * MHD_gtls_compression_list (void); + const enum MHD_GNUTLS_Protocol * MHD_gtls_protocol_list (void); + const enum MHD_GNUTLS_CertificateType * MHD_gtls_certificate_type_list (void); + const enum MHD_GNUTLS_KeyExchangeAlgorithm * MHD_gtls_kx_list (void); /* error functions */ int MHD_gtls_error_is_fatal (int error); @@ -372,9 +372,9 @@ extern "C" const char *priority, const char **err_pos); /* get the currently used protocol version */ - gnutls_protocol_t MHD_gnutls_protocol_get_version (mhd_gtls_session_t session); + enum MHD_GNUTLS_Protocol MHD_gnutls_protocol_get_version (mhd_gtls_session_t session); - const char * MHD_gnutls_protocol_get_name (gnutls_protocol_t version); + const char * MHD_gnutls_protocol_get_name (enum MHD_GNUTLS_Protocol version); /* * get/set session @@ -415,7 +415,7 @@ extern "C" * cred is a structure defined by the kx algorithm */ int MHD_gnutls_credentials_set (mhd_gtls_session_t session, - gnutls_credentials_type_t type, void *cred); + enum MHD_GNUTLS_CredentialsType type, void *cred); /* Credential structures - used in MHD_gnutls_credentials_set(); */ struct mhd_gtls_certificate_credentials_st; @@ -634,7 +634,7 @@ extern "C" /* * this function returns the hash of the given data. */ - int MHD_gnutls_fingerprint (gnutls_digest_algorithm_t algo, + int MHD_gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo, const gnutls_datum_t * data, void *result, size_t * result_size); @@ -789,7 +789,7 @@ extern "C" typedef struct gnutls_retr_st { - gnutls_certificate_type_t type; + enum MHD_GNUTLS_CertificateType type; union cert { gnutls_x509_crt_t *x509; @@ -810,7 +810,7 @@ extern "C" req_ca_rdn, int nreqs, const - gnutls_pk_algorithm_t + enum MHD_GNUTLS_PublicKeyAlgorithm * pk_algos, int pk_algos_length, @@ -822,10 +822,10 @@ extern "C" /* * Functions that allow auth_info_t structures handling */ - gnutls_credentials_type_t MHD_gtls_auth_get_type (mhd_gtls_session_t session); - gnutls_credentials_type_t + enum MHD_GNUTLS_CredentialsType 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); - gnutls_credentials_type_t + enum MHD_GNUTLS_CredentialsType MHD_gtls_auth_client_get_type (mhd_gtls_session_t session); /* @@ -852,7 +852,7 @@ extern "C" /* External signing callback. Experimental. */ typedef int (*gnutls_sign_func) (mhd_gtls_session_t session, void *userdata, - gnutls_certificate_type_t cert_type, + enum MHD_GNUTLS_CertificateType cert_type, const gnutls_datum_t * cert, const gnutls_datum_t * hash, gnutls_datum_t * signature); diff --git a/src/daemon/https/tls/auth_cert.c b/src/daemon/https/tls/auth_cert.c @@ -113,9 +113,9 @@ clear: * -1 otherwise. */ inline static int -_gnutls_check_pk_algo_in_list (const gnutls_pk_algorithm_t * +_gnutls_check_pk_algo_in_list (const enum MHD_GNUTLS_PublicKeyAlgorithm * pk_algos, int pk_algos_length, - gnutls_pk_algorithm_t algo_to_check) + enum MHD_GNUTLS_PublicKeyAlgorithm algo_to_check) { int i; for (i = 0; i < pk_algos_length; i++) @@ -185,7 +185,7 @@ _gnutls_cert_get_issuer_dn (gnutls_cert * cert, gnutls_datum_t * odn) static int _find_x509_cert (const mhd_gtls_cert_credentials_t cred, opaque * _data, size_t _data_size, - const gnutls_pk_algorithm_t * pk_algos, + const enum MHD_GNUTLS_PublicKeyAlgorithm * pk_algos, int pk_algos_length, int *indx) { unsigned size; @@ -348,14 +348,14 @@ static int call_get_cert_callback (mhd_gtls_session_t session, gnutls_datum_t * issuers_dn, int issuers_dn_length, - gnutls_pk_algorithm_t * pk_algos, int pk_algos_length) + enum MHD_GNUTLS_PublicKeyAlgorithm * pk_algos, int pk_algos_length) { unsigned i; gnutls_cert *local_certs = NULL; gnutls_privkey *local_key = NULL; gnutls_retr_st st; int ret; - gnutls_certificate_type_t type = gnutls_certificate_type_get (session); + enum MHD_GNUTLS_CertificateType type = gnutls_certificate_type_get (session); mhd_gtls_cert_credentials_t cred; cred = (mhd_gtls_cert_credentials_t) @@ -443,7 +443,7 @@ cleanup: static int _select_client_cert (mhd_gtls_session_t session, opaque * _data, size_t _data_size, - gnutls_pk_algorithm_t * pk_algos, int pk_algos_length) + enum MHD_GNUTLS_PublicKeyAlgorithm * pk_algos, int pk_algos_length) { int result; int indx = -1; @@ -793,7 +793,7 @@ typedef enum CertificateSigType } CertificateSigType; /* Checks if we support the given signature algorithm - * (RSA or DSA). Returns the corresponding gnutls_pk_algorithm_t + * (RSA or DSA). Returns the corresponding enum MHD_GNUTLS_PublicKeyAlgorithm * if true; */ inline static int @@ -818,9 +818,9 @@ mhd_gtls_proc_cert_cert_req (mhd_gtls_session_t session, opaque * data, cert_auth_info_t info; ssize_t dsize; int i, j; - gnutls_pk_algorithm_t pk_algos[MAX_SIGN_ALGOS]; + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algos[MAX_SIGN_ALGOS]; int pk_algos_length; - gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session); + enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); cred = (mhd_gtls_cert_credentials_t) mhd_gtls_get_cred (session->key, MHD_GNUTLS_CRD_CERTIFICATE, NULL); @@ -1014,7 +1014,7 @@ mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t session, opaque ** data) mhd_gtls_cert_credentials_t cred; int size; opaque *pdata; - gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session); + enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); /* Now we need to generate the RDN sequence. This is * already in the CERTIFICATE_CRED structure, to improve @@ -1029,7 +1029,7 @@ mhd_gtls_gen_cert_server_cert_req (mhd_gtls_session_t session, opaque ** data) return GNUTLS_E_INSUFFICIENT_CREDENTIALS; } - size = CERTTYPE_SIZE + 2; /* 2 for gnutls_certificate_type_t + 2 for size of rdn_seq + size = CERTTYPE_SIZE + 2; /* 2 for enum MHD_GNUTLS_CertificateType + 2 for size of rdn_seq */ if (session->security_parameters.cert_type == MHD_GNUTLS_CRT_X509 && @@ -1248,7 +1248,7 @@ mhd_gtls_selected_certs_set (mhd_gtls_session_t session, */ int mhd_gtls_server_select_cert (mhd_gtls_session_t session, - gnutls_pk_algorithm_t requested_algo) + enum MHD_GNUTLS_PublicKeyAlgorithm requested_algo) { unsigned i; int idx, ret; diff --git a/src/daemon/https/tls/auth_cert.h b/src/daemon/https/tls/auth_cert.h @@ -141,7 +141,7 @@ int mhd_gtls_get_selected_cert (mhd_gtls_session_t session, gnutls_privkey ** apr_pkey); int mhd_gtls_server_select_cert (struct MHD_gtls_session_int *, - gnutls_pk_algorithm_t); + 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, diff --git a/src/daemon/https/tls/auth_rsa.c b/src/daemon/https/tls/auth_rsa.c @@ -325,7 +325,7 @@ _gnutls_gen_rsa_client_kx (mhd_gtls_session_t session, opaque ** data) mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; int params_len = MAX_PUBLIC_PARAMS_SIZE; int ret, i; - gnutls_protocol_t ver; + enum MHD_GNUTLS_Protocol ver; if (auth == NULL) { diff --git a/src/daemon/https/tls/gnutls_algorithms.c b/src/daemon/https/tls/gnutls_algorithms.c @@ -35,9 +35,9 @@ */ typedef struct { - gnutls_kx_algorithm_t algorithm; - gnutls_credentials_type_t client_type; - gnutls_credentials_type_t server_type; /* The type of credentials a server + enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm; + enum MHD_GNUTLS_CredentialsType client_type; + enum MHD_GNUTLS_CredentialsType server_type; /* The type of credentials a server * needs to set */ } gnutls_cred_map; @@ -84,8 +84,8 @@ static const gnutls_cred_map mhd_gtls_cred_mappings[] = { /* KX mappings to PK algorithms */ typedef struct { - gnutls_kx_algorithm_t kx_algorithm; - gnutls_pk_algorithm_t pk_algorithm; + enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm; + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm; enum encipher_type encipher_type; /* CIPHER_ENCRYPT if this algorithm is to be used * for encryption, CIPHER_SIGN if signature only, * CIPHER_IGN if this does not apply at all. @@ -130,7 +130,7 @@ static const gnutls_pk_map mhd_gtls_pk_mappings[] = { typedef struct { const char *name; - gnutls_protocol_t id; /* gnutls internal version number */ + enum MHD_GNUTLS_Protocol id; /* gnutls internal version number */ int major; /* defined by the protocol */ int minor; /* defined by the protocol */ int supported; /* 0 not supported, > 0 is supported */ @@ -165,7 +165,7 @@ static const gnutls_version_entry mhd_gtls_sup_versions[] = { }; /* Keep the contents of this struct the same as the previous one. */ -static const gnutls_protocol_t mhd_gtls_supported_protocols[] = { MHD_GNUTLS_SSL3, +static const enum MHD_GNUTLS_Protocol mhd_gtls_supported_protocols[] = { MHD_GNUTLS_SSL3, MHD_GNUTLS_TLS1_0, MHD_GNUTLS_TLS1_1, MHD_GNUTLS_TLS1_2, @@ -182,7 +182,7 @@ static const gnutls_protocol_t mhd_gtls_supported_protocols[] = { MHD_GNUTLS_SSL struct gnutls_cipher_entry { const char *name; - gnutls_cipher_algorithm_t id; + enum MHD_GNUTLS_CipherAlgorithm id; uint16_t blocksize; uint16_t keysize; cipher_type_t block; @@ -271,7 +271,7 @@ static const gnutls_cipher_entry mhd_gtls_algorithms[] = { }; /* Keep the contents of this struct the same as the previous one. */ -static const gnutls_cipher_algorithm_t mhd_gtls_supported_ciphers[] = +static const enum MHD_GNUTLS_CipherAlgorithm mhd_gtls_supported_ciphers[] = { MHD_GNUTLS_CIPHER_AES_256_CBC, MHD_GNUTLS_CIPHER_AES_128_CBC, MHD_GNUTLS_CIPHER_3DES_CBC, @@ -298,7 +298,7 @@ struct gnutls_hash_entry { const char *name; const char *oid; - gnutls_mac_algorithm_t id; + enum MHD_GNUTLS_HashAlgorithm id; size_t key_size; /* in case of mac */ }; typedef struct gnutls_hash_entry gnutls_hash_entry; @@ -327,7 +327,7 @@ static const gnutls_hash_entry mhd_gtls_hash_algorithms[] = { }; /* Keep the contents of this struct the same as the previous one. */ -static const gnutls_mac_algorithm_t mhd_gtls_supported_macs[] = { MHD_GNUTLS_MAC_SHA1, +static const enum MHD_GNUTLS_HashAlgorithm mhd_gtls_supported_macs[] = { MHD_GNUTLS_MAC_SHA1, MHD_GNUTLS_MAC_MD5, MHD_GNUTLS_MAC_SHA256, MHD_GNUTLS_MAC_NULL, @@ -364,7 +364,7 @@ gnutls_compression_entry _gnutls_compression_algorithms[MAX_COMP_METHODS] = 0} }; -static const gnutls_compression_method_t mhd_gtls_supported_compressions[] = { +static const enum MHD_GNUTLS_CompressionMethod mhd_gtls_supported_compressions[] = { #ifdef HAVE_LIBZ MHD_GNUTLS_COMP_DEFLATE, #endif @@ -395,7 +395,7 @@ extern mhd_gtls_mod_auth_st srp_dss_auth_struct; typedef struct mhd_gtls_kx_algo_entry { const char *name; - gnutls_kx_algorithm_t algorithm; + enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm; mhd_gtls_mod_auth_st *auth_struct; int needs_dh_params; int needs_rsa_params; @@ -444,7 +444,7 @@ static const mhd_gtls_kx_algo_entry_t mhd_gtls_kx_algorithms[] = { }; /* Keep the contents of this struct the same as the previous one. */ -static const gnutls_kx_algorithm_t mhd_gtls_supported_kxs[] = { +static const enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_supported_kxs[] = { #ifdef ENABLE_ANON MHD_GNUTLS_KX_ANON_DH, #endif @@ -479,10 +479,10 @@ typedef struct { const char *name; cipher_suite_st id; - gnutls_cipher_algorithm_t block_algorithm; - gnutls_kx_algorithm_t kx_algorithm; - gnutls_mac_algorithm_t mac_algorithm; - gnutls_protocol_t version; /* this cipher suite is supported + enum MHD_GNUTLS_CipherAlgorithm block_algorithm; + enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm; + enum MHD_GNUTLS_HashAlgorithm mac_algorithm; + enum MHD_GNUTLS_Protocol version; /* this cipher suite is supported * from 'version' and above; */ } mhd_gtls_cipher_suite_entry; @@ -763,7 +763,7 @@ static const mhd_gtls_cipher_suite_entry mhd_gtls_cs_algorithms[] = { int mhd_gtls_mac_priority (mhd_gtls_session_t session, - gnutls_mac_algorithm_t algorithm) + enum MHD_GNUTLS_HashAlgorithm algorithm) { /* actually returns the priority */ unsigned int i; for (i = 0; i < session->internals.priorities.mac.num_algorithms; i++) @@ -782,7 +782,7 @@ mhd_gtls_mac_priority (mhd_gtls_session_t session, * algorithm, or %NULL. **/ const char * -MHD_gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm) +MHD_gnutls_mac_get_name (enum MHD_GNUTLS_HashAlgorithm algorithm) { const char *ret = NULL; @@ -796,14 +796,14 @@ MHD_gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm) * MHD_gtls_mac_get_id - Returns the gnutls id of the specified in string algorithm * @algorithm: is a MAC algorithm name * - * Returns: an %gnutls_mac_algorithm_tid of the specified in a string + * Returns: an %enum MHD_GNUTLS_HashAlgorithmid of the specified in a string * MAC algorithm, or %GNUTLS_MAC_UNKNOWN on failures. The names are * compared in a case insensitive way. **/ -gnutls_mac_algorithm_t +enum MHD_GNUTLS_HashAlgorithm MHD_gtls_mac_get_id (const char *name) { - gnutls_mac_algorithm_t ret = MHD_GNUTLS_MAC_UNKNOWN; + enum MHD_GNUTLS_HashAlgorithm ret = MHD_GNUTLS_MAC_UNKNOWN; GNUTLS_HASH_LOOP (if (strcasecmp (p->name, name) == 0) ret = p->id) ; @@ -820,7 +820,7 @@ MHD_gtls_mac_get_id (const char *name) * **/ size_t -MHD_gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm) +MHD_gnutls_mac_get_key_size (enum MHD_GNUTLS_HashAlgorithm algorithm) { size_t ret = 0; @@ -838,17 +838,17 @@ MHD_gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm) * example, MD2 is not supported as a cipher suite, but is supported * for other purposes (e.g., X.509 signature verification or similar). * - * Returns: Return a zero-terminated list of %gnutls_mac_algorithm_t + * Returns: Return a zero-terminated list of %enum MHD_GNUTLS_HashAlgorithm * integers indicating the available MACs. **/ -const gnutls_mac_algorithm_t * +const enum MHD_GNUTLS_HashAlgorithm * MHD_gtls_mac_list (void) { return mhd_gtls_supported_macs; } const char * -mhd_gtls_x509_mac_to_oid (gnutls_mac_algorithm_t algorithm) +mhd_gtls_x509_mac_to_oid (enum MHD_GNUTLS_HashAlgorithm algorithm) { const char *ret = NULL; @@ -858,10 +858,10 @@ mhd_gtls_x509_mac_to_oid (gnutls_mac_algorithm_t algorithm) return ret; } -gnutls_mac_algorithm_t +enum MHD_GNUTLS_HashAlgorithm mhd_gtls_x509_oid2mac_algorithm (const char *oid) { - gnutls_mac_algorithm_t ret = 0; + enum MHD_GNUTLS_HashAlgorithm ret = 0; GNUTLS_HASH_LOOP (if (p->oid && strcmp (oid, p->oid) == 0) { @@ -875,7 +875,7 @@ mhd_gtls_x509_oid2mac_algorithm (const char *oid) } int -mhd_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm) +mhd_gnutls_mac_is_ok (enum MHD_GNUTLS_HashAlgorithm algorithm) { ssize_t ret = -1; GNUTLS_HASH_ALG_LOOP (ret = p->id); @@ -889,7 +889,7 @@ mhd_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm) /* Compression Functions */ int mhd_gtls_compression_priority (mhd_gtls_session_t session, - gnutls_compression_method_t algorithm) + enum MHD_GNUTLS_CompressionMethod algorithm) { /* actually returns the priority */ unsigned int i; for (i = 0; i < session->internals.priorities.compression.num_algorithms; i++) @@ -908,7 +908,7 @@ mhd_gtls_compression_priority (mhd_gtls_session_t session, * specified compression algorithm, or %NULL. **/ const char * -MHD_gnutls_compression_get_name (gnutls_compression_method_t algorithm) +MHD_gnutls_compression_get_name (enum MHD_GNUTLS_CompressionMethod algorithm) { const char *ret = NULL; @@ -928,10 +928,10 @@ MHD_gnutls_compression_get_name (gnutls_compression_method_t algorithm) * %GNUTLS_COMP_UNKNOWN on error. * **/ -gnutls_compression_method_t +enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get_id (const char *name) { - gnutls_compression_method_t ret = MHD_GNUTLS_COMP_UNKNOWN; + enum MHD_GNUTLS_CompressionMethod ret = MHD_GNUTLS_COMP_UNKNOWN; GNUTLS_COMPRESSION_LOOP (if (strcasecmp @@ -949,10 +949,10 @@ MHD_gtls_compression_get_id (const char *name) * compression, you must link to libgnutls-extra and call * gnutls_global_init_extra(). * - * Returns: a zero-terminated list of %gnutls_compression_method_t + * Returns: a zero-terminated list of %enum MHD_GNUTLS_CompressionMethod * integers indicating the available compression methods. **/ -const gnutls_compression_method_t * +const enum MHD_GNUTLS_CompressionMethod * MHD_gtls_compression_list (void) { return mhd_gtls_supported_compressions; @@ -960,7 +960,7 @@ MHD_gtls_compression_list (void) /* return the tls number of the specified algorithm */ int -mhd_gtls_compression_get_num (gnutls_compression_method_t algorithm) +mhd_gtls_compression_get_num (enum MHD_GNUTLS_CompressionMethod algorithm) { int ret = -1; @@ -971,7 +971,7 @@ mhd_gtls_compression_get_num (gnutls_compression_method_t algorithm) } int -mhd_gtls_compression_get_wbits (gnutls_compression_method_t algorithm) +mhd_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod algorithm) { int ret = -1; /* avoid prefix */ @@ -980,7 +980,7 @@ mhd_gtls_compression_get_wbits (gnutls_compression_method_t algorithm) } int -mhd_gtls_compression_get_mem_level (gnutls_compression_method_t algorithm) +mhd_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod algorithm) { int ret = -1; /* avoid prefix */ @@ -989,7 +989,7 @@ mhd_gtls_compression_get_mem_level (gnutls_compression_method_t algorithm) } int -mhd_gtls_compression_get_comp_level (gnutls_compression_method_t algorithm) +mhd_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod algorithm) { int ret = -1; /* avoid prefix */ @@ -1000,10 +1000,10 @@ mhd_gtls_compression_get_comp_level (gnutls_compression_method_t algorithm) /* returns the gnutls internal ID of the TLS compression * method num */ -gnutls_compression_method_t +enum MHD_GNUTLS_CompressionMethod mhd_gtls_compression_get_id (int num) { - gnutls_compression_method_t ret = -1; + enum MHD_GNUTLS_CompressionMethod ret = -1; /* avoid prefix */ GNUTLS_COMPRESSION_ALG_LOOP_NUM (ret = p->id); @@ -1012,7 +1012,7 @@ mhd_gtls_compression_get_id (int num) } int -mhd_gtls_compression_is_ok (gnutls_compression_method_t algorithm) +mhd_gtls_compression_is_ok (enum MHD_GNUTLS_CompressionMethod algorithm) { ssize_t ret = -1; GNUTLS_COMPRESSION_ALG_LOOP (ret = p->id); @@ -1025,7 +1025,7 @@ mhd_gtls_compression_is_ok (gnutls_compression_method_t algorithm) /* CIPHER functions */ int -mhd_gtls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm) +mhd_gtls_cipher_get_block_size (enum MHD_GNUTLS_CipherAlgorithm algorithm) { size_t ret = 0; GNUTLS_ALG_LOOP (ret = p->blocksize); @@ -1036,7 +1036,7 @@ mhd_gtls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm) /* returns the priority */ int mhd_gtls_cipher_priority (mhd_gtls_session_t session, - gnutls_cipher_algorithm_t algorithm) + enum MHD_GNUTLS_CipherAlgorithm algorithm) { unsigned int i; for (i = 0; i < session->internals.priorities.cipher.num_algorithms; i++) @@ -1048,7 +1048,7 @@ mhd_gtls_cipher_priority (mhd_gtls_session_t session, } int -mhd_gtls_cipher_is_block (gnutls_cipher_algorithm_t algorithm) +mhd_gtls_cipher_is_block (enum MHD_GNUTLS_CipherAlgorithm algorithm) { size_t ret = 0; @@ -1065,7 +1065,7 @@ mhd_gtls_cipher_is_block (gnutls_cipher_algorithm_t algorithm) * the given cipher is invalid. **/ size_t -MHD_gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm) +MHD_gnutls_cipher_get_key_size (enum MHD_GNUTLS_CipherAlgorithm algorithm) { /* In bytes */ size_t ret = 0; GNUTLS_ALG_LOOP (ret = p->keysize); @@ -1074,7 +1074,7 @@ MHD_gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm) } int -mhd_gtls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm) +mhd_gtls_cipher_get_iv_size (enum MHD_GNUTLS_CipherAlgorithm algorithm) { /* In bytes */ size_t ret = 0; GNUTLS_ALG_LOOP (ret = p->iv); @@ -1083,7 +1083,7 @@ mhd_gtls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm) } int -mhd_gtls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm) +mhd_gtls_cipher_get_export_flag (enum MHD_GNUTLS_CipherAlgorithm algorithm) { /* In bytes */ size_t ret = 0; GNUTLS_ALG_LOOP (ret = p->export_flag); @@ -1099,7 +1099,7 @@ mhd_gtls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm) * specified cipher, or %NULL. **/ const char * -MHD_gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm) +MHD_gnutls_cipher_get_name (enum MHD_GNUTLS_CipherAlgorithm algorithm) { const char *ret = NULL; @@ -1119,10 +1119,10 @@ MHD_gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm) * on error. * **/ -gnutls_cipher_algorithm_t +enum MHD_GNUTLS_CipherAlgorithm MHD_gtls_cipher_get_id (const char *name) { - gnutls_cipher_algorithm_t ret = MHD_GNUTLS_CIPHER_UNKNOWN; + enum MHD_GNUTLS_CipherAlgorithm ret = MHD_GNUTLS_CIPHER_UNKNOWN; GNUTLS_LOOP (if (strcasecmp (p->name, name) == 0) ret = p->id) ; @@ -1138,18 +1138,18 @@ MHD_gtls_cipher_get_id (const char *name) * example, DES is not supported as a cipher suite, but is supported * for other purposes (e.g., PKCS#8 or similar). * - * Returns: a zero-terminated list of %gnutls_cipher_algorithm_t + * Returns: a zero-terminated list of %enum MHD_GNUTLS_CipherAlgorithm * integers indicating the available ciphers. * **/ -const gnutls_cipher_algorithm_t * +const enum MHD_GNUTLS_CipherAlgorithm * MHD_gtls_cipher_list (void) { return mhd_gtls_supported_ciphers; } int -mhd_gtls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm) +mhd_gtls_cipher_is_ok (enum MHD_GNUTLS_CipherAlgorithm algorithm) { ssize_t ret = -1; GNUTLS_ALG_LOOP (ret = p->id); @@ -1162,7 +1162,7 @@ mhd_gtls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm) /* Key EXCHANGE functions */ mhd_gtls_mod_auth_st * -mhd_gtls_kx_auth_struct (gnutls_kx_algorithm_t algorithm) +mhd_gtls_kx_auth_struct (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) { mhd_gtls_mod_auth_st *ret = NULL; GNUTLS_KX_ALG_LOOP (ret = p->auth_struct); @@ -1172,7 +1172,7 @@ mhd_gtls_kx_auth_struct (gnutls_kx_algorithm_t algorithm) int mhd_gtls_kx_priority (mhd_gtls_session_t session, - gnutls_kx_algorithm_t algorithm) + enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) { unsigned int i; for (i = 0; i < session->internals.priorities.kx.num_algorithms; i++) @@ -1191,7 +1191,7 @@ mhd_gtls_kx_priority (mhd_gtls_session_t session, * specified key exchange algorithm, or %NULL. **/ const char * -MHD_gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm) +MHD_gnutls_kx_get_name (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) { const char *ret = NULL; @@ -1210,10 +1210,10 @@ MHD_gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm) * Returns: an id of the specified KX algorithm, or * %GNUTLS_KX_UNKNOWN on error. **/ -gnutls_kx_algorithm_t +enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gtls_kx_get_id (const char *name) { - gnutls_cipher_algorithm_t ret = MHD_GNUTLS_KX_UNKNOWN; + enum MHD_GNUTLS_CipherAlgorithm ret = MHD_GNUTLS_KX_UNKNOWN; GNUTLS_KX_LOOP (if (strcasecmp (p->name, name) == 0) ret = p->algorithm) ; @@ -1226,17 +1226,17 @@ MHD_gtls_kx_get_id (const char *name) * * Get a list of supported key exchange algorithms. * - * Returns: a zero-terminated list of %gnutls_kx_algorithm_t integers + * Returns: a zero-terminated list of %enum MHD_GNUTLS_KeyExchangeAlgorithm integers * indicating the available key exchange algorithms. **/ -const gnutls_kx_algorithm_t * +const enum MHD_GNUTLS_KeyExchangeAlgorithm * MHD_gtls_kx_list (void) { return mhd_gtls_supported_kxs; } int -mhd_gtls_kx_is_ok (gnutls_kx_algorithm_t algorithm) +mhd_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) { ssize_t ret = -1; GNUTLS_KX_ALG_LOOP (ret = p->algorithm); @@ -1248,7 +1248,7 @@ mhd_gtls_kx_is_ok (gnutls_kx_algorithm_t algorithm) } int -mhd_gtls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm) +mhd_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) { ssize_t ret = 0; GNUTLS_KX_ALG_LOOP (ret = p->needs_rsa_params); @@ -1256,7 +1256,7 @@ mhd_gtls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm) } int -mhd_gtls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm) +mhd_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm) { ssize_t ret = 0; GNUTLS_KX_ALG_LOOP (ret = p->needs_dh_params); @@ -1265,7 +1265,7 @@ mhd_gtls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm) /* Version */ int -mhd_gtls_version_priority (mhd_gtls_session_t session, gnutls_protocol_t version) +mhd_gtls_version_priority (mhd_gtls_session_t session, enum MHD_GNUTLS_Protocol version) { /* actually returns the priority */ unsigned int i; @@ -1283,7 +1283,7 @@ mhd_gtls_version_priority (mhd_gtls_session_t session, gnutls_protocol_t version return -1; } -gnutls_protocol_t +enum MHD_GNUTLS_Protocol mhd_gtls_version_lowest (mhd_gtls_session_t session) { /* returns the lowest version supported */ unsigned int i, min = 0xff; @@ -1305,7 +1305,7 @@ mhd_gtls_version_lowest (mhd_gtls_session_t session) return min; } -gnutls_protocol_t +enum MHD_GNUTLS_Protocol mhd_gtls_version_max (mhd_gtls_session_t session) { /* returns the maximum version supported */ unsigned int i, max = 0x00; @@ -1335,7 +1335,7 @@ mhd_gtls_version_max (mhd_gtls_session_t session) * version (e.g., "TLS 1.0"), or %NULL. **/ const char * -MHD_gnutls_protocol_get_name (gnutls_protocol_t version) +MHD_gnutls_protocol_get_name (enum MHD_GNUTLS_Protocol version) { const char *ret = NULL; @@ -1353,10 +1353,10 @@ MHD_gnutls_protocol_get_name (gnutls_protocol_t version) * Returns: an id of the specified protocol, or * %GNUTLS_VERSION_UNKNOWN on error. **/ -gnutls_protocol_t +enum MHD_GNUTLS_Protocol MHD_gtls_protocol_get_id (const char *name) { - gnutls_protocol_t ret = MHD_GNUTLS_VERSION_UNKNOWN; + enum MHD_GNUTLS_Protocol ret = MHD_GNUTLS_VERSION_UNKNOWN; GNUTLS_VERSION_LOOP (if (strcasecmp (p->name, name) == 0) ret = p->id) ; @@ -1369,18 +1369,18 @@ MHD_gtls_protocol_get_id (const char *name) * * Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc. * - * Returns: a zero-terminated list of %gnutls_protocol_t integers + * Returns: a zero-terminated list of %enum MHD_GNUTLS_Protocol integers * indicating the available protocols. * **/ -const gnutls_protocol_t * +const enum MHD_GNUTLS_Protocol * MHD_gtls_protocol_list (void) { return mhd_gtls_supported_protocols; } int -mhd_gtls_version_get_minor (gnutls_protocol_t version) +mhd_gtls_version_get_minor (enum MHD_GNUTLS_Protocol version) { int ret = -1; @@ -1388,7 +1388,7 @@ mhd_gtls_version_get_minor (gnutls_protocol_t version) return ret; } -gnutls_protocol_t +enum MHD_GNUTLS_Protocol mhd_gtls_version_get (int major, int minor) { int ret = -1; @@ -1400,7 +1400,7 @@ mhd_gtls_version_get (int major, int minor) } int -mhd_gtls_version_get_major (gnutls_protocol_t version) +mhd_gtls_version_get_major (enum MHD_GNUTLS_Protocol version) { int ret = -1; @@ -1412,7 +1412,7 @@ mhd_gtls_version_get_major (gnutls_protocol_t version) int mhd_gtls_version_is_supported (mhd_gtls_session_t session, - const gnutls_protocol_t version) + const enum MHD_GNUTLS_Protocol version) { int ret = 0; @@ -1427,10 +1427,10 @@ mhd_gtls_version_is_supported (mhd_gtls_session_t session, } /* Type to KX mappings */ -gnutls_kx_algorithm_t -mhd_gtls_map_kx_get_kx (gnutls_credentials_type_t type, int server) +enum MHD_GNUTLS_KeyExchangeAlgorithm +mhd_gtls_map_kx_get_kx (enum MHD_GNUTLS_CredentialsType type, int server) { - gnutls_kx_algorithm_t ret = -1; + enum MHD_GNUTLS_KeyExchangeAlgorithm ret = -1; if (server) { @@ -1443,10 +1443,10 @@ mhd_gtls_map_kx_get_kx (gnutls_credentials_type_t type, int server) return ret; } -gnutls_credentials_type_t -mhd_gtls_map_kx_get_cred (gnutls_kx_algorithm_t algorithm, int server) +enum MHD_GNUTLS_CredentialsType +mhd_gtls_map_kx_get_cred (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm, int server) { - gnutls_credentials_type_t ret = -1; + enum MHD_GNUTLS_CredentialsType ret = -1; if (server) { GNUTLS_KX_MAP_LOOP (if (p->algorithm == algorithm) ret = p->server_type) @@ -1462,7 +1462,7 @@ mhd_gtls_map_kx_get_cred (gnutls_kx_algorithm_t algorithm, int server) } /* Cipher Suite's functions */ -gnutls_cipher_algorithm_t +enum MHD_GNUTLS_CipherAlgorithm mhd_gtls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite) { int ret = 0; @@ -1470,7 +1470,7 @@ mhd_gtls_cipher_suite_get_cipher_algo (const cipher_suite_st * suite) return ret; } -gnutls_protocol_t +enum MHD_GNUTLS_Protocol mhd_gtls_cipher_suite_get_version (const cipher_suite_st * suite) { int ret = 0; @@ -1478,7 +1478,7 @@ mhd_gtls_cipher_suite_get_version (const cipher_suite_st * suite) return ret; } -gnutls_kx_algorithm_t +enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st * suite) { int ret = 0; @@ -1488,7 +1488,7 @@ mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st * suite) } -gnutls_mac_algorithm_t +enum MHD_GNUTLS_HashAlgorithm mhd_gtls_cipher_suite_get_mac_algo (const cipher_suite_st * suite) { /* In bytes */ int ret = 0; @@ -1613,17 +1613,17 @@ static int _gnutls_compare_algo (mhd_gtls_session_t session, const void *i_A1, const void *i_A2) { - gnutls_kx_algorithm_t kA1 = + enum MHD_GNUTLS_KeyExchangeAlgorithm kA1 = mhd_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A1); - gnutls_kx_algorithm_t kA2 = + enum MHD_GNUTLS_KeyExchangeAlgorithm kA2 = mhd_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A2); - gnutls_cipher_algorithm_t cA1 = + enum MHD_GNUTLS_CipherAlgorithm cA1 = mhd_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A1); - gnutls_cipher_algorithm_t cA2 = + enum MHD_GNUTLS_CipherAlgorithm cA2 = mhd_gtls_cipher_suite_get_cipher_algo ((const cipher_suite_st *) i_A2); - gnutls_mac_algorithm_t mA1 = + enum MHD_GNUTLS_HashAlgorithm mA1 = mhd_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A1); - gnutls_mac_algorithm_t mA2 = + enum MHD_GNUTLS_HashAlgorithm mA2 = mhd_gtls_cipher_suite_get_mac_algo ((const cipher_suite_st *) i_A2); int p1 = (mhd_gtls_kx_priority (session, kA1) + 1) * 64; @@ -1717,7 +1717,7 @@ mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session, unsigned int count = CIPHER_SUITES_COUNT; cipher_suite_st *tmp_ciphers; cipher_suite_st *ciphers; - gnutls_protocol_t version; + enum MHD_GNUTLS_Protocol version; if (count == 0) { @@ -1860,7 +1860,7 @@ mhd_gtls_supported_compression_methods (mhd_gtls_session_t session, * specified certificate type. **/ const char * -MHD_gnutls_certificate_type_get_name (gnutls_certificate_type_t type) +MHD_gnutls_certificate_type_get_name (enum MHD_GNUTLS_CertificateType type) { const char *ret = NULL; @@ -1878,17 +1878,17 @@ MHD_gnutls_certificate_type_get_name (gnutls_certificate_type_t type) * Returns: an id of the specified in a string certificate type, or * %GNUTLS_CRT_UNKNOWN on error. **/ -gnutls_certificate_type_t +enum MHD_GNUTLS_CertificateType MHD_gtls_certificate_type_get_id (const char *name) { - gnutls_certificate_type_t ret = MHD_GNUTLS_CRT_UNKNOWN; + enum MHD_GNUTLS_CertificateType ret = MHD_GNUTLS_CRT_UNKNOWN; if (strcasecmp (name, "X.509") == 0 || strcasecmp (name, "X509") == 0) return MHD_GNUTLS_CRT_X509; return ret; } -static const gnutls_certificate_type_t mhd_gtls_supported_certificate_types[] = +static const enum MHD_GNUTLS_CertificateType mhd_gtls_supported_certificate_types[] = { MHD_GNUTLS_CRT_X509, 0 }; @@ -1898,23 +1898,23 @@ static const gnutls_certificate_type_t mhd_gtls_supported_certificate_types[] = * * Get a list of certificate types. * - * Returns: a zero-terminated list of %gnutls_certificate_type_t + * Returns: a zero-terminated list of %enum MHD_GNUTLS_CertificateType * integers indicating the available certificate types. * **/ -const gnutls_certificate_type_t * +const enum MHD_GNUTLS_CertificateType * MHD_gtls_certificate_type_list (void) { return mhd_gtls_supported_certificate_types; } -/* returns the gnutls_pk_algorithm_t which is compatible with - * the given gnutls_kx_algorithm_t. +/* returns the enum MHD_GNUTLS_PublicKeyAlgorithm which is compatible with + * the given enum MHD_GNUTLS_KeyExchangeAlgorithm. */ -gnutls_pk_algorithm_t -mhd_gtls_map_pk_get_pk (gnutls_kx_algorithm_t kx_algorithm) +enum MHD_GNUTLS_PublicKeyAlgorithm +mhd_gtls_map_pk_get_pk (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm) { - gnutls_pk_algorithm_t ret = -1; + enum MHD_GNUTLS_PublicKeyAlgorithm ret = -1; GNUTLS_PK_MAP_ALG_LOOP (ret = p->pk_algorithm) return ret; } @@ -1925,7 +1925,7 @@ mhd_gtls_map_pk_get_pk (gnutls_kx_algorithm_t kx_algorithm) * ex. GNUTLS_KX_RSA requires a certificate able to encrypt... so returns CIPHER_ENCRYPT. */ enum encipher_type -mhd_gtls_kx_encipher_type (gnutls_kx_algorithm_t kx_algorithm) +mhd_gtls_kx_encipher_type (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm) { int ret = CIPHER_IGN; GNUTLS_PK_MAP_ALG_LOOP (ret = p->encipher_type) return ret; @@ -1939,8 +1939,8 @@ struct gnutls_sign_entry const char *name; const char *oid; gnutls_sign_algorithm_t id; - gnutls_pk_algorithm_t pk; - gnutls_mac_algorithm_t mac; + enum MHD_GNUTLS_PublicKeyAlgorithm pk; + enum MHD_GNUTLS_HashAlgorithm mac; }; typedef struct gnutls_sign_entry gnutls_sign_entry; @@ -2005,7 +2005,7 @@ mhd_gtls_x509_oid2sign_algorithm (const char *oid) } gnutls_sign_algorithm_t -mhd_gtls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, gnutls_mac_algorithm_t mac) +mhd_gtls_x509_pk_to_sign (enum MHD_GNUTLS_PublicKeyAlgorithm pk, enum MHD_GNUTLS_HashAlgorithm mac) { gnutls_sign_algorithm_t ret = 0; @@ -2020,8 +2020,8 @@ mhd_gtls_x509_pk_to_sign (gnutls_pk_algorithm_t pk, gnutls_mac_algorithm_t mac) } const char * -mhd_gtls_x509_sign_to_oid (gnutls_pk_algorithm_t pk, - gnutls_mac_algorithm_t mac) +mhd_gtls_x509_sign_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm pk, + enum MHD_GNUTLS_HashAlgorithm mac) { gnutls_sign_algorithm_t sign; const char *ret = NULL; @@ -2040,7 +2040,7 @@ struct gnutls_pk_entry { const char *name; const char *oid; - gnutls_pk_algorithm_t id; + enum MHD_GNUTLS_PublicKeyAlgorithm id; }; typedef struct gnutls_pk_entry gnutls_pk_entry; @@ -2059,10 +2059,10 @@ static const gnutls_pk_entry mhd_gtls_pk_algorithms[] = { 0} }; -gnutls_pk_algorithm_t +enum MHD_GNUTLS_PublicKeyAlgorithm mhd_gtls_x509_oid2pk_algorithm (const char *oid) { - gnutls_pk_algorithm_t ret = MHD_GNUTLS_PK_UNKNOWN; + enum MHD_GNUTLS_PublicKeyAlgorithm ret = MHD_GNUTLS_PK_UNKNOWN; const gnutls_pk_entry *p; for (p = mhd_gtls_pk_algorithms; p->name != NULL; p++) @@ -2076,7 +2076,7 @@ mhd_gtls_x509_oid2pk_algorithm (const char *oid) } const char * -mhd_gtls_x509_pk_to_oid (gnutls_pk_algorithm_t algorithm) +mhd_gtls_x509_pk_to_oid (enum MHD_GNUTLS_PublicKeyAlgorithm algorithm) { const char *ret = NULL; const gnutls_pk_entry *p; diff --git a/src/daemon/https/tls/gnutls_algorithms.h b/src/daemon/https/tls/gnutls_algorithms.h @@ -28,20 +28,20 @@ #include "gnutls_auth.h" /* Functions for version handling. */ -gnutls_protocol_t mhd_gtls_version_lowest (mhd_gtls_session_t session); -gnutls_protocol_t mhd_gtls_version_max (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, - gnutls_protocol_t version); + enum MHD_GNUTLS_Protocol version); int mhd_gtls_version_is_supported (mhd_gtls_session_t session, - const gnutls_protocol_t version); -int mhd_gtls_version_get_major (gnutls_protocol_t ver); -int mhd_gtls_version_get_minor (gnutls_protocol_t ver); -gnutls_protocol_t mhd_gtls_version_get (int major, int minor); + 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); /* Functions for MACs. */ -int mhd_gnutls_mac_is_ok (gnutls_mac_algorithm_t algorithm); -gnutls_mac_algorithm_t mhd_gtls_x509_oid2mac_algorithm (const char *oid); -const char * mhd_gtls_x509_mac_to_oid (gnutls_mac_algorithm_t mac); +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); /* Functions for cipher suites. */ int mhd_gtls_supported_ciphersuites (mhd_gtls_session_t session, @@ -51,62 +51,62 @@ int mhd_gtls_supported_ciphersuites_sorted (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); -gnutls_cipher_algorithm_t mhd_gtls_cipher_suite_get_cipher_algo (const +enum MHD_GNUTLS_CipherAlgorithm mhd_gtls_cipher_suite_get_cipher_algo (const cipher_suite_st * algorithm); -gnutls_kx_algorithm_t mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st +enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_cipher_suite_get_kx_algo (const cipher_suite_st * algorithm); -gnutls_mac_algorithm_t mhd_gtls_cipher_suite_get_mac_algo (const +enum MHD_GNUTLS_HashAlgorithm mhd_gtls_cipher_suite_get_mac_algo (const cipher_suite_st * algorithm); -gnutls_protocol_t mhd_gtls_cipher_suite_get_version (const cipher_suite_st * +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 * algorithm); /* Functions for ciphers. */ -int mhd_gtls_cipher_get_block_size (gnutls_cipher_algorithm_t algorithm); -int mhd_gtls_cipher_is_block (gnutls_cipher_algorithm_t algorithm); -int mhd_gtls_cipher_is_ok (gnutls_cipher_algorithm_t algorithm); -int mhd_gtls_cipher_get_iv_size (gnutls_cipher_algorithm_t algorithm); -int mhd_gtls_cipher_get_export_flag (gnutls_cipher_algorithm_t algorithm); +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 algorithm); /* Functions for key exchange. */ -int mhd_gtls_kx_needs_dh_params (gnutls_kx_algorithm_t algorithm); -int mhd_gtls_kx_needs_rsa_params (gnutls_kx_algorithm_t algorithm); -mhd_gtls_mod_auth_st * mhd_gtls_kx_auth_struct (gnutls_kx_algorithm_t algorithm); -int mhd_gtls_kx_is_ok (gnutls_kx_algorithm_t algorithm); +int mhd_gtls_kx_needs_dh_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm); +int mhd_gtls_kx_needs_rsa_params (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm); +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); /* Functions for compression. */ -int mhd_gtls_compression_is_ok (gnutls_compression_method_t algorithm); -int mhd_gtls_compression_get_num (gnutls_compression_method_t algorithm); -gnutls_compression_method_t mhd_gtls_compression_get_id (int num); -int mhd_gtls_compression_get_mem_level (gnutls_compression_method_t algorithm); -int mhd_gtls_compression_get_comp_level (gnutls_compression_method_t +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 algorithm); +int mhd_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod algorithm); -int mhd_gtls_compression_get_wbits (gnutls_compression_method_t algorithm); +int mhd_gtls_compression_get_wbits (enum MHD_GNUTLS_CompressionMethod algorithm); /* Type to KX mappings. */ -gnutls_kx_algorithm_t mhd_gtls_map_kx_get_kx (gnutls_credentials_type_t type, +enum MHD_GNUTLS_KeyExchangeAlgorithm mhd_gtls_map_kx_get_kx (enum MHD_GNUTLS_CredentialsType type, int server); -gnutls_credentials_type_t mhd_gtls_map_kx_get_cred (gnutls_kx_algorithm_t +enum MHD_GNUTLS_CredentialsType mhd_gtls_map_kx_get_cred (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm, int server); /* KX to PK mapping. */ -gnutls_pk_algorithm_t mhd_gtls_map_pk_get_pk (gnutls_kx_algorithm_t +enum MHD_GNUTLS_PublicKeyAlgorithm mhd_gtls_map_pk_get_pk (enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm); -gnutls_pk_algorithm_t mhd_gtls_x509_oid2pk_algorithm (const char *oid); -const char * mhd_gtls_x509_pk_to_oid (gnutls_pk_algorithm_t pk); +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); enum encipher_type { CIPHER_ENCRYPT = 0, CIPHER_SIGN = 1, CIPHER_IGN }; -enum encipher_type mhd_gtls_kx_encipher_type (gnutls_kx_algorithm_t algorithm); +enum encipher_type mhd_gtls_kx_encipher_type (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm); struct mhd_gtls_compression_entry { const char *name; - gnutls_compression_method_t id; + enum MHD_GNUTLS_CompressionMethod id; int num; /* the number reserved in TLS for the specific compression method */ /* used in zlib compressor */ @@ -118,24 +118,24 @@ typedef struct mhd_gtls_compression_entry 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 (gnutls_pk_algorithm_t pk, - gnutls_mac_algorithm_t mac); -const char * mhd_gtls_x509_sign_to_oid (gnutls_pk_algorithm_t, - gnutls_mac_algorithm_t mac); +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, + enum MHD_GNUTLS_HashAlgorithm mac); int mhd_gtls_mac_priority (mhd_gtls_session_t session, - gnutls_mac_algorithm_t algorithm); + enum MHD_GNUTLS_HashAlgorithm algorithm); int mhd_gtls_cipher_priority (mhd_gtls_session_t session, - gnutls_cipher_algorithm_t algorithm); + enum MHD_GNUTLS_CipherAlgorithm algorithm); int mhd_gtls_kx_priority (mhd_gtls_session_t session, - gnutls_kx_algorithm_t algorithm); + enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm); int mhd_gtls_compression_priority (mhd_gtls_session_t session, - gnutls_compression_method_t algorithm); + enum MHD_GNUTLS_CompressionMethod algorithm); -gnutls_mac_algorithm_t MHD_gtls_mac_get_id (const char* name); -gnutls_cipher_algorithm_t MHD_gtls_cipher_get_id (const char* name); -gnutls_kx_algorithm_t MHD_gtls_kx_get_id (const char* name); -gnutls_protocol_t MHD_gtls_protocol_get_id (const char* name); -gnutls_certificate_type_t MHD_gtls_certificate_type_get_id (const char* name); +enum MHD_GNUTLS_HashAlgorithm MHD_gtls_mac_get_id (const char* name); +enum MHD_GNUTLS_CipherAlgorithm MHD_gtls_cipher_get_id (const char* name); +enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gtls_kx_get_id (const char* name); +enum MHD_GNUTLS_Protocol MHD_gtls_protocol_get_id (const char* name); +enum MHD_GNUTLS_CertificateType MHD_gtls_certificate_type_get_id (const char* name); #endif diff --git a/src/daemon/https/tls/gnutls_auth.c b/src/daemon/https/tls/gnutls_auth.c @@ -91,7 +91,7 @@ MHD_gnutls_credentials_clear (mhd_gtls_session_t session) **/ int MHD_gnutls_credentials_set (mhd_gtls_session_t session, - gnutls_credentials_type_t type, void *cred) + enum MHD_GNUTLS_CredentialsType type, void *cred) { auth_cred_st *ccred = NULL, *pcred = NULL; int exists = 0; @@ -160,7 +160,7 @@ MHD_gnutls_credentials_set (mhd_gtls_session_t session, * Eg. for CERTIFICATE ciphersuites (key exchange algorithms: KX_RSA, KX_DHE_RSA), * the same function are to be used to access the authentication data. **/ -gnutls_credentials_type_t +enum MHD_GNUTLS_CredentialsType MHD_gtls_auth_get_type (mhd_gtls_session_t session) { /* This is not the credentials we must set, but the authentication data @@ -183,7 +183,7 @@ MHD_gtls_auth_get_type (mhd_gtls_session_t session) * to access authentication data. * **/ -gnutls_credentials_type_t +enum MHD_GNUTLS_CredentialsType MHD_gtls_auth_server_get_type (mhd_gtls_session_t session) { return @@ -201,7 +201,7 @@ MHD_gtls_auth_server_get_type (mhd_gtls_session_t session) * to access authentication data. * **/ -gnutls_credentials_type_t +enum MHD_GNUTLS_CredentialsType MHD_gtls_auth_client_get_type (mhd_gtls_session_t session) { return @@ -217,7 +217,7 @@ MHD_gtls_auth_client_get_type (mhd_gtls_session_t session) */ const void * mhd_gtls_get_kx_cred (mhd_gtls_session_t session, - gnutls_kx_algorithm_t algo, int *err) + enum MHD_GNUTLS_KeyExchangeAlgorithm algo, int *err) { int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0; @@ -226,7 +226,7 @@ mhd_gtls_get_kx_cred (mhd_gtls_session_t session, } const void * -mhd_gtls_get_cred (mhd_gtls_key_st key, gnutls_credentials_type_t type, int *err) +mhd_gtls_get_cred (mhd_gtls_key_st key, enum MHD_GNUTLS_CredentialsType type, int *err) { const void *retval = NULL; int _err = -1; @@ -354,7 +354,7 @@ mhd_gtls_free_auth_info (mhd_gtls_session_t session) */ int mhd_gtls_auth_info_set (mhd_gtls_session_t session, - gnutls_credentials_type_t type, int size, + enum MHD_GNUTLS_CredentialsType type, int size, int allow_change) { if (session->key->auth_info == NULL) diff --git a/src/daemon/https/tls/gnutls_auth_int.h b/src/daemon/https/tls/gnutls_auth_int.h @@ -23,10 +23,10 @@ */ const void * mhd_gtls_get_cred (mhd_gtls_key_st key, - gnutls_credentials_type_t kx, int *err); + enum MHD_GNUTLS_CredentialsType kx, int *err); const void * mhd_gtls_get_kx_cred (mhd_gtls_session_t session, - gnutls_kx_algorithm_t algo, int *err); + 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, - gnutls_credentials_type_t type, int size, + enum MHD_GNUTLS_CredentialsType type, int size, int allow_change); diff --git a/src/daemon/https/tls/gnutls_cert.c b/src/daemon/https/tls/gnutls_cert.c @@ -232,12 +232,12 @@ MHD_gnutls_certificate_allocate_credentials (mhd_gtls_cert_credentials_t * */ int mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session, - gnutls_kx_algorithm_t ** alg, + enum MHD_GNUTLS_KeyExchangeAlgorithm ** alg, int *alg_size) { - gnutls_kx_algorithm_t kx; - gnutls_pk_algorithm_t pk; - gnutls_kx_algorithm_t kxlist[MAX_ALGOS]; + enum MHD_GNUTLS_KeyExchangeAlgorithm kx; + enum MHD_GNUTLS_PublicKeyAlgorithm pk; + enum MHD_GNUTLS_KeyExchangeAlgorithm kxlist[MAX_ALGOS]; gnutls_cert *cert; int i; @@ -271,13 +271,13 @@ mhd_gtls_selected_cert_supported_kx (mhd_gtls_session_t session, return GNUTLS_E_INVALID_REQUEST; } - *alg = gnutls_calloc (1, sizeof (gnutls_kx_algorithm_t) * i); + *alg = gnutls_calloc (1, sizeof (enum MHD_GNUTLS_KeyExchangeAlgorithm) * i); if (*alg == NULL) return GNUTLS_E_MEMORY_ERROR; *alg_size = i; - memcpy (*alg, kxlist, i * sizeof (gnutls_kx_algorithm_t)); + memcpy (*alg, kxlist, i * sizeof (enum MHD_GNUTLS_KeyExchangeAlgorithm)); return 0; } @@ -311,7 +311,7 @@ MHD_gtls_certificate_server_set_request (mhd_gtls_session_t session, * 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 gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr_st* st); + * const enum MHD_GNUTLS_PublicKeyAlgorithm* pk_algos, int pk_algos_length, 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. @@ -598,7 +598,7 @@ MHD_gtls_certificate_activation_time_peers (mhd_gtls_session_t session) int mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert, - gnutls_certificate_type_t type, + enum MHD_GNUTLS_CertificateType type, const gnutls_datum_t * raw_cert, int flags /* OR of ConvFlags */ ) { @@ -614,7 +614,7 @@ mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert, int mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key, - gnutls_certificate_type_t type, + enum MHD_GNUTLS_CertificateType type, const gnutls_datum_t * raw_key, int key_enc /* DER or PEM */ ) { @@ -780,7 +780,7 @@ mhd_gtls_gcert_deinit (gnutls_cert * cert) * * typedef int (*gnutls_sign_func) (mhd_gtls_session_t session, * void *userdata, - * gnutls_certificate_type_t cert_type, + * enum MHD_GNUTLS_CertificateType cert_type, * const gnutls_datum_t * cert, * const gnutls_datum_t * hash, * gnutls_datum_t * signature); diff --git a/src/daemon/https/tls/gnutls_cert.h b/src/daemon/https/tls/gnutls_cert.h @@ -61,7 +61,7 @@ typedef struct gnutls_cert */ int params_size; /* holds the size of MPI params */ - gnutls_pk_algorithm_t subject_pk_algorithm; + enum MHD_GNUTLS_PublicKeyAlgorithm subject_pk_algorithm; unsigned int key_usage; /* bits from KEY_* */ @@ -69,7 +69,7 @@ typedef struct gnutls_cert unsigned int version; /* holds the type (PGP, X509) */ - gnutls_certificate_type_t cert_type; + enum MHD_GNUTLS_CertificateType cert_type; gnutls_datum_t raw; @@ -95,7 +95,7 @@ typedef struct gnutls_privkey_int */ int params_size; /* holds the number of params */ - gnutls_pk_algorithm_t pk_algorithm; + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm; } gnutls_privkey; struct MHD_gtls_session_int; /* because mhd_gtls_session_t is not defined when this file is included */ @@ -117,15 +117,15 @@ void mhd_gtls_gkey_deinit (gnutls_privkey * key); void mhd_gtls_gcert_deinit (gnutls_cert * cert); int mhd_gtls_selected_cert_supported_kx (struct MHD_gtls_session_int *session, - gnutls_kx_algorithm_t ** alg, + enum MHD_GNUTLS_KeyExchangeAlgorithm ** alg, int *alg_size); int mhd_gtls_raw_cert_to_gcert (gnutls_cert * gcert, - gnutls_certificate_type_t type, + enum MHD_GNUTLS_CertificateType type, const gnutls_datum_t * raw_cert, int flags /* OR of ConvFlags */ ); int mhd_gtls_raw_privkey_to_gkey (gnutls_privkey * key, - gnutls_certificate_type_t type, + enum MHD_GNUTLS_CertificateType type, const gnutls_datum_t * raw_key, int key_enc /* DER or PEM */ ); diff --git a/src/daemon/https/tls/gnutls_cipher.c b/src/daemon/https/tls/gnutls_cipher.c @@ -194,7 +194,7 @@ mhd_gtls_decrypt (mhd_gtls_session_t session, opaque * ciphertext, } inline static mac_hd_t -mac_init (gnutls_mac_algorithm_t mac, opaque * secret, int secret_size, +mac_init (enum MHD_GNUTLS_HashAlgorithm mac, opaque * secret, int secret_size, int ver) { mac_hd_t td; @@ -304,7 +304,7 @@ mhd_gtls_compressed2ciphertext (mhd_gtls_session_t session, int hash_size = mhd_gnutls_hash_get_algo_len (session->security_parameters. write_mac_algorithm); - gnutls_protocol_t ver; + enum MHD_GNUTLS_Protocol ver; int blocksize = mhd_gtls_cipher_get_block_size (session->security_parameters. write_bulk_cipher_algorithm); @@ -429,7 +429,7 @@ mhd_gtls_ciphertext2compressed (mhd_gtls_session_t session, uint16_t blocksize; int ret, i, pad_failed = 0; uint8_t major, minor; - gnutls_protocol_t ver; + enum MHD_GNUTLS_Protocol ver; int hash_size = mhd_gnutls_hash_get_algo_len (session->security_parameters. read_mac_algorithm); diff --git a/src/daemon/https/tls/gnutls_cipher_int.c b/src/daemon/https/tls/gnutls_cipher_int.c @@ -28,7 +28,7 @@ #include <gnutls_datum.h> cipher_hd_t -mhd_gtls_cipher_init (gnutls_cipher_algorithm_t cipher, +mhd_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher, const gnutls_datum_t * key, const gnutls_datum_t * iv) { cipher_hd_t ret = NULL; diff --git a/src/daemon/https/tls/gnutls_cipher_int.h b/src/daemon/https/tls/gnutls_cipher_int.h @@ -29,7 +29,7 @@ #define GNUTLS_CIPHER_FAILED NULL // TODO gc_cipher_handle -> void * x3 -void * mhd_gtls_cipher_init(gnutls_cipher_algorithm_t cipher, +void * mhd_gtls_cipher_init(enum MHD_GNUTLS_CipherAlgorithm cipher, const gnutls_datum_t * key, const gnutls_datum_t * iv); diff --git a/src/daemon/https/tls/gnutls_compress_int.c b/src/daemon/https/tls/gnutls_compress_int.c @@ -31,7 +31,7 @@ * decompress. */ comp_hd_t -mhd_gtls_comp_init (gnutls_compression_method_t method, int d) +mhd_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d) { comp_hd_t ret; diff --git a/src/daemon/https/tls/gnutls_compress_int.h b/src/daemon/https/tls/gnutls_compress_int.h @@ -34,10 +34,10 @@ typedef struct comp_hd_t_STRUCT { void *handle; - gnutls_compression_method_t algo; + enum MHD_GNUTLS_CompressionMethod algo; } *comp_hd_t; -comp_hd_t mhd_gtls_comp_init (gnutls_compression_method_t, 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, diff --git a/src/daemon/https/tls/gnutls_constate.c b/src/daemon/https/tls/gnutls_constate.c @@ -390,8 +390,8 @@ _gnutls_set_read_keys (mhd_gtls_session_t session) int hash_size; int IV_size; int key_size, export_flag; - gnutls_cipher_algorithm_t algo; - gnutls_mac_algorithm_t mac_algo; + enum MHD_GNUTLS_CipherAlgorithm algo; + enum MHD_GNUTLS_HashAlgorithm mac_algo; mac_algo = session->security_parameters.read_mac_algorithm; algo = session->security_parameters.read_bulk_cipher_algorithm; @@ -411,8 +411,8 @@ _gnutls_set_write_keys (mhd_gtls_session_t session) int hash_size; int IV_size; int key_size, export_flag; - gnutls_cipher_algorithm_t algo; - gnutls_mac_algorithm_t mac_algo; + enum MHD_GNUTLS_CipherAlgorithm algo; + enum MHD_GNUTLS_HashAlgorithm mac_algo; mac_algo = session->security_parameters.write_mac_algorithm; algo = session->security_parameters.write_bulk_cipher_algorithm; @@ -874,7 +874,7 @@ mhd_gtls_write_connection_state_init (mhd_gtls_session_t session) */ int mhd_gtls_set_read_cipher (mhd_gtls_session_t session, - gnutls_cipher_algorithm_t algo) + enum MHD_GNUTLS_CipherAlgorithm algo) { if (mhd_gtls_cipher_is_ok (algo) == 0) @@ -900,7 +900,7 @@ mhd_gtls_set_read_cipher (mhd_gtls_session_t session, int mhd_gtls_set_write_cipher (mhd_gtls_session_t session, - gnutls_cipher_algorithm_t algo) + enum MHD_GNUTLS_CipherAlgorithm algo) { if (mhd_gtls_cipher_is_ok (algo) == 0) @@ -929,7 +929,7 @@ mhd_gtls_set_write_cipher (mhd_gtls_session_t session, */ int mhd_gtls_set_read_compression (mhd_gtls_session_t session, - gnutls_compression_method_t algo) + enum MHD_GNUTLS_CompressionMethod algo) { if (mhd_gtls_compression_is_ok (algo) == 0) @@ -947,7 +947,7 @@ mhd_gtls_set_read_compression (mhd_gtls_session_t session, int mhd_gtls_set_write_compression (mhd_gtls_session_t session, - gnutls_compression_method_t algo) + enum MHD_GNUTLS_CompressionMethod algo) { if (mhd_gtls_compression_is_ok (algo) == 0) @@ -966,7 +966,7 @@ mhd_gtls_set_write_compression (mhd_gtls_session_t session, /* Sets the specified kx algorithm into pending session */ int -mhd_gtls_set_kx (mhd_gtls_session_t session, gnutls_kx_algorithm_t algo) +mhd_gtls_set_kx (mhd_gtls_session_t session, enum MHD_GNUTLS_KeyExchangeAlgorithm algo) { if (mhd_gtls_kx_is_ok (algo) == 0) @@ -991,7 +991,7 @@ mhd_gtls_set_kx (mhd_gtls_session_t session, gnutls_kx_algorithm_t algo) /* Sets the specified mac algorithm into pending session */ int -mhd_gtls_set_read_mac (mhd_gtls_session_t session, gnutls_mac_algorithm_t algo) +mhd_gtls_set_read_mac (mhd_gtls_session_t session, enum MHD_GNUTLS_HashAlgorithm algo) { if (mhd_gnutls_mac_is_ok (algo) == 0) @@ -1015,7 +1015,7 @@ mhd_gtls_set_read_mac (mhd_gtls_session_t session, gnutls_mac_algorithm_t algo) } int -mhd_gtls_set_write_mac (mhd_gtls_session_t session, gnutls_mac_algorithm_t algo) +mhd_gtls_set_write_mac (mhd_gtls_session_t session, enum MHD_GNUTLS_HashAlgorithm algo) { if (mhd_gnutls_mac_is_ok (algo) == 0) diff --git a/src/daemon/https/tls/gnutls_constate.h b/src/daemon/https/tls/gnutls_constate.h @@ -26,15 +26,15 @@ 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, - gnutls_cipher_algorithm_t algo); + enum MHD_GNUTLS_CipherAlgorithm algo); int mhd_gtls_set_write_mac (mhd_gtls_session_t session, - gnutls_mac_algorithm_t algo); + enum MHD_GNUTLS_HashAlgorithm algo); int mhd_gtls_set_read_cipher (mhd_gtls_session_t session, - gnutls_cipher_algorithm_t algo); + enum MHD_GNUTLS_CipherAlgorithm algo); int mhd_gtls_set_read_mac (mhd_gtls_session_t session, - gnutls_mac_algorithm_t algo); + enum MHD_GNUTLS_HashAlgorithm algo); int mhd_gtls_set_read_compression (mhd_gtls_session_t session, - gnutls_compression_method_t algo); + enum MHD_GNUTLS_CompressionMethod algo); int mhd_gtls_set_write_compression (mhd_gtls_session_t session, - gnutls_compression_method_t algo); -int mhd_gtls_set_kx (mhd_gtls_session_t session, gnutls_kx_algorithm_t algo); + enum MHD_GNUTLS_CompressionMethod algo); +int mhd_gtls_set_kx (mhd_gtls_session_t session, enum MHD_GNUTLS_KeyExchangeAlgorithm algo); diff --git a/src/daemon/https/tls/gnutls_handshake.c b/src/daemon/https/tls/gnutls_handshake.c @@ -195,7 +195,7 @@ _gnutls_finished (mhd_gtls_session_t session, int type, void *ret) const char *mesg; mac_hd_t td_md5 = NULL; mac_hd_t td_sha; - gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session); + enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); if (ver < MHD_GNUTLS_TLS1_2) { @@ -271,7 +271,7 @@ mhd_gtls_tls_create_random (opaque * dst) */ int mhd_gtls_negotiate_version (mhd_gtls_session_t session, - gnutls_protocol_t adv_version) + enum MHD_GNUTLS_Protocol adv_version) { int ret; @@ -302,7 +302,7 @@ mhd_gtls_negotiate_version (mhd_gtls_session_t session, int mhd_gtls_user_hello_func (mhd_gtls_session_t session, - gnutls_protocol_t adv_version) + enum MHD_GNUTLS_Protocol adv_version) { int ret; @@ -339,7 +339,7 @@ _gnutls_read_client_hello (mhd_gtls_session_t session, opaque * data, uint8_t session_id_len; int pos = 0, ret = 0; uint16_t suite_size, comp_size; - gnutls_protocol_t adv_version; + enum MHD_GNUTLS_Protocol adv_version; int neg_version; int len = datalen; opaque rnd[TLS_RANDOM_SIZE], *suite_ptr, *comp_ptr; @@ -637,8 +637,8 @@ _gnutls_server_find_pk_algos_in_ciphersuites (const opaque * data, int datalen) { int j; - gnutls_pk_algorithm_t algo = GNUTLS_PK_NONE, prev_algo = 0; - gnutls_kx_algorithm_t kx; + enum MHD_GNUTLS_PublicKeyAlgorithm algo = GNUTLS_PK_NONE, prev_algo = 0; + enum MHD_GNUTLS_KeyExchangeAlgorithm kx; cipher_suite_st cs; if (datalen % 2 != 0) @@ -676,7 +676,7 @@ mhd_gtls_server_select_suite (mhd_gtls_session_t session, opaque * data, int x, i, j; cipher_suite_st *ciphers, cs; int retval, err; - gnutls_pk_algorithm_t pk_algo; /* will hold the pk algorithms + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algo; /* will hold the pk algorithms * supported by the peer. */ @@ -811,7 +811,7 @@ _gnutls_server_select_comp_method (mhd_gtls_session_t session, } memset (&session->internals.compression_method, 0, - sizeof (gnutls_compression_method_t)); + sizeof (enum MHD_GNUTLS_CompressionMethod)); for (j = 0; j < datalen; j++) { @@ -819,7 +819,7 @@ _gnutls_server_select_comp_method (mhd_gtls_session_t session, { if (comps[i] == data[j]) { - gnutls_compression_method_t method = + enum MHD_GNUTLS_CompressionMethod method = mhd_gtls_compression_get_id (comps[i]); session->internals.compression_method = method; @@ -1454,7 +1454,7 @@ _gnutls_read_server_hello (mhd_gtls_session_t session, uint8_t session_id_len = 0; int pos = 0; int ret = 0; - gnutls_protocol_t version; + enum MHD_GNUTLS_Protocol version; int len = datalen; if (datalen < 38) @@ -1672,7 +1672,7 @@ _gnutls_send_client_hello (mhd_gtls_session_t session, int again) int pos = 0; int datalen = 0, ret = 0; opaque rnd[TLS_RANDOM_SIZE]; - gnutls_protocol_t hver; + enum MHD_GNUTLS_Protocol hver; opaque extdata[MAX_EXT_DATA_LENGTH]; opaque *SessionID = @@ -2700,8 +2700,8 @@ mhd_gtls_recv_hello_request (mhd_gtls_session_t session, void *data, */ inline static int check_server_params (mhd_gtls_session_t session, - gnutls_kx_algorithm_t kx, - gnutls_kx_algorithm_t * alg, int alg_size) + enum MHD_GNUTLS_KeyExchangeAlgorithm kx, + enum MHD_GNUTLS_KeyExchangeAlgorithm * alg, int alg_size) { int cred_type; mhd_gtls_dh_params_t dh_params = NULL; @@ -2818,16 +2818,16 @@ int mhd_gtls_remove_unwanted_ciphersuites (mhd_gtls_session_t session, cipher_suite_st ** cipherSuites, int numCipherSuites, - gnutls_pk_algorithm_t requested_pk_algo) + enum MHD_GNUTLS_PublicKeyAlgorithm requested_pk_algo) { int ret = 0; cipher_suite_st *newSuite, cs; int newSuiteSize = 0, i; mhd_gtls_cert_credentials_t cert_cred; - gnutls_kx_algorithm_t kx; + enum MHD_GNUTLS_KeyExchangeAlgorithm kx; int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0; - gnutls_kx_algorithm_t *alg = NULL; + enum MHD_GNUTLS_KeyExchangeAlgorithm *alg = NULL; int alg_size = 0; /* if we should use a specific certificate, @@ -2959,13 +2959,13 @@ MHD_gnutls_handshake_set_max_packet_length (mhd_gtls_session_t session, size_t m } void -mhd_gtls_set_adv_version (mhd_gtls_session_t session, gnutls_protocol_t ver) +mhd_gtls_set_adv_version (mhd_gtls_session_t session, enum MHD_GNUTLS_Protocol ver) { set_adv_version (session, mhd_gtls_version_get_major (ver), mhd_gtls_version_get_minor (ver)); } -gnutls_protocol_t +enum MHD_GNUTLS_Protocol mhd_gtls_get_adv_version (mhd_gtls_session_t session) { return mhd_gtls_version_get (_gnutls_get_adv_version_major (session), diff --git a/src/daemon/https/tls/gnutls_handshake.h b/src/daemon/https/tls/gnutls_handshake.h @@ -44,13 +44,13 @@ 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, - gnutls_pk_algorithm_t); + 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 datalen); -int mhd_gtls_negotiate_version( mhd_gtls_session_t session, gnutls_protocol_t adv_version); -int mhd_gtls_user_hello_func( mhd_gtls_session_t, gnutls_protocol_t adv_version); +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, enum MHD_GNUTLS_Protocol adv_version); #if MHD_DEBUG_TLS int mhd_gtls_handshake_client (mhd_gtls_session_t session); diff --git a/src/daemon/https/tls/gnutls_hash_int.c b/src/daemon/https/tls/gnutls_hash_int.c @@ -31,7 +31,7 @@ #include <gnutls_errors.h> static inline Gc_hash -_gnutls_mac2gc (gnutls_mac_algorithm_t mac) +_gnutls_mac2gc (enum MHD_GNUTLS_HashAlgorithm mac) { switch (mac) { @@ -55,7 +55,7 @@ _gnutls_mac2gc (gnutls_mac_algorithm_t mac) } GNUTLS_HASH_HANDLE -mhd_gtls_hash_init (gnutls_mac_algorithm_t algorithm) +mhd_gtls_hash_init (enum MHD_GNUTLS_HashAlgorithm algorithm) { mac_hd_t ret; int result; @@ -81,7 +81,7 @@ mhd_gtls_hash_init (gnutls_mac_algorithm_t algorithm) } int -mhd_gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm) +mhd_gnutls_hash_get_algo_len (enum MHD_GNUTLS_HashAlgorithm algorithm) { int ret; @@ -144,7 +144,7 @@ mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest) mac_hd_t -mhd_gtls_hmac_init (gnutls_mac_algorithm_t algorithm, +mhd_gtls_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm, const void *key, int keylen) { mac_hd_t ret; @@ -189,7 +189,7 @@ mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest) } inline static int -get_padsize (gnutls_mac_algorithm_t algorithm) +get_padsize (enum MHD_GNUTLS_HashAlgorithm algorithm) { switch (algorithm) { @@ -203,7 +203,7 @@ get_padsize (gnutls_mac_algorithm_t algorithm) } mac_hd_t -mhd_gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key, +mhd_gnutls_mac_init_ssl3 (enum MHD_GNUTLS_HashAlgorithm algorithm, void *key, int keylen) { mac_hd_t ret; diff --git a/src/daemon/https/tls/gnutls_hash_int.h b/src/daemon/https/tls/gnutls_hash_int.h @@ -32,7 +32,7 @@ typedef struct { gc_hash_handle handle; - gnutls_mac_algorithm_t algorithm; + enum MHD_GNUTLS_HashAlgorithm algorithm; const void *key; int keysize; } mac_hd_st; @@ -42,17 +42,17 @@ typedef mac_hd_t GNUTLS_HASH_HANDLE; #define GNUTLS_HASH_FAILED NULL #define GNUTLS_MAC_FAILED NULL -mac_hd_t mhd_gtls_hmac_init (gnutls_mac_algorithm_t algorithm, +mac_hd_t mhd_gtls_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm, const void *key, int keylen); void mhd_gnutls_hmac_deinit (mac_hd_t handle, void *digest); -mac_hd_t mhd_gnutls_mac_init_ssl3 (gnutls_mac_algorithm_t algorithm, void *key, +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); -GNUTLS_HASH_HANDLE mhd_gtls_hash_init (gnutls_mac_algorithm_t algorithm); -int mhd_gnutls_hash_get_algo_len (gnutls_mac_algorithm_t algorithm); +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, size_t textlen); void mhd_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest); diff --git a/src/daemon/https/tls/gnutls_int.h b/src/daemon/https/tls/gnutls_int.h @@ -96,7 +96,7 @@ #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 HASH2MAC(x) ((gnutls_mac_algorithm_t)x) +#define HASH2MAC(x) ((enum MHD_GNUTLS_HashAlgorithm)x) /* TODO rm */ /* Additional cast to bring void* to a type castable to int. */ @@ -171,8 +171,8 @@ typedef enum content_type_t GNUTLS_INNER_APPLICATION = 24 } content_type_t; -#define GNUTLS_PK_ANY (gnutls_pk_algorithm_t)-1 -#define GNUTLS_PK_NONE (gnutls_pk_algorithm_t)-2 +#define GNUTLS_PK_ANY (enum MHD_GNUTLS_PublicKeyAlgorithm)-1 +#define GNUTLS_PK_NONE (enum MHD_GNUTLS_PublicKeyAlgorithm)-2 /* STATE (stop) */ @@ -182,7 +182,7 @@ typedef void (*LOG_FUNC)(int, /* Store & Retrieve functions defines: */ typedef struct mhd_gtls_auth_cred_st { - gnutls_credentials_type_t algorithm; + enum MHD_GNUTLS_CredentialsType algorithm; /* the type of credentials depends on algorithm */ @@ -217,7 +217,7 @@ struct mhd_gtls_key * Rememember that this should be calloced! */ void *auth_info; - gnutls_credentials_type_t auth_info_type; + enum MHD_GNUTLS_CredentialsType auth_info_type; int auth_info_size; /* needed in order to store to db for restoring */ uint8_t crypt_algo; @@ -316,18 +316,18 @@ typedef enum tls_ext_parse_type_t typedef struct { gnutls_connection_end_t entity; - gnutls_kx_algorithm_t kx_algorithm; + 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 * null cipher and we don't */ - gnutls_cipher_algorithm_t read_bulk_cipher_algorithm; - gnutls_mac_algorithm_t read_mac_algorithm; - gnutls_compression_method_t read_compression_algorithm; + enum MHD_GNUTLS_CipherAlgorithm read_bulk_cipher_algorithm; + enum MHD_GNUTLS_HashAlgorithm read_mac_algorithm; + enum MHD_GNUTLS_CompressionMethod read_compression_algorithm; - gnutls_cipher_algorithm_t write_bulk_cipher_algorithm; - gnutls_mac_algorithm_t write_mac_algorithm; - gnutls_compression_method_t write_compression_algorithm; + enum MHD_GNUTLS_CipherAlgorithm write_bulk_cipher_algorithm; + enum MHD_GNUTLS_HashAlgorithm write_mac_algorithm; + enum MHD_GNUTLS_CompressionMethod write_compression_algorithm; /* this is the ciphersuite we are going to use * moved here from internals in order to be restored @@ -348,8 +348,8 @@ typedef struct uint16_t max_record_send_size; uint16_t max_record_recv_size; /* holds the negotiated certificate type */ - gnutls_certificate_type_t cert_type; - gnutls_protocol_t version; /* moved here */ + enum MHD_GNUTLS_CertificateType cert_type; + 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; @@ -465,7 +465,7 @@ typedef struct int last_handshake_out; /* this is the compression method we are going to use */ - gnutls_compression_method_t compression_method; + enum MHD_GNUTLS_CompressionMethod compression_method; /* priorities */ struct MHD_gtls_priority_st priorities; @@ -654,7 +654,7 @@ struct MHD_gtls_session_int /* functions */ void mhd_gtls_set_current_version(mhd_gtls_session_t session, - gnutls_protocol_t version); + enum MHD_GNUTLS_Protocol version); void mhd_gtls_free_auth_info(mhd_gtls_session_t session); @@ -672,7 +672,7 @@ void mhd_gtls_free_auth_info(mhd_gtls_session_t session); session->internals.adv_version_minor = minor void mhd_gtls_set_adv_version(mhd_gtls_session_t, - gnutls_protocol_t); -gnutls_protocol_t mhd_gtls_get_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 */ diff --git a/src/daemon/https/tls/gnutls_priority.c b/src/daemon/https/tls/gnutls_priority.c @@ -35,7 +35,7 @@ /** * MHD_gnutls_cipher_set_priority - Sets the priority on the ciphers supported by gnutls. * @session: is a #mhd_gtls_session_t structure. - * @list: is a 0 terminated list of gnutls_cipher_algorithm_t elements. + * @list: is a 0 terminated list of enum MHD_GNUTLS_CipherAlgorithm elements. * * Sets the priority on the ciphers supported by gnutls. * Priority is higher for elements specified before others. @@ -88,7 +88,7 @@ _set_priority (mhd_gtls_priority_st * st, const int *list) /** * MHD_gnutls_kx_set_priority - Sets the priority on the key exchange algorithms supported by gnutls. * @session: is a #mhd_gtls_session_t structure. - * @list: is a 0 terminated list of gnutls_kx_algorithm_t elements. + * @list: is a 0 terminated list of enum MHD_GNUTLS_KeyExchangeAlgorithm elements. * * Sets the priority on the key exchange algorithms supported by gnutls. * Priority is higher for elements specified before others. @@ -109,7 +109,7 @@ MHD_gnutls_kx_set_priority (mhd_gtls_session_t session, const int *list) /** * MHD_gnutls_mac_set_priority - Sets the priority on the mac algorithms supported by gnutls. * @session: is a #mhd_gtls_session_t structure. - * @list: is a 0 terminated list of gnutls_mac_algorithm_t elements. + * @list: is a 0 terminated list of enum MHD_GNUTLS_HashAlgorithm elements. * * Sets the priority on the mac algorithms supported by gnutls. * Priority is higher for elements specified before others. @@ -130,7 +130,7 @@ MHD_gnutls_mac_set_priority (mhd_gtls_session_t session, const int *list) /** * MHD_gnutls_compression_set_priority - Sets the priority on the compression algorithms supported by gnutls. * @session: is a #mhd_gtls_session_t structure. - * @list: is a 0 terminated list of gnutls_compression_method_t elements. + * @list: is a 0 terminated list of enum MHD_GNUTLS_CompressionMethod elements. * * Sets the priority on the compression algorithms supported by gnutls. * Priority is higher for elements specified before others. @@ -155,7 +155,7 @@ MHD_gnutls_compression_set_priority (mhd_gtls_session_t session, const int *list /** * MHD_gnutls_protocol_set_priority - Sets the priority on the protocol versions supported by gnutls. * @session: is a #mhd_gtls_session_t structure. - * @list: is a 0 terminated list of gnutls_protocol_t elements. + * @list: is a 0 terminated list of enum MHD_GNUTLS_Protocol elements. * * Sets the priority on the protocol versions supported by gnutls. * This function actually enables or disables protocols. Newer protocol @@ -183,7 +183,7 @@ MHD_gnutls_protocol_set_priority (mhd_gtls_session_t session, const int *list) /** * MHD_gnutls_certificate_type_set_priority - Sets the priority on the certificate types supported by gnutls. * @session: is a #mhd_gtls_session_t structure. - * @list: is a 0 terminated list of gnutls_certificate_type_t elements. + * @list: is a 0 terminated list of enum MHD_GNUTLS_CertificateType elements. * * Sets the priority on the certificate types supported by gnutls. * Priority is higher for elements specified before others. diff --git a/src/daemon/https/tls/gnutls_record.c b/src/daemon/https/tls/gnutls_record.c @@ -49,7 +49,7 @@ * * Returns: the version of the currently used protocol. **/ -gnutls_protocol_t +enum MHD_GNUTLS_Protocol MHD_gnutls_protocol_get_version (mhd_gtls_session_t session) { return session->security_parameters.version; @@ -57,7 +57,7 @@ MHD_gnutls_protocol_get_version (mhd_gtls_session_t session) void mhd_gtls_set_current_version (mhd_gtls_session_t session, - gnutls_protocol_t version) + enum MHD_GNUTLS_Protocol version) { session->security_parameters.version = version; } @@ -259,7 +259,7 @@ inline static void copy_record_version (mhd_gtls_session_t session, gnutls_handshake_description_t htype, opaque version[2]) { - gnutls_protocol_t lver; + enum MHD_GNUTLS_Protocol lver; if (htype != GNUTLS_HANDSHAKE_CLIENT_HELLO || session->internals.default_record_version[0] == 0) diff --git a/src/daemon/https/tls/gnutls_sig.c b/src/daemon/https/tls/gnutls_sig.c @@ -56,7 +56,7 @@ mhd_gtls_tls_sign_hdata (mhd_gtls_session_t session, opaque concat[36]; mac_hd_t td_md5; mac_hd_t td_sha; - gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session); + enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); td_sha = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_sha); if (td_sha == NULL) @@ -128,7 +128,7 @@ mhd_gtls_tls_sign_params (mhd_gtls_session_t session, int ret; mac_hd_t td_sha; opaque concat[36]; - gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session); + enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); td_sha = mhd_gtls_hash_init (MHD_GNUTLS_MAC_SHA1); if (td_sha == NULL) @@ -204,7 +204,7 @@ mhd_gtls_tls_sign_params (mhd_gtls_session_t session, * given data. The output will be allocated and be put in signature. */ int -mhd_gtls_sign (gnutls_pk_algorithm_t algo, +mhd_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo, mpi_t * params, int params_size, const gnutls_datum_t * data, gnutls_datum_t * signature) @@ -335,7 +335,7 @@ mhd_gtls_verify_sig_hdata (mhd_gtls_session_t session, mac_hd_t td_md5; mac_hd_t td_sha; gnutls_datum_t dconcat; - gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session); + enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); td_md5 = mhd_gnutls_hash_copy (session->internals.handshake_mac_handle_md5); if (td_md5 == NULL) @@ -402,7 +402,7 @@ mhd_gtls_verify_sig_params (mhd_gtls_session_t session, mac_hd_t td_md5 = NULL; mac_hd_t td_sha; opaque concat[36]; - gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session); + enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); if (ver < MHD_GNUTLS_TLS1_2) { diff --git a/src/daemon/https/tls/gnutls_sig.h b/src/daemon/https/tls/gnutls_sig.h @@ -44,7 +44,7 @@ int mhd_gtls_verify_sig_params (mhd_gtls_session_t session, const gnutls_datum_t * params, gnutls_datum_t * signature); -int mhd_gtls_sign (gnutls_pk_algorithm_t algo, +int mhd_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo, mpi_t * params, int params_size, const gnutls_datum_t * data, gnutls_datum_t * signature); diff --git a/src/daemon/https/tls/gnutls_state.c b/src/daemon/https/tls/gnutls_state.c @@ -44,7 +44,7 @@ void _gnutls_session_cert_type_set (mhd_gtls_session_t session, - gnutls_certificate_type_t ct) + enum MHD_GNUTLS_CertificateType ct) { session->security_parameters.cert_type = ct; } @@ -55,7 +55,7 @@ _gnutls_session_cert_type_set (mhd_gtls_session_t session, * * Returns: the currently used cipher. **/ -gnutls_cipher_algorithm_t +enum MHD_GNUTLS_CipherAlgorithm gnutls_cipher_get (mhd_gtls_session_t session) { return session->security_parameters.read_bulk_cipher_algorithm; @@ -68,10 +68,10 @@ gnutls_cipher_get (mhd_gtls_session_t session) * The certificate type is by default X.509, unless it is negotiated * as a TLS extension. * - * Returns: the currently used %gnutls_certificate_type_t certificate + * Returns: the currently used %enum MHD_GNUTLS_CertificateType certificate * type. **/ -gnutls_certificate_type_t +enum MHD_GNUTLS_CertificateType gnutls_certificate_type_get (mhd_gtls_session_t session) { return session->security_parameters.cert_type; @@ -83,7 +83,7 @@ gnutls_certificate_type_get (mhd_gtls_session_t session) * * Returns: the key exchange algorithm used in the last handshake. **/ -gnutls_kx_algorithm_t +enum MHD_GNUTLS_KeyExchangeAlgorithm gnutls_kx_get (mhd_gtls_session_t session) { return session->security_parameters.kx_algorithm; @@ -95,7 +95,7 @@ gnutls_kx_get (mhd_gtls_session_t session) * * Returns: the currently used mac algorithm. **/ -gnutls_mac_algorithm_t +enum MHD_GNUTLS_HashAlgorithm gnutls_mac_get (mhd_gtls_session_t session) { return session->security_parameters.read_mac_algorithm; @@ -107,7 +107,7 @@ gnutls_mac_get (mhd_gtls_session_t session) * * Returns: the currently used compression method. **/ -gnutls_compression_method_t +enum MHD_GNUTLS_CompressionMethod gnutls_compression_get (mhd_gtls_session_t session) { return session->security_parameters.read_compression_algorithm; @@ -119,7 +119,7 @@ gnutls_compression_get (mhd_gtls_session_t session) */ int mhd_gtls_session_cert_type_supported (mhd_gtls_session_t session, - gnutls_certificate_type_t cert_type) + enum MHD_GNUTLS_CertificateType cert_type) { unsigned i; unsigned cert_found = 0; @@ -656,7 +656,7 @@ MHD_gtls_handshake_set_private_extensions (mhd_gtls_session_t session, int allow } inline static int -_gnutls_cal_PRF_A (gnutls_mac_algorithm_t algorithm, +_gnutls_cal_PRF_A (enum MHD_GNUTLS_HashAlgorithm algorithm, const void *secret, int secret_size, const void *seed, int seed_size, void *result) @@ -682,7 +682,7 @@ _gnutls_cal_PRF_A (gnutls_mac_algorithm_t algorithm, * (used in the PRF function) */ static int -_gnutls_P_hash (gnutls_mac_algorithm_t algorithm, +_gnutls_P_hash (enum MHD_GNUTLS_HashAlgorithm algorithm, const opaque * secret, int secret_size, const opaque * seed, @@ -789,7 +789,7 @@ mhd_gtls_PRF (mhd_gtls_session_t session, opaque s_seed[MAX_SEED_SIZE]; opaque o1[MAX_PRF_BYTES], o2[MAX_PRF_BYTES]; int result; - gnutls_protocol_t ver = MHD_gnutls_protocol_get_version (session); + enum MHD_GNUTLS_Protocol ver = MHD_gnutls_protocol_get_version (session); if (total_bytes > MAX_PRF_BYTES) { @@ -1069,7 +1069,7 @@ MHD_gtls_session_is_resumed (mhd_gtls_session_t session) int mhd_gtls_session_is_export (mhd_gtls_session_t session) { - gnutls_cipher_algorithm_t cipher; + enum MHD_GNUTLS_CipherAlgorithm cipher; cipher = mhd_gtls_cipher_suite_get_cipher_algo (&session->security_parameters. diff --git a/src/daemon/https/tls/gnutls_state.h b/src/daemon/https/tls/gnutls_state.h @@ -28,10 +28,10 @@ #include <gnutls_int.h> void _gnutls_session_cert_type_set (mhd_gtls_session_t session, - gnutls_certificate_type_t); -gnutls_kx_algorithm_t gnutls_kx_get (mhd_gtls_session_t session); -gnutls_cipher_algorithm_t gnutls_cipher_get (mhd_gtls_session_t session); -gnutls_certificate_type_t gnutls_certificate_type_get (mhd_gtls_session_t); + enum MHD_GNUTLS_CertificateType); +enum MHD_GNUTLS_KeyExchangeAlgorithm gnutls_kx_get (mhd_gtls_session_t session); +enum MHD_GNUTLS_CipherAlgorithm gnutls_cipher_get (mhd_gtls_session_t session); +enum MHD_GNUTLS_CertificateType gnutls_certificate_type_get (mhd_gtls_session_t); #include <gnutls_auth_int.h> @@ -43,7 +43,7 @@ gnutls_certificate_type_t gnutls_certificate_type_get (mhd_gtls_session_t); #endif int mhd_gtls_session_cert_type_supported (mhd_gtls_session_t, - gnutls_certificate_type_t); + enum MHD_GNUTLS_CertificateType); int mhd_gtls_dh_set_secret_bits (mhd_gtls_session_t session, unsigned bits); diff --git a/src/daemon/https/tls/gnutls_ui.c b/src/daemon/https/tls/gnutls_ui.c @@ -489,7 +489,7 @@ MHD_gtls_certificate_client_get_request_status (mhd_gtls_session_t session) * **/ int -MHD_gnutls_fingerprint (gnutls_digest_algorithm_t algo, +MHD_gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo, const gnutls_datum_t * data, void *result, size_t * result_size) { diff --git a/src/daemon/https/tls/gnutls_x509.c b/src/daemon/https/tls/gnutls_x509.c @@ -951,11 +951,11 @@ generate_rdn_seq (mhd_gtls_cert_credentials_t res) return 0; } -/* Returns 0 if it's ok to use the gnutls_kx_algorithm_t with this +/* Returns 0 if it's ok to use the enum MHD_GNUTLS_KeyExchangeAlgorithm with this * certificate (uses the KeyUsage field). */ int -_gnutls_check_key_usage (const gnutls_cert * cert, gnutls_kx_algorithm_t alg) +_gnutls_check_key_usage (const gnutls_cert * cert, enum MHD_GNUTLS_KeyExchangeAlgorithm alg) { unsigned int key_usage = 0; int encipher_type; diff --git a/src/daemon/https/tls/gnutls_x509.h b/src/daemon/https/tls/gnutls_x509.h @@ -37,7 +37,7 @@ int _gnutls_x509_cert_verify_peers (mhd_gtls_session_t session, #define PEM_KEY_DSA_SEP "-----BEGIN DSA" int _gnutls_check_key_usage (const gnutls_cert * cert, - gnutls_kx_algorithm_t alg); + enum MHD_GNUTLS_KeyExchangeAlgorithm alg); int _gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params); int _gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params); diff --git a/src/daemon/https/x509/common.c b/src/daemon/https/x509/common.c @@ -1215,7 +1215,7 @@ cleanup:if (val.data != data->data) int _gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst, const char *dst_name, - gnutls_pk_algorithm_t + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm, mpi_t * params, int params_size) { diff --git a/src/daemon/https/x509/common.h b/src/daemon/https/x509/common.h @@ -112,7 +112,7 @@ int _gnutls_x509_get_pk_algorithm (ASN1_TYPE src, const char *src_name, int _gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst, const char *dst_name, - gnutls_pk_algorithm_t + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm, mpi_t * params, int params_size); int _gnutls_asn1_copy_node (ASN1_TYPE * dst, const char *dst_name, diff --git a/src/daemon/https/x509/crl_write.c b/src/daemon/https/x509/crl_write.c @@ -102,7 +102,7 @@ gnutls_x509_crl_set_version (gnutls_x509_crl_t crl, unsigned int version) int gnutls_x509_crl_sign2 (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key, - gnutls_digest_algorithm_t dig, unsigned int flags) + enum MHD_GNUTLS_HashAlgorithm dig, unsigned int flags) { int result; @@ -143,7 +143,7 @@ int gnutls_x509_crl_sign (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key) { - return gnutls_x509_crl_sign2 (crl, issuer, issuer_key, MHD_GNUTLS_DIG_SHA1, + return gnutls_x509_crl_sign2 (crl, issuer, issuer_key, MHD_GNUTLS_MAC_SHA1, 0); } diff --git a/src/daemon/https/x509/crq.c b/src/daemon/https/x509/crq.c @@ -740,7 +740,7 @@ gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t crq, **/ int gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key, - gnutls_digest_algorithm_t dig, unsigned int flags) + enum MHD_GNUTLS_HashAlgorithm dig, unsigned int flags) { int result; gnutls_datum_t signature; @@ -805,7 +805,7 @@ gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key, int gnutls_x509_crq_sign (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key) { - return gnutls_x509_crq_sign2 (crq, key, MHD_GNUTLS_DIG_SHA1, 0); + return gnutls_x509_crq_sign2 (crq, key, MHD_GNUTLS_MAC_SHA1, 0); } /** @@ -857,7 +857,7 @@ gnutls_x509_crq_export (gnutls_x509_crq_t crq, * For DSA the bits returned are of the public * exponent. * - * Returns a member of the gnutls_pk_algorithm_t enumeration on success, + * Returns a member of the enum MHD_GNUTLS_PublicKeyAlgorithm enumeration on success, * or a negative value on error. * **/ diff --git a/src/daemon/https/x509/mpi.c b/src/daemon/https/x509/mpi.c @@ -335,8 +335,8 @@ cleanup:asn1_delete_structure (&spk); int _gnutls_x509_write_sig_params (ASN1_TYPE dst, const char *dst_name, - gnutls_pk_algorithm_t pk_algorithm, - gnutls_digest_algorithm_t dig, + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm, + enum MHD_GNUTLS_HashAlgorithm dig, mpi_t * params, int params_size) { int result; diff --git a/src/daemon/https/x509/mpi.h b/src/daemon/https/x509/mpi.h @@ -52,6 +52,6 @@ int _gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, uint32_t num); int _gnutls_x509_write_sig_params (ASN1_TYPE dst, const char *dst_name, - gnutls_pk_algorithm_t pk_algorithm, - gnutls_digest_algorithm_t, mpi_t * params, + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm, + enum MHD_GNUTLS_HashAlgorithm, mpi_t * params, int params_size); diff --git a/src/daemon/https/x509/privkey_pkcs8.c b/src/daemon/https/x509/privkey_pkcs8.c @@ -63,7 +63,7 @@ struct pbkdf2_params struct pbe_enc_params { - gnutls_cipher_algorithm_t cipher; + enum MHD_GNUTLS_CipherAlgorithm cipher; opaque iv[8]; int iv_size; }; @@ -1284,7 +1284,7 @@ error: /* Converts an OID to a gnutls cipher type. */ inline static int -oid2cipher (const char *oid, gnutls_cipher_algorithm_t * algo) +oid2cipher (const char *oid, enum MHD_GNUTLS_CipherAlgorithm * algo) { *algo = 0; diff --git a/src/daemon/https/x509/sign.c b/src/daemon/https/x509/sign.c @@ -49,14 +49,14 @@ * structure. The digest info is allocated and stored into the info structure. */ static int -encode_ber_digest_info (gnutls_digest_algorithm_t hash, +encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, const gnutls_datum_t * digest, gnutls_datum_t * info) { ASN1_TYPE dinfo = ASN1_TYPE_EMPTY; int result; const char *algo; - algo = mhd_gtls_x509_mac_to_oid ((gnutls_mac_algorithm_t) hash); + algo = mhd_gtls_x509_mac_to_oid ((enum MHD_GNUTLS_HashAlgorithm) hash); if (algo == NULL) { gnutls_assert (); @@ -132,7 +132,7 @@ encode_ber_digest_info (gnutls_digest_algorithm_t hash, * params[1] is public key */ static int -pkcs1_rsa_sign (gnutls_digest_algorithm_t hash, const gnutls_datum_t * text, +pkcs1_rsa_sign (enum MHD_GNUTLS_HashAlgorithm hash, const gnutls_datum_t * text, mpi_t * params, int params_len, gnutls_datum_t * signature) { int ret; @@ -186,7 +186,7 @@ pkcs1_rsa_sign (gnutls_digest_algorithm_t hash, const gnutls_datum_t * text, */ int _gnutls_x509_sign (const gnutls_datum_t * tbs, - gnutls_digest_algorithm_t hash, + enum MHD_GNUTLS_HashAlgorithm hash, gnutls_x509_privkey_t signer, gnutls_datum_t * signature) { int ret; @@ -217,7 +217,7 @@ _gnutls_x509_sign (const gnutls_datum_t * tbs, */ int _gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name, - gnutls_digest_algorithm_t hash, + enum MHD_GNUTLS_HashAlgorithm hash, gnutls_x509_privkey_t signer, gnutls_datum_t * signature) { @@ -268,7 +268,7 @@ _gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name, -*/ int _gnutls_x509_pkix_sign (ASN1_TYPE src, const char *src_name, - gnutls_digest_algorithm_t dig, + enum MHD_GNUTLS_HashAlgorithm dig, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key) { diff --git a/src/daemon/https/x509/sign.h b/src/daemon/https/x509/sign.h @@ -23,14 +23,14 @@ */ int _gnutls_x509_sign (const gnutls_datum_t * tbs, - gnutls_digest_algorithm_t hash, + enum MHD_GNUTLS_HashAlgorithm hash, gnutls_x509_privkey_t signer, gnutls_datum_t * signature); int _gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name, - gnutls_digest_algorithm_t hash, + enum MHD_GNUTLS_HashAlgorithm hash, gnutls_x509_privkey_t signer, gnutls_datum_t * signature); int _gnutls_x509_pkix_sign (ASN1_TYPE src, const char *src_name, - gnutls_digest_algorithm_t, + enum MHD_GNUTLS_HashAlgorithm, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key); diff --git a/src/daemon/https/x509/x509.c b/src/daemon/https/x509/x509.c @@ -858,7 +858,7 @@ gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert, * For DSA the bits returned are of the public * exponent. * - * Returns a member of the gnutls_pk_algorithm_t enumeration on success, + * Returns a member of the enum MHD_GNUTLS_PublicKeyAlgorithm enumeration on success, * or a negative value on error. * **/ @@ -1945,7 +1945,7 @@ gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn, **/ int gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert, - gnutls_digest_algorithm_t algo, + enum MHD_GNUTLS_HashAlgorithm algo, void *buf, size_t * sizeof_buf) { opaque *cert_buf; @@ -2165,7 +2165,7 @@ gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt, return mhd_gtls_asn2err (result); } - result = MHD_gnutls_fingerprint (MHD_GNUTLS_DIG_SHA1, &pubkey, output_data, + result = MHD_gnutls_fingerprint (MHD_GNUTLS_MAC_SHA1, &pubkey, output_data, output_data_size); gnutls_afree (pubkey.data); diff --git a/src/daemon/https/x509/x509.h b/src/daemon/https/x509/x509.h @@ -296,7 +296,7 @@ int gnutls_x509_crt_sign(gnutls_x509_crt_t crt, int gnutls_x509_crt_sign2(gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key, - gnutls_digest_algorithm_t, + enum MHD_GNUTLS_HashAlgorithm, unsigned int flags); int gnutls_x509_crt_set_activation_time(gnutls_x509_crt_t cert, time_t act_time); @@ -435,7 +435,7 @@ int gnutls_x509_crl_sign(gnutls_x509_crl_t crl, int gnutls_x509_crl_sign2(gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key, - gnutls_digest_algorithm_t, + enum MHD_GNUTLS_HashAlgorithm, unsigned int flags); int gnutls_x509_crl_set_this_update(gnutls_x509_crl_t crl, time_t act_time); @@ -556,7 +556,7 @@ int gnutls_x509_crt_check_revocation(gnutls_x509_crt_t cert, int crl_list_length); int gnutls_x509_crt_get_fingerprint(gnutls_x509_crt_t cert, - gnutls_digest_algorithm_t algo, + enum MHD_GNUTLS_HashAlgorithm algo, void *buf, size_t * sizeof_buf); @@ -631,7 +631,7 @@ int gnutls_x509_privkey_get_key_id(gnutls_x509_privkey_t key, size_t * output_data_size); int gnutls_x509_privkey_generate(gnutls_x509_privkey_t key, - gnutls_pk_algorithm_t algo, + enum MHD_GNUTLS_PublicKeyAlgorithm algo, unsigned int bits, unsigned int flags); @@ -656,7 +656,7 @@ int gnutls_x509_privkey_export_rsa_raw(gnutls_x509_privkey_t key, /* Signing stuff. */ int gnutls_x509_privkey_sign_data(gnutls_x509_privkey_t key, - gnutls_digest_algorithm_t digest, + enum MHD_GNUTLS_HashAlgorithm digest, unsigned int flags, const gnutls_datum_t * data, void *signature, @@ -710,7 +710,7 @@ int gnutls_x509_crq_set_key(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key); int gnutls_x509_crq_sign2(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key, - gnutls_digest_algorithm_t, + enum MHD_GNUTLS_HashAlgorithm, unsigned int flags); int gnutls_x509_crq_sign(gnutls_x509_crq_t crq, gnutls_x509_privkey_t key); @@ -800,7 +800,7 @@ typedef struct MHD_gtls_x509_privkey_int */ int params_size; /* holds the number of params */ - gnutls_pk_algorithm_t pk_algorithm; + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm; int crippled; /* The crippled keys will not use the ASN1_TYPE key. * The encoding will only be performed at the export @@ -887,7 +887,7 @@ int gnutls_x509_privkey_init(gnutls_x509_privkey_t * key); void gnutls_x509_privkey_deinit(gnutls_x509_privkey_t key); int gnutls_x509_privkey_generate(gnutls_x509_privkey_t key, - gnutls_pk_algorithm_t algo, + enum MHD_GNUTLS_PublicKeyAlgorithm algo, unsigned int bits, unsigned int flags); diff --git a/src/daemon/https/x509/x509_privkey.c b/src/daemon/https/x509/x509_privkey.c @@ -552,7 +552,7 @@ gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t key, * This function will return the public key algorithm of a private * key. * - * Returns a member of the gnutls_pk_algorithm_t enumeration on success, + * Returns a member of the enum MHD_GNUTLS_PublicKeyAlgorithm enumeration on success, * or a negative value on error. * **/ @@ -1190,7 +1190,7 @@ cleanup:asn1_delete_structure (c2); **/ int gnutls_x509_privkey_generate (gnutls_x509_privkey_t key, - gnutls_pk_algorithm_t algo, + enum MHD_GNUTLS_PublicKeyAlgorithm algo, unsigned int bits, unsigned int flags) { int ret, params_len; @@ -1348,7 +1348,7 @@ cleanup: **/ int gnutls_x509_privkey_sign_data (gnutls_x509_privkey_t key, - gnutls_digest_algorithm_t digest, + enum MHD_GNUTLS_HashAlgorithm digest, unsigned int flags, const gnutls_datum_t * data, void *signature, size_t * signature_size) diff --git a/src/daemon/https/x509/x509_verify.c b/src/daemon/https/x509/x509_verify.c @@ -465,7 +465,7 @@ _gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list, */ static int decode_ber_digest_info (const gnutls_datum_t * info, - gnutls_mac_algorithm_t * hash, + enum MHD_GNUTLS_HashAlgorithm * hash, opaque * digest, int *digest_size) { ASN1_TYPE dinfo = ASN1_TYPE_EMPTY; @@ -547,7 +547,7 @@ _pkcs1_rsa_verify_sig (const gnutls_datum_t * text, const gnutls_datum_t * signature, mpi_t * params, int params_len) { - gnutls_mac_algorithm_t hash = MHD_GNUTLS_MAC_UNKNOWN; + enum MHD_GNUTLS_HashAlgorithm hash = MHD_GNUTLS_MAC_UNKNOWN; int ret; opaque digest[MAX_HASH_SIZE], md[MAX_HASH_SIZE]; int digest_size; @@ -637,7 +637,7 @@ dsa_verify_sig (const gnutls_datum_t * text, static int verify_sig (const gnutls_datum_t * tbs, const gnutls_datum_t * signature, - gnutls_pk_algorithm_t pk, + enum MHD_GNUTLS_PublicKeyAlgorithm pk, mpi_t * issuer_params, int issuer_params_size) { diff --git a/src/daemon/https/x509/x509_write.c b/src/daemon/https/x509/x509_write.c @@ -591,7 +591,7 @@ gnutls_x509_crt_set_proxy (gnutls_x509_crt_t crt, int gnutls_x509_crt_sign2 (gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key, - gnutls_digest_algorithm_t dig, unsigned int flags) + enum MHD_GNUTLS_HashAlgorithm dig, unsigned int flags) { int result; @@ -632,7 +632,7 @@ int gnutls_x509_crt_sign (gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key) { - return gnutls_x509_crt_sign2 (crt, issuer, issuer_key, MHD_GNUTLS_DIG_SHA1, + return gnutls_x509_crt_sign2 (crt, issuer, issuer_key, MHD_GNUTLS_MAC_SHA1, 0); } diff --git a/src/daemon/internal.h b/src/daemon/internal.h @@ -627,7 +627,7 @@ struct MHD_Daemon unsigned short port; #if HTTPS_SUPPORT - gnutls_credentials_type_t cred_type; + enum MHD_GNUTLS_CredentialsType cred_type; /* server x509 credintials */ mhd_gtls_cert_credentials_t x509_cred; diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -343,13 +343,11 @@ enum MHD_OPTION /** * Bind daemon to the supplied sockaddr. this option should be followed by a - * 'struct sockaddr'. Supplying an IPv6 address must be done in conjunction with - * with the 'MHD_USE_IPv6' option. + * 'struct sockaddr *'. If 'MHD_USE_IPv6' is specified, the 'struct sockaddr*' + * should point to a 'struct sockaddr_in6', otherwise to a 'struct sockaddr_in'. */ MHD_OPTION_SOCK_ADDR = 6, - MHD_HTTPS_OPTION_START = 7, - /** * Filename for the private key (key.pem) to be used by the * HTTPS daemon. This option should be followed by an @@ -357,7 +355,7 @@ enum MHD_OPTION * not be released until the application terminates. * This should be used in conjunction with 'MHD_OPTION_HTTPS_CERT_PATH'. */ - MHD_OPTION_HTTPS_KEY_PATH, + MHD_OPTION_HTTPS_KEY_PATH = 7, /** * Filename for the certificate (cert.pem) to be used by the @@ -366,70 +364,79 @@ enum MHD_OPTION * not be released until the application terminates. * This should be used in conjunction with 'MHD_OPTION_HTTPS_KEY_PATH'. */ - MHD_OPTION_HTTPS_CERT_PATH, + MHD_OPTION_HTTPS_CERT_PATH = 8, /** - * Memory pointer for the private key (key.pem) to be used by the - * HTTPS daemon. This option should be followed by an - * "const char*" argument. - * This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_CERT'. - */ - MHD_OPTION_HTTPS_MEM_KEY, - + * Memory pointer for the private key (key.pem) to be used by the + * HTTPS daemon. This option should be followed by an + * "const char*" argument. + * This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_CERT'. + */ + MHD_OPTION_HTTPS_MEM_KEY = 9, + /** - * Memory pointer for the certificate (cert.pem) to be used by the - * HTTPS daemon. This option should be followed by an - * "const char*" argument. - * This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_KEY'. - */ - MHD_OPTION_HTTPS_MEM_CERT, + * Memory pointer for the certificate (cert.pem) to be used by the + * HTTPS daemon. This option should be followed by an + * "const char*" argument. + * This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_KEY'. + */ + MHD_OPTION_HTTPS_MEM_CERT = 10, - /* - * daemon credentials type. either certificate or anonymous, + /** + * Daemon credentials type. Either certificate or anonymous, * this option should be followed by one of the values listed in - * gnutls_credentials_type_t. + * "enum MHD_GNUTLS_CredentialsType". */ - MHD_OPTION_CRED_TYPE, + MHD_OPTION_CRED_TYPE = 11, - /* - * SSL/TLS protocol version + /** + * SSL/TLS protocol version. * - * Memory pointer to a zero terminated int array representing the + * Memory pointer to a zero (MHD_GNUTLS_PROTOCOL_END) terminated + * (const) array of 'enum MHD_GNUTLS_Protocol' values representing the * protocol versions to this server should support. Unsupported - * requests will be droped by the server. + * requests will be droped by the server. */ - MHD_OPTION_PROTOCOL_VERSION, + MHD_OPTION_PROTOCOL_VERSION = 12, - /* - * Memory pointer to a zero terminated int array representing the - * cipher priority order to which the HTTPS daemon should adhere. - * "const int *" argument. + /** + * Memory pointer to a zero (MHD_GNUTLS_CIPHER_UNKNOWN) + * terminated (const) array of 'enum MHD_GNUTLS_CipherAlgorithm' + * representing the cipher priority order to which the HTTPS + * daemon should adhere. */ - MHD_OPTION_CIPHER_ALGORITHM, + MHD_OPTION_CIPHER_ALGORITHM = 13, - /* - * Memory pointer to a zero terminated int array representing the + /** + * Memory pointer to a zero (MHD_GNUTLS_KX_UNKNOWN) + * terminated (const) array of 'MHD_GNUTLS_KeyExchangeAlgorithm' representing the * key exchange algorithm priority order to which the HTTPS daemon should adhere. - * "const int *" argument. */ - MHD_OPTION_KX_PRIORITY, + MHD_OPTION_KX_PRIORITY = 14, - /* - * used to indicate which type of certificate this server will use, + /** + * Indicate which type of certificate this server will use, + * followed by a value of type 'enum MHD_GNUTLS_CertificateType'. */ - MHD_OPTION_CRET_TYPE, + MHD_OPTION_CERT_TYPE = 15, - /* - * mac algorithm used by server + /** + * Specify the mac algorithm used by server. + * The argument should be of type "enum MHD_GNUTLS_MacAlgorithm" */ - MHD_OPTION_MAC_ALGO, + MHD_OPTION_MAC_ALGO = 16, - /* - * compression algorithm used by server + /** + * Compression algorithm used by server. Should be followed by an + * option of type 'enum MHD_GNUTLS_CompressionMethod'. */ - MHD_OPTION_TLS_COMP_ALGO, + MHD_OPTION_TLS_COMP_ALGO = 17, - MHD_HTTPS_OPTION_END + /** + * This value is used to indicate the end of the + * list of vararg options. + */ + MHD_HTTPS_OPTION_END = -1 }; /** @@ -509,23 +516,198 @@ enum MHD_RequestTerminationCode */ MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3, -#if HTTPS_SUPPORT - /* - * this is the final state of a successfully processed secure connection - */ - MHD_TLS_REQUEST_TERMINATED_COMPLETED_OK, + /* FIXME: add TLS-specific error codes, + but only those that are useful! */ + /** + * Processing of this secure connection encountered + * an error. + */ + MHD_TLS_REQUEST_TERMINATED_WITH_ERROR, + + MHD_TLS_REQUEST_TERMINATED_WITH_FATAL_ALERT - /* - * processing of this secure connection encountered an error - */ - /* TODO consider elaborating error cause & registering a error callback */ - MHD_TLS_REQUEST_TERMINATED_WITH_ERROR, +}; - MHD_TLS_REQUEST_TERMINATED_WITH_FATAL_ALERT, -#endif +/** + * Which symmetric cipher should be used by HTTPS? + * Note that not all listed algorithms are necessarily + * supported by all builds of MHD. + */ +enum MHD_GNUTLS_CipherAlgorithm +{ + MHD_GNUTLS_CIPHER_UNKNOWN = 0, + MHD_GNUTLS_CIPHER_NULL = 1, + MHD_GNUTLS_CIPHER_ARCFOUR_128, + MHD_GNUTLS_CIPHER_3DES_CBC, + MHD_GNUTLS_CIPHER_AES_128_CBC, + MHD_GNUTLS_CIPHER_AES_256_CBC, + MHD_GNUTLS_CIPHER_ARCFOUR_40, + MHD_GNUTLS_CIPHER_CAMELLIA_128_CBC, + MHD_GNUTLS_CIPHER_CAMELLIA_256_CBC, + MHD_GNUTLS_CIPHER_RC2_40_CBC = 90, + MHD_GNUTLS_CIPHER_DES_CBC +}; // enum MHD_GNUTLS_CipherAlgorithm; + +/** + * Which public key algorithm should be used + * for the key exchange? + * Note that not all listed algorithms are necessarily + * supported by all builds of MHD. + */ +enum MHD_GNUTLS_KeyExchangeAlgorithm +{ + MHD_GNUTLS_KX_UNKNOWN = 0, + MHD_GNUTLS_KX_RSA = 1, + MHD_GNUTLS_KX_DHE_DSS, + MHD_GNUTLS_KX_DHE_RSA, + MHD_GNUTLS_KX_ANON_DH, + MHD_GNUTLS_KX_SRP, + MHD_GNUTLS_KX_RSA_EXPORT, + MHD_GNUTLS_KX_SRP_RSA, + MHD_GNUTLS_KX_SRP_DSS }; /** + * Server credentials type + */ +enum MHD_GNUTLS_CredentialsType +{ + MHD_GNUTLS_CRD_CERTIFICATE = 1, + MHD_GNUTLS_CRD_ANON, + MHD_GNUTLS_CRD_SRP, + MHD_GNUTLS_CRD_PSK, + MHD_GNUTLS_CRD_IA +}; + +/** + * Enumeration of possible cryptographic + * hash functions (for MAC and Digest operations). + */ +enum MHD_GNUTLS_HashAlgorithm +{ + MHD_GNUTLS_MAC_UNKNOWN = 0, + MHD_GNUTLS_MAC_NULL = 1, + MHD_GNUTLS_MAC_MD5, + MHD_GNUTLS_MAC_SHA1, + MHD_GNUTLS_MAC_SHA256 + //GNUTLS_MAC_SHA384, + //GNUTLS_MAC_SHA512 +}; + +/** + * Compression methods. + */ +enum MHD_GNUTLS_CompressionMethod +{ + MHD_GNUTLS_COMP_UNKNOWN = 0, + MHD_GNUTLS_COMP_NULL = 1, + MHD_GNUTLS_COMP_DEFLATE +}; + +/** + * SSL/TLS Protocol types. + */ +enum MHD_GNUTLS_Protocol +{ + MHD_GNUTLS_PROTOCOL_END = 0, + MHD_GNUTLS_SSL3 = 1, + MHD_GNUTLS_TLS1_0, + MHD_GNUTLS_TLS1_1, + MHD_GNUTLS_TLS1_2, + MHD_GNUTLS_VERSION_UNKNOWN = 0xff +}; + +/** + * Specify what type of certificate should be used. + */ +enum MHD_GNUTLS_CertificateType +{ + MHD_GNUTLS_CRT_UNKNOWN = 0, + MHD_GNUTLS_CRT_X509 = 1 +}; + +enum MHD_GNUTLS_PublicKeyAlgorithm +{ + MHD_GNUTLS_PK_UNKNOWN = 0, + MHD_GNUTLS_PK_RSA = 1 + //GNUTLS_PK_DSA +}; + +/** + * Values of this enum are used to specify what + * information about a connection is desired. + */ +enum MHD_ConnectionInfoType +{ + /** + * What cipher algorithm is being used. + * Takes no extra arguments. + */ + MHD_SESSION_INFO_CIPHER_ALGO, + + /** + * What key exchange algorithm is being used. + * Takes no extra arguments. + */ + MHD_SESSION_INFO_KX_ALGO, + + /** + * + * Takes no extra arguments. + */ + MHD_SESSION_INFO_CREDENTIALS_TYPE, + + /** + * + * Takes no extra arguments. + */ + MHD_SESSION_INFO_MAC_ALGO, + + /** + * What compression method is being used. + * Takes no extra arguments. + */ + MHD_SESSION_INFO_COMPRESSION_METHOD, + + /** + * + * Takes no extra arguments. + */ + MHD_SESSION_INFO_PROTOCOL, + + /** + * + * Takes no extra arguments. + */ + MHD_SESSION_INFO_CERT_TYPE +}; + +/** + * Values of this enum are used to specify what + * information about a deamon is desired. + */ +enum MHD_DaemonInfoType +{ + /** + * Request information about the key size for + * a particular cipher algorithm. The cipher + * algorithm should be passed as an extra + * argument (of type 'enum MHD_GNUTLS_CipherAlgorithm'). + */ + MHD_DAEMON_INFO_KEY_SIZE, + + /** + * Request information about the key size for + * a particular cipher algorithm. The cipher + * algorithm should be passed as an extra + * argument (of type 'enum MHD_GNUTLS_HashAlgorithm'). + */ + MHD_DAEMON_INFO_MAC_KEY_SIZE +}; + + + +/** * Handle for the daemon (listening on a socket for HTTP traffic). */ struct MHD_Daemon; @@ -1004,140 +1186,66 @@ MHD_post_process (struct MHD_PostProcessor *pp, */ int MHD_destroy_post_processor (struct MHD_PostProcessor *pp); -/* - * HTTPS - */ -typedef enum MHD_GNUTLS_cipher_algorithm +/** + * Information about a connection. + */ +union MHD_ConnectionInfo { - MHD_GNUTLS_CIPHER_UNKNOWN = 0, - MHD_GNUTLS_CIPHER_NULL = 1, - MHD_GNUTLS_CIPHER_ARCFOUR_128, - MHD_GNUTLS_CIPHER_3DES_CBC, - MHD_GNUTLS_CIPHER_AES_128_CBC, - MHD_GNUTLS_CIPHER_AES_256_CBC, - MHD_GNUTLS_CIPHER_ARCFOUR_40, - MHD_GNUTLS_CIPHER_CAMELLIA_128_CBC, - MHD_GNUTLS_CIPHER_CAMELLIA_256_CBC, - MHD_GNUTLS_CIPHER_RC2_40_CBC = 90, - MHD_GNUTLS_CIPHER_DES_CBC -} gnutls_cipher_algorithm_t; + enum MHD_GNUTLS_CipherAlgorithm cipher_algorithm; + enum MHD_GNUTLS_KeyExchangeAlgorithm kx_algorithm; + enum MHD_GNUTLS_CredentialsType credentials_type; + enum MHD_GNUTLS_HashAlgorithm mac_algorithm; + enum MHD_GNUTLS_CompressionMethod compression_method; + enum MHD_GNUTLS_Protocol protocol; + enum MHD_GNUTLS_CertificateType certificate_type; + enum MHD_GNUTLS_PublicKeyAlgorithm pk_algorithm; +}; -typedef enum -{ - MHD_GNUTLS_KX_UNKNOWN = 0, - MHD_GNUTLS_KX_RSA = 1, - MHD_GNUTLS_KX_DHE_DSS, - MHD_GNUTLS_KX_DHE_RSA, - MHD_GNUTLS_KX_ANON_DH, - MHD_GNUTLS_KX_SRP, - MHD_GNUTLS_KX_RSA_EXPORT, - MHD_GNUTLS_KX_SRP_RSA, - MHD_GNUTLS_KX_SRP_DSS -} gnutls_kx_algorithm_t; +/** + * Obtain information about the given connection. + * + * @param connection what connection to get information about + * @param infoType what information is desired? + * @param ... depends on infoType + * @return NULL if this information is not available + * (or if the infoType is unknown) + */ +const union MHD_ConnectionInfo * +MHD_get_connection_info (struct MHD_Connection * connection, + enum MHD_ConnectionInfoType infoType, + ...); -/* server credentials type */ -typedef enum -{ - MHD_GNUTLS_CRD_CERTIFICATE = 1, - MHD_GNUTLS_CRD_ANON, - MHD_GNUTLS_CRD_SRP, - MHD_GNUTLS_CRD_PSK, - MHD_GNUTLS_CRD_IA -} gnutls_credentials_type_t; -/* mac algorithm */ -typedef enum +/** + * Information about an MHD daemon. + */ +union MHD_DaemonInfo { - MHD_GNUTLS_MAC_UNKNOWN = 0, - MHD_GNUTLS_MAC_NULL = 1, - MHD_GNUTLS_MAC_MD5, - MHD_GNUTLS_MAC_SHA1, - MHD_GNUTLS_MAC_SHA256 - //GNUTLS_MAC_SHA384, - //GNUTLS_MAC_SHA512 -} gnutls_mac_algorithm_t; - - /* The enumerations here should have the same value with - gnutls_mac_algorithm_t. + /** + * Size of the key (unit??) */ -typedef enum -{ - MHD_GNUTLS_DIG_NULL = MHD_GNUTLS_MAC_NULL, - MHD_GNUTLS_DIG_MD5 = MHD_GNUTLS_MAC_MD5, - MHD_GNUTLS_DIG_SHA1 = MHD_GNUTLS_MAC_SHA1, - MHD_GNUTLS_DIG_SHA256 = MHD_GNUTLS_MAC_SHA256 -} gnutls_digest_algorithm_t; - -/* compression method */ -typedef enum -{ - MHD_GNUTLS_COMP_UNKNOWN = 0, - MHD_GNUTLS_COMP_NULL = 1, - MHD_GNUTLS_COMP_DEFLATE, - MHD_GNUTLS_COMP_LZO /* only available if gnutls-extra has - been initialized - */ -} gnutls_compression_method_t; - -/* protocol type */ -typedef enum -{ - MHD_GNUTLS_SSL3 = 1, - MHD_GNUTLS_TLS1_0, - MHD_GNUTLS_TLS1_1, - MHD_GNUTLS_TLS1_2, - MHD_GNUTLS_VERSION_UNKNOWN = 0xff -} gnutls_protocol_t; - -/* certificate_type */ -typedef enum -{ - MHD_GNUTLS_CRT_UNKNOWN = 0, - MHD_GNUTLS_CRT_X509 = 1 -} gnutls_certificate_type_t; + size_t key_size; -typedef enum -{ - MHD_GNUTLS_PK_UNKNOWN = 0, - MHD_GNUTLS_PK_RSA = 1 - //GNUTLS_PK_DSA -} gnutls_pk_algorithm_t; - -union MHD_SessionInfo -{ - gnutls_cipher_algorithm_t cipher_algorithm; - gnutls_kx_algorithm_t kx_algorithm; - gnutls_credentials_type_t credentials_type; - gnutls_mac_algorithm_t mac_algorithm; - gnutls_compression_method_t compression_method; - gnutls_protocol_t protocol; - gnutls_certificate_type_t certificate_type; - gnutls_pk_algorithm_t pk_algorithm; - int null_info; -}; - -enum MHD_InfoType -{ - MHS_INFO_CIPHER_ALGO, - MHD_INFO_KX_ALGO, - MHD_INFO_CREDENTIALS_TYPE, - MHD_INFO_MAC_ALGO, - MHD_INFO_COMPRESSION_METHOD, - MHD_INFO_PROTOCOL, - MHD_INFO_CERT_TYPE + /** + * Size of the mac key (unit??) + */ + size_t mac_key_size; }; -union MHD_SessionInfo -MHD_get_session_info ( struct MHD_Connection * connection, enum MHD_InfoType infoType); - -/* TODO impl */ -size_t MHDS_get_key_size (struct MHD_Daemon *daemon, - gnutls_cipher_algorithm_t algorithm); -size_t MHDS_get_mac_key_size (struct MHD_Daemon *daemon, - gnutls_mac_algorithm_t algorithm); - - +/** + * Obtain information about the given daemon. + * + * @param daemon what daemon to get information about + * @param infoType what information is desired? + * @param ... depends on infoType + * @return NULL if this information is not available + * (or if the infoType is unknown) + */ +const union MHD_DaemonInfo * +MHD_get_daemon_info (struct MHD_Daemon * daemon, + enum MHD_DaemonInfoType infoType, + ...); #if 0 /* keep Emacsens' auto-indent happy */ { diff --git a/src/testcurl/daemon_options_test.c b/src/testcurl/daemon_options_test.c @@ -50,12 +50,9 @@ int test_wrap (char *test_name, int (*test) (void)) { int ret; - va_list arg_list; - struct MHD_Daemon *d; fprintf (stdout, "running test: %s ", test_name); ret = test (); - if (ret == 0) { fprintf (stdout, "[pass]\n"); diff --git a/src/testcurl/https/Makefile.am b/src/testcurl/https/Makefile.am @@ -21,7 +21,7 @@ if MHD_DEBUG_TLS tls_cipher_change_test \ tls_alert_test endif - + TESTS = $(check_PROGRAMS) # cURL independent tests @@ -64,7 +64,7 @@ mhds_session_info_test_LDADD = \ $(top_builddir)/src/testcurl/libcurl_version_check.a \ $(top_builddir)/src/daemon/libmicrohttpd.la \ @LIBCURL@ - + mhds_multi_daemon_test_SOURCES = \ mhds_multi_daemon_test.c mhds_multi_daemon_test_LDADD = \